@rjsf/utils 5.11.1 → 5.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. package/dist/index.js +2544 -5
  2. package/dist/index.js.map +7 -0
  3. package/dist/utils.esm.js +1228 -2105
  4. package/dist/utils.esm.js.map +7 -1
  5. package/dist/utils.umd.js +2414 -0
  6. package/lib/ErrorSchemaBuilder.d.ts +60 -0
  7. package/lib/ErrorSchemaBuilder.js +103 -0
  8. package/lib/ErrorSchemaBuilder.js.map +1 -0
  9. package/lib/allowAdditionalItems.d.ts +8 -0
  10. package/lib/allowAdditionalItems.js +14 -0
  11. package/lib/allowAdditionalItems.js.map +1 -0
  12. package/lib/asNumber.d.ts +10 -0
  13. package/lib/asNumber.js +36 -0
  14. package/lib/asNumber.js.map +1 -0
  15. package/lib/canExpand.d.ts +11 -0
  16. package/lib/canExpand.js +26 -0
  17. package/lib/canExpand.js.map +1 -0
  18. package/lib/constants.d.ts +31 -0
  19. package/lib/constants.js +32 -0
  20. package/lib/constants.js.map +1 -0
  21. package/lib/createErrorHandler.d.ts +7 -0
  22. package/lib/createErrorHandler.js +31 -0
  23. package/lib/createErrorHandler.js.map +1 -0
  24. package/lib/createSchemaUtils.d.ts +10 -0
  25. package/lib/createSchemaUtils.js +207 -0
  26. package/lib/createSchemaUtils.js.map +1 -0
  27. package/lib/dataURItoBlob.d.ts +16 -0
  28. package/lib/dataURItoBlob.js +43 -0
  29. package/lib/dataURItoBlob.js.map +1 -0
  30. package/lib/deepEquals.d.ts +8 -0
  31. package/lib/deepEquals.js +19 -0
  32. package/lib/deepEquals.js.map +1 -0
  33. package/lib/englishStringTranslator.d.ts +10 -0
  34. package/lib/englishStringTranslator.js +13 -0
  35. package/lib/englishStringTranslator.js.map +1 -0
  36. package/lib/enumOptionsDeselectValue.d.ts +14 -0
  37. package/lib/enumOptionsDeselectValue.js +22 -0
  38. package/lib/enumOptionsDeselectValue.js.map +1 -0
  39. package/lib/enumOptionsIndexForValue.d.ts +13 -0
  40. package/lib/enumOptionsIndexForValue.js +22 -0
  41. package/lib/enumOptionsIndexForValue.js.map +1 -0
  42. package/lib/enumOptionsIsSelected.d.ts +8 -0
  43. package/lib/enumOptionsIsSelected.js +14 -0
  44. package/lib/enumOptionsIsSelected.js.map +1 -0
  45. package/lib/enumOptionsSelectValue.d.ts +10 -0
  46. package/lib/enumOptionsSelectValue.js +23 -0
  47. package/lib/enumOptionsSelectValue.js.map +1 -0
  48. package/lib/enumOptionsValueForIndex.d.ts +13 -0
  49. package/lib/enumOptionsValueForIndex.js +21 -0
  50. package/lib/enumOptionsValueForIndex.js.map +1 -0
  51. package/lib/enums.d.ts +72 -0
  52. package/lib/enums.js +76 -0
  53. package/lib/enums.js.map +1 -0
  54. package/lib/findSchemaDefinition.d.ts +20 -0
  55. package/lib/findSchemaDefinition.js +49 -0
  56. package/lib/findSchemaDefinition.js.map +1 -0
  57. package/lib/getDiscriminatorFieldFromSchema.d.ts +8 -0
  58. package/lib/getDiscriminatorFieldFromSchema.js +20 -0
  59. package/lib/getDiscriminatorFieldFromSchema.js.map +1 -0
  60. package/lib/getInputProps.d.ts +10 -0
  61. package/lib/getInputProps.js +41 -0
  62. package/lib/getInputProps.js.map +1 -0
  63. package/lib/getSchemaType.d.ts +13 -0
  64. package/lib/getSchemaType.js +29 -0
  65. package/lib/getSchemaType.js.map +1 -0
  66. package/lib/getSubmitButtonOptions.d.ts +10 -0
  67. package/lib/getSubmitButtonOptions.js +25 -0
  68. package/lib/getSubmitButtonOptions.js.map +1 -0
  69. package/lib/getTemplate.d.ts +10 -0
  70. package/lib/getTemplate.js +19 -0
  71. package/lib/getTemplate.js.map +1 -0
  72. package/lib/getUiOptions.d.ts +9 -0
  73. package/lib/getUiOptions.js +25 -0
  74. package/lib/getUiOptions.js.map +1 -0
  75. package/lib/getWidget.d.ts +13 -0
  76. package/lib/getWidget.js +118 -0
  77. package/lib/getWidget.js.map +1 -0
  78. package/lib/guessType.d.ts +7 -0
  79. package/lib/guessType.js +29 -0
  80. package/lib/guessType.js.map +1 -0
  81. package/lib/hasWidget.d.ts +10 -0
  82. package/lib/hasWidget.js +23 -0
  83. package/lib/hasWidget.js.map +1 -0
  84. package/lib/hashForSchema.d.ts +8 -0
  85. package/lib/hashForSchema.js +29 -0
  86. package/lib/hashForSchema.js.map +1 -0
  87. package/lib/idGenerators.d.ts +47 -0
  88. package/lib/idGenerators.js +73 -0
  89. package/lib/idGenerators.js.map +1 -0
  90. package/lib/index.d.ts +57 -0
  91. package/lib/index.js +58 -0
  92. package/lib/index.js.map +1 -0
  93. package/lib/isConstant.d.ts +8 -0
  94. package/lib/isConstant.js +11 -0
  95. package/lib/isConstant.js.map +1 -0
  96. package/lib/isCustomWidget.d.ts +7 -0
  97. package/lib/isCustomWidget.js +13 -0
  98. package/lib/isCustomWidget.js.map +1 -0
  99. package/lib/isFixedItems.d.ts +8 -0
  100. package/lib/isFixedItems.js +11 -0
  101. package/lib/isFixedItems.js.map +1 -0
  102. package/lib/isObject.d.ts +7 -0
  103. package/lib/isObject.js +16 -0
  104. package/lib/isObject.js.map +1 -0
  105. package/lib/labelValue.d.ts +13 -0
  106. package/lib/labelValue.js +4 -0
  107. package/lib/labelValue.js.map +1 -0
  108. package/lib/localToUTC.d.ts +6 -0
  109. package/lib/localToUTC.js +9 -0
  110. package/lib/localToUTC.js.map +1 -0
  111. package/lib/mergeDefaultsWithFormData.d.ts +17 -0
  112. package/lib/mergeDefaultsWithFormData.js +43 -0
  113. package/lib/mergeDefaultsWithFormData.js.map +1 -0
  114. package/lib/mergeObjects.d.ts +11 -0
  115. package/lib/mergeObjects.js +35 -0
  116. package/lib/mergeObjects.js.map +1 -0
  117. package/lib/mergeSchemas.d.ts +10 -0
  118. package/lib/mergeSchemas.js +35 -0
  119. package/lib/mergeSchemas.js.map +1 -0
  120. package/lib/optionsList.d.ts +10 -0
  121. package/lib/optionsList.js +36 -0
  122. package/lib/optionsList.js.map +1 -0
  123. package/lib/orderProperties.d.ts +11 -0
  124. package/lib/orderProperties.js +38 -0
  125. package/lib/orderProperties.js.map +1 -0
  126. package/lib/pad.d.ts +7 -0
  127. package/lib/pad.js +14 -0
  128. package/lib/pad.js.map +1 -0
  129. package/lib/parseDateString.d.ts +9 -0
  130. package/lib/parseDateString.js +32 -0
  131. package/lib/parseDateString.js.map +1 -0
  132. package/lib/parser/ParserValidator.d.ts +70 -0
  133. package/lib/parser/ParserValidator.js +93 -0
  134. package/lib/parser/ParserValidator.js.map +1 -0
  135. package/lib/parser/index.d.ts +4 -0
  136. package/lib/parser/index.js +3 -0
  137. package/lib/parser/index.js.map +1 -0
  138. package/lib/parser/schemaParser.d.ts +9 -0
  139. package/lib/parser/schemaParser.js +48 -0
  140. package/lib/parser/schemaParser.js.map +1 -0
  141. package/lib/rangeSpec.d.ts +9 -0
  142. package/lib/rangeSpec.js +20 -0
  143. package/lib/rangeSpec.js.map +1 -0
  144. package/lib/replaceStringParameters.d.ts +9 -0
  145. package/lib/replaceStringParameters.js +23 -0
  146. package/lib/replaceStringParameters.js.map +1 -0
  147. package/lib/schema/getClosestMatchingOption.d.ts +49 -0
  148. package/lib/schema/getClosestMatchingOption.js +154 -0
  149. package/lib/schema/getClosestMatchingOption.js.map +1 -0
  150. package/lib/schema/getDefaultFormState.d.ts +66 -0
  151. package/lib/schema/getDefaultFormState.js +351 -0
  152. package/lib/schema/getDefaultFormState.js.map +1 -0
  153. package/lib/schema/getDisplayLabel.d.ts +12 -0
  154. package/lib/schema/getDisplayLabel.js +39 -0
  155. package/lib/schema/getDisplayLabel.js.map +1 -0
  156. package/lib/schema/getFirstMatchingOption.d.ts +13 -0
  157. package/lib/schema/getFirstMatchingOption.js +16 -0
  158. package/lib/schema/getFirstMatchingOption.js.map +1 -0
  159. package/lib/schema/getMatchingOption.d.ts +14 -0
  160. package/lib/schema/getMatchingOption.js +80 -0
  161. package/lib/schema/getMatchingOption.js.map +1 -0
  162. package/lib/schema/index.d.ts +14 -0
  163. package/lib/schema/index.js +15 -0
  164. package/lib/schema/index.js.map +1 -0
  165. package/lib/schema/isFilesArray.d.ts +10 -0
  166. package/lib/schema/isFilesArray.js +21 -0
  167. package/lib/schema/isFilesArray.js.map +1 -0
  168. package/lib/schema/isMultiSelect.d.ts +9 -0
  169. package/lib/schema/isMultiSelect.js +15 -0
  170. package/lib/schema/isMultiSelect.js.map +1 -0
  171. package/lib/schema/isSelect.d.ts +9 -0
  172. package/lib/schema/isSelect.js +21 -0
  173. package/lib/schema/isSelect.js.map +1 -0
  174. package/lib/schema/mergeValidationData.d.ts +14 -0
  175. package/lib/schema/mergeValidationData.js +28 -0
  176. package/lib/schema/mergeValidationData.js.map +1 -0
  177. package/lib/schema/retrieveSchema.d.ts +170 -0
  178. package/lib/schema/retrieveSchema.js +437 -0
  179. package/lib/schema/retrieveSchema.js.map +1 -0
  180. package/lib/schema/sanitizeDataForNewSchema.d.ts +49 -0
  181. package/lib/schema/sanitizeDataForNewSchema.js +173 -0
  182. package/lib/schema/sanitizeDataForNewSchema.js.map +1 -0
  183. package/lib/schema/toIdSchema.d.ts +13 -0
  184. package/lib/schema/toIdSchema.js +59 -0
  185. package/lib/schema/toIdSchema.js.map +1 -0
  186. package/lib/schema/toPathSchema.d.ts +11 -0
  187. package/lib/schema/toPathSchema.js +68 -0
  188. package/lib/schema/toPathSchema.js.map +1 -0
  189. package/lib/schemaRequiresTrueValue.d.ts +11 -0
  190. package/lib/schemaRequiresTrueValue.js +34 -0
  191. package/lib/schemaRequiresTrueValue.js.map +1 -0
  192. package/lib/shouldRender.d.ts +10 -0
  193. package/lib/shouldRender.js +14 -0
  194. package/lib/shouldRender.js.map +1 -0
  195. package/lib/toConstant.d.ts +9 -0
  196. package/lib/toConstant.js +18 -0
  197. package/lib/toConstant.js.map +1 -0
  198. package/lib/toDateString.d.ts +9 -0
  199. package/lib/toDateString.js +14 -0
  200. package/lib/toDateString.js.map +1 -0
  201. package/lib/toErrorList.d.ts +8 -0
  202. package/lib/toErrorList.js +34 -0
  203. package/lib/toErrorList.js.map +1 -0
  204. package/lib/toErrorSchema.d.ts +21 -0
  205. package/lib/toErrorSchema.js +41 -0
  206. package/lib/toErrorSchema.js.map +1 -0
  207. package/lib/types.d.ts +982 -0
  208. package/lib/types.js +2 -0
  209. package/lib/types.js.map +1 -0
  210. package/lib/unwrapErrorHandler.d.ts +7 -0
  211. package/lib/unwrapErrorHandler.js +21 -0
  212. package/lib/unwrapErrorHandler.js.map +1 -0
  213. package/lib/utcToLocal.d.ts +6 -0
  214. package/lib/utcToLocal.js +26 -0
  215. package/lib/utcToLocal.js.map +1 -0
  216. package/lib/validationDataMerge.d.ts +11 -0
  217. package/lib/validationDataMerge.js +26 -0
  218. package/lib/validationDataMerge.js.map +1 -0
  219. package/lib/withIdRefPrefix.d.ts +8 -0
  220. package/lib/withIdRefPrefix.js +47 -0
  221. package/lib/withIdRefPrefix.js.map +1 -0
  222. package/package.json +21 -13
  223. package/src/ErrorSchemaBuilder.ts +112 -0
  224. package/src/allowAdditionalItems.ts +15 -0
  225. package/src/asNumber.ts +38 -0
  226. package/src/canExpand.ts +31 -0
  227. package/src/constants.ts +31 -0
  228. package/src/createErrorHandler.ts +33 -0
  229. package/src/createSchemaUtils.ts +298 -0
  230. package/src/dataURItoBlob.ts +42 -0
  231. package/src/deepEquals.ts +19 -0
  232. package/src/englishStringTranslator.ts +14 -0
  233. package/src/enumOptionsDeselectValue.ts +28 -0
  234. package/src/enumOptionsIndexForValue.ts +27 -0
  235. package/src/enumOptionsIsSelected.ts +19 -0
  236. package/src/enumOptionsSelectValue.ts +28 -0
  237. package/src/enumOptionsValueForIndex.ts +26 -0
  238. package/src/enums.ts +74 -0
  239. package/src/findSchemaDefinition.ts +54 -0
  240. package/src/getDiscriminatorFieldFromSchema.ts +21 -0
  241. package/src/getInputProps.ts +55 -0
  242. package/src/getSchemaType.ts +37 -0
  243. package/src/getSubmitButtonOptions.ts +32 -0
  244. package/src/getTemplate.ts +26 -0
  245. package/src/getUiOptions.ts +32 -0
  246. package/src/getWidget.tsx +133 -0
  247. package/src/guessType.ts +28 -0
  248. package/src/hasWidget.ts +27 -0
  249. package/src/hashForSchema.ts +31 -0
  250. package/src/idGenerators.ts +81 -0
  251. package/src/index.ts +118 -0
  252. package/src/isConstant.ts +12 -0
  253. package/src/isCustomWidget.ts +19 -0
  254. package/src/isFixedItems.ts +12 -0
  255. package/src/isObject.ts +15 -0
  256. package/src/labelValue.ts +16 -0
  257. package/src/localToUTC.ts +8 -0
  258. package/src/mergeDefaultsWithFormData.ts +53 -0
  259. package/src/mergeObjects.ts +39 -0
  260. package/src/mergeSchemas.ts +38 -0
  261. package/src/optionsList.ts +41 -0
  262. package/src/orderProperties.ts +44 -0
  263. package/src/pad.ts +13 -0
  264. package/src/parseDateString.ts +33 -0
  265. package/src/parser/ParserValidator.ts +132 -0
  266. package/src/parser/index.ts +6 -0
  267. package/src/parser/schemaParser.ts +60 -0
  268. package/src/rangeSpec.ts +22 -0
  269. package/src/replaceStringParameters.ts +22 -0
  270. package/src/schema/getClosestMatchingOption.ts +191 -0
  271. package/src/schema/getDefaultFormState.ts +447 -0
  272. package/src/schema/getDisplayLabel.ts +59 -0
  273. package/src/schema/getFirstMatchingOption.ts +27 -0
  274. package/src/schema/getMatchingOption.ts +95 -0
  275. package/src/schema/index.ts +29 -0
  276. package/src/schema/isFilesArray.ts +27 -0
  277. package/src/schema/isMultiSelect.ts +21 -0
  278. package/src/schema/isSelect.ts +26 -0
  279. package/src/schema/mergeValidationData.ts +38 -0
  280. package/src/schema/retrieveSchema.ts +614 -0
  281. package/src/schema/sanitizeDataForNewSchema.ts +197 -0
  282. package/src/schema/toIdSchema.ts +105 -0
  283. package/src/schema/toPathSchema.ts +121 -0
  284. package/src/schemaRequiresTrueValue.ts +40 -0
  285. package/src/shouldRender.ts +16 -0
  286. package/src/toConstant.ts +19 -0
  287. package/src/toDateString.ts +15 -0
  288. package/src/toErrorList.ts +41 -0
  289. package/src/toErrorSchema.ts +43 -0
  290. package/src/types.ts +1139 -0
  291. package/src/unwrapErrorHandler.ts +25 -0
  292. package/src/utcToLocal.ts +30 -0
  293. package/src/validationDataMerge.ts +31 -0
  294. package/src/withIdRefPrefix.ts +49 -0
  295. package/dist/index.d.ts +0 -1912
  296. package/dist/utils.cjs.development.js +0 -3513
  297. package/dist/utils.cjs.development.js.map +0 -1
  298. package/dist/utils.cjs.production.min.js +0 -2
  299. package/dist/utils.cjs.production.min.js.map +0 -1
  300. package/dist/utils.umd.development.js +0 -3496
  301. package/dist/utils.umd.development.js.map +0 -1
  302. package/dist/utils.umd.production.min.js +0 -2
  303. package/dist/utils.umd.production.min.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,8 +1,2547 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
