adp-web-components 0.0.65 → 0.0.67

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 (317) hide show
  1. package/dist/cjs/app-globals-4aa8f46f.js +46 -0
  2. package/dist/cjs/cn-f559f9e5.js +2588 -0
  3. package/dist/cjs/contact-us-form.cjs.entry.js +209 -0
  4. package/dist/cjs/dead-stock-lookup_3.cjs.entry.js +445 -0
  5. package/dist/cjs/dynamic-claim_6.cjs.entry.js +1180 -0
  6. package/dist/cjs/dynamic-redeem.cjs.entry.js +156 -0
  7. package/dist/cjs/form-dialog_8.cjs.entry.js +503 -0
  8. package/dist/cjs/get-local-language-ec0e41e0.js +2381 -0
  9. package/dist/cjs/index-603d8f32.js +1610 -0
  10. package/dist/cjs/index.cjs.js +6 -0
  11. package/dist/cjs/loader-baf2418b.js +9 -0
  12. package/dist/cjs/loader.cjs.js +19 -0
  13. package/dist/cjs/loading-spinner.cjs.entry.js +27 -0
  14. package/dist/cjs/part-lookup.cjs.entry.js +129 -0
  15. package/dist/cjs/service-booking-form.cjs.entry.js +209 -0
  16. package/dist/cjs/shift-components.cjs.js +29 -0
  17. package/dist/cjs/urls-9077b31c.js +4874 -0
  18. package/dist/cjs/vehicle-lookup.cjs.entry.js +203 -0
  19. package/dist/collection/collection-manifest.json +35 -0
  20. package/dist/collection/components/components/loading-spinner.css +1 -0
  21. package/dist/collection/components/components/loading-spinner.js +47 -0
  22. package/dist/collection/components/form-elements/form-dialog.css +1 -0
  23. package/dist/collection/components/form-elements/form-dialog.js +137 -0
  24. package/dist/collection/components/form-elements/form-input.css +1 -0
  25. package/dist/collection/components/form-elements/form-input.js +323 -0
  26. package/dist/collection/components/form-elements/form-select.css +1 -0
  27. package/dist/collection/components/form-elements/form-select.js +400 -0
  28. package/dist/collection/components/form-elements/form-shadow-input.css +1 -0
  29. package/dist/collection/components/form-elements/form-shadow-input.js +100 -0
  30. package/dist/collection/components/form-elements/form-structure-error.css +1 -0
  31. package/dist/collection/components/form-elements/form-structure-error.js +72 -0
  32. package/dist/collection/components/form-elements/form-structure.css +1 -0
  33. package/dist/collection/components/form-elements/form-structure.js +269 -0
  34. package/dist/collection/components/form-elements/form-submit.css +1 -0
  35. package/dist/collection/components/form-elements/form-submit.js +140 -0
  36. package/dist/collection/components/form-elements/form-text-area.css +1 -0
  37. package/dist/collection/components/form-elements/form-text-area.js +264 -0
  38. package/dist/collection/components/forms/contact-us/element-mapper.js +87 -0
  39. package/dist/collection/components/forms/contact-us/form.css +1 -0
  40. package/dist/collection/components/forms/contact-us/validations.js +19 -0
  41. package/dist/collection/components/forms/contact-us-form.js +280 -0
  42. package/dist/collection/components/forms/service-booking/element-mapper.js +87 -0
  43. package/dist/collection/components/forms/service-booking/form.css +1 -0
  44. package/dist/collection/components/forms/service-booking/validations.js +19 -0
  45. package/dist/collection/components/forms/service-booking-form.js +280 -0
  46. package/dist/collection/components/part-lookup/dead-stock-lookup.css +1 -0
  47. package/dist/collection/components/part-lookup/dead-stock-lookup.js +405 -0
  48. package/dist/collection/components/part-lookup/distributor-lookup.css +1 -0
  49. package/dist/collection/components/part-lookup/distributor-lookup.js +470 -0
  50. package/dist/collection/components/part-lookup/manufacturer-lookup.css +1 -0
  51. package/dist/collection/components/part-lookup/manufacturer-lookup.js +468 -0
  52. package/dist/collection/components/part-lookup/part-lookup.css +1 -0
  53. package/dist/collection/components/part-lookup/part-lookup.js +376 -0
  54. package/dist/collection/components/vehicle-lookup/assets/cancelled.svg +8 -0
  55. package/dist/collection/components/vehicle-lookup/assets/check.svg +4 -0
  56. package/dist/collection/components/vehicle-lookup/assets/expired.svg +9 -0
  57. package/dist/collection/components/vehicle-lookup/assets/loader.svg +11 -0
  58. package/dist/collection/components/vehicle-lookup/assets/pending.svg +9 -0
  59. package/dist/collection/components/vehicle-lookup/assets/processed.svg +9 -0
  60. package/dist/collection/components/vehicle-lookup/assets/x-mark.svg +4 -0
  61. package/dist/collection/components/vehicle-lookup/components/CardsContainer.js +13 -0
  62. package/dist/collection/components/vehicle-lookup/components/Loading.js +10 -0
  63. package/dist/collection/components/vehicle-lookup/components/SSCTable.js +16 -0
  64. package/dist/collection/components/vehicle-lookup/components/StatusCard.js +11 -0
  65. package/dist/collection/components/vehicle-lookup/dynamic-claim.css +1 -0
  66. package/dist/collection/components/vehicle-lookup/dynamic-claim.js +662 -0
  67. package/dist/collection/components/vehicle-lookup/dynamic-redeem.css +1 -0
  68. package/dist/collection/components/vehicle-lookup/dynamic-redeem.js +373 -0
  69. package/dist/collection/components/vehicle-lookup/paint-thickness.css +1 -0
  70. package/dist/collection/components/vehicle-lookup/paint-thickness.js +410 -0
  71. package/dist/collection/components/vehicle-lookup/service-history.css +1 -0
  72. package/dist/collection/components/vehicle-lookup/service-history.js +393 -0
  73. package/dist/collection/components/vehicle-lookup/vehicle-accessories.css +1 -0
  74. package/dist/collection/components/vehicle-lookup/vehicle-accessories.js +414 -0
  75. package/dist/collection/components/vehicle-lookup/vehicle-lookup.css +1 -0
  76. package/dist/collection/components/vehicle-lookup/vehicle-lookup.js +406 -0
  77. package/dist/collection/components/vehicle-lookup/vehicle-specification.css +1 -0
  78. package/dist/collection/components/vehicle-lookup/vehicle-specification.js +405 -0
  79. package/dist/collection/components/vehicle-lookup/warranty-details.css +1 -0
  80. package/dist/collection/components/vehicle-lookup/warranty-details.js +780 -0
  81. package/dist/collection/global/api/partInformation.js +32 -0
  82. package/dist/collection/global/api/urls.js +6 -0
  83. package/dist/collection/global/api/vehicleInformation.js +48 -0
  84. package/dist/collection/global/assets/eye.svg +5 -0
  85. package/dist/collection/global/assets/loader.svg +11 -0
  86. package/dist/collection/global/assets/white-loader.svg +11 -0
  87. package/dist/collection/global/lib/cn.js +9 -0
  88. package/dist/collection/global/lib/form-hook.js +162 -0
  89. package/dist/collection/global/lib/general.js +9 -0
  90. package/dist/collection/global/lib/get-local-language.js +20 -0
  91. package/dist/collection/global/lib/image-expansion.js +69 -0
  92. package/dist/collection/global/lib/middleware.js +39 -0
  93. package/dist/collection/global/lib/recaptcha.js +25 -0
  94. package/dist/collection/global/lib/utils.js +7 -0
  95. package/dist/collection/global/lib/validate-form-structure.js +47 -0
  96. package/dist/collection/global/lib/validate-vin.js +62 -0
  97. package/dist/collection/global/types/components.js +1 -0
  98. package/dist/collection/global/types/forms.js +1 -0
  99. package/dist/collection/global/types/general.js +1 -0
  100. package/dist/collection/global/types/locales/error-schema.js +17 -0
  101. package/dist/collection/global/types/locales/forms/contact-us-schema.js +24 -0
  102. package/dist/collection/global/types/locales/forms/index.js +11 -0
  103. package/dist/collection/global/types/locales/general.js +11 -0
  104. package/dist/collection/global/types/locales/index.js +33 -0
  105. package/dist/collection/global/types/locales/inquiryTypes.js +15 -0
  106. package/dist/collection/global/types/locales/part-lookup/dead-stock-schema.js +10 -0
  107. package/dist/collection/global/types/locales/part-lookup/distributor-schema.js +21 -0
  108. package/dist/collection/global/types/locales/part-lookup/index.js +13 -0
  109. package/dist/collection/global/types/locales/part-lookup/manufacturer-schema.js +22 -0
  110. package/dist/collection/global/types/locales/vehicle-lookup/accessories-schema.js +13 -0
  111. package/dist/collection/global/types/locales/vehicle-lookup/dynamic-claim-schema.js +21 -0
  112. package/dist/collection/global/types/locales/vehicle-lookup/dynamic-redeem-schema.js +19 -0
  113. package/dist/collection/global/types/locales/vehicle-lookup/index.js +21 -0
  114. package/dist/collection/global/types/locales/vehicle-lookup/paint-thickness-schema.js +14 -0
  115. package/dist/collection/global/types/locales/vehicle-lookup/service-history-schema.js +15 -0
  116. package/dist/collection/global/types/locales/vehicle-lookup/specification-schema.js +15 -0
  117. package/dist/collection/global/types/locales/vehicle-lookup/warranty-schema.js +23 -0
  118. package/dist/collection/global/types/part-information.js +1 -0
  119. package/dist/collection/global/types/vehicle-information.js +5 -0
  120. package/dist/collection/index.js +1 -0
  121. package/dist/collection/templates/part-lookup/mock-data.js +199 -0
  122. package/dist/collection/templates/vehicle-lookup/mock-data.js +4165 -0
  123. package/dist/collection/templates/vehicle-lookup/vehicle-lookup.js +285 -0
  124. package/dist/collection/templates/vehicle-lookup/warranty-mock-data.js +3064 -0
  125. package/dist/components/contact-us-form.d.ts +11 -0
  126. package/dist/components/contact-us-form.js +5 -0
  127. package/dist/components/dead-stock-lookup.d.ts +11 -0
  128. package/dist/components/dead-stock-lookup.js +5 -0
  129. package/dist/components/distributor-lookup.d.ts +11 -0
  130. package/dist/components/distributor-lookup.js +5 -0
  131. package/dist/components/dynamic-claim.d.ts +11 -0
  132. package/dist/components/dynamic-claim.js +5 -0
  133. package/dist/components/dynamic-redeem.d.ts +11 -0
  134. package/dist/components/dynamic-redeem.js +5 -0
  135. package/dist/components/form-dialog.d.ts +11 -0
  136. package/dist/components/form-dialog.js +5 -0
  137. package/dist/components/form-input.d.ts +11 -0
  138. package/dist/components/form-input.js +5 -0
  139. package/dist/components/form-select.d.ts +11 -0
  140. package/dist/components/form-select.js +5 -0
  141. package/dist/components/form-shadow-input.d.ts +11 -0
  142. package/dist/components/form-shadow-input.js +5 -0
  143. package/dist/components/form-structure-error.d.ts +11 -0
  144. package/dist/components/form-structure-error.js +5 -0
  145. package/dist/components/form-structure.d.ts +11 -0
  146. package/dist/components/form-structure.js +5 -0
  147. package/dist/components/form-submit.d.ts +11 -0
  148. package/dist/components/form-submit.js +5 -0
  149. package/dist/components/form-text-area.d.ts +11 -0
  150. package/dist/components/form-text-area.js +5 -0
  151. package/dist/components/index.d.ts +33 -0
  152. package/dist/components/index.js +5 -0
  153. package/dist/components/loading-spinner.d.ts +11 -0
  154. package/dist/components/loading-spinner.js +5 -0
  155. package/dist/components/manufacturer-lookup.d.ts +11 -0
  156. package/dist/components/manufacturer-lookup.js +5 -0
  157. package/dist/components/p-00d97183.js +5 -0
  158. package/dist/components/p-1e9e4abd.js +5 -0
  159. package/dist/components/p-1f001d39.js +5 -0
  160. package/dist/components/p-1fe65d6e.js +5 -0
  161. package/dist/components/p-3f19382d.js +5 -0
  162. package/dist/components/p-5b4b3060.js +5 -0
  163. package/dist/components/p-5d3cc3c1.js +5 -0
  164. package/dist/components/p-6055174a.js +5 -0
  165. package/dist/components/p-6e3ab655.js +5 -0
  166. package/dist/components/p-73a5d441.js +5 -0
  167. package/dist/components/p-75476014.js +5 -0
  168. package/dist/components/p-810e84ab.js +5 -0
  169. package/dist/components/p-8b1d90d7.js +5 -0
  170. package/dist/components/p-927296bb.js +5 -0
  171. package/dist/components/p-932ff922.js +5 -0
  172. package/dist/components/p-98d9e7ab.js +5 -0
  173. package/dist/components/p-a21e2e2e.js +5 -0
  174. package/dist/components/p-a2c14be5.js +5 -0
  175. package/dist/components/p-a57338da.js +5 -0
  176. package/dist/components/p-bacd1638.js +5 -0
  177. package/dist/components/p-c526513b.js +5 -0
  178. package/dist/components/p-cb600b18.js +5 -0
  179. package/dist/components/p-ceea200f.js +5 -0
  180. package/dist/components/p-cefc0575.js +5 -0
  181. package/dist/components/p-d5ff7544.js +5 -0
  182. package/dist/components/p-e2158fc6.js +5 -0
  183. package/dist/components/p-fab97ac7.js +5 -0
  184. package/dist/components/paint-thickness.d.ts +11 -0
  185. package/dist/components/paint-thickness.js +5 -0
  186. package/dist/components/part-lookup.d.ts +11 -0
  187. package/dist/components/part-lookup.js +5 -0
  188. package/dist/components/service-booking-form.d.ts +11 -0
  189. package/dist/components/service-booking-form.js +5 -0
  190. package/dist/components/service-history.d.ts +11 -0
  191. package/dist/components/service-history.js +5 -0
  192. package/dist/components/vehicle-accessories.d.ts +11 -0
  193. package/dist/components/vehicle-accessories.js +5 -0
  194. package/dist/components/vehicle-lookup.d.ts +11 -0
  195. package/dist/components/vehicle-lookup.js +5 -0
  196. package/dist/components/vehicle-specification.d.ts +11 -0
  197. package/dist/components/vehicle-specification.js +5 -0
  198. package/dist/components/warranty-details.d.ts +11 -0
  199. package/dist/components/warranty-details.js +5 -0
  200. package/dist/esm/app-globals-68faa233.js +44 -0
  201. package/dist/esm/cn-cc419b94.js +2586 -0
  202. package/dist/esm/contact-us-form.entry.js +205 -0
  203. package/dist/esm/dead-stock-lookup_3.entry.js +439 -0
  204. package/dist/esm/dynamic-claim_6.entry.js +1171 -0
  205. package/dist/esm/dynamic-redeem.entry.js +152 -0
  206. package/dist/esm/form-dialog_8.entry.js +492 -0
  207. package/dist/esm/get-local-language-98c26a89.js +2376 -0
  208. package/dist/esm/index-cac905b0.js +1581 -0
  209. package/dist/esm/index.js +4 -0
  210. package/dist/esm/loader-027b88af.js +7 -0
  211. package/dist/esm/loader.js +15 -0
  212. package/dist/esm/loading-spinner.entry.js +23 -0
  213. package/dist/esm/part-lookup.entry.js +125 -0
  214. package/dist/esm/service-booking-form.entry.js +205 -0
  215. package/dist/esm/shift-components.js +24 -0
  216. package/dist/esm/urls-e22234f9.js +4870 -0
  217. package/dist/esm/vehicle-lookup.entry.js +199 -0
  218. package/dist/index.cjs.js +1 -0
  219. package/dist/index.js +1 -0
  220. package/dist/locales/ar.json +185 -0
  221. package/dist/locales/en.json +185 -0
  222. package/dist/locales/ku.json +185 -0
  223. package/dist/locales/ru.json +185 -0
  224. package/dist/shift-components/index.esm.js +4 -0
  225. package/dist/shift-components/p-014f3fba.entry.js +5 -0
  226. package/dist/shift-components/p-0739b7d7.entry.js +5 -0
  227. package/dist/shift-components/p-446d908d.js +5 -0
  228. package/dist/shift-components/p-46878289.entry.js +5 -0
  229. package/dist/shift-components/p-62c8eed3.entry.js +5 -0
  230. package/dist/shift-components/p-65102e7a.js +6 -0
  231. package/dist/shift-components/p-65a5ebdf.entry.js +5 -0
  232. package/dist/shift-components/p-87f8fbb3.entry.js +5 -0
  233. package/dist/shift-components/p-8830682d.entry.js +5 -0
  234. package/dist/shift-components/p-932ff922.js +5 -0
  235. package/dist/shift-components/p-98d9e7ab.js +5 -0
  236. package/dist/shift-components/p-a21e2e2e.js +5 -0
  237. package/dist/shift-components/p-c06844c1.js +5 -0
  238. package/dist/shift-components/p-da1511a0.entry.js +5 -0
  239. package/dist/shift-components/p-f68052c1.entry.js +5 -0
  240. package/dist/shift-components/shift-components.esm.js +5 -0
  241. package/dist/types/components/components/loading-spinner.d.ts +4 -0
  242. package/dist/types/components/form-elements/form-dialog.d.ts +13 -0
  243. package/dist/types/components/form-elements/form-input.d.ts +28 -0
  244. package/dist/types/components/form-elements/form-select.d.ts +39 -0
  245. package/dist/types/components/form-elements/form-shadow-input.d.ts +9 -0
  246. package/dist/types/components/form-elements/form-structure-error.d.ts +8 -0
  247. package/dist/types/components/form-elements/form-structure.d.ts +23 -0
  248. package/dist/types/components/form-elements/form-submit.d.ts +12 -0
  249. package/dist/types/components/form-elements/form-text-area.d.ts +24 -0
  250. package/dist/types/components/forms/contact-us/element-mapper.d.ts +3 -0
  251. package/dist/types/components/forms/contact-us/validations.d.ts +26 -0
  252. package/dist/types/components/forms/contact-us-form.d.ts +32 -0
  253. package/dist/types/components/forms/service-booking/element-mapper.d.ts +3 -0
  254. package/dist/types/components/forms/service-booking/validations.d.ts +26 -0
  255. package/dist/types/components/forms/service-booking-form.d.ts +32 -0
  256. package/dist/types/components/part-lookup/dead-stock-lookup.d.ts +31 -0
  257. package/dist/types/components/part-lookup/distributor-lookup.d.ts +32 -0
  258. package/dist/types/components/part-lookup/manufacturer-lookup.d.ts +33 -0
  259. package/dist/types/components/part-lookup/part-lookup.d.ts +43 -0
  260. package/dist/types/components/vehicle-lookup/components/CardsContainer.d.ts +10 -0
  261. package/dist/types/components/vehicle-lookup/components/Loading.d.ts +5 -0
  262. package/dist/types/components/vehicle-lookup/components/SSCTable.d.ts +8 -0
  263. package/dist/types/components/vehicle-lookup/components/StatusCard.d.ts +12 -0
  264. package/dist/types/components/vehicle-lookup/dynamic-claim.d.ts +57 -0
  265. package/dist/types/components/vehicle-lookup/dynamic-redeem.d.ts +39 -0
  266. package/dist/types/components/vehicle-lookup/paint-thickness.d.ts +35 -0
  267. package/dist/types/components/vehicle-lookup/service-history.d.ts +30 -0
  268. package/dist/types/components/vehicle-lookup/vehicle-accessories.d.ts +35 -0
  269. package/dist/types/components/vehicle-lookup/vehicle-lookup.d.ts +53 -0
  270. package/dist/types/components/vehicle-lookup/vehicle-specification.d.ts +29 -0
  271. package/dist/types/components/vehicle-lookup/warranty-details.d.ts +57 -0
  272. package/dist/types/components.d.ts +764 -0
  273. package/dist/types/global/api/partInformation.d.ts +19 -0
  274. package/dist/types/global/api/urls.d.ts +2 -0
  275. package/dist/types/global/api/vehicleInformation.d.ts +33 -0
  276. package/dist/types/global/lib/cn.d.ts +2 -0
  277. package/dist/types/global/lib/form-hook.d.ts +47 -0
  278. package/dist/types/global/lib/general.d.ts +1 -0
  279. package/dist/types/global/lib/get-local-language.d.ts +2 -0
  280. package/dist/types/global/lib/image-expansion.d.ts +9 -0
  281. package/dist/types/global/lib/middleware.d.ts +0 -0
  282. package/dist/types/global/lib/recaptcha.d.ts +16 -0
  283. package/dist/types/global/lib/utils.d.ts +1 -0
  284. package/dist/types/global/lib/validate-form-structure.d.ts +3 -0
  285. package/dist/types/global/lib/validate-vin.d.ts +1 -0
  286. package/dist/types/global/types/components.d.ts +7 -0
  287. package/dist/types/global/types/forms.d.ts +63 -0
  288. package/dist/types/global/types/general.d.ts +23 -0
  289. package/dist/types/global/types/locales/error-schema.d.ts +23 -0
  290. package/dist/types/global/types/locales/forms/contact-us-schema.d.ts +37 -0
  291. package/dist/types/global/types/locales/forms/index.d.ts +45 -0
  292. package/dist/types/global/types/locales/general.d.ts +11 -0
  293. package/dist/types/global/types/locales/index.d.ts +382 -0
  294. package/dist/types/global/types/locales/inquiryTypes.d.ts +19 -0
  295. package/dist/types/global/types/locales/part-lookup/dead-stock-schema.d.ts +9 -0
  296. package/dist/types/global/types/locales/part-lookup/distributor-schema.d.ts +31 -0
  297. package/dist/types/global/types/locales/part-lookup/index.d.ts +79 -0
  298. package/dist/types/global/types/locales/part-lookup/manufacturer-schema.d.ts +33 -0
  299. package/dist/types/global/types/locales/vehicle-lookup/accessories-schema.d.ts +15 -0
  300. package/dist/types/global/types/locales/vehicle-lookup/dynamic-claim-schema.d.ts +31 -0
  301. package/dist/types/global/types/locales/vehicle-lookup/dynamic-redeem-schema.d.ts +27 -0
  302. package/dist/types/global/types/locales/vehicle-lookup/index.d.ts +173 -0
  303. package/dist/types/global/types/locales/vehicle-lookup/paint-thickness-schema.d.ts +17 -0
  304. package/dist/types/global/types/locales/vehicle-lookup/service-history-schema.d.ts +19 -0
  305. package/dist/types/global/types/locales/vehicle-lookup/specification-schema.d.ts +19 -0
  306. package/dist/types/global/types/locales/vehicle-lookup/warranty-schema.d.ts +35 -0
  307. package/dist/types/global/types/part-information.d.ts +53 -0
  308. package/dist/types/global/types/vehicle-information.d.ts +172 -0
  309. package/dist/types/index.d.ts +10 -0
  310. package/dist/types/stencil-public-runtime.d.ts +1680 -0
  311. package/loader/cdn.js +5 -0
  312. package/loader/index.cjs.js +5 -0
  313. package/loader/index.d.ts +24 -0
  314. package/loader/index.es2017.js +5 -0
  315. package/loader/index.js +6 -0
  316. package/loader/package.json +11 -0
  317. package/package.json +1 -1
