hemfixarna-web-components 1.6.2 → 1.6.4

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/cjs/hemfixarna-address_36.cjs.entry.js +2763 -0
  2. package/dist/{hemfixarna-components/index-f1a87cf1.js.map → cjs/hemfixarna-address_36.cjs.entry.js.map} +1 -1
  3. package/dist/cjs/hemfixarna-components.cjs.js +28 -0
  4. package/dist/cjs/hemfixarna-components.cjs.js.map +1 -0
  5. package/dist/cjs/index-b83343b9.js +1687 -0
  6. package/dist/cjs/index-b83343b9.js.map +1 -0
  7. package/dist/cjs/index.cjs.js +4 -0
  8. package/dist/cjs/index.cjs.js.map +1 -0
  9. package/dist/cjs/loader.cjs.js +24 -0
  10. package/dist/cjs/loader.cjs.js.map +1 -0
  11. package/dist/collection/assets/back.svg +3 -0
  12. package/dist/collection/assets/cart.svg +10 -0
  13. package/dist/collection/assets/checked.svg +10 -0
  14. package/dist/collection/assets/close.svg +5 -0
  15. package/dist/collection/assets/copy.png +0 -0
  16. package/dist/collection/assets/date.svg +6 -0
  17. package/dist/collection/assets/down.svg +3 -0
  18. package/dist/collection/assets/drag-drop.svg +3 -0
  19. package/dist/collection/assets/elfa.png +0 -0
  20. package/dist/collection/assets/gubbe-pensel.svg +1 -0
  21. package/dist/collection/assets/hemfixarna.svg +11 -0
  22. package/dist/collection/assets/hornbach/logo.svg +42 -0
  23. package/dist/collection/assets/hornbach/nav.jpg +0 -0
  24. package/dist/collection/assets/info.svg +5 -0
  25. package/dist/collection/assets/kbygg.svg +29 -0
  26. package/dist/collection/assets/minus.svg +4 -0
  27. package/dist/collection/assets/montering.svg +15 -0
  28. package/dist/collection/assets/norrgavel.svg +1 -0
  29. package/dist/collection/assets/pensel.svg +1 -0
  30. package/dist/collection/assets/plus.svg +5 -0
  31. package/dist/collection/assets/spinner.gif +0 -0
  32. package/dist/collection/assets/tesla.svg +1 -0
  33. package/dist/collection/assets/zaptec.svg +1 -0
  34. package/dist/collection/collection-manifest.json +47 -0
  35. package/dist/collection/components/customers/hemfixarna-byggmax/hemfixarna-byggmax.css +0 -0
  36. package/dist/collection/components/customers/hemfixarna-byggmax/hemfixarna-byggmax.js +184 -0
  37. package/dist/collection/components/customers/hemfixarna-byggmax/hemfixarna-byggmax.js.map +1 -0
  38. package/dist/collection/components/customers/hemfixarna-doro/hemfixarna-doro.css +0 -0
  39. package/dist/collection/components/customers/hemfixarna-doro/hemfixarna-doro.js +123 -0
  40. package/dist/collection/components/customers/hemfixarna-doro/hemfixarna-doro.js.map +1 -0
  41. package/dist/collection/components/customers/hemfixarna-elfa/hemfixarna-elfa.css +0 -0
  42. package/dist/collection/components/customers/hemfixarna-elfa/hemfixarna-elfa.js +142 -0
  43. package/dist/collection/components/customers/hemfixarna-elfa/hemfixarna-elfa.js.map +1 -0
  44. package/dist/collection/components/customers/hemfixarna-fargvaruhuset/hemfixarna-fargvaruhuset.js +132 -0
  45. package/dist/collection/components/customers/hemfixarna-fargvaruhuset/hemfixarna-fargvaruhuset.js.map +1 -0
  46. package/dist/collection/components/customers/hemfixarna-flyttsmart/hemfixarna-flyttsmart.js +132 -0
  47. package/dist/collection/components/customers/hemfixarna-flyttsmart/hemfixarna-flyttsmart.js.map +1 -0
  48. package/dist/collection/components/customers/hemfixarna-forebygg/hemfixarna-forebygg.css +0 -0
  49. package/dist/collection/components/customers/hemfixarna-forebygg/hemfixarna-forebygg.js +123 -0
  50. package/dist/collection/components/customers/hemfixarna-forebygg/hemfixarna-forebygg.js.map +1 -0
  51. package/dist/collection/components/customers/hemfixarna-hornbach/hemfixarna-hornbach.css +0 -0
  52. package/dist/collection/components/customers/hemfixarna-hornbach/hemfixarna-hornbach.js +142 -0
  53. package/dist/collection/components/customers/hemfixarna-hornbach/hemfixarna-hornbach.js.map +1 -0
  54. package/dist/collection/components/customers/hemfixarna-kbygg/hemfixarna-kbygg.js +132 -0
  55. package/dist/collection/components/customers/hemfixarna-kbygg/hemfixarna-kbygg.js.map +1 -0
  56. package/dist/collection/components/customers/hemfixarna-klint/hemfixarna-klint.js +113 -0
  57. package/dist/collection/components/customers/hemfixarna-klint/hemfixarna-klint.js.map +1 -0
  58. package/dist/collection/components/customers/hemfixarna-kund/hemfixarna-kund.js +113 -0
  59. package/dist/collection/components/customers/hemfixarna-kund/hemfixarna-kund.js.map +1 -0
  60. package/dist/collection/components/customers/hemfixarna-norrgavel/hemfixarna-norrgavel.js +132 -0
  61. package/dist/collection/components/customers/hemfixarna-norrgavel/hemfixarna-norrgavel.js.map +1 -0
  62. package/dist/collection/components/customers/hemfixarna-power/hemfixarna-power.js +131 -0
  63. package/dist/collection/components/customers/hemfixarna-power/hemfixarna-power.js.map +1 -0
  64. package/dist/collection/components/customers/hemfixarna-skanska/hemfixarna-skanska.css +0 -0
  65. package/dist/collection/components/customers/hemfixarna-skanska/hemfixarna-skanska.js +141 -0
  66. package/dist/collection/components/customers/hemfixarna-skanska/hemfixarna-skanska.js.map +1 -0
  67. package/dist/collection/components/customers/hemfixarna-sparfonster/hemfixarna-sparfonster.js +131 -0
  68. package/dist/collection/components/customers/hemfixarna-sparfonster/hemfixarna-sparfonster.js.map +1 -0
  69. package/dist/collection/components/customers/hemfixarna-string/hemfixarna-string-furniture.js +123 -0
  70. package/dist/collection/components/customers/hemfixarna-string/hemfixarna-string-furniture.js.map +1 -0
  71. package/dist/collection/components/customers/hemfixarna-string/hemfixarna-string.css +0 -0
  72. package/dist/collection/components/customers/hemfixarna-superfront.tsx/hemfixarna-superfront.js +113 -0
  73. package/dist/collection/components/customers/hemfixarna-superfront.tsx/hemfixarna-superfront.js.map +1 -0
  74. package/dist/collection/components/customers/hemfixarna-tesla/hemfixarna-tesla.js +132 -0
  75. package/dist/collection/components/customers/hemfixarna-tesla/hemfixarna-tesla.js.map +1 -0
  76. package/dist/collection/components/customers/hemfixarna-traningspartner/hemfixarna-traningspartner.js +113 -0
  77. package/dist/collection/components/customers/hemfixarna-traningspartner/hemfixarna-traningspartner.js.map +1 -0
  78. package/dist/collection/components/customers/hemfixarna-zaptec/hemfixarna-zaptec.js +132 -0
  79. package/dist/collection/components/customers/hemfixarna-zaptec/hemfixarna-zaptec.js.map +1 -0
  80. package/dist/{hemfixarna-components/hemfixarna-address.entry.js → collection/components/hemfixarna-address/hemfixarna-address.js} +20 -14
  81. package/dist/collection/components/hemfixarna-address/hemfixarna-address.js.map +1 -0
  82. package/dist/collection/components/hemfixarna-box/hemfixarna-box.js +138 -0
  83. package/dist/collection/components/hemfixarna-box/hemfixarna-box.js.map +1 -0
  84. package/dist/{hemfixarna-components/hemfixarna-breadcrumbs.entry.js → collection/components/hemfixarna-breadcrumbs/hemfixarna-breadcrumbs.js} +84 -13
  85. package/dist/collection/components/hemfixarna-breadcrumbs/hemfixarna-breadcrumbs.js.map +1 -0
  86. package/dist/{hemfixarna-components/hemfixarna-cart.entry.js → collection/components/hemfixarna-cart/hemfixarna-cart.js} +31 -11
  87. package/dist/collection/components/hemfixarna-cart/hemfixarna-cart.js.map +1 -0
  88. package/dist/{hemfixarna-components/hemfixarna-category.entry.js → collection/components/hemfixarna-category.tsx/hemfixarna-category.js} +6 -12
  89. package/dist/collection/components/hemfixarna-category.tsx/hemfixarna-category.js.map +1 -0
  90. package/dist/{hemfixarna-components/hemfixarna-checkout.entry.js → collection/components/hemfixarna-checkout/hemfixarna-checkout.js} +27 -32
  91. package/dist/collection/components/hemfixarna-checkout/hemfixarna-checkout.js.map +1 -0
  92. package/dist/collection/components/hemfixarna-component/hemfixarna-component.js +483 -0
  93. package/dist/collection/components/hemfixarna-component/hemfixarna-component.js.map +1 -0
  94. package/dist/collection/components/hemfixarna-component/hemfixarna.css +1031 -0
  95. package/dist/{hemfixarna-components/hemfixarna-contact.entry.js → collection/components/hemfixarna-contact/hemfixarna-contact.js} +28 -10
  96. package/dist/collection/components/hemfixarna-contact/hemfixarna-contact.js.map +1 -0
  97. package/dist/collection/components/hemfixarna-demo/hemfixarna-demo.css +135 -0
  98. package/dist/{hemfixarna-components/hemfixarna-demo.entry.js → collection/components/hemfixarna-demo/hemfixarna-demo.js} +46 -23
  99. package/dist/collection/components/hemfixarna-demo/hemfixarna-demo.js.map +1 -0
  100. package/dist/collection/components/hemfixarna-getuser/hemfixarna-getuser.js +91 -0
  101. package/dist/collection/components/hemfixarna-getuser/hemfixarna-getuser.js.map +1 -0
  102. package/dist/{hemfixarna-components/hemfixarna-info.entry.js → collection/components/hemfixarna-info/hemfixarna-info.js} +7 -11
  103. package/dist/collection/components/hemfixarna-info/hemfixarna-info.js.map +1 -0
  104. package/dist/collection/components/hemfixarna-invoice/hemfixarna-invoice.css +76 -0
  105. package/dist/{hemfixarna-components/hemfixarna-invoice.entry.js → collection/components/hemfixarna-invoice/hemfixarna-invoice.js} +27 -16
  106. package/dist/collection/components/hemfixarna-invoice/hemfixarna-invoice.js.map +1 -0
  107. package/dist/{hemfixarna-components/hemfixarna-order.entry.js → collection/components/hemfixarna-order/hemfixarna-order.js} +31 -11
  108. package/dist/collection/components/hemfixarna-order/hemfixarna-order.js.map +1 -0
  109. package/dist/{hemfixarna-components/hemfixarna-orderrows.entry.js → collection/components/hemfixarna-orderrows/hemfixarna-orderrows.js} +50 -12
  110. package/dist/collection/components/hemfixarna-orderrows/hemfixarna-orderrows.js.map +1 -0
  111. package/dist/collection/components/hemfixarna-product/hemfixarna-product.css +0 -0
  112. package/dist/{hemfixarna-components/hemfixarna-product.entry.js → collection/components/hemfixarna-product/hemfixarna-product.js} +27 -18
  113. package/dist/collection/components/hemfixarna-product/hemfixarna-product.js.map +1 -0
  114. package/dist/{hemfixarna-components/hemfixarna-service.entry.js → collection/components/hemfixarna-service/hemfixarna-service.js} +6 -12
  115. package/dist/collection/components/hemfixarna-service/hemfixarna-service.js.map +1 -0
  116. package/dist/{hemfixarna-components/hemfixarna-start.entry.js → collection/components/hemfixarna-start/hemfixarna-start.js} +48 -11
  117. package/dist/collection/components/hemfixarna-start/hemfixarna-start.js.map +1 -0
  118. package/dist/collection/index.js +2 -0
  119. package/dist/collection/index.js.map +1 -0
  120. package/dist/collection/store/index.js +62 -0
  121. package/dist/collection/store/index.js.map +1 -0
  122. package/dist/collection/types/felixtypes.js +3 -0
  123. package/dist/collection/types/felixtypes.js.map +1 -0
  124. package/dist/{hemfixarna-components/index-d90ad11b.js → collection/types/index.js} +4 -7
  125. package/dist/collection/types/index.js.map +1 -0
  126. package/dist/{hemfixarna-components/api-36f73d0d.js → collection/utils/api.js} +4 -6
  127. package/dist/collection/utils/api.js.map +1 -0
  128. package/dist/{hemfixarna-components/calc-4c79b798.js → collection/utils/calc.js} +3 -6
  129. package/dist/collection/utils/calc.js.map +1 -0
  130. package/dist/collection/utils/creditSafe.js +18 -0
  131. package/dist/collection/utils/creditSafe.js.map +1 -0
  132. package/dist/collection/utils/felixApi.js +18 -0
  133. package/dist/collection/utils/felixApi.js.map +1 -0
  134. package/dist/collection/utils/felixFunctions.js +189 -0
  135. package/dist/collection/utils/felixFunctions.js.map +1 -0
  136. package/dist/{hemfixarna-components/form-c53dca29.js → collection/utils/form.js} +2 -4
  137. package/dist/collection/utils/form.js.map +1 -0
  138. package/dist/{hemfixarna-components/scroll-6c26b5da.js → collection/utils/scroll.js} +2 -4
  139. package/dist/collection/utils/scroll.js.map +1 -0
  140. package/dist/{hemfixarna-components/types-641c9a1c.js → collection/utils/types.js} +3 -6
  141. package/dist/collection/utils/types.js.map +1 -0
  142. package/dist/esm/hemfixarna-address_36.entry.js +4090 -0
  143. package/dist/esm/hemfixarna-address_36.entry.js.map +1 -0
  144. package/dist/esm/hemfixarna-components.js +23 -0
  145. package/dist/esm/hemfixarna-components.js.map +1 -0
  146. package/dist/esm/index-8c417125.js +1656 -0
  147. package/dist/esm/index-8c417125.js.map +1 -0
  148. package/dist/esm/index.js +3 -0
  149. package/dist/esm/index.js.map +1 -0
  150. package/dist/esm/loader.js +20 -0
  151. package/dist/esm/loader.js.map +1 -0
  152. package/dist/esm/polyfills/core-js.js +11 -0
  153. package/dist/esm/polyfills/css-shim.js +1 -0
  154. package/dist/esm/polyfills/dom.js +79 -0
  155. package/dist/esm/polyfills/es5-html-element.js +1 -0
  156. package/dist/esm/polyfills/index.js +34 -0
  157. package/dist/esm/polyfills/system.js +6 -0
  158. package/dist/hemfixarna-components/hemfixarna-components.esm.js +1 -162
  159. package/dist/hemfixarna-components/hemfixarna-components.esm.js.map +1 -1
  160. package/dist/hemfixarna-components/index.esm.js +0 -1
  161. package/dist/hemfixarna-components/index.esm.js.map +1 -1
  162. package/dist/hemfixarna-components/p-852e7173.js +3 -0
  163. package/dist/hemfixarna-components/p-852e7173.js.map +1 -0
  164. package/dist/hemfixarna-components/p-97461831.entry.js +2 -0
  165. package/dist/hemfixarna-components/p-97461831.entry.js.map +1 -0
  166. package/dist/index.cjs.js +1 -0
  167. package/dist/index.js +1 -0
  168. package/package.json +1 -1
  169. package/dist/hemfixarna-components/api-36f73d0d.js.map +0 -1
  170. package/dist/hemfixarna-components/app-globals-0f993ce5.js +0 -5
  171. package/dist/hemfixarna-components/app-globals-0f993ce5.js.map +0 -1
  172. package/dist/hemfixarna-components/calc-4c79b798.js.map +0 -1
  173. package/dist/hemfixarna-components/css-shim-62d2171c.js +0 -6
  174. package/dist/hemfixarna-components/css-shim-62d2171c.js.map +0 -1
  175. package/dist/hemfixarna-components/dom-46a68c9b.js +0 -75
  176. package/dist/hemfixarna-components/dom-46a68c9b.js.map +0 -1
  177. package/dist/hemfixarna-components/form-c53dca29.js.map +0 -1
  178. package/dist/hemfixarna-components/hemfixarna-address.entry.js.map +0 -1
  179. package/dist/hemfixarna-components/hemfixarna-box.entry.js +0 -49
  180. package/dist/hemfixarna-components/hemfixarna-box.entry.js.map +0 -1
  181. package/dist/hemfixarna-components/hemfixarna-breadcrumbs.entry.js.map +0 -1
  182. package/dist/hemfixarna-components/hemfixarna-byggmax.entry.js +0 -27
  183. package/dist/hemfixarna-components/hemfixarna-byggmax.entry.js.map +0 -1
  184. package/dist/hemfixarna-components/hemfixarna-cart.entry.js.map +0 -1
  185. package/dist/hemfixarna-components/hemfixarna-category.entry.js.map +0 -1
  186. package/dist/hemfixarna-components/hemfixarna-checkout.entry.js.map +0 -1
  187. package/dist/hemfixarna-components/hemfixarna-component.entry.js +0 -248
  188. package/dist/hemfixarna-components/hemfixarna-component.entry.js.map +0 -1
  189. package/dist/hemfixarna-components/hemfixarna-contact.entry.js.map +0 -1
  190. package/dist/hemfixarna-components/hemfixarna-demo.entry.js.map +0 -1
  191. package/dist/hemfixarna-components/hemfixarna-doro.entry.js +0 -23
  192. package/dist/hemfixarna-components/hemfixarna-doro.entry.js.map +0 -1
  193. package/dist/hemfixarna-components/hemfixarna-elfa.entry.js +0 -24
  194. package/dist/hemfixarna-components/hemfixarna-elfa.entry.js.map +0 -1
  195. package/dist/hemfixarna-components/hemfixarna-fargvaruhuset.entry.js +0 -21
  196. package/dist/hemfixarna-components/hemfixarna-fargvaruhuset.entry.js.map +0 -1
  197. package/dist/hemfixarna-components/hemfixarna-flyttsmart.entry.js +0 -21
  198. package/dist/hemfixarna-components/hemfixarna-flyttsmart.entry.js.map +0 -1
  199. package/dist/hemfixarna-components/hemfixarna-forebygg.entry.js +0 -23
  200. package/dist/hemfixarna-components/hemfixarna-forebygg.entry.js.map +0 -1
  201. package/dist/hemfixarna-components/hemfixarna-getuser.entry.js +0 -770
  202. package/dist/hemfixarna-components/hemfixarna-getuser.entry.js.map +0 -1
  203. package/dist/hemfixarna-components/hemfixarna-hornbach.entry.js +0 -24
  204. package/dist/hemfixarna-components/hemfixarna-hornbach.entry.js.map +0 -1
  205. package/dist/hemfixarna-components/hemfixarna-info.entry.js.map +0 -1
  206. package/dist/hemfixarna-components/hemfixarna-invoice.entry.js.map +0 -1
  207. package/dist/hemfixarna-components/hemfixarna-kbygg.entry.js +0 -21
  208. package/dist/hemfixarna-components/hemfixarna-kbygg.entry.js.map +0 -1
  209. package/dist/hemfixarna-components/hemfixarna-klint.entry.js +0 -20
  210. package/dist/hemfixarna-components/hemfixarna-klint.entry.js.map +0 -1
  211. package/dist/hemfixarna-components/hemfixarna-kund.entry.js +0 -20
  212. package/dist/hemfixarna-components/hemfixarna-kund.entry.js.map +0 -1
  213. package/dist/hemfixarna-components/hemfixarna-norrgavel.entry.js +0 -21
  214. package/dist/hemfixarna-components/hemfixarna-norrgavel.entry.js.map +0 -1
  215. package/dist/hemfixarna-components/hemfixarna-order.entry.js.map +0 -1
  216. package/dist/hemfixarna-components/hemfixarna-orderrows.entry.js.map +0 -1
  217. package/dist/hemfixarna-components/hemfixarna-power.entry.js +0 -21
  218. package/dist/hemfixarna-components/hemfixarna-power.entry.js.map +0 -1
  219. package/dist/hemfixarna-components/hemfixarna-product.entry.js.map +0 -1
  220. package/dist/hemfixarna-components/hemfixarna-service.entry.js.map +0 -1
  221. package/dist/hemfixarna-components/hemfixarna-skanska.entry.js +0 -24
  222. package/dist/hemfixarna-components/hemfixarna-skanska.entry.js.map +0 -1
  223. package/dist/hemfixarna-components/hemfixarna-sparfonster.entry.js +0 -21
  224. package/dist/hemfixarna-components/hemfixarna-sparfonster.entry.js.map +0 -1
  225. package/dist/hemfixarna-components/hemfixarna-start.entry.js.map +0 -1
  226. package/dist/hemfixarna-components/hemfixarna-string-furniture.entry.js +0 -23
  227. package/dist/hemfixarna-components/hemfixarna-string-furniture.entry.js.map +0 -1
  228. package/dist/hemfixarna-components/hemfixarna-superfront.entry.js +0 -20
  229. package/dist/hemfixarna-components/hemfixarna-superfront.entry.js.map +0 -1
  230. package/dist/hemfixarna-components/hemfixarna-tesla.entry.js +0 -21
  231. package/dist/hemfixarna-components/hemfixarna-tesla.entry.js.map +0 -1
  232. package/dist/hemfixarna-components/hemfixarna-traningspartner.entry.js +0 -20
  233. package/dist/hemfixarna-components/hemfixarna-traningspartner.entry.js.map +0 -1
  234. package/dist/hemfixarna-components/hemfixarna-zaptec.entry.js +0 -21
  235. package/dist/hemfixarna-components/hemfixarna-zaptec.entry.js.map +0 -1
  236. package/dist/hemfixarna-components/index-b6a6e994.js +0 -256
  237. package/dist/hemfixarna-components/index-b6a6e994.js.map +0 -1
  238. package/dist/hemfixarna-components/index-d90ad11b.js.map +0 -1
  239. package/dist/hemfixarna-components/index-f1a87cf1.js +0 -3397
  240. package/dist/hemfixarna-components/scroll-6c26b5da.js.map +0 -1
  241. package/dist/hemfixarna-components/shadow-css-05e0c1f4.js +0 -389
  242. package/dist/hemfixarna-components/shadow-css-05e0c1f4.js.map +0 -1
  243. package/dist/hemfixarna-components/types-641c9a1c.js.map +0 -1