29
 
2
- 'use strict'
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ ADDITIONAL_PROPERTIES_KEY: () => ADDITIONAL_PROPERTIES_KEY,
34
+ ADDITIONAL_PROPERTY_FLAG: () => ADDITIONAL_PROPERTY_FLAG,
35
+ ALL_OF_KEY: () => ALL_OF_KEY,
36
+ ANY_OF_KEY: () => ANY_OF_KEY,
37
+ CONST_KEY: () => CONST_KEY,
38
+ DEFAULT_KEY: () => DEFAULT_KEY,
39
+ DEFINITIONS_KEY: () => DEFINITIONS_KEY,
40
+ DEPENDENCIES_KEY: () => DEPENDENCIES_KEY,
41
+ ENUM_KEY: () => ENUM_KEY,
42
+ ERRORS_KEY: () => ERRORS_KEY,
43
+ ErrorSchemaBuilder: () => ErrorSchemaBuilder,
44
+ ID_KEY: () => ID_KEY,
45
+ IF_KEY: () => IF_KEY,
46
+ ITEMS_KEY: () => ITEMS_KEY,
47
+ JUNK_OPTION_ID: () => JUNK_OPTION_ID,
48
+ NAME_KEY: () => NAME_KEY,
49
+ ONE_OF_KEY: () => ONE_OF_KEY,
50
+ PROPERTIES_KEY: () => PROPERTIES_KEY,
51
+ REF_KEY: () => REF_KEY,
52
+ REQUIRED_KEY: () => REQUIRED_KEY,
53
+ RJSF_ADDITONAL_PROPERTIES_FLAG: () => RJSF_ADDITONAL_PROPERTIES_FLAG,
54
+ ROOT_SCHEMA_PREFIX: () => ROOT_SCHEMA_PREFIX,
55
+ SUBMIT_BTN_OPTIONS_KEY: () => SUBMIT_BTN_OPTIONS_KEY,
56
+ TranslatableString: () => TranslatableString,
57
+ UI_FIELD_KEY: () => UI_FIELD_KEY,
58
+ UI_GLOBAL_OPTIONS_KEY: () => UI_GLOBAL_OPTIONS_KEY,
59
+ UI_OPTIONS_KEY: () => UI_OPTIONS_KEY,
60
+ UI_WIDGET_KEY: () => UI_WIDGET_KEY,
61
+ allowAdditionalItems: () => allowAdditionalItems,
62
+ ariaDescribedByIds: () => ariaDescribedByIds,
63
+ asNumber: () => asNumber,
64
+ canExpand: () => canExpand,
65
+ createErrorHandler: () => createErrorHandler,
66
+ createSchemaUtils: () => createSchemaUtils,
67
+ dataURItoBlob: () => dataURItoBlob,
68
+ deepEquals: () => deepEquals,
69
+ descriptionId: () => descriptionId,
70
+ englishStringTranslator: () => englishStringTranslator,
71
+ enumOptionsDeselectValue: () => enumOptionsDeselectValue,
72
+ enumOptionsIndexForValue: () => enumOptionsIndexForValue,
73
+ enumOptionsIsSelected: () => enumOptionsIsSelected,
74
+ enumOptionsSelectValue: () => enumOptionsSelectValue,
75
+ enumOptionsValueForIndex: () => enumOptionsValueForIndex,
76
+ errorId: () => errorId,
77
+ examplesId: () => examplesId,
78
+ findSchemaDefinition: () => findSchemaDefinition,
79
+ getClosestMatchingOption: () => getClosestMatchingOption,
80
+ getDefaultFormState: () => getDefaultFormState,
81
+ getDiscriminatorFieldFromSchema: () => getDiscriminatorFieldFromSchema,
82
+ getDisplayLabel: () => getDisplayLabel,
83
+ getFirstMatchingOption: () => getFirstMatchingOption,
84
+ getInputProps: () => getInputProps,
85
+ getMatchingOption: () => getMatchingOption,
86
+ getSchemaType: () => getSchemaType,
87
+ getSubmitButtonOptions: () => getSubmitButtonOptions,
88
+ getTemplate: () => getTemplate,
89
+ getUiOptions: () => getUiOptions,
90
+ getWidget: () => getWidget,
91
+ guessType: () => guessType,
92
+ hasWidget: () => hasWidget,
93
+ hashForSchema: () => hashForSchema,
94
+ helpId: () => helpId,
95
+ isConstant: () => isConstant,
96
+ isCustomWidget: () => isCustomWidget,
97
+ isFilesArray: () => isFilesArray,
98
+ isFixedItems: () => isFixedItems,
99
+ isMultiSelect: () => isMultiSelect,
100
+ isObject: () => isObject,
101
+ isSelect: () => isSelect,
102
+ labelValue: () => labelValue,
103
+ localToUTC: () => localToUTC,
104
+ mergeDefaultsWithFormData: () => mergeDefaultsWithFormData,
105
+ mergeObjects: () => mergeObjects,
106
+ mergeSchemas: () => mergeSchemas,
107
+ mergeValidationData: () => mergeValidationData,
108
+ optionId: () => optionId,
109
+ optionsList: () => optionsList,
110
+ orderProperties: () => orderProperties,
111
+ pad: () => pad,
112
+ parseDateString: () => parseDateString,
113
+ rangeSpec: () => rangeSpec,
114
+ replaceStringParameters: () => replaceStringParameters,
115
+ retrieveSchema: () => retrieveSchema,
116
+ sanitizeDataForNewSchema: () => sanitizeDataForNewSchema,
117
+ schemaParser: () => schemaParser,
118
+ schemaRequiresTrueValue: () => schemaRequiresTrueValue,
119
+ shouldRender: () => shouldRender,
120
+ titleId: () => titleId,
121
+ toConstant: () => toConstant,
122
+ toDateString: () => toDateString,
123
+ toErrorList: () => toErrorList,
124
+ toErrorSchema: () => toErrorSchema,
125
+ toIdSchema: () => toIdSchema,
126
+ toPathSchema: () => toPathSchema,
127
+ unwrapErrorHandler: () => unwrapErrorHandler,
128
+ utcToLocal: () => utcToLocal,
129
+ validationDataMerge: () => validationDataMerge,
130
+ withIdRefPrefix: () => withIdRefPrefix
131
+ });
132
+ module.exports = __toCommonJS(src_exports);
3
133
 