@@ -0,0 +1,2381 @@
1
+ /*!
2
+ * Built by ShiftSoftware
3
+ * Copyright (c)
4
+ */
5
+ 'use strict';
6
+
7
+ require('./index-603d8f32.js');
8
+
9
+ /**
10
+ * Based on Kendo UI Core expression code <https://github.com/telerik/kendo-ui-core#license-information>
11
+ */
12
+
13
+ function Cache(maxSize) {
14
+ this._maxSize = maxSize;
15
+ this.clear();
16
+ }
17
+ Cache.prototype.clear = function () {
18
+ this._size = 0;
19
+ this._values = Object.create(null);
20
+ };
21
+ Cache.prototype.get = function (key) {
22
+ return this._values[key]
23
+ };
24
+ Cache.prototype.set = function (key, value) {
25
+ this._size >= this._maxSize && this.clear();
26
+ if (!(key in this._values)) this._size++;
27
+
28
+ return (this._values[key] = value)
29
+ };
30
+
31
+ var SPLIT_REGEX = /[^.^\]^[]+|(?=\[\]|\.\.)/g,
32
+ DIGIT_REGEX = /^\d+$/,
33
+ LEAD_DIGIT_REGEX = /^\d/,
34
+ SPEC_CHAR_REGEX = /[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,
35
+ CLEAN_QUOTES_REGEX = /^\s*(['"]?)(.*?)(\1)\s*$/,
36
+ MAX_CACHE_SIZE = 512;
37
+
38
+ var pathCache = new Cache(MAX_CACHE_SIZE),
39
+ setCache = new Cache(MAX_CACHE_SIZE),
40
+ getCache = new Cache(MAX_CACHE_SIZE);
41
+
42
+ var propertyExpr = {
43
+ Cache: Cache,
44
+
45
+ split: split,
46
+
47
+ normalizePath: normalizePath,
48
+
49
+ setter: function (path) {
50
+ var parts = normalizePath(path);
51
+
52
+ return (
53
+ setCache.get(path) ||
54
+ setCache.set(path, function setter(obj, value) {
55
+ var index = 0;
56
+ var len = parts.length;
57
+ var data = obj;
58
+
59
+ while (index < len - 1) {
60
+ var part = parts[index];
61
+ if (
62
+ part === '__proto__' ||
63
+ part === 'constructor' ||
64
+ part === 'prototype'
65
+ ) {
66
+ return obj
67
+ }
68
+
69
+ data = data[parts[index++]];
70
+ }
71
+ data[parts[index]] = value;
72
+ })
73
+ )
74
+ },
75
+
76
+ getter: function (path, safe) {
77
+ var parts = normalizePath(path);
78
+ return (
79
+ getCache.get(path) ||
80
+ getCache.set(path, function getter(data) {
81
+ var index = 0,
82
+ len = parts.length;
83
+ while (index < len) {
84
+ if (data != null || !safe) data = data[parts[index++]];
85
+ else return
86
+ }
87
+ return data
88
+ })
89
+ )
90
+ },
91
+
92
+ join: function (segments) {
93
+ return segments.reduce(function (path, part) {
94
+ return (
95
+ path +
96
+ (isQuoted(part) || DIGIT_REGEX.test(part)
97
+ ? '[' + part + ']'
98
+ : (path ? '.' : '') + part)
99
+ )
100
+ }, '')
101
+ },
102
+
103
+ forEach: function (path, cb, thisArg) {
104
+ forEach(Array.isArray(path) ? path : split(path), cb, thisArg);
105
+ },
106
+ };
107
+
108
+ function normalizePath(path) {
109
+ return (
110
+ pathCache.get(path) ||
111
+ pathCache.set(
112
+ path,
113
+ split(path).map(function (part) {
114
+ return part.replace(CLEAN_QUOTES_REGEX, '$2')
115
+ })
116
+ )
117
+ )
118
+ }
119
+
120
+ function split(path) {
121
+ return path.match(SPLIT_REGEX) || ['']
122
+ }
123
+
124
+ function forEach(parts, iter, thisArg) {
125
+ var len = parts.length,
126
+ part,
127
+ idx,
128
+ isArray,
129
+ isBracket;
130
+
131
+ for (idx = 0; idx < len; idx++) {
132
+ part = parts[idx];
133
+
134
+ if (part) {
135
+ if (shouldBeQuoted(part)) {
136
+ part = '"' + part + '"';
137
+ }
138
+
139
+ isBracket = isQuoted(part);
140
+ isArray = !isBracket && /^\d+$/.test(part);
141
+
142
+ iter.call(thisArg, part, isBracket, isArray, idx, parts);
143
+ }
144
+ }
145
+ }
146
+
147
+ function isQuoted(str) {
148
+ return (
149
+ typeof str === 'string' && str && ["'", '"'].indexOf(str.charAt(0)) !== -1
150
+ )
151
+ }
152
+
153
+ function hasLeadingNumber(part) {
154
+ return part.match(LEAD_DIGIT_REGEX) && !part.match(DIGIT_REGEX)
155
+ }
156
+
157
+ function hasSpecialChars(part) {
158
+ return SPEC_CHAR_REGEX.test(part)
159
+ }
160
+
161
+ function shouldBeQuoted(part) {
162
+ return !isQuoted(part) && (hasLeadingNumber(part) || hasSpecialChars(part))
163
+ }
164
+
165
+ const reWords = /[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g;
166
+
167
+ const words = (str) => str.match(reWords) || [];
168
+
169
+ const upperFirst = (str) => str[0].toUpperCase() + str.slice(1);
170
+
171
+ const join = (str, d) => words(str).join(d).toLowerCase();
172
+
173
+ const camelCase = (str) =>
174
+ words(str).reduce(
175
+ (acc, next) =>
176
+ `${acc}${
177
+ !acc
178
+ ? next.toLowerCase()
179
+ : next[0].toUpperCase() + next.slice(1).toLowerCase()
180
+ }`,
181
+ '',
182
+ );
183
+
184
+ const pascalCase = (str) => upperFirst(camelCase(str));
185
+
186
+ const snakeCase = (str) => join(str, '_');
187
+
188
+ const kebabCase = (str) => join(str, '-');
189
+
190
+ const sentenceCase = (str) => upperFirst(join(str, ' '));
191
+
192
+ const titleCase = (str) => words(str).map(upperFirst).join(' ');
193
+
194
+ var tinyCase = {
195
+ words,
196
+ upperFirst,
197
+ camelCase,
198
+ pascalCase,
199
+ snakeCase,
200
+ kebabCase,
201
+ sentenceCase,
202
+ titleCase,
203
+ };
204
+
205
+ var toposort$2 = {exports: {}};
206
+
207
+ /**
208
+ * Topological sorting function
209
+ *
210
+ * @param {Array} edges
211
+ * @returns {Array}
212
+ */
213
+
214
+ toposort$2.exports = function(edges) {
215
+ return toposort(uniqueNodes(edges), edges)
216
+ };
217
+
218
+ toposort$2.exports.array = toposort;
219
+
220
+ function toposort(nodes, edges) {
221
+ var cursor = nodes.length
222
+ , sorted = new Array(cursor)
223
+ , visited = {}
224
+ , i = cursor
225
+ // Better data structures make algorithm much faster.
226
+ , outgoingEdges = makeOutgoingEdges(edges)
227
+ , nodesHash = makeNodesHash(nodes);
228
+
229
+ // check for unknown nodes
230
+ edges.forEach(function(edge) {
231
+ if (!nodesHash.has(edge[0]) || !nodesHash.has(edge[1])) {
232
+ throw new Error('Unknown node. There is an unknown node in the supplied edges.')
233
+ }
234
+ });
235
+
236
+ while (i--) {
237
+ if (!visited[i]) visit(nodes[i], i, new Set());
238
+ }
239
+
240
+ return sorted
241
+
242
+ function visit(node, i, predecessors) {
243
+ if(predecessors.has(node)) {
244
+ var nodeRep;
245
+ try {
246
+ nodeRep = ", node was:" + JSON.stringify(node);
247
+ } catch(e) {
248
+ nodeRep = "";
249
+ }
250
+ throw new Error('Cyclic dependency' + nodeRep)
251
+ }
252
+
253
+ if (!nodesHash.has(node)) {
254
+ throw new Error('Found unknown node. Make sure to provided all involved nodes. Unknown node: '+JSON.stringify(node))
255
+ }
256
+
257
+ if (visited[i]) return;
258
+ visited[i] = true;
259
+
260
+ var outgoing = outgoingEdges.get(node) || new Set();
261
+ outgoing = Array.from(outgoing);
262
+
263
+ if (i = outgoing.length) {
264
+ predecessors.add(node);
265
+ do {
266
+ var child = outgoing[--i];
267
+ visit(child, nodesHash.get(child), predecessors);
268
+ } while (i)
269
+ predecessors.delete(node);
270
+ }
271
+
272
+ sorted[--cursor] = node;
273
+ }
274
+ }
275
+
276
+ function uniqueNodes(arr){
277
+ var res = new Set();
278
+ for (var i = 0, len = arr.length; i < len; i++) {
279
+ var edge = arr[i];
280
+ res.add(edge[0]);
281
+ res.add(edge[1]);
282
+ }
283
+ return Array.from(res)
284
+ }
285
+
286
+ function makeOutgoingEdges(arr){
287
+ var edges = new Map();
288
+ for (var i = 0, len = arr.length; i < len; i++) {
289
+ var edge = arr[i];
290
+ if (!edges.has(edge[0])) edges.set(edge[0], new Set());
291
+ if (!edges.has(edge[1])) edges.set(edge[1], new Set());
292
+ edges.get(edge[0]).add(edge[1]);
293
+ }
294
+ return edges
295
+ }
296
+
297
+ function makeNodesHash(arr){
298
+ var res = new Map();
299
+ for (var i = 0, len = arr.length; i < len; i++) {
300
+ res.set(arr[i], i);
301
+ }
302
+ return res
303
+ }
304
+
305
+ const toposort$1 = toposort$2.exports;
306
+
307
+ const toString = Object.prototype.toString;
308
+ const errorToString = Error.prototype.toString;
309
+ const regExpToString = RegExp.prototype.toString;
310
+ const symbolToString = typeof Symbol !== 'undefined' ? Symbol.prototype.toString : () => '';
311
+ const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
312
+ function printNumber(val) {
313
+ if (val != +val) return 'NaN';
314
+ const isNegativeZero = val === 0 && 1 / val < 0;
315
+ return isNegativeZero ? '-0' : '' + val;
316
+ }
317
+ function printSimpleValue(val, quoteStrings = false) {
318
+ if (val == null || val === true || val === false) return '' + val;
319
+ const typeOf = typeof val;
320
+ if (typeOf === 'number') return printNumber(val);
321
+ if (typeOf === 'string') return quoteStrings ? `"${val}"` : val;
322
+ if (typeOf === 'function') return '[Function ' + (val.name || 'anonymous') + ']';
323
+ if (typeOf === 'symbol') return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
324
+ const tag = toString.call(val).slice(8, -1);
325
+ if (tag === 'Date') return isNaN(val.getTime()) ? '' + val : val.toISOString(val);
326
+ if (tag === 'Error' || val instanceof Error) return '[' + errorToString.call(val) + ']';
327
+ if (tag === 'RegExp') return regExpToString.call(val);
328
+ return null;
329
+ }
330
+ function printValue(value, quoteStrings) {
331
+ let result = printSimpleValue(value, quoteStrings);
332
+ if (result !== null) return result;
333
+ return JSON.stringify(value, function (key, value) {
334
+ let result = printSimpleValue(this[key], quoteStrings);
335
+ if (result !== null) return result;
336
+ return value;
337
+ }, 2);
338
+ }
339
+
340
+ function toArray(value) {
341
+ return value == null ? [] : [].concat(value);
342
+ }
343
+
344
+ let _Symbol$toStringTag, _Symbol$hasInstance, _Symbol$toStringTag2;
345
+ let strReg = /\$\{\s*(\w+)\s*\}/g;
346
+ _Symbol$toStringTag = Symbol.toStringTag;
347
+ class ValidationErrorNoStack {
348
+ constructor(errorOrErrors, value, field, type) {
349
+ this.name = void 0;
350
+ this.message = void 0;
351
+ this.value = void 0;
352
+ this.path = void 0;
353
+ this.type = void 0;
354
+ this.params = void 0;
355
+ this.errors = void 0;
356
+ this.inner = void 0;
357
+ this[_Symbol$toStringTag] = 'Error';
358
+ this.name = 'ValidationError';
359
+ this.value = value;
360
+ this.path = field;
361
+ this.type = type;
362
+ this.errors = [];
363
+ this.inner = [];
364
+ toArray(errorOrErrors).forEach(err => {
365
+ if (ValidationError.isError(err)) {
366
+ this.errors.push(...err.errors);
367
+ const innerErrors = err.inner.length ? err.inner : [err];
368
+ this.inner.push(...innerErrors);
369
+ } else {
370
+ this.errors.push(err);
371
+ }
372
+ });
373
+ this.message = this.errors.length > 1 ? `${this.errors.length} errors occurred` : this.errors[0];
374
+ }
375
+ }
376
+ _Symbol$hasInstance = Symbol.hasInstance;
377
+ _Symbol$toStringTag2 = Symbol.toStringTag;
378
+ class ValidationError extends Error {
379
+ static formatError(message, params) {
380
+ // Attempt to make the path more friendly for error message interpolation.
381
+ const path = params.label || params.path || 'this';
382
+ // Store the original path under `originalPath` so it isn't lost to custom
383
+ // message functions; e.g., ones provided in `setLocale()` calls.
384
+ params = Object.assign({}, params, {
385
+ path,
386
+ originalPath: params.path
387
+ });
388
+ if (typeof message === 'string') return message.replace(strReg, (_, key) => printValue(params[key]));
389
+ if (typeof message === 'function') return message(params);
390
+ return message;
391
+ }
392
+ static isError(err) {
393
+ return err && err.name === 'ValidationError';
394
+ }
395
+ constructor(errorOrErrors, value, field, type, disableStack) {
396
+ const errorNoStack = new ValidationErrorNoStack(errorOrErrors, value, field, type);
397
+ if (disableStack) {
398
+ return errorNoStack;
399
+ }
400
+ super();
401
+ this.value = void 0;
402
+ this.path = void 0;
403
+ this.type = void 0;
404
+ this.params = void 0;
405
+ this.errors = [];
406
+ this.inner = [];
407
+ this[_Symbol$toStringTag2] = 'Error';
408
+ this.name = errorNoStack.name;
409
+ this.message = errorNoStack.message;
410
+ this.type = errorNoStack.type;
411
+ this.value = errorNoStack.value;
412
+ this.path = errorNoStack.path;
413
+ this.errors = errorNoStack.errors;
414
+ this.inner = errorNoStack.inner;
415
+ if (Error.captureStackTrace) {
416
+ Error.captureStackTrace(this, ValidationError);
417
+ }
418
+ }
419
+ static [_Symbol$hasInstance](inst) {
420
+ return ValidationErrorNoStack[Symbol.hasInstance](inst) || super[Symbol.hasInstance](inst);
421
+ }
422
+ }
423
+
424
+ let mixed = {
425
+ default: '${path} is invalid',
426
+ required: '${path} is a required field',
427
+ defined: '${path} must be defined',
428
+ notNull: '${path} cannot be null',
429
+ oneOf: '${path} must be one of the following values: ${values}',
430
+ notOneOf: '${path} must not be one of the following values: ${values}',
431
+ notType: ({
432
+ path,
433
+ type,
434
+ value,
435
+ originalValue
436
+ }) => {
437
+ const castMsg = originalValue != null && originalValue !== value ? ` (cast from the value \`${printValue(originalValue, true)}\`).` : '.';
438
+ return type !== 'mixed' ? `${path} must be a \`${type}\` type, ` + `but the final value was: \`${printValue(value, true)}\`` + castMsg : `${path} must match the configured type. ` + `The validated value was: \`${printValue(value, true)}\`` + castMsg;
439
+ }
440
+ };
441
+ let string = {
442
+ length: '${path} must be exactly ${length} characters',
443
+ min: '${path} must be at least ${min} characters',
444
+ max: '${path} must be at most ${max} characters',
445
+ matches: '${path} must match the following: "${regex}"',
446
+ email: '${path} must be a valid email',
447
+ url: '${path} must be a valid URL',
448
+ uuid: '${path} must be a valid UUID',
449
+ datetime: '${path} must be a valid ISO date-time',
450
+ datetime_precision: '${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits',
451
+ datetime_offset: '${path} must be a valid ISO date-time with UTC "Z" timezone',
452
+ trim: '${path} must be a trimmed string',
453
+ lowercase: '${path} must be a lowercase string',
454
+ uppercase: '${path} must be a upper case string'
455
+ };
456
+ let number = {
457
+ min: '${path} must be greater than or equal to ${min}',
458
+ max: '${path} must be less than or equal to ${max}',
459
+ lessThan: '${path} must be less than ${less}',
460
+ moreThan: '${path} must be greater than ${more}',
461
+ positive: '${path} must be a positive number',
462
+ negative: '${path} must be a negative number',
463
+ integer: '${path} must be an integer'
464
+ };
465
+ let date = {
466
+ min: '${path} field must be later than ${min}',
467
+ max: '${path} field must be at earlier than ${max}'
468
+ };
469
+ let boolean = {
470
+ isValue: '${path} field must be ${value}'
471
+ };
472
+ let object = {
473
+ noUnknown: '${path} field has unspecified keys: ${unknown}',
474
+ exact: '${path} object contains unknown properties: ${properties}'
475
+ };
476
+ let array = {
477
+ min: '${path} field must have at least ${min} items',
478
+ max: '${path} field must have less than or equal to ${max} items',
479
+ length: '${path} must have ${length} items'
480
+ };
481
+ let tuple = {
482
+ notType: params => {
483
+ const {
484
+ path,
485
+ value,
486
+ spec
487
+ } = params;
488
+ const typeLen = spec.types.length;
489
+ if (Array.isArray(value)) {
490
+ if (value.length < typeLen) return `${path} tuple value has too few items, expected a length of ${typeLen} but got ${value.length} for value: \`${printValue(value, true)}\``;
491
+ if (value.length > typeLen) return `${path} tuple value has too many items, expected a length of ${typeLen} but got ${value.length} for value: \`${printValue(value, true)}\``;
492
+ }
493
+ return ValidationError.formatError(mixed.notType, params);
494
+ }
495
+ };
496
+ Object.assign(Object.create(null), {
497
+ mixed,
498
+ string,
499
+ number,
500
+ date,
501
+ object,
502
+ array,
503
+ boolean,
504
+ tuple
505
+ });
506
+
507
+ const isSchema = obj => obj && obj.__isYupSchema__;
508
+
509
+ class Condition {
510
+ static fromOptions(refs, config) {
511
+ if (!config.then && !config.otherwise) throw new TypeError('either `then:` or `otherwise:` is required for `when()` conditions');
512
+ let {
513
+ is,
514
+ then,
515
+ otherwise
516
+ } = config;
517
+ let check = typeof is === 'function' ? is : (...values) => values.every(value => value === is);
518
+ return new Condition(refs, (values, schema) => {
519
+ var _branch;
520
+ let branch = check(...values) ? then : otherwise;
521
+ return (_branch = branch == null ? void 0 : branch(schema)) != null ? _branch : schema;
522
+ });
523
+ }
524
+ constructor(refs, builder) {
525
+ this.fn = void 0;
526
+ this.refs = refs;
527
+ this.refs = refs;
528
+ this.fn = builder;
529
+ }
530
+ resolve(base, options) {
531
+ let values = this.refs.map(ref =>
532
+ // TODO: ? operator here?
533
+ ref.getValue(options == null ? void 0 : options.value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context));
534
+ let schema = this.fn(values, base, options);
535
+ if (schema === undefined ||
536
+ // @ts-ignore this can be base
537
+ schema === base) {
538
+ return base;
539
+ }
540
+ if (!isSchema(schema)) throw new TypeError('conditions must return a schema object');
541
+ return schema.resolve(options);
542
+ }
543
+ }
544
+
545
+ const prefixes = {
546
+ context: '$',
547
+ value: '.'
548
+ };
549
+ class Reference {
550
+ constructor(key, options = {}) {
551
+ this.key = void 0;
552
+ this.isContext = void 0;
553
+ this.isValue = void 0;
554
+ this.isSibling = void 0;
555
+ this.path = void 0;
556
+ this.getter = void 0;
557
+ this.map = void 0;
558
+ if (typeof key !== 'string') throw new TypeError('ref must be a string, got: ' + key);
559
+ this.key = key.trim();
560
+ if (key === '') throw new TypeError('ref must be a non-empty string');
561
+ this.isContext = this.key[0] === prefixes.context;
562
+ this.isValue = this.key[0] === prefixes.value;
563
+ this.isSibling = !this.isContext && !this.isValue;
564
+ let prefix = this.isContext ? prefixes.context : this.isValue ? prefixes.value : '';
565
+ this.path = this.key.slice(prefix.length);
566
+ this.getter = this.path && propertyExpr.getter(this.path, true);
567
+ this.map = options.map;
568
+ }
569
+ getValue(value, parent, context) {
570
+ let result = this.isContext ? context : this.isValue ? value : parent;
571
+ if (this.getter) result = this.getter(result || {});
572
+ if (this.map) result = this.map(result);
573
+ return result;
574
+ }
575
+
576
+ /**
577
+ *
578
+ * @param {*} value
579
+ * @param {Object} options
580
+ * @param {Object=} options.context
581
+ * @param {Object=} options.parent
582
+ */
583
+ cast(value, options) {
584
+ return this.getValue(value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context);
585
+ }
586
+ resolve() {
587
+ return this;
588
+ }
589
+ describe() {
590
+ return {
591
+ type: 'ref',
592
+ key: this.key
593
+ };
594
+ }
595
+ toString() {
596
+ return `Ref(${this.key})`;
597
+ }
598
+ static isRef(value) {
599
+ return value && value.__isYupRef;
600
+ }
601
+ }
602
+
603
+ // @ts-ignore
604
+ Reference.prototype.__isYupRef = true;
605
+
606
+ const isAbsent = value => value == null;
607
+
608
+ function createValidation(config) {
609
+ function validate({
610
+ value,
611
+ path = '',
612
+ options,
613
+ originalValue,
614
+ schema
615
+ }, panic, next) {
616
+ const {
617
+ name,
618
+ test,
619
+ params,
620
+ message,
621
+ skipAbsent
622
+ } = config;
623
+ let {
624
+ parent,
625
+ context,
626
+ abortEarly = schema.spec.abortEarly,
627
+ disableStackTrace = schema.spec.disableStackTrace
628
+ } = options;
629
+ function resolve(item) {
630
+ return Reference.isRef(item) ? item.getValue(value, parent, context) : item;
631
+ }
632
+ function createError(overrides = {}) {
633
+ const nextParams = Object.assign({
634
+ value,
635
+ originalValue,
636
+ label: schema.spec.label,
637
+ path: overrides.path || path,
638
+ spec: schema.spec,
639
+ disableStackTrace: overrides.disableStackTrace || disableStackTrace
640
+ }, params, overrides.params);
641
+ for (const key of Object.keys(nextParams)) nextParams[key] = resolve(nextParams[key]);
642
+ const error = new ValidationError(ValidationError.formatError(overrides.message || message, nextParams), value, nextParams.path, overrides.type || name, nextParams.disableStackTrace);
643
+ error.params = nextParams;
644
+ return error;
645
+ }
646
+ const invalid = abortEarly ? panic : next;
647
+ let ctx = {
648
+ path,
649
+ parent,
650
+ type: name,
651
+ from: options.from,
652
+ createError,
653
+ resolve,
654
+ options,
655
+ originalValue,
656
+ schema
657
+ };
658
+ const handleResult = validOrError => {
659
+ if (ValidationError.isError(validOrError)) invalid(validOrError);else if (!validOrError) invalid(createError());else next(null);
660
+ };
661
+ const handleError = err => {
662
+ if (ValidationError.isError(err)) invalid(err);else panic(err);
663
+ };
664
+ const shouldSkip = skipAbsent && isAbsent(value);
665
+ if (shouldSkip) {
666
+ return handleResult(true);
667
+ }
668
+ let result;
669
+ try {
670
+ var _result;
671
+ result = test.call(ctx, value, ctx);
672
+ if (typeof ((_result = result) == null ? void 0 : _result.then) === 'function') {
673
+ if (options.sync) {
674
+ throw new Error(`Validation test of type: "${ctx.type}" returned a Promise during a synchronous validate. ` + `This test will finish after the validate call has returned`);
675
+ }
676
+ return Promise.resolve(result).then(handleResult, handleError);
677
+ }
678
+ } catch (err) {
679
+ handleError(err);
680
+ return;
681
+ }
682
+ handleResult(result);
683
+ }
684
+ validate.OPTIONS = config;
685
+ return validate;
686
+ }
687
+
688
+ function getIn(schema, path, value, context = value) {
689
+ let parent, lastPart, lastPartDebug;
690
+
691
+ // root path: ''
692
+ if (!path) return {
693
+ parent,
694
+ parentPath: path,
695
+ schema
696
+ };
697
+ propertyExpr.forEach(path, (_part, isBracket, isArray) => {
698
+ let part = isBracket ? _part.slice(1, _part.length - 1) : _part;
699
+ schema = schema.resolve({
700
+ context,
701
+ parent,
702
+ value
703
+ });
704
+ let isTuple = schema.type === 'tuple';
705
+ let idx = isArray ? parseInt(part, 10) : 0;
706
+ if (schema.innerType || isTuple) {
707
+ if (isTuple && !isArray) throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${lastPartDebug}" must contain an index to the tuple element, e.g. "${lastPartDebug}[0]"`);
708
+ if (value && idx >= value.length) {
709
+ throw new Error(`Yup.reach cannot resolve an array item at index: ${_part}, in the path: ${path}. ` + `because there is no value at that index. `);
710
+ }
711
+ parent = value;
712
+ value = value && value[idx];
713
+ schema = isTuple ? schema.spec.types[idx] : schema.innerType;
714
+ }
715
+
716
+ // sometimes the array index part of a path doesn't exist: "nested.arr.child"
717
+ // in these cases the current part is the next schema and should be processed
718
+ // in this iteration. For cases where the index signature is included this
719
+ // check will fail and we'll handle the `child` part on the next iteration like normal
720
+ if (!isArray) {
721
+ if (!schema.fields || !schema.fields[part]) throw new Error(`The schema does not contain the path: ${path}. ` + `(failed at: ${lastPartDebug} which is a type: "${schema.type}")`);
722
+ parent = value;
723
+ value = value && value[part];
724
+ schema = schema.fields[part];
725
+ }
726
+ lastPart = part;
727
+ lastPartDebug = isBracket ? '[' + _part + ']' : '.' + _part;
728
+ });
729
+ return {
730
+ schema,
731
+ parent,
732
+ parentPath: lastPart
733
+ };
734
+ }
735
+
736
+ class ReferenceSet extends Set {
737
+ describe() {
738
+ const description = [];
739
+ for (const item of this.values()) {
740
+ description.push(Reference.isRef(item) ? item.describe() : item);
741
+ }
742
+ return description;
743
+ }
744
+ resolveAll(resolve) {
745
+ let result = [];
746
+ for (const item of this.values()) {
747
+ result.push(resolve(item));
748
+ }
749
+ return result;
750
+ }
751
+ clone() {
752
+ return new ReferenceSet(this.values());
753
+ }
754
+ merge(newItems, removeItems) {
755
+ const next = this.clone();
756
+ newItems.forEach(value => next.add(value));
757
+ removeItems.forEach(value => next.delete(value));
758
+ return next;
759
+ }
760
+ }
761
+
762
+ // tweaked from https://github.com/Kelin2025/nanoclone/blob/0abeb7635bda9b68ef2277093f76dbe3bf3948e1/src/index.js
763
+ function clone(src, seen = new Map()) {
764
+ if (isSchema(src) || !src || typeof src !== 'object') return src;
765
+ if (seen.has(src)) return seen.get(src);
766
+ let copy;
767
+ if (src instanceof Date) {
768
+ // Date
769
+ copy = new Date(src.getTime());
770
+ seen.set(src, copy);
771
+ } else if (src instanceof RegExp) {
772
+ // RegExp
773
+ copy = new RegExp(src);
774
+ seen.set(src, copy);
775
+ } else if (Array.isArray(src)) {
776
+ // Array
777
+ copy = new Array(src.length);
778
+ seen.set(src, copy);
779
+ for (let i = 0; i < src.length; i++) copy[i] = clone(src[i], seen);
780
+ } else if (src instanceof Map) {
781
+ // Map
782
+ copy = new Map();
783
+ seen.set(src, copy);
784
+ for (const [k, v] of src.entries()) copy.set(k, clone(v, seen));
785
+ } else if (src instanceof Set) {
786
+ // Set
787
+ copy = new Set();
788
+ seen.set(src, copy);
789
+ for (const v of src) copy.add(clone(v, seen));
790
+ } else if (src instanceof Object) {
791
+ // Object
792
+ copy = {};
793
+ seen.set(src, copy);
794
+ for (const [k, v] of Object.entries(src)) copy[k] = clone(v, seen);
795
+ } else {
796
+ throw Error(`Unable to clone ${src}`);
797
+ }
798
+ return copy;
799
+ }
800
+
801
+ // If `CustomSchemaMeta` isn't extended with any keys, we'll fall back to a
802
+ // loose Record definition allowing free form usage.
803
+ class Schema {
804
+ constructor(options) {
805
+ this.type = void 0;
806
+ this.deps = [];
807
+ this.tests = void 0;
808
+ this.transforms = void 0;
809
+ this.conditions = [];
810
+ this._mutate = void 0;
811
+ this.internalTests = {};
812
+ this._whitelist = new ReferenceSet();
813
+ this._blacklist = new ReferenceSet();
814
+ this.exclusiveTests = Object.create(null);
815
+ this._typeCheck = void 0;
816
+ this.spec = void 0;
817
+ this.tests = [];
818
+ this.transforms = [];
819
+ this.withMutation(() => {
820
+ this.typeError(mixed.notType);
821
+ });
822
+ this.type = options.type;
823
+ this._typeCheck = options.check;
824
+ this.spec = Object.assign({
825
+ strip: false,
826
+ strict: false,
827
+ abortEarly: true,
828
+ recursive: true,
829
+ disableStackTrace: false,
830
+ nullable: false,
831
+ optional: true,
832
+ coerce: true
833
+ }, options == null ? void 0 : options.spec);
834
+ this.withMutation(s => {
835
+ s.nonNullable();
836
+ });
837
+ }
838
+
839
+ // TODO: remove
840
+ get _type() {
841
+ return this.type;
842
+ }
843
+ clone(spec) {
844
+ if (this._mutate) {
845
+ if (spec) Object.assign(this.spec, spec);
846
+ return this;
847
+ }
848
+
849
+ // if the nested value is a schema we can skip cloning, since
850
+ // they are already immutable
851
+ const next = Object.create(Object.getPrototypeOf(this));
852
+
853
+ // @ts-expect-error this is readonly
854
+ next.type = this.type;
855
+ next._typeCheck = this._typeCheck;
856
+ next._whitelist = this._whitelist.clone();
857
+ next._blacklist = this._blacklist.clone();
858
+ next.internalTests = Object.assign({}, this.internalTests);
859
+ next.exclusiveTests = Object.assign({}, this.exclusiveTests);
860
+
861
+ // @ts-expect-error this is readonly
862
+ next.deps = [...this.deps];
863
+ next.conditions = [...this.conditions];
864
+ next.tests = [...this.tests];
865
+ next.transforms = [...this.transforms];
866
+ next.spec = clone(Object.assign({}, this.spec, spec));
867
+ return next;
868
+ }
869
+ label(label) {
870
+ let next = this.clone();
871
+ next.spec.label = label;
872
+ return next;
873
+ }
874
+ meta(...args) {
875
+ if (args.length === 0) return this.spec.meta;
876
+ let next = this.clone();
877
+ next.spec.meta = Object.assign(next.spec.meta || {}, args[0]);
878
+ return next;
879
+ }
880
+ withMutation(fn) {
881
+ let before = this._mutate;
882
+ this._mutate = true;
883
+ let result = fn(this);
884
+ this._mutate = before;
885
+ return result;
886
+ }
887
+ concat(schema) {
888
+ if (!schema || schema === this) return this;
889
+ if (schema.type !== this.type && this.type !== 'mixed') throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${schema.type}`);
890
+ let base = this;
891
+ let combined = schema.clone();
892
+ const mergedSpec = Object.assign({}, base.spec, combined.spec);
893
+ combined.spec = mergedSpec;
894
+ combined.internalTests = Object.assign({}, base.internalTests, combined.internalTests);
895
+
896
+ // manually merge the blacklist/whitelist (the other `schema` takes
897
+ // precedence in case of conflicts)
898
+ combined._whitelist = base._whitelist.merge(schema._whitelist, schema._blacklist);
899
+ combined._blacklist = base._blacklist.merge(schema._blacklist, schema._whitelist);
900
+
901
+ // start with the current tests
902
+ combined.tests = base.tests;
903
+ combined.exclusiveTests = base.exclusiveTests;
904
+
905
+ // manually add the new tests to ensure
906
+ // the deduping logic is consistent
907
+ combined.withMutation(next => {
908
+ schema.tests.forEach(fn => {
909
+ next.test(fn.OPTIONS);
910
+ });
911
+ });
912
+ combined.transforms = [...base.transforms, ...combined.transforms];
913
+ return combined;
914
+ }
915
+ isType(v) {
916
+ if (v == null) {
917
+ if (this.spec.nullable && v === null) return true;
918
+ if (this.spec.optional && v === undefined) return true;
919
+ return false;
920
+ }
921
+ return this._typeCheck(v);
922
+ }
923
+ resolve(options) {
924
+ let schema = this;
925
+ if (schema.conditions.length) {
926
+ let conditions = schema.conditions;
927
+ schema = schema.clone();
928
+ schema.conditions = [];
929
+ schema = conditions.reduce((prevSchema, condition) => condition.resolve(prevSchema, options), schema);
930
+ schema = schema.resolve(options);
931
+ }
932
+ return schema;
933
+ }
934
+ resolveOptions(options) {
935
+ var _options$strict, _options$abortEarly, _options$recursive, _options$disableStack;
936
+ return Object.assign({}, options, {
937
+ from: options.from || [],
938
+ strict: (_options$strict = options.strict) != null ? _options$strict : this.spec.strict,
939
+ abortEarly: (_options$abortEarly = options.abortEarly) != null ? _options$abortEarly : this.spec.abortEarly,
940
+ recursive: (_options$recursive = options.recursive) != null ? _options$recursive : this.spec.recursive,
941
+ disableStackTrace: (_options$disableStack = options.disableStackTrace) != null ? _options$disableStack : this.spec.disableStackTrace
942
+ });
943
+ }
944
+
945
+ /**
946
+ * Run the configured transform pipeline over an input value.
947
+ */
948
+
949
+ cast(value, options = {}) {
950
+ let resolvedSchema = this.resolve(Object.assign({
951
+ value
952
+ }, options));
953
+ let allowOptionality = options.assert === 'ignore-optionality';
954
+ let result = resolvedSchema._cast(value, options);
955
+ if (options.assert !== false && !resolvedSchema.isType(result)) {
956
+ if (allowOptionality && isAbsent(result)) {
957
+ return result;
958
+ }
959
+ let formattedValue = printValue(value);
960
+ let formattedResult = printValue(result);
961
+ throw new TypeError(`The value of ${options.path || 'field'} could not be cast to a value ` + `that satisfies the schema type: "${resolvedSchema.type}". \n\n` + `attempted value: ${formattedValue} \n` + (formattedResult !== formattedValue ? `result of cast: ${formattedResult}` : ''));
962
+ }
963
+ return result;
964
+ }
965
+ _cast(rawValue, options) {
966
+ let value = rawValue === undefined ? rawValue : this.transforms.reduce((prevValue, fn) => fn.call(this, prevValue, rawValue, this), rawValue);
967
+ if (value === undefined) {
968
+ value = this.getDefault(options);
969
+ }
970
+ return value;
971
+ }
972
+ _validate(_value, options = {}, panic, next) {
973
+ let {
974
+ path,
975
+ originalValue = _value,
976
+ strict = this.spec.strict
977
+ } = options;
978
+ let value = _value;
979
+ if (!strict) {
980
+ value = this._cast(value, Object.assign({
981
+ assert: false
982
+ }, options));
983
+ }
984
+ let initialTests = [];
985
+ for (let test of Object.values(this.internalTests)) {
986
+ if (test) initialTests.push(test);
987
+ }
988
+ this.runTests({
989
+ path,
990
+ value,
991
+ originalValue,
992
+ options,
993
+ tests: initialTests
994
+ }, panic, initialErrors => {
995
+ // even if we aren't ending early we can't proceed further if the types aren't correct
996
+ if (initialErrors.length) {
997
+ return next(initialErrors, value);
998
+ }
999
+ this.runTests({
1000
+ path,
1001
+ value,
1002
+ originalValue,
1003
+ options,
1004
+ tests: this.tests
1005
+ }, panic, next);
1006
+ });
1007
+ }
1008
+
1009
+ /**
1010
+ * Executes a set of validations, either schema, produced Tests or a nested
1011
+ * schema validate result.
1012
+ */
1013
+ runTests(runOptions, panic, next) {
1014
+ let fired = false;
1015
+ let {
1016
+ tests,
1017
+ value,
1018
+ originalValue,
1019
+ path,
1020
+ options
1021
+ } = runOptions;
1022
+ let panicOnce = arg => {
1023
+ if (fired) return;
1024
+ fired = true;
1025
+ panic(arg, value);
1026
+ };
1027
+ let nextOnce = arg => {
1028
+ if (fired) return;
1029
+ fired = true;
1030
+ next(arg, value);
1031
+ };
1032
+ let count = tests.length;
1033
+ let nestedErrors = [];
1034
+ if (!count) return nextOnce([]);
1035
+ let args = {
1036
+ value,
1037
+ originalValue,
1038
+ path,
1039
+ options,
1040
+ schema: this
1041
+ };
1042
+ for (let i = 0; i < tests.length; i++) {
1043
+ const test = tests[i];
1044
+ test(args, panicOnce, function finishTestRun(err) {
1045
+ if (err) {
1046
+ Array.isArray(err) ? nestedErrors.push(...err) : nestedErrors.push(err);
1047
+ }
1048
+ if (--count <= 0) {
1049
+ nextOnce(nestedErrors);
1050
+ }
1051
+ });
1052
+ }
1053
+ }
1054
+ asNestedTest({
1055
+ key,
1056
+ index,
1057
+ parent,
1058
+ parentPath,
1059
+ originalParent,
1060
+ options
1061
+ }) {
1062
+ const k = key != null ? key : index;
1063
+ if (k == null) {
1064
+ throw TypeError('Must include `key` or `index` for nested validations');
1065
+ }
1066
+ const isIndex = typeof k === 'number';
1067
+ let value = parent[k];
1068
+ const testOptions = Object.assign({}, options, {
1069
+ // Nested validations fields are always strict:
1070
+ // 1. parent isn't strict so the casting will also have cast inner values
1071
+ // 2. parent is strict in which case the nested values weren't cast either
1072
+ strict: true,
1073
+ parent,
1074
+ value,
1075
+ originalValue: originalParent[k],
1076
+ // FIXME: tests depend on `index` being passed around deeply,
1077
+ // we should not let the options.key/index bleed through
1078
+ key: undefined,
1079
+ // index: undefined,
1080
+ [isIndex ? 'index' : 'key']: k,
1081
+ path: isIndex || k.includes('.') ? `${parentPath || ''}[${isIndex ? k : `"${k}"`}]` : (parentPath ? `${parentPath}.` : '') + key
1082
+ });
1083
+ return (_, panic, next) => this.resolve(testOptions)._validate(value, testOptions, panic, next);
1084
+ }
1085
+ validate(value, options) {
1086
+ var _options$disableStack2;
1087
+ let schema = this.resolve(Object.assign({}, options, {
1088
+ value
1089
+ }));
1090
+ let disableStackTrace = (_options$disableStack2 = options == null ? void 0 : options.disableStackTrace) != null ? _options$disableStack2 : schema.spec.disableStackTrace;
1091
+ return new Promise((resolve, reject) => schema._validate(value, options, (error, parsed) => {
1092
+ if (ValidationError.isError(error)) error.value = parsed;
1093
+ reject(error);
1094
+ }, (errors, validated) => {
1095
+ if (errors.length) reject(new ValidationError(errors, validated, undefined, undefined, disableStackTrace));else resolve(validated);
1096
+ }));
1097
+ }
1098
+ validateSync(value, options) {
1099
+ var _options$disableStack3;
1100
+ let schema = this.resolve(Object.assign({}, options, {
1101
+ value
1102
+ }));
1103
+ let result;
1104
+ let disableStackTrace = (_options$disableStack3 = options == null ? void 0 : options.disableStackTrace) != null ? _options$disableStack3 : schema.spec.disableStackTrace;
1105
+ schema._validate(value, Object.assign({}, options, {
1106
+ sync: true
1107
+ }), (error, parsed) => {
1108
+ if (ValidationError.isError(error)) error.value = parsed;
1109
+ throw error;
1110
+ }, (errors, validated) => {
1111
+ if (errors.length) throw new ValidationError(errors, value, undefined, undefined, disableStackTrace);
1112
+ result = validated;
1113
+ });
1114
+ return result;
1115
+ }
1116
+ isValid(value, options) {
1117
+ return this.validate(value, options).then(() => true, err => {
1118
+ if (ValidationError.isError(err)) return false;
1119
+ throw err;
1120
+ });
1121
+ }
1122
+ isValidSync(value, options) {
1123
+ try {
1124
+ this.validateSync(value, options);
1125
+ return true;
1126
+ } catch (err) {
1127
+ if (ValidationError.isError(err)) return false;
1128
+ throw err;
1129
+ }
1130
+ }
1131
+ _getDefault(options) {
1132
+ let defaultValue = this.spec.default;
1133
+ if (defaultValue == null) {
1134
+ return defaultValue;
1135
+ }
1136
+ return typeof defaultValue === 'function' ? defaultValue.call(this, options) : clone(defaultValue);
1137
+ }
1138
+ getDefault(options
1139
+ // If schema is defaulted we know it's at least not undefined
1140
+ ) {
1141
+ let schema = this.resolve(options || {});
1142
+ return schema._getDefault(options);
1143
+ }
1144
+ default(def) {
1145
+ if (arguments.length === 0) {
1146
+ return this._getDefault();
1147
+ }
1148
+ let next = this.clone({
1149
+ default: def
1150
+ });
1151
+ return next;
1152
+ }
1153
+ strict(isStrict = true) {
1154
+ return this.clone({
1155
+ strict: isStrict
1156
+ });
1157
+ }
1158
+ nullability(nullable, message) {
1159
+ const next = this.clone({
1160
+ nullable
1161
+ });
1162
+ next.internalTests.nullable = createValidation({
1163
+ message,
1164
+ name: 'nullable',
1165
+ test(value) {
1166
+ return value === null ? this.schema.spec.nullable : true;
1167
+ }
1168
+ });
1169
+ return next;
1170
+ }
1171
+ optionality(optional, message) {
1172
+ const next = this.clone({
1173
+ optional
1174
+ });
1175
+ next.internalTests.optionality = createValidation({
1176
+ message,
1177
+ name: 'optionality',
1178
+ test(value) {
1179
+ return value === undefined ? this.schema.spec.optional : true;
1180
+ }
1181
+ });
1182
+ return next;
1183
+ }
1184
+ optional() {
1185
+ return this.optionality(true);
1186
+ }
1187
+ defined(message = mixed.defined) {
1188
+ return this.optionality(false, message);
1189
+ }
1190
+ nullable() {
1191
+ return this.nullability(true);
1192
+ }
1193
+ nonNullable(message = mixed.notNull) {
1194
+ return this.nullability(false, message);
1195
+ }
1196
+ required(message = mixed.required) {
1197
+ return this.clone().withMutation(next => next.nonNullable(message).defined(message));
1198
+ }
1199
+ notRequired() {
1200
+ return this.clone().withMutation(next => next.nullable().optional());
1201
+ }
1202
+ transform(fn) {
1203
+ let next = this.clone();
1204
+ next.transforms.push(fn);
1205
+ return next;
1206
+ }
1207
+
1208
+ /**
1209
+ * Adds a test function to the schema's queue of tests.
1210
+ * tests can be exclusive or non-exclusive.
1211
+ *
1212
+ * - exclusive tests, will replace any existing tests of the same name.
1213
+ * - non-exclusive: can be stacked
1214
+ *
1215
+ * If a non-exclusive test is added to a schema with an exclusive test of the same name
1216
+ * the exclusive test is removed and further tests of the same name will be stacked.
1217
+ *
1218
+ * If an exclusive test is added to a schema with non-exclusive tests of the same name
1219
+ * the previous tests are removed and further tests of the same name will replace each other.
1220
+ */
1221
+
1222
+ test(...args) {
1223
+ let opts;
1224
+ if (args.length === 1) {
1225
+ if (typeof args[0] === 'function') {
1226
+ opts = {
1227
+ test: args[0]
1228
+ };
1229
+ } else {
1230
+ opts = args[0];
1231
+ }
1232
+ } else if (args.length === 2) {
1233
+ opts = {
1234
+ name: args[0],
1235
+ test: args[1]
1236
+ };
1237
+ } else {
1238
+ opts = {
1239
+ name: args[0],
1240
+ message: args[1],
1241
+ test: args[2]
1242
+ };
1243
+ }
1244
+ if (opts.message === undefined) opts.message = mixed.default;
1245
+ if (typeof opts.test !== 'function') throw new TypeError('`test` is a required parameters');
1246
+ let next = this.clone();
1247
+ let validate = createValidation(opts);
1248
+ let isExclusive = opts.exclusive || opts.name && next.exclusiveTests[opts.name] === true;
1249
+ if (opts.exclusive) {
1250
+ if (!opts.name) throw new TypeError('Exclusive tests must provide a unique `name` identifying the test');
1251
+ }
1252
+ if (opts.name) next.exclusiveTests[opts.name] = !!opts.exclusive;
1253
+ next.tests = next.tests.filter(fn => {
1254
+ if (fn.OPTIONS.name === opts.name) {
1255
+ if (isExclusive) return false;
1256
+ if (fn.OPTIONS.test === validate.OPTIONS.test) return false;
1257
+ }
1258
+ return true;
1259
+ });
1260
+ next.tests.push(validate);
1261
+ return next;
1262
+ }
1263
+ when(keys, options) {
1264
+ if (!Array.isArray(keys) && typeof keys !== 'string') {
1265
+ options = keys;
1266
+ keys = '.';
1267
+ }
1268
+ let next = this.clone();
1269
+ let deps = toArray(keys).map(key => new Reference(key));
1270
+ deps.forEach(dep => {
1271
+ // @ts-ignore readonly array
1272
+ if (dep.isSibling) next.deps.push(dep.key);
1273
+ });
1274
+ next.conditions.push(typeof options === 'function' ? new Condition(deps, options) : Condition.fromOptions(deps, options));
1275
+ return next;
1276
+ }
1277
+ typeError(message) {
1278
+ let next = this.clone();
1279
+ next.internalTests.typeError = createValidation({
1280
+ message,
1281
+ name: 'typeError',
1282
+ skipAbsent: true,
1283
+ test(value) {
1284
+ if (!this.schema._typeCheck(value)) return this.createError({
1285
+ params: {
1286
+ type: this.schema.type
1287
+ }
1288
+ });
1289
+ return true;
1290
+ }
1291
+ });
1292
+ return next;
1293
+ }
1294
+ oneOf(enums, message = mixed.oneOf) {
1295
+ let next = this.clone();
1296
+ enums.forEach(val => {
1297
+ next._whitelist.add(val);
1298
+ next._blacklist.delete(val);
1299
+ });
1300
+ next.internalTests.whiteList = createValidation({
1301
+ message,
1302
+ name: 'oneOf',
1303
+ skipAbsent: true,
1304
+ test(value) {
1305
+ let valids = this.schema._whitelist;
1306
+ let resolved = valids.resolveAll(this.resolve);
1307
+ return resolved.includes(value) ? true : this.createError({
1308
+ params: {
1309
+ values: Array.from(valids).join(', '),
1310
+ resolved
1311
+ }
1312
+ });
1313
+ }
1314
+ });
1315
+ return next;
1316
+ }
1317
+ notOneOf(enums, message = mixed.notOneOf) {
1318
+ let next = this.clone();
1319
+ enums.forEach(val => {
1320
+ next._blacklist.add(val);
1321
+ next._whitelist.delete(val);
1322
+ });
1323
+ next.internalTests.blacklist = createValidation({
1324
+ message,
1325
+ name: 'notOneOf',
1326
+ test(value) {
1327
+ let invalids = this.schema._blacklist;
1328
+ let resolved = invalids.resolveAll(this.resolve);
1329
+ if (resolved.includes(value)) return this.createError({
1330
+ params: {
1331
+ values: Array.from(invalids).join(', '),
1332
+ resolved
1333
+ }
1334
+ });
1335
+ return true;
1336
+ }
1337
+ });
1338
+ return next;
1339
+ }
1340
+ strip(strip = true) {
1341
+ let next = this.clone();
1342
+ next.spec.strip = strip;
1343
+ return next;
1344
+ }
1345
+
1346
+ /**
1347
+ * Return a serialized description of the schema including validations, flags, types etc.
1348
+ *
1349
+ * @param options Provide any needed context for resolving runtime schema alterations (lazy, when conditions, etc).
1350
+ */
1351
+ describe(options) {
1352
+ const next = (options ? this.resolve(options) : this).clone();
1353
+ const {
1354
+ label,
1355
+ meta,
1356
+ optional,
1357
+ nullable
1358
+ } = next.spec;
1359
+ const description = {
1360
+ meta,
1361
+ label,
1362
+ optional,
1363
+ nullable,
1364
+ default: next.getDefault(options),
1365
+ type: next.type,
1366
+ oneOf: next._whitelist.describe(),
1367
+ notOneOf: next._blacklist.describe(),
1368
+ tests: next.tests.map(fn => ({
1369
+ name: fn.OPTIONS.name,
1370
+ params: fn.OPTIONS.params
1371
+ })).filter((n, idx, list) => list.findIndex(c => c.name === n.name) === idx)
1372
+ };
1373
+ return description;
1374
+ }
1375
+ }
1376
+ // @ts-expect-error
1377
+ Schema.prototype.__isYupSchema__ = true;
1378
+ for (const method of ['validate', 'validateSync']) Schema.prototype[`${method}At`] = function (path, value, options = {}) {
1379
+ const {
1380
+ parent,
1381
+ parentPath,
1382
+ schema
1383
+ } = getIn(this, path, value, options.context);
1384
+ return schema[method](parent && parent[parentPath], Object.assign({}, options, {
1385
+ parent,
1386
+ path
1387
+ }));
1388
+ };
1389
+ for (const alias of ['equals', 'is']) Schema.prototype[alias] = Schema.prototype.oneOf;
1390
+ for (const alias of ['not', 'nope']) Schema.prototype[alias] = Schema.prototype.notOneOf;
1391
+
1392
+ /**
1393
+ * This file is a modified version of the file from the following repository:
1394
+ * Date.parse with progressive enhancement for ISO 8601 <https://github.com/csnover/js-iso8601>
1395
+ * NON-CONFORMANT EDITION.
1396
+ * © 2011 Colin Snover <http://zetafleet.com>
1397
+ * Released under MIT license.
1398
+ */
1399
+
1400
+ // prettier-ignore
1401
+ // 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm
1402
+ const isoReg = /^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;
1403
+ function parseIsoDate(date) {
1404
+ const struct = parseDateStruct(date);
1405
+ if (!struct) return Date.parse ? Date.parse(date) : Number.NaN;
1406
+
1407
+ // timestamps without timezone identifiers should be considered local time
1408
+ if (struct.z === undefined && struct.plusMinus === undefined) {
1409
+ return new Date(struct.year, struct.month, struct.day, struct.hour, struct.minute, struct.second, struct.millisecond).valueOf();
1410
+ }
1411
+ let totalMinutesOffset = 0;
1412
+ if (struct.z !== 'Z' && struct.plusMinus !== undefined) {
1413
+ totalMinutesOffset = struct.hourOffset * 60 + struct.minuteOffset;
1414
+ if (struct.plusMinus === '+') totalMinutesOffset = 0 - totalMinutesOffset;
1415
+ }
1416
+ return Date.UTC(struct.year, struct.month, struct.day, struct.hour, struct.minute + totalMinutesOffset, struct.second, struct.millisecond);
1417
+ }
1418
+ function parseDateStruct(date) {
1419
+ var _regexResult$7$length, _regexResult$;
1420
+ const regexResult = isoReg.exec(date);
1421
+ if (!regexResult) return null;
1422
+
1423
+ // use of toNumber() avoids NaN timestamps caused by “undefined”
1424
+ // values being passed to Date constructor
1425
+ return {
1426
+ year: toNumber(regexResult[1]),
1427
+ month: toNumber(regexResult[2], 1) - 1,
1428
+ day: toNumber(regexResult[3], 1),
1429
+ hour: toNumber(regexResult[4]),
1430
+ minute: toNumber(regexResult[5]),
1431
+ second: toNumber(regexResult[6]),
1432
+ millisecond: regexResult[7] ?
1433
+ // allow arbitrary sub-second precision beyond milliseconds
1434
+ toNumber(regexResult[7].substring(0, 3)) : 0,
1435
+ precision: (_regexResult$7$length = (_regexResult$ = regexResult[7]) == null ? void 0 : _regexResult$.length) != null ? _regexResult$7$length : undefined,
1436
+ z: regexResult[8] || undefined,
1437
+ plusMinus: regexResult[9] || undefined,
1438
+ hourOffset: toNumber(regexResult[10]),
1439
+ minuteOffset: toNumber(regexResult[11])
1440
+ };
1441
+ }
1442
+ function toNumber(str, defaultValue = 0) {
1443
+ return Number(str) || defaultValue;
1444
+ }
1445
+
1446
+ // Taken from HTML spec: https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
1447
+ let rEmail =
1448
+ // eslint-disable-next-line
1449
+ /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
1450
+ let rUrl =
1451
+ // eslint-disable-next-line
1452
+ /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i;
1453
+
1454
+ // eslint-disable-next-line
1455
+ let rUUID = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
1456
+ let yearMonthDay = '^\\d{4}-\\d{2}-\\d{2}';
1457
+ let hourMinuteSecond = '\\d{2}:\\d{2}:\\d{2}';
1458
+ let zOrOffset = '(([+-]\\d{2}(:?\\d{2})?)|Z)';
1459
+ let rIsoDateTime = new RegExp(`${yearMonthDay}T${hourMinuteSecond}(\\.\\d+)?${zOrOffset}$`);
1460
+ let isTrimmed = value => isAbsent(value) || value === value.trim();
1461
+ let objStringTag = {}.toString();
1462
+ function create$6() {
1463
+ return new StringSchema();
1464
+ }
1465
+ class StringSchema extends Schema {
1466
+ constructor() {
1467
+ super({
1468
+ type: 'string',
1469
+ check(value) {
1470
+ if (value instanceof String) value = value.valueOf();
1471
+ return typeof value === 'string';
1472
+ }
1473
+ });
1474
+ this.withMutation(() => {
1475
+ this.transform((value, _raw, ctx) => {
1476
+ if (!ctx.spec.coerce || ctx.isType(value)) return value;
1477
+
1478
+ // don't ever convert arrays
1479
+ if (Array.isArray(value)) return value;
1480
+ const strValue = value != null && value.toString ? value.toString() : value;
1481
+
1482
+ // no one wants plain objects converted to [Object object]
1483
+ if (strValue === objStringTag) return value;
1484
+ return strValue;
1485
+ });
1486
+ });
1487
+ }
1488
+ required(message) {
1489
+ return super.required(message).withMutation(schema => schema.test({
1490
+ message: message || mixed.required,
1491
+ name: 'required',
1492
+ skipAbsent: true,
1493
+ test: value => !!value.length
1494
+ }));
1495
+ }
1496
+ notRequired() {
1497
+ return super.notRequired().withMutation(schema => {
1498
+ schema.tests = schema.tests.filter(t => t.OPTIONS.name !== 'required');
1499
+ return schema;
1500
+ });
1501
+ }
1502
+ length(length, message = string.length) {
1503
+ return this.test({
1504
+ message,
1505
+ name: 'length',
1506
+ exclusive: true,
1507
+ params: {
1508
+ length
1509
+ },
1510
+ skipAbsent: true,
1511
+ test(value) {
1512
+ return value.length === this.resolve(length);
1513
+ }
1514
+ });
1515
+ }
1516
+ min(min, message = string.min) {
1517
+ return this.test({
1518
+ message,
1519
+ name: 'min',
1520
+ exclusive: true,
1521
+ params: {
1522
+ min
1523
+ },
1524
+ skipAbsent: true,
1525
+ test(value) {
1526
+ return value.length >= this.resolve(min);
1527
+ }
1528
+ });
1529
+ }
1530
+ max(max, message = string.max) {
1531
+ return this.test({
1532
+ name: 'max',
1533
+ exclusive: true,
1534
+ message,
1535
+ params: {
1536
+ max
1537
+ },
1538
+ skipAbsent: true,
1539
+ test(value) {
1540
+ return value.length <= this.resolve(max);
1541
+ }
1542
+ });
1543
+ }
1544
+ matches(regex, options) {
1545
+ let excludeEmptyString = false;
1546
+ let message;
1547
+ let name;
1548
+ if (options) {
1549
+ if (typeof options === 'object') {
1550
+ ({
1551
+ excludeEmptyString = false,
1552
+ message,
1553
+ name
1554
+ } = options);
1555
+ } else {
1556
+ message = options;
1557
+ }
1558
+ }
1559
+ return this.test({
1560
+ name: name || 'matches',
1561
+ message: message || string.matches,
1562
+ params: {
1563
+ regex
1564
+ },
1565
+ skipAbsent: true,
1566
+ test: value => value === '' && excludeEmptyString || value.search(regex) !== -1
1567
+ });
1568
+ }
1569
+ email(message = string.email) {
1570
+ return this.matches(rEmail, {
1571
+ name: 'email',
1572
+ message,
1573
+ excludeEmptyString: true
1574
+ });
1575
+ }
1576
+ url(message = string.url) {
1577
+ return this.matches(rUrl, {
1578
+ name: 'url',
1579
+ message,
1580
+ excludeEmptyString: true
1581
+ });
1582
+ }
1583
+ uuid(message = string.uuid) {
1584
+ return this.matches(rUUID, {
1585
+ name: 'uuid',
1586
+ message,
1587
+ excludeEmptyString: false
1588
+ });
1589
+ }
1590
+ datetime(options) {
1591
+ let message = '';
1592
+ let allowOffset;
1593
+ let precision;
1594
+ if (options) {
1595
+ if (typeof options === 'object') {
1596
+ ({
1597
+ message = '',
1598
+ allowOffset = false,
1599
+ precision = undefined
1600
+ } = options);
1601
+ } else {
1602
+ message = options;
1603
+ }
1604
+ }
1605
+ return this.matches(rIsoDateTime, {
1606
+ name: 'datetime',
1607
+ message: message || string.datetime,
1608
+ excludeEmptyString: true
1609
+ }).test({
1610
+ name: 'datetime_offset',
1611
+ message: message || string.datetime_offset,
1612
+ params: {
1613
+ allowOffset
1614
+ },
1615
+ skipAbsent: true,
1616
+ test: value => {
1617
+ if (!value || allowOffset) return true;
1618
+ const struct = parseDateStruct(value);
1619
+ if (!struct) return false;
1620
+ return !!struct.z;
1621
+ }
1622
+ }).test({
1623
+ name: 'datetime_precision',
1624
+ message: message || string.datetime_precision,
1625
+ params: {
1626
+ precision
1627
+ },
1628
+ skipAbsent: true,
1629
+ test: value => {
1630
+ if (!value || precision == undefined) return true;
1631
+ const struct = parseDateStruct(value);
1632
+ if (!struct) return false;
1633
+ return struct.precision === precision;
1634
+ }
1635
+ });
1636
+ }
1637
+
1638
+ //-- transforms --
1639
+ ensure() {
1640
+ return this.default('').transform(val => val === null ? '' : val);
1641
+ }
1642
+ trim(message = string.trim) {
1643
+ return this.transform(val => val != null ? val.trim() : val).test({
1644
+ message,
1645
+ name: 'trim',
1646
+ test: isTrimmed
1647
+ });
1648
+ }
1649
+ lowercase(message = string.lowercase) {
1650
+ return this.transform(value => !isAbsent(value) ? value.toLowerCase() : value).test({
1651
+ message,
1652
+ name: 'string_case',
1653
+ exclusive: true,
1654
+ skipAbsent: true,
1655
+ test: value => isAbsent(value) || value === value.toLowerCase()
1656
+ });
1657
+ }
1658
+ uppercase(message = string.uppercase) {
1659
+ return this.transform(value => !isAbsent(value) ? value.toUpperCase() : value).test({
1660
+ message,
1661
+ name: 'string_case',
1662
+ exclusive: true,
1663
+ skipAbsent: true,
1664
+ test: value => isAbsent(value) || value === value.toUpperCase()
1665
+ });
1666
+ }
1667
+ }
1668
+ create$6.prototype = StringSchema.prototype;
1669
+
1670
+ //
1671
+ // Number Interfaces
1672
+ //
1673
+
1674
+ let invalidDate = new Date('');
1675
+ let isDate = obj => Object.prototype.toString.call(obj) === '[object Date]';
1676
+ class DateSchema extends Schema {
1677
+ constructor() {
1678
+ super({
1679
+ type: 'date',
1680
+ check(v) {
1681
+ return isDate(v) && !isNaN(v.getTime());
1682
+ }
1683
+ });
1684
+ this.withMutation(() => {
1685
+ this.transform((value, _raw, ctx) => {
1686
+ // null -> InvalidDate isn't useful; treat all nulls as null and let it fail on
1687
+ // nullability check vs TypeErrors
1688
+ if (!ctx.spec.coerce || ctx.isType(value) || value === null) return value;
1689
+ value = parseIsoDate(value);
1690
+
1691
+ // 0 is a valid timestamp equivalent to 1970-01-01T00:00:00Z(unix epoch) or before.
1692
+ return !isNaN(value) ? new Date(value) : DateSchema.INVALID_DATE;
1693
+ });
1694
+ });
1695
+ }
1696
+ prepareParam(ref, name) {
1697
+ let param;
1698
+ if (!Reference.isRef(ref)) {
1699
+ let cast = this.cast(ref);
1700
+ if (!this._typeCheck(cast)) throw new TypeError(`\`${name}\` must be a Date or a value that can be \`cast()\` to a Date`);
1701
+ param = cast;
1702
+ } else {
1703
+ param = ref;
1704
+ }
1705
+ return param;
1706
+ }
1707
+ min(min, message = date.min) {
1708
+ let limit = this.prepareParam(min, 'min');
1709
+ return this.test({
1710
+ message,
1711
+ name: 'min',
1712
+ exclusive: true,
1713
+ params: {
1714
+ min
1715
+ },
1716
+ skipAbsent: true,
1717
+ test(value) {
1718
+ return value >= this.resolve(limit);
1719
+ }
1720
+ });
1721
+ }
1722
+ max(max, message = date.max) {
1723
+ let limit = this.prepareParam(max, 'max');
1724
+ return this.test({
1725
+ message,
1726
+ name: 'max',
1727
+ exclusive: true,
1728
+ params: {
1729
+ max
1730
+ },
1731
+ skipAbsent: true,
1732
+ test(value) {
1733
+ return value <= this.resolve(limit);
1734
+ }
1735
+ });
1736
+ }
1737
+ }
1738
+ DateSchema.INVALID_DATE = invalidDate;
1739
+
1740
+ // @ts-expect-error
1741
+ function sortFields(fields, excludedEdges = []) {
1742
+ let edges = [];
1743
+ let nodes = new Set();
1744
+ let excludes = new Set(excludedEdges.map(([a, b]) => `${a}-${b}`));
1745
+ function addNode(depPath, key) {
1746
+ let node = propertyExpr.split(depPath)[0];
1747
+ nodes.add(node);
1748
+ if (!excludes.has(`${key}-${node}`)) edges.push([key, node]);
1749
+ }
1750
+ for (const key of Object.keys(fields)) {
1751
+ let value = fields[key];
1752
+ nodes.add(key);
1753
+ if (Reference.isRef(value) && value.isSibling) addNode(value.path, key);else if (isSchema(value) && 'deps' in value) value.deps.forEach(path => addNode(path, key));
1754
+ }
1755
+ return toposort$1.array(Array.from(nodes), edges).reverse();
1756
+ }
1757
+
1758
+ function findIndex(arr, err) {
1759
+ let idx = Infinity;
1760
+ arr.some((key, ii) => {
1761
+ var _err$path;
1762
+ if ((_err$path = err.path) != null && _err$path.includes(key)) {
1763
+ idx = ii;
1764
+ return true;
1765
+ }
1766
+ });
1767
+ return idx;
1768
+ }
1769
+ function sortByKeyOrder(keys) {
1770
+ return (a, b) => {
1771
+ return findIndex(keys, a) - findIndex(keys, b);
1772
+ };
1773
+ }
1774
+
1775
+ const parseJson = (value, _, ctx) => {
1776
+ if (typeof value !== 'string') {
1777
+ return value;
1778
+ }
1779
+ let parsed = value;
1780
+ try {
1781
+ parsed = JSON.parse(value);
1782
+ } catch (err) {
1783
+ /* */
1784
+ }
1785
+ return ctx.isType(parsed) ? parsed : value;
1786
+ };
1787
+
1788
+ // @ts-ignore
1789
+ function deepPartial(schema) {
1790
+ if ('fields' in schema) {
1791
+ const partial = {};
1792
+ for (const [key, fieldSchema] of Object.entries(schema.fields)) {
1793
+ partial[key] = deepPartial(fieldSchema);
1794
+ }
1795
+ return schema.setFields(partial);
1796
+ }
1797
+ if (schema.type === 'array') {
1798
+ const nextArray = schema.optional();
1799
+ if (nextArray.innerType) nextArray.innerType = deepPartial(nextArray.innerType);
1800
+ return nextArray;
1801
+ }
1802
+ if (schema.type === 'tuple') {
1803
+ return schema.optional().clone({
1804
+ types: schema.spec.types.map(deepPartial)
1805
+ });
1806
+ }
1807
+ if ('optional' in schema) {
1808
+ return schema.optional();
1809
+ }
1810
+ return schema;
1811
+ }
1812
+ const deepHas = (obj, p) => {
1813
+ const path = [...propertyExpr.normalizePath(p)];
1814
+ if (path.length === 1) return path[0] in obj;
1815
+ let last = path.pop();
1816
+ let parent = propertyExpr.getter(propertyExpr.join(path), true)(obj);
1817
+ return !!(parent && last in parent);
1818
+ };
1819
+ let isObject = obj => Object.prototype.toString.call(obj) === '[object Object]';
1820
+ function unknown(ctx, value) {
1821
+ let known = Object.keys(ctx.fields);
1822
+ return Object.keys(value).filter(key => known.indexOf(key) === -1);
1823
+ }
1824
+ const defaultSort = sortByKeyOrder([]);
1825
+ function create$3(spec) {
1826
+ return new ObjectSchema(spec);
1827
+ }
1828
+ class ObjectSchema extends Schema {
1829
+ constructor(spec) {
1830
+ super({
1831
+ type: 'object',
1832
+ check(value) {
1833
+ return isObject(value) || typeof value === 'function';
1834
+ }
1835
+ });
1836
+ this.fields = Object.create(null);
1837
+ this._sortErrors = defaultSort;
1838
+ this._nodes = [];
1839
+ this._excludedEdges = [];
1840
+ this.withMutation(() => {
1841
+ if (spec) {
1842
+ this.shape(spec);
1843
+ }
1844
+ });
1845
+ }
1846
+ _cast(_value, options = {}) {
1847
+ var _options$stripUnknown;
1848
+ let value = super._cast(_value, options);
1849
+
1850
+ //should ignore nulls here
1851
+ if (value === undefined) return this.getDefault(options);
1852
+ if (!this._typeCheck(value)) return value;
1853
+ let fields = this.fields;
1854
+ let strip = (_options$stripUnknown = options.stripUnknown) != null ? _options$stripUnknown : this.spec.noUnknown;
1855
+ let props = [].concat(this._nodes, Object.keys(value).filter(v => !this._nodes.includes(v)));
1856
+ let intermediateValue = {}; // is filled during the transform below
1857
+ let innerOptions = Object.assign({}, options, {
1858
+ parent: intermediateValue,
1859
+ __validating: options.__validating || false
1860
+ });
1861
+ let isChanged = false;
1862
+ for (const prop of props) {
1863
+ let field = fields[prop];
1864
+ let exists = (prop in value);
1865
+ if (field) {
1866
+ let fieldValue;
1867
+ let inputValue = value[prop];
1868
+
1869
+ // safe to mutate since this is fired in sequence
1870
+ innerOptions.path = (options.path ? `${options.path}.` : '') + prop;
1871
+ field = field.resolve({
1872
+ value: inputValue,
1873
+ context: options.context,
1874
+ parent: intermediateValue
1875
+ });
1876
+ let fieldSpec = field instanceof Schema ? field.spec : undefined;
1877
+ let strict = fieldSpec == null ? void 0 : fieldSpec.strict;
1878
+ if (fieldSpec != null && fieldSpec.strip) {
1879
+ isChanged = isChanged || prop in value;
1880
+ continue;
1881
+ }
1882
+ fieldValue = !options.__validating || !strict ?
1883
+ // TODO: use _cast, this is double resolving
1884
+ field.cast(value[prop], innerOptions) : value[prop];
1885
+ if (fieldValue !== undefined) {
1886
+ intermediateValue[prop] = fieldValue;
1887
+ }
1888
+ } else if (exists && !strip) {
1889
+ intermediateValue[prop] = value[prop];
1890
+ }
1891
+ if (exists !== prop in intermediateValue || intermediateValue[prop] !== value[prop]) {
1892
+ isChanged = true;
1893
+ }
1894
+ }
1895
+ return isChanged ? intermediateValue : value;
1896
+ }
1897
+ _validate(_value, options = {}, panic, next) {
1898
+ let {
1899
+ from = [],
1900
+ originalValue = _value,
1901
+ recursive = this.spec.recursive
1902
+ } = options;
1903
+ options.from = [{
1904
+ schema: this,
1905
+ value: originalValue
1906
+ }, ...from];
1907
+ // this flag is needed for handling `strict` correctly in the context of
1908
+ // validation vs just casting. e.g strict() on a field is only used when validating
1909
+ options.__validating = true;
1910
+ options.originalValue = originalValue;
1911
+ super._validate(_value, options, panic, (objectErrors, value) => {
1912
+ if (!recursive || !isObject(value)) {
1913
+ next(objectErrors, value);
1914
+ return;
1915
+ }
1916
+ originalValue = originalValue || value;
1917
+ let tests = [];
1918
+ for (let key of this._nodes) {
1919
+ let field = this.fields[key];
1920
+ if (!field || Reference.isRef(field)) {
1921
+ continue;
1922
+ }
1923
+ tests.push(field.asNestedTest({
1924
+ options,
1925
+ key,
1926
+ parent: value,
1927
+ parentPath: options.path,
1928
+ originalParent: originalValue
1929
+ }));
1930
+ }
1931
+ this.runTests({
1932
+ tests,
1933
+ value,
1934
+ originalValue,
1935
+ options
1936
+ }, panic, fieldErrors => {
1937
+ next(fieldErrors.sort(this._sortErrors).concat(objectErrors), value);
1938
+ });
1939
+ });
1940
+ }
1941
+ clone(spec) {
1942
+ const next = super.clone(spec);
1943
+ next.fields = Object.assign({}, this.fields);
1944
+ next._nodes = this._nodes;
1945
+ next._excludedEdges = this._excludedEdges;
1946
+ next._sortErrors = this._sortErrors;
1947
+ return next;
1948
+ }
1949
+ concat(schema) {
1950
+ let next = super.concat(schema);
1951
+ let nextFields = next.fields;
1952
+ for (let [field, schemaOrRef] of Object.entries(this.fields)) {
1953
+ const target = nextFields[field];
1954
+ nextFields[field] = target === undefined ? schemaOrRef : target;
1955
+ }
1956
+ return next.withMutation(s =>
1957
+ // XXX: excludes here is wrong
1958
+ s.setFields(nextFields, [...this._excludedEdges, ...schema._excludedEdges]));
1959
+ }
1960
+ _getDefault(options) {
1961
+ if ('default' in this.spec) {
1962
+ return super._getDefault(options);
1963
+ }
1964
+
1965
+ // if there is no default set invent one
1966
+ if (!this._nodes.length) {
1967
+ return undefined;
1968
+ }
1969
+ let dft = {};
1970
+ this._nodes.forEach(key => {
1971
+ var _innerOptions;
1972
+ const field = this.fields[key];
1973
+ let innerOptions = options;
1974
+ if ((_innerOptions = innerOptions) != null && _innerOptions.value) {
1975
+ innerOptions = Object.assign({}, innerOptions, {
1976
+ parent: innerOptions.value,
1977
+ value: innerOptions.value[key]
1978
+ });
1979
+ }
1980
+ dft[key] = field && 'getDefault' in field ? field.getDefault(innerOptions) : undefined;
1981
+ });
1982
+ return dft;
1983
+ }
1984
+ setFields(shape, excludedEdges) {
1985
+ let next = this.clone();
1986
+ next.fields = shape;
1987
+ next._nodes = sortFields(shape, excludedEdges);
1988
+ next._sortErrors = sortByKeyOrder(Object.keys(shape));
1989
+ // XXX: this carries over edges which may not be what you want
1990
+ if (excludedEdges) next._excludedEdges = excludedEdges;
1991
+ return next;
1992
+ }
1993
+ shape(additions, excludes = []) {
1994
+ return this.clone().withMutation(next => {
1995
+ let edges = next._excludedEdges;
1996
+ if (excludes.length) {
1997
+ if (!Array.isArray(excludes[0])) excludes = [excludes];
1998
+ edges = [...next._excludedEdges, ...excludes];
1999
+ }
2000
+
2001
+ // XXX: excludes here is wrong
2002
+ return next.setFields(Object.assign(next.fields, additions), edges);
2003
+ });
2004
+ }
2005
+ partial() {
2006
+ const partial = {};
2007
+ for (const [key, schema] of Object.entries(this.fields)) {
2008
+ partial[key] = 'optional' in schema && schema.optional instanceof Function ? schema.optional() : schema;
2009
+ }
2010
+ return this.setFields(partial);
2011
+ }
2012
+ deepPartial() {
2013
+ const next = deepPartial(this);
2014
+ return next;
2015
+ }
2016
+ pick(keys) {
2017
+ const picked = {};
2018
+ for (const key of keys) {
2019
+ if (this.fields[key]) picked[key] = this.fields[key];
2020
+ }
2021
+ return this.setFields(picked, this._excludedEdges.filter(([a, b]) => keys.includes(a) && keys.includes(b)));
2022
+ }
2023
+ omit(keys) {
2024
+ const remaining = [];
2025
+ for (const key of Object.keys(this.fields)) {
2026
+ if (keys.includes(key)) continue;
2027
+ remaining.push(key);
2028
+ }
2029
+ return this.pick(remaining);
2030
+ }
2031
+ from(from, to, alias) {
2032
+ let fromGetter = propertyExpr.getter(from, true);
2033
+ return this.transform(obj => {
2034
+ if (!obj) return obj;
2035
+ let newObj = obj;
2036
+ if (deepHas(obj, from)) {
2037
+ newObj = Object.assign({}, obj);
2038
+ if (!alias) delete newObj[from];
2039
+ newObj[to] = fromGetter(obj);
2040
+ }
2041
+ return newObj;
2042
+ });
2043
+ }
2044
+
2045
+ /** Parse an input JSON string to an object */
2046
+ json() {
2047
+ return this.transform(parseJson);
2048
+ }
2049
+
2050
+ /**
2051
+ * Similar to `noUnknown` but only validates that an object is the right shape without stripping the unknown keys
2052
+ */
2053
+ exact(message) {
2054
+ return this.test({
2055
+ name: 'exact',
2056
+ exclusive: true,
2057
+ message: message || object.exact,
2058
+ test(value) {
2059
+ if (value == null) return true;
2060
+ const unknownKeys = unknown(this.schema, value);
2061
+ return unknownKeys.length === 0 || this.createError({
2062
+ params: {
2063
+ properties: unknownKeys.join(', ')
2064
+ }
2065
+ });
2066
+ }
2067
+ });
2068
+ }
2069
+ stripUnknown() {
2070
+ return this.clone({
2071
+ noUnknown: true
2072
+ });
2073
+ }
2074
+ noUnknown(noAllow = true, message = object.noUnknown) {
2075
+ if (typeof noAllow !== 'boolean') {
2076
+ message = noAllow;
2077
+ noAllow = true;
2078
+ }
2079
+ let next = this.test({
2080
+ name: 'noUnknown',
2081
+ exclusive: true,
2082
+ message: message,
2083
+ test(value) {
2084
+ if (value == null) return true;
2085
+ const unknownKeys = unknown(this.schema, value);
2086
+ return !noAllow || unknownKeys.length === 0 || this.createError({
2087
+ params: {
2088
+ unknown: unknownKeys.join(', ')
2089
+ }
2090
+ });
2091
+ }
2092
+ });
2093
+ next.spec.noUnknown = noAllow;
2094
+ return next;
2095
+ }
2096
+ unknown(allow = true, message = object.noUnknown) {
2097
+ return this.noUnknown(!allow, message);
2098
+ }
2099
+ transformKeys(fn) {
2100
+ return this.transform(obj => {
2101
+ if (!obj) return obj;
2102
+ const result = {};
2103
+ for (const key of Object.keys(obj)) result[fn(key)] = obj[key];
2104
+ return result;
2105
+ });
2106
+ }
2107
+ camelCase() {
2108
+ return this.transformKeys(tinyCase.camelCase);
2109
+ }
2110
+ snakeCase() {
2111
+ return this.transformKeys(tinyCase.snakeCase);
2112
+ }
2113
+ constantCase() {
2114
+ return this.transformKeys(key => tinyCase.snakeCase(key).toUpperCase());
2115
+ }
2116
+ describe(options) {
2117
+ const next = (options ? this.resolve(options) : this).clone();
2118
+ const base = super.describe(options);
2119
+ base.fields = {};
2120
+ for (const [key, value] of Object.entries(next.fields)) {
2121
+ var _innerOptions2;
2122
+ let innerOptions = options;
2123
+ if ((_innerOptions2 = innerOptions) != null && _innerOptions2.value) {
2124
+ innerOptions = Object.assign({}, innerOptions, {
2125
+ parent: innerOptions.value,
2126
+ value: innerOptions.value[key]
2127
+ });
2128
+ }
2129
+ base.fields[key] = value.describe(innerOptions);
2130
+ }
2131
+ return base;
2132
+ }
2133
+ }
2134
+ create$3.prototype = ObjectSchema.prototype;
2135
+
2136
+ const version = "0.0.67";
2137
+
2138
+ const contactUsSchema = create$3({
2139
+ fullName: create$6().required(),
2140
+ fullNameMinimum: create$6().required(),
2141
+ fullNameIsRequired: create$6().required(),
2142
+ emailAddress: create$6().required(),
2143
+ emailAddressNotValid: create$6().required(),
2144
+ city: create$6().required(),
2145
+ selectCity: create$6().required(),
2146
+ cityIsRequired: create$6().required(),
2147
+ phoneNumber: create$6().required(),
2148
+ phoneNumberIsRequired: create$6().required(),
2149
+ phoneNumberFormatInvalid: create$6().required(),
2150
+ inquiryType: create$6().required(),
2151
+ selectInquiryType: create$6().required(),
2152
+ inquiryTypeIsRequired: create$6().required(),
2153
+ writeAMessage: create$6().required(),
2154
+ leaveUsMessage: create$6().required(),
2155
+ messageIsRequired: create$6().required(),
2156
+ });
2157
+
2158
+ const FormsSchema = create$3({
2159
+ contactUs: contactUsSchema,
2160
+ reCaptchaIsRequired: create$6().required(),
2161
+ inputValueIsIncorrect: create$6().required(),
2162
+ });
2163
+
2164
+ const generalSchema = create$3({
2165
+ close: create$6().required(),
2166
+ submit: create$6().required(),
2167
+ noSelectOptions: create$6().required(),
2168
+ formSubmittedSuccessfully: create$6().required(),
2169
+ });
2170
+
2171
+ const errorsSchema = create$3({
2172
+ wildCard: create$6().required(),
2173
+ noBaseUrl: create$6().required(),
2174
+ invalidVin: create$6().required(),
2175
+ noPartsFound: create$6().required(),
2176
+ vinNumberRequired: create$6().required(),
2177
+ wrongFormStructure: create$6().required(),
2178
+ partNumberRequired: create$6().required(),
2179
+ noServiceAvailable: create$6().required(),
2180
+ wrongResponseFormat: create$6().required(),
2181
+ requestFailedPleaseTryAgainLater: create$6().required(),
2182
+ });
2183
+
2184
+ const deadStockSchema = create$3({
2185
+ deadStock: create$6().required(),
2186
+ branch: create$6().required(),
2187
+ availableQuantity: create$6().required(),
2188
+ });
2189
+
2190
+ const distributorSchema = create$3({
2191
+ info: create$6().required(),
2192
+ distributorStock: create$6().required(),
2193
+ availability: create$6().required(),
2194
+ notAvailable: create$6().required(),
2195
+ partiallyAvailable: create$6().required(),
2196
+ available: create$6().required(),
2197
+ location: create$6().required(),
2198
+ description: create$6().required(),
2199
+ productGroup: create$6().required(),
2200
+ localDescription: create$6().required(),
2201
+ dealerPurchasePrice: create$6().required(),
2202
+ recommendedRetailPrice: create$6().required(),
2203
+ supersededFrom: create$6().required(),
2204
+ supersessions: create$6().required(),
2205
+ });
2206
+
2207
+ const manufacturerSchema = create$3({
2208
+ origin: create$6().required(),
2209
+ warrantyPrice: create$6().required(),
2210
+ specialPrice: create$6().required(),
2211
+ wholesalesPrice: create$6().required(),
2212
+ pnc: create$6().required(),
2213
+ pncName: create$6().required(),
2214
+ binCode: create$6().required(),
2215
+ dimension1: create$6().required(),
2216
+ dimension2: create$6().required(),
2217
+ dimension3: create$6().required(),
2218
+ netWeight: create$6().required(),
2219
+ grossWeight: create$6().required(),
2220
+ cubicMeasure: create$6().required(),
2221
+ hsCode: create$6().required(),
2222
+ uzHsCode: create$6().required(),
2223
+ });
2224
+
2225
+ const partLookupSchema = create$3({
2226
+ deadStock: deadStockSchema,
2227
+ distributor: distributorSchema,
2228
+ manufacturer: manufacturerSchema,
2229
+ });
2230
+
2231
+ const warrantySchema = create$3({
2232
+ authorized: create$6().required(),
2233
+ unauthorized: create$6().required(),
2234
+ activeWarranty: create$6().required(),
2235
+ notActiveWarranty: create$6().required(),
2236
+ notInvoiced: create$6().required(),
2237
+ from: create$6().required(),
2238
+ to: create$6().required(),
2239
+ pendingSSC: create$6().required(),
2240
+ noPendingSSC: create$6().required(),
2241
+ checkingTMC: create$6().required(),
2242
+ sscCampings: create$6().required(),
2243
+ sscTableCode: create$6().required(),
2244
+ sscTableDescription: create$6().required(),
2245
+ sscTableRepairStatus: create$6().required(),
2246
+ sscTableOPCode: create$6().required(),
2247
+ sscTablePartNumber: create$6().required(),
2248
+ });
2249
+
2250
+ const accessoriesSchema = create$3({
2251
+ vehicleAccessories: create$6().required(),
2252
+ noData: create$6().required(),
2253
+ partNumber: create$6().required(),
2254
+ description: create$6().required(),
2255
+ image: create$6().required(),
2256
+ expand: create$6().required(),
2257
+ });
2258
+
2259
+ const dynamicClaimSchema = create$3({
2260
+ serviceType: create$6().required(),
2261
+ activationDate: create$6().required(),
2262
+ expireDate: create$6().required(),
2263
+ claimAt: create$6().required(),
2264
+ redeemingDealer: create$6().required(),
2265
+ invoiceNumber: create$6().required(),
2266
+ jobNumber: create$6().required(),
2267
+ packageCode: create$6().required(),
2268
+ claim: create$6().required(),
2269
+ processed: create$6().required(),
2270
+ expired: create$6().required(),
2271
+ cancelled: create$6().required(),
2272
+ pending: create$6().required(),
2273
+ warning: create$6().required(),
2274
+ });
2275
+
2276
+ const specificationSchema = create$3({
2277
+ vehicleSpecification: create$6().required(),
2278
+ noData: create$6().required(),
2279
+ model: create$6().required(),
2280
+ variant: create$6().required(),
2281
+ katashiki: create$6().required(),
2282
+ modelYear: create$6().required(),
2283
+ sfx: create$6().required(),
2284
+ productionDate: create$6().required(),
2285
+ });
2286
+
2287
+ const dynamicRedeemSchema = create$3({
2288
+ serviceType: create$6().required(),
2289
+ name: create$6().required(),
2290
+ activationDate: create$6().required(),
2291
+ expireDate: create$6().required(),
2292
+ packageCode: create$6().required(),
2293
+ scanTheInvoice: create$6().required(),
2294
+ processing: create$6().required(),
2295
+ warning: create$6().required(),
2296
+ skipServicesWarning: create$6().required(),
2297
+ confirmSkipServices: create$6().required(),
2298
+ notInvoiced: create$6().required(),
2299
+ confirmNotInvoiced: create$6().required(),
2300
+ });
2301
+
2302
+ const ServiceHistorySchema = create$3({
2303
+ serviceHistory: create$6().required(),
2304
+ noData: create$6().required(),
2305
+ branch: create$6().required(),
2306
+ dealer: create$6().required(),
2307
+ invoiceNumber: create$6().required(),
2308
+ date: create$6().required(),
2309
+ serviceType: create$6().required(),
2310
+ odometer: create$6().required(),
2311
+ });
2312
+
2313
+ const paintThicknessSchema = create$3({
2314
+ paintThickness: create$6().required(),
2315
+ noData: create$6().required(),
2316
+ part: create$6().required(),
2317
+ left: create$6().required(),
2318
+ right: create$6().required(),
2319
+ noImageGroups: create$6().required(),
2320
+ expand: create$6().required(),
2321
+ });
2322
+
2323
+ const vehicleLookupSchema = create$3({
2324
+ warranty: warrantySchema,
2325
+ accessories: accessoriesSchema,
2326
+ dynamicClaim: dynamicClaimSchema,
2327
+ dynamicRedeem: dynamicRedeemSchema,
2328
+ specification: specificationSchema,
2329
+ serviceHistory: ServiceHistorySchema,
2330
+ paintThickness: paintThicknessSchema,
2331
+ });
2332
+
2333
+ const generalTicketTypesSchema = create$3({
2334
+ TLP: create$6().required(),
2335
+ Complaint: create$6().required(),
2336
+ PartInquiry: create$6().required(),
2337
+ SalesCampaign: create$6().required(),
2338
+ GeneralInquiry: create$6().required(),
2339
+ ServiceCampaign: create$6().required(),
2340
+ InstallmentPayment: create$6().required(),
2341
+ ServicePriceInquiry: create$6().required(),
2342
+ });
2343
+
2344
+ const ARABIC_JSON_FILE = 'ar.json';
2345
+ const ENGLISH_JSON_FILE = 'en.json';
2346
+ const KURDISH_JSON_FILE = 'ku.json';
2347
+ const RUSSIAN_JSON_FILE = 'ru.json';
2348
+ const languageMapper = {
2349
+ ar: ARABIC_JSON_FILE,
2350
+ en: ENGLISH_JSON_FILE,
2351
+ ku: KURDISH_JSON_FILE,
2352
+ ru: RUSSIAN_JSON_FILE,
2353
+ };
2354
+ const localeSchema = create$3({
2355
+ forms: FormsSchema,
2356
+ errors: errorsSchema,
2357
+ general: generalSchema,
2358
+ lang: create$6().required(),
2359
+ noData: create$6().required(),
2360
+ partLookup: partLookupSchema,
2361
+ language: create$6().required(),
2362
+ direction: create$6().required(),
2363
+ vehicleLookup: vehicleLookupSchema,
2364
+ generalTicketTypes: generalTicketTypesSchema,
2365
+ });
2366
+
2367
+ const cachedLocales = {};
2368
+ const getLocaleLanguage = async (fileKey) => {
2369
+ const languageFile = languageMapper[fileKey] || languageMapper.en;
2370
+ if (cachedLocales[languageFile])
2371
+ return await cachedLocales[languageFile];
2372
+ let localeResponse;
2373
+ localeResponse = fetch(`https://cdn.jsdelivr.net/npm/adp-web-components@${version}/dist/locales/${languageFile}`).then(res => res.json());
2374
+ cachedLocales[languageFile] = localeResponse;
2375
+ return await localeResponse;
2376
+ };
2377
+
2378
+ exports.create$3 = create$3;
2379
+ exports.create$6 = create$6;
2380
+ exports.getLocaleLanguage = getLocaleLanguage;
2381
+ exports.localeSchema = localeSchema;