@justifi/webcomponents 4.4.0 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (462) hide show
  1. package/dist/cjs/{Api-7303478d.js → Api-d2df6e84.js} +16 -4
  2. package/dist/cjs/Api-d2df6e84.js.map +1 -0
  3. package/dist/cjs/Payout-4906a445.js +116 -0
  4. package/dist/cjs/Payout-4906a445.js.map +1 -0
  5. package/dist/cjs/{business-form-schema-63b311b2.js → business-form-schema-725ec6f5.js} +40 -22
  6. package/dist/cjs/business-form-schema-725ec6f5.js.map +1 -0
  7. package/dist/cjs/form-control-datepart_2.cjs.entry.js +107 -0
  8. package/dist/cjs/form-control-datepart_2.cjs.entry.js.map +1 -0
  9. package/dist/cjs/form-control-monetary.cjs.entry.js +65 -0
  10. package/dist/cjs/form-control-monetary.cjs.entry.js.map +1 -0
  11. package/dist/cjs/{form-control-select_2.cjs.entry.js → form-control-number_3.cjs.entry.js} +99 -12
  12. package/dist/cjs/form-control-number_3.cjs.entry.js.map +1 -0
  13. package/dist/cjs/form-control-select.cjs.entry.js +47 -0
  14. package/dist/cjs/form-control-select.cjs.entry.js.map +1 -0
  15. package/dist/cjs/{index-83b2ec02.js → index-4ffc90c0.js} +10 -1
  16. package/dist/cjs/index-4ffc90c0.js.map +1 -0
  17. package/dist/cjs/index-5a880722.js +3233 -0
  18. package/dist/cjs/index-5a880722.js.map +1 -0
  19. package/dist/cjs/{index.esm-7e12ce07.js → index.esm-84a0a7a8.js} +1 -19
  20. package/dist/cjs/index.esm-84a0a7a8.js.map +1 -0
  21. package/dist/cjs/justifi-additional-questions_5.cjs.entry.js +396 -0
  22. package/dist/cjs/justifi-additional-questions_5.cjs.entry.js.map +1 -0
  23. package/dist/cjs/justifi-bank-account-form.cjs.entry.js +1 -1
  24. package/dist/cjs/justifi-billing-form_2.cjs.entry.js +2 -2
  25. package/dist/cjs/justifi-business-form.cjs.entry.js +98 -16
  26. package/dist/cjs/justifi-business-form.cjs.entry.js.map +1 -1
  27. package/dist/cjs/justifi-business-list.cjs.entry.js +189 -0
  28. package/dist/cjs/justifi-business-list.cjs.entry.js.map +1 -0
  29. package/dist/cjs/justifi-card-form.cjs.entry.js +1 -1
  30. package/dist/cjs/justifi-details.cjs.entry.js +30 -0
  31. package/dist/cjs/justifi-details.cjs.entry.js.map +1 -0
  32. package/dist/cjs/justifi-payment-details.cjs.entry.js +63 -0
  33. package/dist/cjs/justifi-payment-details.cjs.entry.js.map +1 -0
  34. package/dist/cjs/justifi-payment-form.cjs.entry.js +6 -5
  35. package/dist/cjs/justifi-payment-form.cjs.entry.js.map +1 -1
  36. package/dist/cjs/justifi-payment-method-form.cjs.entry.js +7 -5
  37. package/dist/cjs/justifi-payment-method-form.cjs.entry.js.map +1 -1
  38. package/dist/cjs/justifi-payments-list.cjs.entry.js +49 -47
  39. package/dist/cjs/justifi-payments-list.cjs.entry.js.map +1 -1
  40. package/dist/cjs/justifi-payout-details.cjs.entry.js +61 -0
  41. package/dist/cjs/justifi-payout-details.cjs.entry.js.map +1 -0
  42. package/dist/cjs/justifi-payouts-list.cjs.entry.js +64 -54
  43. package/dist/cjs/justifi-payouts-list.cjs.entry.js.map +1 -1
  44. package/dist/cjs/justifi-proceeds-list.cjs.entry.js +156 -0
  45. package/dist/cjs/justifi-proceeds-list.cjs.entry.js.map +1 -0
  46. package/dist/cjs/justifi-table.cjs.entry.js +68 -0
  47. package/dist/cjs/justifi-table.cjs.entry.js.map +1 -0
  48. package/dist/cjs/loader.cjs.js +2 -2
  49. package/dist/cjs/select-input_2.cjs.entry.js +1 -1
  50. package/dist/cjs/table-utils-617126e5.js +13 -0
  51. package/dist/cjs/table-utils-617126e5.js.map +1 -0
  52. package/dist/cjs/{utils-4ee7e080.js → utils-0fd61dbd.js} +43 -104
  53. package/dist/cjs/utils-0fd61dbd.js.map +1 -0
  54. package/dist/cjs/utils-a5b5bfdf.js +35 -0
  55. package/dist/cjs/utils-a5b5bfdf.js.map +1 -0
  56. package/dist/cjs/webcomponents.cjs.js +3 -3
  57. package/dist/cjs/webcomponents.cjs.js.map +1 -1
  58. package/dist/collection/api/Api.js +15 -3
  59. package/dist/collection/api/Api.js.map +1 -1
  60. package/dist/collection/api/Business.js +50 -0
  61. package/dist/collection/api/Business.js.map +1 -0
  62. package/dist/collection/api/Payment.js.map +1 -1
  63. package/dist/collection/api/Payout.js +9 -0
  64. package/dist/collection/api/Payout.js.map +1 -1
  65. package/dist/collection/api/Proceed.js +42 -0
  66. package/dist/collection/api/Proceed.js.map +1 -0
  67. package/dist/collection/api/shared.js +2 -0
  68. package/dist/collection/api/shared.js.map +1 -0
  69. package/dist/collection/collection-manifest.json +13 -1
  70. package/dist/collection/components/business-form/additional-questions/additional-questions.js +59 -0
  71. package/dist/collection/components/business-form/additional-questions/additional-questions.js.map +1 -0
  72. package/dist/collection/components/business-form/business-address/business-address-form.js +1 -1
  73. package/dist/collection/components/business-form/business-address/business-address-form.js.map +1 -1
  74. package/dist/collection/components/business-form/business-address/test/business-address.spec.js +22 -18
  75. package/dist/collection/components/business-form/business-address/test/business-address.spec.js.map +1 -1
  76. package/dist/collection/components/business-form/business-form-schema.js +48 -37
  77. package/dist/collection/components/business-form/business-form-schema.js.map +1 -1
  78. package/dist/collection/components/business-form/business-form.css +5283 -43
  79. package/dist/collection/components/business-form/business-form.js +83 -6
  80. package/dist/collection/components/business-form/business-form.js.map +1 -1
  81. package/dist/collection/components/business-form/{businessForm.stories.js → business-form.stories.js} +8 -8
  82. package/dist/collection/components/business-form/business-form.stories.js.map +1 -0
  83. package/dist/collection/components/business-form/business-generic-info/business-generic-info.js +10 -17
  84. package/dist/collection/components/business-form/business-generic-info/business-generic-info.js.map +1 -1
  85. package/dist/collection/components/business-form/business-owners/business-owners.css +5283 -0
  86. package/dist/collection/components/business-form/business-owners/business-owners.js +48 -37
  87. package/dist/collection/components/business-form/business-owners/business-owners.js.map +1 -1
  88. package/dist/collection/components/business-form/business-representative/business-representative.js +12 -17
  89. package/dist/collection/components/business-form/business-representative/business-representative.js.map +1 -1
  90. package/dist/collection/components/business-form/test/business-form.spec.js +44 -0
  91. package/dist/collection/components/business-form/test/business-form.spec.js.map +1 -0
  92. package/dist/collection/components/business-list/business-list.css +576 -0
  93. package/dist/collection/components/business-list/business-list.js +209 -0
  94. package/dist/collection/components/business-list/business-list.js.map +1 -0
  95. package/dist/collection/components/business-list/business-list.stories.js +68 -0
  96. package/dist/collection/components/business-list/business-list.stories.js.map +1 -0
  97. package/dist/collection/components/business-list/example.js +12 -0
  98. package/dist/collection/components/details/details.css +7983 -0
  99. package/dist/collection/components/details/details.js +66 -0
  100. package/dist/collection/components/details/details.js.map +1 -0
  101. package/dist/collection/components/details/utils.js +10 -0
  102. package/dist/collection/components/details/utils.js.map +1 -0
  103. package/dist/collection/components/form/form-control-datepart.js +233 -0
  104. package/dist/collection/components/form/form-control-datepart.js.map +1 -0
  105. package/dist/collection/components/form/form-control-monetary.js +186 -0
  106. package/dist/collection/components/form/form-control-monetary.js.map +1 -0
  107. package/dist/collection/components/form/form-control-number-masked.js +217 -0
  108. package/dist/collection/components/form/form-control-number-masked.js.map +1 -0
  109. package/dist/collection/components/form/form-control-number.css +1818 -0
  110. package/dist/collection/components/form/form-control-number.js +194 -0
  111. package/dist/collection/components/form/form-control-number.js.map +1 -0
  112. package/dist/collection/components/form/form-control-select.css +6 -0
  113. package/dist/collection/components/form/form-control-select.js +36 -4
  114. package/dist/collection/components/form/form-control-select.js.map +1 -1
  115. package/dist/collection/components/form/form-control-text.css +7 -0
  116. package/dist/collection/components/form/form-control-text.js +45 -3
  117. package/dist/collection/components/form/form-control-text.js.map +1 -1
  118. package/dist/collection/components/form/form.js +16 -8
  119. package/dist/collection/components/form/form.js.map +1 -1
  120. package/dist/collection/components/legal-address-form/legal-address-form-schema.js +11 -0
  121. package/dist/collection/components/legal-address-form/legal-address-form-schema.js.map +1 -0
  122. package/dist/collection/components/legal-address-form/legal-address-form.css +2489 -0
  123. package/dist/collection/components/legal-address-form/legal-address-form.js +90 -0
  124. package/dist/collection/components/legal-address-form/legal-address-form.js.map +1 -0
  125. package/dist/collection/components/payment-details/example.js +12 -0
  126. package/dist/collection/components/payment-details/payment-details.css +7983 -0
  127. package/dist/collection/components/payment-details/payment-details.js +129 -0
  128. package/dist/collection/components/payment-details/payment-details.js.map +1 -0
  129. package/dist/collection/components/payment-details/payment-details.stories.js +47 -0
  130. package/dist/collection/components/payment-details/payment-details.stories.js.map +1 -0
  131. package/dist/collection/components/payments-list/payments-list.css +0 -7380
  132. package/dist/collection/components/payments-list/payments-list.js +69 -43
  133. package/dist/collection/components/payments-list/payments-list.js.map +1 -1
  134. package/dist/collection/components/payments-list/payments-list.stories.js +10 -10
  135. package/dist/collection/components/payments-list/payments-list.stories.js.map +1 -1
  136. package/dist/collection/components/payments-list/test/payments-list.spec.js +3 -54
  137. package/dist/collection/components/payments-list/test/payments-list.spec.js.map +1 -1
  138. package/dist/collection/components/payout-details/example.js +12 -0
  139. package/dist/collection/components/payout-details/payout-details.css +7983 -0
  140. package/dist/collection/components/payout-details/payout-details.js +126 -0
  141. package/dist/collection/components/payout-details/payout-details.js.map +1 -0
  142. package/dist/collection/components/payout-details/payout-details.stories.js +47 -0
  143. package/dist/collection/components/payout-details/payout-details.stories.js.map +1 -0
  144. package/dist/collection/components/payouts-list/example.js +12 -0
  145. package/dist/collection/components/payouts-list/payouts-list.css +0 -7407
  146. package/dist/collection/components/payouts-list/payouts-list.js +82 -48
  147. package/dist/collection/components/payouts-list/payouts-list.js.map +1 -1
  148. package/dist/collection/components/payouts-list/payouts-list.stories.js +10 -10
  149. package/dist/collection/components/payouts-list/payouts-list.stories.js.map +1 -1
  150. package/dist/collection/components/proceeds-list/example.js +12 -0
  151. package/dist/collection/components/proceeds-list/proceeds-list.css +576 -0
  152. package/dist/collection/components/proceeds-list/proceeds-list.js +207 -0
  153. package/dist/collection/components/proceeds-list/proceeds-list.js.map +1 -0
  154. package/dist/collection/components/proceeds-list/proceeds-list.stories.js +69 -0
  155. package/dist/collection/components/proceeds-list/proceeds-list.stories.js.map +1 -0
  156. package/dist/collection/components/table/table-utils.js +8 -0
  157. package/dist/collection/components/table/table-utils.js.map +1 -0
  158. package/dist/collection/components/table/table.css +8077 -0
  159. package/dist/collection/components/table/table.js +215 -0
  160. package/dist/collection/components/table/table.js.map +1 -0
  161. package/dist/collection/components/table/test/table.spec.js +59 -0
  162. package/dist/collection/components/table/test/table.spec.js.map +1 -0
  163. package/dist/collection/utils/country-options.js +202 -0
  164. package/dist/collection/utils/country-options.js.map +1 -0
  165. package/dist/collection/utils/phone-masks.js +4 -0
  166. package/dist/collection/utils/phone-masks.js.map +1 -0
  167. package/dist/collection/utils/utils.js +40 -0
  168. package/dist/collection/utils/utils.js.map +1 -1
  169. package/dist/components/Api.js +15 -3
  170. package/dist/components/Api.js.map +1 -1
  171. package/dist/components/Payout.js +113 -0
  172. package/dist/components/Payout.js.map +1 -0
  173. package/dist/components/additional-questions.js +51 -0
  174. package/dist/components/additional-questions.js.map +1 -0
  175. package/dist/components/business-address-form.js +8 -2
  176. package/dist/components/business-address-form.js.map +1 -1
  177. package/dist/components/business-generic-info.js +61 -35
  178. package/dist/components/business-generic-info.js.map +1 -1
  179. package/dist/components/business-owners.js +52 -36
  180. package/dist/components/business-owners.js.map +1 -1
  181. package/dist/components/business-representative.js +31 -15
  182. package/dist/components/business-representative.js.map +1 -1
  183. package/dist/components/details.js +66 -0
  184. package/dist/components/details.js.map +1 -0
  185. package/dist/components/form-control-datepart.d.ts +11 -0
  186. package/dist/components/form-control-datepart.js +8 -0
  187. package/dist/components/form-control-datepart.js.map +1 -0
  188. package/dist/components/form-control-datepart2.js +97 -0
  189. package/dist/components/form-control-datepart2.js.map +1 -0
  190. package/dist/components/form-control-monetary.d.ts +11 -0
  191. package/dist/components/form-control-monetary.js +8 -0
  192. package/dist/components/form-control-monetary.js.map +1 -0
  193. package/dist/components/form-control-monetary2.js +82 -0
  194. package/dist/components/form-control-monetary2.js.map +1 -0
  195. package/dist/components/form-control-number-masked.d.ts +11 -0
  196. package/dist/components/form-control-number-masked.js +8 -0
  197. package/dist/components/form-control-number-masked.js.map +1 -0
  198. package/dist/components/form-control-number-masked2.js +81 -0
  199. package/dist/components/form-control-number-masked2.js.map +1 -0
  200. package/dist/components/form-control-number.d.ts +11 -0
  201. package/dist/components/form-control-number.js +8 -0
  202. package/dist/components/form-control-number.js.map +1 -0
  203. package/dist/components/form-control-number2.js +70 -0
  204. package/dist/components/form-control-number2.js.map +1 -0
  205. package/dist/components/form-control-select.js +2 -2
  206. package/dist/components/form-control-select2.js +20 -7
  207. package/dist/components/form-control-select2.js.map +1 -1
  208. package/dist/components/form-control-text2.js +23 -4
  209. package/dist/components/form-control-text2.js.map +1 -1
  210. package/dist/components/index.d.ts +6 -0
  211. package/dist/components/index.esm.js +1 -18
  212. package/dist/components/index.esm.js.map +1 -1
  213. package/dist/components/index.js +1 -1
  214. package/dist/components/index2.js +3231 -0
  215. package/dist/components/index2.js.map +1 -0
  216. package/dist/components/justifi-additional-questions.d.ts +11 -0
  217. package/dist/components/justifi-additional-questions.js +8 -0
  218. package/dist/components/justifi-additional-questions.js.map +1 -0
  219. package/dist/components/justifi-business-form.js +146 -28
  220. package/dist/components/justifi-business-form.js.map +1 -1
  221. package/dist/components/justifi-business-generic-info.js +1 -1
  222. package/dist/components/justifi-business-list.d.ts +11 -0
  223. package/dist/components/justifi-business-list.js +215 -0
  224. package/dist/components/justifi-business-list.js.map +1 -0
  225. package/dist/components/justifi-details.d.ts +11 -0
  226. package/dist/components/justifi-details.js +8 -0
  227. package/dist/components/justifi-details.js.map +1 -0
  228. package/dist/components/justifi-legal-address-form.d.ts +11 -0
  229. package/dist/components/justifi-legal-address-form.js +8 -0
  230. package/dist/components/justifi-legal-address-form.js.map +1 -0
  231. package/dist/components/justifi-payment-details.d.ts +11 -0
  232. package/dist/components/justifi-payment-details.js +88 -0
  233. package/dist/components/justifi-payment-details.js.map +1 -0
  234. package/dist/components/justifi-payment-form.js +2 -1
  235. package/dist/components/justifi-payment-form.js.map +1 -1
  236. package/dist/components/justifi-payments-list.js +52 -45
  237. package/dist/components/justifi-payments-list.js.map +1 -1
  238. package/dist/components/justifi-payout-details.d.ts +11 -0
  239. package/dist/components/justifi-payout-details.js +86 -0
  240. package/dist/components/justifi-payout-details.js.map +1 -0
  241. package/dist/components/justifi-payouts-list.js +65 -50
  242. package/dist/components/justifi-payouts-list.js.map +1 -1
  243. package/dist/components/justifi-proceeds-list.d.ts +11 -0
  244. package/dist/components/justifi-proceeds-list.js +182 -0
  245. package/dist/components/justifi-proceeds-list.js.map +1 -0
  246. package/dist/components/justifi-table.d.ts +11 -0
  247. package/dist/components/justifi-table.js +8 -0
  248. package/dist/components/justifi-table.js.map +1 -0
  249. package/dist/components/legal-address-form.js +271 -0
  250. package/dist/components/legal-address-form.js.map +1 -0
  251. package/dist/components/payment-method-form.js +6 -4
  252. package/dist/components/payment-method-form.js.map +1 -1
  253. package/dist/components/phone-masks.js +7 -0
  254. package/dist/components/phone-masks.js.map +1 -0
  255. package/dist/components/table.js +94 -0
  256. package/dist/components/table.js.map +1 -0
  257. package/dist/components/utils.js +41 -102
  258. package/dist/components/utils.js.map +1 -1
  259. package/dist/esm/{Api-436dfa09.js → Api-a95f17ac.js} +16 -4
  260. package/dist/esm/Api-a95f17ac.js.map +1 -0
  261. package/dist/esm/Payout-9a1f2859.js +113 -0
  262. package/dist/esm/Payout-9a1f2859.js.map +1 -0
  263. package/dist/esm/{business-form-schema-30c48693.js → business-form-schema-5885d3d6.js} +40 -22
  264. package/dist/esm/business-form-schema-5885d3d6.js.map +1 -0
  265. package/dist/esm/form-control-datepart_2.entry.js +102 -0
  266. package/dist/esm/form-control-datepart_2.entry.js.map +1 -0
  267. package/dist/esm/form-control-monetary.entry.js +61 -0
  268. package/dist/esm/form-control-monetary.entry.js.map +1 -0
  269. package/dist/esm/{form-control-select_2.entry.js → form-control-number_3.entry.js} +98 -12
  270. package/dist/esm/form-control-number_3.entry.js.map +1 -0
  271. package/dist/esm/form-control-select.entry.js +43 -0
  272. package/dist/esm/form-control-select.entry.js.map +1 -0
  273. package/dist/esm/index-5ed53c20.js +3231 -0
  274. package/dist/esm/index-5ed53c20.js.map +1 -0
  275. package/dist/esm/{index-c8f391de.js → index-609a2c67.js} +10 -2
  276. package/dist/esm/index-609a2c67.js.map +1 -0
  277. package/dist/esm/{index.esm-be2cd327.js → index.esm-89fe6af9.js} +2 -19
  278. package/dist/esm/index.esm-89fe6af9.js.map +1 -0
  279. package/dist/esm/justifi-additional-questions_5.entry.js +388 -0
  280. package/dist/esm/justifi-additional-questions_5.entry.js.map +1 -0
  281. package/dist/esm/justifi-bank-account-form.entry.js +1 -1
  282. package/dist/esm/justifi-billing-form_2.entry.js +2 -2
  283. package/dist/esm/justifi-business-form.entry.js +98 -16
  284. package/dist/esm/justifi-business-form.entry.js.map +1 -1
  285. package/dist/esm/justifi-business-list.entry.js +185 -0
  286. package/dist/esm/justifi-business-list.entry.js.map +1 -0
  287. package/dist/esm/justifi-card-form.entry.js +1 -1
  288. package/dist/esm/justifi-details.entry.js +26 -0
  289. package/dist/esm/justifi-details.entry.js.map +1 -0
  290. package/dist/esm/justifi-payment-details.entry.js +59 -0
  291. package/dist/esm/justifi-payment-details.entry.js.map +1 -0
  292. package/dist/esm/justifi-payment-form.entry.js +3 -2
  293. package/dist/esm/justifi-payment-form.entry.js.map +1 -1
  294. package/dist/esm/justifi-payment-method-form.entry.js +7 -5
  295. package/dist/esm/justifi-payment-method-form.entry.js.map +1 -1
  296. package/dist/esm/justifi-payments-list.entry.js +47 -45
  297. package/dist/esm/justifi-payments-list.entry.js.map +1 -1
  298. package/dist/esm/justifi-payout-details.entry.js +57 -0
  299. package/dist/esm/justifi-payout-details.entry.js.map +1 -0
  300. package/dist/esm/justifi-payouts-list.entry.js +60 -50
  301. package/dist/esm/justifi-payouts-list.entry.js.map +1 -1
  302. package/dist/esm/justifi-proceeds-list.entry.js +152 -0
  303. package/dist/esm/justifi-proceeds-list.entry.js.map +1 -0
  304. package/dist/esm/justifi-table.entry.js +64 -0
  305. package/dist/esm/justifi-table.entry.js.map +1 -0
  306. package/dist/esm/loader.js +3 -3
  307. package/dist/esm/select-input_2.entry.js +1 -1
  308. package/dist/esm/table-utils-6cdcaa8c.js +11 -0
  309. package/dist/esm/table-utils-6cdcaa8c.js.map +1 -0
  310. package/dist/esm/{utils-e7782126.js → utils-ad0bbe03.js} +42 -103
  311. package/dist/esm/utils-ad0bbe03.js.map +1 -0
  312. package/dist/esm/utils-cdf0b984.js +28 -0
  313. package/dist/esm/utils-cdf0b984.js.map +1 -0
  314. package/dist/esm/webcomponents.js +4 -4
  315. package/dist/esm/webcomponents.js.map +1 -1
  316. package/dist/types/api/Api.d.ts +1 -1
  317. package/dist/types/api/Business.d.ts +133 -0
  318. package/dist/types/api/Payment.d.ts +1 -0
  319. package/dist/types/api/Payout.d.ts +10 -12
  320. package/dist/types/api/Proceed.d.ts +60 -0
  321. package/dist/types/api/shared.d.ts +11 -0
  322. package/dist/types/components/business-form/additional-questions/additional-questions.d.ts +15 -0
  323. package/dist/types/components/business-form/business-form-schema.d.ts +47 -21
  324. package/dist/types/components/business-form/business-form.d.ts +7 -2
  325. package/dist/types/components/business-form/business-generic-info/business-generic-info.d.ts +1 -2
  326. package/dist/types/components/business-form/business-owners/business-owners.d.ts +3 -2
  327. package/dist/types/components/business-form/business-representative/business-representative.d.ts +1 -2
  328. package/dist/types/components/business-list/business-list.d.ts +35 -0
  329. package/dist/types/components/business-list/business-list.stories.d.ts +9 -0
  330. package/dist/types/components/details/details.d.ts +7 -0
  331. package/dist/types/components/details/utils.d.ts +19 -0
  332. package/dist/types/components/form/form-control-datepart.d.ts +19 -0
  333. package/dist/types/components/form/form-control-monetary.d.ts +17 -0
  334. package/dist/types/components/form/form-control-number-masked.d.ts +19 -0
  335. package/dist/types/components/form/form-control-number.d.ts +18 -0
  336. package/dist/types/components/form/form-control-select.d.ts +6 -1
  337. package/dist/types/components/form/form-control-text.d.ts +6 -0
  338. package/dist/types/components/form/form.d.ts +5 -4
  339. package/dist/types/components/legal-address-form/legal-address-form-schema.d.ts +17 -0
  340. package/dist/types/components/legal-address-form/legal-address-form.d.ts +16 -0
  341. package/dist/types/components/payment-details/payment-details.d.ts +28 -0
  342. package/dist/types/components/payment-details/payment-details.stories.d.ts +8 -0
  343. package/dist/types/components/payments-list/payments-list.d.ts +6 -14
  344. package/dist/types/components/payments-list/payments-list.stories.d.ts +1 -8
  345. package/dist/types/components/payout-details/payout-details.d.ts +28 -0
  346. package/dist/types/components/payout-details/payout-details.stories.d.ts +8 -0
  347. package/dist/types/components/payouts-list/payouts-list.d.ts +7 -15
  348. package/dist/types/components/payouts-list/payouts-list.stories.d.ts +1 -8
  349. package/dist/types/components/proceeds-list/proceeds-list.d.ts +37 -0
  350. package/dist/types/components/proceeds-list/proceeds-list.stories.d.ts +9 -0
  351. package/dist/types/components/table/table-utils.d.ts +14 -0
  352. package/dist/types/components/table/table.d.ts +28 -0
  353. package/dist/types/components.d.ts +635 -12
  354. package/dist/types/stencil-public-runtime.d.ts +2 -0
  355. package/dist/types/utils/country-options.d.ts +5 -0
  356. package/dist/types/utils/phone-masks.d.ts +3 -0
  357. package/dist/types/utils/utils.d.ts +2 -0
  358. package/dist/webcomponents/{p-33d69eb5.entry.js → p-0237a6bc.entry.js} +2 -2
  359. package/dist/webcomponents/p-0237a6bc.entry.js.map +1 -0
  360. package/dist/webcomponents/{p-7041a637.entry.js → p-0d6e9f76.entry.js} +2 -2
  361. package/dist/webcomponents/p-126146d4.js +2 -0
  362. package/dist/webcomponents/p-126146d4.js.map +1 -0
  363. package/dist/webcomponents/p-239564c6.entry.js +2 -0
  364. package/dist/webcomponents/p-239564c6.entry.js.map +1 -0
  365. package/dist/webcomponents/p-27b15fe8.entry.js +2 -0
  366. package/dist/webcomponents/p-27b15fe8.entry.js.map +1 -0
  367. package/dist/webcomponents/p-2c2cde2d.js +2 -0
  368. package/dist/webcomponents/p-2c2cde2d.js.map +1 -0
  369. package/dist/webcomponents/p-308b6784.js +3 -0
  370. package/dist/webcomponents/p-308b6784.js.map +1 -0
  371. package/dist/webcomponents/p-391b8f1d.entry.js +2 -0
  372. package/dist/webcomponents/p-391b8f1d.entry.js.map +1 -0
  373. package/dist/webcomponents/p-439fc294.entry.js +2 -0
  374. package/dist/webcomponents/p-439fc294.entry.js.map +1 -0
  375. package/dist/webcomponents/p-66f010e5.entry.js +2 -0
  376. package/dist/webcomponents/{p-d5bc9f22.entry.js.map → p-66f010e5.entry.js.map} +1 -1
  377. package/dist/webcomponents/p-7abb092c.entry.js +2 -0
  378. package/dist/webcomponents/{p-309a886f.entry.js.map → p-7abb092c.entry.js.map} +1 -1
  379. package/dist/webcomponents/{p-d5cadc78.entry.js → p-7e3bbe32.entry.js} +2 -2
  380. package/dist/webcomponents/p-86464cab.entry.js +2 -0
  381. package/dist/webcomponents/p-86464cab.entry.js.map +1 -0
  382. package/dist/webcomponents/p-8f421dc6.js +2 -0
  383. package/dist/webcomponents/p-8f421dc6.js.map +1 -0
  384. package/dist/webcomponents/p-9346ae33.js +2 -0
  385. package/dist/webcomponents/p-9346ae33.js.map +1 -0
  386. package/dist/webcomponents/p-ab0756ff.js +2 -0
  387. package/dist/webcomponents/p-ab0756ff.js.map +1 -0
  388. package/dist/webcomponents/p-b042bf80.entry.js +2 -0
  389. package/dist/webcomponents/p-b042bf80.entry.js.map +1 -0
  390. package/dist/webcomponents/{p-1953797f.entry.js → p-b967262f.entry.js} +2 -2
  391. package/dist/webcomponents/p-bf9c2be2.entry.js +2 -0
  392. package/dist/webcomponents/p-bf9c2be2.entry.js.map +1 -0
  393. package/dist/webcomponents/p-c18d876e.entry.js +2 -0
  394. package/dist/webcomponents/p-c18d876e.entry.js.map +1 -0
  395. package/dist/webcomponents/p-c1e4288d.entry.js +2 -0
  396. package/dist/webcomponents/p-c1e4288d.entry.js.map +1 -0
  397. package/dist/webcomponents/{p-0fd4aae2.js → p-c46241ba.js} +2 -2
  398. package/dist/webcomponents/p-c46241ba.js.map +1 -0
  399. package/dist/webcomponents/p-ccb0e1c5.js +2 -0
  400. package/dist/webcomponents/p-ccb0e1c5.js.map +1 -0
  401. package/dist/webcomponents/p-d1bbf409.entry.js +2 -0
  402. package/dist/webcomponents/p-d1bbf409.entry.js.map +1 -0
  403. package/dist/webcomponents/p-e26d7eea.entry.js +2 -0
  404. package/dist/webcomponents/p-e26d7eea.entry.js.map +1 -0
  405. package/dist/webcomponents/{p-23e9c7d4.entry.js → p-e77d8c6e.entry.js} +2 -2
  406. package/dist/webcomponents/p-f0acb27e.entry.js +2 -0
  407. package/dist/webcomponents/p-f0acb27e.entry.js.map +1 -0
  408. package/dist/webcomponents/p-f8d49acb.entry.js +2 -0
  409. package/dist/webcomponents/p-f8d49acb.entry.js.map +1 -0
  410. package/dist/webcomponents/p-f9e127a5.js +2 -0
  411. package/dist/webcomponents/p-f9e127a5.js.map +1 -0
  412. package/dist/webcomponents/webcomponents.esm.js +1 -1
  413. package/dist/webcomponents/webcomponents.esm.js.map +1 -1
  414. package/package.json +7 -5
  415. package/dist/cjs/Api-7303478d.js.map +0 -1
  416. package/dist/cjs/business-form-schema-63b311b2.js.map +0 -1
  417. package/dist/cjs/form-control-select_2.cjs.entry.js.map +0 -1
  418. package/dist/cjs/index-83b2ec02.js.map +0 -1
  419. package/dist/cjs/index.esm-7e12ce07.js.map +0 -1
  420. package/dist/cjs/justifi-business-address-form.cjs.entry.js +0 -37
  421. package/dist/cjs/justifi-business-address-form.cjs.entry.js.map +0 -1
  422. package/dist/cjs/justifi-business-generic-info_3.cjs.entry.js +0 -148
  423. package/dist/cjs/justifi-business-generic-info_3.cjs.entry.js.map +0 -1
  424. package/dist/cjs/utils-4ee7e080.js.map +0 -1
  425. package/dist/collection/components/business-form/businessForm.stories.js.map +0 -1
  426. package/dist/esm/Api-436dfa09.js.map +0 -1
  427. package/dist/esm/business-form-schema-30c48693.js.map +0 -1
  428. package/dist/esm/form-control-select_2.entry.js.map +0 -1
  429. package/dist/esm/index-c8f391de.js.map +0 -1
  430. package/dist/esm/index.esm-be2cd327.js.map +0 -1
  431. package/dist/esm/justifi-business-address-form.entry.js +0 -33
  432. package/dist/esm/justifi-business-address-form.entry.js.map +0 -1
  433. package/dist/esm/justifi-business-generic-info_3.entry.js +0 -142
  434. package/dist/esm/justifi-business-generic-info_3.entry.js.map +0 -1
  435. package/dist/esm/utils-e7782126.js.map +0 -1
  436. package/dist/webcomponents/p-0fd4aae2.js.map +0 -1
  437. package/dist/webcomponents/p-1a1f2196.js +0 -2
  438. package/dist/webcomponents/p-1a1f2196.js.map +0 -1
  439. package/dist/webcomponents/p-309a886f.entry.js +0 -2
  440. package/dist/webcomponents/p-33d69eb5.entry.js.map +0 -1
  441. package/dist/webcomponents/p-3a80a2ec.entry.js +0 -2
  442. package/dist/webcomponents/p-3a80a2ec.entry.js.map +0 -1
  443. package/dist/webcomponents/p-45fea6a8.entry.js +0 -2
  444. package/dist/webcomponents/p-45fea6a8.entry.js.map +0 -1
  445. package/dist/webcomponents/p-79456add.js +0 -2
  446. package/dist/webcomponents/p-79456add.js.map +0 -1
  447. package/dist/webcomponents/p-af080b21.js +0 -2
  448. package/dist/webcomponents/p-af080b21.js.map +0 -1
  449. package/dist/webcomponents/p-bc969904.js +0 -3
  450. package/dist/webcomponents/p-bc969904.js.map +0 -1
  451. package/dist/webcomponents/p-cd097ce9.entry.js +0 -2
  452. package/dist/webcomponents/p-cd097ce9.entry.js.map +0 -1
  453. package/dist/webcomponents/p-d5bc9f22.entry.js +0 -2
  454. package/dist/webcomponents/p-dd1ebc0b.entry.js +0 -2
  455. package/dist/webcomponents/p-dd1ebc0b.entry.js.map +0 -1
  456. package/dist/webcomponents/p-e05e0c6b.entry.js +0 -2
  457. package/dist/webcomponents/p-e05e0c6b.entry.js.map +0 -1
  458. /package/dist/types/components/business-form/{businessForm.stories.d.ts → business-form.stories.d.ts} +0 -0
  459. /package/dist/webcomponents/{p-7041a637.entry.js.map → p-0d6e9f76.entry.js.map} +0 -0
  460. /package/dist/webcomponents/{p-d5cadc78.entry.js.map → p-7e3bbe32.entry.js.map} +0 -0
  461. /package/dist/webcomponents/{p-1953797f.entry.js.map → p-b967262f.entry.js.map} +0 -0
  462. /package/dist/webcomponents/{p-23e9c7d4.entry.js.map → p-e77d8c6e.entry.js.map} +0 -0