@@ -0,0 +1,4090 @@
1
+ import { f as forceUpdate, F as Fragment, c as getAssetPath, a as getElement, g as getRenderingRef, h, r as registerInstance } from './index-8c417125.js';
2
+
3
+ const appendToMap = (map, propName, value) => {
4
+ const items = map.get(propName);
5
+ if (!items) {
6
+ map.set(propName, [value]);
7
+ } else if (!items.includes(value)) {
8
+ items.push(value);
9
+ }
10
+ };
11
+ const debounce = (fn, ms) => {
12
+ let timeoutId;
13
+ return (...args) => {
14
+ if (timeoutId) {
15
+ clearTimeout(timeoutId);
16
+ }
17
+ timeoutId = setTimeout(() => {
18
+ timeoutId = 0;
19
+ fn(...args);
20
+ }, ms);
21
+ };
22
+ };
23
+
24
+ /**
25
+ * Check if a possible element isConnected.
26
+ * The property might not be there, so we check for it.
27
+ *
28
+ * We want it to return true if isConnected is not a property,
29
+ * otherwise we would remove these elements and would not update.
30
+ *
31
+ * Better leak in Edge than to be useless.
32
+ */
33
+ const isConnected = maybeElement => !('isConnected' in maybeElement) || maybeElement.isConnected;
34
+ const cleanupElements = debounce(map => {
35
+ for (let key of map.keys()) {
36
+ map.set(key, map.get(key).filter(isConnected));
37
+ }
38
+ }, 2000);
39
+ const stencilSubscription = () => {
40
+ if (typeof getRenderingRef !== 'function') {
41
+ // If we are not in a stencil project, we do nothing.
42
+ // This function is not really exported by @stencil/core.
43
+ return {};
44
+ }
45
+ const elmsToUpdate = new Map();
46
+ return {
47
+ dispose: () => elmsToUpdate.clear(),
48
+ get: propName => {
49
+ const elm = getRenderingRef();
50
+ if (elm) {
51
+ appendToMap(elmsToUpdate, propName, elm);
52
+ }
53
+ },
54
+ set: propName => {
55
+ const elements = elmsToUpdate.get(propName);
56
+ if (elements) {
57
+ elmsToUpdate.set(propName, elements.filter(forceUpdate));
58
+ }
59
+ cleanupElements(elmsToUpdate);
60
+ },
61
+ reset: () => {
62
+ elmsToUpdate.forEach(elms => elms.forEach(forceUpdate));
63
+ cleanupElements(elmsToUpdate);
64
+ },
65
+ };
66
+ };
67
+
68
+ const unwrap = val => (typeof val === 'function' ? val() : val);
69
+ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
70
+ const unwrappedState = unwrap(defaultState);
71
+ let states = new Map(Object.entries(unwrappedState !== null && unwrappedState !== void 0 ? unwrappedState : {}));
72
+ const handlers = {
73
+ dispose: [],
74
+ get: [],
75
+ set: [],
76
+ reset: [],
77
+ };
78
+ const reset = () => {
79
+ var _a;
80
+ // When resetting the state, the default state may be a function - unwrap it to invoke it.
81
+ // otherwise, the state won't be properly reset
82
+ states = new Map(Object.entries((_a = unwrap(defaultState)) !== null && _a !== void 0 ? _a : {}));
83
+ handlers.reset.forEach(cb => cb());
84
+ };
85
+ const dispose = () => {
86
+ // Call first dispose as resetting the state would
87
+ // cause less updates ;)
88
+ handlers.dispose.forEach(cb => cb());
89
+ reset();
90
+ };
91
+ const get = propName => {
92
+ handlers.get.forEach(cb => cb(propName));
93
+ return states.get(propName);
94
+ };
95
+ const set = (propName, value) => {
96
+ const oldValue = states.get(propName);
97
+ if (shouldUpdate(value, oldValue, propName)) {
98
+ states.set(propName, value);
99
+ handlers.set.forEach(cb => cb(propName, value, oldValue));
100
+ }
101
+ };
102
+ const state =
103
+ typeof Proxy === 'undefined'
104
+ ? {}
105
+ : new Proxy(unwrappedState, {
106
+ get(_, propName) {
107
+ return get(propName);
108
+ },
109
+ ownKeys(_) {
110
+ return Array.from(states.keys());
111
+ },
112
+ getOwnPropertyDescriptor() {
113
+ return {
114
+ enumerable: true,
115
+ configurable: true,
116
+ };
117
+ },
118
+ has(_, propName) {
119
+ return states.has(propName);
120
+ },
121
+ set(_, propName, value) {
122
+ set(propName, value);
123
+ return true;
124
+ },
125
+ });
126
+ const on = (eventName, callback) => {
127
+ handlers[eventName].push(callback);
128
+ return () => {
129
+ removeFromArray(handlers[eventName], callback);
130
+ };
131
+ };
132
+ const onChange = (propName, cb) => {
133
+ const unSet = on('set', (key, newValue) => {
134
+ if (key === propName) {
135
+ cb(newValue);
136
+ }
137
+ });
138
+ // We need to unwrap the defaultState because it might be a function.
139
+ // Otherwise we might not be sending the right reset value.
140
+ const unReset = on('reset', () => cb(unwrap(defaultState)[propName]));
141
+ return () => {
142
+ unSet();
143
+ unReset();
144
+ };
145
+ };
146
+ const use = (...subscriptions) => {
147
+ const unsubs = subscriptions.reduce((unsubs, subscription) => {
148
+ if (subscription.set) {
149
+ unsubs.push(on('set', subscription.set));
150
+ }
151
+ if (subscription.get) {
152
+ unsubs.push(on('get', subscription.get));
153
+ }
154
+ if (subscription.reset) {
155
+ unsubs.push(on('reset', subscription.reset));
156
+ }
157
+ if (subscription.dispose) {
158
+ unsubs.push(on('dispose', subscription.dispose));
159
+ }
160
+ return unsubs;
161
+ }, []);
162
+ return () => unsubs.forEach(unsub => unsub());
163
+ };
164
+ const forceUpdate = key => {
165
+ const oldValue = states.get(key);
166
+ handlers.set.forEach(cb => cb(key, oldValue, oldValue));
167
+ };
168
+ return {
169
+ state,
170
+ get,
171
+ set,
172
+ on,
173
+ onChange,
174
+ use,
175
+ dispose,
176
+ reset,
177
+ forceUpdate,
178
+ };
179
+ };
180
+ const removeFromArray = (array, item) => {
181
+ const index = array.indexOf(item);
182
+ if (index >= 0) {
183
+ array[index] = array[array.length - 1];
184
+ array.length--;
185
+ }
186
+ };
187
+
188
+ const createStore = (defaultState, shouldUpdate) => {
189
+ const map = createObservableMap(defaultState, shouldUpdate);
190
+ map.use(stencilSubscription());
191
+ return map;
192
+ };
193
+
194
+ const { state, onChange } = createStore({
195
+ step: 1,
196
+ checkoutStep: 1,
197
+ checkoutEdit: false,
198
+ selectedCategory: null,
199
+ selectedService: null,
200
+ selectedProduct: null,
201
+ cart: [],
202
+ business: 'undefined',
203
+ options: null,
204
+ rut: true,
205
+ rot: true,
206
+ green: true,
207
+ token: null,
208
+ user: null,
209
+ modal: null,
210
+ rutOptions: null,
211
+ rotOptions: null,
212
+ greenOptions: null,
213
+ customer: null,
214
+ selectedCustomerCategory: null,
215
+ parentCategory: null,
216
+ creditSafeUser: null,
217
+ checkoutInvoice: false,
218
+ maleri: false,
219
+ sources: null,
220
+ });
221
+ onChange('cart', cart => {
222
+ window.sessionStorage.setItem(`hemfixarna-${state.business}-cart`, JSON.stringify(cart));
223
+ });
224
+ onChange('user', user => {
225
+ window.sessionStorage.setItem(`hemfixarna-${state.business}-user`, JSON.stringify(user));
226
+ });
227
+ onChange('creditSafeUser', user => {
228
+ window.sessionStorage.setItem(`hemfixarna-${state.business}-creditSafeUser`, JSON.stringify(user));
229
+ });
230
+ onChange('selectedProduct', product => {
231
+ if (!state.customer || !product) return;
232
+ const categories = [
233
+ ...state.customer.categories,
234
+ ...state.customer.categories.map(c => {
235
+ var _a;
236
+ return (_a = c.sub_categories) !== null && _a !== void 0 ? _a : [];
237
+ }),
238
+ ].flat();
239
+ const category = categories.find(c => c && c.id === product.category);
240
+ if (category) {
241
+ state.parentCategory = category;
242
+ return;
243
+ }
244
+ state.parentCategory = null;
245
+ });
246
+ onChange('selectedCustomerCategory', category => {
247
+ if (!state.customer || !category) return;
248
+ if (category.parent) {
249
+ const parent = state.customer.categories.find(c => c.id === category.parent);
250
+ if (parent) {
251
+ state.parentCategory = parent;
252
+ return;
253
+ }
254
+ }
255
+ state.parentCategory = null;
256
+ });
257
+
258
+ const hideField = field => {
259
+ return field.split(' ').reduce((acc, curr) => {
260
+ if (curr.length <= 2) {
261
+ return acc + curr.slice(0, 1) + '* ';
262
+ } else {
263
+ return acc + curr.slice(0, 1) + '*'.repeat(curr.length - 2) + curr.slice(-1) + ' ';
264
+ }
265
+ }, '');
266
+ };
267
+
268
+ const scrollToTop = el => {
269
+ if (!el) return;
270
+ el.scrollTo({
271
+ top: 0,
272
+ behavior: 'smooth',
273
+ });
274
+ };
275
+
276
+ const HemfixarnaAddress = class {
277
+ constructor(hostRef) {
278
+ registerInstance(this, hostRef);
279
+ this.handleSubmit = e => {
280
+ e.preventDefault();
281
+ const streetValid = this.street.length > 0;
282
+ if (!streetValid) {
283
+ this.streetError = 'Ange en gatuadress';
284
+ }
285
+ const zipValid = this.zip.length > 0;
286
+ const zipIsNumber = /^\s*\d[\d\s]*$/.test(this.zip);
287
+ if (!zipIsNumber) {
288
+ this.zipError = 'Postnummer får endast innehålla siffror';
289
+ }
290
+ if (!zipValid) {
291
+ this.zipError = 'Ange ett postnummer';
292
+ }
293
+ const townValid = /^[^\d\s]{2,}$/.test(this.town);
294
+ if (!townValid) {
295
+ this.townError = 'Ange en ort';
296
+ }
297
+ if (streetValid && zipValid && townValid && zipIsNumber) {
298
+ state.user = Object.assign(Object.assign({}, state.user), { street: this.street, zip: this.zip, town: this.town });
299
+ state.checkoutStep = 2;
300
+ state.checkoutEdit = false;
301
+ const el = this.el.closest('.hemfixarna_content');
302
+ scrollToTop(el);
303
+ }
304
+ };
305
+ this.handleChangeStreet = e => {
306
+ this.streetError = null;
307
+ this.street = this.street === state.user.street ? '' : e.target.value;
308
+ };
309
+ this.handleChangeZip = e => {
310
+ this.zipError = null;
311
+ this.zip = this.zip === state.user.zip ? '' : e.target.value;
312
+ };
313
+ this.handleChangeTown = e => {
314
+ this.townError = null;
315
+ this.town = this.town === state.user.town ? '' : e.target.value;
316
+ };
317
+ this.render = () => {
318
+ return h(
319
+ 'form',
320
+ { class: 'hemfixarna_address', onSubmit: e => this.handleSubmit(e) },
321
+ h(
322
+ 'div',
323
+ null,
324
+ h('input', {
325
+ class: `${this.street.length ? 'input_active' : ''}`,
326
+ onInput: this.handleChangeStreet,
327
+ type: 'text',
328
+ name: 'street',
329
+ value: this.street === state.user.street ? hideField(this.street) : this.street,
330
+ }),
331
+ h('label', { htmlFor: 'street' }, 'Gatuaddress '),
332
+ ),
333
+ this.streetError && h('span', null, this.streetError),
334
+ h(
335
+ 'div',
336
+ null,
337
+ h('input', {
338
+ class: `${this.zip.length ? 'input_active' : ''}`,
339
+ onInput: this.handleChangeZip,
340
+ type: 'tel',
341
+ name: 'zip',
342
+ value: this.zip === state.user.zip ? hideField(this.zip) : this.zip,
343
+ }),
344
+ h('label', { htmlFor: 'zip' }, 'Postnummer '),
345
+ ),
346
+ this.zipError && h('span', null, this.zipError),
347
+ h(
348
+ 'div',
349
+ null,
350
+ h('input', {
351
+ class: `${this.town.length ? 'input_active' : ''}`,
352
+ onInput: this.handleChangeTown,
353
+ type: 'text',
354
+ name: 'town',
355
+ value: this.town === state.user.town ? hideField(this.town) : this.town,
356
+ }),
357
+ h('label', { htmlFor: 'town' }, 'Ort '),
358
+ ),
359
+ this.townError && h('span', null, this.townError),
360
+ h('input', { type: 'submit', value: 'Forts\u00E4tt' }),
361
+ );
362
+ };
363
+ this.street = '';
364
+ this.streetError = null;
365
+ this.zip = '';
366
+ this.zipError = null;
367
+ this.town = '';
368
+ this.townError = null;
369
+ }
370
+ componentWillLoad() {
371
+ if (state.user) {
372
+ this.street = state.user.street;
373
+ this.zip = state.user.zip;
374
+ this.town = state.user.town;
375
+ }
376
+ }
377
+ get el() {
378
+ return getElement(this);
379
+ }
380
+ };
381
+
382
+ const getRutPrice = price => {
383
+ return Math.ceil(price / 2);
384
+ };
385
+ const getRotPrice = price => {
386
+ return Math.ceil(price * 0.7);
387
+ };
388
+ const getGreenPrice = price => {
389
+ return Math.ceil(price * 0.5);
390
+ };
391
+ const getProductPrice = (product, price, amount = 1) => {
392
+ if (product.rot && state.rot) {
393
+ return getRotPrice((price || product.price) * amount);
394
+ } else if (product.rut && state.rut) {
395
+ return getRutPrice((price || product.price) * amount);
396
+ } else if (product.green && state.green) {
397
+ return getGreenPrice((price || product.price) * amount);
398
+ } else {
399
+ return (price || product.price) * amount;
400
+ }
401
+ };
402
+ const getProductPriceWithRotAndRut = product => {
403
+ if (product.rot) {
404
+ return getRotPrice(product.price);
405
+ } else if (product.rut && state.rut) {
406
+ return getRutPrice(product.price);
407
+ } else {
408
+ return product.price;
409
+ }
410
+ };
411
+ const getPartPrice = (part, product, amount = 1) => {
412
+ if (product.rot && state.rot) {
413
+ return getRotPrice(part.price * amount);
414
+ } else if (product.rut && state.rut) {
415
+ return getRutPrice(part.price * amount);
416
+ } else {
417
+ return part.price * amount;
418
+ }
419
+ };
420
+ const getStartFee = () => {
421
+ if (!state.cart) return { rut: 0, rot: 0, green: 0 };
422
+ const hasRut = state.cart.some(item => item.rut && item.start_fee);
423
+ const hasRot = state.cart.some(item => item.rot && item.start_fee);
424
+ const hasGreen = state.cart.some(item => item.green && item.start_fee);
425
+ const rutPrice = state.rut ? getRutPrice(state.options.start_fee) : state.options.start_fee * 1;
426
+ const rotPrice = state.rot ? getRotPrice(state.options.start_fee) : state.options.start_fee * 1;
427
+ const greenPrice = state.green ? getGreenPrice(state.options.start_fee) : state.options.start_fee * 1;
428
+ return { rut: hasRut ? rutPrice : 0, rot: hasRot ? rotPrice : 0, green: hasGreen ? greenPrice : 0, length: [hasRut, hasRot, hasGreen].filter(d => d).length };
429
+ // if (hasRut && hasRot) {
430
+ // return { rut: rutPrice, rot: rotPrice, length: 2 };
431
+ // } else if (hasRut) {
432
+ // return { rut: rutPrice, rot: 0, length: 1 };
433
+ // } else if (hasRot) {
434
+ // return { rut: 0, rot: rotPrice, length: 1 };
435
+ // } else {
436
+ // return { rut: 0, rot: 0, length: 0 };
437
+ // }
438
+ };
439
+ const getItemPrice = item => {
440
+ const partsPrice = item.parts.reduce((acc, curr) => {
441
+ return acc + curr.price * curr.amount;
442
+ }, 0);
443
+ return getProductPrice(item, item.price * item.amount + partsPrice);
444
+ };
445
+ const calculateRot = () => {
446
+ const totalWithRot =
447
+ state.cart.reduce((acc, curr) => {
448
+ return curr.rot ? acc + getItemPrice(curr) : acc;
449
+ }, 0) + getStartFee().rot;
450
+ const totalWithoutRot =
451
+ state.cart.reduce((acc, curr) => {
452
+ const partsPrice = curr.parts.reduce((acc, curr) => {
453
+ return acc + curr.price * curr.amount;
454
+ }, 0);
455
+ return curr.rot ? acc + curr.price * curr.amount + partsPrice : acc;
456
+ }, 0) + Number(state.options.start_fee);
457
+ return totalWithoutRot - totalWithRot;
458
+ };
459
+ const calculateRut = () => {
460
+ const totalWithRut =
461
+ state.cart.reduce((acc, curr) => {
462
+ return curr.rut ? acc + getItemPrice(curr) : acc;
463
+ }, 0) + getStartFee().rut;
464
+ const totalWithoutRut =
465
+ state.cart.reduce((acc, curr) => {
466
+ const partsPrice = curr.parts.reduce((acc, curr) => {
467
+ return acc + curr.price * curr.amount;
468
+ }, 0);
469
+ return curr.rut ? acc + curr.price * curr.amount + partsPrice : acc;
470
+ }, 0) + Number(state.options.start_fee);
471
+ return totalWithoutRut - totalWithRut;
472
+ };
473
+ const calculateGreenDiscount = () => {
474
+ const totalWithGreen =
475
+ state.cart.reduce((acc, curr) => {
476
+ return curr.green ? acc + getItemPrice(curr) : acc;
477
+ }, 0) + getStartFee().green;
478
+ const totalWithoutGreen =
479
+ state.cart.reduce((acc, curr) => {
480
+ const partsPrice = curr.parts.reduce((acc, curr) => {
481
+ return acc + curr.price * curr.amount;
482
+ }, 0);
483
+ return curr.green ? acc + curr.price * curr.amount + partsPrice : acc;
484
+ }, 0) + Number(state.options.start_fee);
485
+ return totalWithoutGreen - totalWithGreen;
486
+ };
487
+ const getTotalPrice = () => {
488
+ return state.cart.reduce((acc, curr) => acc + getItemPrice(curr), 0) + getStartFee().rot + getStartFee().rut;
489
+ };
490
+
491
+ var Business;
492
+ (function (Business) {
493
+ Business['kund'] = 'kund';
494
+ Business['byggmax'] = 'byggmax';
495
+ Business['skanska'] = 'skanska';
496
+ Business['string'] = 'string-furniture';
497
+ Business['hornbach'] = 'hornbach';
498
+ Business['forebygg'] = 'forebygg';
499
+ Business['doro'] = 'doro';
500
+ Business['elfa'] = 'elfa';
501
+ Business['kbygg'] = 'k-bygg';
502
+ Business['norrgavel'] = 'norrgavel';
503
+ Business['fargvaruhuset'] = 'fargvaruhuset';
504
+ Business['zaptec'] = 'zaptec';
505
+ Business['tesla'] = 'tesla';
506
+ Business['klint'] = 'klint';
507
+ Business['flyttsmart'] = 'flyttsmart';
508
+ Business['lg'] = 'lg';
509
+ Business['sparfonster'] = 'sparfonster';
510
+ Business['power'] = 'power';
511
+ Business['traningspartner'] = 'traningspartner';
512
+ Business['superfront'] = 'superfront';
513
+ })(Business || (Business = {}));
514
+ var WidgetStyle;
515
+ (function (WidgetStyle) {
516
+ WidgetStyle['standard'] = 'standard';
517
+ WidgetStyle['alternative'] = 'alternative';
518
+ WidgetStyle['alternative_2'] = 'alternative_2';
519
+ WidgetStyle['alternative_3'] = 'alternative_3';
520
+ })(WidgetStyle || (WidgetStyle = {}));
521
+ var TopCategory;
522
+ (function (TopCategory) {
523
+ TopCategory['byggmax'] = 'category/bygg';
524
+ })(TopCategory || (TopCategory = {}));
525
+
526
+ const isProduct = category => {
527
+ return category.post_name !== undefined;
528
+ };
529
+ const isBusiness = partner => {
530
+ return Object.values(Business).includes(partner);
531
+ };
532
+
533
+ const HemfixarnaBox = class {
534
+ constructor(hostRef) {
535
+ registerInstance(this, hostRef);
536
+ this.post = undefined;
537
+ this.category = undefined;
538
+ this.icon = undefined;
539
+ this.postTitle = undefined;
540
+ }
541
+ setTaxonomy(taxonomy) {
542
+ if (taxonomy) {
543
+ if ((taxonomy === null || taxonomy === void 0 ? void 0 : taxonomy.taxonomy) === 'service_cat') {
544
+ state.selectedCategory = taxonomy;
545
+ state.step = 2;
546
+ } else if ((taxonomy === null || taxonomy === void 0 ? void 0 : taxonomy.post_type) === 'service') {
547
+ state.selectedService = taxonomy;
548
+ state.step = 3;
549
+ } else if ((taxonomy === null || taxonomy === void 0 ? void 0 : taxonomy.post_type) === 'ikea_product') {
550
+ state.selectedProduct = taxonomy;
551
+ state.step = 4;
552
+ }
553
+ const el = this.el.closest('.hemfixarna_content');
554
+ scrollToTop(el);
555
+ }
556
+ }
557
+ setProduct() {
558
+ state.selectedProduct = this.category;
559
+ state.step = 4;
560
+ state.selectedCustomerCategory = null;
561
+ const el = this.el.closest('.hemfixarna_content');
562
+ scrollToTop(el);
563
+ }
564
+ render() {
565
+ return this.category
566
+ ? h(
567
+ Fragment,
568
+ null,
569
+ isProduct(this.category)
570
+ ? h(
571
+ 'li',
572
+ { onClick: () => this.setProduct() },
573
+ h('img', { class: 'hemfixarna_logo', height: 82, src: this.category.icon, alt: this.category.post_name }),
574
+ h('div', null, h('p', null, this.category.title), !this.category.invoice ? h('p', { class: 'price' }, 'Fr\u00E5n ', getProductPrice(this.category), 'kr') : null),
575
+ )
576
+ : h(
577
+ 'li',
578
+ { onClick: () => (state.selectedCustomerCategory = this.category) },
579
+ h('img', { class: 'hemfixarna_logo', height: 82, src: this.category.icon, alt: this.category.name }),
580
+ h('div', null, h('p', null, this.category.name)),
581
+ ),
582
+ )
583
+ : h(
584
+ 'li',
585
+ { onClick: () => this.setTaxonomy(this.post) },
586
+ this.post.icon && h('img', { class: 'hemfixarna_logo', height: 82, src: this.icon, alt: this.postTitle }),
587
+ h('div', null, h('p', null, this.postTitle), state.step === 3 && h('p', { class: 'price' }, 'Fr\u00E5n ', getProductPrice(this.post), 'kr')),
588
+ );
589
+ }
590
+ get el() {
591
+ return getElement(this);
592
+ }
593
+ };
594
+
595
+ const HemfixarnaBreadcrumbs = class {
596
+ constructor(hostRef) {
597
+ registerInstance(this, hostRef);
598
+ this.triggerScrollTotop = () => {
599
+ const el = this.el.nextSibling;
600
+ scrollToTop(el);
601
+ };
602
+ this.tree = undefined;
603
+ this.closeModal = undefined;
604
+ this.loadFromQuery = false;
605
+ this.isDemo = false;
606
+ }
607
+ getCartLength() {
608
+ return state.cart.reduce((acc, curr) => acc + curr.amount, 0);
609
+ }
610
+ handleCartClick() {
611
+ var _a;
612
+ if ((_a = state.cart) === null || _a === void 0 ? void 0 : _a.length) {
613
+ state.step = 5;
614
+ this.triggerScrollTotop();
615
+ }
616
+ }
617
+ handleHomePageClick() {
618
+ state.step = 1;
619
+ state.parentCategory = null;
620
+ state.selectedCustomerCategory = null;
621
+ this.triggerScrollTotop();
622
+ setTimeout(() => {
623
+ state.selectedCategory = null;
624
+ state.selectedProduct = null;
625
+ state.maleri = null;
626
+ state.selectedService = null;
627
+ }, 200);
628
+ }
629
+ render() {
630
+ const logo = getAssetPath(`./assets/hemfixarna.svg`);
631
+ const close = getAssetPath(`./assets/close.svg`);
632
+ const cart = getAssetPath(`./assets/cart.svg`);
633
+ const back = getAssetPath(`./assets/back.svg`);
634
+ return h(
635
+ 'div',
636
+ null,
637
+ h(
638
+ 'div',
639
+ { class: 'hemfixarna_crumbs' },
640
+ h(
641
+ 'div',
642
+ { class: 'hemfixarna_crumbs--links' },
643
+ h('img', { onClick: () => this.handleHomePageClick(), src: logo, width: 110 }),
644
+ !this.loadFromQuery || this.isDemo ? h('img', { onClick: () => this.closeModal(), class: 'close', src: close, width: 32 }) : null,
645
+ h('div', null, h('button', { onClick: () => this.handleHomePageClick() }, 'Alla tj\u00E4nster')),
646
+ ),
647
+ h(
648
+ 'div',
649
+ { class: 'hemfixarna_crumbs--right' },
650
+ h('hemfixarna-contact', null),
651
+ h(
652
+ 'div',
653
+ { onClick: () => this.handleCartClick(), class: `cart ${this.getCartLength() > 0 ? 'cart_active' : ''}` },
654
+ h('img', { src: cart, width: 24 }),
655
+ h('span', null, this.getCartLength()),
656
+ ),
657
+ ),
658
+ ),
659
+ [3, 4].includes(state.step) &&
660
+ !state.customer &&
661
+ h(
662
+ 'button',
663
+ {
664
+ class: 'hemfixarna_crumbs--back',
665
+ onClick: () => {
666
+ state.step = state.step === 4 ? 3 : 2;
667
+ },
668
+ },
669
+ h('img', { width: 24, src: back, alt: 'back arrow' }),
670
+ h('span', null, 'Se allt ', state.step === 4 ? state.selectedService.post_title : state.selectedCategory.name),
671
+ ),
672
+ !state.parentCategory &&
673
+ state.step &&
674
+ state.selectedCustomerCategory &&
675
+ h(
676
+ 'button',
677
+ {
678
+ class: 'hemfixarna_crumbs--back',
679
+ onClick: () => {
680
+ state.step = 1;
681
+ state.selectedCustomerCategory = null;
682
+ state.selectedProduct = null;
683
+ state.maleri = null;
684
+ },
685
+ },
686
+ h('img', { width: 24, src: back, alt: 'back arrow' }),
687
+ h('span', null, 'Se alla tj\u00E4nster'),
688
+ ),
689
+ state.parentCategory &&
690
+ state.step < 5 &&
691
+ h(
692
+ 'button',
693
+ {
694
+ class: 'hemfixarna_crumbs--back',
695
+ onClick: () => {
696
+ state.step = 1;
697
+ state.selectedCustomerCategory = state.parentCategory;
698
+ state.selectedProduct = null;
699
+ state.maleri = null;
700
+ },
701
+ },
702
+ h('img', { width: 24, src: back, alt: 'back arrow' }),
703
+ h('span', null, 'Se allt ', state.parentCategory.name),
704
+ ),
705
+ );
706
+ }
707
+ get el() {
708
+ return getElement(this);
709
+ }
710
+ };
711
+
712
+ const hemfixarnaByggmaxCss = '';
713
+
714
+ const MyComponent$j = class {
715
+ constructor(hostRef) {
716
+ registerInstance(this, hostRef);
717
+ this.tree = null;
718
+ this.slug = undefined;
719
+ this.id = undefined;
720
+ this.forceOldTree = false;
721
+ this.loadFromQuery = undefined;
722
+ this.customer = undefined;
723
+ this.widgetStyle = WidgetStyle.standard;
724
+ this.buttonColor = undefined;
725
+ this.buttonBg = undefined;
726
+ }
727
+ render() {
728
+ return h('hemfixarna-component', {
729
+ forceOldTree: this.forceOldTree,
730
+ id: this.id,
731
+ slug: this.slug,
732
+ business: Business.byggmax,
733
+ topCategory: TopCategory.byggmax,
734
+ loadFromQuery: Boolean(this.loadFromQuery),
735
+ widgetStyle: this.widgetStyle,
736
+ buttonBg: this.buttonBg,
737
+ buttonColor: this.buttonColor,
738
+ });
739
+ }
740
+ };
741
+ MyComponent$j.style = hemfixarnaByggmaxCss;
742
+
743
+ const HemfixarnaCart = class {
744
+ constructor(hostRef) {
745
+ registerInstance(this, hostRef);
746
+ this.tree = undefined;
747
+ }
748
+ render() {
749
+ const back = getAssetPath(`./assets/back.svg`);
750
+ return h(
751
+ 'div',
752
+ { class: 'hemfixarna_cart' },
753
+ h(
754
+ 'div',
755
+ { class: 'hemfixarna_cart--left' },
756
+ h(
757
+ 'h2',
758
+ null,
759
+ state.checkoutStep === 2 &&
760
+ !state.checkoutEdit &&
761
+ h(
762
+ 'button',
763
+ {
764
+ onClick: () => {
765
+ state.checkoutStep = 1;
766
+ },
767
+ },
768
+ h('img', { width: 24, src: back, alt: 'back arrow' }),
769
+ ),
770
+ 'Din bokning',
771
+ ),
772
+ h('hemfixarna-orderrows', { tree: this.tree }),
773
+ ),
774
+ h(
775
+ 'div',
776
+ { class: 'hemfixarna_cart--right' },
777
+ h(
778
+ 'h2',
779
+ null,
780
+ state.checkoutStep === 2 &&
781
+ !state.checkoutEdit &&
782
+ h(
783
+ 'button',
784
+ {
785
+ onClick: () => {
786
+ state.checkoutStep = 1;
787
+ },
788
+ },
789
+ h('img', { width: 24, src: back, alt: 'back arrow' }),
790
+ ),
791
+ 'Dina uppgifter',
792
+ ),
793
+ h('hemfixarna-checkout', null),
794
+ h('hemfixarna-info', null),
795
+ ),
796
+ );
797
+ }
798
+ };
799
+
800
+ const HemfixarnaCategory = class {
801
+ constructor(hostRef) {
802
+ registerInstance(this, hostRef);
803
+ }
804
+ setSelectedService(service) {
805
+ state.selectedService = service;
806
+ state.step = 3;
807
+ }
808
+ render() {
809
+ return h(
810
+ 'div',
811
+ null,
812
+ h('h2', null, state.selectedCategory.name),
813
+ h(
814
+ 'div',
815
+ { class: 'hemfixarna_categories--wrapper' },
816
+ h(
817
+ 'div',
818
+ null,
819
+ h(
820
+ 'ul',
821
+ { class: 'hemfixarna_categories' },
822
+ state.selectedCategory.services
823
+ .sort((a, b) => (a.post_title < b.post_title ? -1 : 1))
824
+ .map(s => {
825
+ var _a;
826
+ return h('hemfixarna-box', { post: s, icon: (_a = s.icon.url) !== null && _a !== void 0 ? _a : s.icon, postTitle: s.post_title });
827
+ }),
828
+ ),
829
+ ),
830
+ h('hemfixarna-info', null),
831
+ ),
832
+ );
833
+ }
834
+ };
835
+
836
+ const base$2 = `${'https://hemfixarna.se'}/wp-json/headless`;
837
+ async function fetchWithType(request, options) {
838
+ const response = await fetch(request, options);
839
+ const body = await response.json();
840
+ return body;
841
+ }
842
+ const getTaxonomy = async endpoint => {
843
+ if (!endpoint) {
844
+ return;
845
+ }
846
+ const type = endpoint.split('/')[0];
847
+ const slug = endpoint.split('/')[1];
848
+ try {
849
+ const res = await fetch(`${base$2}/${type}/${slug}`);
850
+ return await res.json();
851
+ } catch (error) {
852
+ console.log(error);
853
+ }
854
+ };
855
+ const getCustomer = async slug => {
856
+ try {
857
+ const res = await fetch(`${base$2}/customer/${slug}`);
858
+ return await res.json();
859
+ } catch (error) {
860
+ console.log(error);
861
+ }
862
+ };
863
+ const getOptions = async () => {
864
+ try {
865
+ const res = await fetch(`${base$2}/webcoptions`);
866
+ return await res.json();
867
+ } catch (error) {
868
+ console.log(error);
869
+ }
870
+ };
871
+ const getRut = async () => {
872
+ try {
873
+ const data = await fetchWithType(`${base$2}/rut`);
874
+ return data;
875
+ } catch (error) {
876
+ console.log(error);
877
+ }
878
+ };
879
+ const getRot = async () => {
880
+ try {
881
+ const res = await fetch(`${base$2}/rot`);
882
+ return await res.json();
883
+ } catch (error) {
884
+ console.log(error);
885
+ }
886
+ };
887
+ const getGreenDiscount = async () => {
888
+ try {
889
+ const res = await fetch(`${base$2}/green-discount`);
890
+ return await res.json();
891
+ } catch (error) {
892
+ console.log(error);
893
+ }
894
+ };
895
+ const postOrder = async data => {
896
+ try {
897
+ const res = await fetch(`${base$2}/weborder`, {
898
+ method: 'POST',
899
+ body: JSON.stringify(data),
900
+ headers: {
901
+ 'Content-Type': 'application/json',
902
+ },
903
+ });
904
+ return await res.json();
905
+ } catch (error) {
906
+ console.log(error);
907
+ }
908
+ };
909
+
910
+ const base$1 = `${'https://hemfixarna.se'}/wp-json/felix`;
911
+ const postPerson = async felixOrder => {
912
+ try {
913
+ return await fetchWithType(`${base$1}/createperson`, {
914
+ method: 'POST',
915
+ body: JSON.stringify(felixOrder),
916
+ headers: {
917
+ 'Content-Type': 'application/json',
918
+ },
919
+ });
920
+ } catch (error) {
921
+ console.log(error);
922
+ }
923
+ };
924
+
925
+ const HemfixarnaCheckout = class {
926
+ constructor(hostRef) {
927
+ registerInstance(this, hostRef);
928
+ this.handleChangeDate = e => {
929
+ this.dateError = null;
930
+ this.date = e.target.value;
931
+ };
932
+ this.handleChangeTerms = () => {
933
+ this.generalError = null;
934
+ };
935
+ this.sendOrder = async () => {
936
+ var _a, _b, _c, _d;
937
+ if (this.loading) return;
938
+ this.loading = true;
939
+ let order = {
940
+ firstName: state.creditSafeUser.firstName,
941
+ lastName: state.creditSafeUser.lastName,
942
+ street: state.user.street,
943
+ zip: state.user.zip,
944
+ town: state.user.town,
945
+ ssn: state.user.ssn,
946
+ email: state.user.email,
947
+ phone: state.user.phone,
948
+ url: `${state.business === Business.string ? 'string' : state.business}-webk`,
949
+ date: this.date,
950
+ products: [
951
+ ...state.cart.map(item => {
952
+ const parts = item.parts.map(part => ({
953
+ id: String(part.id),
954
+ name: part.name,
955
+ quantity: part.amount,
956
+ rut: 0,
957
+ rot: 0,
958
+ }));
959
+ return [
960
+ {
961
+ id: String(item.id),
962
+ name: item.name,
963
+ quantity: item.amount,
964
+ rot: item.rot ? 1 : 0,
965
+ rut: item.rut ? 1 : 0,
966
+ },
967
+ ...parts,
968
+ ];
969
+ }),
970
+ ].flat(),
971
+ creditSafe: state.creditSafeUser,
972
+ customer: state.business,
973
+ id_source: '',
974
+ id_sub_source: '',
975
+ seller_id: (_a = this.sellerID) !== null && _a !== void 0 ? _a : '',
976
+ referral_id: (_b = this.RefferalID) !== null && _b !== void 0 ? _b : '',
977
+ };
978
+ const felixOrder = await postPerson(order);
979
+ if (!felixOrder || !((_d = (_c = felixOrder.response) === null || _c === void 0 ? void 0 : _c.scriptResult) === null || _d === void 0 ? void 0 : _d.includes('OK'))) {
980
+ order = Object.assign(Object.assign({}, order), { felixStatus: 'error' });
981
+ } else {
982
+ order = Object.assign(Object.assign({}, order), { felixStatus: 'success' });
983
+ }
984
+ try {
985
+ const { data: orderConfirm, status } = await postOrder(order);
986
+ if (orderConfirm && status && status === 200) {
987
+ state.step = 6;
988
+ const el = this.el.closest('.hemfixarna_content');
989
+ scrollToTop(el);
990
+ } else {
991
+ this.generalError = 'Något gick fel, försök igen senare';
992
+ }
993
+ } catch (error) {
994
+ this.generalError = 'Något gick fel, försök igen senare';
995
+ }
996
+ this.loading = false;
997
+ };
998
+ this.handleSubmit = e => {
999
+ e.preventDefault();
1000
+ this.generalError = null;
1001
+ const validDate = this.date.length > 0;
1002
+ if (!validDate) {
1003
+ this.dateError = 'Ange ett giltigt datum';
1004
+ }
1005
+ const checkBoxes = Array.from(this.el.querySelectorAll('input[type="checkbox"]'));
1006
+ const notValidTerms = checkBoxes.find(i => !i.checked);
1007
+ if (notValidTerms) {
1008
+ this.generalError = 'Du måste godkänna villkoren';
1009
+ }
1010
+ // if (state.customer.source) {
1011
+ // if (!this.sellerID) {
1012
+ // this.generalError = 'Ange säljare';
1013
+ // return;
1014
+ // }
1015
+ // if (state.customer.source.sub_sources?.length && !this.selectedSubSource) {
1016
+ // this.generalError = 'Välj underkälla';
1017
+ // return;
1018
+ // }
1019
+ // }
1020
+ if (validDate && !notValidTerms) {
1021
+ this.sendOrder();
1022
+ }
1023
+ };
1024
+ this.handleKeyDown = event => {
1025
+ this.enteredPin += event.key;
1026
+ const correctPin = '+0033';
1027
+ if (this.enteredPin.length === correctPin.length) {
1028
+ if (this.enteredPin === correctPin) {
1029
+ localStorage.setItem('show_sources', 'true');
1030
+ this.showSources = true;
1031
+ window.removeEventListener('keydown', this.handleKeyDown);
1032
+ }
1033
+ this.enteredPin = '';
1034
+ }
1035
+ clearTimeout(this.pinTimeout);
1036
+ this.pinTimeout = setTimeout(() => (this.enteredPin = ''), 5000);
1037
+ };
1038
+ this.render = () => {
1039
+ var _a;
1040
+ const dateLogo = getAssetPath(`./assets/date.svg`);
1041
+ const down = getAssetPath(`./assets/down.svg`);
1042
+ const loading = getAssetPath(`./assets/spinner.gif`);
1043
+ if (state.checkoutEdit) {
1044
+ return h('hemfixarna-address', null);
1045
+ } else if (state.checkoutStep === 1) {
1046
+ return h('hemfixarna-getuser', null);
1047
+ } else if (state.checkoutStep === 2) {
1048
+ return h(
1049
+ 'div',
1050
+ { class: 'mb-2' },
1051
+ h(
1052
+ 'div',
1053
+ { class: 'hemfixarna_addressinfo' },
1054
+ h(
1055
+ 'div',
1056
+ null,
1057
+ h('p', null, hideField(state.user.firstName)),
1058
+ h('p', null, hideField(state.user.lastName)),
1059
+ h('p', null, state.user.email),
1060
+ h('p', null, state.user.phone),
1061
+ ),
1062
+ h('div', null, h('p', null, hideField(state.user.street)), h('p', null, hideField(state.user.zip)), h('p', null, hideField(state.user.town))),
1063
+ h('button', { onClick: () => (state.checkoutEdit = true) }, 'Beh\u00F6ver du \u00E4ndra adressen?'),
1064
+ ),
1065
+ h(
1066
+ 'form',
1067
+ { onSubmit: e => this.handleSubmit(e) },
1068
+ h(
1069
+ 'div',
1070
+ null,
1071
+ h('img', { src: dateLogo, width: 24 }),
1072
+ h('input', {
1073
+ class: `${this.date.length ? 'input_active' : ''}`,
1074
+ min: new Date().toISOString().split('T')[0],
1075
+ onChange: e => this.handleChangeDate(e),
1076
+ type: 'date',
1077
+ name: 'date',
1078
+ value: this.date,
1079
+ }),
1080
+ h('label', { htmlFor: 'date' }, 'Tidigaste datum f\u00F6r hembes\u00F6k'),
1081
+ h('img', { src: down, width: 24 }),
1082
+ ),
1083
+ this.dateError && h('span', null, this.dateError),
1084
+ state.customer.source && this.showSources
1085
+ ? h(
1086
+ Fragment,
1087
+ null,
1088
+ h('p', null, 'Inloggad som:', h('strong', null, ' ', state.customer.source.fieldData.So01_Name)),
1089
+ h('label', null, 'S\u00E4ljare (S\u00E4ljarId)', h('input', { type: 'text', value: this.sellerID, onChange: e => (this.sellerID = e.target.value) })),
1090
+ h('label', null, 'PartnerOrderID (RefferalID)', h('input', { type: 'text', value: this.RefferalID, onChange: e => (this.RefferalID = e.target.value) })),
1091
+ ((_a = state.customer.source.sub_sources) === null || _a === void 0 ? void 0 : _a.length)
1092
+ ? h(
1093
+ 'div',
1094
+ null,
1095
+ h(
1096
+ 'select',
1097
+ { onChange: e => (this.selectedSubSource = e.target.value) },
1098
+ h('option', { disabled: true, selected: true, value: 'null' }, 'V\u00E4lj underk\u00E4lla'),
1099
+ state.customer.source.sub_sources.map(sub => h('option', { value: sub['So_SubSource::_id'] }, sub['So_SubSource::Sus01_Name'])),
1100
+ ),
1101
+ )
1102
+ : h('h4', null, 'Det finns inga underk\u00E4llor att v\u00E4lja'),
1103
+ )
1104
+ : null,
1105
+ h('label', { class: 'hemfixarna_checkbox' }, h('input', { onChange: () => this.handleChangeTerms(), type: 'checkbox' }), h('span', { innerHTML: state.options.terms })),
1106
+ state.cart
1107
+ .filter(i => {
1108
+ var _a;
1109
+ return (_a = i.terms_checkout) === null || _a === void 0 ? void 0 : _a.length;
1110
+ })
1111
+ .map(item =>
1112
+ h(
1113
+ Fragment,
1114
+ null,
1115
+ h('label', { class: 'hemfixarna_checkbox' }, h('input', { onChange: () => this.handleChangeTerms(), type: 'checkbox' }), h('span', null, item.terms_checkout)),
1116
+ ),
1117
+ ),
1118
+ this.generalError && h('span', null, this.generalError),
1119
+ h(
1120
+ 'div',
1121
+ { class: this.loading ? 'loading' : '' },
1122
+ h('input', { type: 'submit', value: this.loading ? '' : 'Skicka bokning' }),
1123
+ h('img', { width: 20, height: 20, src: loading, alt: 'spinner' }),
1124
+ ),
1125
+ ),
1126
+ );
1127
+ }
1128
+ };
1129
+ this.date = '';
1130
+ this.dateError = null;
1131
+ this.generalError = null;
1132
+ this.loading = false;
1133
+ this.enteredPin = '';
1134
+ this.selectedSubSource = null;
1135
+ this.partnerOrderId = null;
1136
+ this.showSources = false;
1137
+ this.sellerID = null;
1138
+ this.RefferalID = null;
1139
+ }
1140
+ componentWillLoad() {
1141
+ if (Boolean(state.user && state.user.street)) {
1142
+ state.checkoutStep = 2;
1143
+ }
1144
+ if (state.customer && state.customer.source) {
1145
+ window.addEventListener('keydown', this.handleKeyDown);
1146
+ }
1147
+ const showSources = localStorage.getItem('show_sources');
1148
+ if (showSources) {
1149
+ this.showSources = true;
1150
+ }
1151
+ }
1152
+ disconnectedCallback() {
1153
+ window.removeEventListener('keydown', this.handleKeyDown);
1154
+ }
1155
+ get el() {
1156
+ return getElement(this);
1157
+ }
1158
+ };
1159
+
1160
+ const hemfixarnaCss =
1161
+ '@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap");\n@keyframes fadeIn {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n* {\n box-sizing: border-box;\n}\n\n:host {\n font-family: "Inter", sans-serif;\n}\n:host input[type=text] {\n padding: 16px;\n width: 100%;\n font-size: 16px;\n border: 1px solid #fcd9c9;\n}\n:host .mb-2 {\n margin-bottom: 32px;\n}\n:host button {\n color: #474444;\n}\n:host form {\n display: flex;\n flex-direction: column;\n gap: 16px;\n position: relative;\n}\n:host form button {\n position: absolute;\n right: 0;\n top: -1rem;\n}\n:host form img {\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n pointer-events: none;\n}\n:host form img:first-of-type {\n left: 16px;\n}\n:host form img:last-of-type {\n right: 16px;\n}\n:host form span {\n margin-top: -8px;\n color: #ec6632;\n}\n:host form p {\n text-align: center;\n}\n:host form p {\n margin: 0;\n}\n:host form div {\n position: relative;\n}\n:host form div label {\n pointer-events: none;\n position: absolute;\n left: 16px;\n top: 50%;\n transform: translateY(-50%);\n background: #fff;\n padding: 4px;\n transition: 0.2s all cubic-bezier(0.465, 0.183, 0.153, 0.946);\n}\n:host form div input {\n padding: 16px;\n width: 100%;\n font-size: 16px;\n border: 1px solid #fcd9c9;\n}\n:host form div input:focus ~ label,\n:host form div .input_active ~ label {\n top: 0;\n transform: translateY(-50%);\n background: linear-gradient(180deg, #fffaf2 50%, #fff 50%);\n}\n:host form select {\n padding: 0.75rem 1rem;\n width: 100%;\n}\n:host h1 {\n font-size: 24px;\n font-weight: 400;\n line-height: 32px;\n letter-spacing: -3%;\n text-align: left;\n margin: 0 0 8px;\n}\n:host h2 {\n margin: 0 0 24px;\n font-weight: 700;\n font-size: 20px;\n line-height: 28px;\n letter-spacing: -3%;\n}\n:host p {\n font-size: 16px;\n font-weight: 400;\n line-height: 24px;\n letter-spacing: -3%;\n}\n:host .hemfixarna {\n width: 100%;\n /* Hide default HTML checkbox */\n /* The slider */\n}\n:host .hemfixarna_contact {\n display: flex;\n gap: 16px;\n}\n:host .hemfixarna_contact a {\n display: flex;\n align-items: center;\n gap: 8px;\n color: #474444;\n text-decoration: none;\n font-weight: 600;\n font-size: 13px;\n}\n:host .hemfixarna_contact a:hover {\n text-decoration: underline;\n}\n:host .hemfixarna_contact--horizontal span {\n display: none;\n}\n@media (min-width: 769px) {\n :host .hemfixarna_contact--horizontal span {\n display: initial;\n }\n}\n:host .hemfixarna_painting {\n opacity: 0;\n padding: 0 1rem;\n animation: fadeIn 0.5s forwards 0.3s;\n}\n:host .hemfixarna_painting > h2,\n:host .hemfixarna_painting p {\n text-align: center;\n padding: 0 16px;\n}\n:host .hemfixarna_painting > h2 {\n margin: 0 0 8px;\n}\n:host .hemfixarna_partnerlogo {\n max-height: 50px;\n min-height: 45px;\n object-fit: contain;\n max-width: 150px;\n}\n@media (min-width: 769px) {\n :host .hemfixarna_partnerlogo {\n max-width: 200px;\n }\n}\n:host .hemfixarna_nav {\n position: absolute;\n top: 0;\n width: 100dvw;\n left: 0;\n height: 80px;\n z-index: 9999;\n}\n:host .hemfixarna_nav--links {\n display: none !important;\n}\n@media (min-width: 769px) {\n :host .hemfixarna_nav--links {\n display: flex !important;\n }\n}\n:host .hemfixarna_nav--links a {\n color: #ec6632;\n text-decoration: none;\n border: 1px solid rgba(255, 255, 255, 0.3);\n border-radius: 56px;\n padding: 8px 32px;\n text-transform: capitalize;\n}\n:host .hemfixarna_nav > div {\n position: relative;\n overflow: hidden;\n width: 100%;\n height: 100%;\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 0 16px;\n}\n@media (min-width: 769px) {\n :host .hemfixarna_nav > div {\n padding: 0 32px;\n }\n}\n:host .hemfixarna_nav > div > div {\n display: flex;\n gap: 32px;\n justify-content: space-between;\n}\n:host .hemfixarna_nav > div > img {\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n z-index: -1;\n}\n:host .hemfixarna_nav a {\n text-decoration: none;\n}\n:host .hemfixarna_nav p {\n color: #474444;\n}\n:host .hemfixarna_nav p.with-bg {\n color: #fff;\n}\n:host .hemfixarna_standalone .hemfixarna_backdrop {\n background: #fffaf2;\n opacity: 1;\n}\n:host .hemfixarna_standalone .hemfixarna_modal {\n top: 80px;\n transform: translateX(-50%);\n border: none;\n height: calc(100dvh - 80px);\n opacity: 0;\n}\n:host .hemfixarna_standalone .hemfixarna_modal--open {\n opacity: 1;\n}\n:host .hemfixarna .switch {\n position: relative;\n display: inline-block;\n width: 40px;\n height: 20px;\n}\n:host .hemfixarna .switch input {\n opacity: 0;\n width: 0;\n height: 0;\n}\n:host .hemfixarna .slider {\n position: absolute;\n cursor: pointer;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #ccc;\n -webkit-transition: 0.4s;\n transition: 0.4s;\n border-radius: 34px;\n}\n:host .hemfixarna .slider:before {\n position: absolute;\n content: "";\n height: 18px;\n width: 18px;\n left: 2px;\n bottom: 1px;\n background-color: white;\n -webkit-transition: 0.4s;\n transition: 0.4s;\n border-radius: 50%;\n}\n:host .hemfixarna input:checked + .slider {\n background-color: #fcd9c9;\n}\n:host .hemfixarna input:focus + .slider {\n box-shadow: 0 0 1px #fcd9c9;\n}\n:host .hemfixarna input:checked + .slider:before {\n -webkit-transform: translateX(18px);\n -ms-transform: translateX(18px);\n transform: translateX(18px);\n background: #ec6632;\n}\n:host .hemfixarna_maleribox {\n background: #fff;\n box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.0392156863);\n width: 100%;\n min-height: 132px;\n padding: 24px;\n display: flex;\n align-items: center;\n gap: 24px;\n text-align: left;\n}\n:host .hemfixarna_maleribox:hover {\n transition: 0.1s all cubic-bezier(0.465, 0.183, 0.153, 0.946);\n filter: brightness(1.02);\n transform: scale(1.01);\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.0392156863);\n}\n:host .hemfixarna_checkbox {\n display: grid;\n grid-template-columns: 40px auto;\n font-size: 16px;\n font-weight: 400;\n line-height: 24px;\n letter-spacing: -3%;\n}\n:host .hemfixarna_checkbox > span {\n transform: translateY(6px);\n}\n:host .hemfixarna_checkbox span,\n:host .hemfixarna_checkbox span p {\n color: #474444;\n font-size: 14px;\n}\n:host .hemfixarna_checkbox p {\n text-align: left;\n}\n:host .hemfixarna_info {\n display: flex;\n flex-direction: column;\n gap: 24px;\n padding: 32px;\n box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.0392156863);\n border-radius: 4px;\n border: 1px solid #fcd9c9;\n}\n:host .hemfixarna_info h2 {\n margin: 0;\n}\n@media (min-width: 769px) {\n :host .hemfixarna_info {\n position: sticky;\n top: 0;\n }\n}\n:host .hemfixarna_infomodal {\n position: absolute;\n top: 40%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 100%;\n max-width: 80%;\n background: #fffaf2;\n border: 1px solid #fcd9c9;\n padding: 32px;\n z-index: 99;\n border-radius: 4px;\n box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.0392156863);\n display: flex;\n flex-direction: column;\n gap: 16px;\n}\n:host .hemfixarna_infomodal p,\n:host .hemfixarna_infomodal h4 {\n margin: 0;\n}\n:host .hemfixarna_infomodal button {\n background: #ec6632;\n color: #fff;\n border-radius: 60px;\n font-size: 16px;\n padding: 8px 16px;\n}\n:host .hemfixarna_addressinfo {\n padding: 16px 16px 64px;\n border: 1px solid #fcd9c9;\n position: relative;\n margin-bottom: 32px;\n display: grid;\n grid-template-columns: 1fr;\n gap: 8px;\n}\n@media (min-width: 769px) {\n :host .hemfixarna_addressinfo {\n grid-template-columns: 1fr 1fr;\n }\n}\n:host .hemfixarna_addressinfo button {\n position: absolute;\n bottom: 16px;\n right: 16px;\n font-weight: 500;\n text-underline-offset: 2px;\n text-decoration: underline;\n}\n:host .hemfixarna_part {\n background: #fff;\n box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.0392156863);\n display: grid;\n padding: 16px;\n grid-template-columns: auto 75px;\n}\n:host .hemfixarna_counter {\n display: flex;\n align-items: center;\n}\n:host .hemfixarna_counter span {\n padding: 0 8px;\n}\n:host .hemfixarna_counter img {\n cursor: pointer;\n}\n:host .hemfixarna_counter img:not(.disabled):hover {\n transition: 0.1s all cubic-bezier(0.465, 0.183, 0.153, 0.946);\n filter: brightness(1.02);\n transform: scale(1.01);\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.0392156863);\n}\n:host .hemfixarna_description {\n display: grid;\n gap: 16px;\n}\n:host .hemfixarna_description ul {\n list-style: disc;\n padding-right: 12px;\n transform: translateX(12px);\n}\n:host .hemfixarna_description--hidden {\n max-height: 140px;\n overflow: hidden;\n position: relative;\n cursor: pointer;\n}\n:host .hemfixarna_description--hidden::after {\n content: "";\n position: absolute;\n bottom: 0;\n left: 0;\n right: 0;\n height: 128px;\n background: linear-gradient(180deg, rgba(255, 253, 250, 0), rgba(255, 253, 250, 0.46) 50%, #fffaf2);\n}\n:host .hemfixarna_terms {\n font-size: 14px;\n}\n:host .hemfixarna_terms a {\n color: inherit;\n}\n:host .hemfixarna_logo {\n height: 64px;\n}\n:host .hemfixarna_box {\n padding: 16px;\n display: flex;\n align-items: center;\n width: 100%;\n box-sizing: border-box;\n border-radius: 4px;\n gap: 16px 8px;\n border-radius: 4px;\n gap: 16px 8px;\n}\n:host .hemfixarna_box p,\n:host .hemfixarna_box span {\n font-size: 15px;\n}\n:host .hemfixarna_box .underline {\n text-decoration: underline;\n text-underline-offset: 2px;\n}\n:host .hemfixarna_box .pointer {\n cursor: pointer;\n}\n:host .hemfixarna_box .p-s {\n font-size: 12px;\n}\n:host .hemfixarna_box > div {\n display: grid;\n gap: 8px;\n}\n:host .hemfixarna_box--standard {\n background: #fffaf2;\n border: 1px solid #fcd9c9;\n}\n:host .hemfixarna_box--alternative, :host .hemfixarna_box--alternative_2, :host .hemfixarna_box--alternative_3 {\n background: transparent;\n border: 1px solid #e3e3e3;\n}\n:host .hemfixarna_box--alternative_2, :host .hemfixarna_box--alternative_3 {\n box-shadow: 0px 2px 16px 0px rgba(0, 0, 0, 0.0784313725);\n}\n:host .hemfixarna_box--alternative_3 {\n justify-content: center;\n}\n:host .hemfixarna_altbtn {\n display: flex !important;\n flex-direction: column;\n gap: 8px;\n align-items: center;\n margin-left: auto;\n}\n:host .hemfixarna_btn {\n margin-left: auto;\n}\n:host .hemfixarna_btn, :host .hemfixarna_buy,\n:host .hemfixarna input[type=submit] {\n border: none;\n border-radius: 60px;\n font-weight: 600;\n letter-spacing: 0.5px;\n line-height: 20px;\n box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.0392156863);\n}\n:host .hemfixarna_btn:not(.disabled):hover, :host .hemfixarna_buy:not(.disabled):hover,\n:host .hemfixarna input[type=submit]:not(.disabled):hover {\n transition: 0.1s all cubic-bezier(0.465, 0.183, 0.153, 0.946);\n filter: brightness(1.02);\n transform: scale(1.01);\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.0392156863);\n}\n:host .hemfixarna div:has(> input[type=submit]) {\n position: relative;\n}\n:host .hemfixarna div:has(> input[type=submit]) input {\n cursor: pointer;\n}\n:host .hemfixarna div:has(> input[type=submit]) img {\n display: none;\n}\n:host .hemfixarna .loading {\n cursor: default;\n opacity: 0.6;\n}\n:host .hemfixarna .loading > img {\n display: initial !important;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n:host .hemfixarna_btn {\n font-size: 14px;\n background: #c84e18;\n color: #fff;\n padding: 16px 24px;\n white-space: nowrap;\n position: relative;\n}\n:host .hemfixarna_btn span {\n position: absolute;\n background: #fff;\n border-radius: 100%;\n width: 24px;\n height: 24px;\n display: flex;\n justify-content: center;\n align-items: center;\n font-weight: 600;\n font-size: 13px;\n line-height: 11px;\n top: -6px;\n right: -12px;\n}\n:host .hemfixarna_btn span {\n background: #25a710;\n color: #fff;\n right: 0 !important;\n}\n:host .hemfixarna_buy,\n:host .hemfixarna input[type=submit] {\n font-size: 21px;\n background: #25a710;\n color: #fff;\n padding: 16px 24px;\n}\n:host .hemfixarna .disabled {\n opacity: 0.5;\n cursor: default;\n}\n:host .hemfixarna_modal {\n position: fixed;\n background: #fffaf2;\n border: 1px solid #fcd9c9;\n border-radius: 4px;\n top: 50%;\n left: 50%;\n z-index: 1000;\n transition: 0.1s all cubic-bezier(0.465, 0.183, 0.153, 0.946);\n transform: translate(-50%, -50%) scale(0.7);\n opacity: 0;\n height: 92%;\n width: 92%;\n max-width: 920px;\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n:host .hemfixarna_modal--open {\n opacity: 1;\n transform: translate(-50%, -50%) scale(1);\n}\n:host .hemfixarna_backdrop {\n z-index: 999;\n position: fixed;\n background: #474444;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n opacity: 0;\n transition: transform 0.1s cubic-bezier(0.465, 0.183, 0.153, 0.946), opacity 0.1s cubic-bezier(0.465, 0.183, 0.153, 0.946);\n}\n:host .hemfixarna_backdrop--open {\n opacity: 0.3;\n}\n:host .hemfixarna_order {\n position: absolute;\n top: -1px;\n left: -1px;\n right: -1px;\n bottom: -1px;\n background-repeat: no-repeat !important;\n background-size: cover !important;\n background-position: center !important;\n display: grid;\n grid-template-columns: 1fr 1fr;\n padding: 48px 32px 64px;\n}\n@media (max-width: 768px) {\n :host .hemfixarna_order {\n grid-template-columns: 1fr;\n grid-template-rows: 0 auto;\n }\n}\n:host .hemfixarna_order > div:last-of-type {\n background: #fffaf2;\n padding: 32px;\n display: flex;\n flex-direction: column;\n max-height: 100%;\n overflow: auto;\n}\n:host .hemfixarna_order img {\n cursor: pointer;\n}\n:host .hemfixarna_order button {\n margin: 16px 0;\n padding: 0;\n text-decoration: underline;\n text-underline-offset: 2px;\n font-size: 14px;\n font-weight: 600;\n}\n:host .hemfixarna_cart {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 32px;\n}\n@media (max-width: 768px) {\n :host .hemfixarna_cart {\n grid-template-columns: 1fr;\n gap: 0;\n }\n}\n:host .hemfixarna_cart--right h2, :host .hemfixarna_cart--left h2 {\n display: flex;\n align-items: center;\n}\n:host .hemfixarna_cart--right h2 img, :host .hemfixarna_cart--left h2 img {\n margin-top: 3.2px;\n}\n@media (min-width: 769px) {\n :host .hemfixarna_cart--left h2 button {\n display: none;\n }\n}\n@media (max-width: 768px) {\n :host .hemfixarna_cart--right h2 button {\n display: none;\n }\n}\n:host .hemfixarna_cart--startfee {\n display: flex;\n justify-content: space-between;\n}\n:host .hemfixarna_cart--rutrot {\n display: flex;\n justify-content: space-between;\n}\n:host .hemfixarna_cart--rutrot div {\n display: flex;\n gap: 16px;\n align-items: center;\n}\n:host .hemfixarna_cart--additional {\n display: flex;\n flex-direction: column;\n gap: 16px;\n padding: 16px;\n border-top: 1px solid #fcd9c9;\n}\n:host .hemfixarna_cart--additional p {\n font-size: 14px;\n}\n:host .hemfixarna_cart--additional strong {\n text-decoration: underline;\n text-underline-offset: 2px;\n cursor: pointer;\n position: relative;\n}\n:host .hemfixarna_cart--additional strong img {\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n right: -24px;\n}\n:host .hemfixarna_cart--price {\n border-top: 1px solid #fcd9c9;\n padding: 16px;\n display: flex;\n justify-content: space-between;\n}\n:host .hemfixarna_cart--price h3 {\n margin: 0;\n}\n:host .hemfixarna_cart--item {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 16px 0;\n border-top: 1px solid #fcd9c9;\n}\n:host .hemfixarna_cart--item span {\n font-size: 12px;\n}\n:host .hemfixarna_cart--item > div {\n display: flex;\n justify-content: space-between;\n}\n:host .hemfixarna_cart--item > div > div {\n display: flex;\n align-items: center;\n gap: 16px;\n}\n:host .hemfixarna_cart--item > div button {\n color: #ec6632;\n}\n:host .hemfixarna_categories {\n display: flex;\n flex-direction: column;\n gap: 24px;\n}\n:host .hemfixarna_categories--wrapper {\n gap: 32px;\n display: grid;\n grid-template-columns: 1fr 1fr;\n}\n@media (max-width: 768px) {\n :host .hemfixarna_categories--wrapper {\n grid-template-columns: 1fr;\n }\n}\n:host .hemfixarna_categories li {\n position: relative;\n background: #fff;\n border-radius: 4px;\n min-height: 132px;\n padding: 24px;\n box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.0392156863);\n display: flex;\n align-items: center;\n gap: 24px;\n cursor: pointer;\n}\n:host .hemfixarna_categories li:hover {\n transition: 0.1s all cubic-bezier(0.465, 0.183, 0.153, 0.946);\n filter: brightness(1.02);\n transform: scale(1.01);\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.0392156863);\n}\n:host .hemfixarna_categories li > button {\n height: 100%;\n width: 100%;\n}\n:host .hemfixarna_categories li .price {\n font-weight: 700;\n}\n:host .hemfixarna_content {\n height: 100%;\n overflow: auto;\n padding: 0 32px 64px;\n}\n:host .hemfixarna_content--5 {\n padding-top: 16px;\n}\n:host .hemfixarna_content--painting {\n padding: 0;\n overflow: initial;\n}\n:host .hemfixarna_crumbs {\n position: relative;\n padding: 16px 24px;\n border-bottom: 1px solid #fcd9c9;\n display: flex;\n justify-content: space-between;\n}\n:host .hemfixarna_crumbs--back {\n padding: 16px 24px 8px;\n display: flex;\n align-items: center;\n gap: 8px;\n box-shadow: none !important;\n}\n:host .hemfixarna_crumbs--back:hover {\n transition: 0.1s all cubic-bezier(0.465, 0.183, 0.153, 0.946);\n filter: brightness(1.02);\n transform: scale(1.01);\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.0392156863);\n}\n:host .hemfixarna_crumbs img {\n cursor: pointer;\n}\n:host .hemfixarna_crumbs .close {\n position: absolute;\n right: -16px;\n top: -16px;\n z-index: 9;\n -webkit-transform: translate3d(0, 0, 0);\n}\n:host .hemfixarna_crumbs .cart {\n display: flex;\n padding-left: 16px;\n position: relative;\n}\n:host .hemfixarna_crumbs .cart img {\n cursor: inherit;\n}\n:host .hemfixarna_crumbs .cart span {\n position: absolute;\n background: #fff;\n border-radius: 100%;\n width: 24px;\n height: 24px;\n display: flex;\n justify-content: center;\n align-items: center;\n font-weight: 600;\n font-size: 13px;\n line-height: 11px;\n top: -6px;\n right: -12px;\n}\n:host .hemfixarna_crumbs .cart_active {\n cursor: pointer;\n}\n:host .hemfixarna_crumbs .cart_active span {\n background: #25a710;\n color: #fff;\n}\n:host .hemfixarna_crumbs--links {\n display: flex;\n align-items: center;\n gap: 16px;\n overflow: auto;\n}\n@media (min-width: 769px) {\n :host .hemfixarna_crumbs--links {\n -ms-overflow-style: none;\n }\n :host .hemfixarna_crumbs--links::-webkit-scrollbar {\n display: none;\n }\n :host .hemfixarna_crumbs--links::-webkit-scrollbar-button {\n display: none;\n }\n}\n:host .hemfixarna_crumbs--right {\n display: flex;\n align-items: center;\n}\n:host .hemfixarna_crumbs button {\n white-space: nowrap;\n background: #f1ded6;\n border-radius: 64px;\n padding: 12px 16px;\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.3px;\n box-shadow: none !important;\n}\n:host .hemfixarna_crumbs button:not(.active):hover {\n transition: 0.1s all cubic-bezier(0.465, 0.183, 0.153, 0.946);\n filter: brightness(1.02);\n transform: scale(1.01);\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.0392156863);\n}\n@media (max-width: 768px) {\n :host .hemfixarna_crumbs button {\n display: none;\n }\n}\n:host .hemfixarna_crumbs .active {\n background: #fffaf2;\n cursor: default;\n}\n:host .hemfixarna_features {\n gap: 12px !important;\n}\n:host .hemfixarna_features li {\n display: flex;\n gap: 16px;\n align-items: center;\n}\n:host .hemfixarna_address {\n margin-bottom: 16px;\n}\n:host .hemfixarna_product {\n display: grid;\n gap: 16px;\n}\n:host .hemfixarna_product--link {\n font-weight: 700;\n color: #474444;\n text-underline-offset: 4px;\n}\n:host .hemfixarna_product--left {\n gap: 32px;\n}\n:host .hemfixarna_product--right {\n gap: 32px;\n}\n:host .hemfixarna_product--price {\n margin-top: 4px;\n font-weight: 700;\n}\n:host .hemfixarna_product--total {\n text-align: center;\n margin: -16px 0;\n font-size: 21px;\n line-height: 28px;\n}\n:host .hemfixarna_product--item {\n background: #fff;\n padding: 16px;\n display: grid;\n grid-template-columns: auto 75px;\n box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.0392156863);\n}\n:host .hemfixarna_product--grid {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 32px;\n}\n@media (max-width: 768px) {\n :host .hemfixarna_product--grid {\n grid-template-columns: 1fr;\n }\n}\n:host .hemfixarna_product--grid > div {\n display: flex;\n flex-direction: column;\n}\n:host .hemfixarna_product--grid ul {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n:host .hemfixarna_product p {\n margin: 0;\n}\n:host .hemfixarna_product--top {\n display: flex;\n gap: 32px;\n}\n:host .hemfixarna_product--top img {\n object-fit: contain;\n}\n:host .hemfixarna_product--top > div {\n width: 100%;\n}\n:host .hemfixarna_product--top > div h1 {\n max-width: 80%;\n}\n@media (max-width: 768px) {\n :host .hemfixarna_product--top > div h1 {\n max-width: 100%;\n }\n}\n:host .hemfixarna_product--top h4 {\n margin-bottom: 8px;\n}\n:host h5,\n:host p {\n margin: 0;\n}\n:host input[type=submit] {\n cursor: pointer;\n}\n:host input[type=date] ~ label {\n left: 56px;\n}\n:host input[type=date] {\n border: 1px solid #fcd9c9;\n padding-left: 64px;\n}\n:host input[type=checkbox] {\n height: 18px;\n width: 18px;\n border: 1px solid #fcd9c9;\n}\n:host input[type=checkbox]:checked {\n background: red;\n}\n:host input[type=date]::-webkit-calendar-picker-indicator {\n background: transparent;\n bottom: 0;\n color: transparent;\n cursor: pointer;\n height: auto;\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n width: auto;\n}\n:host button,\n:host a {\n cursor: pointer;\n background: none;\n border: none;\n}\n:host ul {\n list-style: none;\n margin: 0;\n padding: 0;\n}';
1162
+
1163
+ const HemfixarnaComponent = class {
1164
+ constructor(hostRef) {
1165
+ registerInstance(this, hostRef);
1166
+ this.slugIsOldFormat = slug => {
1167
+ if (!slug) return false;
1168
+ return ['product', 'service', 'category'].some(str => slug.includes(str));
1169
+ };
1170
+ this.triggerScrollTotop = () => {
1171
+ const el = this.el.shadowRoot.querySelector('.hemfixarna_content');
1172
+ scrollToTop(el);
1173
+ };
1174
+ this.modal = false;
1175
+ this.showModal = false;
1176
+ this.tree = null;
1177
+ this.product = null;
1178
+ this.proppedProduct = null;
1179
+ this.slug = undefined;
1180
+ this.id = undefined;
1181
+ this.business = undefined;
1182
+ this.topCategory = undefined;
1183
+ this.forceOldTree = false;
1184
+ this.loadFromQuery = false;
1185
+ this.isDemo = false;
1186
+ this.widgetStyle = undefined;
1187
+ this.nav = undefined;
1188
+ this.buttonColor = undefined;
1189
+ this.buttonBg = undefined;
1190
+ }
1191
+ loadCategoryOrProduct(id) {
1192
+ this.proppedProduct = null;
1193
+ if (id.startsWith('c-')) {
1194
+ const categories = [
1195
+ ...state.customer.categories,
1196
+ ...state.customer.categories.map(c => {
1197
+ var _a;
1198
+ return (_a = c.sub_categories) !== null && _a !== void 0 ? _a : [];
1199
+ }),
1200
+ ].flat();
1201
+ const category = categories.find(c => c && c.id === id.replace('c-', ''));
1202
+ if (category) {
1203
+ state.selectedCustomerCategory = category;
1204
+ state.step = 2;
1205
+ }
1206
+ } else {
1207
+ const products = state.customer.categories
1208
+ .map(c => (c.show_products ? c.products : c.sub_categories ? c.sub_categories.map(c => c.products) : []))
1209
+ .flat()
1210
+ .flat();
1211
+ const product = products.find(p => p && p.fields.ID === parseInt(id));
1212
+ if (product) {
1213
+ state.selectedProduct = product.fields;
1214
+ state.step = 4;
1215
+ this.proppedProduct = product.fields;
1216
+ }
1217
+ }
1218
+ }
1219
+ async watchSlugChange(newValue) {
1220
+ if (this.slugIsOldFormat(newValue)) {
1221
+ this.fetchNewTaxonomy(newValue);
1222
+ } else if (state.customer && newValue) {
1223
+ this.loadCategoryOrProduct(newValue);
1224
+ }
1225
+ }
1226
+ async watchIdChange(id) {
1227
+ if (id && state.customer) {
1228
+ if (id === 'maleri') {
1229
+ state.maleri = true;
1230
+ state.step = 4;
1231
+ } else {
1232
+ this.loadCategoryOrProduct(id);
1233
+ }
1234
+ }
1235
+ }
1236
+ async fetchNewTaxonomy(slug) {
1237
+ state.selectedCategory = null;
1238
+ state.selectedProduct = null;
1239
+ state.selectedService = null;
1240
+ state.maleri = null;
1241
+ const res = await getTaxonomy(slug);
1242
+ if ((res === null || res === void 0 ? void 0 : res.code) === 'not_found' || (res === null || res === void 0 ? void 0 : res.code) === 'rest_no_route') {
1243
+ console.log('taxonomy not found');
1244
+ } else if (res) {
1245
+ this.setTaxonomy(res);
1246
+ if ((res === null || res === void 0 ? void 0 : res.post_type) === 'ikea_product') {
1247
+ this.product = res;
1248
+ }
1249
+ }
1250
+ }
1251
+ async componentWillLoad() {
1252
+ state.business = this.business;
1253
+ const cart = window.sessionStorage.getItem(`hemfixarna-${this.business}-cart`);
1254
+ if (cart) {
1255
+ state.cart = JSON.parse(cart);
1256
+ }
1257
+ const user = window.sessionStorage.getItem(`hemfixarna-${this.business}-user`);
1258
+ if (user) {
1259
+ state.user = JSON.parse(user);
1260
+ }
1261
+ const creditSafeUser = window.sessionStorage.getItem(`hemfixarna-${this.business}-creditSafeUser`);
1262
+ if (creditSafeUser) {
1263
+ state.creditSafeUser = JSON.parse(creditSafeUser);
1264
+ }
1265
+ const [tree, res, options, rut, rot, greenDiscount] = await Promise.all([
1266
+ this.topCategory ? getTaxonomy(this.topCategory) : null,
1267
+ this.slug ? getTaxonomy(this.slug) : Promise.resolve(null),
1268
+ getOptions(),
1269
+ getRut(),
1270
+ getRot(),
1271
+ getGreenDiscount(),
1272
+ ]);
1273
+ if ((!this.slug || !this.slugIsOldFormat(this.slug)) && !this.forceOldTree) {
1274
+ try {
1275
+ const customer = await getCustomer(this.business);
1276
+ if ((customer === null || customer === void 0 ? void 0 : customer.code) === 'not_found') {
1277
+ console.warn('customer not found');
1278
+ } else if (customer) {
1279
+ state.customer = customer;
1280
+ if (this.id) {
1281
+ if (this.id === 'maleri') {
1282
+ state.maleri = true;
1283
+ state.step = 4;
1284
+ } else {
1285
+ this.loadCategoryOrProduct(this.id);
1286
+ }
1287
+ } else if (this.slug && !this.slugIsOldFormat(this.slug)) {
1288
+ this.loadCategoryOrProduct(this.slug);
1289
+ }
1290
+ }
1291
+ } catch (error) {
1292
+ console.warn('customer not found');
1293
+ }
1294
+ }
1295
+ if ((tree === null || tree === void 0 ? void 0 : tree.code) === 'not_found');
1296
+ else if (tree) {
1297
+ this.tree = tree;
1298
+ }
1299
+ if ((res === null || res === void 0 ? void 0 : res.code) === 'not_found') {
1300
+ console.log('taxonomy not found');
1301
+ } else if (res) {
1302
+ this.setTaxonomy(res);
1303
+ if ((res === null || res === void 0 ? void 0 : res.post_type) === 'ikea_product') {
1304
+ this.product = res;
1305
+ }
1306
+ }
1307
+ if (this.loadFromQuery) {
1308
+ const params = new URL(document.location.toString()).searchParams;
1309
+ this.id = params.get('id');
1310
+ if (!this.isDemo) {
1311
+ this.openModal();
1312
+ }
1313
+ }
1314
+ state.rotOptions = rot;
1315
+ state.rutOptions = rut;
1316
+ state.greenOptions = greenDiscount;
1317
+ state.options = options;
1318
+ }
1319
+ setTaxonomy(taxonomy) {
1320
+ if (taxonomy) {
1321
+ if ((taxonomy === null || taxonomy === void 0 ? void 0 : taxonomy.taxonomy) === 'service_cat') {
1322
+ state.selectedCategory = taxonomy;
1323
+ state.step = 2;
1324
+ } else if ((taxonomy === null || taxonomy === void 0 ? void 0 : taxonomy.post_type) === 'service') {
1325
+ state.selectedService = taxonomy;
1326
+ state.selectedCategory = this.tree.sub_cats.find(c => c.services.find(s => s.ID === taxonomy.ID));
1327
+ state.step = 3;
1328
+ } else if ((taxonomy === null || taxonomy === void 0 ? void 0 : taxonomy.post_type) === 'ikea_product') {
1329
+ state.selectedProduct = taxonomy;
1330
+ state.selectedService = this.tree.sub_cats
1331
+ .map(c => c.services)
1332
+ .flat()
1333
+ .find(s => s.products.find(p => p.ID === state.selectedProduct.ID));
1334
+ state.selectedCategory = this.tree.sub_cats.find(c => c.services.find(s => s.ID === state.selectedService.ID));
1335
+ state.step = 4;
1336
+ }
1337
+ this.triggerScrollTotop();
1338
+ }
1339
+ }
1340
+ // Open close modal && click outside event
1341
+ openModal() {
1342
+ this.modal = true;
1343
+ setTimeout(() => {
1344
+ this.showModal = true;
1345
+ }, 50);
1346
+ }
1347
+ closeModal() {
1348
+ this.showModal = false;
1349
+ setTimeout(() => {
1350
+ this.modal = false;
1351
+ }, 200);
1352
+ }
1353
+ handleClick(e) {
1354
+ if (this.loadFromQuery && !this.isDemo) return;
1355
+ if ((e === null || e === void 0 ? void 0 : e.composedPath()[0]).classList.contains('hemfixarna_backdrop')) {
1356
+ this.closeModal();
1357
+ }
1358
+ const infomodal = this.el.shadowRoot.querySelector('.hemfixarna_infomodal');
1359
+ if (infomodal) {
1360
+ const isClickInside = infomodal.contains(e.composedPath()[0]);
1361
+ if (!isClickInside) {
1362
+ state.modal = null;
1363
+ }
1364
+ }
1365
+ }
1366
+ getCartLength() {
1367
+ return state.cart.reduce((acc, curr) => acc + curr.amount, 0);
1368
+ }
1369
+ render() {
1370
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
1371
+ const logo = getAssetPath(`./assets/hemfixarna.svg`);
1372
+ const pensel = getAssetPath(`./assets/pensel.svg`);
1373
+ const monteringLogo = getAssetPath(`./assets/montering.svg`);
1374
+ const navBackground = ((_a = this.nav) === null || _a === void 0 ? void 0 : _a.background) ? getAssetPath(this.nav.background) : '';
1375
+ const navLogo = ((_b = this.nav) === null || _b === void 0 ? void 0 : _b.logo) ? getAssetPath(this.nav.logo) : '';
1376
+ return h(
1377
+ 'div',
1378
+ { class: `hemfixarna ${this.loadFromQuery ? 'hemfixarna_standalone' : ''}` },
1379
+ this.loadFromQuery && !this.isDemo && this.nav
1380
+ ? h(
1381
+ 'nav',
1382
+ { class: 'hemfixarna_nav', style: { backgroundColor: (_c = this.nav.backgroundColor) !== null && _c !== void 0 ? _c : '' } },
1383
+ h(
1384
+ 'div',
1385
+ null,
1386
+ h(
1387
+ 'div',
1388
+ { class: 'hemfixarna_nav--logos' },
1389
+ h('a', { href: this.nav.url, target: '_blank' }, h('img', { class: 'hemfixarna_partnerlogo', src: navLogo, alt: `${this.business} logo` })),
1390
+ h(
1391
+ 'a',
1392
+ { href: 'https://hemfixarna.se/', target: '_blank' },
1393
+ h('p', { class: navBackground || this.nav.backgroundColor ? 'with-bg' : '' }, 'I samarbete med:'),
1394
+ h('img', { src: logo, alt: 'hemfixarna_logo', width: 104 }),
1395
+ ),
1396
+ ),
1397
+ h(
1398
+ 'div',
1399
+ { class: 'hemfixarna_nav--links' },
1400
+ h('a', { href: this.nav.url, target: '_blank' }, 'Till ', this.business),
1401
+ h('a', { href: 'https://www.hemfixarna.se/', target: '_blank' }, 'Till Hemfixarna'),
1402
+ ),
1403
+ navBackground ? h('img', { src: navBackground, class: 'nav_background', alt: 'nav_background' }) : null,
1404
+ ),
1405
+ )
1406
+ : null,
1407
+ !this.loadFromQuery || this.isDemo
1408
+ ? h(
1409
+ 'div',
1410
+ { class: `hemfixarna_box hemfixarna_box--${this.widgetStyle}` },
1411
+ [WidgetStyle.alternative_2, WidgetStyle.alternative_3].includes(this.widgetStyle)
1412
+ ? h('img', { src: this.id === 'maleri' ? pensel : monteringLogo, alt: 'montering logo', width: 32, height: 32 })
1413
+ : null,
1414
+ h(
1415
+ 'div',
1416
+ null,
1417
+ h(
1418
+ 'div',
1419
+ null,
1420
+ h(
1421
+ 'p',
1422
+ {
1423
+ onClick: () => this.openModal(),
1424
+ class: `pointer ${[WidgetStyle.alternative_2, WidgetStyle.alternative_3].includes(this.widgetStyle) && state.selectedProduct ? 'underline' : ''}`,
1425
+ },
1426
+ this.id === 'maleri'
1427
+ ? h('span', null, 'Ber\u00E4kna fast pris p\u00E5 m\u00E5leri & tapetsering h\u00E4r')
1428
+ : h(
1429
+ Fragment,
1430
+ null,
1431
+ !state.selectedCustomerCategory && !this.product && !this.proppedProduct
1432
+ ? h(
1433
+ Fragment,
1434
+ null,
1435
+ ((_d = state.customer) === null || _d === void 0 ? void 0 : _d.widget_title)
1436
+ ? h('span', null, state.customer.widget_title)
1437
+ : h('span', null, 'Montering/Installation - ', h('strong', { class: 'underline' }, 'se priser h\u00E4r')),
1438
+ )
1439
+ : h(
1440
+ Fragment,
1441
+ null,
1442
+ ((_e = this.product) === null || _e === void 0 ? void 0 : _e.title) ||
1443
+ ((_f = this.proppedProduct) === null || _f === void 0 ? void 0 : _f.title) ||
1444
+ ((_g = state.selectedCustomerCategory) === null || _g === void 0 ? void 0 : _g.widget_title) ||
1445
+ h(
1446
+ 'span',
1447
+ null,
1448
+ 'Montering',
1449
+ h('wbr', null),
1450
+ '/Installation ',
1451
+ (_j = (_h = state.selectedCustomerCategory) === null || _h === void 0 ? void 0 : _h.name) !== null && _j !== void 0 ? _j : 'på plats',
1452
+ ' - ',
1453
+ h('strong', { class: 'underline' }, 'se priser h\u00E4r'),
1454
+ ),
1455
+ (this.product && ((_k = this.slug) === null || _k === void 0 ? void 0 : _k.includes('product'))) ||
1456
+ (this.proppedProduct &&
1457
+ !((_l = this.product) === null || _l === void 0 ? void 0 : _l.invoice) &&
1458
+ !((_m = this.proppedProduct) === null || _m === void 0 ? void 0 : _m.invoice))
1459
+ ? h('span', null, ' från', ' ', h('strong', null, getProductPriceWithRotAndRut(this.proppedProduct || this.product), 'kr'))
1460
+ : null,
1461
+ ),
1462
+ ),
1463
+ ),
1464
+ ),
1465
+ this.widgetStyle === WidgetStyle.standard ? h('img', { src: logo, width: 104 }) : null,
1466
+ this.widgetStyle === WidgetStyle.alternative ? h('span', { class: 'p-s' }, 'Utf\u00F6rs av ', h('strong', null, 'Hemfixarna')) : null,
1467
+ ),
1468
+ [WidgetStyle.standard, WidgetStyle.alternative].includes(this.widgetStyle)
1469
+ ? h(
1470
+ 'button',
1471
+ {
1472
+ onClick: () => this.openModal(),
1473
+ class: 'hemfixarna_btn',
1474
+ style: {
1475
+ color:
1476
+ ((_o = this.buttonColor) === null || _o === void 0 ? void 0 : _o.startsWith('#')) ||
1477
+ !((_p = this.buttonColor) === null || _p === void 0 ? void 0 : _p.length)
1478
+ ? this.buttonColor
1479
+ : `#${this.buttonColor}`,
1480
+ backgroundColor:
1481
+ ((_q = this.buttonBg) === null || _q === void 0 ? void 0 : _q.startsWith('#')) || !((_r = this.buttonBg) === null || _r === void 0 ? void 0 : _r.length)
1482
+ ? this.buttonBg
1483
+ : `#${this.buttonBg}`,
1484
+ },
1485
+ },
1486
+ 'Best\u00E4ll h\u00E4r',
1487
+ this.getCartLength() > 0 && h('span', null, this.getCartLength()),
1488
+ )
1489
+ : null,
1490
+ WidgetStyle.alternative_2 === this.widgetStyle
1491
+ ? h('div', { class: 'hemfixarna_altbtn' }, h('strong', { class: 'p-s' }, 'Utf\u00F6rs av'), h('img', { src: logo, alt: 'hemfixarna logo', width: 98 }))
1492
+ : null,
1493
+ )
1494
+ : null,
1495
+ this.modal &&
1496
+ h(
1497
+ 'div',
1498
+ null,
1499
+ h(
1500
+ 'div',
1501
+ { class: `hemfixarna_modal ${this.showModal ? 'hemfixarna_modal--open' : ''}` },
1502
+ state.modal &&
1503
+ h(
1504
+ 'div',
1505
+ { class: 'hemfixarna_infomodal' },
1506
+ state.modal.title && h('h2', null, state.modal.title),
1507
+ state.modal.text.map(t => h('p', { innerHTML: t })),
1508
+ h('div', null, h('button', { onClick: () => (state.modal = null) }, 'St\u00E4ng')),
1509
+ ),
1510
+ (this.tree || state.customer) &&
1511
+ h('hemfixarna-breadcrumbs', { isDemo: this.isDemo, loadFromQuery: this.loadFromQuery, closeModal: () => this.closeModal(), tree: this.tree }),
1512
+ !state.customer || this.slugIsOldFormat(this.slug)
1513
+ ? h(
1514
+ 'div',
1515
+ { class: `hemfixarna_content hemfixarna_content--${state.step}` },
1516
+ state.step === 1 && this.tree && h('hemfixarna-start', { tree: this.tree }),
1517
+ state.step === 2 && state.selectedCategory && h('hemfixarna-category', null),
1518
+ state.step === 3 && state.selectedService && h('hemfixarna-service', null),
1519
+ state.step === 4 && state.selectedProduct && h('hemfixarna-product', null),
1520
+ state.step === 5 && h('hemfixarna-cart', { tree: this.tree }),
1521
+ state.step === 6 && h('hemfixarna-order', { tree: this.tree }),
1522
+ )
1523
+ : h(
1524
+ 'div',
1525
+ { class: `hemfixarna_content hemfixarna_content--${state.step} ${state.step === 4 && state.maleri ? 'hemfixarna_content--painting' : ''}` },
1526
+ state.step < 4 && h('hemfixarna-start', null),
1527
+ state.step === 4 && h('hemfixarna-product', null),
1528
+ state.step === 5 && h('hemfixarna-cart', { tree: this.tree }),
1529
+ state.step === 6 && h('hemfixarna-order', { tree: this.tree }),
1530
+ ),
1531
+ ),
1532
+ !this.isDemo ? h('div', { class: `hemfixarna_backdrop ${this.showModal ? 'hemfixarna_backdrop--open' : ''}` }) : null,
1533
+ ),
1534
+ );
1535
+ }
1536
+ static get assetsDirs() {
1537
+ return ['assets'];
1538
+ }
1539
+ get el() {
1540
+ return getElement(this);
1541
+ }
1542
+ static get watchers() {
1543
+ return {
1544
+ slug: ['watchSlugChange'],
1545
+ id: ['watchIdChange'],
1546
+ };
1547
+ }
1548
+ };
1549
+ HemfixarnaComponent.style = hemfixarnaCss;
1550
+
1551
+ const HemfixarnaInfo$1 = class {
1552
+ constructor(hostRef) {
1553
+ registerInstance(this, hostRef);
1554
+ this.vertical = false;
1555
+ }
1556
+ render() {
1557
+ return h(
1558
+ 'div',
1559
+ { class: `hemfixarna_contact ${this.vertical ? 'hemfixarna_contact--vertical' : 'hemfixarna_contact--horizontal'}` },
1560
+ h(
1561
+ 'a',
1562
+ { href: 'tel:0770-220 720' },
1563
+ h(
1564
+ 'svg',
1565
+ { width: '24', height: '24', viewBox: '0 0 24 24', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
1566
+ h('path', {
1567
+ d: 'M7 4V20H17V4H7ZM6 2H18C18.5523 2 19 2.44772 19 3V21C19 21.5523 18.5523 22 18 22H6C5.44772 22 5 21.5523 5 21V3C5 2.44772 5.44772 2 6 2ZM12 17C12.5523 17 13 17.4477 13 18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18C11 17.4477 11.4477 17 12 17Z',
1568
+ fill: '#C84E18',
1569
+ }),
1570
+ ),
1571
+ h('span', null, '0770-220 720'),
1572
+ ),
1573
+ h(
1574
+ 'a',
1575
+ { href: 'https://hemfixarna.se/kundservice/', target: '_blank' },
1576
+ h(
1577
+ 'svg',
1578
+ { width: '24', height: '24', viewBox: '0 0 24 24', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
1579
+ h(
1580
+ 'g',
1581
+ { 'clip-path': 'url(#clip0_1001_894)' },
1582
+ h('path', {
1583
+ d: 'M21 12.22C21 6.73 16.74 3 12 3C7.31 3 3 6.65 3 12.28C2.4 12.62 2 13.26 2 14V16C2 17.1 2.9 18 4 18H5V11.9C5 8.03 8.13 4.9 12 4.9C15.87 4.9 19 8.03 19 11.9V19H11V21H19C20.1 21 21 20.1 21 19V17.78C21.59 17.47 22 16.86 22 16.14V13.84C22 13.14 21.59 12.53 21 12.22Z',
1584
+ fill: '#C84E18',
1585
+ }),
1586
+ h('path', { d: 'M9 14C9.55228 14 10 13.5523 10 13C10 12.4477 9.55228 12 9 12C8.44772 12 8 12.4477 8 13C8 13.5523 8.44772 14 9 14Z', fill: '#C84E18' }),
1587
+ h('path', { d: 'M15 14C15.5523 14 16 13.5523 16 13C16 12.4477 15.5523 12 15 12C14.4477 12 14 12.4477 14 13C14 13.5523 14.4477 14 15 14Z', fill: '#C84E18' }),
1588
+ h('path', {
1589
+ d: 'M18 11.03C17.52 8.18 15.04 6 12.05 6C9.01997 6 5.75997 8.51 6.01997 12.45C8.48997 11.44 10.35 9.24 10.88 6.56C12.19 9.19 14.88 11 18 11.03Z',
1590
+ fill: '#C84E18',
1591
+ }),
1592
+ ),
1593
+ h('defs', null, h('clipPath', { id: 'clip0_1001_894' }, h('rect', { width: '24', height: '24', fill: 'white' }))),
1594
+ ),
1595
+ h('span', null, 'Kundservice'),
1596
+ ),
1597
+ );
1598
+ }
1599
+ };
1600
+
1601
+ const hemfixarnaDemoCss =
1602
+ '@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap"); :host{font-family:"Inter", sans-serif}:host .hemfixarna_widgetstyles label{cursor:pointer}:host .hemfixarna_widgetstyles>div{display:flex;gap:1rem}:host .hemfixarna_widgetstyles h5{margin:1rem 0}:host .hemfixarna_example{margin-bottom:16px;background:#000;padding:16px;color:#fff;display:flex;justify-content:space-between;cursor:pointer;max-width:500px;box-sizing:border-box;position:relative}:host .hemfixarna_example--tooltip{background:#000;top:-48px;font-size:16px;left:40%;color:white;padding:8px;position:absolute;opacity:0}:host .hemfixarna_example--tooltip::after{content:"";position:absolute;top:100%;left:50%;margin-left:-5px;border-width:5px;border-style:solid;border-color:#000 transparent transparent transparent}:host .hemfixarna_example:hover .hemfixarna_example--tooltip{opacity:1}:host .hemfixarna_example p{font-size:14px}:host .hemfixarna_example img{filter:invert(1)}:host .hemfixarna_install{display:grid;gap:8px;margin-top:16px}:host .hemfixarna_product--label{background:#e1e0f5}:host .hemfixarna_categories{max-height:100%;overflow:auto;position:relative}:host .hemfixarna_categories--label{display:flex;align-items:center;justify-content:space-between;padding:8px}:host .hemfixarna_categories--label button{background:#3f3a92;border:none;font-weight:600;padding:3.2px 9.6px;border-radius:10px;margin-right:8px;color:#ece8e8}:host .hemfixarna_categories--label button:active{transform:scale(0.95)}:host .hemfixarna_categories--label--big{font-weight:600;border-bottom:1px solid black}:host p{margin:0}:host span{color:darkolivegreen;font-size:10px}:host button{cursor:pointer}:host>div:not(.hemfixarna_hosted){grid-template-columns:1fr 1fr}:host .hemfixarna_hosted .hemfixarna_scripts{display:none}:host>div{display:grid;gap:32px;width:100%;height:100vh;place-items:center;overflow:hidden;padding:16px 32px;box-sizing:border-box}:host>div>*{width:100%}:host>div>div{max-width:500px}:host>div ul{margin:0;padding:0;list-style:none}:host>div ul ul{gap:1px;display:grid}:host>div ul li{padding-left:16px;background:#fff}';
1603
+
1604
+ const MyComponent$i = class {
1605
+ constructor(hostRef) {
1606
+ registerInstance(this, hostRef);
1607
+ this.debounce = null;
1608
+ this.cdnLink = '<script type="module" src="https://cdn.jsdelivr.net/npm//hemfixarna-web-components@latest/dist/hemfixarna-components/hemfixarna-components.esm.js"></script>';
1609
+ this.selectedSlug = undefined;
1610
+ this.selectedID = undefined;
1611
+ this.tooltipText = 'Kopiera till urklipp';
1612
+ this.tree = null;
1613
+ this.customer = null;
1614
+ this.widgetStyle = WidgetStyle.standard;
1615
+ this.buttonBg = '';
1616
+ this.buttonColor = '';
1617
+ this.partner = undefined;
1618
+ this.colorAccessibility = undefined;
1619
+ }
1620
+ debouncedFunction() {
1621
+ if (this.debounce !== null) {
1622
+ clearTimeout(this.debounce);
1623
+ this.debounce = null;
1624
+ }
1625
+ this.debounce = window.setTimeout(() => {
1626
+ this.checkColorAccessibility();
1627
+ this.debounce = null;
1628
+ }, 1500);
1629
+ }
1630
+ async checkColorAccessibility() {
1631
+ const defaultTextColor = '#fff';
1632
+ const defaultBgColor = '#c84e18';
1633
+ const firstColor = this.buttonBg.length ? (this.buttonBg.startsWith('#') ? this.buttonBg : `#${this.buttonBg}`) : defaultBgColor;
1634
+ const secondColor = this.buttonColor.length ? (this.buttonColor.startsWith('#') ? this.buttonColor : `#${this.buttonColor}`) : defaultTextColor;
1635
+ fetch('https://www.aremycolorsaccessible.com/api/are-they', {
1636
+ mode: 'cors',
1637
+ method: 'POST',
1638
+ body: JSON.stringify({ colors: [firstColor, secondColor] }),
1639
+ })
1640
+ .then(response => response.json())
1641
+ .then(json => {
1642
+ if (json && json) {
1643
+ this.colorAccessibility = json;
1644
+ }
1645
+ });
1646
+ // Your color accessibility logic here
1647
+ }
1648
+ getTopLevelCategory() {
1649
+ switch (process.env.BUSINESS) {
1650
+ case Business.byggmax:
1651
+ return TopCategory.byggmax;
1652
+ default:
1653
+ return '';
1654
+ }
1655
+ }
1656
+ getColor(rating) {
1657
+ switch (rating) {
1658
+ case 'AAA':
1659
+ return 'green';
1660
+ case 'AA':
1661
+ return 'orange';
1662
+ case 'A':
1663
+ return 'yellow';
1664
+ case 'Fail':
1665
+ return 'red';
1666
+ default:
1667
+ return 'black';
1668
+ }
1669
+ }
1670
+ async componentWillLoad() {
1671
+ var _a;
1672
+ if (process.env.FORCE_OLD_TREE) {
1673
+ const tree = await getTaxonomy(this.getTopLevelCategory());
1674
+ if ((tree === null || tree === void 0 ? void 0 : tree.code) === 'not_found');
1675
+ else if (tree) {
1676
+ this.tree = tree;
1677
+ }
1678
+ } else {
1679
+ const partner = window.location.pathname.replace('/', '');
1680
+ this.partner = isBusiness(partner) ? partner : (_a = process.env.BUSINESS) !== null && _a !== void 0 ? _a : Business.kund;
1681
+ const customer = await getCustomer(this.partner);
1682
+ if (customer.code !== 'not_found' && customer) {
1683
+ this.customer = customer;
1684
+ }
1685
+ }
1686
+ }
1687
+ getExample() {
1688
+ return `<hemfixarna-${this.partner}${this.selectedSlug ? ` slug="${this.selectedSlug}" ` : ''}${this.selectedID ? ` id="${this.selectedID}" ` : ''} ${this.widgetStyle === WidgetStyle.standard ? '' : `widget-style="${this.widgetStyle}"`} ${this.buttonColor.length ? `button-color="${this.buttonColor}"` : ''} ${this.buttonBg.length ? `button-bg="${this.buttonBg}"` : ''}></hemfixarna-${this.partner}>`;
1689
+ }
1690
+ copyExample() {
1691
+ navigator.clipboard.writeText(this.getExample());
1692
+ this.tooltipText = 'Snippet kopierad';
1693
+ setTimeout(() => {
1694
+ this.tooltipText = 'Kopiera till urklipp';
1695
+ }, 2000);
1696
+ }
1697
+ copyCdn() {
1698
+ navigator.clipboard.writeText(this.cdnLink);
1699
+ this.tooltipText = 'Text kopierad';
1700
+ setTimeout(() => {
1701
+ this.tooltipText = 'Kopiera till urklipp';
1702
+ }, 2000);
1703
+ }
1704
+ copyNpmInstall() {
1705
+ navigator.clipboard.writeText('npm i hemfixarna-web-components');
1706
+ this.tooltipText = 'Text kopierad';
1707
+ setTimeout(() => {
1708
+ this.tooltipText = 'Kopiera till urklipp';
1709
+ }, 2000);
1710
+ }
1711
+ showMaleri() {
1712
+ var _a;
1713
+ const allCategories = (_a = this.customer) === null || _a === void 0 ? void 0 : _a.categories.map(c => (c.sub_categories ? c.sub_categories : c)).flat();
1714
+ return allCategories === null || allCategories === void 0 ? void 0 : allCategories.some(c => c.add_painting);
1715
+ }
1716
+ render() {
1717
+ var _a;
1718
+ const copy = getAssetPath(`./assets/copy.png`);
1719
+ return h(
1720
+ 'div',
1721
+ { class: ((_a = this.customer) === null || _a === void 0 ? void 0 : _a.at_hemfixarna) ? 'hemfixarna_hosted' : '' },
1722
+ h(
1723
+ 'div',
1724
+ { class: 'hemfixarna_scripts' },
1725
+ h(
1726
+ 'div',
1727
+ { onClick: () => this.copyExample(), class: 'hemfixarna_example' },
1728
+ h('p', null, this.getExample()),
1729
+ h('img', { src: copy, height: 20 }),
1730
+ h('span', { class: 'hemfixarna_example--tooltip' }, this.tooltipText),
1731
+ ),
1732
+ this.partner === Business.byggmax &&
1733
+ h('hemfixarna-byggmax', {
1734
+ buttonColor: this.buttonColor,
1735
+ buttonBg: this.buttonBg,
1736
+ widgetStyle: this.widgetStyle,
1737
+ forceOldTree: Boolean(process.env.FORCE_OLD_TREE),
1738
+ slug: this.selectedSlug,
1739
+ id: this.selectedID,
1740
+ }),
1741
+ this.partner === Business.skanska &&
1742
+ h('hemfixarna-skanska', { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }),
1743
+ this.partner === Business.sparfonster &&
1744
+ h('hemfixarna-sparfonster', { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }),
1745
+ this.partner === Business.string &&
1746
+ h('hemfixarna-string-furniture', { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }),
1747
+ this.partner === Business.hornbach &&
1748
+ h('hemfixarna-hornbach', { isDemo: true, buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }),
1749
+ this.partner === Business.traningspartner &&
1750
+ h('hemfixarna-traningspartner', { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }),
1751
+ this.partner === Business.superfront &&
1752
+ h('hemfixarna-superfront', { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }),
1753
+ this.partner === Business.zaptec &&
1754
+ h('hemfixarna-zaptec', { isDemo: true, buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }),
1755
+ this.partner === Business.tesla &&
1756
+ h('hemfixarna-tesla', { isDemo: true, buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }),
1757
+ this.partner === Business.forebygg &&
1758
+ h('hemfixarna-forebygg', { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }),
1759
+ this.partner === Business.doro && h('hemfixarna-doro', { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }),
1760
+ this.partner === Business.elfa &&
1761
+ h('hemfixarna-elfa', { isDemo: true, buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }),
1762
+ this.partner === Business.kbygg &&
1763
+ h('hemfixarna-kbygg', { isDemo: true, buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }),
1764
+ this.partner === Business.fargvaruhuset &&
1765
+ h('hemfixarna-fargvaruhuset', { isDemo: true, buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }),
1766
+ this.partner === Business.norrgavel &&
1767
+ h('hemfixarna-norrgavel', { isDemo: true, buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }),
1768
+ this.partner === Business.klint && h('hemfixarna-klint', { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }),
1769
+ this.partner === Business.flyttsmart &&
1770
+ h('hemfixarna-flyttsmart', { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }),
1771
+ this.partner === Business.power && h('hemfixarna-power', { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }),
1772
+ this.partner === Business.kund && h('hemfixarna-kund', { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }),
1773
+ h(
1774
+ 'div',
1775
+ { class: 'hemfixarna_install' },
1776
+ h(
1777
+ 'div',
1778
+ { onClick: () => this.copyCdn(), class: 'hemfixarna_example' },
1779
+ h('p', null, this.cdnLink),
1780
+ h('span', { class: 'hemfixarna_example--tooltip' }, this.tooltipText),
1781
+ h('img', { src: copy, height: 20 }),
1782
+ ),
1783
+ ),
1784
+ h(
1785
+ 'div',
1786
+ { class: 'hemfixarna_widgetstyles' },
1787
+ h('h5', null, 'Widget styles'),
1788
+ h(
1789
+ 'div',
1790
+ null,
1791
+ Object.values(WidgetStyle).map(style =>
1792
+ h('label', { key: style }, h('input', { type: 'radio', value: style, checked: this.widgetStyle === style, onChange: () => (this.widgetStyle = style) }), style),
1793
+ ),
1794
+ ),
1795
+ h(
1796
+ 'div',
1797
+ null,
1798
+ h('div', null, h('h5', null, 'Button background color'), h('input', { type: 'text', value: this.buttonBg, onInput: e => (this.buttonBg = e.target.value) })),
1799
+ h('div', null, h('h5', null, 'Button text color'), h('input', { type: 'text', value: this.buttonColor, onInput: e => (this.buttonColor = e.target.value) })),
1800
+ ),
1801
+ ),
1802
+ h('span', null, 'Write an hexa code no # needed'),
1803
+ this.colorAccessibility
1804
+ ? h(
1805
+ 'div',
1806
+ null,
1807
+ h('h5', null, 'Tillg\u00E4nglighetsrapport'),
1808
+ h(
1809
+ 'div',
1810
+ null,
1811
+ h('strong', null, 'Liten text:'),
1812
+ h('span', { style: { color: this.getColor(this.colorAccessibility.small) } }, this.colorAccessibility.small),
1813
+ h('br', null),
1814
+ h('strong', null, 'Fet text:'),
1815
+ h('span', { style: { color: this.getColor(this.colorAccessibility.bold) } }, this.colorAccessibility.bold),
1816
+ h('br', null),
1817
+ h('strong', null, 'Stor text:'),
1818
+ h('span', { style: { color: this.getColor(this.colorAccessibility.large) } }, this.colorAccessibility.large),
1819
+ h('br', null),
1820
+ h('strong', null, 'Kontrastf\u00F6rh\u00E5llande:'),
1821
+ ' ',
1822
+ this.colorAccessibility.contrast,
1823
+ ),
1824
+ )
1825
+ : null,
1826
+ ),
1827
+ h(
1828
+ 'ul',
1829
+ { class: 'hemfixarna_categories' },
1830
+ this.customer
1831
+ ? h(
1832
+ 'div',
1833
+ null,
1834
+ this.customer.logo
1835
+ ? h(
1836
+ 'div',
1837
+ { style: { width: '100%', display: 'flex', justifyContent: 'center' } },
1838
+ h('img', { style: { maxWidth: '250px', height: 'auto', margin: '0 auto 2rem' }, src: this.customer.logo.url, alt: this.customer.post_title }),
1839
+ )
1840
+ : null,
1841
+ this.showMaleri()
1842
+ ? h(
1843
+ 'li',
1844
+ null,
1845
+ h(
1846
+ 'div',
1847
+ { class: 'hemfixarna_categories--label hemfixarna_categories--label--big' },
1848
+ h('div', null, h('p', null, 'M\u00E5leriverktyget'), h('span', null, 'maleri')),
1849
+ h(
1850
+ 'div',
1851
+ null,
1852
+ h('button', { onClick: () => navigator.clipboard.writeText('maleri') }, 'Kopiera ID'),
1853
+ this.customer.at_hemfixarna
1854
+ ? h(
1855
+ 'button',
1856
+ {
1857
+ onClick: () => {
1858
+ var _a;
1859
+ return navigator.clipboard.writeText(
1860
+ `${(_a = 'https://hemfixarna.se') !== null && _a !== void 0 ? _a : 'https://hemfixarna.se'}/partner/${this.customer.post_name}?id=maleri`,
1861
+ );
1862
+ },
1863
+ },
1864
+ 'Kopiera URL',
1865
+ )
1866
+ : h('button', { onClick: () => (this.selectedID = 'maleri') }, 'Ladda m\u00E5leri'),
1867
+ ),
1868
+ ),
1869
+ )
1870
+ : null,
1871
+ this.customer.categories.map(c =>
1872
+ h(
1873
+ 'li',
1874
+ null,
1875
+ h(
1876
+ 'div',
1877
+ { class: 'hemfixarna_categories--label hemfixarna_categories--label--big' },
1878
+ h('div', null, h('p', null, c.name), h('span', null, `c-${c.id}`)),
1879
+ h(
1880
+ 'div',
1881
+ null,
1882
+ h('button', { onClick: () => navigator.clipboard.writeText(`c-${c.id}`) }, 'Kopiera ID'),
1883
+ this.customer.at_hemfixarna
1884
+ ? h(
1885
+ 'button',
1886
+ {
1887
+ onClick: () => {
1888
+ var _a;
1889
+ return navigator.clipboard.writeText(
1890
+ `${(_a = 'https://hemfixarna.se') !== null && _a !== void 0 ? _a : 'https://hemfixarna.se'}/partner/${this.customer.post_name}?id=c-${c.id}`,
1891
+ );
1892
+ },
1893
+ },
1894
+ 'Kopiera URL',
1895
+ )
1896
+ : h('button', { onClick: () => (this.selectedID = `c-${c.id}`) }, 'Ladda kategori'),
1897
+ ),
1898
+ ),
1899
+ c.show_products && c.products
1900
+ ? h(
1901
+ 'ul',
1902
+ null,
1903
+ c.products.map(p =>
1904
+ h(
1905
+ 'li',
1906
+ null,
1907
+ h(
1908
+ 'div',
1909
+ { class: 'hemfixarna_categories--label hemfixarna_product--label' },
1910
+ h('div', null, h('p', null, p.fields.title), h('span', null, p.fields.ID)),
1911
+ h(
1912
+ 'div',
1913
+ null,
1914
+ h('button', { onClick: () => navigator.clipboard.writeText(String(p.fields.ID)) }, 'Kopiera ID'),
1915
+ this.customer.at_hemfixarna
1916
+ ? h(
1917
+ 'button',
1918
+ {
1919
+ onClick: () => {
1920
+ var _a;
1921
+ return navigator.clipboard.writeText(
1922
+ `${(_a = 'https://hemfixarna.se') !== null && _a !== void 0 ? _a : 'https://hemfixarna.se'}/partner/${this.customer.post_name}?id=${p.fields.ID}`,
1923
+ );
1924
+ },
1925
+ },
1926
+ 'Kopiera URL',
1927
+ )
1928
+ : h('button', { onClick: () => (this.selectedID = String(p.fields.ID)) }, 'Ladda produkt'),
1929
+ ),
1930
+ ),
1931
+ ),
1932
+ ),
1933
+ )
1934
+ : h(
1935
+ 'ul',
1936
+ null,
1937
+ c.sub_categories &&
1938
+ c.sub_categories.map(sc =>
1939
+ h(
1940
+ 'li',
1941
+ null,
1942
+ h(
1943
+ 'div',
1944
+ { class: 'hemfixarna_categories--label' },
1945
+ h('div', null, h('p', null, sc.name), h('span', null, `c-${sc.id}`)),
1946
+ h(
1947
+ 'div',
1948
+ null,
1949
+ h('button', { onClick: () => navigator.clipboard.writeText(`c-${sc.id}`) }, 'Kopiera ID'),
1950
+ this.customer.at_hemfixarna
1951
+ ? h(
1952
+ 'button',
1953
+ {
1954
+ onClick: () => {
1955
+ var _a;
1956
+ return navigator.clipboard.writeText(
1957
+ `${(_a = 'https://hemfixarna.se') !== null && _a !== void 0 ? _a : 'https://hemfixarna.se'}/partner/${this.customer.post_name}?id=c-${c.id}`,
1958
+ );
1959
+ },
1960
+ },
1961
+ 'Kopiera URL',
1962
+ )
1963
+ : h('button', { onClick: () => (this.selectedID = `c-${sc.id}`) }, 'Ladda kategori'),
1964
+ ),
1965
+ ),
1966
+ h(
1967
+ 'ul',
1968
+ null,
1969
+ sc.products.map(p =>
1970
+ h(
1971
+ 'li',
1972
+ null,
1973
+ h(
1974
+ 'div',
1975
+ { class: 'hemfixarna_categories--label hemfixarna_product--label' },
1976
+ h('div', null, h('p', null, p.fields.title), h('span', null, p.fields.ID)),
1977
+ h(
1978
+ 'div',
1979
+ null,
1980
+ h('button', { onClick: () => navigator.clipboard.writeText(String(p.fields.ID)) }, 'Kopiera ID'),
1981
+ this.customer.at_hemfixarna
1982
+ ? h(
1983
+ 'button',
1984
+ {
1985
+ onClick: () => {
1986
+ var _a;
1987
+ return navigator.clipboard.writeText(
1988
+ `${(_a = 'https://hemfixarna.se') !== null && _a !== void 0 ? _a : 'https://hemfixarna.se'}/partner/${this.customer.post_name}?id=${p.fields.ID}`,
1989
+ );
1990
+ },
1991
+ },
1992
+ 'Kopiera URL',
1993
+ )
1994
+ : h('button', { onClick: () => (this.selectedID = String(p.fields.ID)) }, 'Ladda produkt'),
1995
+ ),
1996
+ ),
1997
+ ),
1998
+ ),
1999
+ ),
2000
+ ),
2001
+ ),
2002
+ ),
2003
+ ),
2004
+ ),
2005
+ )
2006
+ : this.tree
2007
+ ? h(
2008
+ 'div',
2009
+ null,
2010
+ this.tree.sub_cats.map(c =>
2011
+ h(
2012
+ 'li',
2013
+ null,
2014
+ h(
2015
+ 'div',
2016
+ { class: 'hemfixarna_categories--label hemfixarna_categories--label--big' },
2017
+ h('div', null, h('p', null, c.name), h('span', null, `category/${c.slug}`)),
2018
+ h(
2019
+ 'div',
2020
+ null,
2021
+ h('button', { onClick: () => navigator.clipboard.writeText(`category/${c.slug}`) }, 'Kopiera slug'),
2022
+ h('button', { onClick: () => (this.selectedSlug = `category/${c.slug}`) }, 'Ladda kategori'),
2023
+ ),
2024
+ ),
2025
+ h(
2026
+ 'ul',
2027
+ null,
2028
+ c.services.map(sc =>
2029
+ h(
2030
+ 'li',
2031
+ null,
2032
+ h(
2033
+ 'div',
2034
+ { class: 'hemfixarna_categories--label' },
2035
+ h('div', null, h('p', null, sc.post_title), h('span', null, `service/${sc.post_name}`)),
2036
+ h(
2037
+ 'div',
2038
+ null,
2039
+ h('button', { onClick: () => navigator.clipboard.writeText(`service/${sc.post_name}`) }, 'Kopiera slug'),
2040
+ h('button', { onClick: () => (this.selectedSlug = `service/${sc.post_name}`) }, 'Ladda kategori'),
2041
+ ),
2042
+ ),
2043
+ h(
2044
+ 'ul',
2045
+ null,
2046
+ sc.products.map(sc =>
2047
+ h(
2048
+ 'li',
2049
+ null,
2050
+ h(
2051
+ 'div',
2052
+ { class: 'hemfixarna_categories--label' },
2053
+ h('div', null, h('p', null, sc.post_title), h('span', null, `product/${sc.post_name}`)),
2054
+ h(
2055
+ 'div',
2056
+ null,
2057
+ h('button', { onClick: () => navigator.clipboard.writeText(`product/${sc.post_name}`) }, 'Kopiera slug'),
2058
+ h('button', { onClick: () => (this.selectedSlug = `product/${sc.post_name}`) }, 'Ladda produkt'),
2059
+ ),
2060
+ ),
2061
+ ),
2062
+ ),
2063
+ ),
2064
+ ),
2065
+ ),
2066
+ ),
2067
+ ),
2068
+ ),
2069
+ )
2070
+ : null,
2071
+ ),
2072
+ );
2073
+ }
2074
+ static get watchers() {
2075
+ return {
2076
+ buttonBg: ['debouncedFunction'],
2077
+ buttonColor: ['debouncedFunction'],
2078
+ };
2079
+ }
2080
+ };
2081
+ MyComponent$i.style = hemfixarnaDemoCss;
2082
+
2083
+ const hemfixarnaDoroCss = '';
2084
+
2085
+ const MyComponent$h = class {
2086
+ constructor(hostRef) {
2087
+ registerInstance(this, hostRef);
2088
+ this.id = undefined;
2089
+ this.loadFromQuery = undefined;
2090
+ this.widgetStyle = WidgetStyle.standard;
2091
+ this.buttonColor = undefined;
2092
+ this.buttonBg = undefined;
2093
+ }
2094
+ render() {
2095
+ return h('hemfixarna-component', {
2096
+ widgetStyle: this.widgetStyle,
2097
+ buttonBg: this.buttonBg,
2098
+ buttonColor: this.buttonColor,
2099
+ loadFromQuery: Boolean(this.loadFromQuery),
2100
+ id: this.id,
2101
+ business: Business.doro,
2102
+ });
2103
+ }
2104
+ };
2105
+ MyComponent$h.style = hemfixarnaDoroCss;
2106
+
2107
+ const hemfixarnaElfaCss = '';
2108
+
2109
+ const MyComponent$g = class {
2110
+ constructor(hostRef) {
2111
+ registerInstance(this, hostRef);
2112
+ this.id = undefined;
2113
+ this.loadFromQuery = 'true';
2114
+ this.widgetStyle = WidgetStyle.standard;
2115
+ this.buttonColor = undefined;
2116
+ this.buttonBg = undefined;
2117
+ this.isDemo = false;
2118
+ }
2119
+ render() {
2120
+ return h('hemfixarna-component', {
2121
+ widgetStyle: this.widgetStyle,
2122
+ buttonBg: this.buttonBg,
2123
+ buttonColor: this.buttonColor,
2124
+ nav: { url: 'https://elfa.com', logo: 'assets/elfa.png' },
2125
+ loadFromQuery: Boolean(this.loadFromQuery),
2126
+ id: this.id,
2127
+ business: Business.elfa,
2128
+ isDemo: this.isDemo,
2129
+ });
2130
+ }
2131
+ };
2132
+ MyComponent$g.style = hemfixarnaElfaCss;
2133
+
2134
+ const MyComponent$f = class {
2135
+ constructor(hostRef) {
2136
+ registerInstance(this, hostRef);
2137
+ this.id = undefined;
2138
+ this.loadFromQuery = undefined;
2139
+ this.widgetStyle = WidgetStyle.standard;
2140
+ this.buttonColor = undefined;
2141
+ this.buttonBg = undefined;
2142
+ this.isDemo = false;
2143
+ }
2144
+ render() {
2145
+ return h('hemfixarna-component', {
2146
+ widgetStyle: this.widgetStyle,
2147
+ buttonBg: this.buttonBg,
2148
+ buttonColor: this.buttonColor,
2149
+ loadFromQuery: Boolean(this.loadFromQuery),
2150
+ id: this.id,
2151
+ business: Business.fargvaruhuset,
2152
+ isDemo: this.isDemo,
2153
+ });
2154
+ }
2155
+ };
2156
+
2157
+ const MyComponent$e = class {
2158
+ constructor(hostRef) {
2159
+ registerInstance(this, hostRef);
2160
+ this.id = undefined;
2161
+ this.loadFromQuery = undefined;
2162
+ this.widgetStyle = WidgetStyle.standard;
2163
+ this.buttonColor = undefined;
2164
+ this.buttonBg = undefined;
2165
+ this.isDemo = false;
2166
+ }
2167
+ render() {
2168
+ return h('hemfixarna-component', {
2169
+ widgetStyle: this.widgetStyle,
2170
+ buttonBg: this.buttonBg,
2171
+ buttonColor: this.buttonColor,
2172
+ loadFromQuery: Boolean(this.loadFromQuery),
2173
+ id: this.id,
2174
+ business: Business.flyttsmart,
2175
+ isDemo: this.isDemo,
2176
+ });
2177
+ }
2178
+ };
2179
+
2180
+ const hemfixarnaForebyggCss = '';
2181
+
2182
+ const MyComponent$d = class {
2183
+ constructor(hostRef) {
2184
+ registerInstance(this, hostRef);
2185
+ this.id = undefined;
2186
+ this.loadFromQuery = undefined;
2187
+ this.widgetStyle = WidgetStyle.standard;
2188
+ this.buttonColor = undefined;
2189
+ this.buttonBg = undefined;
2190
+ }
2191
+ render() {
2192
+ return h('hemfixarna-component', {
2193
+ widgetStyle: this.widgetStyle,
2194
+ buttonBg: this.buttonBg,
2195
+ buttonColor: this.buttonColor,
2196
+ loadFromQuery: Boolean(this.loadFromQuery),
2197
+ id: this.id,
2198
+ business: Business.forebygg,
2199
+ });
2200
+ }
2201
+ };
2202
+ MyComponent$d.style = hemfixarnaForebyggCss;
2203
+
2204
+ // src/errors.ts
2205
+ var PersonnummerError = class extends Error {
2206
+ constructor() {
2207
+ super('Invalid swedish personal identity number');
2208
+ }
2209
+ };
2210
+
2211
+ // src/utils.ts
2212
+ var compareAsc = (dateLeft, dateRight) => {
2213
+ const diff = dateLeft.getTime() - dateRight.getTime();
2214
+ return diff < 0 ? -1 : diff > 0 ? 1 : diff;
2215
+ };
2216
+ var diffInYears = (dateLeft, dateRight) => {
2217
+ const sign = compareAsc(dateLeft, dateRight);
2218
+ const yearDiff = Math.abs(dateLeft.getFullYear() - dateRight.getFullYear());
2219
+ dateLeft.setFullYear(dateLeft.getFullYear() - sign * yearDiff);
2220
+ const isLastYearNotFull = compareAsc(dateLeft, dateRight) === -sign;
2221
+ const result = sign * (yearDiff - +isLastYearNotFull);
2222
+ return result === 0 ? 0 : result;
2223
+ };
2224
+ var luhn = str => {
2225
+ let sum = 0;
2226
+ str += '';
2227
+ for (let i = 0, l = str.length; i < l; i++) {
2228
+ let v = parseInt(str[i]);
2229
+ v *= 2 - (i % 2);
2230
+ if (v > 9) {
2231
+ v -= 9;
2232
+ }
2233
+ sum += v;
2234
+ }
2235
+ return Math.ceil(sum / 10) * 10 - sum;
2236
+ };
2237
+ var testDate = (year, month, day) => {
2238
+ month -= 1;
2239
+ const date = new Date(year, month, day);
2240
+ return !(date.getFullYear() !== year || date.getMonth() !== month || date.getDate() !== day);
2241
+ };
2242
+
2243
+ // src/index.ts
2244
+ var Personnummer = class {
2245
+ /**
2246
+ * Personnummer constructor.
2247
+ *
2248
+ * @param {string} pin
2249
+ * @param {object} options
2250
+ */
2251
+ constructor(pin, options) {
2252
+ /**
2253
+ * Personnummer century.
2254
+ *
2255
+ * @var {string}
2256
+ */
2257
+ this._century = '';
2258
+ /**
2259
+ * Personnummer full year.
2260
+ *
2261
+ * @var {string}
2262
+ */
2263
+ this._fullYear = '';
2264
+ /**
2265
+ * Personnummer year.
2266
+ *
2267
+ * @var {string}
2268
+ */
2269
+ this._year = '';
2270
+ /**
2271
+ * Personnummer month.
2272
+ *
2273
+ * @var {string}
2274
+ */
2275
+ this._month = '';
2276
+ /**
2277
+ * Personnummer day.
2278
+ *
2279
+ * @var {string}
2280
+ */
2281
+ this._day = '';
2282
+ /**
2283
+ * Personnummer seperator.
2284
+ *
2285
+ * @var {string}
2286
+ */
2287
+ this._sep = '';
2288
+ /**
2289
+ * Personnumer first three of the last four numbers.
2290
+ *
2291
+ * @var {string}
2292
+ */
2293
+ this._num = '';
2294
+ /**
2295
+ * The last number of the personnummer.
2296
+ *
2297
+ * @var {string}
2298
+ */
2299
+ this._check = '';
2300
+ this.parse(pin, {
2301
+ allowCoordinationNumber: true,
2302
+ allowInterimNumber: false,
2303
+ ...options,
2304
+ });
2305
+ }
2306
+ /**
2307
+ * Get century.
2308
+ *
2309
+ * @return {string}
2310
+ */
2311
+ get century() {
2312
+ return this._century;
2313
+ }
2314
+ /**
2315
+ * Get age.
2316
+ *
2317
+ * @return {string}
2318
+ */
2319
+ get fullYear() {
2320
+ return this._fullYear;
2321
+ }
2322
+ /**
2323
+ * Get age.
2324
+ *
2325
+ * @return {string}
2326
+ */
2327
+ get year() {
2328
+ return this._year;
2329
+ }
2330
+ /**
2331
+ * Get month.
2332
+ *
2333
+ * @return {string}
2334
+ */
2335
+ get month() {
2336
+ return this._month;
2337
+ }
2338
+ /**
2339
+ * Get day.
2340
+ *
2341
+ * @return {string}
2342
+ */
2343
+ get day() {
2344
+ return this._day;
2345
+ }
2346
+ /**
2347
+ * Get sep.
2348
+ *
2349
+ * @return {string}
2350
+ */
2351
+ get sep() {
2352
+ return this._sep;
2353
+ }
2354
+ /**
2355
+ * Get num.
2356
+ *
2357
+ * @return {string}
2358
+ */
2359
+ get num() {
2360
+ return this._num;
2361
+ }
2362
+ /**
2363
+ * Get check.
2364
+ *
2365
+ * @return {string}
2366
+ */
2367
+ get check() {
2368
+ return this._check;
2369
+ }
2370
+ /**
2371
+ * Parse personnummer.
2372
+ *
2373
+ * @param {string} pin
2374
+ * @param {object} options
2375
+ *
2376
+ * @return {Personnummer}
2377
+ */
2378
+ static parse(pin, options) {
2379
+ return new Personnummer(pin, options);
2380
+ }
2381
+ /**
2382
+ * Validate a Swedish personal identity number.
2383
+ *
2384
+ * @param {string} str
2385
+ * @param {object} options
2386
+ *
2387
+ * @return {boolean}
2388
+ */
2389
+ static valid(pin, options) {
2390
+ try {
2391
+ Personnummer.parse(pin, options);
2392
+ return true;
2393
+ } catch (e) {
2394
+ return false;
2395
+ }
2396
+ }
2397
+ /**
2398
+ * Parse personnummer and set class properties.
2399
+ *
2400
+ * @param {string} pin
2401
+ * @param {object} options
2402
+ */
2403
+ parse(pin, options) {
2404
+ if (pin.length < 10 || pin.length > 13) {
2405
+ throw new PersonnummerError();
2406
+ }
2407
+ const reg = /^(\d{2}){0,1}(\d{2})(\d{2})(\d{2})([+-]?)((?!000)\d{3}|[TRSUWXJKLMN]\d{2})(\d)$/;
2408
+ const match = reg.exec(pin);
2409
+ if (!match) {
2410
+ throw new PersonnummerError();
2411
+ }
2412
+ const century = match[1];
2413
+ const year = match[2];
2414
+ const month = match[3];
2415
+ const day = match[4];
2416
+ const sep = match[5];
2417
+ const num = match[6];
2418
+ const check = match[7];
2419
+ if (typeof century === 'undefined' || !century.length) {
2420
+ const d = /* @__PURE__ */ new Date();
2421
+ let baseYear = 0;
2422
+ if (sep === '+') {
2423
+ this._sep = '+';
2424
+ baseYear = d.getFullYear() - 100;
2425
+ } else {
2426
+ this._sep = '-';
2427
+ baseYear = d.getFullYear();
2428
+ }
2429
+ this._century = ('' + (baseYear - ((baseYear - parseInt(year)) % 100))).substr(0, 2);
2430
+ } else {
2431
+ this._century = century;
2432
+ if (/* @__PURE__ */ new Date().getFullYear() - parseInt(century + year, 10) < 100) {
2433
+ this._sep = '-';
2434
+ } else {
2435
+ this._sep = '+';
2436
+ }
2437
+ }
2438
+ this._year = year;
2439
+ this._fullYear = this._century + year;
2440
+ this._month = month;
2441
+ this._day = day;
2442
+ this._num = num;
2443
+ this._check = check;
2444
+ if (!this.valid()) {
2445
+ throw new PersonnummerError();
2446
+ }
2447
+ if (!(options == null ? void 0 : options.allowCoordinationNumber) && this.isCoordinationNumber()) {
2448
+ throw new PersonnummerError();
2449
+ }
2450
+ if (!(options == null ? void 0 : options.allowInterimNumber) && this.isInterimNumber()) {
2451
+ throw new PersonnummerError();
2452
+ }
2453
+ }
2454
+ /**
2455
+ * Validate a Swedish personal identity number.
2456
+ *
2457
+ * @return {boolean}
2458
+ */
2459
+ valid() {
2460
+ const valid = luhn(this.year + this.month + this.day + this.num.replace(/[TRSUWXJKLMN]/, '1')) === +this.check && !!this.check;
2461
+ if (valid && testDate(parseInt(this.century + this.year), +this.month, +this.day)) {
2462
+ return valid;
2463
+ }
2464
+ return valid && testDate(parseInt(this.century + this.year), +this.month, +this.day - 60);
2465
+ }
2466
+ /**
2467
+ * Format a Swedish personal identity number as one of the official formats,
2468
+ * A long format or a short format.
2469
+ *
2470
+ * If the input number could not be parsed a empty string will be returned.
2471
+ *
2472
+ * @param {boolean} longFormat
2473
+ *
2474
+ * @return {string}
2475
+ */
2476
+ format(longFormat = false) {
2477
+ if (longFormat) {
2478
+ return `${this.century}${this.year}${this.month}${this.day}${this.num}${this.check}`;
2479
+ }
2480
+ return `${this.year}${this.month}${this.day}${this.sep}${this.num}${this.check}`;
2481
+ }
2482
+ /**
2483
+ * Get age from a Swedish personal identity number.
2484
+ *
2485
+ * @return {number}
2486
+ */
2487
+ getAge() {
2488
+ const date = this.getDate();
2489
+ return diffInYears(new Date(Date.now()), date);
2490
+ }
2491
+ /**
2492
+ * Get date from a Swedish personal identity number.
2493
+ *
2494
+ * @return {Date}
2495
+ */
2496
+ getDate() {
2497
+ let ageDay = +this.day;
2498
+ if (this.isCoordinationNumber()) {
2499
+ ageDay -= 60;
2500
+ }
2501
+ const ageDate = this.century + this.year + '-' + this.month + '-' + (ageDay < 10 ? '0' + ageDay : ageDay);
2502
+ return new Date(ageDate);
2503
+ }
2504
+ /**
2505
+ * Check if a Swedish personal identity number is a interim number or not.
2506
+ *
2507
+ * @return {boolean}
2508
+ */
2509
+ isInterimNumber() {
2510
+ return /[TRSUWXJKLMN]/.test(this.num[0]);
2511
+ }
2512
+ /**
2513
+ * Check if a Swedish personal identity number is a coordination number or not.
2514
+ *
2515
+ * @return {boolean}
2516
+ */
2517
+ isCoordinationNumber() {
2518
+ return testDate(parseInt(this.century + this.year), +this.month, +this.day - 60);
2519
+ }
2520
+ /**
2521
+ * Check if a Swedish personal identity number is for a female.
2522
+ *
2523
+ * @return {boolean}
2524
+ */
2525
+ isFemale() {
2526
+ return !this.isMale();
2527
+ }
2528
+ /**
2529
+ * Check if a Swedish personal identity number is for a male.
2530
+ *
2531
+ * @return {boolean}
2532
+ */
2533
+ isMale() {
2534
+ const sexDigit = parseInt(this.num.substr(-1));
2535
+ return sexDigit % 2 === 1;
2536
+ }
2537
+ };
2538
+ var src_default = Personnummer;
2539
+
2540
+ function createCommonjsModule(fn, basedir, module) {
2541
+ return (
2542
+ (module = {
2543
+ path: basedir,
2544
+ exports: {},
2545
+ require: function (path, base) {
2546
+ return commonjsRequire();
2547
+ },
2548
+ }),
2549
+ fn(module, module.exports),
2550
+ module.exports
2551
+ );
2552
+ }
2553
+
2554
+ function commonjsRequire() {
2555
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
2556
+ }
2557
+
2558
+ var utf8 = createCommonjsModule(function (module, exports) {
2559
+ // tslint:disable:no-bitwise
2560
+ Object.defineProperty(exports, '__esModule', { value: true });
2561
+ exports.utf8 = void 0;
2562
+ exports.utf8 = {
2563
+ encode: encode,
2564
+ decode: decode,
2565
+ };
2566
+ function encode(unicodeText) {
2567
+ unicodeText = unicodeText.replace(/\r\n/g, '\n');
2568
+ var result = '';
2569
+ for (var i = 0; i < unicodeText.length; i++) {
2570
+ var char = unicodeText.charCodeAt(i);
2571
+ if (char < 128) {
2572
+ result += String.fromCharCode(char);
2573
+ } else if (char > 127 && char < 2048) {
2574
+ result += String.fromCharCode((char >> 6) | 192);
2575
+ result += String.fromCharCode((char & 63) | 128);
2576
+ } else {
2577
+ result += String.fromCharCode((char >> 12) | 224);
2578
+ result += String.fromCharCode(((char >> 6) & 63) | 128);
2579
+ result += String.fromCharCode((char & 63) | 128);
2580
+ }
2581
+ }
2582
+ return result;
2583
+ }
2584
+ function decode(utf8Text) {
2585
+ var result = '';
2586
+ var i = 0;
2587
+ var char1 = 0;
2588
+ var char2 = 0;
2589
+ var char3 = 0;
2590
+ while (i < utf8Text.length) {
2591
+ char1 = utf8Text.charCodeAt(i);
2592
+ if (char1 < 128) {
2593
+ result += String.fromCharCode(char1);
2594
+ i++;
2595
+ } else if (char1 > 191 && char1 < 224) {
2596
+ char2 = utf8Text.charCodeAt(i + 1);
2597
+ result += String.fromCharCode(((char1 & 31) << 6) | (char2 & 63));
2598
+ i += 2;
2599
+ } else {
2600
+ char2 = utf8Text.charCodeAt(i + 1);
2601
+ char3 = utf8Text.charCodeAt(i + 2);
2602
+ result += String.fromCharCode(((char1 & 15) << 12) | ((char2 & 63) << 6) | (char3 & 63));
2603
+ i += 3;
2604
+ }
2605
+ }
2606
+ return result;
2607
+ }
2608
+ });
2609
+
2610
+ var md5 = createCommonjsModule(function (module, exports) {
2611
+ // tslint:disable:no-bitwise
2612
+ Object.defineProperty(exports, '__esModule', { value: true });
2613
+ exports.generate = void 0;
2614
+
2615
+ function generate(unicodeText) {
2616
+ var x = [];
2617
+ var k;
2618
+ var AA;
2619
+ var BB;
2620
+ var CC;
2621
+ var DD;
2622
+ var a;
2623
+ var b;
2624
+ var c;
2625
+ var d;
2626
+ var S11 = 7;
2627
+ var S12 = 12;
2628
+ var S13 = 17;
2629
+ var S14 = 22;
2630
+ var S21 = 5;
2631
+ var S22 = 9;
2632
+ var S23 = 14;
2633
+ var S24 = 20;
2634
+ var S31 = 4;
2635
+ var S32 = 11;
2636
+ var S33 = 16;
2637
+ var S34 = 23;
2638
+ var S41 = 6;
2639
+ var S42 = 10;
2640
+ var S43 = 15;
2641
+ var S44 = 21;
2642
+ var utf8Text = utf8.utf8.encode(unicodeText);
2643
+ x = convertToWordArray(utf8Text);
2644
+ a = 0x67452301;
2645
+ b = 0xefcdab89;
2646
+ c = 0x98badcfe;
2647
+ d = 0x10325476;
2648
+ for (k = 0; k < x.length; k += 16) {
2649
+ AA = a;
2650
+ BB = b;
2651
+ CC = c;
2652
+ DD = d;
2653
+ a = FF(a, b, c, d, x[k + 0], S11, 0xd76aa478);
2654
+ d = FF(d, a, b, c, x[k + 1], S12, 0xe8c7b756);
2655
+ c = FF(c, d, a, b, x[k + 2], S13, 0x242070db);
2656
+ b = FF(b, c, d, a, x[k + 3], S14, 0xc1bdceee);
2657
+ a = FF(a, b, c, d, x[k + 4], S11, 0xf57c0faf);
2658
+ d = FF(d, a, b, c, x[k + 5], S12, 0x4787c62a);
2659
+ c = FF(c, d, a, b, x[k + 6], S13, 0xa8304613);
2660
+ b = FF(b, c, d, a, x[k + 7], S14, 0xfd469501);
2661
+ a = FF(a, b, c, d, x[k + 8], S11, 0x698098d8);
2662
+ d = FF(d, a, b, c, x[k + 9], S12, 0x8b44f7af);
2663
+ c = FF(c, d, a, b, x[k + 10], S13, 0xffff5bb1);
2664
+ b = FF(b, c, d, a, x[k + 11], S14, 0x895cd7be);
2665
+ a = FF(a, b, c, d, x[k + 12], S11, 0x6b901122);
2666
+ d = FF(d, a, b, c, x[k + 13], S12, 0xfd987193);
2667
+ c = FF(c, d, a, b, x[k + 14], S13, 0xa679438e);
2668
+ b = FF(b, c, d, a, x[k + 15], S14, 0x49b40821);
2669
+ a = GG(a, b, c, d, x[k + 1], S21, 0xf61e2562);
2670
+ d = GG(d, a, b, c, x[k + 6], S22, 0xc040b340);
2671
+ c = GG(c, d, a, b, x[k + 11], S23, 0x265e5a51);
2672
+ b = GG(b, c, d, a, x[k + 0], S24, 0xe9b6c7aa);
2673
+ a = GG(a, b, c, d, x[k + 5], S21, 0xd62f105d);
2674
+ d = GG(d, a, b, c, x[k + 10], S22, 0x2441453);
2675
+ c = GG(c, d, a, b, x[k + 15], S23, 0xd8a1e681);
2676
+ b = GG(b, c, d, a, x[k + 4], S24, 0xe7d3fbc8);
2677
+ a = GG(a, b, c, d, x[k + 9], S21, 0x21e1cde6);
2678
+ d = GG(d, a, b, c, x[k + 14], S22, 0xc33707d6);
2679
+ c = GG(c, d, a, b, x[k + 3], S23, 0xf4d50d87);
2680
+ b = GG(b, c, d, a, x[k + 8], S24, 0x455a14ed);
2681
+ a = GG(a, b, c, d, x[k + 13], S21, 0xa9e3e905);
2682
+ d = GG(d, a, b, c, x[k + 2], S22, 0xfcefa3f8);
2683
+ c = GG(c, d, a, b, x[k + 7], S23, 0x676f02d9);
2684
+ b = GG(b, c, d, a, x[k + 12], S24, 0x8d2a4c8a);
2685
+ a = HH(a, b, c, d, x[k + 5], S31, 0xfffa3942);
2686
+ d = HH(d, a, b, c, x[k + 8], S32, 0x8771f681);
2687
+ c = HH(c, d, a, b, x[k + 11], S33, 0x6d9d6122);
2688
+ b = HH(b, c, d, a, x[k + 14], S34, 0xfde5380c);
2689
+ a = HH(a, b, c, d, x[k + 1], S31, 0xa4beea44);
2690
+ d = HH(d, a, b, c, x[k + 4], S32, 0x4bdecfa9);
2691
+ c = HH(c, d, a, b, x[k + 7], S33, 0xf6bb4b60);
2692
+ b = HH(b, c, d, a, x[k + 10], S34, 0xbebfbc70);
2693
+ a = HH(a, b, c, d, x[k + 13], S31, 0x289b7ec6);
2694
+ d = HH(d, a, b, c, x[k + 0], S32, 0xeaa127fa);
2695
+ c = HH(c, d, a, b, x[k + 3], S33, 0xd4ef3085);
2696
+ b = HH(b, c, d, a, x[k + 6], S34, 0x4881d05);
2697
+ a = HH(a, b, c, d, x[k + 9], S31, 0xd9d4d039);
2698
+ d = HH(d, a, b, c, x[k + 12], S32, 0xe6db99e5);
2699
+ c = HH(c, d, a, b, x[k + 15], S33, 0x1fa27cf8);
2700
+ b = HH(b, c, d, a, x[k + 2], S34, 0xc4ac5665);
2701
+ a = II(a, b, c, d, x[k + 0], S41, 0xf4292244);
2702
+ d = II(d, a, b, c, x[k + 7], S42, 0x432aff97);
2703
+ c = II(c, d, a, b, x[k + 14], S43, 0xab9423a7);
2704
+ b = II(b, c, d, a, x[k + 5], S44, 0xfc93a039);
2705
+ a = II(a, b, c, d, x[k + 12], S41, 0x655b59c3);
2706
+ d = II(d, a, b, c, x[k + 3], S42, 0x8f0ccc92);
2707
+ c = II(c, d, a, b, x[k + 10], S43, 0xffeff47d);
2708
+ b = II(b, c, d, a, x[k + 1], S44, 0x85845dd1);
2709
+ a = II(a, b, c, d, x[k + 8], S41, 0x6fa87e4f);
2710
+ d = II(d, a, b, c, x[k + 15], S42, 0xfe2ce6e0);
2711
+ c = II(c, d, a, b, x[k + 6], S43, 0xa3014314);
2712
+ b = II(b, c, d, a, x[k + 13], S44, 0x4e0811a1);
2713
+ a = II(a, b, c, d, x[k + 4], S41, 0xf7537e82);
2714
+ d = II(d, a, b, c, x[k + 11], S42, 0xbd3af235);
2715
+ c = II(c, d, a, b, x[k + 2], S43, 0x2ad7d2bb);
2716
+ b = II(b, c, d, a, x[k + 9], S44, 0xeb86d391);
2717
+ a = addUnsigned(a, AA);
2718
+ b = addUnsigned(b, BB);
2719
+ c = addUnsigned(c, CC);
2720
+ d = addUnsigned(d, DD);
2721
+ }
2722
+ return wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d);
2723
+ }
2724
+ exports.generate = generate;
2725
+ function rotateLeft(lValue, iShiftBits) {
2726
+ return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
2727
+ }
2728
+ function addUnsigned(lX, lY) {
2729
+ var lX4;
2730
+ var lY4;
2731
+ var lX8;
2732
+ var lY8;
2733
+ var lResult;
2734
+ lX8 = lX & 0x80000000;
2735
+ lY8 = lY & 0x80000000;
2736
+ lX4 = lX & 0x40000000;
2737
+ lY4 = lY & 0x40000000;
2738
+ lResult = (lX & 0x3fffffff) + (lY & 0x3fffffff);
2739
+ if (lX4 & lY4) {
2740
+ return lResult ^ 0x80000000 ^ lX8 ^ lY8;
2741
+ }
2742
+ if (lX4 | lY4) {
2743
+ if (lResult & 0x40000000) {
2744
+ return lResult ^ 0xc0000000 ^ lX8 ^ lY8;
2745
+ } else {
2746
+ return lResult ^ 0x40000000 ^ lX8 ^ lY8;
2747
+ }
2748
+ } else {
2749
+ return lResult ^ lX8 ^ lY8;
2750
+ }
2751
+ }
2752
+ function F(x, y, z) {
2753
+ return (x & y) | (~x & z);
2754
+ }
2755
+ function G(x, y, z) {
2756
+ return (x & z) | (y & ~z);
2757
+ }
2758
+ function H(x, y, z) {
2759
+ return x ^ y ^ z;
2760
+ }
2761
+ function I(x, y, z) {
2762
+ return y ^ (x | ~z);
2763
+ }
2764
+ function FF(a, b, c, d, x, s, ac) {
2765
+ a = addUnsigned(a, addUnsigned(addUnsigned(F(b, c, d), x), ac));
2766
+ return addUnsigned(rotateLeft(a, s), b);
2767
+ }
2768
+ function GG(a, b, c, d, x, s, ac) {
2769
+ a = addUnsigned(a, addUnsigned(addUnsigned(G(b, c, d), x), ac));
2770
+ return addUnsigned(rotateLeft(a, s), b);
2771
+ }
2772
+ function HH(a, b, c, d, x, s, ac) {
2773
+ a = addUnsigned(a, addUnsigned(addUnsigned(H(b, c, d), x), ac));
2774
+ return addUnsigned(rotateLeft(a, s), b);
2775
+ }
2776
+ function II(a, b, c, d, x, s, ac) {
2777
+ a = addUnsigned(a, addUnsigned(addUnsigned(I(b, c, d), x), ac));
2778
+ return addUnsigned(rotateLeft(a, s), b);
2779
+ }
2780
+ function convertToWordArray(value) {
2781
+ var lWordCount;
2782
+ var lMessageLength = value.length;
2783
+ var lNumberOfWordsTemp1 = lMessageLength + 8;
2784
+ var lNumberOfWordsTemp2 = (lNumberOfWordsTemp1 - (lNumberOfWordsTemp1 % 64)) / 64;
2785
+ var lNumberOfWords = (lNumberOfWordsTemp2 + 1) * 16;
2786
+ var lWordArray = Array(lNumberOfWords - 1);
2787
+ var lBytePosition = 0;
2788
+ var lByteCount = 0;
2789
+ while (lByteCount < lMessageLength) {
2790
+ lWordCount = (lByteCount - (lByteCount % 4)) / 4;
2791
+ lBytePosition = (lByteCount % 4) * 8;
2792
+ lWordArray[lWordCount] = lWordArray[lWordCount] | (value.charCodeAt(lByteCount) << lBytePosition);
2793
+ lByteCount++;
2794
+ }
2795
+ lWordCount = (lByteCount - (lByteCount % 4)) / 4;
2796
+ lBytePosition = (lByteCount % 4) * 8;
2797
+ lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
2798
+ lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
2799
+ lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
2800
+ return lWordArray;
2801
+ }
2802
+ function wordToHex(lValue) {
2803
+ var wordToHexValue = '';
2804
+ var wordToHexValueTemp = '';
2805
+ var lByte;
2806
+ var lCount;
2807
+ for (lCount = 0; lCount <= 3; lCount++) {
2808
+ lByte = (lValue >>> (lCount * 8)) & 255;
2809
+ wordToHexValueTemp = '0' + lByte.toString(16);
2810
+ wordToHexValue = wordToHexValue + wordToHexValueTemp.substr(wordToHexValueTemp.length - 2, 2);
2811
+ }
2812
+ return wordToHexValue;
2813
+ }
2814
+ });
2815
+
2816
+ var lib = createCommonjsModule(function (module, exports) {
2817
+ Object.defineProperty(exports, '__esModule', { value: true });
2818
+ exports.MD5 = exports.generate = void 0;
2819
+
2820
+ var md5_2 = md5;
2821
+ Object.defineProperty(exports, 'generate', {
2822
+ enumerable: true,
2823
+ get: function () {
2824
+ return md5_2.generate;
2825
+ },
2826
+ });
2827
+ exports.MD5 = {
2828
+ generate: md5.generate,
2829
+ };
2830
+ });
2831
+
2832
+ const apiSearch = async query => {
2833
+ var _a;
2834
+ const res = await fetch((_a = 'https://hemfixare-lookup.vercel.app/api') !== null && _a !== void 0 ? _a : 'https://hemfixare-lookup.vercel.app/api', {
2835
+ method: 'POST',
2836
+ headers: {
2837
+ 'Content-Type': 'application/json',
2838
+ },
2839
+ body: JSON.stringify({
2840
+ query,
2841
+ hash: lib.MD5.generate(String.fromCharCode(83, 101, 67, 82, 101, 116) + query),
2842
+ }),
2843
+ });
2844
+ const data = await res.json();
2845
+ return data;
2846
+ };
2847
+
2848
+ const HemfixarnaGetuser = class {
2849
+ constructor(hostRef) {
2850
+ registerInstance(this, hostRef);
2851
+ this.handleChangeEmail = e => {
2852
+ this.emailError = null;
2853
+ this.email = e.target.value;
2854
+ };
2855
+ this.handleChangePhone = e => {
2856
+ this.phoneError = null;
2857
+ this.phone = e.target.value;
2858
+ };
2859
+ this.handleChangessn = e => {
2860
+ this.ssnError = null;
2861
+ this.ssn = e.target.value;
2862
+ };
2863
+ this.handleSubmit = async e => {
2864
+ e.preventDefault();
2865
+ const emailRegex = new RegExp(
2866
+ /^(([^<>()\[\]\\.,;:\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,}))$/,
2867
+ );
2868
+ const validEmail = emailRegex.test(this.email);
2869
+ if (!validEmail) {
2870
+ this.emailError = 'Ange en giltig e-postadress';
2871
+ }
2872
+ const validPhone = /^[\d\s()+-]{6,}$/.test(this.phone);
2873
+ if (!validPhone) {
2874
+ this.phoneError = 'Ange ett giltigt telefonnummer';
2875
+ }
2876
+ const validssn = src_default.valid(this.ssn);
2877
+ if (!validssn) {
2878
+ this.ssnError = 'Ange ett giltigt personnummer';
2879
+ } else if (validssn) {
2880
+ const pn = src_default.parse(this.ssn).format(true);
2881
+ this.ssn = [pn.slice(0, 8), '-', pn.slice(8)].join('');
2882
+ }
2883
+ if (validEmail && validPhone && validssn) {
2884
+ try {
2885
+ const creditSafeData = await apiSearch(this.ssn);
2886
+ if (creditSafeData) {
2887
+ state.creditSafeUser = creditSafeData;
2888
+ state.checkoutStep = 2;
2889
+ state.user = Object.assign(Object.assign({}, creditSafeData), { email: this.email, phone: this.phone, ssn: this.ssn });
2890
+ } else {
2891
+ this.ssnError = 'Vi kunde tyvärr inte hitta en address med ditt angivna personnummer';
2892
+ }
2893
+ } catch (e) {
2894
+ this.ssnError = 'Vi kunde tyvärr inte hitta en address med ditt angivna personnummer';
2895
+ console.log(e);
2896
+ } finally {
2897
+ const el = this.el.closest('.hemfixarna_content');
2898
+ scrollToTop(el);
2899
+ }
2900
+ }
2901
+ };
2902
+ this.render = () => {
2903
+ return h(
2904
+ 'form',
2905
+ { class: 'mb-2', onSubmit: e => this.handleSubmit(e) },
2906
+ h(
2907
+ 'div',
2908
+ null,
2909
+ h('input', { class: `${this.email.length ? 'input_active' : ''}`, onChange: e => this.handleChangeEmail(e), type: 'email', name: 'email', value: this.email }),
2910
+ h('label', { htmlFor: 'email' }, 'E-post '),
2911
+ ),
2912
+ this.emailError && h('span', null, this.emailError),
2913
+ h(
2914
+ 'div',
2915
+ null,
2916
+ h('input', { class: `${this.phone.length ? 'input_active' : ''}`, onChange: e => this.handleChangePhone(e), type: 'tel', name: 'phone', value: this.phone }),
2917
+ h('label', { htmlFor: 'phone' }, 'Mobiltelefon '),
2918
+ ),
2919
+ this.phoneError && h('span', null, this.phoneError),
2920
+ h(
2921
+ 'div',
2922
+ null,
2923
+ h('input', { class: `${this.ssn.length ? 'input_active' : ''}`, onChange: e => this.handleChangessn(e), type: 'tel', name: 'ssn', value: this.ssn }),
2924
+ h('label', { htmlFor: 'phone' }, 'Personnummer*'),
2925
+ ),
2926
+ this.ssnError && h('span', null, this.ssnError),
2927
+ h('input', { type: 'submit', value: 'Forts\u00E4tt*' }),
2928
+ h('p', null, '*Vi h\u00E4mtar din adress'),
2929
+ );
2930
+ };
2931
+ this.email = '';
2932
+ this.emailError = null;
2933
+ this.phone = '';
2934
+ this.phoneError = null;
2935
+ this.ssn = '';
2936
+ this.ssnError = null;
2937
+ }
2938
+ componentWillLoad() {
2939
+ if (state.user) {
2940
+ this.email = state.user.email;
2941
+ this.phone = state.user.phone;
2942
+ this.ssn = state.user.ssn;
2943
+ }
2944
+ }
2945
+ get el() {
2946
+ return getElement(this);
2947
+ }
2948
+ };
2949
+
2950
+ const hemfixarnaHornbachCss = '';
2951
+
2952
+ const MyComponent$c = class {
2953
+ constructor(hostRef) {
2954
+ registerInstance(this, hostRef);
2955
+ this.id = undefined;
2956
+ this.loadFromQuery = 'true';
2957
+ this.isDemo = false;
2958
+ this.widgetStyle = WidgetStyle.standard;
2959
+ this.buttonColor = undefined;
2960
+ this.buttonBg = undefined;
2961
+ }
2962
+ render() {
2963
+ return h('hemfixarna-component', {
2964
+ widgetStyle: this.widgetStyle,
2965
+ buttonBg: this.buttonBg,
2966
+ buttonColor: this.buttonColor,
2967
+ nav: { url: 'https://www.hornbach.se/', logo: 'assets/hornbach/logo.svg', background: './assets/hornbach/nav.jpg' },
2968
+ isDemo: this.isDemo,
2969
+ loadFromQuery: Boolean(this.loadFromQuery),
2970
+ id: this.id,
2971
+ business: Business.hornbach,
2972
+ });
2973
+ }
2974
+ };
2975
+ MyComponent$c.style = hemfixarnaHornbachCss;
2976
+
2977
+ const HemfixarnaInfo = class {
2978
+ constructor(hostRef) {
2979
+ registerInstance(this, hostRef);
2980
+ this.logo = getAssetPath(`./assets/hemfixarna.svg`);
2981
+ }
2982
+ render() {
2983
+ var _a;
2984
+ const checked = getAssetPath(`./assets/checked.svg`);
2985
+ return h(
2986
+ 'div',
2987
+ { class: 'hemfixarna_info' },
2988
+ state.step < 5 ? h(Fragment, null, h('h2', null, state.customer.info_title), h('p', null, state.customer.info_text)) : h('h2', null, state.customer.checkout_title),
2989
+ h(
2990
+ 'ul',
2991
+ { class: 'hemfixarna_features' },
2992
+ state.step < 5
2993
+ ? h(
2994
+ Fragment,
2995
+ null,
2996
+ ((_a = state.customer.trust_badges) === null || _a === void 0 ? void 0 : _a.length)
2997
+ ? h(
2998
+ Fragment,
2999
+ null,
3000
+ state.customer.trust_badges.map(l => h('li', { key: l.text }, h('img', { src: checked, alt: 'checked' }), h('p', null, l.text))),
3001
+ )
3002
+ : h(
3003
+ Fragment,
3004
+ null,
3005
+ state.options.trust.map(l => h('li', { key: l.trust_badge }, h('img', { src: checked, alt: 'checked' }), h('p', null, l.trust_badge))),
3006
+ ),
3007
+ )
3008
+ : h(
3009
+ Fragment,
3010
+ null,
3011
+ state.customer.checkout_trust_badges.map(l => h('li', { key: l.text }, h('img', { src: checked, alt: 'checked' }), h('p', null, l.text))),
3012
+ ),
3013
+ ),
3014
+ h('img', { src: this.logo, width: 200, alt: 'hemfixarna' }),
3015
+ h('a', { class: 'hemfixarna_product--link', target: '_blank', href: state.options.link.url }, state.options.link.title),
3016
+ );
3017
+ }
3018
+ };
3019
+
3020
+ const hemfixarnaInvoiceCss =
3021
+ ':host .invoice{gap:16px;display:grid}:host .invoice form>span{text-align:center;padding:16px 0}:host .invoice img{right:unset;left:unset;position:initial;transform:none}:host .invoice label{cursor:pointer;font-size:14px;display:flex;align-items:flex-start;padding:16px 0}:host .invoice label input{margin:0 5px 0 0;accent-color:#ea662c}:host .invoice-preview{display:flex;gap:4px}:host .invoice-preview div{position:relative}:host .invoice-preview div button{position:absolute;top:0;right:0;padding:0}:host .invoice-preview div button img{width:24px;height:24px}:host .invoice-preview div>img{width:100px;height:80px;object-fit:cover}:host .invoice input[type=email],:host .invoice input[type=tel],:host .invoice textarea{padding:16px;border:1px solid #fcd9c9;font-size:16px}:host .invoice textarea{resize:none;height:200px;font-family:"Inter", sans-serif}:host .invoice div:has(>input[type=file]){display:flex;align-items:center;justify-content:center;cursor:pointer;background:#fff;border:1px solid #fcd9c9;padding:32px 16px;gap:16px}:host .invoice div:has(>input[type=file]) span{color:#000;font-size:12px}:host .invoice input[type=file]{display:none}';
3022
+
3023
+ const base = `${'https://hemfixarna.se'}/wp-json/headless`;
3024
+ const HemfixarnaInvoice = class {
3025
+ constructor(hostRef) {
3026
+ registerInstance(this, hostRef);
3027
+ this.formError = null;
3028
+ this.displayImages = [];
3029
+ this.formImages = [];
3030
+ this.formState = 'initial';
3031
+ }
3032
+ isValidEmail(email) {
3033
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
3034
+ return emailRegex.test(email);
3035
+ }
3036
+ componentDidRender() {
3037
+ const form = this.el.querySelector('form');
3038
+ if (form) {
3039
+ form.addEventListener('input', () => {
3040
+ this.formError = null;
3041
+ });
3042
+ }
3043
+ }
3044
+ disconnectedCallback() {
3045
+ const form = this.el.querySelector('form');
3046
+ if (form) {
3047
+ form.removeEventListener('input', () => {
3048
+ this.formError = null;
3049
+ });
3050
+ }
3051
+ }
3052
+ async submit(e) {
3053
+ var _a;
3054
+ e.preventDefault();
3055
+ this.formState = 'loading';
3056
+ this.formError = null;
3057
+ const form = e.currentTarget.elements;
3058
+ const values = {
3059
+ description: form.descriptionInput.value.length ? form.descriptionInput.value : null,
3060
+ email: form.emailInput.value.length ? form.emailInput.value : null,
3061
+ tel: form.telInput.value.length ? form.telInput.value : null,
3062
+ terms: (_a = form.termsInput) === null || _a === void 0 ? void 0 : _a.checked,
3063
+ };
3064
+ if (!values.description) {
3065
+ this.formError = 'Vänligen fyll i formulärtexten';
3066
+ this.formState = 'initial';
3067
+ return;
3068
+ }
3069
+ if (!values.email || !this.isValidEmail(values.email)) {
3070
+ this.formError = 'Vänligen ange en giltig e-postadress';
3071
+ this.formState = 'initial';
3072
+ return;
3073
+ }
3074
+ if (!values.tel) {
3075
+ this.formError = 'Vänligen ange ditt telefonnummer';
3076
+ this.formState = 'initial';
3077
+ return;
3078
+ }
3079
+ if (state.selectedProduct.terms_show_checkbox && !values.terms) {
3080
+ this.formError = 'Vänligen acceptera villkoren';
3081
+ this.formState = 'initial';
3082
+ return;
3083
+ }
3084
+ const formData = new FormData();
3085
+ formData.append('text', values.description);
3086
+ formData.append('email', values.email);
3087
+ formData.append('phone', values.tel);
3088
+ formData.append('customer', state.business);
3089
+ this.formImages.forEach(file => {
3090
+ formData.append('images[]', file);
3091
+ });
3092
+ formData.append(
3093
+ 'product',
3094
+ JSON.stringify({
3095
+ title: state.selectedProduct.title,
3096
+ amount: 1,
3097
+ has_rut: state.selectedProduct.rut,
3098
+ has_rot: state.selectedProduct.rot,
3099
+ has_green: state.selectedProduct.green,
3100
+ ID: state.selectedProduct.ID,
3101
+ parts: [],
3102
+ }),
3103
+ );
3104
+ try {
3105
+ const res = await fetch(`${base}/saveinvoiceproduct`, {
3106
+ method: 'POST',
3107
+ body: formData,
3108
+ });
3109
+ const { response } = await res.json();
3110
+ if (response.code === 200) {
3111
+ state.checkoutInvoice = true;
3112
+ state.step = 6;
3113
+ } else {
3114
+ this.formError = 'Vi kan inte ta emot din beställning just nu';
3115
+ this.formState = 'initial';
3116
+ }
3117
+ } catch (error) {
3118
+ this.formError = 'Vi kan inte ta emot din beställning just nu';
3119
+ this.formState = 'initial';
3120
+ }
3121
+ }
3122
+ handleImageDrop(e) {
3123
+ e.preventDefault();
3124
+ const files = e.dataTransfer.files;
3125
+ for (let i = 0; i < files.length; i++) {
3126
+ const file = files[i];
3127
+ if (file.type.startsWith('image/')) {
3128
+ const reader = new FileReader();
3129
+ reader.onload = () => {
3130
+ this.displayImages = [...this.displayImages, reader.result];
3131
+ this.formImages = [...this.formImages, file];
3132
+ };
3133
+ reader.readAsDataURL(file);
3134
+ }
3135
+ }
3136
+ }
3137
+ handleFileInputChange(e) {
3138
+ e.preventDefault();
3139
+ const files = e.target.files;
3140
+ for (let i = 0; i < files.length; i++) {
3141
+ const file = files[i];
3142
+ if (file.type.startsWith('image/')) {
3143
+ const reader = new FileReader();
3144
+ reader.onload = () => {
3145
+ this.displayImages = [...this.displayImages, reader.result];
3146
+ this.formImages = [...this.formImages, file];
3147
+ };
3148
+ reader.readAsDataURL(file);
3149
+ }
3150
+ }
3151
+ }
3152
+ handleImageClick() {
3153
+ this.el.querySelector('.hemfixarna-file-upload').click();
3154
+ }
3155
+ preventDragOver(e) {
3156
+ e.preventDefault();
3157
+ }
3158
+ removeImage(index) {
3159
+ this.displayImages = this.displayImages.filter((_, i) => i !== index);
3160
+ this.formImages = this.formImages.filter((_, i) => i !== index);
3161
+ }
3162
+ render() {
3163
+ const upload = getAssetPath(`./assets/drag-drop.svg`);
3164
+ return h(
3165
+ 'div',
3166
+ { class: 'invoice' },
3167
+ h('p', null, state.selectedProduct.invoice_description),
3168
+ h(
3169
+ 'form',
3170
+ { onSubmit: e => this.submit(e) },
3171
+ h('textarea', { name: 'descriptionInput', placeholder: 'Beskriv ditt \u00E4rende' }),
3172
+ h(
3173
+ 'div',
3174
+ {
3175
+ 'role': 'button',
3176
+ 'aria-label': 'upload image',
3177
+ 'onDragOver': e => this.preventDragOver(e),
3178
+ 'onDrop': e => this.handleImageDrop(e),
3179
+ 'onClick': () => this.handleImageClick(),
3180
+ },
3181
+ h('img', { src: upload, alt: 'hemfixarna_logo', width: 24 }),
3182
+ h('div', null, h('p', null, 'Bifoga ev bilder'), h('span', null, '(dra bilder hit)')),
3183
+ h('input', { onChange: e => this.handleFileInputChange(e), class: 'hemfixarna-file-upload', accept: 'image/*', type: 'file', multiple: true, name: 'fileInput' }),
3184
+ ),
3185
+ h(
3186
+ 'div',
3187
+ { class: 'invoice-preview' },
3188
+ this.displayImages.map((img, i) =>
3189
+ h(
3190
+ 'div',
3191
+ { key: i },
3192
+ h('img', { src: img, alt: 'uploaded image' }),
3193
+ h('button', { onClick: () => this.removeImage(i) }, h('img', { src: getAssetPath(`./assets/close.svg`), alt: 'close' })),
3194
+ ),
3195
+ ),
3196
+ ),
3197
+ h('input', { placeholder: 'E-post', type: 'email', name: 'emailInput' }),
3198
+ h('input', { placeholder: 'Telefonnummer', type: 'tel', name: 'telInput' }),
3199
+ state.selectedProduct.terms_show_checkbox ? h('label', null, h('input', { type: 'checkbox', name: 'termsInput' }), state.selectedProduct.terms) : null,
3200
+ this.formError ? h('span', null, this.formError) : null,
3201
+ h('input', { type: 'submit', value: this.formState === 'loading' ? 'Skickar' : 'Kontakta mig' }),
3202
+ ),
3203
+ );
3204
+ }
3205
+ get el() {
3206
+ return getElement(this);
3207
+ }
3208
+ };
3209
+ HemfixarnaInvoice.style = hemfixarnaInvoiceCss;
3210
+
3211
+ const MyComponent$b = class {
3212
+ constructor(hostRef) {
3213
+ registerInstance(this, hostRef);
3214
+ this.id = undefined;
3215
+ this.loadFromQuery = 'true';
3216
+ this.widgetStyle = WidgetStyle.standard;
3217
+ this.buttonColor = undefined;
3218
+ this.buttonBg = undefined;
3219
+ this.isDemo = false;
3220
+ }
3221
+ render() {
3222
+ return h('hemfixarna-component', {
3223
+ widgetStyle: this.widgetStyle,
3224
+ buttonBg: this.buttonBg,
3225
+ buttonColor: this.buttonColor,
3226
+ nav: { url: 'https://k-bygg.se', logo: 'assets/kbygg.svg', backgroundColor: '#651d32' },
3227
+ loadFromQuery: Boolean(this.loadFromQuery),
3228
+ id: this.id,
3229
+ business: Business.kbygg,
3230
+ isDemo: this.isDemo,
3231
+ });
3232
+ }
3233
+ };
3234
+
3235
+ const MyComponent$a = class {
3236
+ constructor(hostRef) {
3237
+ registerInstance(this, hostRef);
3238
+ this.id = undefined;
3239
+ this.loadFromQuery = undefined;
3240
+ this.widgetStyle = WidgetStyle.standard;
3241
+ this.buttonColor = undefined;
3242
+ this.buttonBg = undefined;
3243
+ }
3244
+ render() {
3245
+ return h('hemfixarna-component', {
3246
+ widgetStyle: this.widgetStyle,
3247
+ buttonBg: this.buttonBg,
3248
+ buttonColor: this.buttonColor,
3249
+ loadFromQuery: Boolean(this.loadFromQuery),
3250
+ id: this.id,
3251
+ business: Business.klint,
3252
+ });
3253
+ }
3254
+ };
3255
+
3256
+ const MyComponent$9 = class {
3257
+ constructor(hostRef) {
3258
+ registerInstance(this, hostRef);
3259
+ this.id = undefined;
3260
+ this.loadFromQuery = undefined;
3261
+ this.widgetStyle = WidgetStyle.standard;
3262
+ this.buttonColor = undefined;
3263
+ this.buttonBg = undefined;
3264
+ }
3265
+ render() {
3266
+ return h('hemfixarna-component', {
3267
+ widgetStyle: this.widgetStyle,
3268
+ buttonBg: this.buttonBg,
3269
+ buttonColor: this.buttonColor,
3270
+ loadFromQuery: Boolean(this.loadFromQuery),
3271
+ id: this.id,
3272
+ business: Business.kund,
3273
+ });
3274
+ }
3275
+ };
3276
+
3277
+ const MyComponent$8 = class {
3278
+ constructor(hostRef) {
3279
+ registerInstance(this, hostRef);
3280
+ this.id = undefined;
3281
+ this.loadFromQuery = 'true';
3282
+ this.widgetStyle = WidgetStyle.standard;
3283
+ this.buttonColor = undefined;
3284
+ this.buttonBg = undefined;
3285
+ this.isDemo = false;
3286
+ }
3287
+ render() {
3288
+ return h('hemfixarna-component', {
3289
+ widgetStyle: this.widgetStyle,
3290
+ buttonBg: this.buttonBg,
3291
+ buttonColor: this.buttonColor,
3292
+ nav: { url: 'https://norrgavel.se', logo: 'assets/norrgavel.svg' },
3293
+ loadFromQuery: Boolean(this.loadFromQuery),
3294
+ id: this.id,
3295
+ business: Business.norrgavel,
3296
+ isDemo: this.isDemo,
3297
+ });
3298
+ }
3299
+ };
3300
+
3301
+ const HemfixarnaOrder = class {
3302
+ constructor(hostRef) {
3303
+ registerInstance(this, hostRef);
3304
+ this.render = () => {
3305
+ return h(
3306
+ 'div',
3307
+ { style: { background: `url(${state.options.thank_you_image})` }, class: 'hemfixarna_order' },
3308
+ h('div', null),
3309
+ h(
3310
+ 'div',
3311
+ null,
3312
+ h('h2', null, state.checkoutInvoice ? 'Tack för din förfrågan' : 'Tack för din bokning'),
3313
+ state.checkoutInvoice ? h('p', null, 'Vi \u00E5terkommer inom kort till dig p\u00E5 angivet telefonnummer eller epost') : null,
3314
+ state.checkoutInvoice ? h('div', null) : h('hemfixarna-orderrows', { tree: this.tree, cart: false }),
3315
+ h('span', { onClick: () => this.resetShop() }, h('button', null, 'G\u00F6r en ny bokning')),
3316
+ h('hemfixarna-info', null),
3317
+ ),
3318
+ );
3319
+ };
3320
+ this.tree = undefined;
3321
+ }
3322
+ resetShop() {
3323
+ state.step = 1;
3324
+ state.cart = [];
3325
+ state.selectedCategory = null;
3326
+ state.selectedService = null;
3327
+ state.selectedProduct = null;
3328
+ state.maleri = null;
3329
+ state.checkoutStep = 1;
3330
+ }
3331
+ disconnectedCallback() {
3332
+ this.resetShop();
3333
+ }
3334
+ };
3335
+
3336
+ const HemfixarnaOrderrows = class {
3337
+ constructor(hostRef) {
3338
+ registerInstance(this, hostRef);
3339
+ this.cart = true;
3340
+ this.tree = undefined;
3341
+ }
3342
+ goToProduct(id) {
3343
+ if (state.customer) {
3344
+ const products = state.customer.categories
3345
+ .map(c => (c.show_products ? c.products : c.sub_categories ? c.sub_categories.map(c => c.products) : []))
3346
+ .flat()
3347
+ .flat();
3348
+ const product = products.find(p => p && p.fields.ID === id);
3349
+ if (product) {
3350
+ state.selectedProduct = product.fields;
3351
+ state.step = 4;
3352
+ }
3353
+ } else {
3354
+ const services = this.tree.sub_cats.map(c => c.services).flat();
3355
+ const products = services.map(s => s.products).flat();
3356
+ const product = products.find(p => p.ID === id);
3357
+ const service = services.find(s => s.products.find(p => p.ID === id));
3358
+ const category = this.tree.sub_cats.find(c => c.services.find(s => s.products.find(p => p.ID === id)));
3359
+ state.selectedCategory = category;
3360
+ state.selectedService = service;
3361
+ state.selectedProduct = product;
3362
+ state.step = 4;
3363
+ }
3364
+ }
3365
+ openRot() {
3366
+ state.modal = {
3367
+ title: state.rotOptions.rot_start_fee_heading,
3368
+ text: [state.rotOptions.rot_start_fee_text, state.rotOptions.rot_start_fee_text_secondary],
3369
+ };
3370
+ }
3371
+ openRut() {
3372
+ state.modal = {
3373
+ title: state.rutOptions.rut_start_fee_heading,
3374
+ text: [state.rutOptions.rut_start_fee_text, state.rutOptions.rut_start_fee_text_secondary],
3375
+ };
3376
+ }
3377
+ openGreen() {
3378
+ state.modal = {
3379
+ title: state.greenOptions.green_start_fee_heading,
3380
+ text: [state.greenOptions.green_start_fee_text, state.greenOptions.green_start_fee_text_secondary],
3381
+ };
3382
+ }
3383
+ getDiscountedInfo(item) {
3384
+ if (item.rut && state.rut) {
3385
+ return ' (efter RUT-avdrag)';
3386
+ } else if (item.rot && state.rot) {
3387
+ return ' (efter ROT-avdrag)';
3388
+ } else if (item.green && state.green) {
3389
+ return ' (efter Grön teknik avdrag)';
3390
+ } else {
3391
+ return '';
3392
+ }
3393
+ }
3394
+ render() {
3395
+ const info = getAssetPath(`./assets/info.svg`);
3396
+ return h(
3397
+ Fragment,
3398
+ null,
3399
+ h(
3400
+ 'ul',
3401
+ { class: 'hemfixarna_cart--items' },
3402
+ state.cart.map(item => {
3403
+ var _a;
3404
+ return h(
3405
+ 'li',
3406
+ { class: 'hemfixarna_cart--item' },
3407
+ h(
3408
+ 'div',
3409
+ null,
3410
+ h(
3411
+ 'div',
3412
+ null,
3413
+ item.icon && h('img', { width: 30, src: (_a = item.icon.url) !== null && _a !== void 0 ? _a : item.icon, alt: item.name }),
3414
+ h('p', null, h('strong', null, item.amount, 'x '), item.name),
3415
+ ),
3416
+ this.cart && h('button', { onClick: () => this.goToProduct(item.id) }, '\u00C4ndra'),
3417
+ ),
3418
+ h('p', null, h('strong', null, getProductPrice(item, item.price, item.amount), 'kr'), h('span', null, this.getDiscountedInfo(item))),
3419
+ item.parts.length > 0 &&
3420
+ h(
3421
+ 'ul',
3422
+ null,
3423
+ item.parts.map(part =>
3424
+ h('li', null, h('p', null, h('strong', null, part.amount, 'x '), part.name), h('p', null, h('strong', null, getPartPrice(part, item, part.amount), 'kr'))),
3425
+ ),
3426
+ ),
3427
+ );
3428
+ }),
3429
+ ),
3430
+ h(
3431
+ 'div',
3432
+ { class: 'hemfixarna_cart--additional' },
3433
+ h(
3434
+ 'div',
3435
+ null,
3436
+ getStartFee().rot > 0 &&
3437
+ h(
3438
+ 'div',
3439
+ { class: 'hemfixarna_cart--startfee' },
3440
+ h(
3441
+ 'p',
3442
+ null,
3443
+ h('strong', { onClick: () => this.openRot() }, state.rotOptions.rot_start_fee_heading, h('img', { height: 16, src: info, alt: 'info monteringsavgift' })),
3444
+ ),
3445
+ h('p', null, getStartFee().rot, 'kr'),
3446
+ ),
3447
+ getStartFee().rut > 0 &&
3448
+ h(
3449
+ 'div',
3450
+ { class: 'hemfixarna_cart--startfee' },
3451
+ h(
3452
+ 'p',
3453
+ null,
3454
+ h('strong', { onClick: () => this.openRut() }, state.rutOptions.rut_start_fee_heading, h('img', { height: 16, src: info, alt: 'info monteringsavgift' })),
3455
+ ),
3456
+ h('p', null, getStartFee().rut, 'kr'),
3457
+ ),
3458
+ getStartFee().green > 0 &&
3459
+ h(
3460
+ 'div',
3461
+ { class: 'hemfixarna_cart--startfee' },
3462
+ h(
3463
+ 'p',
3464
+ null,
3465
+ h('strong', { onClick: () => this.openGreen() }, state.greenOptions.green_start_fee_heading, h('img', { height: 16, src: info, alt: 'info monteringsavgift' })),
3466
+ ),
3467
+ h('p', null, getStartFee().green, 'kr'),
3468
+ ),
3469
+ ),
3470
+ state.cart.find(item => item.rot) &&
3471
+ h(
3472
+ 'div',
3473
+ { class: 'hemfixarna_cart--rutrot' },
3474
+ h(
3475
+ 'div',
3476
+ null,
3477
+ this.cart &&
3478
+ h('label', { class: 'switch' }, h('input', { checked: state.rot, onChange: () => (state.rot = !state.rot), type: 'checkbox' }), h('span', { class: 'slider' })),
3479
+ h('p', null, 'ROT-avdrag'),
3480
+ ),
3481
+ h('p', null, '(-', state.rot ? calculateRot() : 0, 'kr)'),
3482
+ ),
3483
+ state.cart.find(item => item.rut) &&
3484
+ h(
3485
+ 'div',
3486
+ { class: 'hemfixarna_cart--rutrot' },
3487
+ h(
3488
+ 'div',
3489
+ null,
3490
+ h('label', { class: 'switch' }, h('input', { onChange: () => (state.rut = !state.rut), checked: state.rut, type: 'checkbox' }), h('span', { class: 'slider' })),
3491
+ h('p', null, 'RUT-avdrag'),
3492
+ ),
3493
+ h('p', null, '(-', state.rut ? calculateRut() : 0, 'kr)'),
3494
+ ),
3495
+ state.cart.find(item => item.green) &&
3496
+ h(
3497
+ 'div',
3498
+ { class: 'hemfixarna_cart--rutrot' },
3499
+ h(
3500
+ 'div',
3501
+ null,
3502
+ h('label', { class: 'switch' }, h('input', { onChange: () => (state.green = !state.green), checked: state.green, type: 'checkbox' }), h('span', { class: 'slider' })),
3503
+ h('p', null, 'Gr\u00F6n teknik avdrag'),
3504
+ ),
3505
+ h('p', null, '(-', state.green ? calculateGreenDiscount() : 0, 'kr)'),
3506
+ ),
3507
+ ),
3508
+ h('div', { class: 'hemfixarna_cart--price' }, h('h2', null, 'Totalbelopp: '), h('h2', null, getTotalPrice(), 'kr')),
3509
+ );
3510
+ }
3511
+ };
3512
+
3513
+ const MyComponent$7 = class {
3514
+ constructor(hostRef) {
3515
+ registerInstance(this, hostRef);
3516
+ this.id = undefined;
3517
+ this.customer = undefined;
3518
+ this.loadFromQuery = undefined;
3519
+ this.widgetStyle = WidgetStyle.standard;
3520
+ this.buttonColor = undefined;
3521
+ this.buttonBg = undefined;
3522
+ }
3523
+ render() {
3524
+ return h('hemfixarna-component', {
3525
+ widgetStyle: this.widgetStyle,
3526
+ buttonBg: this.buttonBg,
3527
+ buttonColor: this.buttonColor,
3528
+ loadFromQuery: Boolean(this.loadFromQuery),
3529
+ id: this.id,
3530
+ business: Business.power,
3531
+ });
3532
+ }
3533
+ };
3534
+
3535
+ const hemfixarnaProductCss = '';
3536
+
3537
+ const HemfixarnaProduct = class {
3538
+ constructor(hostRef) {
3539
+ registerInstance(this, hostRef);
3540
+ this.amount = 0;
3541
+ this.hideDescription = true;
3542
+ }
3543
+ addProduct() {
3544
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
3545
+ if (productInCart) {
3546
+ productInCart.amount++;
3547
+ state.cart = [...state.cart];
3548
+ } else {
3549
+ state.cart = [
3550
+ ...state.cart,
3551
+ {
3552
+ id: state.selectedProduct.ID,
3553
+ rut: state.selectedProduct.rut,
3554
+ rot: state.selectedProduct.rot,
3555
+ green: state.selectedProduct.green,
3556
+ amount: 1,
3557
+ parts: [],
3558
+ price: state.selectedProduct.price,
3559
+ name: state.selectedProduct.title,
3560
+ start_fee: !state.selectedProduct.hide_start_fee,
3561
+ terms_checkout: state.selectedProduct.terms_checkout,
3562
+ icon: state.selectedProduct.icon,
3563
+ },
3564
+ ];
3565
+ }
3566
+ }
3567
+ removeProduct() {
3568
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
3569
+ if (productInCart && productInCart.amount > 1) {
3570
+ productInCart.amount--;
3571
+ state.cart = [...state.cart];
3572
+ } else {
3573
+ state.cart = state.cart.filter(p => p.id !== state.selectedProduct.ID);
3574
+ }
3575
+ }
3576
+ //Handle cart and parts
3577
+ addPart(part) {
3578
+ var _a;
3579
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
3580
+ if (productInCart) {
3581
+ const partInCart = productInCart.parts.find(sp => sp.id === part.ID);
3582
+ if (partInCart) {
3583
+ partInCart.amount++;
3584
+ productInCart.parts = [...productInCart.parts];
3585
+ } else {
3586
+ productInCart.parts = [...productInCart.parts, { id: part.ID, amount: 1, price: part.price, name: (_a = part.title) !== null && _a !== void 0 ? _a : part.title }];
3587
+ }
3588
+ state.cart = [...state.cart.filter(p => p.id !== productInCart.id), productInCart];
3589
+ }
3590
+ }
3591
+ removePart(part) {
3592
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
3593
+ if (productInCart) {
3594
+ const partInCart = productInCart.parts.find(sp => sp.id === part.ID);
3595
+ if (partInCart && partInCart.amount > 1) {
3596
+ partInCart.amount--;
3597
+ productInCart.parts = [...productInCart.parts];
3598
+ } else {
3599
+ productInCart.parts = productInCart.parts.filter(sp => sp.id !== part.ID);
3600
+ }
3601
+ state.cart = [...state.cart.filter(p => p.id !== productInCart.id), productInCart];
3602
+ }
3603
+ }
3604
+ goToCart() {
3605
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
3606
+ if (productInCart) {
3607
+ state.step = 5;
3608
+ const el = this.el.closest('.hemfixarna_content');
3609
+ scrollToTop(el);
3610
+ }
3611
+ }
3612
+ getAmount() {
3613
+ var _a;
3614
+ return ((_a = state.cart.find(p => p.id === state.selectedProduct.ID)) === null || _a === void 0 ? void 0 : _a.amount) || 0;
3615
+ }
3616
+ getPartAmount(partId) {
3617
+ var _a;
3618
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
3619
+ return (
3620
+ ((_a = productInCart === null || productInCart === void 0 ? void 0 : productInCart.parts.find(sp => sp.id === partId)) === null || _a === void 0 ? void 0 : _a.amount) || 0
3621
+ );
3622
+ }
3623
+ getTotalPrice() {
3624
+ let price = 0;
3625
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
3626
+ if (productInCart) {
3627
+ const partsPrice = productInCart.parts.reduce((acc, curr) => {
3628
+ const part = state.selectedProduct.parts.find(p => p.ID === curr.id);
3629
+ if (part) {
3630
+ return acc + part.price * curr.amount;
3631
+ }
3632
+ return acc;
3633
+ }, 0);
3634
+ price = state.selectedProduct.price * productInCart.amount + partsPrice;
3635
+ } else {
3636
+ price = state.selectedProduct.price;
3637
+ }
3638
+ return getProductPrice(state.selectedProduct, price);
3639
+ }
3640
+ componentDidRender() {
3641
+ const linkElem = document.createElement('link');
3642
+ linkElem.setAttribute('rel', 'stylesheet');
3643
+ linkElem.setAttribute('href', 'https://painting-frontend.vercel.app/static/css/main.css');
3644
+ const fonts = document.createElement('link');
3645
+ fonts.setAttribute('rel', 'stylesheet');
3646
+ fonts.setAttribute('href', 'https://painting-frontend.vercel.app/fonts.css');
3647
+ const checkAndInjectCSS = () => {
3648
+ const parents = this.el.getElementsByTagName('hemfixare-calculator');
3649
+ if (parents.length > 0 && parents[0].shadowRoot !== null) {
3650
+ parents[0].shadowRoot.appendChild(linkElem);
3651
+ parents[0].shadowRoot.appendChild(fonts);
3652
+ } else {
3653
+ setTimeout(checkAndInjectCSS, 1);
3654
+ }
3655
+ };
3656
+ checkAndInjectCSS();
3657
+ }
3658
+ render() {
3659
+ var _a, _b, _c;
3660
+ const checked = getAssetPath(`./assets/checked.svg`);
3661
+ const plus = getAssetPath(`./assets/plus.svg`);
3662
+ const minus = getAssetPath(`./assets/minus.svg`);
3663
+ if (state.maleri) {
3664
+ return h(
3665
+ 'div',
3666
+ { class: 'hemfixarna_painting' },
3667
+ h('script', {
3668
+ type: 'text/javascript',
3669
+ src: ['localhost', 'vercel'].some(v => window.location.href.includes(v))
3670
+ ? 'https://painting-dev.vercel.app/static/js/main.js'
3671
+ : 'https://painting-frontend.vercel.app/static/js/main.js',
3672
+ defer: true,
3673
+ async: true,
3674
+ }),
3675
+ h('hemfixare-calculator', {
3676
+ title: state.options.maleri_title,
3677
+ subtitle: state.options.maleri_text,
3678
+ modal: 'true',
3679
+ customer: state.business === Business.string ? 'string' : state.business,
3680
+ }),
3681
+ );
3682
+ }
3683
+ return state.selectedProduct
3684
+ ? h(
3685
+ 'div',
3686
+ { class: 'hemfixarna_product' },
3687
+ h(
3688
+ 'div',
3689
+ { class: 'hemfixarna_product--top' },
3690
+ state.selectedProduct.icon &&
3691
+ h('img', { width: 80, src: (_a = state.selectedProduct.icon.url) !== null && _a !== void 0 ? _a : state.selectedProduct.icon, alt: state.selectedProduct.title }),
3692
+ h(
3693
+ 'div',
3694
+ null,
3695
+ h('h1', null, state.selectedProduct.title),
3696
+ !state.selectedProduct.invoice ? h('h2', null, getProductPrice(state.selectedProduct), ' kr/st') : h('h2', null, state.selectedProduct.invoice_price),
3697
+ ),
3698
+ ),
3699
+ h(
3700
+ 'div',
3701
+ { class: 'hemfixarna_product--grid' },
3702
+ h(
3703
+ 'div',
3704
+ { class: 'hemfixarna_product--left' },
3705
+ ((_b = state.selectedProduct.list) === null || _b === void 0 ? void 0 : _b.length) &&
3706
+ h(
3707
+ 'ul',
3708
+ { class: 'hemfixarna_features' },
3709
+ state.selectedProduct.list.map(l => h('li', { key: l.bullet }, h('img', { src: checked, alt: 'checked' }), h('p', null, l.bullet))),
3710
+ ),
3711
+ state.selectedProduct.description &&
3712
+ h('p', {
3713
+ onClick: () => (this.hideDescription = false),
3714
+ class: `hemfixarna_description ${this.hideDescription ? 'hemfixarna_description--hidden' : ''}`,
3715
+ innerHTML: state.selectedProduct.description,
3716
+ }),
3717
+ ),
3718
+ h(
3719
+ 'div',
3720
+ { class: 'hemfixarna_product--right' },
3721
+ state.selectedProduct.invoice
3722
+ ? h('hemfixarna-invoice', null)
3723
+ : h(
3724
+ Fragment,
3725
+ null,
3726
+ h(
3727
+ 'ul',
3728
+ null,
3729
+ h(
3730
+ 'li',
3731
+ { class: 'hemfixarna_product--item' },
3732
+ h('div', null, h('p', null, state.selectedProduct.title), h('p', { class: 'hemfixarna_product--price' }, getProductPrice(state.selectedProduct), 'kr/st')),
3733
+ h(
3734
+ 'div',
3735
+ { class: 'hemfixarna_counter' },
3736
+ h('img', { class: `${this.getAmount() === 0 ? 'disabled' : ''}`, src: minus, onClick: () => this.removeProduct() }),
3737
+ h('span', null, this.getAmount()),
3738
+ h('img', { src: plus, onClick: () => this.addProduct() }),
3739
+ ),
3740
+ ),
3741
+ ((_c = state.selectedProduct.parts) === null || _c === void 0 ? void 0 : _c.length) &&
3742
+ state.selectedProduct.parts.map(p => {
3743
+ var _a;
3744
+ return h(
3745
+ 'li',
3746
+ { class: 'hemfixarna_part' },
3747
+ h(
3748
+ 'div',
3749
+ null,
3750
+ h('p', null, (_a = p.title) !== null && _a !== void 0 ? _a : p.title),
3751
+ h('p', { class: 'hemfixarna_product--price' }, getPartPrice(p, state.selectedProduct), 'kr/st'),
3752
+ ),
3753
+ h(
3754
+ 'div',
3755
+ { class: 'hemfixarna_counter' },
3756
+ h('img', { class: `${this.getPartAmount(p.ID) === 0 ? 'disabled' : ''}`, src: minus, onClick: () => this.removePart(p) }),
3757
+ h('span', null, this.getPartAmount(p.ID)),
3758
+ h('img', { class: `${this.getAmount() === 0 ? 'disabled' : ''}`, src: plus, onClick: () => this.addPart(p) }),
3759
+ ),
3760
+ );
3761
+ }),
3762
+ ),
3763
+ h('h4', { class: 'hemfixarna_product--total' }, 'Totalt ', this.getTotalPrice(), ' kr'),
3764
+ h('button', { onClick: () => this.goToCart(), class: `hemfixarna_buy ${this.getAmount() === 0 ? 'disabled' : ''}` }, 'Forts\u00E4tt'),
3765
+ ),
3766
+ !state.selectedProduct.hide_start_fee &&
3767
+ (state.selectedProduct.rot || state.selectedProduct.rut) &&
3768
+ state.rutOptions &&
3769
+ state.rotOptions &&
3770
+ h(
3771
+ 'p',
3772
+ { class: 'hemfixarna_terms' },
3773
+ h('strong', null, state.selectedProduct.rot ? state.rotOptions.rot_start_fee_heading : state.rutOptions.rut_start_fee_heading),
3774
+ h('br', null),
3775
+ h('span', { innerHTML: state.selectedProduct.rot ? state.rotOptions.rot_start_fee_text : state.rutOptions.rut_start_fee_text }),
3776
+ ),
3777
+ state.options && h('hemfixarna-info', null),
3778
+ ),
3779
+ ),
3780
+ )
3781
+ : null;
3782
+ }
3783
+ get el() {
3784
+ return getElement(this);
3785
+ }
3786
+ };
3787
+ HemfixarnaProduct.style = hemfixarnaProductCss;
3788
+
3789
+ const HemfixarnaService = class {
3790
+ constructor(hostRef) {
3791
+ registerInstance(this, hostRef);
3792
+ }
3793
+ render() {
3794
+ return h(
3795
+ 'div',
3796
+ null,
3797
+ h('h2', null, state.selectedService.post_title),
3798
+ h(
3799
+ 'div',
3800
+ { class: 'hemfixarna_categories--wrapper' },
3801
+ h(
3802
+ 'div',
3803
+ null,
3804
+ h(
3805
+ 'ul',
3806
+ { class: 'hemfixarna_categories' },
3807
+ state.selectedService.products
3808
+ .sort((a, b) => (a.post_title < b.post_title ? -1 : 1))
3809
+ .map(p => {
3810
+ var _a;
3811
+ return h('hemfixarna-box', { post: p, icon: (_a = p.icon.url) !== null && _a !== void 0 ? _a : p.icon, postTitle: p.title });
3812
+ }),
3813
+ ),
3814
+ ),
3815
+ h('hemfixarna-info', null),
3816
+ ),
3817
+ );
3818
+ }
3819
+ };
3820
+
3821
+ const hemfixarnaSkanskaCss = '';
3822
+
3823
+ const MyComponent$6 = class {
3824
+ constructor(hostRef) {
3825
+ registerInstance(this, hostRef);
3826
+ this.id = undefined;
3827
+ this.customer = undefined;
3828
+ this.loadFromQuery = undefined;
3829
+ this.widgetStyle = WidgetStyle.standard;
3830
+ this.buttonColor = undefined;
3831
+ this.buttonBg = undefined;
3832
+ }
3833
+ render() {
3834
+ return h('hemfixarna-component', {
3835
+ widgetStyle: this.widgetStyle,
3836
+ buttonBg: this.buttonBg,
3837
+ buttonColor: this.buttonColor,
3838
+ loadFromQuery: Boolean(this.loadFromQuery),
3839
+ id: this.id,
3840
+ business: Business.skanska,
3841
+ });
3842
+ }
3843
+ };
3844
+ MyComponent$6.style = hemfixarnaSkanskaCss;
3845
+
3846
+ const MyComponent$5 = class {
3847
+ constructor(hostRef) {
3848
+ registerInstance(this, hostRef);
3849
+ this.id = undefined;
3850
+ this.customer = undefined;
3851
+ this.loadFromQuery = undefined;
3852
+ this.widgetStyle = WidgetStyle.standard;
3853
+ this.buttonColor = undefined;
3854
+ this.buttonBg = undefined;
3855
+ }
3856
+ render() {
3857
+ return h('hemfixarna-component', {
3858
+ widgetStyle: this.widgetStyle,
3859
+ buttonBg: this.buttonBg,
3860
+ buttonColor: this.buttonColor,
3861
+ loadFromQuery: Boolean(this.loadFromQuery),
3862
+ id: this.id,
3863
+ business: Business.sparfonster,
3864
+ });
3865
+ }
3866
+ };
3867
+
3868
+ const HemfixarnaGrid = class {
3869
+ constructor(hostRef) {
3870
+ registerInstance(this, hostRef);
3871
+ this.tree = undefined;
3872
+ this.slug = undefined;
3873
+ }
3874
+ isMainCategory(category) {
3875
+ return category.show_products !== undefined;
3876
+ }
3877
+ handleMaleriClick() {
3878
+ state.step = 4;
3879
+ state.maleri = true;
3880
+ }
3881
+ render() {
3882
+ var _a;
3883
+ const maleriLogo = getAssetPath('./assets/gubbe-pensel.svg');
3884
+ return state.customer
3885
+ ? h(
3886
+ 'div',
3887
+ null,
3888
+ h('h2', null, state.selectedCustomerCategory ? state.selectedCustomerCategory.name : 'Alla tjänster'),
3889
+ h(
3890
+ 'div',
3891
+ { class: 'hemfixarna_categories--wrapper' },
3892
+ h(
3893
+ 'ul',
3894
+ { class: 'hemfixarna_categories' },
3895
+ ((_a = state.selectedCustomerCategory) === null || _a === void 0 ? void 0 : _a.add_painting)
3896
+ ? h(
3897
+ 'button',
3898
+ { onClick: () => this.handleMaleriClick(), class: 'hemfixarna_maleribox' },
3899
+ h('img', { height: 64, src: maleriLogo, alt: 'M\u00E5leri Logotyp' }),
3900
+ h('p', null, 'Ber\u00E4kna fast pris p\u00E5 m\u00E5leri & tapetsering h\u00E4r'),
3901
+ )
3902
+ : null,
3903
+ state.selectedCustomerCategory
3904
+ ? this.isMainCategory(state.selectedCustomerCategory) && state.selectedCustomerCategory.sub_categories && !state.selectedCustomerCategory.show_products
3905
+ ? state.selectedCustomerCategory.sub_categories.map(c => h('hemfixarna-box', { category: c }))
3906
+ : state.selectedCustomerCategory.products
3907
+ ? state.selectedCustomerCategory.products.map(c => h('hemfixarna-box', { category: c.fields }))
3908
+ : null
3909
+ : state.customer.categories.map(c => h('hemfixarna-box', { category: c })),
3910
+ ),
3911
+ h('hemfixarna-info', null),
3912
+ ),
3913
+ )
3914
+ : h(
3915
+ 'div',
3916
+ null,
3917
+ h('h2', null, 'Alla tj\u00E4nster'),
3918
+ h(
3919
+ 'div',
3920
+ { class: 'hemfixarna_categories--wrapper' },
3921
+ h(
3922
+ 'ul',
3923
+ { class: 'hemfixarna_categories' },
3924
+ this.tree.sub_cats
3925
+ .sort((a, b) => (a.name < b.name ? -1 : 1))
3926
+ .map(c => {
3927
+ var _a;
3928
+ return h('hemfixarna-box', { post: c, icon: (_a = c.icon.url) !== null && _a !== void 0 ? _a : c.icon, postTitle: c.name });
3929
+ }),
3930
+ ),
3931
+ h('hemfixarna-info', null),
3932
+ ),
3933
+ );
3934
+ }
3935
+ };
3936
+
3937
+ const hemfixarnaStringCss = '';
3938
+
3939
+ const MyComponent$4 = class {
3940
+ constructor(hostRef) {
3941
+ registerInstance(this, hostRef);
3942
+ this.id = undefined;
3943
+ this.loadFromQuery = undefined;
3944
+ this.widgetStyle = WidgetStyle.standard;
3945
+ this.buttonColor = undefined;
3946
+ this.buttonBg = undefined;
3947
+ }
3948
+ render() {
3949
+ return h('hemfixarna-component', {
3950
+ widgetStyle: this.widgetStyle,
3951
+ buttonBg: this.buttonBg,
3952
+ buttonColor: this.buttonColor,
3953
+ loadFromQuery: Boolean(this.loadFromQuery),
3954
+ id: this.id,
3955
+ business: Business.string,
3956
+ });
3957
+ }
3958
+ };
3959
+ MyComponent$4.style = hemfixarnaStringCss;
3960
+
3961
+ const MyComponent$3 = class {
3962
+ constructor(hostRef) {
3963
+ registerInstance(this, hostRef);
3964
+ this.id = undefined;
3965
+ this.loadFromQuery = undefined;
3966
+ this.widgetStyle = WidgetStyle.standard;
3967
+ this.buttonColor = undefined;
3968
+ this.buttonBg = undefined;
3969
+ }
3970
+ render() {
3971
+ return h('hemfixarna-component', {
3972
+ widgetStyle: this.widgetStyle,
3973
+ buttonBg: this.buttonBg,
3974
+ buttonColor: this.buttonColor,
3975
+ loadFromQuery: Boolean(this.loadFromQuery),
3976
+ id: this.id,
3977
+ business: Business.superfront,
3978
+ });
3979
+ }
3980
+ };
3981
+
3982
+ const MyComponent$2 = class {
3983
+ constructor(hostRef) {
3984
+ registerInstance(this, hostRef);
3985
+ this.id = undefined;
3986
+ this.loadFromQuery = 'true';
3987
+ this.isDemo = false;
3988
+ this.widgetStyle = WidgetStyle.standard;
3989
+ this.buttonColor = undefined;
3990
+ this.buttonBg = undefined;
3991
+ }
3992
+ render() {
3993
+ return h('hemfixarna-component', {
3994
+ widgetStyle: this.widgetStyle,
3995
+ buttonBg: this.buttonBg,
3996
+ buttonColor: this.buttonColor,
3997
+ nav: { url: 'https://www.tesla.com/sv_se/home-charging', logo: 'assets/tesla.svg' },
3998
+ isDemo: this.isDemo,
3999
+ loadFromQuery: Boolean(this.loadFromQuery),
4000
+ id: this.id,
4001
+ business: Business.tesla,
4002
+ });
4003
+ }
4004
+ };
4005
+
4006
+ const MyComponent$1 = class {
4007
+ constructor(hostRef) {
4008
+ registerInstance(this, hostRef);
4009
+ this.id = undefined;
4010
+ this.loadFromQuery = undefined;
4011
+ this.widgetStyle = WidgetStyle.standard;
4012
+ this.buttonColor = undefined;
4013
+ this.buttonBg = undefined;
4014
+ }
4015
+ render() {
4016
+ return h('hemfixarna-component', {
4017
+ widgetStyle: this.widgetStyle,
4018
+ buttonBg: this.buttonBg,
4019
+ buttonColor: this.buttonColor,
4020
+ loadFromQuery: Boolean(this.loadFromQuery),
4021
+ id: this.id,
4022
+ business: Business.traningspartner,
4023
+ });
4024
+ }
4025
+ };
4026
+
4027
+ const MyComponent = class {
4028
+ constructor(hostRef) {
4029
+ registerInstance(this, hostRef);
4030
+ this.id = undefined;
4031
+ this.loadFromQuery = 'true';
4032
+ this.isDemo = false;
4033
+ this.widgetStyle = WidgetStyle.standard;
4034
+ this.buttonColor = undefined;
4035
+ this.buttonBg = undefined;
4036
+ }
4037
+ render() {
4038
+ return h('hemfixarna-component', {
4039
+ widgetStyle: this.widgetStyle,
4040
+ buttonBg: this.buttonBg,
4041
+ buttonColor: this.buttonColor,
4042
+ nav: { url: 'https://www.zaptec.com/sv/laddningslosningar/zaptec-go', logo: 'assets/zaptec.svg' },
4043
+ isDemo: this.isDemo,
4044
+ loadFromQuery: Boolean(this.loadFromQuery),
4045
+ id: this.id,
4046
+ business: Business.zaptec,
4047
+ });
4048
+ }
4049
+ };
4050
+
4051
+ export {
4052
+ HemfixarnaAddress as hemfixarna_address,
4053
+ HemfixarnaBox as hemfixarna_box,
4054
+ HemfixarnaBreadcrumbs as hemfixarna_breadcrumbs,
4055
+ MyComponent$j as hemfixarna_byggmax,
4056
+ HemfixarnaCart as hemfixarna_cart,
4057
+ HemfixarnaCategory as hemfixarna_category,
4058
+ HemfixarnaCheckout as hemfixarna_checkout,
4059
+ HemfixarnaComponent as hemfixarna_component,
4060
+ HemfixarnaInfo$1 as hemfixarna_contact,
4061
+ MyComponent$i as hemfixarna_demo,
4062
+ MyComponent$h as hemfixarna_doro,
4063
+ MyComponent$g as hemfixarna_elfa,
4064
+ MyComponent$f as hemfixarna_fargvaruhuset,
4065
+ MyComponent$e as hemfixarna_flyttsmart,
4066
+ MyComponent$d as hemfixarna_forebygg,
4067
+ HemfixarnaGetuser as hemfixarna_getuser,
4068
+ MyComponent$c as hemfixarna_hornbach,
4069
+ HemfixarnaInfo as hemfixarna_info,
4070
+ HemfixarnaInvoice as hemfixarna_invoice,
4071
+ MyComponent$b as hemfixarna_kbygg,
4072
+ MyComponent$a as hemfixarna_klint,
4073
+ MyComponent$9 as hemfixarna_kund,
4074
+ MyComponent$8 as hemfixarna_norrgavel,
4075
+ HemfixarnaOrder as hemfixarna_order,
4076
+ HemfixarnaOrderrows as hemfixarna_orderrows,
4077
+ MyComponent$7 as hemfixarna_power,
4078
+ HemfixarnaProduct as hemfixarna_product,
4079
+ HemfixarnaService as hemfixarna_service,
4080
+ MyComponent$6 as hemfixarna_skanska,
4081
+ MyComponent$5 as hemfixarna_sparfonster,
4082
+ HemfixarnaGrid as hemfixarna_start,
4083
+ MyComponent$4 as hemfixarna_string_furniture,
4084
+ MyComponent$3 as hemfixarna_superfront,
4085
+ MyComponent$2 as hemfixarna_tesla,
4086
+ MyComponent$1 as hemfixarna_traningspartner,
4087
+ MyComponent as hemfixarna_zaptec,
4088
+ };
4089
+
4090
+ //# sourceMappingURL=hemfixarna-address_36.entry.js.map