hemfixarna-web-components 1.6.1 → 1.6.2

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 (243) hide show
  1. package/dist/{collection/utils/api.js → hemfixarna-components/api-36f73d0d.js} +6 -4
  2. package/dist/hemfixarna-components/api-36f73d0d.js.map +1 -0
  3. package/dist/hemfixarna-components/app-globals-0f993ce5.js +5 -0
  4. package/dist/hemfixarna-components/app-globals-0f993ce5.js.map +1 -0
  5. package/dist/{collection/utils/calc.js → hemfixarna-components/calc-4c79b798.js} +6 -3
  6. package/dist/hemfixarna-components/calc-4c79b798.js.map +1 -0
  7. package/dist/hemfixarna-components/css-shim-62d2171c.js +6 -0
  8. package/dist/hemfixarna-components/css-shim-62d2171c.js.map +1 -0
  9. package/dist/hemfixarna-components/dom-46a68c9b.js +75 -0
  10. package/dist/hemfixarna-components/dom-46a68c9b.js.map +1 -0
  11. package/dist/{collection/utils/form.js → hemfixarna-components/form-c53dca29.js} +4 -2
  12. package/dist/hemfixarna-components/form-c53dca29.js.map +1 -0
  13. package/dist/{collection/components/hemfixarna-address/hemfixarna-address.js → hemfixarna-components/hemfixarna-address.entry.js} +14 -20
  14. package/dist/hemfixarna-components/hemfixarna-address.entry.js.map +1 -0
  15. package/dist/hemfixarna-components/hemfixarna-box.entry.js +49 -0
  16. package/dist/hemfixarna-components/hemfixarna-box.entry.js.map +1 -0
  17. package/dist/{collection/components/hemfixarna-breadcrumbs/hemfixarna-breadcrumbs.js → hemfixarna-components/hemfixarna-breadcrumbs.entry.js} +13 -84
  18. package/dist/hemfixarna-components/hemfixarna-breadcrumbs.entry.js.map +1 -0
  19. package/dist/hemfixarna-components/hemfixarna-byggmax.entry.js +27 -0
  20. package/dist/hemfixarna-components/hemfixarna-byggmax.entry.js.map +1 -0
  21. package/dist/{collection/components/hemfixarna-cart/hemfixarna-cart.js → hemfixarna-components/hemfixarna-cart.entry.js} +11 -31
  22. package/dist/hemfixarna-components/hemfixarna-cart.entry.js.map +1 -0
  23. package/dist/{collection/components/hemfixarna-category.tsx/hemfixarna-category.js → hemfixarna-components/hemfixarna-category.entry.js} +12 -6
  24. package/dist/hemfixarna-components/hemfixarna-category.entry.js.map +1 -0
  25. package/dist/{collection/components/hemfixarna-checkout/hemfixarna-checkout.js → hemfixarna-components/hemfixarna-checkout.entry.js} +38 -33
  26. package/dist/hemfixarna-components/hemfixarna-checkout.entry.js.map +1 -0
  27. package/dist/hemfixarna-components/hemfixarna-component.entry.js +248 -0
  28. package/dist/hemfixarna-components/hemfixarna-component.entry.js.map +1 -0
  29. package/dist/hemfixarna-components/hemfixarna-components.esm.js +162 -1
  30. package/dist/hemfixarna-components/hemfixarna-components.esm.js.map +1 -1
  31. package/dist/{collection/components/hemfixarna-contact/hemfixarna-contact.js → hemfixarna-components/hemfixarna-contact.entry.js} +10 -28
  32. package/dist/hemfixarna-components/hemfixarna-contact.entry.js.map +1 -0
  33. package/dist/{collection/components/hemfixarna-demo/hemfixarna-demo.js → hemfixarna-components/hemfixarna-demo.entry.js} +23 -46
  34. package/dist/hemfixarna-components/hemfixarna-demo.entry.js.map +1 -0
  35. package/dist/hemfixarna-components/hemfixarna-doro.entry.js +23 -0
  36. package/dist/hemfixarna-components/hemfixarna-doro.entry.js.map +1 -0
  37. package/dist/hemfixarna-components/hemfixarna-elfa.entry.js +24 -0
  38. package/dist/hemfixarna-components/hemfixarna-elfa.entry.js.map +1 -0
  39. package/dist/hemfixarna-components/hemfixarna-fargvaruhuset.entry.js +21 -0
  40. package/dist/hemfixarna-components/hemfixarna-fargvaruhuset.entry.js.map +1 -0
  41. package/dist/hemfixarna-components/hemfixarna-flyttsmart.entry.js +21 -0
  42. package/dist/hemfixarna-components/hemfixarna-flyttsmart.entry.js.map +1 -0
  43. package/dist/hemfixarna-components/hemfixarna-forebygg.entry.js +23 -0
  44. package/dist/hemfixarna-components/hemfixarna-forebygg.entry.js.map +1 -0
  45. package/dist/hemfixarna-components/hemfixarna-getuser.entry.js +770 -0
  46. package/dist/hemfixarna-components/hemfixarna-getuser.entry.js.map +1 -0
  47. package/dist/hemfixarna-components/hemfixarna-hornbach.entry.js +24 -0
  48. package/dist/hemfixarna-components/hemfixarna-hornbach.entry.js.map +1 -0
  49. package/dist/{collection/components/hemfixarna-info/hemfixarna-info.js → hemfixarna-components/hemfixarna-info.entry.js} +11 -7
  50. package/dist/hemfixarna-components/hemfixarna-info.entry.js.map +1 -0
  51. package/dist/{collection/components/hemfixarna-invoice/hemfixarna-invoice.js → hemfixarna-components/hemfixarna-invoice.entry.js} +16 -27
  52. package/dist/hemfixarna-components/hemfixarna-invoice.entry.js.map +1 -0
  53. package/dist/hemfixarna-components/hemfixarna-kbygg.entry.js +21 -0
  54. package/dist/hemfixarna-components/hemfixarna-kbygg.entry.js.map +1 -0
  55. package/dist/hemfixarna-components/hemfixarna-klint.entry.js +20 -0
  56. package/dist/hemfixarna-components/hemfixarna-klint.entry.js.map +1 -0
  57. package/dist/hemfixarna-components/hemfixarna-kund.entry.js +20 -0
  58. package/dist/hemfixarna-components/hemfixarna-kund.entry.js.map +1 -0
  59. package/dist/hemfixarna-components/hemfixarna-norrgavel.entry.js +21 -0
  60. package/dist/hemfixarna-components/hemfixarna-norrgavel.entry.js.map +1 -0
  61. package/dist/{collection/components/hemfixarna-order/hemfixarna-order.js → hemfixarna-components/hemfixarna-order.entry.js} +11 -31
  62. package/dist/hemfixarna-components/hemfixarna-order.entry.js.map +1 -0
  63. package/dist/{collection/components/hemfixarna-orderrows/hemfixarna-orderrows.js → hemfixarna-components/hemfixarna-orderrows.entry.js} +12 -50
  64. package/dist/hemfixarna-components/hemfixarna-orderrows.entry.js.map +1 -0
  65. package/dist/hemfixarna-components/hemfixarna-power.entry.js +21 -0
  66. package/dist/hemfixarna-components/hemfixarna-power.entry.js.map +1 -0
  67. package/dist/{collection/components/hemfixarna-product/hemfixarna-product.js → hemfixarna-components/hemfixarna-product.entry.js} +18 -27
  68. package/dist/hemfixarna-components/hemfixarna-product.entry.js.map +1 -0
  69. package/dist/{collection/components/hemfixarna-service/hemfixarna-service.js → hemfixarna-components/hemfixarna-service.entry.js} +12 -6
  70. package/dist/hemfixarna-components/hemfixarna-service.entry.js.map +1 -0
  71. package/dist/hemfixarna-components/hemfixarna-skanska.entry.js +24 -0
  72. package/dist/hemfixarna-components/hemfixarna-skanska.entry.js.map +1 -0
  73. package/dist/hemfixarna-components/hemfixarna-sparfonster.entry.js +21 -0
  74. package/dist/hemfixarna-components/hemfixarna-sparfonster.entry.js.map +1 -0
  75. package/dist/{collection/components/hemfixarna-start/hemfixarna-start.js → hemfixarna-components/hemfixarna-start.entry.js} +11 -48
  76. package/dist/hemfixarna-components/hemfixarna-start.entry.js.map +1 -0
  77. package/dist/hemfixarna-components/hemfixarna-string-furniture.entry.js +23 -0
  78. package/dist/hemfixarna-components/hemfixarna-string-furniture.entry.js.map +1 -0
  79. package/dist/hemfixarna-components/hemfixarna-superfront.entry.js +20 -0
  80. package/dist/hemfixarna-components/hemfixarna-superfront.entry.js.map +1 -0
  81. package/dist/hemfixarna-components/hemfixarna-tesla.entry.js +21 -0
  82. package/dist/hemfixarna-components/hemfixarna-tesla.entry.js.map +1 -0
  83. package/dist/hemfixarna-components/hemfixarna-traningspartner.entry.js +20 -0
  84. package/dist/hemfixarna-components/hemfixarna-traningspartner.entry.js.map +1 -0
  85. package/dist/hemfixarna-components/hemfixarna-zaptec.entry.js +21 -0
  86. package/dist/hemfixarna-components/hemfixarna-zaptec.entry.js.map +1 -0
  87. package/dist/hemfixarna-components/index-b6a6e994.js +256 -0
  88. package/dist/hemfixarna-components/index-b6a6e994.js.map +1 -0
  89. package/dist/{collection/types/index.js → hemfixarna-components/index-d90ad11b.js} +7 -4
  90. package/dist/hemfixarna-components/index-d90ad11b.js.map +1 -0
  91. package/dist/hemfixarna-components/index-f1a87cf1.js +3397 -0
  92. package/dist/{cjs/hemfixarna-address_36.cjs.entry.js.map → hemfixarna-components/index-f1a87cf1.js.map} +1 -1
  93. package/dist/hemfixarna-components/index.esm.js +1 -0
  94. package/dist/hemfixarna-components/index.esm.js.map +1 -1
  95. package/dist/{collection/utils/scroll.js → hemfixarna-components/scroll-6c26b5da.js} +4 -2
  96. package/dist/hemfixarna-components/scroll-6c26b5da.js.map +1 -0
  97. package/dist/hemfixarna-components/shadow-css-05e0c1f4.js +389 -0
  98. package/dist/hemfixarna-components/shadow-css-05e0c1f4.js.map +1 -0
  99. package/dist/{collection/utils/types.js → hemfixarna-components/types-641c9a1c.js} +6 -3
  100. package/dist/hemfixarna-components/types-641c9a1c.js.map +1 -0
  101. package/package.json +1 -1
  102. package/dist/cjs/hemfixarna-address_36.cjs.entry.js +0 -2763
  103. package/dist/cjs/hemfixarna-components.cjs.js +0 -28
  104. package/dist/cjs/hemfixarna-components.cjs.js.map +0 -1
  105. package/dist/cjs/index-b83343b9.js +0 -1687
  106. package/dist/cjs/index-b83343b9.js.map +0 -1
  107. package/dist/cjs/index.cjs.js +0 -4
  108. package/dist/cjs/index.cjs.js.map +0 -1
  109. package/dist/cjs/loader.cjs.js +0 -24
  110. package/dist/cjs/loader.cjs.js.map +0 -1
  111. package/dist/collection/assets/back.svg +0 -3
  112. package/dist/collection/assets/cart.svg +0 -10
  113. package/dist/collection/assets/checked.svg +0 -10
  114. package/dist/collection/assets/close.svg +0 -5
  115. package/dist/collection/assets/copy.png +0 -0
  116. package/dist/collection/assets/date.svg +0 -6
  117. package/dist/collection/assets/down.svg +0 -3
  118. package/dist/collection/assets/drag-drop.svg +0 -3
  119. package/dist/collection/assets/elfa.png +0 -0
  120. package/dist/collection/assets/gubbe-pensel.svg +0 -1
  121. package/dist/collection/assets/hemfixarna.svg +0 -11
  122. package/dist/collection/assets/hornbach/logo.svg +0 -42
  123. package/dist/collection/assets/hornbach/nav.jpg +0 -0
  124. package/dist/collection/assets/info.svg +0 -5
  125. package/dist/collection/assets/kbygg.svg +0 -29
  126. package/dist/collection/assets/minus.svg +0 -4
  127. package/dist/collection/assets/montering.svg +0 -15
  128. package/dist/collection/assets/norrgavel.svg +0 -1
  129. package/dist/collection/assets/pensel.svg +0 -1
  130. package/dist/collection/assets/plus.svg +0 -5
  131. package/dist/collection/assets/spinner.gif +0 -0
  132. package/dist/collection/assets/tesla.svg +0 -1
  133. package/dist/collection/assets/zaptec.svg +0 -1
  134. package/dist/collection/collection-manifest.json +0 -47
  135. package/dist/collection/components/customers/hemfixarna-byggmax/hemfixarna-byggmax.css +0 -0
  136. package/dist/collection/components/customers/hemfixarna-byggmax/hemfixarna-byggmax.js +0 -184
  137. package/dist/collection/components/customers/hemfixarna-byggmax/hemfixarna-byggmax.js.map +0 -1
  138. package/dist/collection/components/customers/hemfixarna-doro/hemfixarna-doro.css +0 -0
  139. package/dist/collection/components/customers/hemfixarna-doro/hemfixarna-doro.js +0 -123
  140. package/dist/collection/components/customers/hemfixarna-doro/hemfixarna-doro.js.map +0 -1
  141. package/dist/collection/components/customers/hemfixarna-elfa/hemfixarna-elfa.css +0 -0
  142. package/dist/collection/components/customers/hemfixarna-elfa/hemfixarna-elfa.js +0 -142
  143. package/dist/collection/components/customers/hemfixarna-elfa/hemfixarna-elfa.js.map +0 -1
  144. package/dist/collection/components/customers/hemfixarna-fargvaruhuset/hemfixarna-fargvaruhuset.js +0 -132
  145. package/dist/collection/components/customers/hemfixarna-fargvaruhuset/hemfixarna-fargvaruhuset.js.map +0 -1
  146. package/dist/collection/components/customers/hemfixarna-flyttsmart/hemfixarna-flyttsmart.js +0 -132
  147. package/dist/collection/components/customers/hemfixarna-flyttsmart/hemfixarna-flyttsmart.js.map +0 -1
  148. package/dist/collection/components/customers/hemfixarna-forebygg/hemfixarna-forebygg.css +0 -0
  149. package/dist/collection/components/customers/hemfixarna-forebygg/hemfixarna-forebygg.js +0 -123
  150. package/dist/collection/components/customers/hemfixarna-forebygg/hemfixarna-forebygg.js.map +0 -1
  151. package/dist/collection/components/customers/hemfixarna-hornbach/hemfixarna-hornbach.css +0 -0
  152. package/dist/collection/components/customers/hemfixarna-hornbach/hemfixarna-hornbach.js +0 -142
  153. package/dist/collection/components/customers/hemfixarna-hornbach/hemfixarna-hornbach.js.map +0 -1
  154. package/dist/collection/components/customers/hemfixarna-kbygg/hemfixarna-kbygg.js +0 -132
  155. package/dist/collection/components/customers/hemfixarna-kbygg/hemfixarna-kbygg.js.map +0 -1
  156. package/dist/collection/components/customers/hemfixarna-klint/hemfixarna-klint.js +0 -113
  157. package/dist/collection/components/customers/hemfixarna-klint/hemfixarna-klint.js.map +0 -1
  158. package/dist/collection/components/customers/hemfixarna-kund/hemfixarna-kund.js +0 -113
  159. package/dist/collection/components/customers/hemfixarna-kund/hemfixarna-kund.js.map +0 -1
  160. package/dist/collection/components/customers/hemfixarna-norrgavel/hemfixarna-norrgavel.js +0 -132
  161. package/dist/collection/components/customers/hemfixarna-norrgavel/hemfixarna-norrgavel.js.map +0 -1
  162. package/dist/collection/components/customers/hemfixarna-power/hemfixarna-power.js +0 -131
  163. package/dist/collection/components/customers/hemfixarna-power/hemfixarna-power.js.map +0 -1
  164. package/dist/collection/components/customers/hemfixarna-skanska/hemfixarna-skanska.css +0 -0
  165. package/dist/collection/components/customers/hemfixarna-skanska/hemfixarna-skanska.js +0 -141
  166. package/dist/collection/components/customers/hemfixarna-skanska/hemfixarna-skanska.js.map +0 -1
  167. package/dist/collection/components/customers/hemfixarna-sparfonster/hemfixarna-sparfonster.js +0 -131
  168. package/dist/collection/components/customers/hemfixarna-sparfonster/hemfixarna-sparfonster.js.map +0 -1
  169. package/dist/collection/components/customers/hemfixarna-string/hemfixarna-string-furniture.js +0 -123
  170. package/dist/collection/components/customers/hemfixarna-string/hemfixarna-string-furniture.js.map +0 -1
  171. package/dist/collection/components/customers/hemfixarna-string/hemfixarna-string.css +0 -0
  172. package/dist/collection/components/customers/hemfixarna-superfront.tsx/hemfixarna-superfront.js +0 -113
  173. package/dist/collection/components/customers/hemfixarna-superfront.tsx/hemfixarna-superfront.js.map +0 -1
  174. package/dist/collection/components/customers/hemfixarna-tesla/hemfixarna-tesla.js +0 -132
  175. package/dist/collection/components/customers/hemfixarna-tesla/hemfixarna-tesla.js.map +0 -1
  176. package/dist/collection/components/customers/hemfixarna-traningspartner/hemfixarna-traningspartner.js +0 -113
  177. package/dist/collection/components/customers/hemfixarna-traningspartner/hemfixarna-traningspartner.js.map +0 -1
  178. package/dist/collection/components/customers/hemfixarna-zaptec/hemfixarna-zaptec.js +0 -132
  179. package/dist/collection/components/customers/hemfixarna-zaptec/hemfixarna-zaptec.js.map +0 -1
  180. package/dist/collection/components/hemfixarna-address/hemfixarna-address.js.map +0 -1
  181. package/dist/collection/components/hemfixarna-box/hemfixarna-box.js +0 -138
  182. package/dist/collection/components/hemfixarna-box/hemfixarna-box.js.map +0 -1
  183. package/dist/collection/components/hemfixarna-breadcrumbs/hemfixarna-breadcrumbs.js.map +0 -1
  184. package/dist/collection/components/hemfixarna-cart/hemfixarna-cart.js.map +0 -1
  185. package/dist/collection/components/hemfixarna-category.tsx/hemfixarna-category.js.map +0 -1
  186. package/dist/collection/components/hemfixarna-checkout/hemfixarna-checkout.js.map +0 -1
  187. package/dist/collection/components/hemfixarna-component/hemfixarna-component.js +0 -483
  188. package/dist/collection/components/hemfixarna-component/hemfixarna-component.js.map +0 -1
  189. package/dist/collection/components/hemfixarna-component/hemfixarna.css +0 -1031
  190. package/dist/collection/components/hemfixarna-contact/hemfixarna-contact.js.map +0 -1
  191. package/dist/collection/components/hemfixarna-demo/hemfixarna-demo.css +0 -135
  192. package/dist/collection/components/hemfixarna-demo/hemfixarna-demo.js.map +0 -1
  193. package/dist/collection/components/hemfixarna-getuser/hemfixarna-getuser.js +0 -91
  194. package/dist/collection/components/hemfixarna-getuser/hemfixarna-getuser.js.map +0 -1
  195. package/dist/collection/components/hemfixarna-info/hemfixarna-info.js.map +0 -1
  196. package/dist/collection/components/hemfixarna-invoice/hemfixarna-invoice.css +0 -76
  197. package/dist/collection/components/hemfixarna-invoice/hemfixarna-invoice.js.map +0 -1
  198. package/dist/collection/components/hemfixarna-order/hemfixarna-order.js.map +0 -1
  199. package/dist/collection/components/hemfixarna-orderrows/hemfixarna-orderrows.js.map +0 -1
  200. package/dist/collection/components/hemfixarna-product/hemfixarna-product.css +0 -0
  201. package/dist/collection/components/hemfixarna-product/hemfixarna-product.js.map +0 -1
  202. package/dist/collection/components/hemfixarna-service/hemfixarna-service.js.map +0 -1
  203. package/dist/collection/components/hemfixarna-start/hemfixarna-start.js.map +0 -1
  204. package/dist/collection/index.js +0 -2
  205. package/dist/collection/index.js.map +0 -1
  206. package/dist/collection/store/index.js +0 -62
  207. package/dist/collection/store/index.js.map +0 -1
  208. package/dist/collection/types/felixtypes.js +0 -3
  209. package/dist/collection/types/felixtypes.js.map +0 -1
  210. package/dist/collection/types/index.js.map +0 -1
  211. package/dist/collection/utils/api.js.map +0 -1
  212. package/dist/collection/utils/calc.js.map +0 -1
  213. package/dist/collection/utils/creditSafe.js +0 -18
  214. package/dist/collection/utils/creditSafe.js.map +0 -1
  215. package/dist/collection/utils/felixApi.js +0 -18
  216. package/dist/collection/utils/felixApi.js.map +0 -1
  217. package/dist/collection/utils/felixFunctions.js +0 -189
  218. package/dist/collection/utils/felixFunctions.js.map +0 -1
  219. package/dist/collection/utils/form.js.map +0 -1
  220. package/dist/collection/utils/scroll.js.map +0 -1
  221. package/dist/collection/utils/types.js.map +0 -1
  222. package/dist/esm/hemfixarna-address_36.entry.js +0 -2724
  223. package/dist/esm/hemfixarna-address_36.entry.js.map +0 -1
  224. package/dist/esm/hemfixarna-components.js +0 -23
  225. package/dist/esm/hemfixarna-components.js.map +0 -1
  226. package/dist/esm/index-8c417125.js +0 -1656
  227. package/dist/esm/index-8c417125.js.map +0 -1
  228. package/dist/esm/index.js +0 -3
  229. package/dist/esm/index.js.map +0 -1
  230. package/dist/esm/loader.js +0 -20
  231. package/dist/esm/loader.js.map +0 -1
  232. package/dist/esm/polyfills/core-js.js +0 -11
  233. package/dist/esm/polyfills/css-shim.js +0 -1
  234. package/dist/esm/polyfills/dom.js +0 -79
  235. package/dist/esm/polyfills/es5-html-element.js +0 -1
  236. package/dist/esm/polyfills/index.js +0 -34
  237. package/dist/esm/polyfills/system.js +0 -6
  238. package/dist/hemfixarna-components/p-211cfa04.entry.js +0 -2
  239. package/dist/hemfixarna-components/p-211cfa04.entry.js.map +0 -1
  240. package/dist/hemfixarna-components/p-852e7173.js +0 -3
  241. package/dist/hemfixarna-components/p-852e7173.js.map +0 -1
  242. package/dist/index.cjs.js +0 -1
  243. package/dist/index.js +0 -1