4
- if (process.env.NODE_ENV === 'production') {
5
- module.exports = require('./utils.cjs.production.min.js')
6
- } else {
7
- module.exports = require('./utils.cjs.development.js')
134
+ // src/isObject.ts
135
+ function isObject(thing) {
136
+ if (typeof File !== "undefined" && thing instanceof File) {
137
+ return false;
138
+ }
139
+ if (typeof Date !== "undefined" && thing instanceof Date) {
140
+ return false;
141
+ }
142
+ return typeof thing === "object" && thing !== null && !Array.isArray(thing);
8
143
  }
144
+
145
+ // src/allowAdditionalItems.ts
146
+ function allowAdditionalItems(schema) {
147
+ if (schema.additionalItems === true) {
148
+ console.warn("additionalItems=true is currently not supported");
149
+ }
150
+ return isObject(schema.additionalItems);
151
+ }
152
+
153
+ // src/asNumber.ts
154
+ function asNumber(value) {
155
+ if (value === "") {
156
+ return void 0;
157
+ }
158
+ if (value === null) {
159
+ return null;
160
+ }
161
+ if (/\.$/.test(value)) {
162
+ return value;
163
+ }
164
+ if (/\.0$/.test(value)) {
165
+ return value;
166
+ }
167
+ if (/\.\d*0$/.test(value)) {
168
+ return value;
169
+ }
170
+ const n = Number(value);
171
+ const valid = typeof n === "number" && !Number.isNaN(n);
172
+ return valid ? n : value;
173
+ }
174
+
175
+ // src/constants.ts
176
+ var ADDITIONAL_PROPERTY_FLAG = "__additional_property";
177
+ var ADDITIONAL_PROPERTIES_KEY = "additionalProperties";
178
+ var ALL_OF_KEY = "allOf";
179
+ var ANY_OF_KEY = "anyOf";
180
+ var CONST_KEY = "const";
181
+ var DEFAULT_KEY = "default";
182
+ var DEFINITIONS_KEY = "definitions";
183
+ var DEPENDENCIES_KEY = "dependencies";
184
+ var ENUM_KEY = "enum";
185
+ var ERRORS_KEY = "__errors";
186
+ var ID_KEY = "$id";
187
+ var IF_KEY = "if";
188
+ var ITEMS_KEY = "items";
189
+ var JUNK_OPTION_ID = "_$junk_option_schema_id$_";
190
+ var NAME_KEY = "$name";
191
+ var ONE_OF_KEY = "oneOf";
192
+ var PROPERTIES_KEY = "properties";
193
+ var REQUIRED_KEY = "required";
194
+ var SUBMIT_BTN_OPTIONS_KEY = "submitButtonOptions";
195
+ var REF_KEY = "$ref";
196
+ var RJSF_ADDITONAL_PROPERTIES_FLAG = "__rjsf_additionalProperties";
197
+ var ROOT_SCHEMA_PREFIX = "__rjsf_rootSchema";
198
+ var UI_FIELD_KEY = "ui:field";
199
+ var UI_WIDGET_KEY = "ui:widget";
200
+ var UI_OPTIONS_KEY = "ui:options";
201
+ var UI_GLOBAL_OPTIONS_KEY = "ui:globalOptions";
202
+
203
+ // src/getUiOptions.ts
204
+ function getUiOptions(uiSchema = {}, globalOptions = {}) {
205
+ return Object.keys(uiSchema).filter((key) => key.indexOf("ui:") === 0).reduce(
206
+ (options, key) => {
207
+ const value = uiSchema[key];
208
+ if (key === UI_WIDGET_KEY && isObject(value)) {
209
+ console.error("Setting options via ui:widget object is no longer supported, use ui:options instead");
210
+ return options;
211
+ }
212
+ if (key === UI_OPTIONS_KEY && isObject(value)) {
213
+ return { ...options, ...value };
214
+ }
215
+ return { ...options, [key.substring(3)]: value };
216
+ },
217
+ { ...globalOptions }
218
+ );
219
+ }
220
+
221
+ // src/canExpand.ts
222
+ function canExpand(schema, uiSchema = {}, formData) {
223
+ if (!schema.additionalProperties) {
224
+ return false;
225
+ }
226
+ const { expandable = true } = getUiOptions(uiSchema);
227
+ if (expandable === false) {
228
+ return expandable;
229
+ }
230
+ if (schema.maxProperties !== void 0 && formData) {
231
+ return Object.keys(formData).length < schema.maxProperties;
232
+ }
233
+ return true;
234
+ }
235
+
236
+ // src/createErrorHandler.ts
237
+ var import_isPlainObject = __toESM(require("lodash/isPlainObject"));
238
+ function createErrorHandler(formData) {
239
+ const handler = {
240
+ // We store the list of errors for this node in a property named __errors
241
+ // to avoid name collision with a possible sub schema field named
242
+ // 'errors' (see `utils.toErrorSchema`).
243
+ [ERRORS_KEY]: [],
244
+ addError(message) {
245
+ this[ERRORS_KEY].push(message);
246
+ }
247
+ };
248
+ if (Array.isArray(formData)) {
249
+ return formData.reduce((acc, value, key) => {
250
+ return { ...acc, [key]: createErrorHandler(value) };
251
+ }, handler);
252
+ }
253
+ if ((0, import_isPlainObject.default)(formData)) {
254
+ const formObject = formData;
255
+ return Object.keys(formObject).reduce((acc, key) => {
256
+ return { ...acc, [key]: createErrorHandler(formObject[key]) };
257
+ }, handler);
258
+ }
259
+ return handler;
260
+ }
261
+
262
+ // src/deepEquals.ts
263
+ var import_isEqualWith = __toESM(require("lodash/isEqualWith"));
264
+ function deepEquals(a, b) {
265
+ return (0, import_isEqualWith.default)(a, b, (obj, other) => {
266
+ if (typeof obj === "function" && typeof other === "function") {
267
+ return true;
268
+ }
269
+ return void 0;
270
+ });
271
+ }
272
+
273
+ // src/schema/getDefaultFormState.ts
274
+ var import_get6 = __toESM(require("lodash/get"));
275
+ var import_isEmpty = __toESM(require("lodash/isEmpty"));
276
+
277
+ // src/findSchemaDefinition.ts
278
+ var import_jsonpointer = __toESM(require("jsonpointer"));
279
+ var import_omit = __toESM(require("lodash/omit"));
280
+ function splitKeyElementFromObject(key, object) {
281
+ const value = object[key];
282
+ const remaining = (0, import_omit.default)(object, [key]);
283
+ return [remaining, value];
284
+ }
285
+ function findSchemaDefinition($ref, rootSchema = {}) {
286
+ let ref = $ref || "";
287
+ if (ref.startsWith("#")) {
288
+ ref = decodeURIComponent(ref.substring(1));
289
+ } else {
290
+ throw new Error(`Could not find a definition for ${$ref}.`);
291
+ }
292
+ const current = import_jsonpointer.default.get(rootSchema, ref);
293
+ if (current === void 0) {
294
+ throw new Error(`Could not find a definition for ${$ref}.`);
295
+ }
296
+ if (current[REF_KEY]) {
297
+ const [remaining, theRef] = splitKeyElementFromObject(REF_KEY, current);
298
+ const subSchema = findSchemaDefinition(theRef, rootSchema);
299
+ if (Object.keys(remaining).length > 0) {
300
+ return { ...remaining, ...subSchema };
301
+ }
302
+ return subSchema;
303
+ }
304
+ return current;
305
+ }
306
+
307
+ // src/schema/getClosestMatchingOption.ts
308
+ var import_get4 = __toESM(require("lodash/get"));
309
+ var import_has2 = __toESM(require("lodash/has"));
310
+ var import_isObject5 = __toESM(require("lodash/isObject"));
311
+ var import_isString2 = __toESM(require("lodash/isString"));
312
+ var import_reduce = __toESM(require("lodash/reduce"));
313
+ var import_times2 = __toESM(require("lodash/times"));
314
+
315
+ // src/schema/getMatchingOption.ts
316
+ var import_get = __toESM(require("lodash/get"));
317
+ var import_has = __toESM(require("lodash/has"));
318
+ function getMatchingOption(validator, formData, options, rootSchema, discriminatorField) {
319
+ if (formData === void 0) {
320
+ return 0;
321
+ }
322
+ for (let i = 0; i < options.length; i++) {
323
+ const option = options[i];
324
+ if (discriminatorField && (0, import_has.default)(option, [PROPERTIES_KEY, discriminatorField])) {
325
+ const value = (0, import_get.default)(formData, discriminatorField);
326
+ const discriminator = (0, import_get.default)(option, [PROPERTIES_KEY, discriminatorField], {});
327
+ if (validator.isValid(discriminator, value, rootSchema)) {
328
+ return i;
329
+ }
330
+ } else if (option[PROPERTIES_KEY]) {
331
+ const requiresAnyOf = {
332
+ anyOf: Object.keys(option[PROPERTIES_KEY]).map((key) => ({
333
+ required: [key]
334
+ }))
335
+ };
336
+ let augmentedSchema;
337
+ if (option.anyOf) {
338
+ const { ...shallowClone } = option;
339
+ if (!shallowClone.allOf) {
340
+ shallowClone.allOf = [];
341
+ } else {
342
+ shallowClone.allOf = shallowClone.allOf.slice();
343
+ }
344
+ shallowClone.allOf.push(requiresAnyOf);
345
+ augmentedSchema = shallowClone;
346
+ } else {
347
+ augmentedSchema = Object.assign({}, option, requiresAnyOf);
348
+ }
349
+ delete augmentedSchema.required;
350
+ if (validator.isValid(augmentedSchema, formData, rootSchema)) {
351
+ return i;
352
+ }
353
+ } else if (validator.isValid(option, formData, rootSchema)) {
354
+ return i;
355
+ }
356
+ }
357
+ return 0;
358
+ }
359
+
360
+ // src/schema/getFirstMatchingOption.ts
361
+ function getFirstMatchingOption(validator, formData, options, rootSchema, discriminatorField) {
362
+ return getMatchingOption(validator, formData, options, rootSchema, discriminatorField);
363
+ }
364
+
365
+ // src/schema/retrieveSchema.ts
366
+ var import_get3 = __toESM(require("lodash/get"));
367
+ var import_set = __toESM(require("lodash/set"));
368
+ var import_times = __toESM(require("lodash/times"));
369
+ var import_transform = __toESM(require("lodash/transform"));
370
+ var import_json_schema_merge_allof = __toESM(require("json-schema-merge-allof"));
371
+
372
+ // src/getDiscriminatorFieldFromSchema.ts
373
+ var import_get2 = __toESM(require("lodash/get"));
374
+ var import_isString = __toESM(require("lodash/isString"));
375
+ function getDiscriminatorFieldFromSchema(schema) {
376
+ let discriminator;
377
+ const maybeString = (0, import_get2.default)(schema, "discriminator.propertyName", void 0);
378
+ if ((0, import_isString.default)(maybeString)) {
379
+ discriminator = maybeString;
380
+ } else if (maybeString !== void 0) {
381
+ console.warn(`Expecting discriminator to be a string, got "${typeof maybeString}" instead`);
382
+ }
383
+ return discriminator;
384
+ }
385
+
386
+ // src/guessType.ts
387
+ function guessType(value) {
388
+ if (Array.isArray(value)) {
389
+ return "array";
390
+ }
391
+ if (typeof value === "string") {
392
+ return "string";
393
+ }
394
+ if (value == null) {
395
+ return "null";
396
+ }
397
+ if (typeof value === "boolean") {
398
+ return "boolean";
399
+ }
400
+ if (!isNaN(value)) {
401
+ return "number";
402
+ }
403
+ if (typeof value === "object") {
404
+ return "object";
405
+ }
406
+ return "string";
407
+ }
408
+
409
+ // src/mergeSchemas.ts
410
+ var import_union = __toESM(require("lodash/union"));
411
+
412
+ // src/getSchemaType.ts
413
+ function getSchemaType(schema) {
414
+ let { type } = schema;
415
+ if (!type && schema.const) {
416
+ return guessType(schema.const);
417
+ }
418
+ if (!type && schema.enum) {
419
+ return "string";
420
+ }
421
+ if (!type && (schema.properties || schema.additionalProperties)) {
422
+ return "object";
423
+ }
424
+ if (Array.isArray(type) && type.length === 2 && type.includes("null")) {
425
+ type = type.find((type2) => type2 !== "null");
426
+ }
427
+ return type;
428
+ }
429
+
430
+ // src/mergeSchemas.ts
431
+ function mergeSchemas(obj1, obj2) {
432
+ const acc = Object.assign({}, obj1);
433
+ return Object.keys(obj2).reduce((acc2, key) => {
434
+ const left = obj1 ? obj1[key] : {}, right = obj2[key];
435
+ if (obj1 && key in obj1 && isObject(right)) {
436
+ acc2[key] = mergeSchemas(left, right);
437
+ } else if (obj1 && obj2 && (getSchemaType(obj1) === "object" || getSchemaType(obj2) === "object") && key === REQUIRED_KEY && Array.isArray(left) && Array.isArray(right)) {
438
+ acc2[key] = (0, import_union.default)(left, right);
439
+ } else {
440
+ acc2[key] = right;
441
+ }
442
+ return acc2;
443
+ }, acc);
444
+ }
445
+
446
+ // src/schema/retrieveSchema.ts
447
+ function retrieveSchema(validator, schema, rootSchema = {}, rawFormData) {
448
+ return retrieveSchemaInternal(validator, schema, rootSchema, rawFormData)[0];
449
+ }
450
+ function resolveCondition(validator, schema, rootSchema, expandAllBranches, formData) {
451
+ const { if: expression, then, else: otherwise, ...resolvedSchemaLessConditional } = schema;
452
+ const conditionValue = validator.isValid(expression, formData || {}, rootSchema);
453
+ let resolvedSchemas = [resolvedSchemaLessConditional];
454
+ let schemas = [];
455
+ if (expandAllBranches) {
456
+ if (then && typeof then !== "boolean") {
457
+ schemas = schemas.concat(
458
+ retrieveSchemaInternal(validator, then, rootSchema, formData, expandAllBranches)
459
+ );
460
+ }
461
+ if (otherwise && typeof otherwise !== "boolean") {
462
+ schemas = schemas.concat(
463
+ retrieveSchemaInternal(validator, otherwise, rootSchema, formData, expandAllBranches)
464
+ );
465
+ }
466
+ } else {
467
+ const conditionalSchema = conditionValue ? then : otherwise;
468
+ if (conditionalSchema && typeof conditionalSchema !== "boolean") {
469
+ schemas = schemas.concat(
470
+ retrieveSchemaInternal(validator, conditionalSchema, rootSchema, formData, expandAllBranches)
471
+ );
472
+ }
473
+ }
474
+ if (schemas.length) {
475
+ resolvedSchemas = schemas.map((s) => mergeSchemas(resolvedSchemaLessConditional, s));
476
+ }
477
+ return resolvedSchemas.flatMap(
478
+ (s) => retrieveSchemaInternal(validator, s, rootSchema, formData, expandAllBranches)
479
+ );
480
+ }
481
+ function getAllPermutationsOfXxxOf(listOfLists) {
482
+ const allPermutations = listOfLists.reduce(
483
+ (permutations, list) => {
484
+ if (list.length > 1) {
485
+ return list.flatMap((element) => (0, import_times.default)(permutations.length, (i) => [...permutations[i]].concat(element)));
486
+ }
487
+ permutations.forEach((permutation) => permutation.push(list[0]));
488
+ return permutations;
489
+ },
490
+ [[]]
491
+ // Start with an empty list
492
+ );
493
+ return allPermutations;
494
+ }
495
+ function resolveSchema(validator, schema, rootSchema, expandAllBranches, formData) {
496
+ if (REF_KEY in schema) {
497
+ return resolveReference(validator, schema, rootSchema, expandAllBranches, formData);
498
+ }
499
+ if (DEPENDENCIES_KEY in schema) {
500
+ const resolvedSchemas = resolveDependencies(validator, schema, rootSchema, expandAllBranches, formData);
501
+ return resolvedSchemas.flatMap((s) => {
502
+ return retrieveSchemaInternal(validator, s, rootSchema, formData, expandAllBranches);
503
+ });
504
+ }
505
+ if (ALL_OF_KEY in schema && Array.isArray(schema.allOf)) {
506
+ const allOfSchemaElements = schema.allOf.map(
507
+ (allOfSubschema) => retrieveSchemaInternal(validator, allOfSubschema, rootSchema, formData, expandAllBranches)
508
+ );
509
+ const allPermutations = getAllPermutationsOfXxxOf(allOfSchemaElements);
510
+ return allPermutations.map((permutation) => ({ ...schema, allOf: permutation }));
511
+ }
512
+ return [schema];
513
+ }
514
+ function resolveReference(validator, schema, rootSchema, expandAllBranches, formData) {
515
+ const { $ref, ...localSchema } = schema;
516
+ const refSchema = findSchemaDefinition($ref, rootSchema);
517
+ return retrieveSchemaInternal(
518
+ validator,
519
+ { ...refSchema, ...localSchema },
520
+ rootSchema,
521
+ formData,
522
+ expandAllBranches
523
+ );
524
+ }
525
+ function resolveAllReferences(schema, rootSchema) {
526
+ let resolvedSchema = schema;
527
+ if (REF_KEY in resolvedSchema) {
528
+ const { $ref, ...localSchema } = resolvedSchema;
529
+ const refSchema = findSchemaDefinition($ref, rootSchema);
530
+ resolvedSchema = { ...refSchema, ...localSchema };
531
+ }
532
+ if (PROPERTIES_KEY in resolvedSchema) {
533
+ const updatedProps = (0, import_transform.default)(
534
+ resolvedSchema[PROPERTIES_KEY],
535
+ (result, value, key) => {
536
+ result[key] = resolveAllReferences(value, rootSchema);
537
+ },
538
+ {}
539
+ );
540
+ resolvedSchema = { ...resolvedSchema, [PROPERTIES_KEY]: updatedProps };
541
+ }
542
+ if (ITEMS_KEY in resolvedSchema && !Array.isArray(resolvedSchema.items) && typeof resolvedSchema.items !== "boolean") {
543
+ resolvedSchema = { ...resolvedSchema, items: resolveAllReferences(resolvedSchema.items, rootSchema) };
544
+ }
545
+ return resolvedSchema;
546
+ }
547
+ function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData) {
548
+ const schema = {
549
+ ...theSchema,
550
+ properties: { ...theSchema.properties }
551
+ };
552
+ const formData = aFormData && isObject(aFormData) ? aFormData : {};
553
+ Object.keys(formData).forEach((key) => {
554
+ if (key in schema.properties) {
555
+ return;
556
+ }
557
+ let additionalProperties = {};
558
+ if (typeof schema.additionalProperties !== "boolean") {
559
+ if (REF_KEY in schema.additionalProperties) {
560
+ additionalProperties = retrieveSchema(
561
+ validator,
562
+ { $ref: (0, import_get3.default)(schema.additionalProperties, [REF_KEY]) },
563
+ rootSchema,
564
+ formData
565
+ );
566
+ } else if ("type" in schema.additionalProperties) {
567
+ additionalProperties = { ...schema.additionalProperties };
568
+ } else if (ANY_OF_KEY in schema.additionalProperties || ONE_OF_KEY in schema.additionalProperties) {
569
+ additionalProperties = {
570
+ type: "object",
571
+ ...schema.additionalProperties
572
+ };
573
+ } else {
574
+ additionalProperties = { type: guessType((0, import_get3.default)(formData, [key])) };
575
+ }
576
+ } else {
577
+ additionalProperties = { type: guessType((0, import_get3.default)(formData, [key])) };
578
+ }
579
+ schema.properties[key] = additionalProperties;
580
+ (0, import_set.default)(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
581
+ });
582
+ return schema;
583
+ }
584
+ function retrieveSchemaInternal(validator, schema, rootSchema, rawFormData, expandAllBranches = false) {
585
+ if (!isObject(schema)) {
586
+ return [{}];
587
+ }
588
+ const resolvedSchemas = resolveSchema(validator, schema, rootSchema, expandAllBranches, rawFormData);
589
+ return resolvedSchemas.flatMap((s) => {
590
+ let resolvedSchema = s;
591
+ if (IF_KEY in resolvedSchema) {
592
+ return resolveCondition(validator, resolvedSchema, rootSchema, expandAllBranches, rawFormData);
593
+ }
594
+ if (ALL_OF_KEY in resolvedSchema) {
595
+ if (expandAllBranches) {
596
+ return [...resolvedSchema.allOf];
597
+ }
598
+ try {
599
+ resolvedSchema = (0, import_json_schema_merge_allof.default)(resolvedSchema, {
600
+ deep: false
601
+ });
602
+ } catch (e) {
603
+ console.warn("could not merge subschemas in allOf:\n", e);
604
+ const { allOf, ...resolvedSchemaWithoutAllOf } = resolvedSchema;
605
+ return resolvedSchemaWithoutAllOf;
606
+ }
607
+ }
608
+ const hasAdditionalProperties = ADDITIONAL_PROPERTIES_KEY in resolvedSchema && resolvedSchema.additionalProperties !== false;
609
+ if (hasAdditionalProperties) {
610
+ return stubExistingAdditionalProperties(validator, resolvedSchema, rootSchema, rawFormData);
611
+ }
612
+ return resolvedSchema;
613
+ });
614
+ }
615
+ function resolveAnyOrOneOfSchemas(validator, schema, rootSchema, expandAllBranches, rawFormData) {
616
+ let anyOrOneOf;
617
+ const { oneOf, anyOf, ...remaining } = schema;
618
+ if (Array.isArray(oneOf)) {
619
+ anyOrOneOf = oneOf;
620
+ } else if (Array.isArray(anyOf)) {
621
+ anyOrOneOf = anyOf;
622
+ }
623
+ if (anyOrOneOf) {
624
+ const formData = rawFormData === void 0 && expandAllBranches ? {} : rawFormData;
625
+ const discriminator = getDiscriminatorFieldFromSchema(schema);
626
+ anyOrOneOf = anyOrOneOf.map((s) => {
627
+ return resolveAllReferences(s, rootSchema);
628
+ });
629
+ const option = getFirstMatchingOption(validator, formData, anyOrOneOf, rootSchema, discriminator);
630
+ if (expandAllBranches) {
631
+ return anyOrOneOf.map((item) => mergeSchemas(remaining, item));
632
+ }
633
+ schema = mergeSchemas(remaining, anyOrOneOf[option]);
634
+ }
635
+ return [schema];
636
+ }
637
+ function resolveDependencies(validator, schema, rootSchema, expandAllBranches, formData) {
638
+ const { dependencies, ...remainingSchema } = schema;
639
+ const resolvedSchemas = resolveAnyOrOneOfSchemas(
640
+ validator,
641
+ remainingSchema,
642
+ rootSchema,
643
+ expandAllBranches,
644
+ formData
645
+ );
646
+ return resolvedSchemas.flatMap(
647
+ (resolvedSchema) => processDependencies(validator, dependencies, resolvedSchema, rootSchema, expandAllBranches, formData)
648
+ );
649
+ }
650
+ function processDependencies(validator, dependencies, resolvedSchema, rootSchema, expandAllBranches, formData) {
651
+ let schemas = [resolvedSchema];
652
+ for (const dependencyKey in dependencies) {
653
+ if (!expandAllBranches && (0, import_get3.default)(formData, [dependencyKey]) === void 0) {
654
+ continue;
655
+ }
656
+ if (resolvedSchema.properties && !(dependencyKey in resolvedSchema.properties)) {
657
+ continue;
658
+ }
659
+ const [remainingDependencies, dependencyValue] = splitKeyElementFromObject(
660
+ dependencyKey,
661
+ dependencies
662
+ );
663
+ if (Array.isArray(dependencyValue)) {
664
+ schemas[0] = withDependentProperties(resolvedSchema, dependencyValue);
665
+ } else if (isObject(dependencyValue)) {
666
+ schemas = withDependentSchema(
667
+ validator,
668
+ resolvedSchema,
669
+ rootSchema,
670
+ dependencyKey,
671
+ dependencyValue,
672
+ expandAllBranches,
673
+ formData
674
+ );
675
+ }
676
+ return schemas.flatMap(
677
+ (schema) => processDependencies(validator, remainingDependencies, schema, rootSchema, expandAllBranches, formData)
678
+ );
679
+ }
680
+ return schemas;
681
+ }
682
+ function withDependentProperties(schema, additionallyRequired) {
683
+ if (!additionallyRequired) {
684
+ return schema;
685
+ }
686
+ const required = Array.isArray(schema.required) ? Array.from(/* @__PURE__ */ new Set([...schema.required, ...additionallyRequired])) : additionallyRequired;
687
+ return { ...schema, required };
688
+ }
689
+ function withDependentSchema(validator, schema, rootSchema, dependencyKey, dependencyValue, expandAllBranches, formData) {
690
+ const dependentSchemas = retrieveSchemaInternal(
691
+ validator,
692
+ dependencyValue,
693
+ rootSchema,
694
+ formData,
695
+ expandAllBranches
696
+ );
697
+ return dependentSchemas.flatMap((dependent) => {
698
+ const { oneOf, ...dependentSchema } = dependent;
699
+ schema = mergeSchemas(schema, dependentSchema);
700
+ if (oneOf === void 0) {
701
+ return schema;
702
+ }
703
+ const resolvedOneOfs = oneOf.map((subschema) => {
704
+ if (typeof subschema === "boolean" || !(REF_KEY in subschema)) {
705
+ return [subschema];
706
+ }
707
+ return resolveReference(validator, subschema, rootSchema, expandAllBranches, formData);
708
+ });
709
+ const allPermutations = getAllPermutationsOfXxxOf(resolvedOneOfs);
710
+ return allPermutations.flatMap(
711
+ (resolvedOneOf) => withExactlyOneSubschema(
712
+ validator,
713
+ schema,
714
+ rootSchema,
715
+ dependencyKey,
716
+ resolvedOneOf,
717
+ expandAllBranches,
718
+ formData
719
+ )
720
+ );
721
+ });
722
+ }
723
+ function withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, oneOf, expandAllBranches, formData) {
724
+ const validSubschemas = oneOf.filter((subschema) => {
725
+ if (typeof subschema === "boolean" || !subschema || !subschema.properties) {
726
+ return false;
727
+ }
728
+ const { [dependencyKey]: conditionPropertySchema } = subschema.properties;
729
+ if (conditionPropertySchema) {
730
+ const conditionSchema = {
731
+ type: "object",
732
+ properties: {
733
+ [dependencyKey]: conditionPropertySchema
734
+ }
735
+ };
736
+ return validator.isValid(conditionSchema, formData, rootSchema) || expandAllBranches;
737
+ }
738
+ return false;
739
+ });
740
+ if (!expandAllBranches && validSubschemas.length !== 1) {
741
+ console.warn("ignoring oneOf in dependencies because there isn't exactly one subschema that is valid");
742
+ return [schema];
743
+ }
744
+ return validSubschemas.flatMap((s) => {
745
+ const subschema = s;
746
+ const [dependentSubschema] = splitKeyElementFromObject(dependencyKey, subschema.properties);
747
+ const dependentSchema = { ...subschema, properties: dependentSubschema };
748
+ const schemas = retrieveSchemaInternal(
749
+ validator,
750
+ dependentSchema,
751
+ rootSchema,
752
+ formData,
753
+ expandAllBranches
754
+ );
755
+ return schemas.map((s2) => mergeSchemas(schema, s2));
756
+ });
757
+ }
758
+
759
+ // src/schema/getClosestMatchingOption.ts
760
+ var JUNK_OPTION = {
761
+ type: "object",
762
+ $id: JUNK_OPTION_ID,
763
+ properties: {
764
+ __not_really_there__: {
765
+ type: "number"
766
+ }
767
+ }
768
+ };
769
+ function calculateIndexScore(validator, rootSchema, schema, formData = {}) {
770
+ let totalScore = 0;
771
+ if (schema) {
772
+ if ((0, import_isObject5.default)(schema.properties)) {
773
+ totalScore += (0, import_reduce.default)(
774
+ schema.properties,
775
+ (score, value, key) => {
776
+ const formValue = (0, import_get4.default)(formData, key);
777
+ if (typeof value === "boolean") {
778
+ return score;
779
+ }
780
+ if ((0, import_has2.default)(value, REF_KEY)) {
781
+ const newSchema = retrieveSchema(validator, value, rootSchema, formValue);
782
+ return score + calculateIndexScore(validator, rootSchema, newSchema, formValue || {});
783
+ }
784
+ if (((0, import_has2.default)(value, ONE_OF_KEY) || (0, import_has2.default)(value, ANY_OF_KEY)) && formValue) {
785
+ const key2 = (0, import_has2.default)(value, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;
786
+ const discriminator = getDiscriminatorFieldFromSchema(value);
787
+ return score + getClosestMatchingOption(
788
+ validator,
789
+ rootSchema,
790
+ formValue,
791
+ (0, import_get4.default)(value, key2),
792
+ -1,
793
+ discriminator
794
+ );
795
+ }
796
+ if (value.type === "object") {
797
+ return score + calculateIndexScore(validator, rootSchema, value, formValue || {});
798
+ }
799
+ if (value.type === guessType(formValue)) {
800
+ let newScore = score + 1;
801
+ if (value.default) {
802
+ newScore += formValue === value.default ? 1 : -1;
803
+ } else if (value.const) {
804
+ newScore += formValue === value.const ? 1 : -1;
805
+ }
806
+ return newScore;
807
+ }
808
+ return score;
809
+ },
810
+ 0
811
+ );
812
+ } else if ((0, import_isString2.default)(schema.type) && schema.type === guessType(formData)) {
813
+ totalScore += 1;
814
+ }
815
+ }
816
+ return totalScore;
817
+ }
818
+ function getClosestMatchingOption(validator, rootSchema, formData, options, selectedOption = -1, discriminatorField) {
819
+ const resolvedOptions = options.map((option) => {
820
+ return resolveAllReferences(option, rootSchema);
821
+ });
822
+ const allValidIndexes = resolvedOptions.reduce((validList, option, index) => {
823
+ const testOptions = [JUNK_OPTION, option];
824
+ const match = getFirstMatchingOption(validator, formData, testOptions, rootSchema, discriminatorField);
825
+ if (match === 1) {
826
+ validList.push(index);
827
+ }
828
+ return validList;
829
+ }, []);
830
+ if (allValidIndexes.length === 1) {
831
+ return allValidIndexes[0];
832
+ }
833
+ if (!allValidIndexes.length) {
834
+ (0, import_times2.default)(resolvedOptions.length, (i) => allValidIndexes.push(i));
835
+ }
836
+ const scoreCount = /* @__PURE__ */ new Set();
837
+ const { bestIndex } = allValidIndexes.reduce(
838
+ (scoreData, index) => {
839
+ const { bestScore } = scoreData;
840
+ const option = resolvedOptions[index];
841
+ const score = calculateIndexScore(validator, rootSchema, option, formData);
842
+ scoreCount.add(score);
843
+ if (score > bestScore) {
844
+ return { bestIndex: index, bestScore: score };
845
+ }
846
+ return scoreData;
847
+ },
848
+ { bestIndex: selectedOption, bestScore: 0 }
849
+ );
850
+ if (scoreCount.size === 1 && selectedOption >= 0) {
851
+ return selectedOption;
852
+ }
853
+ return bestIndex;
854
+ }
855
+
856
+ // src/isFixedItems.ts
857
+ function isFixedItems(schema) {
858
+ return Array.isArray(schema.items) && schema.items.length > 0 && schema.items.every((item) => isObject(item));
859
+ }
860
+
861
+ // src/mergeDefaultsWithFormData.ts
862
+ var import_get5 = __toESM(require("lodash/get"));
863
+ function mergeDefaultsWithFormData(defaults, formData, mergeExtraArrayDefaults = false) {
864
+ if (Array.isArray(formData)) {
865
+ const defaultsArray = Array.isArray(defaults) ? defaults : [];
866
+ const mapped = formData.map((value, idx) => {
867
+ if (defaultsArray[idx]) {
868
+ return mergeDefaultsWithFormData(defaultsArray[idx], value, mergeExtraArrayDefaults);
869
+ }
870
+ return value;
871
+ });
872
+ if (mergeExtraArrayDefaults && mapped.length < defaultsArray.length) {
873
+ mapped.push(...defaultsArray.slice(mapped.length));
874
+ }
875
+ return mapped;
876
+ }
877
+ if (isObject(formData)) {
878
+ const acc = Object.assign({}, defaults);
879
+ return Object.keys(formData).reduce((acc2, key) => {
880
+ acc2[key] = mergeDefaultsWithFormData(
881
+ defaults ? (0, import_get5.default)(defaults, key) : {},
882
+ (0, import_get5.default)(formData, key),
883
+ mergeExtraArrayDefaults
884
+ );
885
+ return acc2;
886
+ }, acc);
887
+ }
888
+ return formData;
889
+ }
890
+
891
+ // src/mergeObjects.ts
892
+ function mergeObjects(obj1, obj2, concatArrays = false) {
893
+ return Object.keys(obj2).reduce((acc, key) => {
894
+ const left = obj1 ? obj1[key] : {}, right = obj2[key];
895
+ if (obj1 && key in obj1 && isObject(right)) {
896
+ acc[key] = mergeObjects(left, right, concatArrays);
897
+ } else if (concatArrays && Array.isArray(left) && Array.isArray(right)) {
898
+ let toMerge = right;
899
+ if (concatArrays === "preventDuplicates") {
900
+ toMerge = right.reduce((result, value) => {
901
+ if (!left.includes(value)) {
902
+ result.push(value);
903
+ }
904
+ return result;
905
+ }, []);
906
+ }
907
+ acc[key] = left.concat(toMerge);
908
+ } else {
909
+ acc[key] = right;
910
+ }
911
+ return acc;
912
+ }, Object.assign({}, obj1));
913
+ }
914
+
915
+ // src/isConstant.ts
916
+ function isConstant(schema) {
917
+ return Array.isArray(schema.enum) && schema.enum.length === 1 || CONST_KEY in schema;
918
+ }
919
+
920
+ // src/schema/isSelect.ts
921
+ function isSelect(validator, theSchema, rootSchema = {}) {
922
+ const schema = retrieveSchema(validator, theSchema, rootSchema, void 0);
923
+ const altSchemas = schema.oneOf || schema.anyOf;
924
+ if (Array.isArray(schema.enum)) {
925
+ return true;
926
+ }
927
+ if (Array.isArray(altSchemas)) {
928
+ return altSchemas.every((altSchemas2) => typeof altSchemas2 !== "boolean" && isConstant(altSchemas2));
929
+ }
930
+ return false;
931
+ }
932
+
933
+ // src/schema/isMultiSelect.ts
934
+ function isMultiSelect(validator, schema, rootSchema) {
935
+ if (!schema.uniqueItems || !schema.items || typeof schema.items === "boolean") {
936
+ return false;
937
+ }
938
+ return isSelect(validator, schema.items, rootSchema);
939
+ }
940
+
941
+ // src/schema/getDefaultFormState.ts
942
+ function getInnerSchemaForArrayItem(schema, additionalItems = 0 /* Ignore */, idx = -1) {
943
+ if (idx >= 0) {
944
+ if (Array.isArray(schema.items) && idx < schema.items.length) {
945
+ const item = schema.items[idx];
946
+ if (typeof item !== "boolean") {
947
+ return item;
948
+ }
949
+ }
950
+ } else if (schema.items && !Array.isArray(schema.items) && typeof schema.items !== "boolean") {
951
+ return schema.items;
952
+ }
953
+ if (additionalItems !== 0 /* Ignore */ && isObject(schema.additionalItems)) {
954
+ return schema.additionalItems;
955
+ }
956
+ return {};
957
+ }
958
+ function maybeAddDefaultToObject(obj, key, computedDefault, includeUndefinedValues, isParentRequired, requiredFields = [], experimental_defaultFormStateBehavior = {}) {
959
+ const { emptyObjectFields = "populateAllDefaults" } = experimental_defaultFormStateBehavior;
960
+ if (includeUndefinedValues) {
961
+ obj[key] = computedDefault;
962
+ } else if (emptyObjectFields !== "skipDefaults") {
963
+ if (isObject(computedDefault)) {
964
+ const isSelfOrParentRequired = isParentRequired === void 0 ? requiredFields.includes(key) : isParentRequired;
965
+ if ((!(0, import_isEmpty.default)(computedDefault) || requiredFields.includes(key)) && (isSelfOrParentRequired || emptyObjectFields !== "populateRequiredDefaults")) {
966
+ obj[key] = computedDefault;
967
+ }
968
+ } else if (
969
+ // Store computedDefault if it's a defined primitive (e.g., true) and satisfies certain conditions
970
+ // Condition 1: computedDefault is not undefined
971
+ // Condition 2: If emptyObjectFields is 'populateAllDefaults' or if the key is a required field
972
+ computedDefault !== void 0 && (emptyObjectFields === "populateAllDefaults" || requiredFields.includes(key))
973
+ ) {
974
+ obj[key] = computedDefault;
975
+ }
976
+ }
977
+ }
978
+ function computeDefaults(validator, rawSchema, {
979
+ parentDefaults,
980
+ rawFormData,
981
+ rootSchema = {},
982
+ includeUndefinedValues = false,
983
+ _recurseList = [],
984
+ experimental_defaultFormStateBehavior = void 0,
985
+ required
986
+ } = {}) {
987
+ const formData = isObject(rawFormData) ? rawFormData : {};
988
+ const schema = isObject(rawSchema) ? rawSchema : {};
989
+ let defaults = parentDefaults;
990
+ let schemaToCompute = null;
991
+ let updatedRecurseList = _recurseList;
992
+ if (isObject(defaults) && isObject(schema.default)) {
993
+ defaults = mergeObjects(defaults, schema.default);
994
+ } else if (DEFAULT_KEY in schema) {
995
+ defaults = schema.default;
996
+ } else if (REF_KEY in schema) {
997
+ const refName = schema[REF_KEY];
998
+ if (!_recurseList.includes(refName)) {
999
+ updatedRecurseList = _recurseList.concat(refName);
1000
+ schemaToCompute = findSchemaDefinition(refName, rootSchema);
1001
+ }
1002
+ } else if (DEPENDENCIES_KEY in schema) {
1003
+ const resolvedSchema = resolveDependencies(validator, schema, rootSchema, false, formData);
1004
+ schemaToCompute = resolvedSchema[0];
1005
+ } else if (isFixedItems(schema)) {
1006
+ defaults = schema.items.map(
1007
+ (itemSchema, idx) => computeDefaults(validator, itemSchema, {
1008
+ rootSchema,
1009
+ includeUndefinedValues,
1010
+ _recurseList,
1011
+ experimental_defaultFormStateBehavior,
1012
+ parentDefaults: Array.isArray(parentDefaults) ? parentDefaults[idx] : void 0,
1013
+ rawFormData: formData,
1014
+ required
1015
+ })
1016
+ );
1017
+ } else if (ONE_OF_KEY in schema) {
1018
+ const { oneOf, ...remaining } = schema;
1019
+ if (oneOf.length === 0) {
1020
+ return void 0;
1021
+ }
1022
+ const discriminator = getDiscriminatorFieldFromSchema(schema);
1023
+ schemaToCompute = oneOf[getClosestMatchingOption(
1024
+ validator,
1025
+ rootSchema,
1026
+ (0, import_isEmpty.default)(formData) ? void 0 : formData,
1027
+ oneOf,
1028
+ 0,
1029
+ discriminator
1030
+ )];
1031
+ schemaToCompute = mergeSchemas(remaining, schemaToCompute);
1032
+ } else if (ANY_OF_KEY in schema) {
1033
+ const { anyOf, ...remaining } = schema;
1034
+ if (anyOf.length === 0) {
1035
+ return void 0;
1036
+ }
1037
+ const discriminator = getDiscriminatorFieldFromSchema(schema);
1038
+ schemaToCompute = anyOf[getClosestMatchingOption(
1039
+ validator,
1040
+ rootSchema,
1041
+ (0, import_isEmpty.default)(formData) ? void 0 : formData,
1042
+ anyOf,
1043
+ 0,
1044
+ discriminator
1045
+ )];
1046
+ schemaToCompute = mergeSchemas(remaining, schemaToCompute);
1047
+ }
1048
+ if (schemaToCompute) {
1049
+ return computeDefaults(validator, schemaToCompute, {
1050
+ rootSchema,
1051
+ includeUndefinedValues,
1052
+ _recurseList: updatedRecurseList,
1053
+ experimental_defaultFormStateBehavior,
1054
+ parentDefaults: defaults,
1055
+ rawFormData: formData,
1056
+ required
1057
+ });
1058
+ }
1059
+ if (defaults === void 0) {
1060
+ defaults = schema.default;
1061
+ }
1062
+ switch (getSchemaType(schema)) {
1063
+ case "object": {
1064
+ const objectDefaults = Object.keys(schema.properties || {}).reduce((acc, key) => {
1065
+ const computedDefault = computeDefaults(validator, (0, import_get6.default)(schema, [PROPERTIES_KEY, key]), {
1066
+ rootSchema,
1067
+ _recurseList,
1068
+ experimental_defaultFormStateBehavior,
1069
+ includeUndefinedValues: includeUndefinedValues === true,
1070
+ parentDefaults: (0, import_get6.default)(defaults, [key]),
1071
+ rawFormData: (0, import_get6.default)(formData, [key]),
1072
+ required: schema.required?.includes(key)
1073
+ });
1074
+ maybeAddDefaultToObject(
1075
+ acc,
1076
+ key,
1077
+ computedDefault,
1078
+ includeUndefinedValues,
1079
+ required,
1080
+ schema.required,
1081
+ experimental_defaultFormStateBehavior
1082
+ );
1083
+ return acc;
1084
+ }, {});
1085
+ if (schema.additionalProperties) {
1086
+ const additionalPropertiesSchema = isObject(schema.additionalProperties) ? schema.additionalProperties : {};
1087
+ const keys = /* @__PURE__ */ new Set();
1088
+ if (isObject(defaults)) {
1089
+ Object.keys(defaults).filter((key) => !schema.properties || !schema.properties[key]).forEach((key) => keys.add(key));
1090
+ }
1091
+ let formDataRequired;
1092
+ if (isObject(formData)) {
1093
+ formDataRequired = [];
1094
+ Object.keys(formData).filter((key) => !schema.properties || !schema.properties[key]).forEach((key) => {
1095
+ keys.add(key);
1096
+ formDataRequired.push(key);
1097
+ });
1098
+ }
1099
+ keys.forEach((key) => {
1100
+ const computedDefault = computeDefaults(validator, additionalPropertiesSchema, {
1101
+ rootSchema,
1102
+ _recurseList,
1103
+ experimental_defaultFormStateBehavior,
1104
+ includeUndefinedValues: includeUndefinedValues === true,
1105
+ parentDefaults: (0, import_get6.default)(defaults, [key]),
1106
+ rawFormData: (0, import_get6.default)(formData, [key]),
1107
+ required: schema.required?.includes(key)
1108
+ });
1109
+ maybeAddDefaultToObject(
1110
+ objectDefaults,
1111
+ key,
1112
+ computedDefault,
1113
+ includeUndefinedValues,
1114
+ required,
1115
+ formDataRequired
1116
+ );
1117
+ });
1118
+ }
1119
+ return objectDefaults;
1120
+ }
1121
+ case "array": {
1122
+ const neverPopulate = experimental_defaultFormStateBehavior?.arrayMinItems?.populate === "never";
1123
+ const ignoreMinItemsFlagSet = experimental_defaultFormStateBehavior?.arrayMinItems?.populate === "requiredOnly";
1124
+ if (Array.isArray(defaults)) {
1125
+ defaults = defaults.map((item, idx) => {
1126
+ const schemaItem = getInnerSchemaForArrayItem(schema, 2 /* Fallback */, idx);
1127
+ return computeDefaults(validator, schemaItem, {
1128
+ rootSchema,
1129
+ _recurseList,
1130
+ experimental_defaultFormStateBehavior,
1131
+ parentDefaults: item,
1132
+ required
1133
+ });
1134
+ });
1135
+ }
1136
+ if (Array.isArray(rawFormData)) {
1137
+ const schemaItem = getInnerSchemaForArrayItem(schema);
1138
+ if (neverPopulate) {
1139
+ defaults = rawFormData;
1140
+ } else {
1141
+ defaults = rawFormData.map((item, idx) => {
1142
+ return computeDefaults(validator, schemaItem, {
1143
+ rootSchema,
1144
+ _recurseList,
1145
+ experimental_defaultFormStateBehavior,
1146
+ rawFormData: item,
1147
+ parentDefaults: (0, import_get6.default)(defaults, [idx]),
1148
+ required
1149
+ });
1150
+ });
1151
+ }
1152
+ }
1153
+ if (neverPopulate) {
1154
+ return defaults ?? [];
1155
+ }
1156
+ if (ignoreMinItemsFlagSet && !required) {
1157
+ return defaults ? defaults : void 0;
1158
+ }
1159
+ const defaultsLength = Array.isArray(defaults) ? defaults.length : 0;
1160
+ if (!schema.minItems || isMultiSelect(validator, schema, rootSchema) || schema.minItems <= defaultsLength) {
1161
+ return defaults ? defaults : [];
1162
+ }
1163
+ const defaultEntries = defaults || [];
1164
+ const fillerSchema = getInnerSchemaForArrayItem(schema, 1 /* Invert */);
1165
+ const fillerDefault = fillerSchema.default;
1166
+ const fillerEntries = new Array(schema.minItems - defaultsLength).fill(
1167
+ computeDefaults(validator, fillerSchema, {
1168
+ parentDefaults: fillerDefault,
1169
+ rootSchema,
1170
+ _recurseList,
1171
+ experimental_defaultFormStateBehavior,
1172
+ required
1173
+ })
1174
+ );
1175
+ return defaultEntries.concat(fillerEntries);
1176
+ }
1177
+ }
1178
+ return defaults;
1179
+ }
1180
+ function getDefaultFormState(validator, theSchema, formData, rootSchema, includeUndefinedValues = false, experimental_defaultFormStateBehavior) {
1181
+ if (!isObject(theSchema)) {
1182
+ throw new Error("Invalid schema: " + theSchema);
1183
+ }
1184
+ const schema = retrieveSchema(validator, theSchema, rootSchema, formData);
1185
+ const defaults = computeDefaults(validator, schema, {
1186
+ rootSchema,
1187
+ includeUndefinedValues,
1188
+ experimental_defaultFormStateBehavior,
1189
+ rawFormData: formData
1190
+ });
1191
+ if (formData === void 0 || formData === null || typeof formData === "number" && isNaN(formData)) {
1192
+ return defaults;
1193
+ }
1194
+ const { mergeExtraDefaults } = experimental_defaultFormStateBehavior?.arrayMinItems || {};
1195
+ if (isObject(formData)) {
1196
+ return mergeDefaultsWithFormData(defaults, formData, mergeExtraDefaults);
1197
+ }
1198
+ if (Array.isArray(formData)) {
1199
+ return mergeDefaultsWithFormData(defaults, formData, mergeExtraDefaults);
1200
+ }
1201
+ return formData;
1202
+ }
1203
+
1204
+ // src/isCustomWidget.ts
1205
+ function isCustomWidget(uiSchema = {}) {
1206
+ return (
1207
+ // TODO: Remove the `&& uiSchema['ui:widget'] !== 'hidden'` once we support hidden widgets for arrays.
1208
+ // https://rjsf-team.github.io/react-jsonschema-form/docs/usage/widgets/#hidden-widgets
1209
+ "widget" in getUiOptions(uiSchema) && getUiOptions(uiSchema)["widget"] !== "hidden"
1210
+ );
1211
+ }
1212
+
1213
+ // src/schema/isFilesArray.ts
1214
+ function isFilesArray(validator, schema, uiSchema = {}, rootSchema) {
1215
+ if (uiSchema[UI_WIDGET_KEY] === "files") {
1216
+ return true;
1217
+ }
1218
+ if (schema.items) {
1219
+ const itemsSchema = retrieveSchema(validator, schema.items, rootSchema);
1220
+ return itemsSchema.type === "string" && itemsSchema.format === "data-url";
1221
+ }
1222
+ return false;
1223
+ }
1224
+
1225
+ // src/schema/getDisplayLabel.ts
1226
+ function getDisplayLabel(validator, schema, uiSchema = {}, rootSchema, globalOptions) {
1227
+ const uiOptions = getUiOptions(uiSchema, globalOptions);
1228
+ const { label = true } = uiOptions;
1229
+ let displayLabel = !!label;
1230
+ const schemaType = getSchemaType(schema);
1231
+ if (schemaType === "array") {
1232
+ displayLabel = isMultiSelect(validator, schema, rootSchema) || isFilesArray(validator, schema, uiSchema, rootSchema) || isCustomWidget(uiSchema);
1233
+ }
1234
+ if (schemaType === "object") {
1235
+ displayLabel = false;
1236
+ }
1237
+ if (schemaType === "boolean" && !uiSchema[UI_WIDGET_KEY]) {
1238
+ displayLabel = false;
1239
+ }
1240
+ if (uiSchema[UI_FIELD_KEY]) {
1241
+ displayLabel = false;
1242
+ }
1243
+ return displayLabel;
1244
+ }
1245
+
1246
+ // src/schema/mergeValidationData.ts
1247
+ var import_isEmpty2 = __toESM(require("lodash/isEmpty"));
1248
+ function mergeValidationData(validator, validationData, additionalErrorSchema) {
1249
+ if (!additionalErrorSchema) {
1250
+ return validationData;
1251
+ }
1252
+ const { errors: oldErrors, errorSchema: oldErrorSchema } = validationData;
1253
+ let errors = validator.toErrorList(additionalErrorSchema);
1254
+ let errorSchema = additionalErrorSchema;
1255
+ if (!(0, import_isEmpty2.default)(oldErrorSchema)) {
1256
+ errorSchema = mergeObjects(oldErrorSchema, additionalErrorSchema, true);
1257
+ errors = [...oldErrors].concat(errors);
1258
+ }
1259
+ return { errorSchema, errors };
1260
+ }
1261
+
1262
+ // src/schema/sanitizeDataForNewSchema.ts
1263
+ var import_get7 = __toESM(require("lodash/get"));
1264
+ var import_has3 = __toESM(require("lodash/has"));
1265
+ var NO_VALUE = Symbol("no Value");
1266
+ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, data = {}) {
1267
+ let newFormData;
1268
+ if ((0, import_has3.default)(newSchema, PROPERTIES_KEY)) {
1269
+ const removeOldSchemaData = {};
1270
+ if ((0, import_has3.default)(oldSchema, PROPERTIES_KEY)) {
1271
+ const properties = (0, import_get7.default)(oldSchema, PROPERTIES_KEY, {});
1272
+ Object.keys(properties).forEach((key) => {
1273
+ if ((0, import_has3.default)(data, key)) {
1274
+ removeOldSchemaData[key] = void 0;
1275
+ }
1276
+ });
1277
+ }
1278
+ const keys = Object.keys((0, import_get7.default)(newSchema, PROPERTIES_KEY, {}));
1279
+ const nestedData = {};
1280
+ keys.forEach((key) => {
1281
+ const formValue = (0, import_get7.default)(data, key);
1282
+ let oldKeyedSchema = (0, import_get7.default)(oldSchema, [PROPERTIES_KEY, key], {});
1283
+ let newKeyedSchema = (0, import_get7.default)(newSchema, [PROPERTIES_KEY, key], {});
1284
+ if ((0, import_has3.default)(oldKeyedSchema, REF_KEY)) {
1285
+ oldKeyedSchema = retrieveSchema(validator, oldKeyedSchema, rootSchema, formValue);
1286
+ }
1287
+ if ((0, import_has3.default)(newKeyedSchema, REF_KEY)) {
1288
+ newKeyedSchema = retrieveSchema(validator, newKeyedSchema, rootSchema, formValue);
1289
+ }
1290
+ const oldSchemaTypeForKey = (0, import_get7.default)(oldKeyedSchema, "type");
1291
+ const newSchemaTypeForKey = (0, import_get7.default)(newKeyedSchema, "type");
1292
+ if (!oldSchemaTypeForKey || oldSchemaTypeForKey === newSchemaTypeForKey) {
1293
+ if ((0, import_has3.default)(removeOldSchemaData, key)) {
1294
+ delete removeOldSchemaData[key];
1295
+ }
1296
+ if (newSchemaTypeForKey === "object" || newSchemaTypeForKey === "array" && Array.isArray(formValue)) {
1297
+ const itemData = sanitizeDataForNewSchema(
1298
+ validator,
1299
+ rootSchema,
1300
+ newKeyedSchema,
1301
+ oldKeyedSchema,
1302
+ formValue
1303
+ );
1304
+ if (itemData !== void 0 || newSchemaTypeForKey === "array") {
1305
+ nestedData[key] = itemData;
1306
+ }
1307
+ } else {
1308
+ const newOptionDefault = (0, import_get7.default)(newKeyedSchema, "default", NO_VALUE);
1309
+ const oldOptionDefault = (0, import_get7.default)(oldKeyedSchema, "default", NO_VALUE);
1310
+ if (newOptionDefault !== NO_VALUE && newOptionDefault !== formValue) {
1311
+ if (oldOptionDefault === formValue) {
1312
+ removeOldSchemaData[key] = newOptionDefault;
1313
+ } else if ((0, import_get7.default)(newKeyedSchema, "readOnly") === true) {
1314
+ removeOldSchemaData[key] = void 0;
1315
+ }
1316
+ }
1317
+ const newOptionConst = (0, import_get7.default)(newKeyedSchema, "const", NO_VALUE);
1318
+ const oldOptionConst = (0, import_get7.default)(oldKeyedSchema, "const", NO_VALUE);
1319
+ if (newOptionConst !== NO_VALUE && newOptionConst !== formValue) {
1320
+ removeOldSchemaData[key] = oldOptionConst === formValue ? newOptionConst : void 0;
1321
+ }
1322
+ }
1323
+ }
1324
+ });
1325
+ newFormData = {
1326
+ ...data,
1327
+ ...removeOldSchemaData,
1328
+ ...nestedData
1329
+ };
1330
+ } else if ((0, import_get7.default)(oldSchema, "type") === "array" && (0, import_get7.default)(newSchema, "type") === "array" && Array.isArray(data)) {
1331
+ let oldSchemaItems = (0, import_get7.default)(oldSchema, "items");
1332
+ let newSchemaItems = (0, import_get7.default)(newSchema, "items");
1333
+ if (typeof oldSchemaItems === "object" && typeof newSchemaItems === "object" && !Array.isArray(oldSchemaItems) && !Array.isArray(newSchemaItems)) {
1334
+ if ((0, import_has3.default)(oldSchemaItems, REF_KEY)) {
1335
+ oldSchemaItems = retrieveSchema(validator, oldSchemaItems, rootSchema, data);
1336
+ }
1337
+ if ((0, import_has3.default)(newSchemaItems, REF_KEY)) {
1338
+ newSchemaItems = retrieveSchema(validator, newSchemaItems, rootSchema, data);
1339
+ }
1340
+ const oldSchemaType = (0, import_get7.default)(oldSchemaItems, "type");
1341
+ const newSchemaType = (0, import_get7.default)(newSchemaItems, "type");
1342
+ if (!oldSchemaType || oldSchemaType === newSchemaType) {
1343
+ const maxItems = (0, import_get7.default)(newSchema, "maxItems", -1);
1344
+ if (newSchemaType === "object") {
1345
+ newFormData = data.reduce((newValue, aValue) => {
1346
+ const itemValue = sanitizeDataForNewSchema(
1347
+ validator,
1348
+ rootSchema,
1349
+ newSchemaItems,
1350
+ oldSchemaItems,
1351
+ aValue
1352
+ );
1353
+ if (itemValue !== void 0 && (maxItems < 0 || newValue.length < maxItems)) {
1354
+ newValue.push(itemValue);
1355
+ }
1356
+ return newValue;
1357
+ }, []);
1358
+ } else {
1359
+ newFormData = maxItems > 0 && data.length > maxItems ? data.slice(0, maxItems) : data;
1360
+ }
1361
+ }
1362
+ } else if (typeof oldSchemaItems === "boolean" && typeof newSchemaItems === "boolean" && oldSchemaItems === newSchemaItems) {
1363
+ newFormData = data;
1364
+ }
1365
+ }
1366
+ return newFormData;
1367
+ }
1368
+
1369
+ // src/schema/toIdSchema.ts
1370
+ var import_get8 = __toESM(require("lodash/get"));
1371
+ var import_isEqual = __toESM(require("lodash/isEqual"));
1372
+ function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList = []) {
1373
+ if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1374
+ const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1375
+ const sameSchemaIndex = _recurseList.findIndex((item) => (0, import_isEqual.default)(item, _schema));
1376
+ if (sameSchemaIndex === -1) {
1377
+ return toIdSchemaInternal(
1378
+ validator,
1379
+ _schema,
1380
+ idPrefix,
1381
+ idSeparator,
1382
+ id,
1383
+ rootSchema,
1384
+ formData,
1385
+ _recurseList.concat(_schema)
1386
+ );
1387
+ }
1388
+ }
1389
+ if (ITEMS_KEY in schema && !(0, import_get8.default)(schema, [ITEMS_KEY, REF_KEY])) {
1390
+ return toIdSchemaInternal(
1391
+ validator,
1392
+ (0, import_get8.default)(schema, ITEMS_KEY),
1393
+ idPrefix,
1394
+ idSeparator,
1395
+ id,
1396
+ rootSchema,
1397
+ formData,
1398
+ _recurseList
1399
+ );
1400
+ }
1401
+ const $id = id || idPrefix;
1402
+ const idSchema = { $id };
1403
+ if (getSchemaType(schema) === "object" && PROPERTIES_KEY in schema) {
1404
+ for (const name in schema.properties) {
1405
+ const field = (0, import_get8.default)(schema, [PROPERTIES_KEY, name]);
1406
+ const fieldId = idSchema[ID_KEY] + idSeparator + name;
1407
+ idSchema[name] = toIdSchemaInternal(
1408
+ validator,
1409
+ isObject(field) ? field : {},
1410
+ idPrefix,
1411
+ idSeparator,
1412
+ fieldId,
1413
+ rootSchema,
1414
+ // It's possible that formData is not an object -- this can happen if an
1415
+ // array item has just been added, but not populated with data yet
1416
+ (0, import_get8.default)(formData, [name]),
1417
+ _recurseList
1418
+ );
1419
+ }
1420
+ }
1421
+ return idSchema;
1422
+ }
1423
+ function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix = "root", idSeparator = "_") {
1424
+ return toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData);
1425
+ }
1426
+
1427
+ // src/schema/toPathSchema.ts
1428
+ var import_get9 = __toESM(require("lodash/get"));
1429
+ var import_isEqual2 = __toESM(require("lodash/isEqual"));
1430
+ var import_set2 = __toESM(require("lodash/set"));
1431
+ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = []) {
1432
+ if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1433
+ const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1434
+ const sameSchemaIndex = _recurseList.findIndex((item) => (0, import_isEqual2.default)(item, _schema));
1435
+ if (sameSchemaIndex === -1) {
1436
+ return toPathSchemaInternal(
1437
+ validator,
1438
+ _schema,
1439
+ name,
1440
+ rootSchema,
1441
+ formData,
1442
+ _recurseList.concat(_schema)
1443
+ );
1444
+ }
1445
+ }
1446
+ let pathSchema = {
1447
+ [NAME_KEY]: name.replace(/^\./, "")
1448
+ };
1449
+ if (ONE_OF_KEY in schema || ANY_OF_KEY in schema) {
1450
+ const xxxOf = ONE_OF_KEY in schema ? schema.oneOf : schema.anyOf;
1451
+ const discriminator = getDiscriminatorFieldFromSchema(schema);
1452
+ const index = getClosestMatchingOption(validator, rootSchema, formData, xxxOf, 0, discriminator);
1453
+ const _schema = xxxOf[index];
1454
+ pathSchema = {
1455
+ ...pathSchema,
1456
+ ...toPathSchemaInternal(validator, _schema, name, rootSchema, formData, _recurseList)
1457
+ };
1458
+ }
1459
+ if (ADDITIONAL_PROPERTIES_KEY in schema && schema[ADDITIONAL_PROPERTIES_KEY] !== false) {
1460
+ (0, import_set2.default)(pathSchema, RJSF_ADDITONAL_PROPERTIES_FLAG, true);
1461
+ }
1462
+ if (ITEMS_KEY in schema && Array.isArray(formData)) {
1463
+ formData.forEach((element, i) => {
1464
+ pathSchema[i] = toPathSchemaInternal(
1465
+ validator,
1466
+ schema.items,
1467
+ `${name}.${i}`,
1468
+ rootSchema,
1469
+ element,
1470
+ _recurseList
1471
+ );
1472
+ });
1473
+ } else if (PROPERTIES_KEY in schema) {
1474
+ for (const property in schema.properties) {
1475
+ const field = (0, import_get9.default)(schema, [PROPERTIES_KEY, property]);
1476
+ pathSchema[property] = toPathSchemaInternal(
1477
+ validator,
1478
+ field,
1479
+ `${name}.${property}`,
1480
+ rootSchema,
1481
+ // It's possible that formData is not an object -- this can happen if an
1482
+ // array item has just been added, but not populated with data yet
1483
+ (0, import_get9.default)(formData, [property]),
1484
+ _recurseList
1485
+ );
1486
+ }
1487
+ }
1488
+ return pathSchema;
1489
+ }
1490
+ function toPathSchema(validator, schema, name = "", rootSchema, formData) {
1491
+ return toPathSchemaInternal(validator, schema, name, rootSchema, formData);
1492
+ }
1493
+
1494
+ // src/createSchemaUtils.ts
1495
+ var SchemaUtils = class {
1496
+ /** Constructs the `SchemaUtils` instance with the given `validator` and `rootSchema` stored as instance variables
1497
+ *
1498
+ * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
1499
+ * @param rootSchema - The root schema that will be forwarded to all the APIs
1500
+ * @param experimental_defaultFormStateBehavior - Configuration flags to allow users to override default form state behavior
1501
+ */
1502
+ constructor(validator, rootSchema, experimental_defaultFormStateBehavior) {
1503
+ this.rootSchema = rootSchema;
1504
+ this.validator = validator;
1505
+ this.experimental_defaultFormStateBehavior = experimental_defaultFormStateBehavior;
1506
+ }
1507
+ /** Returns the `ValidatorType` in the `SchemaUtilsType`
1508
+ *
1509
+ * @returns - The `ValidatorType`
1510
+ */
1511
+ getValidator() {
1512
+ return this.validator;
1513
+ }
1514
+ /** Determines whether either the `validator` and `rootSchema` differ from the ones associated with this instance of
1515
+ * the `SchemaUtilsType`. If either `validator` or `rootSchema` are falsy, then return false to prevent the creation
1516
+ * of a new `SchemaUtilsType` with incomplete properties.
1517
+ *
1518
+ * @param validator - An implementation of the `ValidatorType` interface that will be compared against the current one
1519
+ * @param rootSchema - The root schema that will be compared against the current one
1520
+ * @param [experimental_defaultFormStateBehavior] Optional configuration object, if provided, allows users to override default form state behavior
1521
+ * @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`
1522
+ */
1523
+ doesSchemaUtilsDiffer(validator, rootSchema, experimental_defaultFormStateBehavior = {}) {
1524
+ if (!validator || !rootSchema) {
1525
+ return false;
1526
+ }
1527
+ return this.validator !== validator || !deepEquals(this.rootSchema, rootSchema) || !deepEquals(this.experimental_defaultFormStateBehavior, experimental_defaultFormStateBehavior);
1528
+ }
1529
+ /** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
1530
+ * computed to have defaults provided in the `schema`.
1531
+ *
1532
+ * @param schema - The schema for which the default state is desired
1533
+ * @param [formData] - The current formData, if any, onto which to provide any missing defaults
1534
+ * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults.
1535
+ * If "excludeObjectChildren", pass `includeUndefinedValues` as false when computing defaults for any nested
1536
+ * object properties.
1537
+ * @returns - The resulting `formData` with all the defaults provided
1538
+ */
1539
+ getDefaultFormState(schema, formData, includeUndefinedValues = false) {
1540
+ return getDefaultFormState(
1541
+ this.validator,
1542
+ schema,
1543
+ formData,
1544
+ this.rootSchema,
1545
+ includeUndefinedValues,
1546
+ this.experimental_defaultFormStateBehavior
1547
+ );
1548
+ }
1549
+ /** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`
1550
+ * should be displayed in a UI.
1551
+ *
1552
+ * @param schema - The schema for which the display label flag is desired
1553
+ * @param [uiSchema] - The UI schema from which to derive potentially displayable information
1554
+ * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
1555
+ * @returns - True if the label should be displayed or false if it should not
1556
+ */
1557
+ getDisplayLabel(schema, uiSchema, globalOptions) {
1558
+ return getDisplayLabel(this.validator, schema, uiSchema, this.rootSchema, globalOptions);
1559
+ }
1560
+ /** Determines which of the given `options` provided most closely matches the `formData`.
1561
+ * Returns the index of the option that is valid and is the closest match, or 0 if there is no match.
1562
+ *
1563
+ * The closest match is determined using the number of matching properties, and more heavily favors options with
1564
+ * matching readOnly, default, or const values.
1565
+ *
1566
+ * @param formData - The form data associated with the schema
1567
+ * @param options - The list of options that can be selected from
1568
+ * @param [selectedOption] - The index of the currently selected option, defaulted to -1 if not specified
1569
+ * @param [discriminatorField] - The optional name of the field within the options object whose value is used to
1570
+ * determine which option is selected
1571
+ * @returns - The index of the option that is the closest match to the `formData` or the `selectedOption` if no match
1572
+ */
1573
+ getClosestMatchingOption(formData, options, selectedOption, discriminatorField) {
1574
+ return getClosestMatchingOption(
1575
+ this.validator,
1576
+ this.rootSchema,
1577
+ formData,
1578
+ options,
1579
+ selectedOption,
1580
+ discriminatorField
1581
+ );
1582
+ }
1583
+ /** Given the `formData` and list of `options`, attempts to find the index of the first option that matches the data.
1584
+ * Always returns the first option if there is nothing that matches.
1585
+ *
1586
+ * @param formData - The current formData, if any, used to figure out a match
1587
+ * @param options - The list of options to find a matching options from
1588
+ * @param [discriminatorField] - The optional name of the field within the options object whose value is used to
1589
+ * determine which option is selected
1590
+ * @returns - The firstindex of the matched option or 0 if none is available
1591
+ */
1592
+ getFirstMatchingOption(formData, options, discriminatorField) {
1593
+ return getFirstMatchingOption(this.validator, formData, options, this.rootSchema, discriminatorField);
1594
+ }
1595
+ /** Given the `formData` and list of `options`, attempts to find the index of the option that best matches the data.
1596
+ * Deprecated, use `getFirstMatchingOption()` instead.
1597
+ *
1598
+ * @param formData - The current formData, if any, onto which to provide any missing defaults
1599
+ * @param options - The list of options to find a matching options from
1600
+ * @param [discriminatorField] - The optional name of the field within the options object whose value is used to
1601
+ * determine which option is selected
1602
+ * @returns - The index of the matched option or 0 if none is available
1603
+ * @deprecated
1604
+ */
1605
+ getMatchingOption(formData, options, discriminatorField) {
1606
+ return getMatchingOption(this.validator, formData, options, this.rootSchema, discriminatorField);
1607
+ }
1608
+ /** Checks to see if the `schema` and `uiSchema` combination represents an array of files
1609
+ *
1610
+ * @param schema - The schema for which check for array of files flag is desired
1611
+ * @param [uiSchema] - The UI schema from which to check the widget
1612
+ * @returns - True if schema/uiSchema contains an array of files, otherwise false
1613
+ */
1614
+ isFilesArray(schema, uiSchema) {
1615
+ return isFilesArray(this.validator, schema, uiSchema, this.rootSchema);
1616
+ }
1617
+ /** Checks to see if the `schema` combination represents a multi-select
1618
+ *
1619
+ * @param schema - The schema for which check for a multi-select flag is desired
1620
+ * @returns - True if schema contains a multi-select, otherwise false
1621
+ */
1622
+ isMultiSelect(schema) {
1623
+ return isMultiSelect(this.validator, schema, this.rootSchema);
1624
+ }
1625
+ /** Checks to see if the `schema` combination represents a select
1626
+ *
1627
+ * @param schema - The schema for which check for a select flag is desired
1628
+ * @returns - True if schema contains a select, otherwise false
1629
+ */
1630
+ isSelect(schema) {
1631
+ return isSelect(this.validator, schema, this.rootSchema);
1632
+ }
1633
+ /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in
1634
+ * the two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
1635
+ * `getValidator().toErrorList()` onto the `errors` in the `validationData`. If no `additionalErrorSchema` is passed,
1636
+ * then `validationData` is returned.
1637
+ *
1638
+ * @param validationData - The current `ValidationData` into which to merge the additional errors
1639
+ * @param [additionalErrorSchema] - The additional set of errors
1640
+ * @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
1641
+ * @deprecated - Use the `validationDataMerge()` function exported from `@rjsf/utils` instead. This function will be
1642
+ * removed in the next major release.
1643
+ */
1644
+ mergeValidationData(validationData, additionalErrorSchema) {
1645
+ return mergeValidationData(this.validator, validationData, additionalErrorSchema);
1646
+ }
1647
+ /** Retrieves an expanded schema that has had all of its conditions, additional properties, references and
1648
+ * dependencies resolved and merged into the `schema` given a `rawFormData` that is used to do the potentially
1649
+ * recursive resolution.
1650
+ *
1651
+ * @param schema - The schema for which retrieving a schema is desired
1652
+ * @param [rawFormData] - The current formData, if any, to assist retrieving a schema
1653
+ * @returns - The schema having its conditions, additional properties, references and dependencies resolved
1654
+ */
1655
+ retrieveSchema(schema, rawFormData) {
1656
+ return retrieveSchema(this.validator, schema, this.rootSchema, rawFormData);
1657
+ }
1658
+ /** Sanitize the `data` associated with the `oldSchema` so it is considered appropriate for the `newSchema`. If the
1659
+ * new schema does not contain any properties, then `undefined` is returned to clear all the form data. Due to the
1660
+ * nature of schemas, this sanitization happens recursively for nested objects of data. Also, any properties in the
1661
+ * old schemas that are non-existent in the new schema are set to `undefined`.
1662
+ *
1663
+ * @param [newSchema] - The new schema for which the data is being sanitized
1664
+ * @param [oldSchema] - The old schema from which the data originated
1665
+ * @param [data={}] - The form data associated with the schema, defaulting to an empty object when undefined
1666
+ * @returns - The new form data, with all the fields uniquely associated with the old schema set
1667
+ * to `undefined`. Will return `undefined` if the new schema is not an object containing properties.
1668
+ */
1669
+ sanitizeDataForNewSchema(newSchema, oldSchema, data) {
1670
+ return sanitizeDataForNewSchema(this.validator, this.rootSchema, newSchema, oldSchema, data);
1671
+ }
1672
+ /** Generates an `IdSchema` object for the `schema`, recursively
1673
+ *
1674
+ * @param schema - The schema for which the display label flag is desired
1675
+ * @param [id] - The base id for the schema
1676
+ * @param [formData] - The current formData, if any, onto which to provide any missing defaults
1677
+ * @param [idPrefix='root'] - The prefix to use for the id
1678
+ * @param [idSeparator='_'] - The separator to use for the path segments in the id
1679
+ * @returns - The `IdSchema` object for the `schema`
1680
+ */
1681
+ toIdSchema(schema, id, formData, idPrefix = "root", idSeparator = "_") {
1682
+ return toIdSchema(this.validator, schema, id, this.rootSchema, formData, idPrefix, idSeparator);
1683
+ }
1684
+ /** Generates an `PathSchema` object for the `schema`, recursively
1685
+ *
1686
+ * @param schema - The schema for which the display label flag is desired
1687
+ * @param [name] - The base name for the schema
1688
+ * @param [formData] - The current formData, if any, onto which to provide any missing defaults
1689
+ * @returns - The `PathSchema` object for the `schema`
1690
+ */
1691
+ toPathSchema(schema, name, formData) {
1692
+ return toPathSchema(this.validator, schema, name, this.rootSchema, formData);
1693
+ }
1694
+ };
1695
+ function createSchemaUtils(validator, rootSchema, experimental_defaultFormStateBehavior = {}) {
1696
+ return new SchemaUtils(validator, rootSchema, experimental_defaultFormStateBehavior);
1697
+ }
1698
+
1699
+ // src/dataURItoBlob.ts
1700
+ function dataURItoBlob(dataURI) {
1701
+ const splitted = dataURI.split(",");
1702
+ const params = splitted[0].split(";");
1703
+ const type = params[0].replace("data:", "");
1704
+ const properties = params.filter((param) => {
1705
+ return param.split("=")[0] === "name";
1706
+ });
1707
+ let name;
1708
+ if (properties.length !== 1) {
1709
+ name = "unknown";
1710
+ } else {
1711
+ name = decodeURI(properties[0].split("=")[1]);
1712
+ }
1713
+ try {
1714
+ const binary = atob(splitted[1]);
1715
+ const array = [];
1716
+ for (let i = 0; i < binary.length; i++) {
1717
+ array.push(binary.charCodeAt(i));
1718
+ }
1719
+ const blob = new window.Blob([new Uint8Array(array)], { type });
1720
+ return { blob, name };
1721
+ } catch (error) {
1722
+ return { blob: { size: 0, type: error.message }, name: dataURI };
1723
+ }
1724
+ }
1725
+
1726
+ // src/replaceStringParameters.ts
1727
+ function replaceStringParameters(inputString, params) {
1728
+ let output = inputString;
1729
+ if (Array.isArray(params)) {
1730
+ const parts = output.split(/(%\d)/);
1731
+ params.forEach((param, index) => {
1732
+ const partIndex = parts.findIndex((part) => part === `%${index + 1}`);
1733
+ if (partIndex >= 0) {
1734
+ parts[partIndex] = param;
1735
+ }
1736
+ });
1737
+ output = parts.join("");
1738
+ }
1739
+ return output;
1740
+ }
1741
+
1742
+ // src/englishStringTranslator.ts
1743
+ function englishStringTranslator(stringToTranslate, params) {
1744
+ return replaceStringParameters(stringToTranslate, params);
1745
+ }
1746
+
1747
+ // src/enumOptionsDeselectValue.ts
1748
+ var import_isEqual3 = __toESM(require("lodash/isEqual"));
1749
+
1750
+ // src/enumOptionsValueForIndex.ts
1751
+ function enumOptionsValueForIndex(valueIndex, allEnumOptions = [], emptyValue) {
1752
+ if (Array.isArray(valueIndex)) {
1753
+ return valueIndex.map((index2) => enumOptionsValueForIndex(index2, allEnumOptions)).filter((val) => val);
1754
+ }
1755
+ const index = valueIndex === "" || valueIndex === null ? -1 : Number(valueIndex);
1756
+ const option = allEnumOptions[index];
1757
+ return option ? option.value : emptyValue;
1758
+ }
1759
+
1760
+ // src/enumOptionsDeselectValue.ts
1761
+ function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
1762
+ const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
1763
+ if (Array.isArray(selected)) {
1764
+ return selected.filter((v) => !(0, import_isEqual3.default)(v, value));
1765
+ }
1766
+ return (0, import_isEqual3.default)(value, selected) ? void 0 : selected;
1767
+ }
1768
+
1769
+ // src/enumOptionsIsSelected.ts
1770
+ var import_isEqual4 = __toESM(require("lodash/isEqual"));
1771
+ function enumOptionsIsSelected(value, selected) {
1772
+ if (Array.isArray(selected)) {
1773
+ return selected.some((sel) => (0, import_isEqual4.default)(sel, value));
1774
+ }
1775
+ return (0, import_isEqual4.default)(selected, value);
1776
+ }
1777
+
1778
+ // src/enumOptionsIndexForValue.ts
1779
+ function enumOptionsIndexForValue(value, allEnumOptions = [], multiple = false) {
1780
+ const selectedIndexes = allEnumOptions.map((opt, index) => enumOptionsIsSelected(opt.value, value) ? String(index) : void 0).filter((opt) => typeof opt !== "undefined");
1781
+ if (!multiple) {
1782
+ return selectedIndexes[0];
1783
+ }
1784
+ return selectedIndexes;
1785
+ }
1786
+
1787
+ // src/enumOptionsSelectValue.ts
1788
+ var import_lodash = require("lodash");
1789
+ function enumOptionsSelectValue(valueIndex, selected, allEnumOptions = []) {
1790
+ const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
1791
+ if (!(0, import_lodash.isNil)(value)) {
1792
+ const index = allEnumOptions.findIndex((opt) => value === opt.value);
1793
+ const all = allEnumOptions.map(({ value: val }) => val);
1794
+ const updated = selected.slice(0, index).concat(value, selected.slice(index));
1795
+ return updated.sort((a, b) => Number(all.indexOf(a) > all.indexOf(b)));
1796
+ }
1797
+ return selected;
1798
+ }
1799
+
1800
+ // src/ErrorSchemaBuilder.ts
1801
+ var import_cloneDeep = __toESM(require("lodash/cloneDeep"));
1802
+ var import_get10 = __toESM(require("lodash/get"));
1803
+ var import_set3 = __toESM(require("lodash/set"));
1804
+ var ErrorSchemaBuilder = class {
1805
+ /** Construct an `ErrorSchemaBuilder` with an optional initial set of errors in an `ErrorSchema`.
1806
+ *
1807
+ * @param [initialSchema] - The optional set of initial errors, that will be cloned into the class
1808
+ */
1809
+ constructor(initialSchema) {
1810
+ /** The error schema being built
1811
+ *
1812
+ * @private
1813
+ */
1814
+ this.errorSchema = {};
1815
+ this.resetAllErrors(initialSchema);
1816
+ }
1817
+ /** Returns the `ErrorSchema` that has been updated by the methods of the `ErrorSchemaBuilder`
1818
+ */
1819
+ get ErrorSchema() {
1820
+ return this.errorSchema;
1821
+ }
1822
+ /** Will get an existing `ErrorSchema` at the specified `pathOfError` or create and return one.
1823
+ *
1824
+ * @param [pathOfError] - The optional path into the `ErrorSchema` at which to add the error(s)
1825
+ * @returns - The error block for the given `pathOfError` or the root if not provided
1826
+ * @private
1827
+ */
1828
+ getOrCreateErrorBlock(pathOfError) {
1829
+ const hasPath = Array.isArray(pathOfError) && pathOfError.length > 0 || typeof pathOfError === "string";
1830
+ let errorBlock = hasPath ? (0, import_get10.default)(this.errorSchema, pathOfError) : this.errorSchema;
1831
+ if (!errorBlock && pathOfError) {
1832
+ errorBlock = {};
1833
+ (0, import_set3.default)(this.errorSchema, pathOfError, errorBlock);
1834
+ }
1835
+ return errorBlock;
1836
+ }
1837
+ /** Resets all errors in the `ErrorSchemaBuilder` back to the `initialSchema` if provided, otherwise an empty set.
1838
+ *
1839
+ * @param [initialSchema] - The optional set of initial errors, that will be cloned into the class
1840
+ * @returns - The `ErrorSchemaBuilder` object for chaining purposes
1841
+ */
1842
+ resetAllErrors(initialSchema) {
1843
+ this.errorSchema = initialSchema ? (0, import_cloneDeep.default)(initialSchema) : {};
1844
+ return this;
1845
+ }
1846
+ /** Adds the `errorOrList` to the list of errors in the `ErrorSchema` at either the root level or the location within
1847
+ * the schema described by the `pathOfError`. For more information about how to specify the path see the
1848
+ * [eslint lodash plugin docs](https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/path-style.md).
1849
+ *
1850
+ * @param errorOrList - The error or list of errors to add into the `ErrorSchema`
1851
+ * @param [pathOfError] - The optional path into the `ErrorSchema` at which to add the error(s)
1852
+ * @returns - The `ErrorSchemaBuilder` object for chaining purposes
1853
+ */
1854
+ addErrors(errorOrList, pathOfError) {
1855
+ const errorBlock = this.getOrCreateErrorBlock(pathOfError);
1856
+ let errorsList = (0, import_get10.default)(errorBlock, ERRORS_KEY);
1857
+ if (!Array.isArray(errorsList)) {
1858
+ errorsList = [];
1859
+ errorBlock[ERRORS_KEY] = errorsList;
1860
+ }
1861
+ if (Array.isArray(errorOrList)) {
1862
+ errorsList.push(...errorOrList);
1863
+ } else {
1864
+ errorsList.push(errorOrList);
1865
+ }
1866
+ return this;
1867
+ }
1868
+ /** Sets/replaces the `errorOrList` as the error(s) in the `ErrorSchema` at either the root level or the location
1869
+ * within the schema described by the `pathOfError`. For more information about how to specify the path see the
1870
+ * [eslint lodash plugin docs](https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/path-style.md).
1871
+ *
1872
+ * @param errorOrList - The error or list of errors to set into the `ErrorSchema`
1873
+ * @param [pathOfError] - The optional path into the `ErrorSchema` at which to set the error(s)
1874
+ * @returns - The `ErrorSchemaBuilder` object for chaining purposes
1875
+ */
1876
+ setErrors(errorOrList, pathOfError) {
1877
+ const errorBlock = this.getOrCreateErrorBlock(pathOfError);
1878
+ const listToAdd = Array.isArray(errorOrList) ? [...errorOrList] : [errorOrList];
1879
+ (0, import_set3.default)(errorBlock, ERRORS_KEY, listToAdd);
1880
+ return this;
1881
+ }
1882
+ /** Clears the error(s) in the `ErrorSchema` at either the root level or the location within the schema described by
1883
+ * the `pathOfError`. For more information about how to specify the path see the
1884
+ * [eslint lodash plugin docs](https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/path-style.md).
1885
+ *
1886
+ * @param [pathOfError] - The optional path into the `ErrorSchema` at which to clear the error(s)
1887
+ * @returns - The `ErrorSchemaBuilder` object for chaining purposes
1888
+ */
1889
+ clearErrors(pathOfError) {
1890
+ const errorBlock = this.getOrCreateErrorBlock(pathOfError);
1891
+ (0, import_set3.default)(errorBlock, ERRORS_KEY, []);
1892
+ return this;
1893
+ }
1894
+ };
1895
+
1896
+ // src/rangeSpec.ts
1897
+ function rangeSpec(schema) {
1898
+ const spec = {};
1899
+ if (schema.multipleOf) {
1900
+ spec.step = schema.multipleOf;
1901
+ }
1902
+ if (schema.minimum || schema.minimum === 0) {
1903
+ spec.min = schema.minimum;
1904
+ }
1905
+ if (schema.maximum || schema.maximum === 0) {
1906
+ spec.max = schema.maximum;
1907
+ }
1908
+ return spec;
1909
+ }
1910
+
1911
+ // src/getInputProps.ts
1912
+ function getInputProps(schema, defaultType, options = {}, autoDefaultStepAny = true) {
1913
+ const inputProps = {
1914
+ type: defaultType || "text",
1915
+ ...rangeSpec(schema)
1916
+ };
1917
+ if (options.inputType) {
1918
+ inputProps.type = options.inputType;
1919
+ } else if (!defaultType) {
1920
+ if (schema.type === "number") {
1921
+ inputProps.type = "number";
1922
+ if (autoDefaultStepAny && inputProps.step === void 0) {
1923
+ inputProps.step = "any";
1924
+ }
1925
+ } else if (schema.type === "integer") {
1926
+ inputProps.type = "number";
1927
+ if (inputProps.step === void 0) {
1928
+ inputProps.step = 1;
1929
+ }
1930
+ }
1931
+ }
1932
+ if (options.autocomplete) {
1933
+ inputProps.autoComplete = options.autocomplete;
1934
+ }
1935
+ return inputProps;
1936
+ }
1937
+
1938
+ // src/getSubmitButtonOptions.ts
1939
+ var DEFAULT_OPTIONS = {
1940
+ props: {
1941
+ disabled: false
1942
+ },
1943
+ submitText: "Submit",
1944
+ norender: false
1945
+ };
1946
+ function getSubmitButtonOptions(uiSchema = {}) {
1947
+ const uiOptions = getUiOptions(uiSchema);
1948
+ if (uiOptions && uiOptions[SUBMIT_BTN_OPTIONS_KEY]) {
1949
+ const options = uiOptions[SUBMIT_BTN_OPTIONS_KEY];
1950
+ return { ...DEFAULT_OPTIONS, ...options };
1951
+ }
1952
+ return DEFAULT_OPTIONS;
1953
+ }
1954
+
1955
+ // src/getTemplate.ts
1956
+ function getTemplate(name, registry, uiOptions = {}) {
1957
+ const { templates } = registry;
1958
+ if (name === "ButtonTemplates") {
1959
+ return templates[name];
1960
+ }
1961
+ return (
1962
+ // Evaluating uiOptions[name] results in TS2590: Expression produces a union type that is too complex to represent
1963
+ // To avoid that, we cast uiOptions to `any` before accessing the name field
1964
+ uiOptions[name] || templates[name]
1965
+ );
1966
+ }
1967
+
1968
+ // src/getWidget.tsx
1969
+ var import_react = require("react");
1970
+ var import_react_is = __toESM(require("react-is"));
1971
+ var import_get11 = __toESM(require("lodash/get"));
1972
+ var import_set4 = __toESM(require("lodash/set"));
1973
+ var import_jsx_runtime = require("react/jsx-runtime");
1974
+ var widgetMap = {
1975
+ boolean: {
1976
+ checkbox: "CheckboxWidget",
1977
+ radio: "RadioWidget",
1978
+ select: "SelectWidget",
1979
+ hidden: "HiddenWidget"
1980
+ },
1981
+ string: {
1982
+ text: "TextWidget",
1983
+ password: "PasswordWidget",
1984
+ email: "EmailWidget",
1985
+ hostname: "TextWidget",
1986
+ ipv4: "TextWidget",
1987
+ ipv6: "TextWidget",
1988
+ uri: "URLWidget",
1989
+ "data-url": "FileWidget",
1990
+ radio: "RadioWidget",
1991
+ select: "SelectWidget",
1992
+ textarea: "TextareaWidget",
1993
+ hidden: "HiddenWidget",
1994
+ date: "DateWidget",
1995
+ datetime: "DateTimeWidget",
1996
+ "date-time": "DateTimeWidget",
1997
+ "alt-date": "AltDateWidget",
1998
+ "alt-datetime": "AltDateTimeWidget",
1999
+ time: "TimeWidget",
2000
+ color: "ColorWidget",
2001
+ file: "FileWidget"
2002
+ },
2003
+ number: {
2004
+ text: "TextWidget",
2005
+ select: "SelectWidget",
2006
+ updown: "UpDownWidget",
2007
+ range: "RangeWidget",
2008
+ radio: "RadioWidget",
2009
+ hidden: "HiddenWidget"
2010
+ },
2011
+ integer: {
2012
+ text: "TextWidget",
2013
+ select: "SelectWidget",
2014
+ updown: "UpDownWidget",
2015
+ range: "RangeWidget",
2016
+ radio: "RadioWidget",
2017
+ hidden: "HiddenWidget"
2018
+ },
2019
+ array: {
2020
+ select: "SelectWidget",
2021
+ checkboxes: "CheckboxesWidget",
2022
+ files: "FileWidget",
2023
+ hidden: "HiddenWidget"
2024
+ }
2025
+ };
2026
+ function mergeWidgetOptions(AWidget) {
2027
+ let MergedWidget = (0, import_get11.default)(AWidget, "MergedWidget");
2028
+ if (!MergedWidget) {
2029
+ const defaultOptions = AWidget.defaultProps && AWidget.defaultProps.options || {};
2030
+ MergedWidget = ({ options, ...props }) => {
2031
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AWidget, { options: { ...defaultOptions, ...options }, ...props });
2032
+ };
2033
+ (0, import_set4.default)(AWidget, "MergedWidget", MergedWidget);
2034
+ }
2035
+ return MergedWidget;
2036
+ }
2037
+ function getWidget(schema, widget, registeredWidgets = {}) {
2038
+ const type = getSchemaType(schema);
2039
+ if (typeof widget === "function" || widget && import_react_is.default.isForwardRef((0, import_react.createElement)(widget)) || import_react_is.default.isMemo(widget)) {
2040
+ return mergeWidgetOptions(widget);
2041
+ }
2042
+ if (typeof widget !== "string") {
2043
+ throw new Error(`Unsupported widget definition: ${typeof widget}`);
2044
+ }
2045
+ if (widget in registeredWidgets) {
2046
+ const registeredWidget = registeredWidgets[widget];
2047
+ return getWidget(schema, registeredWidget, registeredWidgets);
2048
+ }
2049
+ if (typeof type === "string") {
2050
+ if (!(type in widgetMap)) {
2051
+ throw new Error(`No widget for type '${type}'`);
2052
+ }
2053
+ if (widget in widgetMap[type]) {
2054
+ const registeredWidget = registeredWidgets[widgetMap[type][widget]];
2055
+ return getWidget(schema, registeredWidget, registeredWidgets);
2056
+ }
2057
+ }
2058
+ throw new Error(`No widget '${widget}' for type '${type}'`);
2059
+ }
2060
+
2061
+ // src/hashForSchema.ts
2062
+ function hashString(string) {
2063
+ let hash = 0;
2064
+ for (let i = 0; i < string.length; i += 1) {
2065
+ const chr = string.charCodeAt(i);
2066
+ hash = (hash << 5) - hash + chr;
2067
+ hash = hash & hash;
2068
+ }
2069
+ return hash.toString(16);
2070
+ }
2071
+ function hashForSchema(schema) {
2072
+ const allKeys = /* @__PURE__ */ new Set();
2073
+ JSON.stringify(schema, (key, value) => (allKeys.add(key), value));
2074
+ return hashString(JSON.stringify(schema, Array.from(allKeys).sort()));
2075
+ }
2076
+
2077
+ // src/hasWidget.ts
2078
+ function hasWidget(schema, widget, registeredWidgets = {}) {
2079
+ try {
2080
+ getWidget(schema, widget, registeredWidgets);
2081
+ return true;
2082
+ } catch (e) {
2083
+ const err = e;
2084
+ if (err.message && (err.message.startsWith("No widget") || err.message.startsWith("Unsupported widget"))) {
2085
+ return false;
2086
+ }
2087
+ throw e;
2088
+ }
2089
+ }
2090
+
2091
+ // src/idGenerators.ts
2092
+ var import_isString3 = __toESM(require("lodash/isString"));
2093
+ function idGenerator(id, suffix) {
2094
+ const theId = (0, import_isString3.default)(id) ? id : id[ID_KEY];
2095
+ return `${theId}__${suffix}`;
2096
+ }
2097
+ function descriptionId(id) {
2098
+ return idGenerator(id, "description");
2099
+ }
2100
+ function errorId(id) {
2101
+ return idGenerator(id, "error");
2102
+ }
2103
+ function examplesId(id) {
2104
+ return idGenerator(id, "examples");
2105
+ }
2106
+ function helpId(id) {
2107
+ return idGenerator(id, "help");
2108
+ }
2109
+ function titleId(id) {
2110
+ return idGenerator(id, "title");
2111
+ }
2112
+ function ariaDescribedByIds(id, includeExamples = false) {
2113
+ const examples = includeExamples ? ` ${examplesId(id)}` : "";
2114
+ return `${errorId(id)} ${descriptionId(id)} ${helpId(id)}${examples}`;
2115
+ }
2116
+ function optionId(id, optionIndex) {
2117
+ return `${id}-${optionIndex}`;
2118
+ }
2119
+
2120
+ // src/labelValue.ts
2121
+ function labelValue(label, hideLabel, fallback) {
2122
+ return hideLabel ? fallback : label;
2123
+ }
2124
+
2125
+ // src/localToUTC.ts
2126
+ function localToUTC(dateString) {
2127
+ return dateString ? new Date(dateString).toJSON() : void 0;
2128
+ }
2129
+
2130
+ // src/toConstant.ts
2131
+ function toConstant(schema) {
2132
+ if (ENUM_KEY in schema && Array.isArray(schema.enum) && schema.enum.length === 1) {
2133
+ return schema.enum[0];
2134
+ }
2135
+ if (CONST_KEY in schema) {
2136
+ return schema.const;
2137
+ }
2138
+ throw new Error("schema cannot be inferred as a constant");
2139
+ }
2140
+
2141
+ // src/optionsList.ts
2142
+ function optionsList(schema) {
2143
+ const schemaWithEnumNames = schema;
2144
+ if (schemaWithEnumNames.enumNames && true) {
2145
+ console.warn("The enumNames property is deprecated and may be removed in a future major release.");
2146
+ }
2147
+ if (schema.enum) {
2148
+ return schema.enum.map((value, i) => {
2149
+ const label = schemaWithEnumNames.enumNames && schemaWithEnumNames.enumNames[i] || String(value);
2150
+ return { label, value };
2151
+ });
2152
+ }
2153
+ const altSchemas = schema.oneOf || schema.anyOf;
2154
+ return altSchemas && altSchemas.map((aSchemaDef) => {
2155
+ const aSchema = aSchemaDef;
2156
+ const value = toConstant(aSchema);
2157
+ const label = aSchema.title || String(value);
2158
+ return {
2159
+ schema: aSchema,
2160
+ label,
2161
+ value
2162
+ };
2163
+ });
2164
+ }
2165
+
2166
+ // src/orderProperties.ts
2167
+ function orderProperties(properties, order) {
2168
+ if (!Array.isArray(order)) {
2169
+ return properties;
2170
+ }
2171
+ const arrayToHash = (arr) => arr.reduce((prev, curr) => {
2172
+ prev[curr] = true;
2173
+ return prev;
2174
+ }, {});
2175
+ const errorPropList = (arr) => arr.length > 1 ? `properties '${arr.join("', '")}'` : `property '${arr[0]}'`;
2176
+ const propertyHash = arrayToHash(properties);
2177
+ const orderFiltered = order.filter((prop) => prop === "*" || propertyHash[prop]);
2178
+ const orderHash = arrayToHash(orderFiltered);
2179
+ const rest = properties.filter((prop) => !orderHash[prop]);
2180
+ const restIndex = orderFiltered.indexOf("*");
2181
+ if (restIndex === -1) {
2182
+ if (rest.length) {
2183
+ throw new Error(`uiSchema order list does not contain ${errorPropList(rest)}`);
2184
+ }
2185
+ return orderFiltered;
2186
+ }
2187
+ if (restIndex !== orderFiltered.lastIndexOf("*")) {
2188
+ throw new Error("uiSchema order list contains more than one wildcard item");
2189
+ }
2190
+ const complete = [...orderFiltered];
2191
+ complete.splice(restIndex, 1, ...rest);
2192
+ return complete;
2193
+ }
2194
+
2195
+ // src/pad.ts
2196
+ function pad(num, width) {
2197
+ let s = String(num);
2198
+ while (s.length < width) {
2199
+ s = "0" + s;
2200
+ }
2201
+ return s;
2202
+ }
2203
+
2204
+ // src/parseDateString.ts
2205
+ function parseDateString(dateString, includeTime = true) {
2206
+ if (!dateString) {
2207
+ return {
2208
+ year: -1,
2209
+ month: -1,
2210
+ day: -1,
2211
+ hour: includeTime ? -1 : 0,
2212
+ minute: includeTime ? -1 : 0,
2213
+ second: includeTime ? -1 : 0
2214
+ };
2215
+ }
2216
+ const date = new Date(dateString);
2217
+ if (Number.isNaN(date.getTime())) {
2218
+ throw new Error("Unable to parse date " + dateString);
2219
+ }
2220
+ return {
2221
+ year: date.getUTCFullYear(),
2222
+ month: date.getUTCMonth() + 1,
2223
+ // oh you, javascript.
2224
+ day: date.getUTCDate(),
2225
+ hour: includeTime ? date.getUTCHours() : 0,
2226
+ minute: includeTime ? date.getUTCMinutes() : 0,
2227
+ second: includeTime ? date.getUTCSeconds() : 0
2228
+ };
2229
+ }
2230
+
2231
+ // src/schemaRequiresTrueValue.ts
2232
+ function schemaRequiresTrueValue(schema) {
2233
+ if (schema.const) {
2234
+ return true;
2235
+ }
2236
+ if (schema.enum && schema.enum.length === 1 && schema.enum[0] === true) {
2237
+ return true;
2238
+ }
2239
+ if (schema.anyOf && schema.anyOf.length === 1) {
2240
+ return schemaRequiresTrueValue(schema.anyOf[0]);
2241
+ }
2242
+ if (schema.oneOf && schema.oneOf.length === 1) {
2243
+ return schemaRequiresTrueValue(schema.oneOf[0]);
2244
+ }
2245
+ if (schema.allOf) {
2246
+ const schemaSome = (subSchema) => schemaRequiresTrueValue(subSchema);
2247
+ return schema.allOf.some(schemaSome);
2248
+ }
2249
+ return false;
2250
+ }
2251
+
2252
+ // src/shouldRender.ts
2253
+ function shouldRender(component, nextProps, nextState) {
2254
+ const { props, state } = component;
2255
+ return !deepEquals(props, nextProps) || !deepEquals(state, nextState);
2256
+ }
2257
+
2258
+ // src/toDateString.ts
2259
+ function toDateString(dateObject, time = true) {
2260
+ const { year, month, day, hour = 0, minute = 0, second = 0 } = dateObject;
2261
+ const utcTime = Date.UTC(year, month - 1, day, hour, minute, second);
2262
+ const datetime = new Date(utcTime).toJSON();
2263
+ return time ? datetime : datetime.slice(0, 10);
2264
+ }
2265
+
2266
+ // src/toErrorList.ts
2267
+ var import_isPlainObject2 = __toESM(require("lodash/isPlainObject"));
2268
+ function toErrorList(errorSchema, fieldPath = []) {
2269
+ if (!errorSchema) {
2270
+ return [];
2271
+ }
2272
+ let errorList = [];
2273
+ if (ERRORS_KEY in errorSchema) {
2274
+ errorList = errorList.concat(
2275
+ errorSchema[ERRORS_KEY].map((message) => {
2276
+ const property = `.${fieldPath.join(".")}`;
2277
+ return {
2278
+ property,
2279
+ message,
2280
+ stack: `${property} ${message}`
2281
+ };
2282
+ })
2283
+ );
2284
+ }
2285
+ return Object.keys(errorSchema).reduce((acc, key) => {
2286
+ if (key !== ERRORS_KEY) {
2287
+ const childSchema = errorSchema[key];
2288
+ if ((0, import_isPlainObject2.default)(childSchema)) {
2289
+ acc = acc.concat(toErrorList(childSchema, [...fieldPath, key]));
2290
+ }
2291
+ }
2292
+ return acc;
2293
+ }, errorList);
2294
+ }
2295
+
2296
+ // src/toErrorSchema.ts
2297
+ var import_toPath = __toESM(require("lodash/toPath"));
2298
+ function toErrorSchema(errors) {
2299
+ const builder = new ErrorSchemaBuilder();
2300
+ if (errors.length) {
2301
+ errors.forEach((error) => {
2302
+ const { property, message } = error;
2303
+ const path = property === "." ? [] : (0, import_toPath.default)(property);
2304
+ if (path.length > 0 && path[0] === "") {
2305
+ path.splice(0, 1);
2306
+ }
2307
+ if (message) {
2308
+ builder.addErrors(message, path);
2309
+ }
2310
+ });
2311
+ }
2312
+ return builder.ErrorSchema;
2313
+ }
2314
+
2315
+ // src/unwrapErrorHandler.ts
2316
+ var import_isPlainObject3 = __toESM(require("lodash/isPlainObject"));
2317
+ function unwrapErrorHandler(errorHandler) {
2318
+ return Object.keys(errorHandler).reduce((acc, key) => {
2319
+ if (key === "addError") {
2320
+ return acc;
2321
+ } else {
2322
+ const childSchema = errorHandler[key];
2323
+ if ((0, import_isPlainObject3.default)(childSchema)) {
2324
+ return {
2325
+ ...acc,
2326
+ [key]: unwrapErrorHandler(childSchema)
2327
+ };
2328
+ }
2329
+ return { ...acc, [key]: childSchema };
2330
+ }
2331
+ }, {});
2332
+ }
2333
+
2334
+ // src/utcToLocal.ts
2335
+ function utcToLocal(jsonDate) {
2336
+ if (!jsonDate) {
2337
+ return "";
2338
+ }
2339
+ const date = new Date(jsonDate);
2340
+ const yyyy = pad(date.getFullYear(), 4);
2341
+ const MM = pad(date.getMonth() + 1, 2);
2342
+ const dd = pad(date.getDate(), 2);
2343
+ const hh = pad(date.getHours(), 2);
2344
+ const mm = pad(date.getMinutes(), 2);
2345
+ const ss = pad(date.getSeconds(), 2);
2346
+ const SSS = pad(date.getMilliseconds(), 3);
2347
+ return `${yyyy}-${MM}-${dd}T${hh}:${mm}:${ss}.${SSS}`;
2348
+ }
2349
+
2350
+ // src/validationDataMerge.ts
2351
+ var import_isEmpty3 = __toESM(require("lodash/isEmpty"));
2352
+ function validationDataMerge(validationData, additionalErrorSchema) {
2353
+ if (!additionalErrorSchema) {
2354
+ return validationData;
2355
+ }
2356
+ const { errors: oldErrors, errorSchema: oldErrorSchema } = validationData;
2357
+ let errors = toErrorList(additionalErrorSchema);
2358
+ let errorSchema = additionalErrorSchema;
2359
+ if (!(0, import_isEmpty3.default)(oldErrorSchema)) {
2360
+ errorSchema = mergeObjects(oldErrorSchema, additionalErrorSchema, true);
2361
+ errors = [...oldErrors].concat(errors);
2362
+ }
2363
+ return { errorSchema, errors };
2364
+ }
2365
+
2366
+ // src/withIdRefPrefix.ts
2367
+ var import_isObject11 = __toESM(require("lodash/isObject"));
2368
+ function withIdRefPrefixObject(node) {
2369
+ for (const key in node) {
2370
+ const realObj = node;
2371
+ const value = realObj[key];
2372
+ if (key === REF_KEY && typeof value === "string" && value.startsWith("#")) {
2373
+ realObj[key] = ROOT_SCHEMA_PREFIX + value;
2374
+ } else {
2375
+ realObj[key] = withIdRefPrefix(value);
2376
+ }
2377
+ }
2378
+ return node;
2379
+ }
2380
+ function withIdRefPrefixArray(node) {
2381
+ for (let i = 0; i < node.length; i++) {
2382
+ node[i] = withIdRefPrefix(node[i]);
2383
+ }
2384
+ return node;
2385
+ }
2386
+ function withIdRefPrefix(schemaNode) {
2387
+ if (Array.isArray(schemaNode)) {
2388
+ return withIdRefPrefixArray([...schemaNode]);
2389
+ }
2390
+ if ((0, import_isObject11.default)(schemaNode)) {
2391
+ return withIdRefPrefixObject({ ...schemaNode });
2392
+ }
2393
+ return schemaNode;
2394
+ }
2395
+
2396
+ // src/enums.ts
2397
+ var TranslatableString = /* @__PURE__ */ ((TranslatableString2) => {
2398
+ TranslatableString2["ArrayItemTitle"] = "Item";
2399
+ TranslatableString2["MissingItems"] = "Missing items definition";
2400
+ TranslatableString2["YesLabel"] = "Yes";
2401
+ TranslatableString2["NoLabel"] = "No";
2402
+ TranslatableString2["CloseLabel"] = "Close";
2403
+ TranslatableString2["ErrorsLabel"] = "Errors";
2404
+ TranslatableString2["NewStringDefault"] = "New Value";
2405
+ TranslatableString2["AddButton"] = "Add";
2406
+ TranslatableString2["AddItemButton"] = "Add Item";
2407
+ TranslatableString2["CopyButton"] = "Copy";
2408
+ TranslatableString2["MoveDownButton"] = "Move down";
2409
+ TranslatableString2["MoveUpButton"] = "Move up";
2410
+ TranslatableString2["RemoveButton"] = "Remove";
2411
+ TranslatableString2["NowLabel"] = "Now";
2412
+ TranslatableString2["ClearLabel"] = "Clear";
2413
+ TranslatableString2["AriaDateLabel"] = "Select a date";
2414
+ TranslatableString2["PreviewLabel"] = "Preview";
2415
+ TranslatableString2["DecrementAriaLabel"] = "Decrease value by 1";
2416
+ TranslatableString2["IncrementAriaLabel"] = "Increase value by 1";
2417
+ TranslatableString2["UnknownFieldType"] = "Unknown field type %1";
2418
+ TranslatableString2["OptionPrefix"] = "Option %1";
2419
+ TranslatableString2["TitleOptionPrefix"] = "%1 option %2";
2420
+ TranslatableString2["KeyLabel"] = "%1 Key";
2421
+ TranslatableString2["InvalidObjectField"] = 'Invalid "%1" object field configuration: <em>%2</em>.';
2422
+ TranslatableString2["UnsupportedField"] = "Unsupported field schema.";
2423
+ TranslatableString2["UnsupportedFieldWithId"] = "Unsupported field schema for field <code>%1</code>.";
2424
+ TranslatableString2["UnsupportedFieldWithReason"] = "Unsupported field schema: <em>%1</em>.";
2425
+ TranslatableString2["UnsupportedFieldWithIdAndReason"] = "Unsupported field schema for field <code>%1</code>: <em>%2</em>.";
2426
+ TranslatableString2["FilesInfo"] = "<strong>%1</strong> (%2, %3 bytes)";
2427
+ return TranslatableString2;
2428
+ })(TranslatableString || {});
2429
+
2430
+ // src/parser/schemaParser.ts
2431
+ var import_forEach = __toESM(require("lodash/forEach"));
2432
+ var import_isEqual6 = __toESM(require("lodash/isEqual"));
2433
+
2434
+ // src/parser/ParserValidator.ts
2435
+ var import_get12 = __toESM(require("lodash/get"));
2436
+ var import_isEqual5 = __toESM(require("lodash/isEqual"));
2437
+ var ParserValidator = class {
2438
+ /** Construct the ParserValidator for the given `rootSchema`. This `rootSchema` will be stashed in the `schemaMap`
2439
+ * first.
2440
+ *
2441
+ * @param rootSchema - The root schema against which this validator will be executed
2442
+ */
2443
+ constructor(rootSchema) {
2444
+ /** The map of schemas encountered by the ParserValidator */
2445
+ this.schemaMap = {};
2446
+ this.rootSchema = rootSchema;
2447
+ this.addSchema(rootSchema, hashForSchema(rootSchema));
2448
+ }
2449
+ /** Adds the given `schema` to the `schemaMap` keyed by the `hash` or `ID_KEY` if present on the `schema`. If the
2450
+ * schema does not have an `ID_KEY`, then the `hash` will be added as the `ID_KEY` to allow the schema to be
2451
+ * associated with it's `hash` for future use (by a schema compiler).
2452
+ *
2453
+ * @param schema - The schema which is to be added to the map
2454
+ * @param hash - The hash value at which to map the schema
2455
+ */
2456
+ addSchema(schema, hash) {
2457
+ const key = (0, import_get12.default)(schema, ID_KEY, hash);
2458
+ const identifiedSchema = { ...schema, [ID_KEY]: key };
2459
+ const existing = this.schemaMap[key];
2460
+ if (!existing) {
2461
+ this.schemaMap[key] = identifiedSchema;
2462
+ } else if (!(0, import_isEqual5.default)(existing, identifiedSchema)) {
2463
+ console.error("existing schema:", JSON.stringify(existing, null, 2));
2464
+ console.error("new schema:", JSON.stringify(identifiedSchema, null, 2));
2465
+ throw new Error(
2466
+ `Two different schemas exist with the same key ${key}! What a bad coincidence. If possible, try adding an $id to one of the schemas`
2467
+ );
2468
+ }
2469
+ }
2470
+ /** Returns the current `schemaMap` to the caller
2471
+ */
2472
+ getSchemaMap() {
2473
+ return this.schemaMap;
2474
+ }
2475
+ /** Implements the `ValidatorType` `isValid()` method to capture the `schema` in the `schemaMap`. Throws an error when
2476
+ * the `rootSchema` is not the same as the root schema provided during construction.
2477
+ *
2478
+ * @param schema - The schema to record in the `schemaMap`
2479
+ * @param _formData - The formData parameter that is ignored
2480
+ * @param rootSchema - The root schema associated with the schema
2481
+ * @throws - Error when the given `rootSchema` differs from the root schema provided during construction
2482
+ */
2483
+ isValid(schema, _formData, rootSchema) {
2484
+ if (!(0, import_isEqual5.default)(rootSchema, this.rootSchema)) {
2485
+ throw new Error("Unexpectedly calling isValid() with a rootSchema that differs from the construction rootSchema");
2486
+ }
2487
+ this.addSchema(schema, hashForSchema(schema));
2488
+ return false;
2489
+ }
2490
+ /** Implements the `ValidatorType` `rawValidation()` method to throw an error since it is never supposed to be called
2491
+ *
2492
+ * @param _schema - The schema parameter that is ignored
2493
+ * @param _formData - The formData parameter that is ignored
2494
+ */
2495
+ rawValidation(_schema, _formData) {
2496
+ throw new Error("Unexpectedly calling the `rawValidation()` method during schema parsing");
2497
+ }
2498
+ /** Implements the `ValidatorType` `toErrorList()` method to throw an error since it is never supposed to be called
2499
+ *
2500
+ * @param _errorSchema - The error schema parameter that is ignored
2501
+ * @param _fieldPath - The field path parameter that is ignored
2502
+ */
2503
+ toErrorList(_errorSchema, _fieldPath) {
2504
+ throw new Error("Unexpectedly calling the `toErrorList()` method during schema parsing");
2505
+ }
2506
+ /** Implements the `ValidatorType` `validateFormData()` method to throw an error since it is never supposed to be
2507
+ * called
2508
+ *
2509
+ * @param _formData - The formData parameter that is ignored
2510
+ * @param _schema - The schema parameter that is ignored
2511
+ * @param _customValidate - The customValidate parameter that is ignored
2512
+ * @param _transformErrors - The transformErrors parameter that is ignored
2513
+ * @param _uiSchema - The uiSchema parameter that is ignored
2514
+ */
2515
+ validateFormData(_formData, _schema, _customValidate, _transformErrors, _uiSchema) {
2516
+ throw new Error("Unexpectedly calling the `validateFormData()` method during schema parsing");
2517
+ }
2518
+ };
2519
+
2520
+ // src/parser/schemaParser.ts
2521
+ function parseSchema(validator, recurseList, rootSchema, schema) {
2522
+ const schemas = retrieveSchemaInternal(validator, schema, rootSchema, void 0, true);
2523
+ schemas.forEach((schema2) => {
2524
+ const sameSchemaIndex = recurseList.findIndex((item) => (0, import_isEqual6.default)(item, schema2));
2525
+ if (sameSchemaIndex === -1) {
2526
+ recurseList.push(schema2);
2527
+ const allOptions = resolveAnyOrOneOfSchemas(validator, schema2, rootSchema, true);
2528
+ allOptions.forEach((s) => {
2529
+ if (PROPERTIES_KEY in s && s[PROPERTIES_KEY]) {
2530
+ (0, import_forEach.default)(schema2[PROPERTIES_KEY], (value) => {
2531
+ parseSchema(validator, recurseList, rootSchema, value);
2532
+ });
2533
+ }
2534
+ });
2535
+ if (ITEMS_KEY in schema2 && !Array.isArray(schema2.items) && typeof schema2.items !== "boolean") {
2536
+ parseSchema(validator, recurseList, rootSchema, schema2.items);
2537
+ }
2538
+ }
2539
+ });
2540
+ }
2541
+ function schemaParser(rootSchema) {
2542
+ const validator = new ParserValidator(rootSchema);
2543
+ const recurseList = [];
2544
+ parseSchema(validator, recurseList, rootSchema, rootSchema);
2545
+ return validator.getSchemaMap();
2546
+ }
2547
+ //# sourceMappingURL=index.js.map