@@ -0,0 +1,3231 @@
1
+ /** Checks if value is string */
2
+ function isString(str) {
3
+ return typeof str === 'string' || str instanceof String;
4
+ }
5
+
6
+ /** Checks if value is object */
7
+ function isObject(obj) {
8
+ var _obj$constructor;
9
+ return typeof obj === 'object' && obj != null && (obj == null || (_obj$constructor = obj.constructor) == null ? void 0 : _obj$constructor.name) === 'Object';
10
+ }
11
+ function pick(obj, keys) {
12
+ if (Array.isArray(keys)) return pick(obj, (_, k) => keys.includes(k));
13
+ return Object.entries(obj).reduce((acc, _ref) => {
14
+ let [k, v] = _ref;
15
+ if (keys(v, k)) acc[k] = v;
16
+ return acc;
17
+ }, {});
18
+ }
19
+
20
+ /** Direction */
21
+ const DIRECTION = {
22
+ NONE: 'NONE',
23
+ LEFT: 'LEFT',
24
+ FORCE_LEFT: 'FORCE_LEFT',
25
+ RIGHT: 'RIGHT',
26
+ FORCE_RIGHT: 'FORCE_RIGHT'
27
+ };
28
+
29
+ /** Direction */
30
+
31
+ function forceDirection(direction) {
32
+ switch (direction) {
33
+ case DIRECTION.LEFT:
34
+ return DIRECTION.FORCE_LEFT;
35
+ case DIRECTION.RIGHT:
36
+ return DIRECTION.FORCE_RIGHT;
37
+ default:
38
+ return direction;
39
+ }
40
+ }
41
+
42
+ /** Escapes regular expression control chars */
43
+ function escapeRegExp(str) {
44
+ return str.replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1');
45
+ }
46
+
47
+ // cloned from https://github.com/epoberezkin/fast-deep-equal with small changes
48
+ function objectIncludes(b, a) {
49
+ if (a === b) return true;
50
+ const arrA = Array.isArray(a),
51
+ arrB = Array.isArray(b);
52
+ let i;
53
+ if (arrA && arrB) {
54
+ if (a.length != b.length) return false;
55
+ for (i = 0; i < a.length; i++) if (!objectIncludes(a[i], b[i])) return false;
56
+ return true;
57
+ }
58
+ if (arrA != arrB) return false;
59
+ if (a && b && typeof a === 'object' && typeof b === 'object') {
60
+ const dateA = a instanceof Date,
61
+ dateB = b instanceof Date;
62
+ if (dateA && dateB) return a.getTime() == b.getTime();
63
+ if (dateA != dateB) return false;
64
+ const regexpA = a instanceof RegExp,
65
+ regexpB = b instanceof RegExp;
66
+ if (regexpA && regexpB) return a.toString() == b.toString();
67
+ if (regexpA != regexpB) return false;
68
+ const keys = Object.keys(a);
69
+ // if (keys.length !== Object.keys(b).length) return false;
70
+
71
+ for (i = 0; i < keys.length; i++) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
72
+ for (i = 0; i < keys.length; i++) if (!objectIncludes(b[keys[i]], a[keys[i]])) return false;
73
+ return true;
74
+ } else if (a && b && typeof a === 'function' && typeof b === 'function') {
75
+ return a.toString() === b.toString();
76
+ }
77
+ return false;
78
+ }
79
+
80
+ /** Provides details of changing input */
81
+ class ActionDetails {
82
+ /** Current input value */
83
+
84
+ /** Current cursor position */
85
+
86
+ /** Old input value */
87
+
88
+ /** Old selection */
89
+
90
+ constructor(opts) {
91
+ Object.assign(this, opts);
92
+
93
+ // double check if left part was changed (autofilling, other non-standard input triggers)
94
+ while (this.value.slice(0, this.startChangePos) !== this.oldValue.slice(0, this.startChangePos)) {
95
+ --this.oldSelection.start;
96
+ }
97
+ }
98
+
99
+ /** Start changing position */
100
+ get startChangePos() {
101
+ return Math.min(this.cursorPos, this.oldSelection.start);
102
+ }
103
+
104
+ /** Inserted symbols count */
105
+ get insertedCount() {
106
+ return this.cursorPos - this.startChangePos;
107
+ }
108
+
109
+ /** Inserted symbols */
110
+ get inserted() {
111
+ return this.value.substr(this.startChangePos, this.insertedCount);
112
+ }
113
+
114
+ /** Removed symbols count */
115
+ get removedCount() {
116
+ // Math.max for opposite operation
117
+ return Math.max(this.oldSelection.end - this.startChangePos ||
118
+ // for Delete
119
+ this.oldValue.length - this.value.length, 0);
120
+ }
121
+
122
+ /** Removed symbols */
123
+ get removed() {
124
+ return this.oldValue.substr(this.startChangePos, this.removedCount);
125
+ }
126
+
127
+ /** Unchanged head symbols */
128
+ get head() {
129
+ return this.value.substring(0, this.startChangePos);
130
+ }
131
+
132
+ /** Unchanged tail symbols */
133
+ get tail() {
134
+ return this.value.substring(this.startChangePos + this.insertedCount);
135
+ }
136
+
137
+ /** Remove direction */
138
+ get removeDirection() {
139
+ if (!this.removedCount || this.insertedCount) return DIRECTION.NONE;
140
+
141
+ // align right if delete at right
142
+ return (this.oldSelection.end === this.cursorPos || this.oldSelection.start === this.cursorPos) &&
143
+ // if not range removed (event with backspace)
144
+ this.oldSelection.end === this.oldSelection.start ? DIRECTION.RIGHT : DIRECTION.LEFT;
145
+ }
146
+ }
147
+
148
+ /** Applies mask on element */
149
+ function IMask(el, opts) {
150
+ // currently available only for input-like elements
151
+ return new IMask.InputMask(el, opts);
152
+ }
153
+
154
+ // TODO can't use overloads here because of https://github.com/microsoft/TypeScript/issues/50754
155
+ // export function maskedClass(mask: string): typeof MaskedPattern;
156
+ // export function maskedClass(mask: DateConstructor): typeof MaskedDate;
157
+ // export function maskedClass(mask: NumberConstructor): typeof MaskedNumber;
158
+ // export function maskedClass(mask: Array<any> | ArrayConstructor): typeof MaskedDynamic;
159
+ // export function maskedClass(mask: MaskedDate): typeof MaskedDate;
160
+ // export function maskedClass(mask: MaskedNumber): typeof MaskedNumber;
161
+ // export function maskedClass(mask: MaskedEnum): typeof MaskedEnum;
162
+ // export function maskedClass(mask: MaskedRange): typeof MaskedRange;
163
+ // export function maskedClass(mask: MaskedRegExp): typeof MaskedRegExp;
164
+ // export function maskedClass(mask: MaskedFunction): typeof MaskedFunction;
165
+ // export function maskedClass(mask: MaskedPattern): typeof MaskedPattern;
166
+ // export function maskedClass(mask: MaskedDynamic): typeof MaskedDynamic;
167
+ // export function maskedClass(mask: Masked): typeof Masked;
168
+ // export function maskedClass(mask: typeof Masked): typeof Masked;
169
+ // export function maskedClass(mask: typeof MaskedDate): typeof MaskedDate;
170
+ // export function maskedClass(mask: typeof MaskedNumber): typeof MaskedNumber;
171
+ // export function maskedClass(mask: typeof MaskedEnum): typeof MaskedEnum;
172
+ // export function maskedClass(mask: typeof MaskedRange): typeof MaskedRange;
173
+ // export function maskedClass(mask: typeof MaskedRegExp): typeof MaskedRegExp;
174
+ // export function maskedClass(mask: typeof MaskedFunction): typeof MaskedFunction;
175
+ // export function maskedClass(mask: typeof MaskedPattern): typeof MaskedPattern;
176
+ // export function maskedClass(mask: typeof MaskedDynamic): typeof MaskedDynamic;
177
+ // export function maskedClass<Mask extends typeof Masked> (mask: Mask): Mask;
178
+ // export function maskedClass(mask: RegExp): typeof MaskedRegExp;
179
+ // export function maskedClass(mask: (value: string, ...args: any[]) => boolean): typeof MaskedFunction;
180
+ /** Get Masked class by mask type */
181
+ function maskedClass(mask) /* TODO */{
182
+ if (mask == null) throw new Error('mask property should be defined');
183
+ if (mask instanceof RegExp) return IMask.MaskedRegExp;
184
+ if (isString(mask)) return IMask.MaskedPattern;
185
+ if (mask === Date) return IMask.MaskedDate;
186
+ if (mask === Number) return IMask.MaskedNumber;
187
+ if (Array.isArray(mask) || mask === Array) return IMask.MaskedDynamic;
188
+ if (IMask.Masked && mask.prototype instanceof IMask.Masked) return mask;
189
+ if (IMask.Masked && mask instanceof IMask.Masked) return mask.constructor;
190
+ if (mask instanceof Function) return IMask.MaskedFunction;
191
+ console.warn('Mask not found for mask', mask); // eslint-disable-line no-console
192
+ return IMask.Masked;
193
+ }
194
+ function normalizeOpts(opts) {
195
+ if (!opts) throw new Error('Options in not defined');
196
+ if (IMask.Masked) {
197
+ if (opts.prototype instanceof IMask.Masked) return {
198
+ mask: opts
199
+ };
200
+
201
+ /*
202
+ handle cases like:
203
+ 1) opts = Masked
204
+ 2) opts = { mask: Masked, ...instanceOpts }
205
+ */
206
+ const {
207
+ mask = undefined,
208
+ ...instanceOpts
209
+ } = opts instanceof IMask.Masked ? {
210
+ mask: opts
211
+ } : isObject(opts) && opts.mask instanceof IMask.Masked ? opts : {};
212
+ if (mask) {
213
+ const _mask = mask.mask;
214
+ return {
215
+ ...pick(mask, (_, k) => !k.startsWith('_')),
216
+ mask: mask.constructor,
217
+ _mask,
218
+ ...instanceOpts
219
+ };
220
+ }
221
+ }
222
+ if (!isObject(opts)) return {
223
+ mask: opts
224
+ };
225
+ return {
226
+ ...opts
227
+ };
228
+ }
229
+
230
+ // TODO can't use overloads here because of https://github.com/microsoft/TypeScript/issues/50754
231
+
232
+ // From masked
233
+ // export default function createMask<Opts extends Masked, ReturnMasked=Opts> (opts: Opts): ReturnMasked;
234
+ // // From masked class
235
+ // export default function createMask<Opts extends MaskedOptions<typeof Masked>, ReturnMasked extends Masked=InstanceType<Opts['mask']>> (opts: Opts): ReturnMasked;
236
+ // export default function createMask<Opts extends MaskedOptions<typeof MaskedDate>, ReturnMasked extends MaskedDate=MaskedDate<Opts['parent']>> (opts: Opts): ReturnMasked;
237
+ // export default function createMask<Opts extends MaskedOptions<typeof MaskedNumber>, ReturnMasked extends MaskedNumber=MaskedNumber<Opts['parent']>> (opts: Opts): ReturnMasked;
238
+ // export default function createMask<Opts extends MaskedOptions<typeof MaskedEnum>, ReturnMasked extends MaskedEnum=MaskedEnum<Opts['parent']>> (opts: Opts): ReturnMasked;
239
+ // export default function createMask<Opts extends MaskedOptions<typeof MaskedRange>, ReturnMasked extends MaskedRange=MaskedRange<Opts['parent']>> (opts: Opts): ReturnMasked;
240
+ // export default function createMask<Opts extends MaskedOptions<typeof MaskedRegExp>, ReturnMasked extends MaskedRegExp=MaskedRegExp<Opts['parent']>> (opts: Opts): ReturnMasked;
241
+ // export default function createMask<Opts extends MaskedOptions<typeof MaskedFunction>, ReturnMasked extends MaskedFunction=MaskedFunction<Opts['parent']>> (opts: Opts): ReturnMasked;
242
+ // export default function createMask<Opts extends MaskedOptions<typeof MaskedPattern>, ReturnMasked extends MaskedPattern=MaskedPattern<Opts['parent']>> (opts: Opts): ReturnMasked;
243
+ // export default function createMask<Opts extends MaskedOptions<typeof MaskedDynamic>, ReturnMasked extends MaskedDynamic=MaskedDynamic<Opts['parent']>> (opts: Opts): ReturnMasked;
244
+ // // From mask opts
245
+ // export default function createMask<Opts extends MaskedOptions<Masked>, ReturnMasked=Opts extends MaskedOptions<infer M> ? M : never> (opts: Opts): ReturnMasked;
246
+ // export default function createMask<Opts extends MaskedNumberOptions, ReturnMasked extends MaskedNumber=MaskedNumber<Opts['parent']>> (opts: Opts): ReturnMasked;
247
+ // export default function createMask<Opts extends MaskedDateFactoryOptions, ReturnMasked extends MaskedDate=MaskedDate<Opts['parent']>> (opts: Opts): ReturnMasked;
248
+ // export default function createMask<Opts extends MaskedEnumOptions, ReturnMasked extends MaskedEnum=MaskedEnum<Opts['parent']>> (opts: Opts): ReturnMasked;
249
+ // export default function createMask<Opts extends MaskedRangeOptions, ReturnMasked extends MaskedRange=MaskedRange<Opts['parent']>> (opts: Opts): ReturnMasked;
250
+ // export default function createMask<Opts extends MaskedPatternOptions, ReturnMasked extends MaskedPattern=MaskedPattern<Opts['parent']>> (opts: Opts): ReturnMasked;
251
+ // export default function createMask<Opts extends MaskedDynamicOptions, ReturnMasked extends MaskedDynamic=MaskedDynamic<Opts['parent']>> (opts: Opts): ReturnMasked;
252
+ // export default function createMask<Opts extends MaskedOptions<RegExp>, ReturnMasked extends MaskedRegExp=MaskedRegExp<Opts['parent']>> (opts: Opts): ReturnMasked;
253
+ // export default function createMask<Opts extends MaskedOptions<Function>, ReturnMasked extends MaskedFunction=MaskedFunction<Opts['parent']>> (opts: Opts): ReturnMasked;
254
+
255
+ /** Creates new {@link Masked} depending on mask type */
256
+ function createMask(opts) {
257
+ if (IMask.Masked && opts instanceof IMask.Masked) return opts;
258
+ const nOpts = normalizeOpts(opts);
259
+ const MaskedClass = maskedClass(nOpts.mask);
260
+ if (!MaskedClass) throw new Error('Masked class is not found for provided mask, appropriate module needs to be imported manually before creating mask.');
261
+ if (nOpts.mask === MaskedClass) delete nOpts.mask;
262
+ if (nOpts._mask) {
263
+ nOpts.mask = nOpts._mask;
264
+ delete nOpts._mask;
265
+ }
266
+ return new MaskedClass(nOpts);
267
+ }
268
+ IMask.createMask = createMask;
269
+
270
+ /** Generic element API to use with mask */
271
+ class MaskElement {
272
+ /** */
273
+
274
+ /** */
275
+
276
+ /** */
277
+
278
+ /** Safely returns selection start */
279
+ get selectionStart() {
280
+ let start;
281
+ try {
282
+ start = this._unsafeSelectionStart;
283
+ } catch {}
284
+ return start != null ? start : this.value.length;
285
+ }
286
+
287
+ /** Safely returns selection end */
288
+ get selectionEnd() {
289
+ let end;
290
+ try {
291
+ end = this._unsafeSelectionEnd;
292
+ } catch {}
293
+ return end != null ? end : this.value.length;
294
+ }
295
+
296
+ /** Safely sets element selection */
297
+ select(start, end) {
298
+ if (start == null || end == null || start === this.selectionStart && end === this.selectionEnd) return;
299
+ try {
300
+ this._unsafeSelect(start, end);
301
+ } catch {}
302
+ }
303
+
304
+ /** */
305
+ get isActive() {
306
+ return false;
307
+ }
308
+ /** */
309
+
310
+ /** */
311
+
312
+ /** */
313
+ }
314
+
315
+ IMask.MaskElement = MaskElement;
316
+
317
+ /** Bridge between HTMLElement and {@link Masked} */
318
+ class HTMLMaskElement extends MaskElement {
319
+ /** HTMLElement to use mask on */
320
+
321
+ constructor(input) {
322
+ super();
323
+ this.input = input;
324
+ this._handlers = {};
325
+ }
326
+ get rootElement() {
327
+ var _this$input$getRootNo, _this$input$getRootNo2, _this$input;
328
+ return (_this$input$getRootNo = (_this$input$getRootNo2 = (_this$input = this.input).getRootNode) == null ? void 0 : _this$input$getRootNo2.call(_this$input)) != null ? _this$input$getRootNo : document;
329
+ }
330
+
331
+ /**
332
+ Is element in focus
333
+ */
334
+ get isActive() {
335
+ return this.input === this.rootElement.activeElement;
336
+ }
337
+
338
+ /**
339
+ Binds HTMLElement events to mask internal events
340
+ */
341
+ bindEvents(handlers) {
342
+ Object.keys(handlers).forEach(event => this._toggleEventHandler(HTMLMaskElement.EVENTS_MAP[event], handlers[event]));
343
+ }
344
+
345
+ /**
346
+ Unbinds HTMLElement events to mask internal events
347
+ */
348
+ unbindEvents() {
349
+ Object.keys(this._handlers).forEach(event => this._toggleEventHandler(event));
350
+ }
351
+ _toggleEventHandler(event, handler) {
352
+ if (this._handlers[event]) {
353
+ this.input.removeEventListener(event, this._handlers[event]);
354
+ delete this._handlers[event];
355
+ }
356
+ if (handler) {
357
+ this.input.addEventListener(event, handler);
358
+ this._handlers[event] = handler;
359
+ }
360
+ }
361
+ }
362
+ /** Mapping between HTMLElement events and mask internal events */
363
+ HTMLMaskElement.EVENTS_MAP = {
364
+ selectionChange: 'keydown',
365
+ input: 'input',
366
+ drop: 'drop',
367
+ click: 'click',
368
+ focus: 'focus',
369
+ commit: 'blur'
370
+ };
371
+ IMask.HTMLMaskElement = HTMLMaskElement;
372
+
373
+ /** Bridge between InputElement and {@link Masked} */
374
+ class HTMLInputMaskElement extends HTMLMaskElement {
375
+ /** InputElement to use mask on */
376
+
377
+ constructor(input) {
378
+ super(input);
379
+ this.input = input;
380
+ this._handlers = {};
381
+ }
382
+
383
+ /** Returns InputElement selection start */
384
+ get _unsafeSelectionStart() {
385
+ return this.input.selectionStart != null ? this.input.selectionStart : this.value.length;
386
+ }
387
+
388
+ /** Returns InputElement selection end */
389
+ get _unsafeSelectionEnd() {
390
+ return this.input.selectionEnd;
391
+ }
392
+
393
+ /** Sets InputElement selection */
394
+ _unsafeSelect(start, end) {
395
+ this.input.setSelectionRange(start, end);
396
+ }
397
+ get value() {
398
+ return this.input.value;
399
+ }
400
+ set value(value) {
401
+ this.input.value = value;
402
+ }
403
+ }
404
+ IMask.HTMLMaskElement = HTMLMaskElement;
405
+
406
+ class HTMLContenteditableMaskElement extends HTMLMaskElement {
407
+ /** Returns HTMLElement selection start */
408
+ get _unsafeSelectionStart() {
409
+ const root = this.rootElement;
410
+ const selection = root.getSelection && root.getSelection();
411
+ const anchorOffset = selection && selection.anchorOffset;
412
+ const focusOffset = selection && selection.focusOffset;
413
+ if (focusOffset == null || anchorOffset == null || anchorOffset < focusOffset) {
414
+ return anchorOffset;
415
+ }
416
+ return focusOffset;
417
+ }
418
+
419
+ /** Returns HTMLElement selection end */
420
+ get _unsafeSelectionEnd() {
421
+ const root = this.rootElement;
422
+ const selection = root.getSelection && root.getSelection();
423
+ const anchorOffset = selection && selection.anchorOffset;
424
+ const focusOffset = selection && selection.focusOffset;
425
+ if (focusOffset == null || anchorOffset == null || anchorOffset > focusOffset) {
426
+ return anchorOffset;
427
+ }
428
+ return focusOffset;
429
+ }
430
+
431
+ /** Sets HTMLElement selection */
432
+ _unsafeSelect(start, end) {
433
+ if (!this.rootElement.createRange) return;
434
+ const range = this.rootElement.createRange();
435
+ range.setStart(this.input.firstChild || this.input, start);
436
+ range.setEnd(this.input.lastChild || this.input, end);
437
+ const root = this.rootElement;
438
+ const selection = root.getSelection && root.getSelection();
439
+ if (selection) {
440
+ selection.removeAllRanges();
441
+ selection.addRange(range);
442
+ }
443
+ }
444
+
445
+ /** HTMLElement value */
446
+ get value() {
447
+ return this.input.textContent || '';
448
+ }
449
+ set value(value) {
450
+ this.input.textContent = value;
451
+ }
452
+ }
453
+ IMask.HTMLContenteditableMaskElement = HTMLContenteditableMaskElement;
454
+
455
+ /** Listens to element events and controls changes between element and {@link Masked} */
456
+ class InputMask {
457
+ /**
458
+ View element
459
+ */
460
+
461
+ /** Internal {@link Masked} model */
462
+
463
+ constructor(el, opts) {
464
+ this.el = el instanceof MaskElement ? el : el.isContentEditable && el.tagName !== 'INPUT' && el.tagName !== 'TEXTAREA' ? new HTMLContenteditableMaskElement(el) : new HTMLInputMaskElement(el);
465
+ this.masked = createMask(opts);
466
+ this._listeners = {};
467
+ this._value = '';
468
+ this._unmaskedValue = '';
469
+ this._saveSelection = this._saveSelection.bind(this);
470
+ this._onInput = this._onInput.bind(this);
471
+ this._onChange = this._onChange.bind(this);
472
+ this._onDrop = this._onDrop.bind(this);
473
+ this._onFocus = this._onFocus.bind(this);
474
+ this._onClick = this._onClick.bind(this);
475
+ this.alignCursor = this.alignCursor.bind(this);
476
+ this.alignCursorFriendly = this.alignCursorFriendly.bind(this);
477
+ this._bindEvents();
478
+
479
+ // refresh
480
+ this.updateValue();
481
+ this._onChange();
482
+ }
483
+ maskEquals(mask) {
484
+ var _this$masked;
485
+ return mask == null || ((_this$masked = this.masked) == null ? void 0 : _this$masked.maskEquals(mask));
486
+ }
487
+
488
+ /** Masked */
489
+ get mask() {
490
+ return this.masked.mask;
491
+ }
492
+ set mask(mask) {
493
+ if (this.maskEquals(mask)) return;
494
+ if (!(mask instanceof IMask.Masked) && this.masked.constructor === maskedClass(mask)) {
495
+ // TODO "any" no idea
496
+ this.masked.updateOptions({
497
+ mask
498
+ });
499
+ return;
500
+ }
501
+ const masked = mask instanceof IMask.Masked ? mask : createMask({
502
+ mask
503
+ });
504
+ masked.unmaskedValue = this.masked.unmaskedValue;
505
+ this.masked = masked;
506
+ }
507
+
508
+ /** Raw value */
509
+ get value() {
510
+ return this._value;
511
+ }
512
+ set value(str) {
513
+ if (this.value === str) return;
514
+ this.masked.value = str;
515
+ this.updateControl();
516
+ this.alignCursor();
517
+ }
518
+
519
+ /** Unmasked value */
520
+ get unmaskedValue() {
521
+ return this._unmaskedValue;
522
+ }
523
+ set unmaskedValue(str) {
524
+ if (this.unmaskedValue === str) return;
525
+ this.masked.unmaskedValue = str;
526
+ this.updateControl();
527
+ this.alignCursor();
528
+ }
529
+
530
+ /** Typed unmasked value */
531
+ get typedValue() {
532
+ return this.masked.typedValue;
533
+ }
534
+ set typedValue(val) {
535
+ if (this.masked.typedValueEquals(val)) return;
536
+ this.masked.typedValue = val;
537
+ this.updateControl();
538
+ this.alignCursor();
539
+ }
540
+
541
+ /** Display value */
542
+ get displayValue() {
543
+ return this.masked.displayValue;
544
+ }
545
+
546
+ /** Starts listening to element events */
547
+ _bindEvents() {
548
+ this.el.bindEvents({
549
+ selectionChange: this._saveSelection,
550
+ input: this._onInput,
551
+ drop: this._onDrop,
552
+ click: this._onClick,
553
+ focus: this._onFocus,
554
+ commit: this._onChange
555
+ });
556
+ }
557
+
558
+ /** Stops listening to element events */
559
+ _unbindEvents() {
560
+ if (this.el) this.el.unbindEvents();
561
+ }
562
+
563
+ /** Fires custom event */
564
+ _fireEvent(ev, e) {
565
+ const listeners = this._listeners[ev];
566
+ if (!listeners) return;
567
+ listeners.forEach(l => l(e));
568
+ }
569
+
570
+ /** Current selection start */
571
+ get selectionStart() {
572
+ return this._cursorChanging ? this._changingCursorPos : this.el.selectionStart;
573
+ }
574
+
575
+ /** Current cursor position */
576
+ get cursorPos() {
577
+ return this._cursorChanging ? this._changingCursorPos : this.el.selectionEnd;
578
+ }
579
+ set cursorPos(pos) {
580
+ if (!this.el || !this.el.isActive) return;
581
+ this.el.select(pos, pos);
582
+ this._saveSelection();
583
+ }
584
+
585
+ /** Stores current selection */
586
+ _saveSelection( /* ev */
587
+ ) {
588
+ if (this.displayValue !== this.el.value) {
589
+ console.warn('Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly.'); // eslint-disable-line no-console
590
+ }
591
+
592
+ this._selection = {
593
+ start: this.selectionStart,
594
+ end: this.cursorPos
595
+ };
596
+ }
597
+
598
+ /** Syncronizes model value from view */
599
+ updateValue() {
600
+ this.masked.value = this.el.value;
601
+ this._value = this.masked.value;
602
+ }
603
+
604
+ /** Syncronizes view from model value, fires change events */
605
+ updateControl() {
606
+ const newUnmaskedValue = this.masked.unmaskedValue;
607
+ const newValue = this.masked.value;
608
+ const newDisplayValue = this.displayValue;
609
+ const isChanged = this.unmaskedValue !== newUnmaskedValue || this.value !== newValue;
610
+ this._unmaskedValue = newUnmaskedValue;
611
+ this._value = newValue;
612
+ if (this.el.value !== newDisplayValue) this.el.value = newDisplayValue;
613
+ if (isChanged) this._fireChangeEvents();
614
+ }
615
+
616
+ /** Updates options with deep equal check, recreates {@link Masked} model if mask type changes */
617
+ updateOptions(opts) {
618
+ const {
619
+ mask,
620
+ ...restOpts
621
+ } = opts;
622
+ const updateMask = !this.maskEquals(mask);
623
+ const updateOpts = !objectIncludes(this.masked, restOpts);
624
+ if (updateMask) this.mask = mask;
625
+ if (updateOpts) this.masked.updateOptions(restOpts); // TODO
626
+
627
+ if (updateMask || updateOpts) this.updateControl();
628
+ }
629
+
630
+ /** Updates cursor */
631
+ updateCursor(cursorPos) {
632
+ if (cursorPos == null) return;
633
+ this.cursorPos = cursorPos;
634
+
635
+ // also queue change cursor for mobile browsers
636
+ this._delayUpdateCursor(cursorPos);
637
+ }
638
+
639
+ /** Delays cursor update to support mobile browsers */
640
+ _delayUpdateCursor(cursorPos) {
641
+ this._abortUpdateCursor();
642
+ this._changingCursorPos = cursorPos;
643
+ this._cursorChanging = setTimeout(() => {
644
+ if (!this.el) return; // if was destroyed
645
+ this.cursorPos = this._changingCursorPos;
646
+ this._abortUpdateCursor();
647
+ }, 10);
648
+ }
649
+
650
+ /** Fires custom events */
651
+ _fireChangeEvents() {
652
+ this._fireEvent('accept', this._inputEvent);
653
+ if (this.masked.isComplete) this._fireEvent('complete', this._inputEvent);
654
+ }
655
+
656
+ /** Aborts delayed cursor update */
657
+ _abortUpdateCursor() {
658
+ if (this._cursorChanging) {
659
+ clearTimeout(this._cursorChanging);
660
+ delete this._cursorChanging;
661
+ }
662
+ }
663
+
664
+ /** Aligns cursor to nearest available position */
665
+ alignCursor() {
666
+ this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, DIRECTION.LEFT));
667
+ }
668
+
669
+ /** Aligns cursor only if selection is empty */
670
+ alignCursorFriendly() {
671
+ if (this.selectionStart !== this.cursorPos) return; // skip if range is selected
672
+ this.alignCursor();
673
+ }
674
+
675
+ /** Adds listener on custom event */
676
+ on(ev, handler) {
677
+ if (!this._listeners[ev]) this._listeners[ev] = [];
678
+ this._listeners[ev].push(handler);
679
+ return this;
680
+ }
681
+
682
+ /** Removes custom event listener */
683
+ off(ev, handler) {
684
+ if (!this._listeners[ev]) return this;
685
+ if (!handler) {
686
+ delete this._listeners[ev];
687
+ return this;
688
+ }
689
+ const hIndex = this._listeners[ev].indexOf(handler);
690
+ if (hIndex >= 0) this._listeners[ev].splice(hIndex, 1);
691
+ return this;
692
+ }
693
+
694
+ /** Handles view input event */
695
+ _onInput(e) {
696
+ this._inputEvent = e;
697
+ this._abortUpdateCursor();
698
+
699
+ // fix strange IE behavior
700
+ if (!this._selection) return this.updateValue();
701
+ const details = new ActionDetails({
702
+ // new state
703
+ value: this.el.value,
704
+ cursorPos: this.cursorPos,
705
+ // old state
706
+ oldValue: this.displayValue,
707
+ oldSelection: this._selection
708
+ });
709
+ const oldRawValue = this.masked.rawInputValue;
710
+ const offset = this.masked.splice(details.startChangePos, details.removed.length, details.inserted, details.removeDirection, {
711
+ input: true,
712
+ raw: true
713
+ }).offset;
714
+
715
+ // force align in remove direction only if no input chars were removed
716
+ // otherwise we still need to align with NONE (to get out from fixed symbols for instance)
717
+ const removeDirection = oldRawValue === this.masked.rawInputValue ? details.removeDirection : DIRECTION.NONE;
718
+ let cursorPos = this.masked.nearestInputPos(details.startChangePos + offset, removeDirection);
719
+ if (removeDirection !== DIRECTION.NONE) cursorPos = this.masked.nearestInputPos(cursorPos, DIRECTION.NONE);
720
+ this.updateControl();
721
+ this.updateCursor(cursorPos);
722
+ delete this._inputEvent;
723
+ }
724
+
725
+ /** Handles view change event and commits model value */
726
+ _onChange() {
727
+ if (this.displayValue !== this.el.value) {
728
+ this.updateValue();
729
+ }
730
+ this.masked.doCommit();
731
+ this.updateControl();
732
+ this._saveSelection();
733
+ }
734
+
735
+ /** Handles view drop event, prevents by default */
736
+ _onDrop(ev) {
737
+ ev.preventDefault();
738
+ ev.stopPropagation();
739
+ }
740
+
741
+ /** Restore last selection on focus */
742
+ _onFocus(ev) {
743
+ this.alignCursorFriendly();
744
+ }
745
+
746
+ /** Restore last selection on focus */
747
+ _onClick(ev) {
748
+ this.alignCursorFriendly();
749
+ }
750
+
751
+ /** Unbind view events and removes element reference */
752
+ destroy() {
753
+ this._unbindEvents();
754
+ this._listeners.length = 0;
755
+ delete this.el;
756
+ }
757
+ }
758
+ IMask.InputMask = InputMask;
759
+
760
+ /** Provides details of changing model value */
761
+ class ChangeDetails {
762
+ /** Inserted symbols */
763
+
764
+ /** Can skip chars */
765
+
766
+ /** Additional offset if any changes occurred before tail */
767
+
768
+ /** Raw inserted is used by dynamic mask */
769
+
770
+ static normalize(prep) {
771
+ return Array.isArray(prep) ? prep : [prep, new ChangeDetails()];
772
+ }
773
+ constructor(details) {
774
+ Object.assign(this, {
775
+ inserted: '',
776
+ rawInserted: '',
777
+ skip: false,
778
+ tailShift: 0
779
+ }, details);
780
+ }
781
+
782
+ /** Aggregate changes */
783
+ aggregate(details) {
784
+ this.rawInserted += details.rawInserted;
785
+ this.skip = this.skip || details.skip;
786
+ this.inserted += details.inserted;
787
+ this.tailShift += details.tailShift;
788
+ return this;
789
+ }
790
+
791
+ /** Total offset considering all changes */
792
+ get offset() {
793
+ return this.tailShift + this.inserted.length;
794
+ }
795
+ }
796
+ IMask.ChangeDetails = ChangeDetails;
797
+
798
+ /** Provides details of continuous extracted tail */
799
+ class ContinuousTailDetails {
800
+ /** Tail value as string */
801
+
802
+ /** Tail start position */
803
+
804
+ /** Start position */
805
+
806
+ constructor(value, from, stop) {
807
+ if (value === void 0) {
808
+ value = '';
809
+ }
810
+ if (from === void 0) {
811
+ from = 0;
812
+ }
813
+ this.value = value;
814
+ this.from = from;
815
+ this.stop = stop;
816
+ }
817
+ toString() {
818
+ return this.value;
819
+ }
820
+ extend(tail) {
821
+ this.value += String(tail);
822
+ }
823
+ appendTo(masked) {
824
+ return masked.append(this.toString(), {
825
+ tail: true
826
+ }).aggregate(masked._appendPlaceholder());
827
+ }
828
+ get state() {
829
+ return {
830
+ value: this.value,
831
+ from: this.from,
832
+ stop: this.stop
833
+ };
834
+ }
835
+ set state(state) {
836
+ Object.assign(this, state);
837
+ }
838
+ unshift(beforePos) {
839
+ if (!this.value.length || beforePos != null && this.from >= beforePos) return '';
840
+ const shiftChar = this.value[0];
841
+ this.value = this.value.slice(1);
842
+ return shiftChar;
843
+ }
844
+ shift() {
845
+ if (!this.value.length) return '';
846
+ const shiftChar = this.value[this.value.length - 1];
847
+ this.value = this.value.slice(0, -1);
848
+ return shiftChar;
849
+ }
850
+ }
851
+
852
+ /** Append flags */
853
+
854
+ /** Extract flags */
855
+
856
+ // see https://github.com/microsoft/TypeScript/issues/6223
857
+
858
+ /** Provides common masking stuff */
859
+ class Masked {
860
+ /** */
861
+
862
+ /** */
863
+
864
+ /** Transforms value before mask processing */
865
+
866
+ /** Transforms each char before mask processing */
867
+
868
+ /** Validates if value is acceptable */
869
+
870
+ /** Does additional processing at the end of editing */
871
+
872
+ /** Format typed value to string */
873
+
874
+ /** Parse string to get typed value */
875
+
876
+ /** Enable characters overwriting */
877
+
878
+ /** */
879
+
880
+ /** */
881
+
882
+ /** */
883
+
884
+ constructor(opts) {
885
+ this._value = '';
886
+ this._update({
887
+ ...Masked.DEFAULTS,
888
+ ...opts
889
+ });
890
+ this._initialized = true;
891
+ }
892
+
893
+ /** Sets and applies new options */
894
+ updateOptions(opts) {
895
+ if (!Object.keys(opts).length) return;
896
+ this.withValueRefresh(this._update.bind(this, opts));
897
+ }
898
+
899
+ /** Sets new options */
900
+ _update(opts) {
901
+ Object.assign(this, opts);
902
+ }
903
+
904
+ /** Mask state */
905
+ get state() {
906
+ return {
907
+ _value: this.value,
908
+ _rawInputValue: this.rawInputValue
909
+ };
910
+ }
911
+ set state(state) {
912
+ this._value = state._value;
913
+ }
914
+
915
+ /** Resets value */
916
+ reset() {
917
+ this._value = '';
918
+ }
919
+ get value() {
920
+ return this._value;
921
+ }
922
+ set value(value) {
923
+ this.resolve(value, {
924
+ input: true
925
+ });
926
+ }
927
+
928
+ /** Resolve new value */
929
+ resolve(value, flags) {
930
+ if (flags === void 0) {
931
+ flags = {
932
+ input: true
933
+ };
934
+ }
935
+ this.reset();
936
+ this.append(value, flags, '');
937
+ this.doCommit();
938
+ }
939
+ get unmaskedValue() {
940
+ return this.value;
941
+ }
942
+ set unmaskedValue(value) {
943
+ this.resolve(value, {});
944
+ }
945
+ get typedValue() {
946
+ return this.parse ? this.parse(this.value, this) : this.unmaskedValue;
947
+ }
948
+ set typedValue(value) {
949
+ if (this.format) {
950
+ this.value = this.format(value, this);
951
+ } else {
952
+ this.unmaskedValue = String(value);
953
+ }
954
+ }
955
+
956
+ /** Value that includes raw user input */
957
+ get rawInputValue() {
958
+ return this.extractInput(0, this.displayValue.length, {
959
+ raw: true
960
+ });
961
+ }
962
+ set rawInputValue(value) {
963
+ this.resolve(value, {
964
+ raw: true
965
+ });
966
+ }
967
+ get displayValue() {
968
+ return this.value;
969
+ }
970
+ get isComplete() {
971
+ return true;
972
+ }
973
+ get isFilled() {
974
+ return this.isComplete;
975
+ }
976
+
977
+ /** Finds nearest input position in direction */
978
+ nearestInputPos(cursorPos, direction) {
979
+ return cursorPos;
980
+ }
981
+ totalInputPositions(fromPos, toPos) {
982
+ if (fromPos === void 0) {
983
+ fromPos = 0;
984
+ }
985
+ if (toPos === void 0) {
986
+ toPos = this.displayValue.length;
987
+ }
988
+ return Math.min(this.displayValue.length, toPos - fromPos);
989
+ }
990
+
991
+ /** Extracts value in range considering flags */
992
+ extractInput(fromPos, toPos, flags) {
993
+ if (fromPos === void 0) {
994
+ fromPos = 0;
995
+ }
996
+ if (toPos === void 0) {
997
+ toPos = this.displayValue.length;
998
+ }
999
+ return this.displayValue.slice(fromPos, toPos);
1000
+ }
1001
+
1002
+ /** Extracts tail in range */
1003
+ extractTail(fromPos, toPos) {
1004
+ if (fromPos === void 0) {
1005
+ fromPos = 0;
1006
+ }
1007
+ if (toPos === void 0) {
1008
+ toPos = this.displayValue.length;
1009
+ }
1010
+ return new ContinuousTailDetails(this.extractInput(fromPos, toPos), fromPos);
1011
+ }
1012
+
1013
+ /** Appends tail */
1014
+ appendTail(tail) {
1015
+ if (isString(tail)) tail = new ContinuousTailDetails(String(tail));
1016
+ return tail.appendTo(this);
1017
+ }
1018
+
1019
+ /** Appends char */
1020
+ _appendCharRaw(ch, flags) {
1021
+ if (!ch) return new ChangeDetails();
1022
+ this._value += ch;
1023
+ return new ChangeDetails({
1024
+ inserted: ch,
1025
+ rawInserted: ch
1026
+ });
1027
+ }
1028
+
1029
+ /** Appends char */
1030
+ _appendChar(ch, flags, checkTail) {
1031
+ if (flags === void 0) {
1032
+ flags = {};
1033
+ }
1034
+ const consistentState = this.state;
1035
+ let details;
1036
+ [ch, details] = this.doPrepareChar(ch, flags);
1037
+ details = details.aggregate(this._appendCharRaw(ch, flags));
1038
+ if (details.inserted) {
1039
+ let consistentTail;
1040
+ let appended = this.doValidate(flags) !== false;
1041
+ if (appended && checkTail != null) {
1042
+ // validation ok, check tail
1043
+ const beforeTailState = this.state;
1044
+ if (this.overwrite === true) {
1045
+ consistentTail = checkTail.state;
1046
+ checkTail.unshift(this.displayValue.length - details.tailShift);
1047
+ }
1048
+ let tailDetails = this.appendTail(checkTail);
1049
+ appended = tailDetails.rawInserted === checkTail.toString();
1050
+
1051
+ // not ok, try shift
1052
+ if (!(appended && tailDetails.inserted) && this.overwrite === 'shift') {
1053
+ this.state = beforeTailState;
1054
+ consistentTail = checkTail.state;
1055
+ checkTail.shift();
1056
+ tailDetails = this.appendTail(checkTail);
1057
+ appended = tailDetails.rawInserted === checkTail.toString();
1058
+ }
1059
+
1060
+ // if ok, rollback state after tail
1061
+ if (appended && tailDetails.inserted) this.state = beforeTailState;
1062
+ }
1063
+
1064
+ // revert all if something went wrong
1065
+ if (!appended) {
1066
+ details = new ChangeDetails();
1067
+ this.state = consistentState;
1068
+ if (checkTail && consistentTail) checkTail.state = consistentTail;
1069
+ }
1070
+ }
1071
+ return details;
1072
+ }
1073
+
1074
+ /** Appends optional placeholder at the end */
1075
+ _appendPlaceholder() {
1076
+ return new ChangeDetails();
1077
+ }
1078
+
1079
+ /** Appends optional eager placeholder at the end */
1080
+ _appendEager() {
1081
+ return new ChangeDetails();
1082
+ }
1083
+
1084
+ /** Appends symbols considering flags */
1085
+ append(str, flags, tail) {
1086
+ if (!isString(str)) throw new Error('value should be string');
1087
+ const checkTail = isString(tail) ? new ContinuousTailDetails(String(tail)) : tail;
1088
+ if (flags != null && flags.tail) flags._beforeTailState = this.state;
1089
+ let details;
1090
+ [str, details] = this.doPrepare(str, flags);
1091
+ for (let ci = 0; ci < str.length; ++ci) {
1092
+ const d = this._appendChar(str[ci], flags, checkTail);
1093
+ if (!d.rawInserted && !this.doSkipInvalid(str[ci], flags, checkTail)) break;
1094
+ details.aggregate(d);
1095
+ }
1096
+ if ((this.eager === true || this.eager === 'append') && flags != null && flags.input && str) {
1097
+ details.aggregate(this._appendEager());
1098
+ }
1099
+
1100
+ // append tail but aggregate only tailShift
1101
+ if (checkTail != null) {
1102
+ details.tailShift += this.appendTail(checkTail).tailShift;
1103
+ // TODO it's a good idea to clear state after appending ends
1104
+ // but it causes bugs when one append calls another (when dynamic dispatch set rawInputValue)
1105
+ // this._resetBeforeTailState();
1106
+ }
1107
+
1108
+ return details;
1109
+ }
1110
+ remove(fromPos, toPos) {
1111
+ if (fromPos === void 0) {
1112
+ fromPos = 0;
1113
+ }
1114
+ if (toPos === void 0) {
1115
+ toPos = this.displayValue.length;
1116
+ }
1117
+ this._value = this.displayValue.slice(0, fromPos) + this.displayValue.slice(toPos);
1118
+ return new ChangeDetails();
1119
+ }
1120
+
1121
+ /** Calls function and reapplies current value */
1122
+ withValueRefresh(fn) {
1123
+ if (this._refreshing || !this._initialized) return fn();
1124
+ this._refreshing = true;
1125
+ const rawInput = this.rawInputValue;
1126
+ const value = this.value;
1127
+ const ret = fn();
1128
+ this.rawInputValue = rawInput;
1129
+ // append lost trailing chars at the end
1130
+ if (this.value && this.value !== value && value.indexOf(this.value) === 0) {
1131
+ this.append(value.slice(this.displayValue.length), {}, '');
1132
+ }
1133
+ delete this._refreshing;
1134
+ return ret;
1135
+ }
1136
+ runIsolated(fn) {
1137
+ if (this._isolated || !this._initialized) return fn(this);
1138
+ this._isolated = true;
1139
+ const state = this.state;
1140
+ const ret = fn(this);
1141
+ this.state = state;
1142
+ delete this._isolated;
1143
+ return ret;
1144
+ }
1145
+ doSkipInvalid(ch, flags, checkTail) {
1146
+ return Boolean(this.skipInvalid);
1147
+ }
1148
+
1149
+ /** Prepares string before mask processing */
1150
+ doPrepare(str, flags) {
1151
+ if (flags === void 0) {
1152
+ flags = {};
1153
+ }
1154
+ return ChangeDetails.normalize(this.prepare ? this.prepare(str, this, flags) : str);
1155
+ }
1156
+
1157
+ /** Prepares each char before mask processing */
1158
+ doPrepareChar(str, flags) {
1159
+ if (flags === void 0) {
1160
+ flags = {};
1161
+ }
1162
+ return ChangeDetails.normalize(this.prepareChar ? this.prepareChar(str, this, flags) : str);
1163
+ }
1164
+
1165
+ /** Validates if value is acceptable */
1166
+ doValidate(flags) {
1167
+ return (!this.validate || this.validate(this.value, this, flags)) && (!this.parent || this.parent.doValidate(flags));
1168
+ }
1169
+
1170
+ /** Does additional processing at the end of editing */
1171
+ doCommit() {
1172
+ if (this.commit) this.commit(this.value, this);
1173
+ }
1174
+ splice(start, deleteCount, inserted, removeDirection, flags) {
1175
+ if (removeDirection === void 0) {
1176
+ removeDirection = DIRECTION.NONE;
1177
+ }
1178
+ if (flags === void 0) {
1179
+ flags = {
1180
+ input: true
1181
+ };
1182
+ }
1183
+ const tailPos = start + deleteCount;
1184
+ const tail = this.extractTail(tailPos);
1185
+ const eagerRemove = this.eager === true || this.eager === 'remove';
1186
+ let oldRawValue;
1187
+ if (eagerRemove) {
1188
+ removeDirection = forceDirection(removeDirection);
1189
+ oldRawValue = this.extractInput(0, tailPos, {
1190
+ raw: true
1191
+ });
1192
+ }
1193
+ let startChangePos = start;
1194
+ const details = new ChangeDetails();
1195
+
1196
+ // if it is just deletion without insertion
1197
+ if (removeDirection !== DIRECTION.NONE) {
1198
+ startChangePos = this.nearestInputPos(start, deleteCount > 1 && start !== 0 && !eagerRemove ? DIRECTION.NONE : removeDirection);
1199
+
1200
+ // adjust tailShift if start was aligned
1201
+ details.tailShift = startChangePos - start;
1202
+ }
1203
+ details.aggregate(this.remove(startChangePos));
1204
+ if (eagerRemove && removeDirection !== DIRECTION.NONE && oldRawValue === this.rawInputValue) {
1205
+ if (removeDirection === DIRECTION.FORCE_LEFT) {
1206
+ let valLength;
1207
+ while (oldRawValue === this.rawInputValue && (valLength = this.displayValue.length)) {
1208
+ details.aggregate(new ChangeDetails({
1209
+ tailShift: -1
1210
+ })).aggregate(this.remove(valLength - 1));
1211
+ }
1212
+ } else if (removeDirection === DIRECTION.FORCE_RIGHT) {
1213
+ tail.unshift();
1214
+ }
1215
+ }
1216
+ return details.aggregate(this.append(inserted, flags, tail));
1217
+ }
1218
+ maskEquals(mask) {
1219
+ return this.mask === mask;
1220
+ }
1221
+ typedValueEquals(value) {
1222
+ const tval = this.typedValue;
1223
+ return value === tval || Masked.EMPTY_VALUES.includes(value) && Masked.EMPTY_VALUES.includes(tval) || (this.format ? this.format(value, this) === this.format(this.typedValue, this) : false);
1224
+ }
1225
+ }
1226
+ Masked.DEFAULTS = {
1227
+ skipInvalid: true
1228
+ };
1229
+ Masked.EMPTY_VALUES = [undefined, null, ''];
1230
+ IMask.Masked = Masked;
1231
+
1232
+ class ChunksTailDetails {
1233
+ /** */
1234
+
1235
+ constructor(chunks, from) {
1236
+ if (chunks === void 0) {
1237
+ chunks = [];
1238
+ }
1239
+ if (from === void 0) {
1240
+ from = 0;
1241
+ }
1242
+ this.chunks = chunks;
1243
+ this.from = from;
1244
+ }
1245
+ toString() {
1246
+ return this.chunks.map(String).join('');
1247
+ }
1248
+ extend(tailChunk) {
1249
+ if (!String(tailChunk)) return;
1250
+ tailChunk = isString(tailChunk) ? new ContinuousTailDetails(String(tailChunk)) : tailChunk;
1251
+ const lastChunk = this.chunks[this.chunks.length - 1];
1252
+ const extendLast = lastChunk && (
1253
+ // if stops are same or tail has no stop
1254
+ lastChunk.stop === tailChunk.stop || tailChunk.stop == null) &&
1255
+ // if tail chunk goes just after last chunk
1256
+ tailChunk.from === lastChunk.from + lastChunk.toString().length;
1257
+ if (tailChunk instanceof ContinuousTailDetails) {
1258
+ // check the ability to extend previous chunk
1259
+ if (extendLast) {
1260
+ // extend previous chunk
1261
+ lastChunk.extend(tailChunk.toString());
1262
+ } else {
1263
+ // append new chunk
1264
+ this.chunks.push(tailChunk);
1265
+ }
1266
+ } else if (tailChunk instanceof ChunksTailDetails) {
1267
+ if (tailChunk.stop == null) {
1268
+ // unwrap floating chunks to parent, keeping `from` pos
1269
+ let firstTailChunk;
1270
+ while (tailChunk.chunks.length && tailChunk.chunks[0].stop == null) {
1271
+ firstTailChunk = tailChunk.chunks.shift(); // not possible to be `undefined` because length was checked above
1272
+ firstTailChunk.from += tailChunk.from;
1273
+ this.extend(firstTailChunk);
1274
+ }
1275
+ }
1276
+
1277
+ // if tail chunk still has value
1278
+ if (tailChunk.toString()) {
1279
+ // if chunks contains stops, then popup stop to container
1280
+ tailChunk.stop = tailChunk.blockIndex;
1281
+ this.chunks.push(tailChunk);
1282
+ }
1283
+ }
1284
+ }
1285
+ appendTo(masked) {
1286
+ if (!(masked instanceof IMask.MaskedPattern)) {
1287
+ const tail = new ContinuousTailDetails(this.toString());
1288
+ return tail.appendTo(masked);
1289
+ }
1290
+ const details = new ChangeDetails();
1291
+ for (let ci = 0; ci < this.chunks.length && !details.skip; ++ci) {
1292
+ const chunk = this.chunks[ci];
1293
+ const lastBlockIter = masked._mapPosToBlock(masked.displayValue.length);
1294
+ const stop = chunk.stop;
1295
+ let chunkBlock;
1296
+ if (stop != null && (
1297
+ // if block not found or stop is behind lastBlock
1298
+ !lastBlockIter || lastBlockIter.index <= stop)) {
1299
+ if (chunk instanceof ChunksTailDetails ||
1300
+ // for continuous block also check if stop is exist
1301
+ masked._stops.indexOf(stop) >= 0) {
1302
+ const phDetails = masked._appendPlaceholder(stop);
1303
+ details.aggregate(phDetails);
1304
+ }
1305
+ chunkBlock = chunk instanceof ChunksTailDetails && masked._blocks[stop];
1306
+ }
1307
+ if (chunkBlock) {
1308
+ const tailDetails = chunkBlock.appendTail(chunk);
1309
+ tailDetails.skip = false; // always ignore skip, it will be set on last
1310
+ details.aggregate(tailDetails);
1311
+ masked._value += tailDetails.inserted;
1312
+
1313
+ // get not inserted chars
1314
+ const remainChars = chunk.toString().slice(tailDetails.rawInserted.length);
1315
+ if (remainChars) details.aggregate(masked.append(remainChars, {
1316
+ tail: true
1317
+ }));
1318
+ } else {
1319
+ details.aggregate(masked.append(chunk.toString(), {
1320
+ tail: true
1321
+ }));
1322
+ }
1323
+ }
1324
+ return details;
1325
+ }
1326
+ get state() {
1327
+ return {
1328
+ chunks: this.chunks.map(c => c.state),
1329
+ from: this.from,
1330
+ stop: this.stop,
1331
+ blockIndex: this.blockIndex
1332
+ };
1333
+ }
1334
+ set state(state) {
1335
+ const {
1336
+ chunks,
1337
+ ...props
1338
+ } = state;
1339
+ Object.assign(this, props);
1340
+ this.chunks = chunks.map(cstate => {
1341
+ const chunk = "chunks" in cstate ? new ChunksTailDetails() : new ContinuousTailDetails();
1342
+ chunk.state = cstate;
1343
+ return chunk;
1344
+ });
1345
+ }
1346
+ unshift(beforePos) {
1347
+ if (!this.chunks.length || beforePos != null && this.from >= beforePos) return '';
1348
+ const chunkShiftPos = beforePos != null ? beforePos - this.from : beforePos;
1349
+ let ci = 0;
1350
+ while (ci < this.chunks.length) {
1351
+ const chunk = this.chunks[ci];
1352
+ const shiftChar = chunk.unshift(chunkShiftPos);
1353
+ if (chunk.toString()) {
1354
+ // chunk still contains value
1355
+ // but not shifted - means no more available chars to shift
1356
+ if (!shiftChar) break;
1357
+ ++ci;
1358
+ } else {
1359
+ // clean if chunk has no value
1360
+ this.chunks.splice(ci, 1);
1361
+ }
1362
+ if (shiftChar) return shiftChar;
1363
+ }
1364
+ return '';
1365
+ }
1366
+ shift() {
1367
+ if (!this.chunks.length) return '';
1368
+ let ci = this.chunks.length - 1;
1369
+ while (0 <= ci) {
1370
+ const chunk = this.chunks[ci];
1371
+ const shiftChar = chunk.shift();
1372
+ if (chunk.toString()) {
1373
+ // chunk still contains value
1374
+ // but not shifted - means no more available chars to shift
1375
+ if (!shiftChar) break;
1376
+ --ci;
1377
+ } else {
1378
+ // clean if chunk has no value
1379
+ this.chunks.splice(ci, 1);
1380
+ }
1381
+ if (shiftChar) return shiftChar;
1382
+ }
1383
+ return '';
1384
+ }
1385
+ }
1386
+
1387
+ class PatternCursor {
1388
+ constructor(masked, pos) {
1389
+ this.masked = masked;
1390
+ this._log = [];
1391
+ const {
1392
+ offset,
1393
+ index
1394
+ } = masked._mapPosToBlock(pos) || (pos < 0 ?
1395
+ // first
1396
+ {
1397
+ index: 0,
1398
+ offset: 0
1399
+ } :
1400
+ // last
1401
+ {
1402
+ index: this.masked._blocks.length,
1403
+ offset: 0
1404
+ });
1405
+ this.offset = offset;
1406
+ this.index = index;
1407
+ this.ok = false;
1408
+ }
1409
+ get block() {
1410
+ return this.masked._blocks[this.index];
1411
+ }
1412
+ get pos() {
1413
+ return this.masked._blockStartPos(this.index) + this.offset;
1414
+ }
1415
+ get state() {
1416
+ return {
1417
+ index: this.index,
1418
+ offset: this.offset,
1419
+ ok: this.ok
1420
+ };
1421
+ }
1422
+ set state(s) {
1423
+ Object.assign(this, s);
1424
+ }
1425
+ pushState() {
1426
+ this._log.push(this.state);
1427
+ }
1428
+ popState() {
1429
+ const s = this._log.pop();
1430
+ if (s) this.state = s;
1431
+ return s;
1432
+ }
1433
+ bindBlock() {
1434
+ if (this.block) return;
1435
+ if (this.index < 0) {
1436
+ this.index = 0;
1437
+ this.offset = 0;
1438
+ }
1439
+ if (this.index >= this.masked._blocks.length) {
1440
+ this.index = this.masked._blocks.length - 1;
1441
+ this.offset = this.block.displayValue.length; // TODO this is stupid type error, `block` depends on index that was changed above
1442
+ }
1443
+ }
1444
+
1445
+ _pushLeft(fn) {
1446
+ this.pushState();
1447
+ for (this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((_this$block = this.block) == null ? void 0 : _this$block.displayValue.length) || 0) {
1448
+ var _this$block;
1449
+ if (fn()) return this.ok = true;
1450
+ }
1451
+ return this.ok = false;
1452
+ }
1453
+ _pushRight(fn) {
1454
+ this.pushState();
1455
+ for (this.bindBlock(); this.index < this.masked._blocks.length; ++this.index, this.offset = 0) {
1456
+ if (fn()) return this.ok = true;
1457
+ }
1458
+ return this.ok = false;
1459
+ }
1460
+ pushLeftBeforeFilled() {
1461
+ return this._pushLeft(() => {
1462
+ if (this.block.isFixed || !this.block.value) return;
1463
+ this.offset = this.block.nearestInputPos(this.offset, DIRECTION.FORCE_LEFT);
1464
+ if (this.offset !== 0) return true;
1465
+ });
1466
+ }
1467
+ pushLeftBeforeInput() {
1468
+ // cases:
1469
+ // filled input: 00|
1470
+ // optional empty input: 00[]|
1471
+ // nested block: XX<[]>|
1472
+ return this._pushLeft(() => {
1473
+ if (this.block.isFixed) return;
1474
+ this.offset = this.block.nearestInputPos(this.offset, DIRECTION.LEFT);
1475
+ return true;
1476
+ });
1477
+ }
1478
+ pushLeftBeforeRequired() {
1479
+ return this._pushLeft(() => {
1480
+ if (this.block.isFixed || this.block.isOptional && !this.block.value) return;
1481
+ this.offset = this.block.nearestInputPos(this.offset, DIRECTION.LEFT);
1482
+ return true;
1483
+ });
1484
+ }
1485
+ pushRightBeforeFilled() {
1486
+ return this._pushRight(() => {
1487
+ if (this.block.isFixed || !this.block.value) return;
1488
+ this.offset = this.block.nearestInputPos(this.offset, DIRECTION.FORCE_RIGHT);
1489
+ if (this.offset !== this.block.value.length) return true;
1490
+ });
1491
+ }
1492
+ pushRightBeforeInput() {
1493
+ return this._pushRight(() => {
1494
+ if (this.block.isFixed) return;
1495
+
1496
+ // const o = this.offset;
1497
+ this.offset = this.block.nearestInputPos(this.offset, DIRECTION.NONE);
1498
+ // HACK cases like (STILL DOES NOT WORK FOR NESTED)
1499
+ // aa|X
1500
+ // aa<X|[]>X_ - this will not work
1501
+ // if (o && o === this.offset && this.block instanceof PatternInputDefinition) continue;
1502
+ return true;
1503
+ });
1504
+ }
1505
+ pushRightBeforeRequired() {
1506
+ return this._pushRight(() => {
1507
+ if (this.block.isFixed || this.block.isOptional && !this.block.value) return;
1508
+
1509
+ // TODO check |[*]XX_
1510
+ this.offset = this.block.nearestInputPos(this.offset, DIRECTION.NONE);
1511
+ return true;
1512
+ });
1513
+ }
1514
+ }
1515
+
1516
+ class PatternFixedDefinition {
1517
+ /** */
1518
+
1519
+ /** */
1520
+
1521
+ /** */
1522
+
1523
+ /** */
1524
+
1525
+ /** */
1526
+
1527
+ /** */
1528
+
1529
+ constructor(opts) {
1530
+ Object.assign(this, opts);
1531
+ this._value = '';
1532
+ this.isFixed = true;
1533
+ }
1534
+ get value() {
1535
+ return this._value;
1536
+ }
1537
+ get unmaskedValue() {
1538
+ return this.isUnmasking ? this.value : '';
1539
+ }
1540
+ get rawInputValue() {
1541
+ return this._isRawInput ? this.value : '';
1542
+ }
1543
+ get displayValue() {
1544
+ return this.value;
1545
+ }
1546
+ reset() {
1547
+ this._isRawInput = false;
1548
+ this._value = '';
1549
+ }
1550
+ remove(fromPos, toPos) {
1551
+ if (fromPos === void 0) {
1552
+ fromPos = 0;
1553
+ }
1554
+ if (toPos === void 0) {
1555
+ toPos = this._value.length;
1556
+ }
1557
+ this._value = this._value.slice(0, fromPos) + this._value.slice(toPos);
1558
+ if (!this._value) this._isRawInput = false;
1559
+ return new ChangeDetails();
1560
+ }
1561
+ nearestInputPos(cursorPos, direction) {
1562
+ if (direction === void 0) {
1563
+ direction = DIRECTION.NONE;
1564
+ }
1565
+ const minPos = 0;
1566
+ const maxPos = this._value.length;
1567
+ switch (direction) {
1568
+ case DIRECTION.LEFT:
1569
+ case DIRECTION.FORCE_LEFT:
1570
+ return minPos;
1571
+ case DIRECTION.NONE:
1572
+ case DIRECTION.RIGHT:
1573
+ case DIRECTION.FORCE_RIGHT:
1574
+ default:
1575
+ return maxPos;
1576
+ }
1577
+ }
1578
+ totalInputPositions(fromPos, toPos) {
1579
+ if (fromPos === void 0) {
1580
+ fromPos = 0;
1581
+ }
1582
+ if (toPos === void 0) {
1583
+ toPos = this._value.length;
1584
+ }
1585
+ return this._isRawInput ? toPos - fromPos : 0;
1586
+ }
1587
+ extractInput(fromPos, toPos, flags) {
1588
+ if (fromPos === void 0) {
1589
+ fromPos = 0;
1590
+ }
1591
+ if (toPos === void 0) {
1592
+ toPos = this._value.length;
1593
+ }
1594
+ if (flags === void 0) {
1595
+ flags = {};
1596
+ }
1597
+ return flags.raw && this._isRawInput && this._value.slice(fromPos, toPos) || '';
1598
+ }
1599
+ get isComplete() {
1600
+ return true;
1601
+ }
1602
+ get isFilled() {
1603
+ return Boolean(this._value);
1604
+ }
1605
+ _appendChar(ch, flags) {
1606
+ if (flags === void 0) {
1607
+ flags = {};
1608
+ }
1609
+ const details = new ChangeDetails();
1610
+ if (this.isFilled) return details;
1611
+ const appendEager = this.eager === true || this.eager === 'append';
1612
+ const appended = this.char === ch;
1613
+ const isResolved = appended && (this.isUnmasking || flags.input || flags.raw) && (!flags.raw || !appendEager) && !flags.tail;
1614
+ if (isResolved) details.rawInserted = this.char;
1615
+ this._value = details.inserted = this.char;
1616
+ this._isRawInput = isResolved && (flags.raw || flags.input);
1617
+ return details;
1618
+ }
1619
+ _appendEager() {
1620
+ return this._appendChar(this.char, {
1621
+ tail: true
1622
+ });
1623
+ }
1624
+ _appendPlaceholder() {
1625
+ const details = new ChangeDetails();
1626
+ if (this.isFilled) return details;
1627
+ this._value = details.inserted = this.char;
1628
+ return details;
1629
+ }
1630
+ extractTail() {
1631
+ return new ContinuousTailDetails('');
1632
+ }
1633
+ appendTail(tail) {
1634
+ if (isString(tail)) tail = new ContinuousTailDetails(String(tail));
1635
+ return tail.appendTo(this);
1636
+ }
1637
+ append(str, flags, tail) {
1638
+ const details = this._appendChar(str[0], flags);
1639
+ if (tail != null) {
1640
+ details.tailShift += this.appendTail(tail).tailShift;
1641
+ }
1642
+ return details;
1643
+ }
1644
+ doCommit() {}
1645
+ get state() {
1646
+ return {
1647
+ _value: this._value,
1648
+ _rawInputValue: this.rawInputValue
1649
+ };
1650
+ }
1651
+ set state(state) {
1652
+ this._value = state._value;
1653
+ this._isRawInput = Boolean(state._rawInputValue);
1654
+ }
1655
+ }
1656
+
1657
+ class PatternInputDefinition {
1658
+ /** */
1659
+
1660
+ /** */
1661
+
1662
+ /** */
1663
+
1664
+ /** */
1665
+
1666
+ /** */
1667
+
1668
+ /** */
1669
+
1670
+ /** */
1671
+
1672
+ /** */
1673
+
1674
+ constructor(opts) {
1675
+ const {
1676
+ parent,
1677
+ isOptional,
1678
+ placeholderChar,
1679
+ displayChar,
1680
+ lazy,
1681
+ eager,
1682
+ ...maskOpts
1683
+ } = opts;
1684
+ this.masked = createMask(maskOpts);
1685
+ Object.assign(this, {
1686
+ parent,
1687
+ isOptional,
1688
+ placeholderChar,
1689
+ displayChar,
1690
+ lazy,
1691
+ eager
1692
+ });
1693
+ }
1694
+ reset() {
1695
+ this.isFilled = false;
1696
+ this.masked.reset();
1697
+ }
1698
+ remove(fromPos, toPos) {
1699
+ if (fromPos === void 0) {
1700
+ fromPos = 0;
1701
+ }
1702
+ if (toPos === void 0) {
1703
+ toPos = this.value.length;
1704
+ }
1705
+ if (fromPos === 0 && toPos >= 1) {
1706
+ this.isFilled = false;
1707
+ return this.masked.remove(fromPos, toPos);
1708
+ }
1709
+ return new ChangeDetails();
1710
+ }
1711
+ get value() {
1712
+ return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : '');
1713
+ }
1714
+ get unmaskedValue() {
1715
+ return this.masked.unmaskedValue;
1716
+ }
1717
+ get rawInputValue() {
1718
+ return this.masked.rawInputValue;
1719
+ }
1720
+ get displayValue() {
1721
+ return this.masked.value && this.displayChar || this.value;
1722
+ }
1723
+ get isComplete() {
1724
+ return Boolean(this.masked.value) || this.isOptional;
1725
+ }
1726
+ _appendChar(ch, flags) {
1727
+ if (flags === void 0) {
1728
+ flags = {};
1729
+ }
1730
+ if (this.isFilled) return new ChangeDetails();
1731
+ const state = this.masked.state;
1732
+ // simulate input
1733
+ const details = this.masked._appendChar(ch, this.currentMaskFlags(flags));
1734
+ if (details.inserted && this.doValidate(flags) === false) {
1735
+ details.inserted = details.rawInserted = '';
1736
+ this.masked.state = state;
1737
+ }
1738
+ if (!details.inserted && !this.isOptional && !this.lazy && !flags.input) {
1739
+ details.inserted = this.placeholderChar;
1740
+ }
1741
+ details.skip = !details.inserted && !this.isOptional;
1742
+ this.isFilled = Boolean(details.inserted);
1743
+ return details;
1744
+ }
1745
+ append(str, flags, tail) {
1746
+ // TODO probably should be done via _appendChar
1747
+ return this.masked.append(str, this.currentMaskFlags(flags), tail);
1748
+ }
1749
+ _appendPlaceholder() {
1750
+ const details = new ChangeDetails();
1751
+ if (this.isFilled || this.isOptional) return details;
1752
+ this.isFilled = true;
1753
+ details.inserted = this.placeholderChar;
1754
+ return details;
1755
+ }
1756
+ _appendEager() {
1757
+ return new ChangeDetails();
1758
+ }
1759
+ extractTail(fromPos, toPos) {
1760
+ return this.masked.extractTail(fromPos, toPos);
1761
+ }
1762
+ appendTail(tail) {
1763
+ return this.masked.appendTail(tail);
1764
+ }
1765
+ extractInput(fromPos, toPos, flags) {
1766
+ if (fromPos === void 0) {
1767
+ fromPos = 0;
1768
+ }
1769
+ if (toPos === void 0) {
1770
+ toPos = this.value.length;
1771
+ }
1772
+ return this.masked.extractInput(fromPos, toPos, flags);
1773
+ }
1774
+ nearestInputPos(cursorPos, direction) {
1775
+ if (direction === void 0) {
1776
+ direction = DIRECTION.NONE;
1777
+ }
1778
+ const minPos = 0;
1779
+ const maxPos = this.value.length;
1780
+ const boundPos = Math.min(Math.max(cursorPos, minPos), maxPos);
1781
+ switch (direction) {
1782
+ case DIRECTION.LEFT:
1783
+ case DIRECTION.FORCE_LEFT:
1784
+ return this.isComplete ? boundPos : minPos;
1785
+ case DIRECTION.RIGHT:
1786
+ case DIRECTION.FORCE_RIGHT:
1787
+ return this.isComplete ? boundPos : maxPos;
1788
+ case DIRECTION.NONE:
1789
+ default:
1790
+ return boundPos;
1791
+ }
1792
+ }
1793
+ totalInputPositions(fromPos, toPos) {
1794
+ if (fromPos === void 0) {
1795
+ fromPos = 0;
1796
+ }
1797
+ if (toPos === void 0) {
1798
+ toPos = this.value.length;
1799
+ }
1800
+ return this.value.slice(fromPos, toPos).length;
1801
+ }
1802
+ doValidate(flags) {
1803
+ return this.masked.doValidate(this.currentMaskFlags(flags)) && (!this.parent || this.parent.doValidate(this.currentMaskFlags(flags)));
1804
+ }
1805
+ doCommit() {
1806
+ this.masked.doCommit();
1807
+ }
1808
+ get state() {
1809
+ return {
1810
+ _value: this.value,
1811
+ _rawInputValue: this.rawInputValue,
1812
+ masked: this.masked.state,
1813
+ isFilled: this.isFilled
1814
+ };
1815
+ }
1816
+ set state(state) {
1817
+ this.masked.state = state.masked;
1818
+ this.isFilled = state.isFilled;
1819
+ }
1820
+ currentMaskFlags(flags) {
1821
+ var _flags$_beforeTailSta;
1822
+ return {
1823
+ ...flags,
1824
+ _beforeTailState: (flags == null || (_flags$_beforeTailSta = flags._beforeTailState) == null ? void 0 : _flags$_beforeTailSta.masked) || (flags == null ? void 0 : flags._beforeTailState)
1825
+ };
1826
+ }
1827
+ }
1828
+ PatternInputDefinition.DEFAULT_DEFINITIONS = {
1829
+ '0': /\d/,
1830
+ 'a': /[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
1831
+ // http://stackoverflow.com/a/22075070
1832
+ '*': /./
1833
+ };
1834
+
1835
+ /** Masking by RegExp */
1836
+ class MaskedRegExp extends Masked {
1837
+ /** */
1838
+
1839
+ /** Enable characters overwriting */
1840
+
1841
+ /** */
1842
+
1843
+ /** */
1844
+
1845
+ updateOptions(opts) {
1846
+ super.updateOptions(opts);
1847
+ }
1848
+ _update(opts) {
1849
+ const mask = opts.mask;
1850
+ if (mask) opts.validate = value => value.search(mask) >= 0;
1851
+ super._update(opts);
1852
+ }
1853
+ }
1854
+ IMask.MaskedRegExp = MaskedRegExp;
1855
+
1856
+ /** Pattern mask */
1857
+ class MaskedPattern extends Masked {
1858
+ /** */
1859
+
1860
+ /** */
1861
+
1862
+ /** Single char for empty input */
1863
+
1864
+ /** Single char for filled input */
1865
+
1866
+ /** Show placeholder only when needed */
1867
+
1868
+ /** Enable characters overwriting */
1869
+
1870
+ /** */
1871
+
1872
+ /** */
1873
+
1874
+ constructor(opts) {
1875
+ super({
1876
+ ...MaskedPattern.DEFAULTS,
1877
+ ...opts,
1878
+ definitions: Object.assign({}, PatternInputDefinition.DEFAULT_DEFINITIONS, opts == null ? void 0 : opts.definitions)
1879
+ });
1880
+ }
1881
+ updateOptions(opts) {
1882
+ super.updateOptions(opts);
1883
+ }
1884
+ _update(opts) {
1885
+ opts.definitions = Object.assign({}, this.definitions, opts.definitions);
1886
+ super._update(opts);
1887
+ this._rebuildMask();
1888
+ }
1889
+ _rebuildMask() {
1890
+ const defs = this.definitions;
1891
+ this._blocks = [];
1892
+ this.exposeBlock = undefined;
1893
+ this._stops = [];
1894
+ this._maskedBlocks = {};
1895
+ const pattern = this.mask;
1896
+ if (!pattern || !defs) return;
1897
+ let unmaskingBlock = false;
1898
+ let optionalBlock = false;
1899
+ for (let i = 0; i < pattern.length; ++i) {
1900
+ if (this.blocks) {
1901
+ const p = pattern.slice(i);
1902
+ const bNames = Object.keys(this.blocks).filter(bName => p.indexOf(bName) === 0);
1903
+ // order by key length
1904
+ bNames.sort((a, b) => b.length - a.length);
1905
+ // use block name with max length
1906
+ const bName = bNames[0];
1907
+ if (bName) {
1908
+ const {
1909
+ expose,
1910
+ ...blockOpts
1911
+ } = normalizeOpts(this.blocks[bName]);
1912
+ const maskedBlock = createMask({
1913
+ lazy: this.lazy,
1914
+ eager: this.eager,
1915
+ placeholderChar: this.placeholderChar,
1916
+ displayChar: this.displayChar,
1917
+ overwrite: this.overwrite,
1918
+ ...blockOpts,
1919
+ parent: this
1920
+ });
1921
+ if (maskedBlock) {
1922
+ this._blocks.push(maskedBlock);
1923
+ if (expose) this.exposeBlock = maskedBlock;
1924
+
1925
+ // store block index
1926
+ if (!this._maskedBlocks[bName]) this._maskedBlocks[bName] = [];
1927
+ this._maskedBlocks[bName].push(this._blocks.length - 1);
1928
+ }
1929
+ i += bName.length - 1;
1930
+ continue;
1931
+ }
1932
+ }
1933
+ let char = pattern[i];
1934
+ let isInput = (char in defs);
1935
+ if (char === MaskedPattern.STOP_CHAR) {
1936
+ this._stops.push(this._blocks.length);
1937
+ continue;
1938
+ }
1939
+ if (char === '{' || char === '}') {
1940
+ unmaskingBlock = !unmaskingBlock;
1941
+ continue;
1942
+ }
1943
+ if (char === '[' || char === ']') {
1944
+ optionalBlock = !optionalBlock;
1945
+ continue;
1946
+ }
1947
+ if (char === MaskedPattern.ESCAPE_CHAR) {
1948
+ ++i;
1949
+ char = pattern[i];
1950
+ if (!char) break;
1951
+ isInput = false;
1952
+ }
1953
+ const def = isInput ? new PatternInputDefinition({
1954
+ isOptional: optionalBlock,
1955
+ lazy: this.lazy,
1956
+ eager: this.eager,
1957
+ placeholderChar: this.placeholderChar,
1958
+ displayChar: this.displayChar,
1959
+ ...normalizeOpts(defs[char]),
1960
+ parent: this
1961
+ }) : new PatternFixedDefinition({
1962
+ char,
1963
+ eager: this.eager,
1964
+ isUnmasking: unmaskingBlock
1965
+ });
1966
+ this._blocks.push(def);
1967
+ }
1968
+ }
1969
+ get state() {
1970
+ return {
1971
+ ...super.state,
1972
+ _blocks: this._blocks.map(b => b.state)
1973
+ };
1974
+ }
1975
+ set state(state) {
1976
+ const {
1977
+ _blocks,
1978
+ ...maskedState
1979
+ } = state;
1980
+ this._blocks.forEach((b, bi) => b.state = _blocks[bi]);
1981
+ super.state = maskedState;
1982
+ }
1983
+ reset() {
1984
+ super.reset();
1985
+ this._blocks.forEach(b => b.reset());
1986
+ }
1987
+ get isComplete() {
1988
+ return this.exposeBlock ? this.exposeBlock.isComplete : this._blocks.every(b => b.isComplete);
1989
+ }
1990
+ get isFilled() {
1991
+ return this._blocks.every(b => b.isFilled);
1992
+ }
1993
+ get isFixed() {
1994
+ return this._blocks.every(b => b.isFixed);
1995
+ }
1996
+ get isOptional() {
1997
+ return this._blocks.every(b => b.isOptional);
1998
+ }
1999
+ doCommit() {
2000
+ this._blocks.forEach(b => b.doCommit());
2001
+ super.doCommit();
2002
+ }
2003
+ get unmaskedValue() {
2004
+ return this.exposeBlock ? this.exposeBlock.unmaskedValue : this._blocks.reduce((str, b) => str += b.unmaskedValue, '');
2005
+ }
2006
+ set unmaskedValue(unmaskedValue) {
2007
+ if (this.exposeBlock) {
2008
+ const tail = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
2009
+ this.exposeBlock.unmaskedValue = unmaskedValue;
2010
+ this.appendTail(tail);
2011
+ this.doCommit();
2012
+ } else super.unmaskedValue = unmaskedValue;
2013
+ }
2014
+ get value() {
2015
+ return this.exposeBlock ? this.exposeBlock.value :
2016
+ // TODO return _value when not in change?
2017
+ this._blocks.reduce((str, b) => str += b.value, '');
2018
+ }
2019
+ set value(value) {
2020
+ if (this.exposeBlock) {
2021
+ const tail = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
2022
+ this.exposeBlock.value = value;
2023
+ this.appendTail(tail);
2024
+ this.doCommit();
2025
+ } else super.value = value;
2026
+ }
2027
+ get typedValue() {
2028
+ return this.exposeBlock ? this.exposeBlock.typedValue : super.typedValue;
2029
+ }
2030
+ set typedValue(value) {
2031
+ if (this.exposeBlock) {
2032
+ const tail = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
2033
+ this.exposeBlock.typedValue = value;
2034
+ this.appendTail(tail);
2035
+ this.doCommit();
2036
+ } else super.typedValue = value;
2037
+ }
2038
+ get displayValue() {
2039
+ return this._blocks.reduce((str, b) => str += b.displayValue, '');
2040
+ }
2041
+ appendTail(tail) {
2042
+ return super.appendTail(tail).aggregate(this._appendPlaceholder());
2043
+ }
2044
+ _appendEager() {
2045
+ var _this$_mapPosToBlock;
2046
+ const details = new ChangeDetails();
2047
+ let startBlockIndex = (_this$_mapPosToBlock = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : _this$_mapPosToBlock.index;
2048
+ if (startBlockIndex == null) return details;
2049
+
2050
+ // TODO test if it works for nested pattern masks
2051
+ if (this._blocks[startBlockIndex].isFilled) ++startBlockIndex;
2052
+ for (let bi = startBlockIndex; bi < this._blocks.length; ++bi) {
2053
+ const d = this._blocks[bi]._appendEager();
2054
+ if (!d.inserted) break;
2055
+ details.aggregate(d);
2056
+ }
2057
+ return details;
2058
+ }
2059
+ _appendCharRaw(ch, flags) {
2060
+ if (flags === void 0) {
2061
+ flags = {};
2062
+ }
2063
+ const blockIter = this._mapPosToBlock(this.displayValue.length);
2064
+ const details = new ChangeDetails();
2065
+ if (!blockIter) return details;
2066
+ for (let bi = blockIter.index;; ++bi) {
2067
+ var _flags$_beforeTailSta;
2068
+ const block = this._blocks[bi];
2069
+ if (!block) break;
2070
+ const blockDetails = block._appendChar(ch, {
2071
+ ...flags,
2072
+ _beforeTailState: (_flags$_beforeTailSta = flags._beforeTailState) == null || (_flags$_beforeTailSta = _flags$_beforeTailSta._blocks) == null ? void 0 : _flags$_beforeTailSta[bi]
2073
+ });
2074
+ const skip = blockDetails.skip;
2075
+ details.aggregate(blockDetails);
2076
+ if (skip || blockDetails.rawInserted) break; // go next char
2077
+ }
2078
+
2079
+ return details;
2080
+ }
2081
+ extractTail(fromPos, toPos) {
2082
+ if (fromPos === void 0) {
2083
+ fromPos = 0;
2084
+ }
2085
+ if (toPos === void 0) {
2086
+ toPos = this.displayValue.length;
2087
+ }
2088
+ const chunkTail = new ChunksTailDetails();
2089
+ if (fromPos === toPos) return chunkTail;
2090
+ this._forEachBlocksInRange(fromPos, toPos, (b, bi, bFromPos, bToPos) => {
2091
+ const blockChunk = b.extractTail(bFromPos, bToPos);
2092
+ blockChunk.stop = this._findStopBefore(bi);
2093
+ blockChunk.from = this._blockStartPos(bi);
2094
+ if (blockChunk instanceof ChunksTailDetails) blockChunk.blockIndex = bi;
2095
+ chunkTail.extend(blockChunk);
2096
+ });
2097
+ return chunkTail;
2098
+ }
2099
+ extractInput(fromPos, toPos, flags) {
2100
+ if (fromPos === void 0) {
2101
+ fromPos = 0;
2102
+ }
2103
+ if (toPos === void 0) {
2104
+ toPos = this.displayValue.length;
2105
+ }
2106
+ if (flags === void 0) {
2107
+ flags = {};
2108
+ }
2109
+ if (fromPos === toPos) return '';
2110
+ let input = '';
2111
+ this._forEachBlocksInRange(fromPos, toPos, (b, _, fromPos, toPos) => {
2112
+ input += b.extractInput(fromPos, toPos, flags);
2113
+ });
2114
+ return input;
2115
+ }
2116
+ _findStopBefore(blockIndex) {
2117
+ let stopBefore;
2118
+ for (let si = 0; si < this._stops.length; ++si) {
2119
+ const stop = this._stops[si];
2120
+ if (stop <= blockIndex) stopBefore = stop;else break;
2121
+ }
2122
+ return stopBefore;
2123
+ }
2124
+
2125
+ /** Appends placeholder depending on laziness */
2126
+ _appendPlaceholder(toBlockIndex) {
2127
+ const details = new ChangeDetails();
2128
+ if (this.lazy && toBlockIndex == null) return details;
2129
+ const startBlockIter = this._mapPosToBlock(this.displayValue.length);
2130
+ if (!startBlockIter) return details;
2131
+ const startBlockIndex = startBlockIter.index;
2132
+ const endBlockIndex = toBlockIndex != null ? toBlockIndex : this._blocks.length;
2133
+ this._blocks.slice(startBlockIndex, endBlockIndex).forEach(b => {
2134
+ if (!b.lazy || toBlockIndex != null) {
2135
+ var _blocks2;
2136
+ const bDetails = b._appendPlaceholder((_blocks2 = b._blocks) == null ? void 0 : _blocks2.length);
2137
+ this._value += bDetails.inserted;
2138
+ details.aggregate(bDetails);
2139
+ }
2140
+ });
2141
+ return details;
2142
+ }
2143
+
2144
+ /** Finds block in pos */
2145
+ _mapPosToBlock(pos) {
2146
+ let accVal = '';
2147
+ for (let bi = 0; bi < this._blocks.length; ++bi) {
2148
+ const block = this._blocks[bi];
2149
+ const blockStartPos = accVal.length;
2150
+ accVal += block.displayValue;
2151
+ if (pos <= accVal.length) {
2152
+ return {
2153
+ index: bi,
2154
+ offset: pos - blockStartPos
2155
+ };
2156
+ }
2157
+ }
2158
+ }
2159
+ _blockStartPos(blockIndex) {
2160
+ return this._blocks.slice(0, blockIndex).reduce((pos, b) => pos += b.displayValue.length, 0);
2161
+ }
2162
+ _forEachBlocksInRange(fromPos, toPos, fn) {
2163
+ if (toPos === void 0) {
2164
+ toPos = this.displayValue.length;
2165
+ }
2166
+ const fromBlockIter = this._mapPosToBlock(fromPos);
2167
+ if (fromBlockIter) {
2168
+ const toBlockIter = this._mapPosToBlock(toPos);
2169
+ // process first block
2170
+ const isSameBlock = toBlockIter && fromBlockIter.index === toBlockIter.index;
2171
+ const fromBlockStartPos = fromBlockIter.offset;
2172
+ const fromBlockEndPos = toBlockIter && isSameBlock ? toBlockIter.offset : this._blocks[fromBlockIter.index].displayValue.length;
2173
+ fn(this._blocks[fromBlockIter.index], fromBlockIter.index, fromBlockStartPos, fromBlockEndPos);
2174
+ if (toBlockIter && !isSameBlock) {
2175
+ // process intermediate blocks
2176
+ for (let bi = fromBlockIter.index + 1; bi < toBlockIter.index; ++bi) {
2177
+ fn(this._blocks[bi], bi, 0, this._blocks[bi].displayValue.length);
2178
+ }
2179
+
2180
+ // process last block
2181
+ fn(this._blocks[toBlockIter.index], toBlockIter.index, 0, toBlockIter.offset);
2182
+ }
2183
+ }
2184
+ }
2185
+ remove(fromPos, toPos) {
2186
+ if (fromPos === void 0) {
2187
+ fromPos = 0;
2188
+ }
2189
+ if (toPos === void 0) {
2190
+ toPos = this.displayValue.length;
2191
+ }
2192
+ const removeDetails = super.remove(fromPos, toPos);
2193
+ this._forEachBlocksInRange(fromPos, toPos, (b, _, bFromPos, bToPos) => {
2194
+ removeDetails.aggregate(b.remove(bFromPos, bToPos));
2195
+ });
2196
+ return removeDetails;
2197
+ }
2198
+ nearestInputPos(cursorPos, direction) {
2199
+ if (direction === void 0) {
2200
+ direction = DIRECTION.NONE;
2201
+ }
2202
+ if (!this._blocks.length) return 0;
2203
+ const cursor = new PatternCursor(this, cursorPos);
2204
+ if (direction === DIRECTION.NONE) {
2205
+ // -------------------------------------------------
2206
+ // NONE should only go out from fixed to the right!
2207
+ // -------------------------------------------------
2208
+ if (cursor.pushRightBeforeInput()) return cursor.pos;
2209
+ cursor.popState();
2210
+ if (cursor.pushLeftBeforeInput()) return cursor.pos;
2211
+ return this.displayValue.length;
2212
+ }
2213
+
2214
+ // FORCE is only about a|* otherwise is 0
2215
+ if (direction === DIRECTION.LEFT || direction === DIRECTION.FORCE_LEFT) {
2216
+ // try to break fast when *|a
2217
+ if (direction === DIRECTION.LEFT) {
2218
+ cursor.pushRightBeforeFilled();
2219
+ if (cursor.ok && cursor.pos === cursorPos) return cursorPos;
2220
+ cursor.popState();
2221
+ }
2222
+
2223
+ // forward flow
2224
+ cursor.pushLeftBeforeInput();
2225
+ cursor.pushLeftBeforeRequired();
2226
+ cursor.pushLeftBeforeFilled();
2227
+
2228
+ // backward flow
2229
+ if (direction === DIRECTION.LEFT) {
2230
+ cursor.pushRightBeforeInput();
2231
+ cursor.pushRightBeforeRequired();
2232
+ if (cursor.ok && cursor.pos <= cursorPos) return cursor.pos;
2233
+ cursor.popState();
2234
+ if (cursor.ok && cursor.pos <= cursorPos) return cursor.pos;
2235
+ cursor.popState();
2236
+ }
2237
+ if (cursor.ok) return cursor.pos;
2238
+ if (direction === DIRECTION.FORCE_LEFT) return 0;
2239
+ cursor.popState();
2240
+ if (cursor.ok) return cursor.pos;
2241
+ cursor.popState();
2242
+ if (cursor.ok) return cursor.pos;
2243
+ return 0;
2244
+ }
2245
+ if (direction === DIRECTION.RIGHT || direction === DIRECTION.FORCE_RIGHT) {
2246
+ // forward flow
2247
+ cursor.pushRightBeforeInput();
2248
+ cursor.pushRightBeforeRequired();
2249
+ if (cursor.pushRightBeforeFilled()) return cursor.pos;
2250
+ if (direction === DIRECTION.FORCE_RIGHT) return this.displayValue.length;
2251
+
2252
+ // backward flow
2253
+ cursor.popState();
2254
+ if (cursor.ok) return cursor.pos;
2255
+ cursor.popState();
2256
+ if (cursor.ok) return cursor.pos;
2257
+ return this.nearestInputPos(cursorPos, DIRECTION.LEFT);
2258
+ }
2259
+ return cursorPos;
2260
+ }
2261
+ totalInputPositions(fromPos, toPos) {
2262
+ if (fromPos === void 0) {
2263
+ fromPos = 0;
2264
+ }
2265
+ if (toPos === void 0) {
2266
+ toPos = this.displayValue.length;
2267
+ }
2268
+ let total = 0;
2269
+ this._forEachBlocksInRange(fromPos, toPos, (b, _, bFromPos, bToPos) => {
2270
+ total += b.totalInputPositions(bFromPos, bToPos);
2271
+ });
2272
+ return total;
2273
+ }
2274
+
2275
+ /** Get block by name */
2276
+ maskedBlock(name) {
2277
+ return this.maskedBlocks(name)[0];
2278
+ }
2279
+
2280
+ /** Get all blocks by name */
2281
+ maskedBlocks(name) {
2282
+ const indices = this._maskedBlocks[name];
2283
+ if (!indices) return [];
2284
+ return indices.map(gi => this._blocks[gi]);
2285
+ }
2286
+ }
2287
+ MaskedPattern.DEFAULTS = {
2288
+ lazy: true,
2289
+ placeholderChar: '_'
2290
+ };
2291
+ MaskedPattern.STOP_CHAR = '`';
2292
+ MaskedPattern.ESCAPE_CHAR = '\\';
2293
+ MaskedPattern.InputDefinition = PatternInputDefinition;
2294
+ MaskedPattern.FixedDefinition = PatternFixedDefinition;
2295
+ IMask.MaskedPattern = MaskedPattern;
2296
+
2297
+ /** Pattern which accepts ranges */
2298
+ class MaskedRange extends MaskedPattern {
2299
+ /**
2300
+ Optionally sets max length of pattern.
2301
+ Used when pattern length is longer then `to` param length. Pads zeros at start in this case.
2302
+ */
2303
+
2304
+ /** Min bound */
2305
+
2306
+ /** Max bound */
2307
+
2308
+ /** */
2309
+
2310
+ get _matchFrom() {
2311
+ return this.maxLength - String(this.from).length;
2312
+ }
2313
+ constructor(opts) {
2314
+ super(opts); // mask will be created in _update
2315
+ }
2316
+
2317
+ updateOptions(opts) {
2318
+ super.updateOptions(opts);
2319
+ }
2320
+ _update(opts) {
2321
+ const {
2322
+ to = this.to || 0,
2323
+ from = this.from || 0,
2324
+ maxLength = this.maxLength || 0,
2325
+ autofix = this.autofix,
2326
+ ...patternOpts
2327
+ } = opts;
2328
+ this.to = to;
2329
+ this.from = from;
2330
+ this.maxLength = Math.max(String(to).length, maxLength);
2331
+ this.autofix = autofix;
2332
+ const fromStr = String(this.from).padStart(this.maxLength, '0');
2333
+ const toStr = String(this.to).padStart(this.maxLength, '0');
2334
+ let sameCharsCount = 0;
2335
+ while (sameCharsCount < toStr.length && toStr[sameCharsCount] === fromStr[sameCharsCount]) ++sameCharsCount;
2336
+ patternOpts.mask = toStr.slice(0, sameCharsCount).replace(/0/g, '\\0') + '0'.repeat(this.maxLength - sameCharsCount);
2337
+ super._update(patternOpts);
2338
+ }
2339
+ get isComplete() {
2340
+ return super.isComplete && Boolean(this.value);
2341
+ }
2342
+ boundaries(str) {
2343
+ let minstr = '';
2344
+ let maxstr = '';
2345
+ const [, placeholder, num] = str.match(/^(\D*)(\d*)(\D*)/) || [];
2346
+ if (num) {
2347
+ minstr = '0'.repeat(placeholder.length) + num;
2348
+ maxstr = '9'.repeat(placeholder.length) + num;
2349
+ }
2350
+ minstr = minstr.padEnd(this.maxLength, '0');
2351
+ maxstr = maxstr.padEnd(this.maxLength, '9');
2352
+ return [minstr, maxstr];
2353
+ }
2354
+ doPrepareChar(ch, flags) {
2355
+ if (flags === void 0) {
2356
+ flags = {};
2357
+ }
2358
+ let details;
2359
+ [ch, details] = super.doPrepareChar(ch.replace(/\D/g, ''), flags);
2360
+ if (!this.autofix || !ch) return [ch, details];
2361
+ const fromStr = String(this.from).padStart(this.maxLength, '0');
2362
+ const toStr = String(this.to).padStart(this.maxLength, '0');
2363
+ const nextVal = this.value + ch;
2364
+ if (nextVal.length > this.maxLength) return ['', details];
2365
+ const [minstr, maxstr] = this.boundaries(nextVal);
2366
+ if (Number(maxstr) < this.from) return [fromStr[nextVal.length - 1], details];
2367
+ if (Number(minstr) > this.to) {
2368
+ if (this.autofix === 'pad' && nextVal.length < this.maxLength) {
2369
+ return ['', details.aggregate(this.append(fromStr[nextVal.length - 1] + ch, flags))];
2370
+ }
2371
+ return [toStr[nextVal.length - 1], details];
2372
+ }
2373
+ return [ch, details];
2374
+ }
2375
+ doValidate(flags) {
2376
+ const str = this.value;
2377
+ const firstNonZero = str.search(/[^0]/);
2378
+ if (firstNonZero === -1 && str.length <= this._matchFrom) return true;
2379
+ const [minstr, maxstr] = this.boundaries(str);
2380
+ return this.from <= Number(maxstr) && Number(minstr) <= this.to && super.doValidate(flags);
2381
+ }
2382
+ }
2383
+ IMask.MaskedRange = MaskedRange;
2384
+
2385
+ /** Date mask */
2386
+ class MaskedDate extends MaskedPattern {
2387
+ /** Pattern mask for date according to {@link MaskedDate#format} */
2388
+
2389
+ /** Start date */
2390
+
2391
+ /** End date */
2392
+
2393
+ /** */
2394
+
2395
+ /** Format typed value to string */
2396
+
2397
+ /** Parse string to get typed value */
2398
+
2399
+ constructor(opts) {
2400
+ const {
2401
+ mask,
2402
+ pattern,
2403
+ ...patternOpts
2404
+ } = {
2405
+ ...MaskedDate.DEFAULTS,
2406
+ ...opts
2407
+ };
2408
+ super({
2409
+ ...patternOpts,
2410
+ mask: isString(mask) ? mask : pattern
2411
+ });
2412
+ }
2413
+ updateOptions(opts) {
2414
+ super.updateOptions(opts);
2415
+ }
2416
+ _update(opts) {
2417
+ const {
2418
+ mask,
2419
+ pattern,
2420
+ blocks,
2421
+ ...patternOpts
2422
+ } = {
2423
+ ...MaskedDate.DEFAULTS,
2424
+ ...opts
2425
+ };
2426
+ const patternBlocks = Object.assign({}, MaskedDate.GET_DEFAULT_BLOCKS());
2427
+ // adjust year block
2428
+ if (opts.min) patternBlocks.Y.from = opts.min.getFullYear();
2429
+ if (opts.max) patternBlocks.Y.to = opts.max.getFullYear();
2430
+ if (opts.min && opts.max && patternBlocks.Y.from === patternBlocks.Y.to) {
2431
+ patternBlocks.m.from = opts.min.getMonth() + 1;
2432
+ patternBlocks.m.to = opts.max.getMonth() + 1;
2433
+ if (patternBlocks.m.from === patternBlocks.m.to) {
2434
+ patternBlocks.d.from = opts.min.getDate();
2435
+ patternBlocks.d.to = opts.max.getDate();
2436
+ }
2437
+ }
2438
+ Object.assign(patternBlocks, this.blocks, blocks);
2439
+
2440
+ // add autofix
2441
+ Object.keys(patternBlocks).forEach(bk => {
2442
+ const b = patternBlocks[bk];
2443
+ if (!('autofix' in b) && 'autofix' in opts) b.autofix = opts.autofix;
2444
+ });
2445
+ super._update({
2446
+ ...patternOpts,
2447
+ mask: isString(mask) ? mask : pattern,
2448
+ blocks: patternBlocks
2449
+ });
2450
+ }
2451
+ doValidate(flags) {
2452
+ const date = this.date;
2453
+ return super.doValidate(flags) && (!this.isComplete || this.isDateExist(this.value) && date != null && (this.min == null || this.min <= date) && (this.max == null || date <= this.max));
2454
+ }
2455
+
2456
+ /** Checks if date is exists */
2457
+ isDateExist(str) {
2458
+ return this.format(this.parse(str, this), this).indexOf(str) >= 0;
2459
+ }
2460
+
2461
+ /** Parsed Date */
2462
+ get date() {
2463
+ return this.typedValue;
2464
+ }
2465
+ set date(date) {
2466
+ this.typedValue = date;
2467
+ }
2468
+ get typedValue() {
2469
+ return this.isComplete ? super.typedValue : null;
2470
+ }
2471
+ set typedValue(value) {
2472
+ super.typedValue = value;
2473
+ }
2474
+ maskEquals(mask) {
2475
+ return mask === Date || super.maskEquals(mask);
2476
+ }
2477
+ }
2478
+ MaskedDate.GET_DEFAULT_BLOCKS = () => ({
2479
+ d: {
2480
+ mask: MaskedRange,
2481
+ from: 1,
2482
+ to: 31,
2483
+ maxLength: 2
2484
+ },
2485
+ m: {
2486
+ mask: MaskedRange,
2487
+ from: 1,
2488
+ to: 12,
2489
+ maxLength: 2
2490
+ },
2491
+ Y: {
2492
+ mask: MaskedRange,
2493
+ from: 1900,
2494
+ to: 9999
2495
+ }
2496
+ });
2497
+ MaskedDate.DEFAULTS = {
2498
+ mask: Date,
2499
+ pattern: 'd{.}`m{.}`Y',
2500
+ format: (date, masked) => {
2501
+ if (!date) return '';
2502
+ const day = String(date.getDate()).padStart(2, '0');
2503
+ const month = String(date.getMonth() + 1).padStart(2, '0');
2504
+ const year = date.getFullYear();
2505
+ return [day, month, year].join('.');
2506
+ },
2507
+ parse: (str, masked) => {
2508
+ const [day, month, year] = str.split('.').map(Number);
2509
+ return new Date(year, month - 1, day);
2510
+ }
2511
+ };
2512
+ IMask.MaskedDate = MaskedDate;
2513
+
2514
+ /** Dynamic mask for choosing appropriate mask in run-time */
2515
+ class MaskedDynamic extends Masked {
2516
+ /** Currently chosen mask */
2517
+
2518
+ /** Currently chosen mask */
2519
+
2520
+ /** Compliled {@link Masked} options */
2521
+
2522
+ /** Chooses {@link Masked} depending on input value */
2523
+
2524
+ constructor(opts) {
2525
+ super({
2526
+ ...MaskedDynamic.DEFAULTS,
2527
+ ...opts
2528
+ });
2529
+ this.currentMask = undefined;
2530
+ }
2531
+ updateOptions(opts) {
2532
+ super.updateOptions(opts);
2533
+ }
2534
+ _update(opts) {
2535
+ super._update(opts);
2536
+ if ('mask' in opts) {
2537
+ this.exposeMask = undefined;
2538
+ // mask could be totally dynamic with only `dispatch` option
2539
+ this.compiledMasks = Array.isArray(opts.mask) ? opts.mask.map(m => {
2540
+ const {
2541
+ expose,
2542
+ ...maskOpts
2543
+ } = normalizeOpts(m);
2544
+ const masked = createMask({
2545
+ overwrite: this._overwrite,
2546
+ eager: this._eager,
2547
+ skipInvalid: this._skipInvalid,
2548
+ ...maskOpts
2549
+ });
2550
+ if (expose) this.exposeMask = masked;
2551
+ return masked;
2552
+ }) : [];
2553
+
2554
+ // this.currentMask = this.doDispatch(''); // probably not needed but lets see
2555
+ }
2556
+ }
2557
+
2558
+ _appendCharRaw(ch, flags) {
2559
+ if (flags === void 0) {
2560
+ flags = {};
2561
+ }
2562
+ const details = this._applyDispatch(ch, flags);
2563
+ if (this.currentMask) {
2564
+ details.aggregate(this.currentMask._appendChar(ch, this.currentMaskFlags(flags)));
2565
+ }
2566
+ return details;
2567
+ }
2568
+ _applyDispatch(appended, flags, tail) {
2569
+ if (appended === void 0) {
2570
+ appended = '';
2571
+ }
2572
+ if (flags === void 0) {
2573
+ flags = {};
2574
+ }
2575
+ if (tail === void 0) {
2576
+ tail = '';
2577
+ }
2578
+ const prevValueBeforeTail = flags.tail && flags._beforeTailState != null ? flags._beforeTailState._value : this.value;
2579
+ const inputValue = this.rawInputValue;
2580
+ const insertValue = flags.tail && flags._beforeTailState != null ? flags._beforeTailState._rawInputValue : inputValue;
2581
+ const tailValue = inputValue.slice(insertValue.length);
2582
+ const prevMask = this.currentMask;
2583
+ const details = new ChangeDetails();
2584
+ const prevMaskState = prevMask == null ? void 0 : prevMask.state;
2585
+
2586
+ // clone flags to prevent overwriting `_beforeTailState`
2587
+ this.currentMask = this.doDispatch(appended, {
2588
+ ...flags
2589
+ }, tail);
2590
+
2591
+ // restore state after dispatch
2592
+ if (this.currentMask) {
2593
+ if (this.currentMask !== prevMask) {
2594
+ // if mask changed reapply input
2595
+ this.currentMask.reset();
2596
+ if (insertValue) {
2597
+ const d = this.currentMask.append(insertValue, {
2598
+ raw: true
2599
+ });
2600
+ details.tailShift = d.inserted.length - prevValueBeforeTail.length;
2601
+ }
2602
+ if (tailValue) {
2603
+ details.tailShift += this.currentMask.append(tailValue, {
2604
+ raw: true,
2605
+ tail: true
2606
+ }).tailShift;
2607
+ }
2608
+ } else if (prevMaskState) {
2609
+ // Dispatch can do something bad with state, so
2610
+ // restore prev mask state
2611
+ this.currentMask.state = prevMaskState;
2612
+ }
2613
+ }
2614
+ return details;
2615
+ }
2616
+ _appendPlaceholder() {
2617
+ const details = this._applyDispatch();
2618
+ if (this.currentMask) {
2619
+ details.aggregate(this.currentMask._appendPlaceholder());
2620
+ }
2621
+ return details;
2622
+ }
2623
+ _appendEager() {
2624
+ const details = this._applyDispatch();
2625
+ if (this.currentMask) {
2626
+ details.aggregate(this.currentMask._appendEager());
2627
+ }
2628
+ return details;
2629
+ }
2630
+ appendTail(tail) {
2631
+ const details = new ChangeDetails();
2632
+ if (tail) details.aggregate(this._applyDispatch('', {}, tail));
2633
+ return details.aggregate(this.currentMask ? this.currentMask.appendTail(tail) : super.appendTail(tail));
2634
+ }
2635
+ currentMaskFlags(flags) {
2636
+ var _flags$_beforeTailSta, _flags$_beforeTailSta2;
2637
+ return {
2638
+ ...flags,
2639
+ _beforeTailState: ((_flags$_beforeTailSta = flags._beforeTailState) == null ? void 0 : _flags$_beforeTailSta.currentMaskRef) === this.currentMask && ((_flags$_beforeTailSta2 = flags._beforeTailState) == null ? void 0 : _flags$_beforeTailSta2.currentMask) || flags._beforeTailState
2640
+ };
2641
+ }
2642
+ doDispatch(appended, flags, tail) {
2643
+ if (flags === void 0) {
2644
+ flags = {};
2645
+ }
2646
+ if (tail === void 0) {
2647
+ tail = '';
2648
+ }
2649
+ return this.dispatch(appended, this, flags, tail);
2650
+ }
2651
+ doValidate(flags) {
2652
+ return super.doValidate(flags) && (!this.currentMask || this.currentMask.doValidate(this.currentMaskFlags(flags)));
2653
+ }
2654
+ doPrepare(str, flags) {
2655
+ if (flags === void 0) {
2656
+ flags = {};
2657
+ }
2658
+ let [s, details] = super.doPrepare(str, flags);
2659
+ if (this.currentMask) {
2660
+ let currentDetails;
2661
+ [s, currentDetails] = super.doPrepare(s, this.currentMaskFlags(flags));
2662
+ details = details.aggregate(currentDetails);
2663
+ }
2664
+ return [s, details];
2665
+ }
2666
+ doPrepareChar(str, flags) {
2667
+ if (flags === void 0) {
2668
+ flags = {};
2669
+ }
2670
+ let [s, details] = super.doPrepareChar(str, flags);
2671
+ if (this.currentMask) {
2672
+ let currentDetails;
2673
+ [s, currentDetails] = super.doPrepareChar(s, this.currentMaskFlags(flags));
2674
+ details = details.aggregate(currentDetails);
2675
+ }
2676
+ return [s, details];
2677
+ }
2678
+ reset() {
2679
+ var _this$currentMask;
2680
+ (_this$currentMask = this.currentMask) == null ? void 0 : _this$currentMask.reset();
2681
+ this.compiledMasks.forEach(m => m.reset());
2682
+ }
2683
+ get value() {
2684
+ return this.exposeMask ? this.exposeMask.value : this.currentMask ? this.currentMask.value : '';
2685
+ }
2686
+ set value(value) {
2687
+ if (this.exposeMask) {
2688
+ this.exposeMask.value = value;
2689
+ this.currentMask = this.exposeMask;
2690
+ this._applyDispatch();
2691
+ } else super.value = value;
2692
+ }
2693
+ get unmaskedValue() {
2694
+ return this.exposeMask ? this.exposeMask.unmaskedValue : this.currentMask ? this.currentMask.unmaskedValue : '';
2695
+ }
2696
+ set unmaskedValue(unmaskedValue) {
2697
+ if (this.exposeMask) {
2698
+ this.exposeMask.unmaskedValue = unmaskedValue;
2699
+ this.currentMask = this.exposeMask;
2700
+ this._applyDispatch();
2701
+ } else super.unmaskedValue = unmaskedValue;
2702
+ }
2703
+ get typedValue() {
2704
+ return this.exposeMask ? this.exposeMask.typedValue : this.currentMask ? this.currentMask.typedValue : '';
2705
+ }
2706
+ set typedValue(typedValue) {
2707
+ if (this.exposeMask) {
2708
+ this.exposeMask.typedValue = typedValue;
2709
+ this.currentMask = this.exposeMask;
2710
+ this._applyDispatch();
2711
+ return;
2712
+ }
2713
+ let unmaskedValue = String(typedValue);
2714
+
2715
+ // double check it
2716
+ if (this.currentMask) {
2717
+ this.currentMask.typedValue = typedValue;
2718
+ unmaskedValue = this.currentMask.unmaskedValue;
2719
+ }
2720
+ this.unmaskedValue = unmaskedValue;
2721
+ }
2722
+ get displayValue() {
2723
+ return this.currentMask ? this.currentMask.displayValue : '';
2724
+ }
2725
+ get isComplete() {
2726
+ var _this$currentMask2;
2727
+ return Boolean((_this$currentMask2 = this.currentMask) == null ? void 0 : _this$currentMask2.isComplete);
2728
+ }
2729
+ get isFilled() {
2730
+ var _this$currentMask3;
2731
+ return Boolean((_this$currentMask3 = this.currentMask) == null ? void 0 : _this$currentMask3.isFilled);
2732
+ }
2733
+ remove(fromPos, toPos) {
2734
+ const details = new ChangeDetails();
2735
+ if (this.currentMask) {
2736
+ details.aggregate(this.currentMask.remove(fromPos, toPos))
2737
+ // update with dispatch
2738
+ .aggregate(this._applyDispatch());
2739
+ }
2740
+ return details;
2741
+ }
2742
+ get state() {
2743
+ var _this$currentMask4;
2744
+ return {
2745
+ ...super.state,
2746
+ _rawInputValue: this.rawInputValue,
2747
+ compiledMasks: this.compiledMasks.map(m => m.state),
2748
+ currentMaskRef: this.currentMask,
2749
+ currentMask: (_this$currentMask4 = this.currentMask) == null ? void 0 : _this$currentMask4.state
2750
+ };
2751
+ }
2752
+ set state(state) {
2753
+ const {
2754
+ compiledMasks,
2755
+ currentMaskRef,
2756
+ currentMask,
2757
+ ...maskedState
2758
+ } = state;
2759
+ if (compiledMasks) this.compiledMasks.forEach((m, mi) => m.state = compiledMasks[mi]);
2760
+ if (currentMaskRef != null) {
2761
+ this.currentMask = currentMaskRef;
2762
+ this.currentMask.state = currentMask;
2763
+ }
2764
+ super.state = maskedState;
2765
+ }
2766
+ extractInput(fromPos, toPos, flags) {
2767
+ return this.currentMask ? this.currentMask.extractInput(fromPos, toPos, flags) : '';
2768
+ }
2769
+ extractTail(fromPos, toPos) {
2770
+ return this.currentMask ? this.currentMask.extractTail(fromPos, toPos) : super.extractTail(fromPos, toPos);
2771
+ }
2772
+ doCommit() {
2773
+ if (this.currentMask) this.currentMask.doCommit();
2774
+ super.doCommit();
2775
+ }
2776
+ nearestInputPos(cursorPos, direction) {
2777
+ return this.currentMask ? this.currentMask.nearestInputPos(cursorPos, direction) : super.nearestInputPos(cursorPos, direction);
2778
+ }
2779
+ get overwrite() {
2780
+ return this.currentMask ? this.currentMask.overwrite : this._overwrite;
2781
+ }
2782
+ set overwrite(overwrite) {
2783
+ this._overwrite = overwrite;
2784
+ }
2785
+ get eager() {
2786
+ return this.currentMask ? this.currentMask.eager : this._eager;
2787
+ }
2788
+ set eager(eager) {
2789
+ this._eager = eager;
2790
+ }
2791
+ get skipInvalid() {
2792
+ return this.currentMask ? this.currentMask.skipInvalid : this._skipInvalid;
2793
+ }
2794
+ set skipInvalid(skipInvalid) {
2795
+ this._skipInvalid = skipInvalid;
2796
+ }
2797
+ maskEquals(mask) {
2798
+ return Array.isArray(mask) ? this.compiledMasks.every((m, mi) => {
2799
+ if (!mask[mi]) return;
2800
+ const {
2801
+ mask: oldMask,
2802
+ ...restOpts
2803
+ } = mask[mi];
2804
+ return objectIncludes(m, restOpts) && m.maskEquals(oldMask);
2805
+ }) : super.maskEquals(mask);
2806
+ }
2807
+ typedValueEquals(value) {
2808
+ var _this$currentMask5;
2809
+ return Boolean((_this$currentMask5 = this.currentMask) == null ? void 0 : _this$currentMask5.typedValueEquals(value));
2810
+ }
2811
+ }
2812
+ MaskedDynamic.DEFAULTS = void 0;
2813
+ MaskedDynamic.DEFAULTS = {
2814
+ dispatch: (appended, masked, flags, tail) => {
2815
+ if (!masked.compiledMasks.length) return;
2816
+ const inputValue = masked.rawInputValue;
2817
+
2818
+ // simulate input
2819
+ const inputs = masked.compiledMasks.map((m, index) => {
2820
+ const isCurrent = masked.currentMask === m;
2821
+ const startInputPos = isCurrent ? m.displayValue.length : m.nearestInputPos(m.displayValue.length, DIRECTION.FORCE_LEFT);
2822
+ if (m.rawInputValue !== inputValue) {
2823
+ m.reset();
2824
+ m.append(inputValue, {
2825
+ raw: true
2826
+ });
2827
+ } else if (!isCurrent) {
2828
+ m.remove(startInputPos);
2829
+ }
2830
+ m.append(appended, masked.currentMaskFlags(flags));
2831
+ m.appendTail(tail);
2832
+ return {
2833
+ index,
2834
+ weight: m.rawInputValue.length,
2835
+ totalInputPositions: m.totalInputPositions(0, Math.max(startInputPos, m.nearestInputPos(m.displayValue.length, DIRECTION.FORCE_LEFT)))
2836
+ };
2837
+ });
2838
+
2839
+ // pop masks with longer values first
2840
+ inputs.sort((i1, i2) => i2.weight - i1.weight || i2.totalInputPositions - i1.totalInputPositions);
2841
+ return masked.compiledMasks[inputs[0].index];
2842
+ }
2843
+ };
2844
+ IMask.MaskedDynamic = MaskedDynamic;
2845
+
2846
+ /** Pattern which validates enum values */
2847
+ class MaskedEnum extends MaskedPattern {
2848
+ constructor(opts) {
2849
+ super(opts); // mask will be created in _update
2850
+ }
2851
+
2852
+ updateOptions(opts) {
2853
+ super.updateOptions(opts);
2854
+ }
2855
+ _update(opts) {
2856
+ const {
2857
+ enum: _enum,
2858
+ ...eopts
2859
+ } = opts;
2860
+ if (_enum) {
2861
+ const lengths = _enum.map(e => e.length);
2862
+ const requiredLength = Math.min(...lengths);
2863
+ const optionalLength = Math.max(...lengths) - requiredLength;
2864
+ eopts.mask = '*'.repeat(requiredLength);
2865
+ if (optionalLength) eopts.mask += '[' + '*'.repeat(optionalLength) + ']';
2866
+ this.enum = _enum;
2867
+ }
2868
+ super._update(eopts);
2869
+ }
2870
+ doValidate(flags) {
2871
+ return this.enum.some(e => e.indexOf(this.unmaskedValue) === 0) && super.doValidate(flags);
2872
+ }
2873
+ }
2874
+ IMask.MaskedEnum = MaskedEnum;
2875
+
2876
+ /** Masking by custom Function */
2877
+ class MaskedFunction extends Masked {
2878
+ /** */
2879
+
2880
+ /** Enable characters overwriting */
2881
+
2882
+ /** */
2883
+
2884
+ /** */
2885
+
2886
+ updateOptions(opts) {
2887
+ super.updateOptions(opts);
2888
+ }
2889
+ _update(opts) {
2890
+ super._update({
2891
+ ...opts,
2892
+ validate: opts.mask
2893
+ });
2894
+ }
2895
+ }
2896
+ IMask.MaskedFunction = MaskedFunction;
2897
+
2898
+ /** Number mask */
2899
+ class MaskedNumber extends Masked {
2900
+ /** Single char */
2901
+
2902
+ /** Single char */
2903
+
2904
+ /** Array of single chars */
2905
+
2906
+ /** */
2907
+
2908
+ /** */
2909
+
2910
+ /** Digits after point */
2911
+
2912
+ /** Flag to remove leading and trailing zeros in the end of editing */
2913
+
2914
+ /** Flag to pad trailing zeros after point in the end of editing */
2915
+
2916
+ /** Enable characters overwriting */
2917
+
2918
+ /** */
2919
+
2920
+ /** */
2921
+
2922
+ /** Format typed value to string */
2923
+
2924
+ /** Parse string to get typed value */
2925
+
2926
+ constructor(opts) {
2927
+ super({
2928
+ ...MaskedNumber.DEFAULTS,
2929
+ ...opts
2930
+ });
2931
+ }
2932
+ updateOptions(opts) {
2933
+ super.updateOptions(opts);
2934
+ }
2935
+ _update(opts) {
2936
+ super._update(opts);
2937
+ this._updateRegExps();
2938
+ }
2939
+ _updateRegExps() {
2940
+ const start = '^' + (this.allowNegative ? '[+|\\-]?' : '');
2941
+ const mid = '\\d*';
2942
+ const end = (this.scale ? "(" + escapeRegExp(this.radix) + "\\d{0," + this.scale + "})?" : '') + '$';
2943
+ this._numberRegExp = new RegExp(start + mid + end);
2944
+ this._mapToRadixRegExp = new RegExp("[" + this.mapToRadix.map(escapeRegExp).join('') + "]", 'g');
2945
+ this._thousandsSeparatorRegExp = new RegExp(escapeRegExp(this.thousandsSeparator), 'g');
2946
+ }
2947
+ _removeThousandsSeparators(value) {
2948
+ return value.replace(this._thousandsSeparatorRegExp, '');
2949
+ }
2950
+ _insertThousandsSeparators(value) {
2951
+ // https://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript
2952
+ const parts = value.split(this.radix);
2953
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandsSeparator);
2954
+ return parts.join(this.radix);
2955
+ }
2956
+ doPrepareChar(ch, flags) {
2957
+ if (flags === void 0) {
2958
+ flags = {};
2959
+ }
2960
+ const [prepCh, details] = super.doPrepareChar(this._removeThousandsSeparators(this.scale && this.mapToRadix.length && (
2961
+ /*
2962
+ radix should be mapped when
2963
+ 1) input is done from keyboard = flags.input && flags.raw
2964
+ 2) unmasked value is set = !flags.input && !flags.raw
2965
+ and should not be mapped when
2966
+ 1) value is set = flags.input && !flags.raw
2967
+ 2) raw value is set = !flags.input && flags.raw
2968
+ */
2969
+ flags.input && flags.raw || !flags.input && !flags.raw) ? ch.replace(this._mapToRadixRegExp, this.radix) : ch), flags);
2970
+ if (ch && !prepCh) details.skip = true;
2971
+ if (prepCh && !this.allowPositive && !this.value && prepCh !== '-') details.aggregate(this._appendChar('-'));
2972
+ return [prepCh, details];
2973
+ }
2974
+ _separatorsCount(to, extendOnSeparators) {
2975
+ if (extendOnSeparators === void 0) {
2976
+ extendOnSeparators = false;
2977
+ }
2978
+ let count = 0;
2979
+ for (let pos = 0; pos < to; ++pos) {
2980
+ if (this._value.indexOf(this.thousandsSeparator, pos) === pos) {
2981
+ ++count;
2982
+ if (extendOnSeparators) to += this.thousandsSeparator.length;
2983
+ }
2984
+ }
2985
+ return count;
2986
+ }
2987
+ _separatorsCountFromSlice(slice) {
2988
+ if (slice === void 0) {
2989
+ slice = this._value;
2990
+ }
2991
+ return this._separatorsCount(this._removeThousandsSeparators(slice).length, true);
2992
+ }
2993
+ extractInput(fromPos, toPos, flags) {
2994
+ if (fromPos === void 0) {
2995
+ fromPos = 0;
2996
+ }
2997
+ if (toPos === void 0) {
2998
+ toPos = this.displayValue.length;
2999
+ }
3000
+ [fromPos, toPos] = this._adjustRangeWithSeparators(fromPos, toPos);
3001
+ return this._removeThousandsSeparators(super.extractInput(fromPos, toPos, flags));
3002
+ }
3003
+ _appendCharRaw(ch, flags) {
3004
+ if (flags === void 0) {
3005
+ flags = {};
3006
+ }
3007
+ if (!this.thousandsSeparator) return super._appendCharRaw(ch, flags);
3008
+ const prevBeforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
3009
+ const prevBeforeTailSeparatorsCount = this._separatorsCountFromSlice(prevBeforeTailValue);
3010
+ this._value = this._removeThousandsSeparators(this.value);
3011
+ const appendDetails = super._appendCharRaw(ch, flags);
3012
+ this._value = this._insertThousandsSeparators(this._value);
3013
+ const beforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
3014
+ const beforeTailSeparatorsCount = this._separatorsCountFromSlice(beforeTailValue);
3015
+ appendDetails.tailShift += (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length;
3016
+ appendDetails.skip = !appendDetails.rawInserted && ch === this.thousandsSeparator;
3017
+ return appendDetails;
3018
+ }
3019
+ _findSeparatorAround(pos) {
3020
+ if (this.thousandsSeparator) {
3021
+ const searchFrom = pos - this.thousandsSeparator.length + 1;
3022
+ const separatorPos = this.value.indexOf(this.thousandsSeparator, searchFrom);
3023
+ if (separatorPos <= pos) return separatorPos;
3024
+ }
3025
+ return -1;
3026
+ }
3027
+ _adjustRangeWithSeparators(from, to) {
3028
+ const separatorAroundFromPos = this._findSeparatorAround(from);
3029
+ if (separatorAroundFromPos >= 0) from = separatorAroundFromPos;
3030
+ const separatorAroundToPos = this._findSeparatorAround(to);
3031
+ if (separatorAroundToPos >= 0) to = separatorAroundToPos + this.thousandsSeparator.length;
3032
+ return [from, to];
3033
+ }
3034
+ remove(fromPos, toPos) {
3035
+ if (fromPos === void 0) {
3036
+ fromPos = 0;
3037
+ }
3038
+ if (toPos === void 0) {
3039
+ toPos = this.displayValue.length;
3040
+ }
3041
+ [fromPos, toPos] = this._adjustRangeWithSeparators(fromPos, toPos);
3042
+ const valueBeforePos = this.value.slice(0, fromPos);
3043
+ const valueAfterPos = this.value.slice(toPos);
3044
+ const prevBeforeTailSeparatorsCount = this._separatorsCount(valueBeforePos.length);
3045
+ this._value = this._insertThousandsSeparators(this._removeThousandsSeparators(valueBeforePos + valueAfterPos));
3046
+ const beforeTailSeparatorsCount = this._separatorsCountFromSlice(valueBeforePos);
3047
+ return new ChangeDetails({
3048
+ tailShift: (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length
3049
+ });
3050
+ }
3051
+ nearestInputPos(cursorPos, direction) {
3052
+ if (!this.thousandsSeparator) return cursorPos;
3053
+ switch (direction) {
3054
+ case DIRECTION.NONE:
3055
+ case DIRECTION.LEFT:
3056
+ case DIRECTION.FORCE_LEFT:
3057
+ {
3058
+ const separatorAtLeftPos = this._findSeparatorAround(cursorPos - 1);
3059
+ if (separatorAtLeftPos >= 0) {
3060
+ const separatorAtLeftEndPos = separatorAtLeftPos + this.thousandsSeparator.length;
3061
+ if (cursorPos < separatorAtLeftEndPos || this.value.length <= separatorAtLeftEndPos || direction === DIRECTION.FORCE_LEFT) {
3062
+ return separatorAtLeftPos;
3063
+ }
3064
+ }
3065
+ break;
3066
+ }
3067
+ case DIRECTION.RIGHT:
3068
+ case DIRECTION.FORCE_RIGHT:
3069
+ {
3070
+ const separatorAtRightPos = this._findSeparatorAround(cursorPos);
3071
+ if (separatorAtRightPos >= 0) {
3072
+ return separatorAtRightPos + this.thousandsSeparator.length;
3073
+ }
3074
+ }
3075
+ }
3076
+ return cursorPos;
3077
+ }
3078
+ doValidate(flags) {
3079
+ // validate as string
3080
+ let valid = Boolean(this._removeThousandsSeparators(this.value).match(this._numberRegExp));
3081
+ if (valid) {
3082
+ // validate as number
3083
+ const number = this.number;
3084
+ valid = valid && !isNaN(number) && (
3085
+ // check min bound for negative values
3086
+ this.min == null || this.min >= 0 || this.min <= this.number) && (
3087
+ // check max bound for positive values
3088
+ this.max == null || this.max <= 0 || this.number <= this.max);
3089
+ }
3090
+ return valid && super.doValidate(flags);
3091
+ }
3092
+ doCommit() {
3093
+ if (this.value) {
3094
+ const number = this.number;
3095
+ let validnum = number;
3096
+
3097
+ // check bounds
3098
+ if (this.min != null) validnum = Math.max(validnum, this.min);
3099
+ if (this.max != null) validnum = Math.min(validnum, this.max);
3100
+ if (validnum !== number) this.unmaskedValue = this.format(validnum, this);
3101
+ let formatted = this.value;
3102
+ if (this.normalizeZeros) formatted = this._normalizeZeros(formatted);
3103
+ if (this.padFractionalZeros && this.scale > 0) formatted = this._padFractionalZeros(formatted);
3104
+ this._value = formatted;
3105
+ }
3106
+ super.doCommit();
3107
+ }
3108
+ _normalizeZeros(value) {
3109
+ const parts = this._removeThousandsSeparators(value).split(this.radix);
3110
+
3111
+ // remove leading zeros
3112
+ parts[0] = parts[0].replace(/^(\D*)(0*)(\d*)/, (match, sign, zeros, num) => sign + num);
3113
+ // add leading zero
3114
+ if (value.length && !/\d$/.test(parts[0])) parts[0] = parts[0] + '0';
3115
+ if (parts.length > 1) {
3116
+ parts[1] = parts[1].replace(/0*$/, ''); // remove trailing zeros
3117
+ if (!parts[1].length) parts.length = 1; // remove fractional
3118
+ }
3119
+
3120
+ return this._insertThousandsSeparators(parts.join(this.radix));
3121
+ }
3122
+ _padFractionalZeros(value) {
3123
+ if (!value) return value;
3124
+ const parts = value.split(this.radix);
3125
+ if (parts.length < 2) parts.push('');
3126
+ parts[1] = parts[1].padEnd(this.scale, '0');
3127
+ return parts.join(this.radix);
3128
+ }
3129
+ doSkipInvalid(ch, flags, checkTail) {
3130
+ if (flags === void 0) {
3131
+ flags = {};
3132
+ }
3133
+ const dropFractional = this.scale === 0 && ch !== this.thousandsSeparator && (ch === this.radix || ch === MaskedNumber.UNMASKED_RADIX || this.mapToRadix.includes(ch));
3134
+ return super.doSkipInvalid(ch, flags, checkTail) && !dropFractional;
3135
+ }
3136
+ get unmaskedValue() {
3137
+ return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix, MaskedNumber.UNMASKED_RADIX);
3138
+ }
3139
+ set unmaskedValue(unmaskedValue) {
3140
+ super.unmaskedValue = unmaskedValue;
3141
+ }
3142
+ get typedValue() {
3143
+ return this.parse(this.unmaskedValue, this);
3144
+ }
3145
+ set typedValue(n) {
3146
+ this.rawInputValue = this.format(n, this).replace(MaskedNumber.UNMASKED_RADIX, this.radix);
3147
+ }
3148
+
3149
+ /** Parsed Number */
3150
+ get number() {
3151
+ return this.typedValue;
3152
+ }
3153
+ set number(number) {
3154
+ this.typedValue = number;
3155
+ }
3156
+
3157
+ /**
3158
+ Is negative allowed
3159
+ */
3160
+ get allowNegative() {
3161
+ return this.min != null && this.min < 0 || this.max != null && this.max < 0;
3162
+ }
3163
+
3164
+ /**
3165
+ Is positive allowed
3166
+ */
3167
+ get allowPositive() {
3168
+ return this.min != null && this.min > 0 || this.max != null && this.max > 0;
3169
+ }
3170
+ typedValueEquals(value) {
3171
+ // handle 0 -> '' case (typed = 0 even if value = '')
3172
+ // for details see https://github.com/uNmAnNeR/imaskjs/issues/134
3173
+ return (super.typedValueEquals(value) || MaskedNumber.EMPTY_VALUES.includes(value) && MaskedNumber.EMPTY_VALUES.includes(this.typedValue)) && !(value === 0 && this.value === '');
3174
+ }
3175
+ }
3176
+ MaskedNumber.UNMASKED_RADIX = '.';
3177
+ MaskedNumber.EMPTY_VALUES = [...Masked.EMPTY_VALUES, 0];
3178
+ MaskedNumber.DEFAULTS = {
3179
+ mask: Number,
3180
+ radix: ',',
3181
+ thousandsSeparator: '',
3182
+ mapToRadix: [MaskedNumber.UNMASKED_RADIX],
3183
+ min: Number.MIN_SAFE_INTEGER,
3184
+ max: Number.MAX_SAFE_INTEGER,
3185
+ scale: 2,
3186
+ normalizeZeros: true,
3187
+ padFractionalZeros: false,
3188
+ parse: Number,
3189
+ format: n => n.toLocaleString('en-US', {
3190
+ useGrouping: false,
3191
+ maximumFractionDigits: 20
3192
+ })
3193
+ };
3194
+ IMask.MaskedNumber = MaskedNumber;
3195
+
3196
+ /** Mask pipe source and destination types */
3197
+ const PIPE_TYPE = {
3198
+ MASKED: 'value',
3199
+ UNMASKED: 'unmaskedValue',
3200
+ TYPED: 'typedValue'
3201
+ };
3202
+ /** Creates new pipe function depending on mask type, source and destination options */
3203
+ function createPipe(arg, from, to) {
3204
+ if (from === void 0) {
3205
+ from = PIPE_TYPE.MASKED;
3206
+ }
3207
+ if (to === void 0) {
3208
+ to = PIPE_TYPE.MASKED;
3209
+ }
3210
+ const masked = createMask(arg);
3211
+ return value => masked.runIsolated(m => {
3212
+ m[from] = value;
3213
+ return m[to];
3214
+ });
3215
+ }
3216
+
3217
+ /** Pipes value through mask depending on mask type, source and destination options */
3218
+ function pipe(value, mask, from, to) {
3219
+ return createPipe(mask, from, to)(value);
3220
+ }
3221
+ IMask.PIPE_TYPE = PIPE_TYPE;
3222
+ IMask.createPipe = createPipe;
3223
+ IMask.pipe = pipe;
3224
+
3225
+ try {
3226
+ globalThis.IMask = IMask;
3227
+ } catch {}
3228
+
3229
+ export { IMask as I };
3230
+
3231
+ //# sourceMappingURL=index2.js.map