@@ -0,0 +1,770 @@
1
+ import { r as registerInstance, h, e as getElement } from './index-f1a87cf1.js';
2
+ import { s as state } from './index-b6a6e994.js';
3
+ import { s as scrollToTop } from './scroll-6c26b5da.js';
4
+
5
+ // src/errors.ts
6
+ var PersonnummerError = class extends Error {
7
+ constructor() {
8
+ super("Invalid swedish personal identity number");
9
+ }
10
+ };
11
+
12
+ // src/utils.ts
13
+ var compareAsc = (dateLeft, dateRight) => {
14
+ const diff = dateLeft.getTime() - dateRight.getTime();
15
+ return diff < 0 ? -1 : diff > 0 ? 1 : diff;
16
+ };
17
+ var diffInYears = (dateLeft, dateRight) => {
18
+ const sign = compareAsc(dateLeft, dateRight);
19
+ const yearDiff = Math.abs(dateLeft.getFullYear() - dateRight.getFullYear());
20
+ dateLeft.setFullYear(dateLeft.getFullYear() - sign * yearDiff);
21
+ const isLastYearNotFull = compareAsc(dateLeft, dateRight) === -sign;
22
+ const result = sign * (yearDiff - +isLastYearNotFull);
23
+ return result === 0 ? 0 : result;
24
+ };
25
+ var luhn = (str) => {
26
+ let sum = 0;
27
+ str += "";
28
+ for (let i = 0, l = str.length; i < l; i++) {
29
+ let v = parseInt(str[i]);
30
+ v *= 2 - i % 2;
31
+ if (v > 9) {
32
+ v -= 9;
33
+ }
34
+ sum += v;
35
+ }
36
+ return Math.ceil(sum / 10) * 10 - sum;
37
+ };
38
+ var testDate = (year, month, day) => {
39
+ month -= 1;
40
+ const date = new Date(year, month, day);
41
+ return !(date.getFullYear() !== year || date.getMonth() !== month || date.getDate() !== day);
42
+ };
43
+
44
+ // src/index.ts
45
+ var Personnummer = class {
46
+ /**
47
+ * Personnummer constructor.
48
+ *
49
+ * @param {string} pin
50
+ * @param {object} options
51
+ */
52
+ constructor(pin, options) {
53
+ /**
54
+ * Personnummer century.
55
+ *
56
+ * @var {string}
57
+ */
58
+ this._century = "";
59
+ /**
60
+ * Personnummer full year.
61
+ *
62
+ * @var {string}
63
+ */
64
+ this._fullYear = "";
65
+ /**
66
+ * Personnummer year.
67
+ *
68
+ * @var {string}
69
+ */
70
+ this._year = "";
71
+ /**
72
+ * Personnummer month.
73
+ *
74
+ * @var {string}
75
+ */
76
+ this._month = "";
77
+ /**
78
+ * Personnummer day.
79
+ *
80
+ * @var {string}
81
+ */
82
+ this._day = "";
83
+ /**
84
+ * Personnummer seperator.
85
+ *
86
+ * @var {string}
87
+ */
88
+ this._sep = "";
89
+ /**
90
+ * Personnumer first three of the last four numbers.
91
+ *
92
+ * @var {string}
93
+ */
94
+ this._num = "";
95
+ /**
96
+ * The last number of the personnummer.
97
+ *
98
+ * @var {string}
99
+ */
100
+ this._check = "";
101
+ this.parse(pin, {
102
+ allowCoordinationNumber: true,
103
+ allowInterimNumber: false,
104
+ ...options
105
+ });
106
+ }
107
+ /**
108
+ * Get century.
109
+ *
110
+ * @return {string}
111
+ */
112
+ get century() {
113
+ return this._century;
114
+ }
115
+ /**
116
+ * Get age.
117
+ *
118
+ * @return {string}
119
+ */
120
+ get fullYear() {
121
+ return this._fullYear;
122
+ }
123
+ /**
124
+ * Get age.
125
+ *
126
+ * @return {string}
127
+ */
128
+ get year() {
129
+ return this._year;
130
+ }
131
+ /**
132
+ * Get month.
133
+ *
134
+ * @return {string}
135
+ */
136
+ get month() {
137
+ return this._month;
138
+ }
139
+ /**
140
+ * Get day.
141
+ *
142
+ * @return {string}
143
+ */
144
+ get day() {
145
+ return this._day;
146
+ }
147
+ /**
148
+ * Get sep.
149
+ *
150
+ * @return {string}
151
+ */
152
+ get sep() {
153
+ return this._sep;
154
+ }
155
+ /**
156
+ * Get num.
157
+ *
158
+ * @return {string}
159
+ */
160
+ get num() {
161
+ return this._num;
162
+ }
163
+ /**
164
+ * Get check.
165
+ *
166
+ * @return {string}
167
+ */
168
+ get check() {
169
+ return this._check;
170
+ }
171
+ /**
172
+ * Parse personnummer.
173
+ *
174
+ * @param {string} pin
175
+ * @param {object} options
176
+ *
177
+ * @return {Personnummer}
178
+ */
179
+ static parse(pin, options) {
180
+ return new Personnummer(pin, options);
181
+ }
182
+ /**
183
+ * Validate a Swedish personal identity number.
184
+ *
185
+ * @param {string} str
186
+ * @param {object} options
187
+ *
188
+ * @return {boolean}
189
+ */
190
+ static valid(pin, options) {
191
+ try {
192
+ Personnummer.parse(pin, options);
193
+ return true;
194
+ } catch (e) {
195
+ return false;
196
+ }
197
+ }
198
+ /**
199
+ * Parse personnummer and set class properties.
200
+ *
201
+ * @param {string} pin
202
+ * @param {object} options
203
+ */
204
+ parse(pin, options) {
205
+ if (pin.length < 10 || pin.length > 13) {
206
+ throw new PersonnummerError();
207
+ }
208
+ const reg = /^(\d{2}){0,1}(\d{2})(\d{2})(\d{2})([+-]?)((?!000)\d{3}|[TRSUWXJKLMN]\d{2})(\d)$/;
209
+ const match = reg.exec(pin);
210
+ if (!match) {
211
+ throw new PersonnummerError();
212
+ }
213
+ const century = match[1];
214
+ const year = match[2];
215
+ const month = match[3];
216
+ const day = match[4];
217
+ const sep = match[5];
218
+ const num = match[6];
219
+ const check = match[7];
220
+ if (typeof century === "undefined" || !century.length) {
221
+ const d = /* @__PURE__ */ new Date();
222
+ let baseYear = 0;
223
+ if (sep === "+") {
224
+ this._sep = "+";
225
+ baseYear = d.getFullYear() - 100;
226
+ } else {
227
+ this._sep = "-";
228
+ baseYear = d.getFullYear();
229
+ }
230
+ this._century = ("" + (baseYear - (baseYear - parseInt(year)) % 100)).substr(0, 2);
231
+ } else {
232
+ this._century = century;
233
+ if ((/* @__PURE__ */ new Date()).getFullYear() - parseInt(century + year, 10) < 100) {
234
+ this._sep = "-";
235
+ } else {
236
+ this._sep = "+";
237
+ }
238
+ }
239
+ this._year = year;
240
+ this._fullYear = this._century + year;
241
+ this._month = month;
242
+ this._day = day;
243
+ this._num = num;
244
+ this._check = check;
245
+ if (!this.valid()) {
246
+ throw new PersonnummerError();
247
+ }
248
+ if (!(options == null ? void 0 : options.allowCoordinationNumber) && this.isCoordinationNumber()) {
249
+ throw new PersonnummerError();
250
+ }
251
+ if (!(options == null ? void 0 : options.allowInterimNumber) && this.isInterimNumber()) {
252
+ throw new PersonnummerError();
253
+ }
254
+ }
255
+ /**
256
+ * Validate a Swedish personal identity number.
257
+ *
258
+ * @return {boolean}
259
+ */
260
+ valid() {
261
+ const valid = luhn(
262
+ this.year + this.month + this.day + this.num.replace(/[TRSUWXJKLMN]/, "1")
263
+ ) === +this.check && !!this.check;
264
+ if (valid && testDate(parseInt(this.century + this.year), +this.month, +this.day)) {
265
+ return valid;
266
+ }
267
+ return valid && testDate(parseInt(this.century + this.year), +this.month, +this.day - 60);
268
+ }
269
+ /**
270
+ * Format a Swedish personal identity number as one of the official formats,
271
+ * A long format or a short format.
272
+ *
273
+ * If the input number could not be parsed a empty string will be returned.
274
+ *
275
+ * @param {boolean} longFormat
276
+ *
277
+ * @return {string}
278
+ */
279
+ format(longFormat = false) {
280
+ if (longFormat) {
281
+ return `${this.century}${this.year}${this.month}${this.day}${this.num}${this.check}`;
282
+ }
283
+ return `${this.year}${this.month}${this.day}${this.sep}${this.num}${this.check}`;
284
+ }
285
+ /**
286
+ * Get age from a Swedish personal identity number.
287
+ *
288
+ * @return {number}
289
+ */
290
+ getAge() {
291
+ const date = this.getDate();
292
+ return diffInYears(new Date(Date.now()), date);
293
+ }
294
+ /**
295
+ * Get date from a Swedish personal identity number.
296
+ *
297
+ * @return {Date}
298
+ */
299
+ getDate() {
300
+ let ageDay = +this.day;
301
+ if (this.isCoordinationNumber()) {
302
+ ageDay -= 60;
303
+ }
304
+ const ageDate = this.century + this.year + "-" + this.month + "-" + (ageDay < 10 ? "0" + ageDay : ageDay);
305
+ return new Date(ageDate);
306
+ }
307
+ /**
308
+ * Check if a Swedish personal identity number is a interim number or not.
309
+ *
310
+ * @return {boolean}
311
+ */
312
+ isInterimNumber() {
313
+ return /[TRSUWXJKLMN]/.test(this.num[0]);
314
+ }
315
+ /**
316
+ * Check if a Swedish personal identity number is a coordination number or not.
317
+ *
318
+ * @return {boolean}
319
+ */
320
+ isCoordinationNumber() {
321
+ return testDate(
322
+ parseInt(this.century + this.year),
323
+ +this.month,
324
+ +this.day - 60
325
+ );
326
+ }
327
+ /**
328
+ * Check if a Swedish personal identity number is for a female.
329
+ *
330
+ * @return {boolean}
331
+ */
332
+ isFemale() {
333
+ return !this.isMale();
334
+ }
335
+ /**
336
+ * Check if a Swedish personal identity number is for a male.
337
+ *
338
+ * @return {boolean}
339
+ */
340
+ isMale() {
341
+ const sexDigit = parseInt(this.num.substr(-1));
342
+ return sexDigit % 2 === 1;
343
+ }
344
+ };
345
+ var src_default = Personnummer;
346
+
347
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
348
+
349
+ function getDefaultExportFromCjs (x) {
350
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
351
+ }
352
+
353
+ function createCommonjsModule(fn, basedir, module) {
354
+ return module = {
355
+ path: basedir,
356
+ exports: {},
357
+ require: function (path, base) {
358
+ return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
359
+ }
360
+ }, fn(module, module.exports), module.exports;
361
+ }
362
+
363
+ function getDefaultExportFromNamespaceIfPresent (n) {
364
+ return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n;
365
+ }
366
+
367
+ function getDefaultExportFromNamespaceIfNotNamed (n) {
368
+ return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;
369
+ }
370
+
371
+ function getAugmentedNamespace(n) {
372
+ if (n.__esModule) return n;
373
+ var a = Object.defineProperty({}, '__esModule', {value: true});
374
+ Object.keys(n).forEach(function (k) {
375
+ var d = Object.getOwnPropertyDescriptor(n, k);
376
+ Object.defineProperty(a, k, d.get ? d : {
377
+ enumerable: true,
378
+ get: function () {
379
+ return n[k];
380
+ }
381
+ });
382
+ });
383
+ return a;
384
+ }
385
+
386
+ function commonjsRequire () {
387
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
388
+ }
389
+
390
+ var utf8 = createCommonjsModule(function (module, exports) {
391
+ "use strict";
392
+ // tslint:disable:no-bitwise
393
+ Object.defineProperty(exports, "__esModule", { value: true });
394
+ exports.utf8 = void 0;
395
+ exports.utf8 = {
396
+ encode: encode,
397
+ decode: decode,
398
+ };
399
+ function encode(unicodeText) {
400
+ unicodeText = unicodeText.replace(/\r\n/g, "\n");
401
+ var result = "";
402
+ for (var i = 0; i < unicodeText.length; i++) {
403
+ var char = unicodeText.charCodeAt(i);
404
+ if (char < 128) {
405
+ result += String.fromCharCode(char);
406
+ }
407
+ else if (char > 127 && char < 2048) {
408
+ result += String.fromCharCode((char >> 6) | 192);
409
+ result += String.fromCharCode((char & 63) | 128);
410
+ }
411
+ else {
412
+ result += String.fromCharCode((char >> 12) | 224);
413
+ result += String.fromCharCode(((char >> 6) & 63) | 128);
414
+ result += String.fromCharCode((char & 63) | 128);
415
+ }
416
+ }
417
+ return result;
418
+ }
419
+ function decode(utf8Text) {
420
+ var result = "";
421
+ var i = 0;
422
+ var char1 = 0;
423
+ var char2 = 0;
424
+ var char3 = 0;
425
+ while (i < utf8Text.length) {
426
+ char1 = utf8Text.charCodeAt(i);
427
+ if (char1 < 128) {
428
+ result += String.fromCharCode(char1);
429
+ i++;
430
+ }
431
+ else if (char1 > 191 && char1 < 224) {
432
+ char2 = utf8Text.charCodeAt(i + 1);
433
+ result += String.fromCharCode(((char1 & 31) << 6) | (char2 & 63));
434
+ i += 2;
435
+ }
436
+ else {
437
+ char2 = utf8Text.charCodeAt(i + 1);
438
+ char3 = utf8Text.charCodeAt(i + 2);
439
+ result += String.fromCharCode(((char1 & 15) << 12) | ((char2 & 63) << 6) | (char3 & 63));
440
+ i += 3;
441
+ }
442
+ }
443
+ return result;
444
+ }
445
+ });
446
+
447
+ const utf8$1 = /*@__PURE__*/getDefaultExportFromCjs(utf8);
448
+
449
+ var md5 = createCommonjsModule(function (module, exports) {
450
+ "use strict";
451
+ // tslint:disable:no-bitwise
452
+ Object.defineProperty(exports, "__esModule", { value: true });
453
+ exports.generate = void 0;
454
+
455
+ function generate(unicodeText) {
456
+ var x = [];
457
+ var k;
458
+ var AA;
459
+ var BB;
460
+ var CC;
461
+ var DD;
462
+ var a;
463
+ var b;
464
+ var c;
465
+ var d;
466
+ var S11 = 7;
467
+ var S12 = 12;
468
+ var S13 = 17;
469
+ var S14 = 22;
470
+ var S21 = 5;
471
+ var S22 = 9;
472
+ var S23 = 14;
473
+ var S24 = 20;
474
+ var S31 = 4;
475
+ var S32 = 11;
476
+ var S33 = 16;
477
+ var S34 = 23;
478
+ var S41 = 6;
479
+ var S42 = 10;
480
+ var S43 = 15;
481
+ var S44 = 21;
482
+ var utf8Text = utf8.utf8.encode(unicodeText);
483
+ x = convertToWordArray(utf8Text);
484
+ a = 0x67452301;
485
+ b = 0xefcdab89;
486
+ c = 0x98badcfe;
487
+ d = 0x10325476;
488
+ for (k = 0; k < x.length; k += 16) {
489
+ AA = a;
490
+ BB = b;
491
+ CC = c;
492
+ DD = d;
493
+ a = FF(a, b, c, d, x[k + 0], S11, 0xd76aa478);
494
+ d = FF(d, a, b, c, x[k + 1], S12, 0xe8c7b756);
495
+ c = FF(c, d, a, b, x[k + 2], S13, 0x242070db);
496
+ b = FF(b, c, d, a, x[k + 3], S14, 0xc1bdceee);
497
+ a = FF(a, b, c, d, x[k + 4], S11, 0xf57c0faf);
498
+ d = FF(d, a, b, c, x[k + 5], S12, 0x4787c62a);
499
+ c = FF(c, d, a, b, x[k + 6], S13, 0xa8304613);
500
+ b = FF(b, c, d, a, x[k + 7], S14, 0xfd469501);
501
+ a = FF(a, b, c, d, x[k + 8], S11, 0x698098d8);
502
+ d = FF(d, a, b, c, x[k + 9], S12, 0x8b44f7af);
503
+ c = FF(c, d, a, b, x[k + 10], S13, 0xffff5bb1);
504
+ b = FF(b, c, d, a, x[k + 11], S14, 0x895cd7be);
505
+ a = FF(a, b, c, d, x[k + 12], S11, 0x6b901122);
506
+ d = FF(d, a, b, c, x[k + 13], S12, 0xfd987193);
507
+ c = FF(c, d, a, b, x[k + 14], S13, 0xa679438e);
508
+ b = FF(b, c, d, a, x[k + 15], S14, 0x49b40821);
509
+ a = GG(a, b, c, d, x[k + 1], S21, 0xf61e2562);
510
+ d = GG(d, a, b, c, x[k + 6], S22, 0xc040b340);
511
+ c = GG(c, d, a, b, x[k + 11], S23, 0x265e5a51);
512
+ b = GG(b, c, d, a, x[k + 0], S24, 0xe9b6c7aa);
513
+ a = GG(a, b, c, d, x[k + 5], S21, 0xd62f105d);
514
+ d = GG(d, a, b, c, x[k + 10], S22, 0x2441453);
515
+ c = GG(c, d, a, b, x[k + 15], S23, 0xd8a1e681);
516
+ b = GG(b, c, d, a, x[k + 4], S24, 0xe7d3fbc8);
517
+ a = GG(a, b, c, d, x[k + 9], S21, 0x21e1cde6);
518
+ d = GG(d, a, b, c, x[k + 14], S22, 0xc33707d6);
519
+ c = GG(c, d, a, b, x[k + 3], S23, 0xf4d50d87);
520
+ b = GG(b, c, d, a, x[k + 8], S24, 0x455a14ed);
521
+ a = GG(a, b, c, d, x[k + 13], S21, 0xa9e3e905);
522
+ d = GG(d, a, b, c, x[k + 2], S22, 0xfcefa3f8);
523
+ c = GG(c, d, a, b, x[k + 7], S23, 0x676f02d9);
524
+ b = GG(b, c, d, a, x[k + 12], S24, 0x8d2a4c8a);
525
+ a = HH(a, b, c, d, x[k + 5], S31, 0xfffa3942);
526
+ d = HH(d, a, b, c, x[k + 8], S32, 0x8771f681);
527
+ c = HH(c, d, a, b, x[k + 11], S33, 0x6d9d6122);
528
+ b = HH(b, c, d, a, x[k + 14], S34, 0xfde5380c);
529
+ a = HH(a, b, c, d, x[k + 1], S31, 0xa4beea44);
530
+ d = HH(d, a, b, c, x[k + 4], S32, 0x4bdecfa9);
531
+ c = HH(c, d, a, b, x[k + 7], S33, 0xf6bb4b60);
532
+ b = HH(b, c, d, a, x[k + 10], S34, 0xbebfbc70);
533
+ a = HH(a, b, c, d, x[k + 13], S31, 0x289b7ec6);
534
+ d = HH(d, a, b, c, x[k + 0], S32, 0xeaa127fa);
535
+ c = HH(c, d, a, b, x[k + 3], S33, 0xd4ef3085);
536
+ b = HH(b, c, d, a, x[k + 6], S34, 0x4881d05);
537
+ a = HH(a, b, c, d, x[k + 9], S31, 0xd9d4d039);
538
+ d = HH(d, a, b, c, x[k + 12], S32, 0xe6db99e5);
539
+ c = HH(c, d, a, b, x[k + 15], S33, 0x1fa27cf8);
540
+ b = HH(b, c, d, a, x[k + 2], S34, 0xc4ac5665);
541
+ a = II(a, b, c, d, x[k + 0], S41, 0xf4292244);
542
+ d = II(d, a, b, c, x[k + 7], S42, 0x432aff97);
543
+ c = II(c, d, a, b, x[k + 14], S43, 0xab9423a7);
544
+ b = II(b, c, d, a, x[k + 5], S44, 0xfc93a039);
545
+ a = II(a, b, c, d, x[k + 12], S41, 0x655b59c3);
546
+ d = II(d, a, b, c, x[k + 3], S42, 0x8f0ccc92);
547
+ c = II(c, d, a, b, x[k + 10], S43, 0xffeff47d);
548
+ b = II(b, c, d, a, x[k + 1], S44, 0x85845dd1);
549
+ a = II(a, b, c, d, x[k + 8], S41, 0x6fa87e4f);
550
+ d = II(d, a, b, c, x[k + 15], S42, 0xfe2ce6e0);
551
+ c = II(c, d, a, b, x[k + 6], S43, 0xa3014314);
552
+ b = II(b, c, d, a, x[k + 13], S44, 0x4e0811a1);
553
+ a = II(a, b, c, d, x[k + 4], S41, 0xf7537e82);
554
+ d = II(d, a, b, c, x[k + 11], S42, 0xbd3af235);
555
+ c = II(c, d, a, b, x[k + 2], S43, 0x2ad7d2bb);
556
+ b = II(b, c, d, a, x[k + 9], S44, 0xeb86d391);
557
+ a = addUnsigned(a, AA);
558
+ b = addUnsigned(b, BB);
559
+ c = addUnsigned(c, CC);
560
+ d = addUnsigned(d, DD);
561
+ }
562
+ return wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d);
563
+ }
564
+ exports.generate = generate;
565
+ function rotateLeft(lValue, iShiftBits) {
566
+ return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
567
+ }
568
+ function addUnsigned(lX, lY) {
569
+ var lX4;
570
+ var lY4;
571
+ var lX8;
572
+ var lY8;
573
+ var lResult;
574
+ lX8 = lX & 0x80000000;
575
+ lY8 = lY & 0x80000000;
576
+ lX4 = lX & 0x40000000;
577
+ lY4 = lY & 0x40000000;
578
+ lResult = (lX & 0x3fffffff) + (lY & 0x3fffffff);
579
+ if (lX4 & lY4) {
580
+ return lResult ^ 0x80000000 ^ lX8 ^ lY8;
581
+ }
582
+ if (lX4 | lY4) {
583
+ if (lResult & 0x40000000) {
584
+ return lResult ^ 0xc0000000 ^ lX8 ^ lY8;
585
+ }
586
+ else {
587
+ return lResult ^ 0x40000000 ^ lX8 ^ lY8;
588
+ }
589
+ }
590
+ else {
591
+ return lResult ^ lX8 ^ lY8;
592
+ }
593
+ }
594
+ function F(x, y, z) {
595
+ return (x & y) | (~x & z);
596
+ }
597
+ function G(x, y, z) {
598
+ return (x & z) | (y & ~z);
599
+ }
600
+ function H(x, y, z) {
601
+ return x ^ y ^ z;
602
+ }
603
+ function I(x, y, z) {
604
+ return y ^ (x | ~z);
605
+ }
606
+ function FF(a, b, c, d, x, s, ac) {
607
+ a = addUnsigned(a, addUnsigned(addUnsigned(F(b, c, d), x), ac));
608
+ return addUnsigned(rotateLeft(a, s), b);
609
+ }
610
+ function GG(a, b, c, d, x, s, ac) {
611
+ a = addUnsigned(a, addUnsigned(addUnsigned(G(b, c, d), x), ac));
612
+ return addUnsigned(rotateLeft(a, s), b);
613
+ }
614
+ function HH(a, b, c, d, x, s, ac) {
615
+ a = addUnsigned(a, addUnsigned(addUnsigned(H(b, c, d), x), ac));
616
+ return addUnsigned(rotateLeft(a, s), b);
617
+ }
618
+ function II(a, b, c, d, x, s, ac) {
619
+ a = addUnsigned(a, addUnsigned(addUnsigned(I(b, c, d), x), ac));
620
+ return addUnsigned(rotateLeft(a, s), b);
621
+ }
622
+ function convertToWordArray(value) {
623
+ var lWordCount;
624
+ var lMessageLength = value.length;
625
+ var lNumberOfWordsTemp1 = lMessageLength + 8;
626
+ var lNumberOfWordsTemp2 = (lNumberOfWordsTemp1 - (lNumberOfWordsTemp1 % 64)) / 64;
627
+ var lNumberOfWords = (lNumberOfWordsTemp2 + 1) * 16;
628
+ var lWordArray = Array(lNumberOfWords - 1);
629
+ var lBytePosition = 0;
630
+ var lByteCount = 0;
631
+ while (lByteCount < lMessageLength) {
632
+ lWordCount = (lByteCount - (lByteCount % 4)) / 4;
633
+ lBytePosition = (lByteCount % 4) * 8;
634
+ lWordArray[lWordCount] =
635
+ lWordArray[lWordCount] | (value.charCodeAt(lByteCount) << lBytePosition);
636
+ lByteCount++;
637
+ }
638
+ lWordCount = (lByteCount - (lByteCount % 4)) / 4;
639
+ lBytePosition = (lByteCount % 4) * 8;
640
+ lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
641
+ lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
642
+ lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
643
+ return lWordArray;
644
+ }
645
+ function wordToHex(lValue) {
646
+ var wordToHexValue = "";
647
+ var wordToHexValueTemp = "";
648
+ var lByte;
649
+ var lCount;
650
+ for (lCount = 0; lCount <= 3; lCount++) {
651
+ lByte = (lValue >>> (lCount * 8)) & 255;
652
+ wordToHexValueTemp = "0" + lByte.toString(16);
653
+ wordToHexValue =
654
+ wordToHexValue + wordToHexValueTemp.substr(wordToHexValueTemp.length - 2, 2);
655
+ }
656
+ return wordToHexValue;
657
+ }
658
+ });
659
+
660
+ const md5$1 = /*@__PURE__*/getDefaultExportFromCjs(md5);
661
+
662
+ var lib = createCommonjsModule(function (module, exports) {
663
+ "use strict";
664
+ Object.defineProperty(exports, "__esModule", { value: true });
665
+ exports.MD5 = exports.generate = void 0;
666
+
667
+ var md5_2 = md5;
668
+ Object.defineProperty(exports, "generate", { enumerable: true, get: function () { return md5_2.generate; } });
669
+ exports.MD5 = {
670
+ generate: md5.generate,
671
+ };
672
+ });
673
+
674
+ const index = /*@__PURE__*/getDefaultExportFromCjs(lib);
675
+
676
+ const apiSearch = async (query) => {
677
+ var _a;
678
+ const res = await fetch((_a = "https://hemfixare-lookup-dev.vercel.app/api") !== null && _a !== void 0 ? _a : 'https://hemfixare-lookup.vercel.app/api', {
679
+ method: 'POST',
680
+ headers: {
681
+ 'Content-Type': 'application/json',
682
+ },
683
+ body: JSON.stringify({
684
+ query,
685
+ hash: lib.MD5.generate(String.fromCharCode(83, 101, 67, 82, 101, 116) + query),
686
+ }),
687
+ });
688
+ const data = await res.json();
689
+ return data;
690
+ };
691
+
692
+ const HemfixarnaGetuser = class {
693
+ constructor(hostRef) {
694
+ registerInstance(this, hostRef);
695
+ this.handleChangeEmail = (e) => {
696
+ this.emailError = null;
697
+ this.email = e.target.value;
698
+ };
699
+ this.handleChangePhone = (e) => {
700
+ this.phoneError = null;
701
+ this.phone = e.target.value;
702
+ };
703
+ this.handleChangessn = (e) => {
704
+ this.ssnError = null;
705
+ this.ssn = e.target.value;
706
+ };
707
+ this.handleSubmit = async (e) => {
708
+ e.preventDefault();
709
+ const emailRegex = new RegExp(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
710
+ const validEmail = emailRegex.test(this.email);
711
+ if (!validEmail) {
712
+ this.emailError = 'Ange en giltig e-postadress';
713
+ }
714
+ const validPhone = /^[\d\s()+-]{6,}$/.test(this.phone);
715
+ if (!validPhone) {
716
+ this.phoneError = 'Ange ett giltigt telefonnummer';
717
+ }
718
+ const validssn = src_default.valid(this.ssn);
719
+ if (!validssn) {
720
+ this.ssnError = 'Ange ett giltigt personnummer';
721
+ }
722
+ else if (validssn) {
723
+ const pn = src_default.parse(this.ssn).format(true);
724
+ this.ssn = [pn.slice(0, 8), '-', pn.slice(8)].join('');
725
+ }
726
+ if (validEmail && validPhone && validssn) {
727
+ try {
728
+ const creditSafeData = await apiSearch(this.ssn);
729
+ if (creditSafeData) {
730
+ state.creditSafeUser = creditSafeData;
731
+ state.checkoutStep = 2;
732
+ state.user = Object.assign(Object.assign({}, creditSafeData), { email: this.email, phone: this.phone, ssn: this.ssn });
733
+ }
734
+ else {
735
+ this.ssnError = 'Vi kunde tyvärr inte hitta en address med ditt angivna personnummer';
736
+ }
737
+ }
738
+ catch (e) {
739
+ this.ssnError = 'Vi kunde tyvärr inte hitta en address med ditt angivna personnummer';
740
+ console.log(e);
741
+ }
742
+ finally {
743
+ const el = this.el.closest('.hemfixarna_content');
744
+ scrollToTop(el);
745
+ }
746
+ }
747
+ };
748
+ this.render = () => {
749
+ return (h("form", { class: "mb-2", onSubmit: e => this.handleSubmit(e) }, h("div", null, h("input", { class: `${this.email.length ? 'input_active' : ''}`, onChange: e => this.handleChangeEmail(e), type: "email", name: "email", value: this.email }), h("label", { htmlFor: "email" }, "E-post ")), this.emailError && h("span", null, this.emailError), h("div", null, h("input", { class: `${this.phone.length ? 'input_active' : ''}`, onChange: e => this.handleChangePhone(e), type: "tel", name: "phone", value: this.phone }), h("label", { htmlFor: "phone" }, "Mobiltelefon ")), this.phoneError && h("span", null, this.phoneError), h("div", null, h("input", { class: `${this.ssn.length ? 'input_active' : ''}`, onChange: e => this.handleChangessn(e), type: "tel", name: "ssn", value: this.ssn }), h("label", { htmlFor: "phone" }, "Personnummer*")), this.ssnError && h("span", null, this.ssnError), h("input", { type: "submit", value: "Forts\u00E4tt*" }), h("p", null, "*Vi h\u00E4mtar din adress")));
750
+ };
751
+ this.email = '';
752
+ this.emailError = null;
753
+ this.phone = '';
754
+ this.phoneError = null;
755
+ this.ssn = '';
756
+ this.ssnError = null;
757
+ }
758
+ componentWillLoad() {
759
+ if (state.user) {
760
+ this.email = state.user.email;
761
+ this.phone = state.user.phone;
762
+ this.ssn = state.user.ssn;
763
+ }
764
+ }
765
+ get el() { return getElement(this); }
766
+ };
767
+
768
+ export { HemfixarnaGetuser as hemfixarna_getuser };
769
+
770
+ //# sourceMappingURL=hemfixarna-getuser.entry.js.map