hemfixarna-web-components 1.6.2 → 1.6.3

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 +2724 -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,2724 @@
1
+ import { g as getRenderingRef, f as forceUpdate, r as registerInstance, h, a as getElement, F as Fragment, c as getAssetPath } 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
+ }
8
+ else if (!items.includes(value)) {
9
+ items.push(value);
10
+ }
11
+ };
12
+ const debounce = (fn, ms) => {
13
+ let timeoutId;
14
+ return (...args) => {
15
+ if (timeoutId) {
16
+ clearTimeout(timeoutId);
17
+ }
18
+ timeoutId = setTimeout(() => {
19
+ timeoutId = 0;
20
+ fn(...args);
21
+ }, ms);
22
+ };
23
+ };
24
+
25
+ /**
26
+ * Check if a possible element isConnected.
27
+ * The property might not be there, so we check for it.
28
+ *
29
+ * We want it to return true if isConnected is not a property,
30
+ * otherwise we would remove these elements and would not update.
31
+ *
32
+ * Better leak in Edge than to be useless.
33
+ */
34
+ const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
35
+ const cleanupElements = debounce((map) => {
36
+ for (let key of map.keys()) {
37
+ map.set(key, map.get(key).filter(isConnected));
38
+ }
39
+ }, 2000);
40
+ const stencilSubscription = () => {
41
+ if (typeof getRenderingRef !== 'function') {
42
+ // If we are not in a stencil project, we do nothing.
43
+ // This function is not really exported by @stencil/core.
44
+ return {};
45
+ }
46
+ const elmsToUpdate = new Map();
47
+ return {
48
+ dispose: () => elmsToUpdate.clear(),
49
+ get: (propName) => {
50
+ const elm = getRenderingRef();
51
+ if (elm) {
52
+ appendToMap(elmsToUpdate, propName, elm);
53
+ }
54
+ },
55
+ set: (propName) => {
56
+ const elements = elmsToUpdate.get(propName);
57
+ if (elements) {
58
+ elmsToUpdate.set(propName, elements.filter(forceUpdate));
59
+ }
60
+ cleanupElements(elmsToUpdate);
61
+ },
62
+ reset: () => {
63
+ elmsToUpdate.forEach((elms) => elms.forEach(forceUpdate));
64
+ cleanupElements(elmsToUpdate);
65
+ },
66
+ };
67
+ };
68
+
69
+ const unwrap = (val) => (typeof val === 'function' ? val() : val);
70
+ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
71
+ const unwrappedState = unwrap(defaultState);
72
+ let states = new Map(Object.entries(unwrappedState !== null && unwrappedState !== void 0 ? unwrappedState : {}));
73
+ const handlers = {
74
+ dispose: [],
75
+ get: [],
76
+ set: [],
77
+ reset: [],
78
+ };
79
+ const reset = () => {
80
+ var _a;
81
+ // When resetting the state, the default state may be a function - unwrap it to invoke it.
82
+ // otherwise, the state won't be properly reset
83
+ states = new Map(Object.entries((_a = unwrap(defaultState)) !== null && _a !== void 0 ? _a : {}));
84
+ handlers.reset.forEach((cb) => cb());
85
+ };
86
+ const dispose = () => {
87
+ // Call first dispose as resetting the state would
88
+ // cause less updates ;)
89
+ handlers.dispose.forEach((cb) => cb());
90
+ reset();
91
+ };
92
+ const get = (propName) => {
93
+ handlers.get.forEach((cb) => cb(propName));
94
+ return states.get(propName);
95
+ };
96
+ const set = (propName, value) => {
97
+ const oldValue = states.get(propName);
98
+ if (shouldUpdate(value, oldValue, propName)) {
99
+ states.set(propName, value);
100
+ handlers.set.forEach((cb) => cb(propName, value, oldValue));
101
+ }
102
+ };
103
+ const state = (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)
232
+ return;
233
+ const categories = [...state.customer.categories, ...state.customer.categories.map(c => { var _a; return (_a = c.sub_categories) !== null && _a !== void 0 ? _a : []; })].flat();
234
+ const category = categories.find(c => c && c.id === product.category);
235
+ if (category) {
236
+ state.parentCategory = category;
237
+ return;
238
+ }
239
+ state.parentCategory = null;
240
+ });
241
+ onChange('selectedCustomerCategory', category => {
242
+ if (!state.customer || !category)
243
+ return;
244
+ if (category.parent) {
245
+ const parent = state.customer.categories.find(c => c.id === category.parent);
246
+ if (parent) {
247
+ state.parentCategory = parent;
248
+ return;
249
+ }
250
+ }
251
+ state.parentCategory = null;
252
+ });
253
+
254
+ const hideField = (field) => {
255
+ return field.split(' ').reduce((acc, curr) => {
256
+ if (curr.length <= 2) {
257
+ return acc + curr.slice(0, 1) + '* ';
258
+ }
259
+ else {
260
+ return acc + curr.slice(0, 1) + '*'.repeat(curr.length - 2) + curr.slice(-1) + ' ';
261
+ }
262
+ }, '');
263
+ };
264
+
265
+ const scrollToTop = (el) => {
266
+ if (!el)
267
+ return;
268
+ el.scrollTo({
269
+ top: 0,
270
+ behavior: 'smooth',
271
+ });
272
+ };
273
+
274
+ const HemfixarnaAddress = class {
275
+ constructor(hostRef) {
276
+ registerInstance(this, hostRef);
277
+ this.handleSubmit = (e) => {
278
+ e.preventDefault();
279
+ const streetValid = this.street.length > 0;
280
+ if (!streetValid) {
281
+ this.streetError = 'Ange en gatuadress';
282
+ }
283
+ const zipValid = this.zip.length > 0;
284
+ const zipIsNumber = /^\s*\d[\d\s]*$/.test(this.zip);
285
+ if (!zipIsNumber) {
286
+ this.zipError = 'Postnummer får endast innehålla siffror';
287
+ }
288
+ if (!zipValid) {
289
+ this.zipError = 'Ange ett postnummer';
290
+ }
291
+ const townValid = /^[^\d\s]{2,}$/.test(this.town);
292
+ if (!townValid) {
293
+ this.townError = 'Ange en ort';
294
+ }
295
+ if (streetValid && zipValid && townValid && zipIsNumber) {
296
+ state.user = Object.assign(Object.assign({}, state.user), { street: this.street, zip: this.zip, town: this.town });
297
+ state.checkoutStep = 2;
298
+ state.checkoutEdit = false;
299
+ const el = this.el.closest('.hemfixarna_content');
300
+ scrollToTop(el);
301
+ }
302
+ };
303
+ this.handleChangeStreet = (e) => {
304
+ this.streetError = null;
305
+ this.street = this.street === state.user.street ? '' : e.target.value;
306
+ };
307
+ this.handleChangeZip = (e) => {
308
+ this.zipError = null;
309
+ this.zip = this.zip === state.user.zip ? '' : e.target.value;
310
+ };
311
+ this.handleChangeTown = (e) => {
312
+ this.townError = null;
313
+ this.town = this.town === state.user.town ? '' : e.target.value;
314
+ };
315
+ this.render = () => {
316
+ return (h("form", { class: "hemfixarna_address", onSubmit: e => this.handleSubmit(e) }, h("div", null, h("input", { class: `${this.street.length ? 'input_active' : ''}`, onInput: this.handleChangeStreet, type: "text", name: "street", value: this.street === state.user.street ? hideField(this.street) : this.street }), h("label", { htmlFor: "street" }, "Gatuaddress ")), this.streetError && h("span", null, this.streetError), h("div", null, h("input", { class: `${this.zip.length ? 'input_active' : ''}`, onInput: this.handleChangeZip, type: "tel", name: "zip", value: this.zip === state.user.zip ? hideField(this.zip) : this.zip }), h("label", { htmlFor: "zip" }, "Postnummer ")), this.zipError && h("span", null, this.zipError), h("div", null, h("input", { class: `${this.town.length ? 'input_active' : ''}`, onInput: this.handleChangeTown, type: "text", name: "town", value: this.town === state.user.town ? hideField(this.town) : this.town }), h("label", { htmlFor: "town" }, "Ort ")), this.townError && h("span", null, this.townError), h("input", { type: "submit", value: "Forts\u00E4tt" })));
317
+ };
318
+ this.street = '';
319
+ this.streetError = null;
320
+ this.zip = '';
321
+ this.zipError = null;
322
+ this.town = '';
323
+ this.townError = null;
324
+ }
325
+ componentWillLoad() {
326
+ if (state.user) {
327
+ this.street = state.user.street;
328
+ this.zip = state.user.zip;
329
+ this.town = state.user.town;
330
+ }
331
+ }
332
+ get el() { return getElement(this); }
333
+ };
334
+
335
+ const getRutPrice = (price) => {
336
+ return Math.ceil(price / 2);
337
+ };
338
+ const getRotPrice = (price) => {
339
+ return Math.ceil(price * 0.7);
340
+ };
341
+ const getGreenPrice = (price) => {
342
+ return Math.ceil(price * 0.5);
343
+ };
344
+ const getProductPrice = (product, price, amount = 1) => {
345
+ if (product.rot && state.rot) {
346
+ return getRotPrice((price || product.price) * amount);
347
+ }
348
+ else if (product.rut && state.rut) {
349
+ return getRutPrice((price || product.price) * amount);
350
+ }
351
+ else if (product.green && state.green) {
352
+ return getGreenPrice((price || product.price) * amount);
353
+ }
354
+ else {
355
+ return (price || product.price) * amount;
356
+ }
357
+ };
358
+ const getProductPriceWithRotAndRut = (product) => {
359
+ if (product.rot) {
360
+ return getRotPrice(product.price);
361
+ }
362
+ else if (product.rut && state.rut) {
363
+ return getRutPrice(product.price);
364
+ }
365
+ else {
366
+ return product.price;
367
+ }
368
+ };
369
+ const getPartPrice = (part, product, amount = 1) => {
370
+ if (product.rot && state.rot) {
371
+ return getRotPrice(part.price * amount);
372
+ }
373
+ else if (product.rut && state.rut) {
374
+ return getRutPrice(part.price * amount);
375
+ }
376
+ else {
377
+ return part.price * amount;
378
+ }
379
+ };
380
+ const getStartFee = () => {
381
+ if (!state.cart)
382
+ return { rut: 0, rot: 0, green: 0 };
383
+ const hasRut = state.cart.some(item => item.rut && item.start_fee);
384
+ const hasRot = state.cart.some(item => item.rot && item.start_fee);
385
+ const hasGreen = state.cart.some(item => item.green && item.start_fee);
386
+ const rutPrice = state.rut ? getRutPrice(state.options.start_fee) : state.options.start_fee * 1;
387
+ const rotPrice = state.rot ? getRotPrice(state.options.start_fee) : state.options.start_fee * 1;
388
+ const greenPrice = state.green ? getGreenPrice(state.options.start_fee) : state.options.start_fee * 1;
389
+ return { rut: hasRut ? rutPrice : 0, rot: hasRot ? rotPrice : 0, green: hasGreen ? greenPrice : 0, length: [hasRut, hasRot, hasGreen].filter(d => d).length };
390
+ // if (hasRut && hasRot) {
391
+ // return { rut: rutPrice, rot: rotPrice, length: 2 };
392
+ // } else if (hasRut) {
393
+ // return { rut: rutPrice, rot: 0, length: 1 };
394
+ // } else if (hasRot) {
395
+ // return { rut: 0, rot: rotPrice, length: 1 };
396
+ // } else {
397
+ // return { rut: 0, rot: 0, length: 0 };
398
+ // }
399
+ };
400
+ const getItemPrice = (item) => {
401
+ const partsPrice = item.parts.reduce((acc, curr) => {
402
+ return acc + curr.price * curr.amount;
403
+ }, 0);
404
+ return getProductPrice(item, item.price * item.amount + partsPrice);
405
+ };
406
+ const calculateRot = () => {
407
+ const totalWithRot = state.cart.reduce((acc, curr) => {
408
+ return curr.rot ? acc + getItemPrice(curr) : acc;
409
+ }, 0) + getStartFee().rot;
410
+ const totalWithoutRot = state.cart.reduce((acc, curr) => {
411
+ const partsPrice = curr.parts.reduce((acc, curr) => {
412
+ return acc + curr.price * curr.amount;
413
+ }, 0);
414
+ return curr.rot ? acc + curr.price * curr.amount + partsPrice : acc;
415
+ }, 0) + Number(state.options.start_fee);
416
+ return totalWithoutRot - totalWithRot;
417
+ };
418
+ const calculateRut = () => {
419
+ const totalWithRut = state.cart.reduce((acc, curr) => {
420
+ return curr.rut ? acc + getItemPrice(curr) : acc;
421
+ }, 0) + getStartFee().rut;
422
+ const totalWithoutRut = state.cart.reduce((acc, curr) => {
423
+ const partsPrice = curr.parts.reduce((acc, curr) => {
424
+ return acc + curr.price * curr.amount;
425
+ }, 0);
426
+ return curr.rut ? acc + curr.price * curr.amount + partsPrice : acc;
427
+ }, 0) + Number(state.options.start_fee);
428
+ return totalWithoutRut - totalWithRut;
429
+ };
430
+ const calculateGreenDiscount = () => {
431
+ const totalWithGreen = state.cart.reduce((acc, curr) => {
432
+ return curr.green ? acc + getItemPrice(curr) : acc;
433
+ }, 0) + getStartFee().green;
434
+ const totalWithoutGreen = state.cart.reduce((acc, curr) => {
435
+ const partsPrice = curr.parts.reduce((acc, curr) => {
436
+ return acc + curr.price * curr.amount;
437
+ }, 0);
438
+ return curr.green ? acc + curr.price * curr.amount + partsPrice : acc;
439
+ }, 0) + Number(state.options.start_fee);
440
+ return totalWithoutGreen - totalWithGreen;
441
+ };
442
+ const getTotalPrice = () => {
443
+ return state.cart.reduce((acc, curr) => acc + getItemPrice(curr), 0) + getStartFee().rot + getStartFee().rut;
444
+ };
445
+
446
+ var Business;
447
+ (function (Business) {
448
+ Business["kund"] = "kund";
449
+ Business["byggmax"] = "byggmax";
450
+ Business["skanska"] = "skanska";
451
+ Business["string"] = "string-furniture";
452
+ Business["hornbach"] = "hornbach";
453
+ Business["forebygg"] = "forebygg";
454
+ Business["doro"] = "doro";
455
+ Business["elfa"] = "elfa";
456
+ Business["kbygg"] = "k-bygg";
457
+ Business["norrgavel"] = "norrgavel";
458
+ Business["fargvaruhuset"] = "fargvaruhuset";
459
+ Business["zaptec"] = "zaptec";
460
+ Business["tesla"] = "tesla";
461
+ Business["klint"] = "klint";
462
+ Business["flyttsmart"] = "flyttsmart";
463
+ Business["lg"] = "lg";
464
+ Business["sparfonster"] = "sparfonster";
465
+ Business["power"] = "power";
466
+ Business["traningspartner"] = "traningspartner";
467
+ Business["superfront"] = "superfront";
468
+ })(Business || (Business = {}));
469
+ var WidgetStyle;
470
+ (function (WidgetStyle) {
471
+ WidgetStyle["standard"] = "standard";
472
+ WidgetStyle["alternative"] = "alternative";
473
+ WidgetStyle["alternative_2"] = "alternative_2";
474
+ WidgetStyle["alternative_3"] = "alternative_3";
475
+ })(WidgetStyle || (WidgetStyle = {}));
476
+ var TopCategory;
477
+ (function (TopCategory) {
478
+ TopCategory["byggmax"] = "category/bygg";
479
+ })(TopCategory || (TopCategory = {}));
480
+
481
+ const isProduct = (category) => {
482
+ return category.post_name !== undefined;
483
+ };
484
+ const isBusiness = (partner) => {
485
+ return Object.values(Business).includes(partner);
486
+ };
487
+
488
+ const HemfixarnaBox = class {
489
+ constructor(hostRef) {
490
+ registerInstance(this, hostRef);
491
+ this.post = undefined;
492
+ this.category = undefined;
493
+ this.icon = undefined;
494
+ this.postTitle = undefined;
495
+ }
496
+ setTaxonomy(taxonomy) {
497
+ if (taxonomy) {
498
+ if ((taxonomy === null || taxonomy === void 0 ? void 0 : taxonomy.taxonomy) === 'service_cat') {
499
+ state.selectedCategory = taxonomy;
500
+ state.step = 2;
501
+ }
502
+ else if ((taxonomy === null || taxonomy === void 0 ? void 0 : taxonomy.post_type) === 'service') {
503
+ state.selectedService = taxonomy;
504
+ state.step = 3;
505
+ }
506
+ else if ((taxonomy === null || taxonomy === void 0 ? void 0 : taxonomy.post_type) === 'ikea_product') {
507
+ state.selectedProduct = taxonomy;
508
+ state.step = 4;
509
+ }
510
+ const el = this.el.closest('.hemfixarna_content');
511
+ scrollToTop(el);
512
+ }
513
+ }
514
+ setProduct() {
515
+ state.selectedProduct = this.category;
516
+ state.step = 4;
517
+ state.selectedCustomerCategory = null;
518
+ const el = this.el.closest('.hemfixarna_content');
519
+ scrollToTop(el);
520
+ }
521
+ render() {
522
+ return this.category ? (h(Fragment, null, isProduct(this.category) ? (h("li", { onClick: () => this.setProduct() }, h("img", { class: "hemfixarna_logo", height: 82, src: this.category.icon, alt: this.category.post_name }), h("div", null, h("p", null, this.category.title), !this.category.invoice ? h("p", { class: "price" }, "Fr\u00E5n ", getProductPrice(this.category), "kr") : null))) : (h("li", { onClick: () => (state.selectedCustomerCategory = this.category) }, h("img", { class: "hemfixarna_logo", height: 82, src: this.category.icon, alt: this.category.name }), h("div", null, h("p", null, this.category.name)))))) : (h("li", { onClick: () => this.setTaxonomy(this.post) }, this.post.icon && h("img", { class: "hemfixarna_logo", height: 82, src: this.icon, alt: this.postTitle }), h("div", null, h("p", null, this.postTitle), state.step === 3 && h("p", { class: "price" }, "Fr\u00E5n ", getProductPrice(this.post), "kr"))));
523
+ }
524
+ get el() { return getElement(this); }
525
+ };
526
+
527
+ const HemfixarnaBreadcrumbs = class {
528
+ constructor(hostRef) {
529
+ registerInstance(this, hostRef);
530
+ this.triggerScrollTotop = () => {
531
+ const el = this.el.nextSibling;
532
+ scrollToTop(el);
533
+ };
534
+ this.tree = undefined;
535
+ this.closeModal = undefined;
536
+ this.loadFromQuery = false;
537
+ this.isDemo = false;
538
+ }
539
+ getCartLength() {
540
+ return state.cart.reduce((acc, curr) => acc + curr.amount, 0);
541
+ }
542
+ handleCartClick() {
543
+ var _a;
544
+ if ((_a = state.cart) === null || _a === void 0 ? void 0 : _a.length) {
545
+ state.step = 5;
546
+ this.triggerScrollTotop();
547
+ }
548
+ }
549
+ handleHomePageClick() {
550
+ state.step = 1;
551
+ state.parentCategory = null;
552
+ state.selectedCustomerCategory = null;
553
+ this.triggerScrollTotop();
554
+ setTimeout(() => {
555
+ state.selectedCategory = null;
556
+ state.selectedProduct = null;
557
+ state.maleri = null;
558
+ state.selectedService = null;
559
+ }, 200);
560
+ }
561
+ render() {
562
+ const logo = getAssetPath(`./assets/hemfixarna.svg`);
563
+ const close = getAssetPath(`./assets/close.svg`);
564
+ const cart = getAssetPath(`./assets/cart.svg`);
565
+ const back = getAssetPath(`./assets/back.svg`);
566
+ return (h("div", null, h("div", { class: "hemfixarna_crumbs" }, h("div", { class: "hemfixarna_crumbs--links" }, h("img", { onClick: () => this.handleHomePageClick(), src: logo, width: 110 }), !this.loadFromQuery || this.isDemo ? h("img", { onClick: () => this.closeModal(), class: "close", src: close, width: 32 }) : null, h("div", null, h("button", { onClick: () => this.handleHomePageClick() }, "Alla tj\u00E4nster"))), h("div", { class: "hemfixarna_crumbs--right" }, h("hemfixarna-contact", null), h("div", { onClick: () => this.handleCartClick(), class: `cart ${this.getCartLength() > 0 ? 'cart_active' : ''}` }, h("img", { src: cart, width: 24 }), h("span", null, this.getCartLength())))), [3, 4].includes(state.step) && !state.customer && (h("button", { class: "hemfixarna_crumbs--back", onClick: () => {
567
+ state.step = state.step === 4 ? 3 : 2;
568
+ } }, h("img", { width: 24, src: back, alt: "back arrow" }), h("span", null, "Se allt ", state.step === 4 ? state.selectedService.post_title : state.selectedCategory.name))), !state.parentCategory && state.step && state.selectedCustomerCategory && (h("button", { class: "hemfixarna_crumbs--back", onClick: () => {
569
+ state.step = 1;
570
+ state.selectedCustomerCategory = null;
571
+ state.selectedProduct = null;
572
+ state.maleri = null;
573
+ } }, h("img", { width: 24, src: back, alt: "back arrow" }), h("span", null, "Se alla tj\u00E4nster"))), state.parentCategory && state.step < 5 && (h("button", { class: "hemfixarna_crumbs--back", onClick: () => {
574
+ state.step = 1;
575
+ state.selectedCustomerCategory = state.parentCategory;
576
+ state.selectedProduct = null;
577
+ state.maleri = null;
578
+ } }, h("img", { width: 24, src: back, alt: "back arrow" }), h("span", null, "Se allt ", state.parentCategory.name)))));
579
+ }
580
+ get el() { return getElement(this); }
581
+ };
582
+
583
+ const hemfixarnaByggmaxCss = "";
584
+
585
+ const MyComponent$j = class {
586
+ constructor(hostRef) {
587
+ registerInstance(this, hostRef);
588
+ this.tree = null;
589
+ this.slug = undefined;
590
+ this.id = undefined;
591
+ this.forceOldTree = false;
592
+ this.loadFromQuery = undefined;
593
+ this.customer = undefined;
594
+ this.widgetStyle = WidgetStyle.standard;
595
+ this.buttonColor = undefined;
596
+ this.buttonBg = undefined;
597
+ }
598
+ render() {
599
+ return (h("hemfixarna-component", { forceOldTree: this.forceOldTree, id: this.id, slug: this.slug, business: Business.byggmax, topCategory: TopCategory.byggmax, loadFromQuery: Boolean(this.loadFromQuery), widgetStyle: this.widgetStyle, buttonBg: this.buttonBg, buttonColor: this.buttonColor }));
600
+ }
601
+ };
602
+ MyComponent$j.style = hemfixarnaByggmaxCss;
603
+
604
+ const HemfixarnaCart = class {
605
+ constructor(hostRef) {
606
+ registerInstance(this, hostRef);
607
+ this.tree = undefined;
608
+ }
609
+ render() {
610
+ const back = getAssetPath(`./assets/back.svg`);
611
+ return (h("div", { class: "hemfixarna_cart" }, h("div", { class: "hemfixarna_cart--left" }, h("h2", null, state.checkoutStep === 2 && !state.checkoutEdit && (h("button", { onClick: () => {
612
+ state.checkoutStep = 1;
613
+ } }, h("img", { width: 24, src: back, alt: "back arrow" }))), "Din bokning"), h("hemfixarna-orderrows", { tree: this.tree })), h("div", { class: "hemfixarna_cart--right" }, h("h2", null, state.checkoutStep === 2 && !state.checkoutEdit && (h("button", { onClick: () => {
614
+ state.checkoutStep = 1;
615
+ } }, h("img", { width: 24, src: back, alt: "back arrow" }))), "Dina uppgifter"), h("hemfixarna-checkout", null), h("hemfixarna-info", null))));
616
+ }
617
+ };
618
+
619
+ const HemfixarnaCategory = class {
620
+ constructor(hostRef) {
621
+ registerInstance(this, hostRef);
622
+ }
623
+ setSelectedService(service) {
624
+ state.selectedService = service;
625
+ state.step = 3;
626
+ }
627
+ render() {
628
+ return (h("div", null, h("h2", null, state.selectedCategory.name), h("div", { class: "hemfixarna_categories--wrapper" }, h("div", null, h("ul", { class: "hemfixarna_categories" }, state.selectedCategory.services
629
+ .sort((a, b) => (a.post_title < b.post_title ? -1 : 1))
630
+ .map(s => {
631
+ var _a;
632
+ return (h("hemfixarna-box", { post: s, icon: (_a = s.icon.url) !== null && _a !== void 0 ? _a : s.icon, postTitle: s.post_title }));
633
+ }))), h("hemfixarna-info", null))));
634
+ }
635
+ };
636
+
637
+ const base$2 = `${"https://hemfixarna.se"}/wp-json/headless` ;
638
+ async function fetchWithType(request, options) {
639
+ const response = await fetch(request, options);
640
+ const body = await response.json();
641
+ return body;
642
+ }
643
+ const getTaxonomy = async (endpoint) => {
644
+ if (!endpoint) {
645
+ return;
646
+ }
647
+ const type = endpoint.split('/')[0];
648
+ const slug = endpoint.split('/')[1];
649
+ try {
650
+ const res = await fetch(`${base$2}/${type}/${slug}`);
651
+ return await res.json();
652
+ }
653
+ catch (error) {
654
+ console.log(error);
655
+ }
656
+ };
657
+ const getCustomer = async (slug) => {
658
+ try {
659
+ const res = await fetch(`${base$2}/customer/${slug}`);
660
+ return await res.json();
661
+ }
662
+ catch (error) {
663
+ console.log(error);
664
+ }
665
+ };
666
+ const getOptions = async () => {
667
+ try {
668
+ const res = await fetch(`${base$2}/webcoptions`);
669
+ return (await res.json());
670
+ }
671
+ catch (error) {
672
+ console.log(error);
673
+ }
674
+ };
675
+ const getRut = async () => {
676
+ try {
677
+ const data = await fetchWithType(`${base$2}/rut`);
678
+ return data;
679
+ }
680
+ catch (error) {
681
+ console.log(error);
682
+ }
683
+ };
684
+ const getRot = async () => {
685
+ try {
686
+ const res = await fetch(`${base$2}/rot`);
687
+ return (await res.json());
688
+ }
689
+ catch (error) {
690
+ console.log(error);
691
+ }
692
+ };
693
+ const getGreenDiscount = async () => {
694
+ try {
695
+ const res = await fetch(`${base$2}/green-discount`);
696
+ return await res.json();
697
+ }
698
+ catch (error) {
699
+ console.log(error);
700
+ }
701
+ };
702
+ const postOrder = async (data) => {
703
+ try {
704
+ const res = await fetch(`${base$2}/weborder`, {
705
+ method: 'POST',
706
+ body: JSON.stringify(data),
707
+ headers: {
708
+ 'Content-Type': 'application/json',
709
+ },
710
+ });
711
+ return (await res.json());
712
+ }
713
+ catch (error) {
714
+ console.log(error);
715
+ }
716
+ };
717
+
718
+ const base$1 = `${"https://hemfixarna.se"}/wp-json/felix` ;
719
+ const postPerson = async (felixOrder) => {
720
+ try {
721
+ return await fetchWithType(`${base$1}/createperson`, {
722
+ method: 'POST',
723
+ body: JSON.stringify(felixOrder),
724
+ headers: {
725
+ 'Content-Type': 'application/json',
726
+ },
727
+ });
728
+ }
729
+ catch (error) {
730
+ console.log(error);
731
+ }
732
+ };
733
+
734
+ const HemfixarnaCheckout = class {
735
+ constructor(hostRef) {
736
+ registerInstance(this, hostRef);
737
+ this.handleChangeDate = (e) => {
738
+ this.dateError = null;
739
+ this.date = e.target.value;
740
+ };
741
+ this.handleChangeTerms = () => {
742
+ this.generalError = null;
743
+ };
744
+ this.sendOrder = async () => {
745
+ var _a, _b, _c, _d;
746
+ if (this.loading)
747
+ return;
748
+ this.loading = true;
749
+ let order = {
750
+ firstName: state.creditSafeUser.firstName,
751
+ lastName: state.creditSafeUser.lastName,
752
+ street: state.user.street,
753
+ zip: state.user.zip,
754
+ town: state.user.town,
755
+ ssn: state.user.ssn,
756
+ email: state.user.email,
757
+ phone: state.user.phone,
758
+ url: `${state.business === Business.string ? 'string' : state.business}-webk`,
759
+ date: this.date,
760
+ products: [
761
+ ...state.cart.map(item => {
762
+ const parts = item.parts.map(part => ({
763
+ id: String(part.id),
764
+ name: part.name,
765
+ quantity: part.amount,
766
+ rut: 0,
767
+ rot: 0,
768
+ }));
769
+ return [
770
+ {
771
+ id: String(item.id),
772
+ name: item.name,
773
+ quantity: item.amount,
774
+ rot: item.rot ? 1 : 0,
775
+ rut: item.rut ? 1 : 0,
776
+ },
777
+ ...parts,
778
+ ];
779
+ }),
780
+ ].flat(),
781
+ creditSafe: state.creditSafeUser,
782
+ customer: state.business,
783
+ id_source: '',
784
+ id_sub_source: '',
785
+ seller_id: (_a = this.sellerID) !== null && _a !== void 0 ? _a : '',
786
+ referral_id: (_b = this.RefferalID) !== null && _b !== void 0 ? _b : '',
787
+ };
788
+ const felixOrder = await postPerson(order);
789
+ if (!felixOrder || !((_d = (_c = felixOrder.response) === null || _c === void 0 ? void 0 : _c.scriptResult) === null || _d === void 0 ? void 0 : _d.includes('OK'))) {
790
+ order = Object.assign(Object.assign({}, order), { felixStatus: 'error' });
791
+ }
792
+ else {
793
+ order = Object.assign(Object.assign({}, order), { felixStatus: 'success' });
794
+ }
795
+ try {
796
+ const { data: orderConfirm, status } = await postOrder(order);
797
+ if (orderConfirm && status && status === 200) {
798
+ state.step = 6;
799
+ const el = this.el.closest('.hemfixarna_content');
800
+ scrollToTop(el);
801
+ }
802
+ else {
803
+ this.generalError = 'Något gick fel, försök igen senare';
804
+ }
805
+ }
806
+ catch (error) {
807
+ this.generalError = 'Något gick fel, försök igen senare';
808
+ }
809
+ this.loading = false;
810
+ };
811
+ this.handleSubmit = (e) => {
812
+ e.preventDefault();
813
+ this.generalError = null;
814
+ const validDate = this.date.length > 0;
815
+ if (!validDate) {
816
+ this.dateError = 'Ange ett giltigt datum';
817
+ }
818
+ const checkBoxes = Array.from(this.el.querySelectorAll('input[type="checkbox"]'));
819
+ const notValidTerms = checkBoxes.find(i => !i.checked);
820
+ if (notValidTerms) {
821
+ this.generalError = 'Du måste godkänna villkoren';
822
+ }
823
+ // if (state.customer.source) {
824
+ // if (!this.sellerID) {
825
+ // this.generalError = 'Ange säljare';
826
+ // return;
827
+ // }
828
+ // if (state.customer.source.sub_sources?.length && !this.selectedSubSource) {
829
+ // this.generalError = 'Välj underkälla';
830
+ // return;
831
+ // }
832
+ // }
833
+ if (validDate && !notValidTerms) {
834
+ this.sendOrder();
835
+ }
836
+ };
837
+ this.handleKeyDown = (event) => {
838
+ this.enteredPin += event.key;
839
+ const correctPin = '+0033';
840
+ if (this.enteredPin.length === correctPin.length) {
841
+ if (this.enteredPin === correctPin) {
842
+ localStorage.setItem('show_sources', 'true');
843
+ this.showSources = true;
844
+ window.removeEventListener('keydown', this.handleKeyDown);
845
+ }
846
+ this.enteredPin = '';
847
+ }
848
+ clearTimeout(this.pinTimeout);
849
+ this.pinTimeout = setTimeout(() => (this.enteredPin = ''), 5000);
850
+ };
851
+ this.render = () => {
852
+ var _a;
853
+ const dateLogo = getAssetPath(`./assets/date.svg`);
854
+ const down = getAssetPath(`./assets/down.svg`);
855
+ const loading = getAssetPath(`./assets/spinner.gif`);
856
+ if (state.checkoutEdit) {
857
+ return h("hemfixarna-address", null);
858
+ }
859
+ else if (state.checkoutStep === 1) {
860
+ return h("hemfixarna-getuser", null);
861
+ }
862
+ else if (state.checkoutStep === 2) {
863
+ return (h("div", { class: "mb-2" }, h("div", { class: "hemfixarna_addressinfo" }, h("div", null, h("p", null, hideField(state.user.firstName)), h("p", null, hideField(state.user.lastName)), h("p", null, state.user.email), h("p", null, state.user.phone)), h("div", null, h("p", null, hideField(state.user.street)), h("p", null, hideField(state.user.zip)), h("p", null, hideField(state.user.town))), h("button", { onClick: () => (state.checkoutEdit = true) }, "Beh\u00F6ver du \u00E4ndra adressen?")), h("form", { onSubmit: e => this.handleSubmit(e) }, h("div", null, h("img", { src: dateLogo, width: 24 }), h("input", { class: `${this.date.length ? 'input_active' : ''}`, min: new Date().toISOString().split('T')[0], onChange: e => this.handleChangeDate(e), type: "date", name: "date", value: this.date }), h("label", { htmlFor: "date" }, "Tidigaste datum f\u00F6r hembes\u00F6k"), h("img", { src: down, width: 24 })), this.dateError && h("span", null, this.dateError), state.customer.source && this.showSources ? (h(Fragment, null, h("p", null, "Inloggad som:", h("strong", null, " ", state.customer.source.fieldData.So01_Name)), h("label", null, "S\u00E4ljare (S\u00E4ljarId)", h("input", { type: "text", value: this.sellerID, onChange: e => (this.sellerID = e.target.value) })), h("label", null, "PartnerOrderID (RefferalID)", h("input", { type: "text", value: this.RefferalID, onChange: e => (this.RefferalID = e.target.value) })), ((_a = state.customer.source.sub_sources) === null || _a === void 0 ? void 0 : _a.length) ? (h("div", null, h("select", { onChange: e => (this.selectedSubSource = e.target.value) }, h("option", { disabled: true, selected: true, value: "null" }, "V\u00E4lj underk\u00E4lla"), state.customer.source.sub_sources.map(sub => (h("option", { value: sub['So_SubSource::_id'] }, sub['So_SubSource::Sus01_Name'])))))) : (h("h4", null, "Det finns inga underk\u00E4llor att v\u00E4lja")))) : null, h("label", { class: "hemfixarna_checkbox" }, h("input", { onChange: () => this.handleChangeTerms(), type: "checkbox" }), h("span", { innerHTML: state.options.terms })), state.cart
864
+ .filter(i => { var _a; return (_a = i.terms_checkout) === null || _a === void 0 ? void 0 : _a.length; })
865
+ .map(item => (h(Fragment, null, h("label", { class: "hemfixarna_checkbox" }, h("input", { onChange: () => this.handleChangeTerms(), type: "checkbox" }), h("span", null, item.terms_checkout))))), this.generalError && h("span", null, this.generalError), h("div", { class: this.loading ? 'loading' : '' }, h("input", { type: "submit", value: this.loading ? '' : 'Skicka bokning' }), h("img", { width: 20, height: 20, src: loading, alt: "spinner" })))));
866
+ }
867
+ };
868
+ this.date = '';
869
+ this.dateError = null;
870
+ this.generalError = null;
871
+ this.loading = false;
872
+ this.enteredPin = '';
873
+ this.selectedSubSource = null;
874
+ this.partnerOrderId = null;
875
+ this.showSources = false;
876
+ this.sellerID = null;
877
+ this.RefferalID = null;
878
+ }
879
+ componentWillLoad() {
880
+ if (Boolean(state.user && state.user.street)) {
881
+ state.checkoutStep = 2;
882
+ }
883
+ if (state.customer && state.customer.source) {
884
+ window.addEventListener('keydown', this.handleKeyDown);
885
+ }
886
+ const showSources = localStorage.getItem('show_sources');
887
+ if (showSources) {
888
+ this.showSources = true;
889
+ }
890
+ }
891
+ disconnectedCallback() {
892
+ window.removeEventListener('keydown', this.handleKeyDown);
893
+ }
894
+ get el() { return getElement(this); }
895
+ };
896
+
897
+ const hemfixarnaCss = "@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}";
898
+
899
+ const HemfixarnaComponent = class {
900
+ constructor(hostRef) {
901
+ registerInstance(this, hostRef);
902
+ this.slugIsOldFormat = (slug) => {
903
+ if (!slug)
904
+ return false;
905
+ return ['product', 'service', 'category'].some(str => slug.includes(str));
906
+ };
907
+ this.triggerScrollTotop = () => {
908
+ const el = this.el.shadowRoot.querySelector('.hemfixarna_content');
909
+ scrollToTop(el);
910
+ };
911
+ this.modal = false;
912
+ this.showModal = false;
913
+ this.tree = null;
914
+ this.product = null;
915
+ this.proppedProduct = null;
916
+ this.slug = undefined;
917
+ this.id = undefined;
918
+ this.business = undefined;
919
+ this.topCategory = undefined;
920
+ this.forceOldTree = false;
921
+ this.loadFromQuery = false;
922
+ this.isDemo = false;
923
+ this.widgetStyle = undefined;
924
+ this.nav = undefined;
925
+ this.buttonColor = undefined;
926
+ this.buttonBg = undefined;
927
+ }
928
+ loadCategoryOrProduct(id) {
929
+ this.proppedProduct = null;
930
+ if (id.startsWith('c-')) {
931
+ const categories = [...state.customer.categories, ...state.customer.categories.map(c => { var _a; return (_a = c.sub_categories) !== null && _a !== void 0 ? _a : []; })].flat();
932
+ const category = categories.find(c => c && c.id === id.replace('c-', ''));
933
+ if (category) {
934
+ state.selectedCustomerCategory = category;
935
+ state.step = 2;
936
+ }
937
+ }
938
+ else {
939
+ const products = state.customer.categories
940
+ .map(c => (c.show_products ? c.products : c.sub_categories ? c.sub_categories.map(c => c.products) : []))
941
+ .flat()
942
+ .flat();
943
+ const product = products.find(p => p && p.fields.ID === parseInt(id));
944
+ if (product) {
945
+ state.selectedProduct = product.fields;
946
+ state.step = 4;
947
+ this.proppedProduct = product.fields;
948
+ }
949
+ }
950
+ }
951
+ async watchSlugChange(newValue) {
952
+ if (this.slugIsOldFormat(newValue)) {
953
+ this.fetchNewTaxonomy(newValue);
954
+ }
955
+ else if (state.customer && newValue) {
956
+ this.loadCategoryOrProduct(newValue);
957
+ }
958
+ }
959
+ async watchIdChange(id) {
960
+ if (id && state.customer) {
961
+ if (id === 'maleri') {
962
+ state.maleri = true;
963
+ state.step = 4;
964
+ }
965
+ else {
966
+ this.loadCategoryOrProduct(id);
967
+ }
968
+ }
969
+ }
970
+ async fetchNewTaxonomy(slug) {
971
+ state.selectedCategory = null;
972
+ state.selectedProduct = null;
973
+ state.selectedService = null;
974
+ state.maleri = null;
975
+ const res = await getTaxonomy(slug);
976
+ if ((res === null || res === void 0 ? void 0 : res.code) === 'not_found' || (res === null || res === void 0 ? void 0 : res.code) === 'rest_no_route') {
977
+ console.log('taxonomy not found');
978
+ }
979
+ else if (res) {
980
+ this.setTaxonomy(res);
981
+ if ((res === null || res === void 0 ? void 0 : res.post_type) === 'ikea_product') {
982
+ this.product = res;
983
+ }
984
+ }
985
+ }
986
+ async componentWillLoad() {
987
+ state.business = this.business;
988
+ const cart = window.sessionStorage.getItem(`hemfixarna-${this.business}-cart`);
989
+ if (cart) {
990
+ state.cart = JSON.parse(cart);
991
+ }
992
+ const user = window.sessionStorage.getItem(`hemfixarna-${this.business}-user`);
993
+ if (user) {
994
+ state.user = JSON.parse(user);
995
+ }
996
+ const creditSafeUser = window.sessionStorage.getItem(`hemfixarna-${this.business}-creditSafeUser`);
997
+ if (creditSafeUser) {
998
+ state.creditSafeUser = JSON.parse(creditSafeUser);
999
+ }
1000
+ const [tree, res, options, rut, rot, greenDiscount] = await Promise.all([
1001
+ this.topCategory ? getTaxonomy(this.topCategory) : null,
1002
+ this.slug ? getTaxonomy(this.slug) : Promise.resolve(null),
1003
+ getOptions(),
1004
+ getRut(),
1005
+ getRot(),
1006
+ getGreenDiscount(),
1007
+ ]);
1008
+ if ((!this.slug || !this.slugIsOldFormat(this.slug)) && !this.forceOldTree) {
1009
+ try {
1010
+ const customer = await getCustomer(this.business);
1011
+ if ((customer === null || customer === void 0 ? void 0 : customer.code) === 'not_found') {
1012
+ console.warn('customer not found');
1013
+ }
1014
+ else if (customer) {
1015
+ state.customer = customer;
1016
+ if (this.id) {
1017
+ if (this.id === 'maleri') {
1018
+ state.maleri = true;
1019
+ state.step = 4;
1020
+ }
1021
+ else {
1022
+ this.loadCategoryOrProduct(this.id);
1023
+ }
1024
+ }
1025
+ else if (this.slug && !this.slugIsOldFormat(this.slug)) {
1026
+ this.loadCategoryOrProduct(this.slug);
1027
+ }
1028
+ }
1029
+ }
1030
+ catch (error) {
1031
+ console.warn('customer not found');
1032
+ }
1033
+ }
1034
+ if ((tree === null || tree === void 0 ? void 0 : tree.code) === 'not_found') ;
1035
+ else if (tree) {
1036
+ this.tree = tree;
1037
+ }
1038
+ if ((res === null || res === void 0 ? void 0 : res.code) === 'not_found') {
1039
+ console.log('taxonomy not found');
1040
+ }
1041
+ else if (res) {
1042
+ this.setTaxonomy(res);
1043
+ if ((res === null || res === void 0 ? void 0 : res.post_type) === 'ikea_product') {
1044
+ this.product = res;
1045
+ }
1046
+ }
1047
+ if (this.loadFromQuery) {
1048
+ const params = new URL(document.location.toString()).searchParams;
1049
+ this.id = params.get('id');
1050
+ if (!this.isDemo) {
1051
+ this.openModal();
1052
+ }
1053
+ }
1054
+ state.rotOptions = rot;
1055
+ state.rutOptions = rut;
1056
+ state.greenOptions = greenDiscount;
1057
+ state.options = options;
1058
+ }
1059
+ setTaxonomy(taxonomy) {
1060
+ if (taxonomy) {
1061
+ if ((taxonomy === null || taxonomy === void 0 ? void 0 : taxonomy.taxonomy) === 'service_cat') {
1062
+ state.selectedCategory = taxonomy;
1063
+ state.step = 2;
1064
+ }
1065
+ else if ((taxonomy === null || taxonomy === void 0 ? void 0 : taxonomy.post_type) === 'service') {
1066
+ state.selectedService = taxonomy;
1067
+ state.selectedCategory = this.tree.sub_cats.find(c => c.services.find(s => s.ID === taxonomy.ID));
1068
+ state.step = 3;
1069
+ }
1070
+ else if ((taxonomy === null || taxonomy === void 0 ? void 0 : taxonomy.post_type) === 'ikea_product') {
1071
+ state.selectedProduct = taxonomy;
1072
+ state.selectedService = this.tree.sub_cats
1073
+ .map(c => c.services)
1074
+ .flat()
1075
+ .find(s => s.products.find(p => p.ID === state.selectedProduct.ID));
1076
+ state.selectedCategory = this.tree.sub_cats.find(c => c.services.find(s => s.ID === state.selectedService.ID));
1077
+ state.step = 4;
1078
+ }
1079
+ this.triggerScrollTotop();
1080
+ }
1081
+ }
1082
+ // Open close modal && click outside event
1083
+ openModal() {
1084
+ this.modal = true;
1085
+ setTimeout(() => {
1086
+ this.showModal = true;
1087
+ }, 50);
1088
+ }
1089
+ closeModal() {
1090
+ this.showModal = false;
1091
+ setTimeout(() => {
1092
+ this.modal = false;
1093
+ }, 200);
1094
+ }
1095
+ handleClick(e) {
1096
+ if (this.loadFromQuery && !this.isDemo)
1097
+ return;
1098
+ if ((e === null || e === void 0 ? void 0 : e.composedPath()[0]).classList.contains('hemfixarna_backdrop')) {
1099
+ this.closeModal();
1100
+ }
1101
+ const infomodal = this.el.shadowRoot.querySelector('.hemfixarna_infomodal');
1102
+ if (infomodal) {
1103
+ const isClickInside = infomodal.contains(e.composedPath()[0]);
1104
+ if (!isClickInside) {
1105
+ state.modal = null;
1106
+ }
1107
+ }
1108
+ }
1109
+ getCartLength() {
1110
+ return state.cart.reduce((acc, curr) => acc + curr.amount, 0);
1111
+ }
1112
+ render() {
1113
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
1114
+ const logo = getAssetPath(`./assets/hemfixarna.svg`);
1115
+ const pensel = getAssetPath(`./assets/pensel.svg`);
1116
+ const monteringLogo = getAssetPath(`./assets/montering.svg`);
1117
+ const navBackground = ((_a = this.nav) === null || _a === void 0 ? void 0 : _a.background) ? getAssetPath(this.nav.background) : '';
1118
+ const navLogo = ((_b = this.nav) === null || _b === void 0 ? void 0 : _b.logo) ? getAssetPath(this.nav.logo) : '';
1119
+ return (h("div", { class: `hemfixarna ${this.loadFromQuery ? 'hemfixarna_standalone' : ''}` }, this.loadFromQuery && !this.isDemo && this.nav ? (h("nav", { class: "hemfixarna_nav", style: { backgroundColor: (_c = this.nav.backgroundColor) !== null && _c !== void 0 ? _c : '' } }, h("div", null, h("div", { class: "hemfixarna_nav--logos" }, h("a", { href: this.nav.url, target: "_blank" }, h("img", { class: "hemfixarna_partnerlogo", src: navLogo, alt: `${this.business} logo` })), h("a", { href: "https://hemfixarna.se/", target: "_blank" }, h("p", { class: navBackground || this.nav.backgroundColor ? 'with-bg' : '' }, "I samarbete med:"), h("img", { src: logo, alt: "hemfixarna_logo", width: 104 }))), h("div", { class: "hemfixarna_nav--links" }, h("a", { href: this.nav.url, target: "_blank" }, "Till ", this.business), h("a", { href: "https://www.hemfixarna.se/", target: "_blank" }, "Till Hemfixarna")), navBackground ? h("img", { src: navBackground, class: "nav_background", alt: "nav_background" }) : null))) : null, !this.loadFromQuery || this.isDemo ? (h("div", { class: `hemfixarna_box hemfixarna_box--${this.widgetStyle}` }, [WidgetStyle.alternative_2, WidgetStyle.alternative_3].includes(this.widgetStyle) ? (h("img", { src: this.id === 'maleri' ? pensel : monteringLogo, alt: "montering logo", width: 32, height: 32 })) : null, h("div", null, h("div", null, h("p", { onClick: () => this.openModal(), class: `pointer ${[WidgetStyle.alternative_2, WidgetStyle.alternative_3].includes(this.widgetStyle) && state.selectedProduct ? 'underline' : ''}` }, this.id === 'maleri' ? (h("span", null, "Ber\u00E4kna fast pris p\u00E5 m\u00E5leri & tapetsering h\u00E4r")) : (h(Fragment, null, !state.selectedCustomerCategory && !this.product && !this.proppedProduct ? (h(Fragment, null, ((_d = state.customer) === null || _d === void 0 ? void 0 : _d.widget_title) ? (h("span", null, state.customer.widget_title)) : (h("span", null, "Montering/Installation - ", h("strong", { class: "underline" }, "se priser h\u00E4r"))))) : (h(Fragment, null, ((_e = this.product) === null || _e === void 0 ? void 0 : _e.title) || ((_f = this.proppedProduct) === null || _f === void 0 ? void 0 : _f.title) || ((_g = state.selectedCustomerCategory) === null || _g === void 0 ? void 0 : _g.widget_title) || (h("span", null, "Montering", h("wbr", null), "/Installation ", (_j = (_h = state.selectedCustomerCategory) === null || _h === void 0 ? void 0 : _h.name) !== null && _j !== void 0 ? _j : 'på plats', " - ", h("strong", { class: "underline" }, "se priser h\u00E4r"))), (this.product && ((_k = this.slug) === null || _k === void 0 ? void 0 : _k.includes('product'))) || (this.proppedProduct && !((_l = this.product) === null || _l === void 0 ? void 0 : _l.invoice) && !((_m = this.proppedProduct) === null || _m === void 0 ? void 0 : _m.invoice)) ? (h("span", null, ' från', " ", h("strong", null, getProductPriceWithRotAndRut(this.proppedProduct || this.product), "kr"))) : null)))))), this.widgetStyle === WidgetStyle.standard ? h("img", { src: logo, width: 104 }) : null, this.widgetStyle === WidgetStyle.alternative ? (h("span", { class: "p-s" }, "Utf\u00F6rs av ", h("strong", null, "Hemfixarna"))) : null), [WidgetStyle.standard, WidgetStyle.alternative].includes(this.widgetStyle) ? (h("button", { onClick: () => this.openModal(), class: "hemfixarna_btn", style: {
1120
+ color: ((_o = this.buttonColor) === null || _o === void 0 ? void 0 : _o.startsWith('#')) || !((_p = this.buttonColor) === null || _p === void 0 ? void 0 : _p.length) ? this.buttonColor : `#${this.buttonColor}`,
1121
+ backgroundColor: ((_q = this.buttonBg) === null || _q === void 0 ? void 0 : _q.startsWith('#')) || !((_r = this.buttonBg) === null || _r === void 0 ? void 0 : _r.length) ? this.buttonBg : `#${this.buttonBg}`,
1122
+ } }, "Best\u00E4ll h\u00E4r", this.getCartLength() > 0 && h("span", null, this.getCartLength()))) : null, WidgetStyle.alternative_2 === this.widgetStyle ? (h("div", { class: "hemfixarna_altbtn" }, h("strong", { class: "p-s" }, "Utf\u00F6rs av"), h("img", { src: logo, alt: "hemfixarna logo", width: 98 }))) : null)) : null, this.modal && (h("div", null, h("div", { class: `hemfixarna_modal ${this.showModal ? 'hemfixarna_modal--open' : ''}` }, state.modal && (h("div", { class: "hemfixarna_infomodal" }, state.modal.title && h("h2", null, state.modal.title), state.modal.text.map((t) => (h("p", { innerHTML: t }))), h("div", null, h("button", { onClick: () => (state.modal = null) }, "St\u00E4ng")))), (this.tree || state.customer) && (h("hemfixarna-breadcrumbs", { isDemo: this.isDemo, loadFromQuery: this.loadFromQuery, closeModal: () => this.closeModal(), tree: this.tree })), !state.customer || this.slugIsOldFormat(this.slug) ? (h("div", { class: `hemfixarna_content hemfixarna_content--${state.step}` }, state.step === 1 && this.tree && h("hemfixarna-start", { tree: this.tree }), state.step === 2 && state.selectedCategory && h("hemfixarna-category", null), state.step === 3 && state.selectedService && h("hemfixarna-service", null), state.step === 4 && state.selectedProduct && h("hemfixarna-product", null), state.step === 5 && h("hemfixarna-cart", { tree: this.tree }), state.step === 6 && h("hemfixarna-order", { tree: this.tree }))) : (h("div", { class: `hemfixarna_content hemfixarna_content--${state.step} ${state.step === 4 && state.maleri ? 'hemfixarna_content--painting' : ''}` }, state.step < 4 && h("hemfixarna-start", null), state.step === 4 && h("hemfixarna-product", null), state.step === 5 && h("hemfixarna-cart", { tree: this.tree }), state.step === 6 && h("hemfixarna-order", { tree: this.tree })))), !this.isDemo ? h("div", { class: `hemfixarna_backdrop ${this.showModal ? 'hemfixarna_backdrop--open' : ''}` }) : null))));
1123
+ }
1124
+ static get assetsDirs() { return ["assets"]; }
1125
+ get el() { return getElement(this); }
1126
+ static get watchers() { return {
1127
+ "slug": ["watchSlugChange"],
1128
+ "id": ["watchIdChange"]
1129
+ }; }
1130
+ };
1131
+ HemfixarnaComponent.style = hemfixarnaCss;
1132
+
1133
+ const HemfixarnaInfo$1 = class {
1134
+ constructor(hostRef) {
1135
+ registerInstance(this, hostRef);
1136
+ this.vertical = false;
1137
+ }
1138
+ render() {
1139
+ return (h("div", { class: `hemfixarna_contact ${this.vertical ? 'hemfixarna_contact--vertical' : 'hemfixarna_contact--horizontal'}` }, h("a", { href: "tel:0770-220 720" }, h("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { 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", fill: "#C84E18" })), h("span", null, "0770-220 720")), h("a", { href: "https://hemfixarna.se/kundservice/", target: "_blank" }, h("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("g", { "clip-path": "url(#clip0_1001_894)" }, h("path", { 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", fill: "#C84E18" }), 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" }), 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" }), h("path", { 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", fill: "#C84E18" })), h("defs", null, h("clipPath", { id: "clip0_1001_894" }, h("rect", { width: "24", height: "24", fill: "white" })))), h("span", null, "Kundservice"))));
1140
+ }
1141
+ };
1142
+
1143
+ const hemfixarnaDemoCss = "@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}";
1144
+
1145
+ const MyComponent$i = class {
1146
+ constructor(hostRef) {
1147
+ registerInstance(this, hostRef);
1148
+ this.debounce = null;
1149
+ this.cdnLink = '<script type="module" src="https://cdn.jsdelivr.net/npm//hemfixarna-web-components@latest/dist/hemfixarna-components/hemfixarna-components.esm.js"></script>';
1150
+ this.selectedSlug = undefined;
1151
+ this.selectedID = undefined;
1152
+ this.tooltipText = 'Kopiera till urklipp';
1153
+ this.tree = null;
1154
+ this.customer = null;
1155
+ this.widgetStyle = WidgetStyle.standard;
1156
+ this.buttonBg = '';
1157
+ this.buttonColor = '';
1158
+ this.partner = undefined;
1159
+ this.colorAccessibility = undefined;
1160
+ }
1161
+ debouncedFunction() {
1162
+ if (this.debounce !== null) {
1163
+ clearTimeout(this.debounce);
1164
+ this.debounce = null;
1165
+ }
1166
+ this.debounce = window.setTimeout(() => {
1167
+ this.checkColorAccessibility();
1168
+ this.debounce = null;
1169
+ }, 1500);
1170
+ }
1171
+ async checkColorAccessibility() {
1172
+ const defaultTextColor = '#fff';
1173
+ const defaultBgColor = '#c84e18';
1174
+ const firstColor = this.buttonBg.length ? (this.buttonBg.startsWith('#') ? this.buttonBg : `#${this.buttonBg}`) : defaultBgColor;
1175
+ const secondColor = this.buttonColor.length ? (this.buttonColor.startsWith('#') ? this.buttonColor : `#${this.buttonColor}`) : defaultTextColor;
1176
+ fetch('https://www.aremycolorsaccessible.com/api/are-they', {
1177
+ mode: 'cors',
1178
+ method: 'POST',
1179
+ body: JSON.stringify({ colors: [firstColor, secondColor] }),
1180
+ })
1181
+ .then(response => response.json())
1182
+ .then(json => {
1183
+ if (json && (json)) {
1184
+ this.colorAccessibility = json;
1185
+ }
1186
+ });
1187
+ // Your color accessibility logic here
1188
+ }
1189
+ getTopLevelCategory() {
1190
+ switch (process.env.BUSINESS) {
1191
+ case Business.byggmax:
1192
+ return TopCategory.byggmax;
1193
+ default:
1194
+ return '';
1195
+ }
1196
+ }
1197
+ getColor(rating) {
1198
+ switch (rating) {
1199
+ case 'AAA':
1200
+ return 'green';
1201
+ case 'AA':
1202
+ return 'orange';
1203
+ case 'A':
1204
+ return 'yellow';
1205
+ case 'Fail':
1206
+ return 'red';
1207
+ default:
1208
+ return 'black';
1209
+ }
1210
+ }
1211
+ async componentWillLoad() {
1212
+ var _a;
1213
+ if (process.env.FORCE_OLD_TREE) {
1214
+ const tree = await getTaxonomy(this.getTopLevelCategory());
1215
+ if ((tree === null || tree === void 0 ? void 0 : tree.code) === 'not_found') ;
1216
+ else if (tree) {
1217
+ this.tree = tree;
1218
+ }
1219
+ }
1220
+ else {
1221
+ const partner = window.location.pathname.replace('/', '');
1222
+ this.partner = isBusiness(partner) ? partner : (_a = process.env.BUSINESS) !== null && _a !== void 0 ? _a : Business.kund;
1223
+ const customer = await getCustomer(this.partner);
1224
+ if (customer.code !== 'not_found' && customer) {
1225
+ this.customer = customer;
1226
+ }
1227
+ }
1228
+ }
1229
+ getExample() {
1230
+ 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}>`;
1231
+ }
1232
+ copyExample() {
1233
+ navigator.clipboard.writeText(this.getExample());
1234
+ this.tooltipText = 'Snippet kopierad';
1235
+ setTimeout(() => {
1236
+ this.tooltipText = 'Kopiera till urklipp';
1237
+ }, 2000);
1238
+ }
1239
+ copyCdn() {
1240
+ navigator.clipboard.writeText(this.cdnLink);
1241
+ this.tooltipText = 'Text kopierad';
1242
+ setTimeout(() => {
1243
+ this.tooltipText = 'Kopiera till urklipp';
1244
+ }, 2000);
1245
+ }
1246
+ copyNpmInstall() {
1247
+ navigator.clipboard.writeText('npm i hemfixarna-web-components');
1248
+ this.tooltipText = 'Text kopierad';
1249
+ setTimeout(() => {
1250
+ this.tooltipText = 'Kopiera till urklipp';
1251
+ }, 2000);
1252
+ }
1253
+ showMaleri() {
1254
+ var _a;
1255
+ const allCategories = (_a = this.customer) === null || _a === void 0 ? void 0 : _a.categories.map(c => (c.sub_categories ? c.sub_categories : c)).flat();
1256
+ return allCategories === null || allCategories === void 0 ? void 0 : allCategories.some(c => c.add_painting);
1257
+ }
1258
+ render() {
1259
+ var _a;
1260
+ const copy = getAssetPath(`./assets/copy.png`);
1261
+ return (h("div", { class: ((_a = this.customer) === null || _a === void 0 ? void 0 : _a.at_hemfixarna) ? 'hemfixarna_hosted' : '' }, h("div", { class: "hemfixarna_scripts" }, h("div", { onClick: () => this.copyExample(), class: "hemfixarna_example" }, h("p", null, this.getExample()), h("img", { src: copy, height: 20 }), h("span", { class: "hemfixarna_example--tooltip" }, this.tooltipText)), this.partner === Business.byggmax && (h("hemfixarna-byggmax", { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, forceOldTree: Boolean(process.env.FORCE_OLD_TREE), slug: this.selectedSlug, id: this.selectedID })), this.partner === Business.skanska && h("hemfixarna-skanska", { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }), this.partner === Business.sparfonster && (h("hemfixarna-sparfonster", { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID })), this.partner === Business.string && (h("hemfixarna-string-furniture", { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID })), this.partner === Business.hornbach && (h("hemfixarna-hornbach", { isDemo: true, buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID })), this.partner === Business.traningspartner && (h("hemfixarna-traningspartner", { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID })), this.partner === Business.superfront && (h("hemfixarna-superfront", { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID })), this.partner === Business.zaptec && (h("hemfixarna-zaptec", { isDemo: true, buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID })), this.partner === Business.tesla && (h("hemfixarna-tesla", { isDemo: true, buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID })), this.partner === Business.forebygg && (h("hemfixarna-forebygg", { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID })), this.partner === Business.doro && h("hemfixarna-doro", { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }), this.partner === Business.elfa && h("hemfixarna-elfa", { isDemo: true, buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }), this.partner === Business.kbygg && (h("hemfixarna-kbygg", { isDemo: true, buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID })), this.partner === Business.fargvaruhuset && (h("hemfixarna-fargvaruhuset", { isDemo: true, buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID })), this.partner === Business.norrgavel && (h("hemfixarna-norrgavel", { isDemo: true, buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID })), this.partner === Business.klint && h("hemfixarna-klint", { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }), this.partner === Business.flyttsmart && (h("hemfixarna-flyttsmart", { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID })), this.partner === Business.power && h("hemfixarna-power", { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }), this.partner === Business.kund && h("hemfixarna-kund", { buttonColor: this.buttonColor, buttonBg: this.buttonBg, widgetStyle: this.widgetStyle, id: this.selectedID }), h("div", { class: "hemfixarna_install" }, h("div", { onClick: () => this.copyCdn(), class: "hemfixarna_example" }, h("p", null, this.cdnLink), h("span", { class: "hemfixarna_example--tooltip" }, this.tooltipText), h("img", { src: copy, height: 20 }))), h("div", { class: "hemfixarna_widgetstyles" }, h("h5", null, "Widget styles"), h("div", null, Object.values(WidgetStyle).map(style => (h("label", { key: style }, h("input", { type: "radio", value: style, checked: this.widgetStyle === style, onChange: () => (this.widgetStyle = style) }), style)))), h("div", null, h("div", null, h("h5", null, "Button background color"), h("input", { type: "text", value: this.buttonBg, onInput: e => (this.buttonBg = e.target.value) })), h("div", null, h("h5", null, "Button text color"), h("input", { type: "text", value: this.buttonColor, onInput: e => (this.buttonColor = e.target.value) })))), h("span", null, "Write an hexa code no # needed"), this.colorAccessibility ? (h("div", null, h("h5", null, "Tillg\u00E4nglighetsrapport"), h("div", null, h("strong", null, "Liten text:"), h("span", { style: { color: this.getColor(this.colorAccessibility.small) } }, this.colorAccessibility.small), h("br", null), h("strong", null, "Fet text:"), h("span", { style: { color: this.getColor(this.colorAccessibility.bold) } }, this.colorAccessibility.bold), h("br", null), h("strong", null, "Stor text:"), h("span", { style: { color: this.getColor(this.colorAccessibility.large) } }, this.colorAccessibility.large), h("br", null), h("strong", null, "Kontrastf\u00F6rh\u00E5llande:"), " ", this.colorAccessibility.contrast))) : null), h("ul", { class: "hemfixarna_categories" }, this.customer ? (h("div", null, this.customer.logo ? (h("div", { style: { width: '100%', display: 'flex', justifyContent: 'center' } }, h("img", { style: { maxWidth: '250px', height: 'auto', margin: '0 auto 2rem' }, src: this.customer.logo.url, alt: this.customer.post_title }))) : null, this.showMaleri() ? (h("li", null, h("div", { class: "hemfixarna_categories--label hemfixarna_categories--label--big" }, h("div", null, h("p", null, "M\u00E5leriverktyget"), h("span", null, "maleri")), h("div", null, h("button", { onClick: () => navigator.clipboard.writeText('maleri') }, "Kopiera ID"), this.customer.at_hemfixarna ? (h("button", { onClick: () => { var _a; return navigator.clipboard.writeText(`${(_a = "https://hemfixarna.se") !== null && _a !== void 0 ? _a : 'https://hemfixarna.se'}/partner/${this.customer.post_name}?id=maleri`); } }, "Kopiera URL")) : (h("button", { onClick: () => (this.selectedID = 'maleri') }, "Ladda m\u00E5leri")))))) : null, this.customer.categories.map(c => (h("li", null, h("div", { class: "hemfixarna_categories--label hemfixarna_categories--label--big" }, h("div", null, h("p", null, c.name), h("span", null, `c-${c.id}`)), h("div", null, h("button", { onClick: () => navigator.clipboard.writeText(`c-${c.id}`) }, "Kopiera ID"), this.customer.at_hemfixarna ? (h("button", { onClick: () => { var _a; return navigator.clipboard.writeText(`${(_a = "https://hemfixarna.se") !== null && _a !== void 0 ? _a : 'https://hemfixarna.se'}/partner/${this.customer.post_name}?id=c-${c.id}`); } }, "Kopiera URL")) : (h("button", { onClick: () => (this.selectedID = `c-${c.id}`) }, "Ladda kategori")))), c.show_products && c.products ? (h("ul", null, c.products.map(p => (h("li", null, h("div", { class: "hemfixarna_categories--label hemfixarna_product--label" }, h("div", null, h("p", null, p.fields.title), h("span", null, p.fields.ID)), h("div", null, h("button", { onClick: () => navigator.clipboard.writeText(String(p.fields.ID)) }, "Kopiera ID"), this.customer.at_hemfixarna ? (h("button", { onClick: () => { var _a; return navigator.clipboard.writeText(`${(_a = "https://hemfixarna.se") !== null && _a !== void 0 ? _a : 'https://hemfixarna.se'}/partner/${this.customer.post_name}?id=${p.fields.ID}`); } }, "Kopiera URL")) : (h("button", { onClick: () => (this.selectedID = String(p.fields.ID)) }, "Ladda produkt"))))))))) : (h("ul", null, c.sub_categories &&
1262
+ c.sub_categories.map(sc => (h("li", null, h("div", { class: "hemfixarna_categories--label" }, h("div", null, h("p", null, sc.name), h("span", null, `c-${sc.id}`)), h("div", null, h("button", { onClick: () => navigator.clipboard.writeText(`c-${sc.id}`) }, "Kopiera ID"), this.customer.at_hemfixarna ? (h("button", { onClick: () => { var _a; return navigator.clipboard.writeText(`${(_a = "https://hemfixarna.se") !== null && _a !== void 0 ? _a : 'https://hemfixarna.se'}/partner/${this.customer.post_name}?id=c-${c.id}`); } }, "Kopiera URL")) : (h("button", { onClick: () => (this.selectedID = `c-${sc.id}`) }, "Ladda kategori")))), h("ul", null, sc.products.map(p => (h("li", null, h("div", { class: "hemfixarna_categories--label hemfixarna_product--label" }, h("div", null, h("p", null, p.fields.title), h("span", null, p.fields.ID)), h("div", null, h("button", { onClick: () => navigator.clipboard.writeText(String(p.fields.ID)) }, "Kopiera ID"), this.customer.at_hemfixarna ? (h("button", { onClick: () => { var _a; return navigator.clipboard.writeText(`${(_a = "https://hemfixarna.se") !== null && _a !== void 0 ? _a : 'https://hemfixarna.se'}/partner/${this.customer.post_name}?id=${p.fields.ID}`); } }, "Kopiera URL")) : (h("button", { onClick: () => (this.selectedID = String(p.fields.ID)) }, "Ladda produkt")))))))))))))))))) : this.tree ? (h("div", null, this.tree.sub_cats.map(c => (h("li", null, h("div", { class: "hemfixarna_categories--label hemfixarna_categories--label--big" }, h("div", null, h("p", null, c.name), h("span", null, `category/${c.slug}`)), h("div", null, h("button", { onClick: () => navigator.clipboard.writeText(`category/${c.slug}`) }, "Kopiera slug"), h("button", { onClick: () => (this.selectedSlug = `category/${c.slug}`) }, "Ladda kategori"))), h("ul", null, c.services.map(sc => (h("li", null, h("div", { class: "hemfixarna_categories--label" }, h("div", null, h("p", null, sc.post_title), h("span", null, `service/${sc.post_name}`)), h("div", null, h("button", { onClick: () => navigator.clipboard.writeText(`service/${sc.post_name}`) }, "Kopiera slug"), h("button", { onClick: () => (this.selectedSlug = `service/${sc.post_name}`) }, "Ladda kategori"))), h("ul", null, sc.products.map(sc => (h("li", null, h("div", { class: "hemfixarna_categories--label" }, h("div", null, h("p", null, sc.post_title), h("span", null, `product/${sc.post_name}`)), h("div", null, h("button", { onClick: () => navigator.clipboard.writeText(`product/${sc.post_name}`) }, "Kopiera slug"), h("button", { onClick: () => (this.selectedSlug = `product/${sc.post_name}`) }, "Ladda produkt")))))))))))))))) : null)));
1263
+ }
1264
+ static get watchers() { return {
1265
+ "buttonBg": ["debouncedFunction"],
1266
+ "buttonColor": ["debouncedFunction"]
1267
+ }; }
1268
+ };
1269
+ MyComponent$i.style = hemfixarnaDemoCss;
1270
+
1271
+ const hemfixarnaDoroCss = "";
1272
+
1273
+ const MyComponent$h = class {
1274
+ constructor(hostRef) {
1275
+ registerInstance(this, hostRef);
1276
+ this.id = undefined;
1277
+ this.loadFromQuery = undefined;
1278
+ this.widgetStyle = WidgetStyle.standard;
1279
+ this.buttonColor = undefined;
1280
+ this.buttonBg = undefined;
1281
+ }
1282
+ render() {
1283
+ return (h("hemfixarna-component", { widgetStyle: this.widgetStyle, buttonBg: this.buttonBg, buttonColor: this.buttonColor, loadFromQuery: Boolean(this.loadFromQuery), id: this.id, business: Business.doro }));
1284
+ }
1285
+ };
1286
+ MyComponent$h.style = hemfixarnaDoroCss;
1287
+
1288
+ const hemfixarnaElfaCss = "";
1289
+
1290
+ const MyComponent$g = class {
1291
+ constructor(hostRef) {
1292
+ registerInstance(this, hostRef);
1293
+ this.id = undefined;
1294
+ this.loadFromQuery = 'true';
1295
+ this.widgetStyle = WidgetStyle.standard;
1296
+ this.buttonColor = undefined;
1297
+ this.buttonBg = undefined;
1298
+ this.isDemo = false;
1299
+ }
1300
+ render() {
1301
+ return (h("hemfixarna-component", { widgetStyle: this.widgetStyle, buttonBg: this.buttonBg, buttonColor: this.buttonColor, nav: { url: 'https://elfa.com', logo: 'assets/elfa.png' }, loadFromQuery: Boolean(this.loadFromQuery), id: this.id, business: Business.elfa, isDemo: this.isDemo }));
1302
+ }
1303
+ };
1304
+ MyComponent$g.style = hemfixarnaElfaCss;
1305
+
1306
+ const MyComponent$f = class {
1307
+ constructor(hostRef) {
1308
+ registerInstance(this, hostRef);
1309
+ this.id = undefined;
1310
+ this.loadFromQuery = undefined;
1311
+ this.widgetStyle = WidgetStyle.standard;
1312
+ this.buttonColor = undefined;
1313
+ this.buttonBg = undefined;
1314
+ this.isDemo = false;
1315
+ }
1316
+ render() {
1317
+ return (h("hemfixarna-component", { widgetStyle: this.widgetStyle, buttonBg: this.buttonBg, buttonColor: this.buttonColor, loadFromQuery: Boolean(this.loadFromQuery), id: this.id, business: Business.fargvaruhuset, isDemo: this.isDemo }));
1318
+ }
1319
+ };
1320
+
1321
+ const MyComponent$e = class {
1322
+ constructor(hostRef) {
1323
+ registerInstance(this, hostRef);
1324
+ this.id = undefined;
1325
+ this.loadFromQuery = undefined;
1326
+ this.widgetStyle = WidgetStyle.standard;
1327
+ this.buttonColor = undefined;
1328
+ this.buttonBg = undefined;
1329
+ this.isDemo = false;
1330
+ }
1331
+ render() {
1332
+ return (h("hemfixarna-component", { widgetStyle: this.widgetStyle, buttonBg: this.buttonBg, buttonColor: this.buttonColor, loadFromQuery: Boolean(this.loadFromQuery), id: this.id, business: Business.flyttsmart, isDemo: this.isDemo }));
1333
+ }
1334
+ };
1335
+
1336
+ const hemfixarnaForebyggCss = "";
1337
+
1338
+ const MyComponent$d = class {
1339
+ constructor(hostRef) {
1340
+ registerInstance(this, hostRef);
1341
+ this.id = undefined;
1342
+ this.loadFromQuery = undefined;
1343
+ this.widgetStyle = WidgetStyle.standard;
1344
+ this.buttonColor = undefined;
1345
+ this.buttonBg = undefined;
1346
+ }
1347
+ render() {
1348
+ return (h("hemfixarna-component", { widgetStyle: this.widgetStyle, buttonBg: this.buttonBg, buttonColor: this.buttonColor, loadFromQuery: Boolean(this.loadFromQuery), id: this.id, business: Business.forebygg }));
1349
+ }
1350
+ };
1351
+ MyComponent$d.style = hemfixarnaForebyggCss;
1352
+
1353
+ // src/errors.ts
1354
+ var PersonnummerError = class extends Error {
1355
+ constructor() {
1356
+ super("Invalid swedish personal identity number");
1357
+ }
1358
+ };
1359
+
1360
+ // src/utils.ts
1361
+ var compareAsc = (dateLeft, dateRight) => {
1362
+ const diff = dateLeft.getTime() - dateRight.getTime();
1363
+ return diff < 0 ? -1 : diff > 0 ? 1 : diff;
1364
+ };
1365
+ var diffInYears = (dateLeft, dateRight) => {
1366
+ const sign = compareAsc(dateLeft, dateRight);
1367
+ const yearDiff = Math.abs(dateLeft.getFullYear() - dateRight.getFullYear());
1368
+ dateLeft.setFullYear(dateLeft.getFullYear() - sign * yearDiff);
1369
+ const isLastYearNotFull = compareAsc(dateLeft, dateRight) === -sign;
1370
+ const result = sign * (yearDiff - +isLastYearNotFull);
1371
+ return result === 0 ? 0 : result;
1372
+ };
1373
+ var luhn = (str) => {
1374
+ let sum = 0;
1375
+ str += "";
1376
+ for (let i = 0, l = str.length; i < l; i++) {
1377
+ let v = parseInt(str[i]);
1378
+ v *= 2 - i % 2;
1379
+ if (v > 9) {
1380
+ v -= 9;
1381
+ }
1382
+ sum += v;
1383
+ }
1384
+ return Math.ceil(sum / 10) * 10 - sum;
1385
+ };
1386
+ var testDate = (year, month, day) => {
1387
+ month -= 1;
1388
+ const date = new Date(year, month, day);
1389
+ return !(date.getFullYear() !== year || date.getMonth() !== month || date.getDate() !== day);
1390
+ };
1391
+
1392
+ // src/index.ts
1393
+ var Personnummer = class {
1394
+ /**
1395
+ * Personnummer constructor.
1396
+ *
1397
+ * @param {string} pin
1398
+ * @param {object} options
1399
+ */
1400
+ constructor(pin, options) {
1401
+ /**
1402
+ * Personnummer century.
1403
+ *
1404
+ * @var {string}
1405
+ */
1406
+ this._century = "";
1407
+ /**
1408
+ * Personnummer full year.
1409
+ *
1410
+ * @var {string}
1411
+ */
1412
+ this._fullYear = "";
1413
+ /**
1414
+ * Personnummer year.
1415
+ *
1416
+ * @var {string}
1417
+ */
1418
+ this._year = "";
1419
+ /**
1420
+ * Personnummer month.
1421
+ *
1422
+ * @var {string}
1423
+ */
1424
+ this._month = "";
1425
+ /**
1426
+ * Personnummer day.
1427
+ *
1428
+ * @var {string}
1429
+ */
1430
+ this._day = "";
1431
+ /**
1432
+ * Personnummer seperator.
1433
+ *
1434
+ * @var {string}
1435
+ */
1436
+ this._sep = "";
1437
+ /**
1438
+ * Personnumer first three of the last four numbers.
1439
+ *
1440
+ * @var {string}
1441
+ */
1442
+ this._num = "";
1443
+ /**
1444
+ * The last number of the personnummer.
1445
+ *
1446
+ * @var {string}
1447
+ */
1448
+ this._check = "";
1449
+ this.parse(pin, {
1450
+ allowCoordinationNumber: true,
1451
+ allowInterimNumber: false,
1452
+ ...options
1453
+ });
1454
+ }
1455
+ /**
1456
+ * Get century.
1457
+ *
1458
+ * @return {string}
1459
+ */
1460
+ get century() {
1461
+ return this._century;
1462
+ }
1463
+ /**
1464
+ * Get age.
1465
+ *
1466
+ * @return {string}
1467
+ */
1468
+ get fullYear() {
1469
+ return this._fullYear;
1470
+ }
1471
+ /**
1472
+ * Get age.
1473
+ *
1474
+ * @return {string}
1475
+ */
1476
+ get year() {
1477
+ return this._year;
1478
+ }
1479
+ /**
1480
+ * Get month.
1481
+ *
1482
+ * @return {string}
1483
+ */
1484
+ get month() {
1485
+ return this._month;
1486
+ }
1487
+ /**
1488
+ * Get day.
1489
+ *
1490
+ * @return {string}
1491
+ */
1492
+ get day() {
1493
+ return this._day;
1494
+ }
1495
+ /**
1496
+ * Get sep.
1497
+ *
1498
+ * @return {string}
1499
+ */
1500
+ get sep() {
1501
+ return this._sep;
1502
+ }
1503
+ /**
1504
+ * Get num.
1505
+ *
1506
+ * @return {string}
1507
+ */
1508
+ get num() {
1509
+ return this._num;
1510
+ }
1511
+ /**
1512
+ * Get check.
1513
+ *
1514
+ * @return {string}
1515
+ */
1516
+ get check() {
1517
+ return this._check;
1518
+ }
1519
+ /**
1520
+ * Parse personnummer.
1521
+ *
1522
+ * @param {string} pin
1523
+ * @param {object} options
1524
+ *
1525
+ * @return {Personnummer}
1526
+ */
1527
+ static parse(pin, options) {
1528
+ return new Personnummer(pin, options);
1529
+ }
1530
+ /**
1531
+ * Validate a Swedish personal identity number.
1532
+ *
1533
+ * @param {string} str
1534
+ * @param {object} options
1535
+ *
1536
+ * @return {boolean}
1537
+ */
1538
+ static valid(pin, options) {
1539
+ try {
1540
+ Personnummer.parse(pin, options);
1541
+ return true;
1542
+ } catch (e) {
1543
+ return false;
1544
+ }
1545
+ }
1546
+ /**
1547
+ * Parse personnummer and set class properties.
1548
+ *
1549
+ * @param {string} pin
1550
+ * @param {object} options
1551
+ */
1552
+ parse(pin, options) {
1553
+ if (pin.length < 10 || pin.length > 13) {
1554
+ throw new PersonnummerError();
1555
+ }
1556
+ const reg = /^(\d{2}){0,1}(\d{2})(\d{2})(\d{2})([+-]?)((?!000)\d{3}|[TRSUWXJKLMN]\d{2})(\d)$/;
1557
+ const match = reg.exec(pin);
1558
+ if (!match) {
1559
+ throw new PersonnummerError();
1560
+ }
1561
+ const century = match[1];
1562
+ const year = match[2];
1563
+ const month = match[3];
1564
+ const day = match[4];
1565
+ const sep = match[5];
1566
+ const num = match[6];
1567
+ const check = match[7];
1568
+ if (typeof century === "undefined" || !century.length) {
1569
+ const d = /* @__PURE__ */ new Date();
1570
+ let baseYear = 0;
1571
+ if (sep === "+") {
1572
+ this._sep = "+";
1573
+ baseYear = d.getFullYear() - 100;
1574
+ } else {
1575
+ this._sep = "-";
1576
+ baseYear = d.getFullYear();
1577
+ }
1578
+ this._century = ("" + (baseYear - (baseYear - parseInt(year)) % 100)).substr(0, 2);
1579
+ } else {
1580
+ this._century = century;
1581
+ if ((/* @__PURE__ */ new Date()).getFullYear() - parseInt(century + year, 10) < 100) {
1582
+ this._sep = "-";
1583
+ } else {
1584
+ this._sep = "+";
1585
+ }
1586
+ }
1587
+ this._year = year;
1588
+ this._fullYear = this._century + year;
1589
+ this._month = month;
1590
+ this._day = day;
1591
+ this._num = num;
1592
+ this._check = check;
1593
+ if (!this.valid()) {
1594
+ throw new PersonnummerError();
1595
+ }
1596
+ if (!(options == null ? void 0 : options.allowCoordinationNumber) && this.isCoordinationNumber()) {
1597
+ throw new PersonnummerError();
1598
+ }
1599
+ if (!(options == null ? void 0 : options.allowInterimNumber) && this.isInterimNumber()) {
1600
+ throw new PersonnummerError();
1601
+ }
1602
+ }
1603
+ /**
1604
+ * Validate a Swedish personal identity number.
1605
+ *
1606
+ * @return {boolean}
1607
+ */
1608
+ valid() {
1609
+ const valid = luhn(
1610
+ this.year + this.month + this.day + this.num.replace(/[TRSUWXJKLMN]/, "1")
1611
+ ) === +this.check && !!this.check;
1612
+ if (valid && testDate(parseInt(this.century + this.year), +this.month, +this.day)) {
1613
+ return valid;
1614
+ }
1615
+ return valid && testDate(parseInt(this.century + this.year), +this.month, +this.day - 60);
1616
+ }
1617
+ /**
1618
+ * Format a Swedish personal identity number as one of the official formats,
1619
+ * A long format or a short format.
1620
+ *
1621
+ * If the input number could not be parsed a empty string will be returned.
1622
+ *
1623
+ * @param {boolean} longFormat
1624
+ *
1625
+ * @return {string}
1626
+ */
1627
+ format(longFormat = false) {
1628
+ if (longFormat) {
1629
+ return `${this.century}${this.year}${this.month}${this.day}${this.num}${this.check}`;
1630
+ }
1631
+ return `${this.year}${this.month}${this.day}${this.sep}${this.num}${this.check}`;
1632
+ }
1633
+ /**
1634
+ * Get age from a Swedish personal identity number.
1635
+ *
1636
+ * @return {number}
1637
+ */
1638
+ getAge() {
1639
+ const date = this.getDate();
1640
+ return diffInYears(new Date(Date.now()), date);
1641
+ }
1642
+ /**
1643
+ * Get date from a Swedish personal identity number.
1644
+ *
1645
+ * @return {Date}
1646
+ */
1647
+ getDate() {
1648
+ let ageDay = +this.day;
1649
+ if (this.isCoordinationNumber()) {
1650
+ ageDay -= 60;
1651
+ }
1652
+ const ageDate = this.century + this.year + "-" + this.month + "-" + (ageDay < 10 ? "0" + ageDay : ageDay);
1653
+ return new Date(ageDate);
1654
+ }
1655
+ /**
1656
+ * Check if a Swedish personal identity number is a interim number or not.
1657
+ *
1658
+ * @return {boolean}
1659
+ */
1660
+ isInterimNumber() {
1661
+ return /[TRSUWXJKLMN]/.test(this.num[0]);
1662
+ }
1663
+ /**
1664
+ * Check if a Swedish personal identity number is a coordination number or not.
1665
+ *
1666
+ * @return {boolean}
1667
+ */
1668
+ isCoordinationNumber() {
1669
+ return testDate(
1670
+ parseInt(this.century + this.year),
1671
+ +this.month,
1672
+ +this.day - 60
1673
+ );
1674
+ }
1675
+ /**
1676
+ * Check if a Swedish personal identity number is for a female.
1677
+ *
1678
+ * @return {boolean}
1679
+ */
1680
+ isFemale() {
1681
+ return !this.isMale();
1682
+ }
1683
+ /**
1684
+ * Check if a Swedish personal identity number is for a male.
1685
+ *
1686
+ * @return {boolean}
1687
+ */
1688
+ isMale() {
1689
+ const sexDigit = parseInt(this.num.substr(-1));
1690
+ return sexDigit % 2 === 1;
1691
+ }
1692
+ };
1693
+ var src_default = Personnummer;
1694
+
1695
+ function createCommonjsModule(fn, basedir, module) {
1696
+ return module = {
1697
+ path: basedir,
1698
+ exports: {},
1699
+ require: function (path, base) {
1700
+ return commonjsRequire();
1701
+ }
1702
+ }, fn(module, module.exports), module.exports;
1703
+ }
1704
+
1705
+ function commonjsRequire () {
1706
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
1707
+ }
1708
+
1709
+ var utf8 = createCommonjsModule(function (module, exports) {
1710
+ // tslint:disable:no-bitwise
1711
+ Object.defineProperty(exports, "__esModule", { value: true });
1712
+ exports.utf8 = void 0;
1713
+ exports.utf8 = {
1714
+ encode: encode,
1715
+ decode: decode,
1716
+ };
1717
+ function encode(unicodeText) {
1718
+ unicodeText = unicodeText.replace(/\r\n/g, "\n");
1719
+ var result = "";
1720
+ for (var i = 0; i < unicodeText.length; i++) {
1721
+ var char = unicodeText.charCodeAt(i);
1722
+ if (char < 128) {
1723
+ result += String.fromCharCode(char);
1724
+ }
1725
+ else if (char > 127 && char < 2048) {
1726
+ result += String.fromCharCode((char >> 6) | 192);
1727
+ result += String.fromCharCode((char & 63) | 128);
1728
+ }
1729
+ else {
1730
+ result += String.fromCharCode((char >> 12) | 224);
1731
+ result += String.fromCharCode(((char >> 6) & 63) | 128);
1732
+ result += String.fromCharCode((char & 63) | 128);
1733
+ }
1734
+ }
1735
+ return result;
1736
+ }
1737
+ function decode(utf8Text) {
1738
+ var result = "";
1739
+ var i = 0;
1740
+ var char1 = 0;
1741
+ var char2 = 0;
1742
+ var char3 = 0;
1743
+ while (i < utf8Text.length) {
1744
+ char1 = utf8Text.charCodeAt(i);
1745
+ if (char1 < 128) {
1746
+ result += String.fromCharCode(char1);
1747
+ i++;
1748
+ }
1749
+ else if (char1 > 191 && char1 < 224) {
1750
+ char2 = utf8Text.charCodeAt(i + 1);
1751
+ result += String.fromCharCode(((char1 & 31) << 6) | (char2 & 63));
1752
+ i += 2;
1753
+ }
1754
+ else {
1755
+ char2 = utf8Text.charCodeAt(i + 1);
1756
+ char3 = utf8Text.charCodeAt(i + 2);
1757
+ result += String.fromCharCode(((char1 & 15) << 12) | ((char2 & 63) << 6) | (char3 & 63));
1758
+ i += 3;
1759
+ }
1760
+ }
1761
+ return result;
1762
+ }
1763
+ });
1764
+
1765
+ var md5 = createCommonjsModule(function (module, exports) {
1766
+ // tslint:disable:no-bitwise
1767
+ Object.defineProperty(exports, "__esModule", { value: true });
1768
+ exports.generate = void 0;
1769
+
1770
+ function generate(unicodeText) {
1771
+ var x = [];
1772
+ var k;
1773
+ var AA;
1774
+ var BB;
1775
+ var CC;
1776
+ var DD;
1777
+ var a;
1778
+ var b;
1779
+ var c;
1780
+ var d;
1781
+ var S11 = 7;
1782
+ var S12 = 12;
1783
+ var S13 = 17;
1784
+ var S14 = 22;
1785
+ var S21 = 5;
1786
+ var S22 = 9;
1787
+ var S23 = 14;
1788
+ var S24 = 20;
1789
+ var S31 = 4;
1790
+ var S32 = 11;
1791
+ var S33 = 16;
1792
+ var S34 = 23;
1793
+ var S41 = 6;
1794
+ var S42 = 10;
1795
+ var S43 = 15;
1796
+ var S44 = 21;
1797
+ var utf8Text = utf8.utf8.encode(unicodeText);
1798
+ x = convertToWordArray(utf8Text);
1799
+ a = 0x67452301;
1800
+ b = 0xefcdab89;
1801
+ c = 0x98badcfe;
1802
+ d = 0x10325476;
1803
+ for (k = 0; k < x.length; k += 16) {
1804
+ AA = a;
1805
+ BB = b;
1806
+ CC = c;
1807
+ DD = d;
1808
+ a = FF(a, b, c, d, x[k + 0], S11, 0xd76aa478);
1809
+ d = FF(d, a, b, c, x[k + 1], S12, 0xe8c7b756);
1810
+ c = FF(c, d, a, b, x[k + 2], S13, 0x242070db);
1811
+ b = FF(b, c, d, a, x[k + 3], S14, 0xc1bdceee);
1812
+ a = FF(a, b, c, d, x[k + 4], S11, 0xf57c0faf);
1813
+ d = FF(d, a, b, c, x[k + 5], S12, 0x4787c62a);
1814
+ c = FF(c, d, a, b, x[k + 6], S13, 0xa8304613);
1815
+ b = FF(b, c, d, a, x[k + 7], S14, 0xfd469501);
1816
+ a = FF(a, b, c, d, x[k + 8], S11, 0x698098d8);
1817
+ d = FF(d, a, b, c, x[k + 9], S12, 0x8b44f7af);
1818
+ c = FF(c, d, a, b, x[k + 10], S13, 0xffff5bb1);
1819
+ b = FF(b, c, d, a, x[k + 11], S14, 0x895cd7be);
1820
+ a = FF(a, b, c, d, x[k + 12], S11, 0x6b901122);
1821
+ d = FF(d, a, b, c, x[k + 13], S12, 0xfd987193);
1822
+ c = FF(c, d, a, b, x[k + 14], S13, 0xa679438e);
1823
+ b = FF(b, c, d, a, x[k + 15], S14, 0x49b40821);
1824
+ a = GG(a, b, c, d, x[k + 1], S21, 0xf61e2562);
1825
+ d = GG(d, a, b, c, x[k + 6], S22, 0xc040b340);
1826
+ c = GG(c, d, a, b, x[k + 11], S23, 0x265e5a51);
1827
+ b = GG(b, c, d, a, x[k + 0], S24, 0xe9b6c7aa);
1828
+ a = GG(a, b, c, d, x[k + 5], S21, 0xd62f105d);
1829
+ d = GG(d, a, b, c, x[k + 10], S22, 0x2441453);
1830
+ c = GG(c, d, a, b, x[k + 15], S23, 0xd8a1e681);
1831
+ b = GG(b, c, d, a, x[k + 4], S24, 0xe7d3fbc8);
1832
+ a = GG(a, b, c, d, x[k + 9], S21, 0x21e1cde6);
1833
+ d = GG(d, a, b, c, x[k + 14], S22, 0xc33707d6);
1834
+ c = GG(c, d, a, b, x[k + 3], S23, 0xf4d50d87);
1835
+ b = GG(b, c, d, a, x[k + 8], S24, 0x455a14ed);
1836
+ a = GG(a, b, c, d, x[k + 13], S21, 0xa9e3e905);
1837
+ d = GG(d, a, b, c, x[k + 2], S22, 0xfcefa3f8);
1838
+ c = GG(c, d, a, b, x[k + 7], S23, 0x676f02d9);
1839
+ b = GG(b, c, d, a, x[k + 12], S24, 0x8d2a4c8a);
1840
+ a = HH(a, b, c, d, x[k + 5], S31, 0xfffa3942);
1841
+ d = HH(d, a, b, c, x[k + 8], S32, 0x8771f681);
1842
+ c = HH(c, d, a, b, x[k + 11], S33, 0x6d9d6122);
1843
+ b = HH(b, c, d, a, x[k + 14], S34, 0xfde5380c);
1844
+ a = HH(a, b, c, d, x[k + 1], S31, 0xa4beea44);
1845
+ d = HH(d, a, b, c, x[k + 4], S32, 0x4bdecfa9);
1846
+ c = HH(c, d, a, b, x[k + 7], S33, 0xf6bb4b60);
1847
+ b = HH(b, c, d, a, x[k + 10], S34, 0xbebfbc70);
1848
+ a = HH(a, b, c, d, x[k + 13], S31, 0x289b7ec6);
1849
+ d = HH(d, a, b, c, x[k + 0], S32, 0xeaa127fa);
1850
+ c = HH(c, d, a, b, x[k + 3], S33, 0xd4ef3085);
1851
+ b = HH(b, c, d, a, x[k + 6], S34, 0x4881d05);
1852
+ a = HH(a, b, c, d, x[k + 9], S31, 0xd9d4d039);
1853
+ d = HH(d, a, b, c, x[k + 12], S32, 0xe6db99e5);
1854
+ c = HH(c, d, a, b, x[k + 15], S33, 0x1fa27cf8);
1855
+ b = HH(b, c, d, a, x[k + 2], S34, 0xc4ac5665);
1856
+ a = II(a, b, c, d, x[k + 0], S41, 0xf4292244);
1857
+ d = II(d, a, b, c, x[k + 7], S42, 0x432aff97);
1858
+ c = II(c, d, a, b, x[k + 14], S43, 0xab9423a7);
1859
+ b = II(b, c, d, a, x[k + 5], S44, 0xfc93a039);
1860
+ a = II(a, b, c, d, x[k + 12], S41, 0x655b59c3);
1861
+ d = II(d, a, b, c, x[k + 3], S42, 0x8f0ccc92);
1862
+ c = II(c, d, a, b, x[k + 10], S43, 0xffeff47d);
1863
+ b = II(b, c, d, a, x[k + 1], S44, 0x85845dd1);
1864
+ a = II(a, b, c, d, x[k + 8], S41, 0x6fa87e4f);
1865
+ d = II(d, a, b, c, x[k + 15], S42, 0xfe2ce6e0);
1866
+ c = II(c, d, a, b, x[k + 6], S43, 0xa3014314);
1867
+ b = II(b, c, d, a, x[k + 13], S44, 0x4e0811a1);
1868
+ a = II(a, b, c, d, x[k + 4], S41, 0xf7537e82);
1869
+ d = II(d, a, b, c, x[k + 11], S42, 0xbd3af235);
1870
+ c = II(c, d, a, b, x[k + 2], S43, 0x2ad7d2bb);
1871
+ b = II(b, c, d, a, x[k + 9], S44, 0xeb86d391);
1872
+ a = addUnsigned(a, AA);
1873
+ b = addUnsigned(b, BB);
1874
+ c = addUnsigned(c, CC);
1875
+ d = addUnsigned(d, DD);
1876
+ }
1877
+ return wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d);
1878
+ }
1879
+ exports.generate = generate;
1880
+ function rotateLeft(lValue, iShiftBits) {
1881
+ return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
1882
+ }
1883
+ function addUnsigned(lX, lY) {
1884
+ var lX4;
1885
+ var lY4;
1886
+ var lX8;
1887
+ var lY8;
1888
+ var lResult;
1889
+ lX8 = lX & 0x80000000;
1890
+ lY8 = lY & 0x80000000;
1891
+ lX4 = lX & 0x40000000;
1892
+ lY4 = lY & 0x40000000;
1893
+ lResult = (lX & 0x3fffffff) + (lY & 0x3fffffff);
1894
+ if (lX4 & lY4) {
1895
+ return lResult ^ 0x80000000 ^ lX8 ^ lY8;
1896
+ }
1897
+ if (lX4 | lY4) {
1898
+ if (lResult & 0x40000000) {
1899
+ return lResult ^ 0xc0000000 ^ lX8 ^ lY8;
1900
+ }
1901
+ else {
1902
+ return lResult ^ 0x40000000 ^ lX8 ^ lY8;
1903
+ }
1904
+ }
1905
+ else {
1906
+ return lResult ^ lX8 ^ lY8;
1907
+ }
1908
+ }
1909
+ function F(x, y, z) {
1910
+ return (x & y) | (~x & z);
1911
+ }
1912
+ function G(x, y, z) {
1913
+ return (x & z) | (y & ~z);
1914
+ }
1915
+ function H(x, y, z) {
1916
+ return x ^ y ^ z;
1917
+ }
1918
+ function I(x, y, z) {
1919
+ return y ^ (x | ~z);
1920
+ }
1921
+ function FF(a, b, c, d, x, s, ac) {
1922
+ a = addUnsigned(a, addUnsigned(addUnsigned(F(b, c, d), x), ac));
1923
+ return addUnsigned(rotateLeft(a, s), b);
1924
+ }
1925
+ function GG(a, b, c, d, x, s, ac) {
1926
+ a = addUnsigned(a, addUnsigned(addUnsigned(G(b, c, d), x), ac));
1927
+ return addUnsigned(rotateLeft(a, s), b);
1928
+ }
1929
+ function HH(a, b, c, d, x, s, ac) {
1930
+ a = addUnsigned(a, addUnsigned(addUnsigned(H(b, c, d), x), ac));
1931
+ return addUnsigned(rotateLeft(a, s), b);
1932
+ }
1933
+ function II(a, b, c, d, x, s, ac) {
1934
+ a = addUnsigned(a, addUnsigned(addUnsigned(I(b, c, d), x), ac));
1935
+ return addUnsigned(rotateLeft(a, s), b);
1936
+ }
1937
+ function convertToWordArray(value) {
1938
+ var lWordCount;
1939
+ var lMessageLength = value.length;
1940
+ var lNumberOfWordsTemp1 = lMessageLength + 8;
1941
+ var lNumberOfWordsTemp2 = (lNumberOfWordsTemp1 - (lNumberOfWordsTemp1 % 64)) / 64;
1942
+ var lNumberOfWords = (lNumberOfWordsTemp2 + 1) * 16;
1943
+ var lWordArray = Array(lNumberOfWords - 1);
1944
+ var lBytePosition = 0;
1945
+ var lByteCount = 0;
1946
+ while (lByteCount < lMessageLength) {
1947
+ lWordCount = (lByteCount - (lByteCount % 4)) / 4;
1948
+ lBytePosition = (lByteCount % 4) * 8;
1949
+ lWordArray[lWordCount] =
1950
+ lWordArray[lWordCount] | (value.charCodeAt(lByteCount) << lBytePosition);
1951
+ lByteCount++;
1952
+ }
1953
+ lWordCount = (lByteCount - (lByteCount % 4)) / 4;
1954
+ lBytePosition = (lByteCount % 4) * 8;
1955
+ lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
1956
+ lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
1957
+ lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
1958
+ return lWordArray;
1959
+ }
1960
+ function wordToHex(lValue) {
1961
+ var wordToHexValue = "";
1962
+ var wordToHexValueTemp = "";
1963
+ var lByte;
1964
+ var lCount;
1965
+ for (lCount = 0; lCount <= 3; lCount++) {
1966
+ lByte = (lValue >>> (lCount * 8)) & 255;
1967
+ wordToHexValueTemp = "0" + lByte.toString(16);
1968
+ wordToHexValue =
1969
+ wordToHexValue + wordToHexValueTemp.substr(wordToHexValueTemp.length - 2, 2);
1970
+ }
1971
+ return wordToHexValue;
1972
+ }
1973
+ });
1974
+
1975
+ var lib = createCommonjsModule(function (module, exports) {
1976
+ Object.defineProperty(exports, "__esModule", { value: true });
1977
+ exports.MD5 = exports.generate = void 0;
1978
+
1979
+ var md5_2 = md5;
1980
+ Object.defineProperty(exports, "generate", { enumerable: true, get: function () { return md5_2.generate; } });
1981
+ exports.MD5 = {
1982
+ generate: md5.generate,
1983
+ };
1984
+ });
1985
+
1986
+ const apiSearch = async (query) => {
1987
+ var _a;
1988
+ const res = await fetch((_a = "https://hemfixare-lookup.vercel.app/api") !== null && _a !== void 0 ? _a : 'https://hemfixare-lookup.vercel.app/api', {
1989
+ method: 'POST',
1990
+ headers: {
1991
+ 'Content-Type': 'application/json',
1992
+ },
1993
+ body: JSON.stringify({
1994
+ query,
1995
+ hash: lib.MD5.generate(String.fromCharCode(83, 101, 67, 82, 101, 116) + query),
1996
+ }),
1997
+ });
1998
+ const data = await res.json();
1999
+ return data;
2000
+ };
2001
+
2002
+ const HemfixarnaGetuser = class {
2003
+ constructor(hostRef) {
2004
+ registerInstance(this, hostRef);
2005
+ this.handleChangeEmail = (e) => {
2006
+ this.emailError = null;
2007
+ this.email = e.target.value;
2008
+ };
2009
+ this.handleChangePhone = (e) => {
2010
+ this.phoneError = null;
2011
+ this.phone = e.target.value;
2012
+ };
2013
+ this.handleChangessn = (e) => {
2014
+ this.ssnError = null;
2015
+ this.ssn = e.target.value;
2016
+ };
2017
+ this.handleSubmit = async (e) => {
2018
+ e.preventDefault();
2019
+ const emailRegex = new RegExp(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
2020
+ const validEmail = emailRegex.test(this.email);
2021
+ if (!validEmail) {
2022
+ this.emailError = 'Ange en giltig e-postadress';
2023
+ }
2024
+ const validPhone = /^[\d\s()+-]{6,}$/.test(this.phone);
2025
+ if (!validPhone) {
2026
+ this.phoneError = 'Ange ett giltigt telefonnummer';
2027
+ }
2028
+ const validssn = src_default.valid(this.ssn);
2029
+ if (!validssn) {
2030
+ this.ssnError = 'Ange ett giltigt personnummer';
2031
+ }
2032
+ else if (validssn) {
2033
+ const pn = src_default.parse(this.ssn).format(true);
2034
+ this.ssn = [pn.slice(0, 8), '-', pn.slice(8)].join('');
2035
+ }
2036
+ if (validEmail && validPhone && validssn) {
2037
+ try {
2038
+ const creditSafeData = await apiSearch(this.ssn);
2039
+ if (creditSafeData) {
2040
+ state.creditSafeUser = creditSafeData;
2041
+ state.checkoutStep = 2;
2042
+ state.user = Object.assign(Object.assign({}, creditSafeData), { email: this.email, phone: this.phone, ssn: this.ssn });
2043
+ }
2044
+ else {
2045
+ this.ssnError = 'Vi kunde tyvärr inte hitta en address med ditt angivna personnummer';
2046
+ }
2047
+ }
2048
+ catch (e) {
2049
+ this.ssnError = 'Vi kunde tyvärr inte hitta en address med ditt angivna personnummer';
2050
+ console.log(e);
2051
+ }
2052
+ finally {
2053
+ const el = this.el.closest('.hemfixarna_content');
2054
+ scrollToTop(el);
2055
+ }
2056
+ }
2057
+ };
2058
+ this.render = () => {
2059
+ return (h("form", { class: "mb-2", onSubmit: e => this.handleSubmit(e) }, h("div", null, h("input", { class: `${this.email.length ? 'input_active' : ''}`, onChange: e => this.handleChangeEmail(e), type: "email", name: "email", value: this.email }), h("label", { htmlFor: "email" }, "E-post ")), this.emailError && h("span", null, this.emailError), h("div", null, h("input", { class: `${this.phone.length ? 'input_active' : ''}`, onChange: e => this.handleChangePhone(e), type: "tel", name: "phone", value: this.phone }), h("label", { htmlFor: "phone" }, "Mobiltelefon ")), this.phoneError && h("span", null, this.phoneError), h("div", null, h("input", { class: `${this.ssn.length ? 'input_active' : ''}`, onChange: e => this.handleChangessn(e), type: "tel", name: "ssn", value: this.ssn }), h("label", { htmlFor: "phone" }, "Personnummer*")), this.ssnError && h("span", null, this.ssnError), h("input", { type: "submit", value: "Forts\u00E4tt*" }), h("p", null, "*Vi h\u00E4mtar din adress")));
2060
+ };
2061
+ this.email = '';
2062
+ this.emailError = null;
2063
+ this.phone = '';
2064
+ this.phoneError = null;
2065
+ this.ssn = '';
2066
+ this.ssnError = null;
2067
+ }
2068
+ componentWillLoad() {
2069
+ if (state.user) {
2070
+ this.email = state.user.email;
2071
+ this.phone = state.user.phone;
2072
+ this.ssn = state.user.ssn;
2073
+ }
2074
+ }
2075
+ get el() { return getElement(this); }
2076
+ };
2077
+
2078
+ const hemfixarnaHornbachCss = "";
2079
+
2080
+ const MyComponent$c = class {
2081
+ constructor(hostRef) {
2082
+ registerInstance(this, hostRef);
2083
+ this.id = undefined;
2084
+ this.loadFromQuery = 'true';
2085
+ this.isDemo = false;
2086
+ this.widgetStyle = WidgetStyle.standard;
2087
+ this.buttonColor = undefined;
2088
+ this.buttonBg = undefined;
2089
+ }
2090
+ render() {
2091
+ return (h("hemfixarna-component", { widgetStyle: this.widgetStyle, buttonBg: this.buttonBg, buttonColor: this.buttonColor, nav: { url: 'https://www.hornbach.se/', logo: 'assets/hornbach/logo.svg', background: './assets/hornbach/nav.jpg' }, isDemo: this.isDemo, loadFromQuery: Boolean(this.loadFromQuery), id: this.id, business: Business.hornbach }));
2092
+ }
2093
+ };
2094
+ MyComponent$c.style = hemfixarnaHornbachCss;
2095
+
2096
+ const HemfixarnaInfo = class {
2097
+ constructor(hostRef) {
2098
+ registerInstance(this, hostRef);
2099
+ this.logo = getAssetPath(`./assets/hemfixarna.svg`);
2100
+ }
2101
+ render() {
2102
+ var _a;
2103
+ const checked = getAssetPath(`./assets/checked.svg`);
2104
+ return (h("div", { class: "hemfixarna_info" }, 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)), h("ul", { class: "hemfixarna_features" }, state.step < 5 ? (h(Fragment, null, ((_a = state.customer.trust_badges) === null || _a === void 0 ? void 0 : _a.length) ? (h(Fragment, null, state.customer.trust_badges.map(l => (h("li", { key: l.text }, h("img", { src: checked, alt: "checked" }), h("p", null, l.text)))))) : (h(Fragment, null, state.options.trust.map(l => (h("li", { key: l.trust_badge }, h("img", { src: checked, alt: "checked" }), h("p", null, l.trust_badge)))))))) : (h(Fragment, null, state.customer.checkout_trust_badges.map(l => (h("li", { key: l.text }, h("img", { src: checked, alt: "checked" }), h("p", null, l.text))))))), h("img", { src: this.logo, width: 200, alt: "hemfixarna" }), h("a", { class: "hemfixarna_product--link", target: "_blank", href: state.options.link.url }, state.options.link.title)));
2105
+ }
2106
+ };
2107
+
2108
+ const hemfixarnaInvoiceCss = ":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}";
2109
+
2110
+ const base = `${"https://hemfixarna.se"}/wp-json/headless` ;
2111
+ const HemfixarnaInvoice = class {
2112
+ constructor(hostRef) {
2113
+ registerInstance(this, hostRef);
2114
+ this.formError = null;
2115
+ this.displayImages = [];
2116
+ this.formImages = [];
2117
+ this.formState = 'initial';
2118
+ }
2119
+ isValidEmail(email) {
2120
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
2121
+ return emailRegex.test(email);
2122
+ }
2123
+ componentDidRender() {
2124
+ const form = this.el.querySelector('form');
2125
+ if (form) {
2126
+ form.addEventListener('input', () => {
2127
+ this.formError = null;
2128
+ });
2129
+ }
2130
+ }
2131
+ disconnectedCallback() {
2132
+ const form = this.el.querySelector('form');
2133
+ if (form) {
2134
+ form.removeEventListener('input', () => {
2135
+ this.formError = null;
2136
+ });
2137
+ }
2138
+ }
2139
+ async submit(e) {
2140
+ var _a;
2141
+ e.preventDefault();
2142
+ this.formState = 'loading';
2143
+ this.formError = null;
2144
+ const form = e.currentTarget.elements;
2145
+ const values = {
2146
+ description: form.descriptionInput.value.length ? form.descriptionInput.value : null,
2147
+ email: form.emailInput.value.length ? form.emailInput.value : null,
2148
+ tel: form.telInput.value.length ? form.telInput.value : null,
2149
+ terms: (_a = form.termsInput) === null || _a === void 0 ? void 0 : _a.checked,
2150
+ };
2151
+ if (!values.description) {
2152
+ this.formError = 'Vänligen fyll i formulärtexten';
2153
+ this.formState = 'initial';
2154
+ return;
2155
+ }
2156
+ if (!values.email || !this.isValidEmail(values.email)) {
2157
+ this.formError = 'Vänligen ange en giltig e-postadress';
2158
+ this.formState = 'initial';
2159
+ return;
2160
+ }
2161
+ if (!values.tel) {
2162
+ this.formError = 'Vänligen ange ditt telefonnummer';
2163
+ this.formState = 'initial';
2164
+ return;
2165
+ }
2166
+ if (state.selectedProduct.terms_show_checkbox && !values.terms) {
2167
+ this.formError = 'Vänligen acceptera villkoren';
2168
+ this.formState = 'initial';
2169
+ return;
2170
+ }
2171
+ const formData = new FormData();
2172
+ formData.append('text', values.description);
2173
+ formData.append('email', values.email);
2174
+ formData.append('phone', values.tel);
2175
+ formData.append('customer', state.business);
2176
+ this.formImages.forEach(file => {
2177
+ formData.append('images[]', file);
2178
+ });
2179
+ formData.append('product', JSON.stringify({
2180
+ title: state.selectedProduct.title,
2181
+ amount: 1,
2182
+ has_rut: state.selectedProduct.rut,
2183
+ has_rot: state.selectedProduct.rot,
2184
+ has_green: state.selectedProduct.green,
2185
+ ID: state.selectedProduct.ID,
2186
+ parts: [],
2187
+ }));
2188
+ try {
2189
+ const res = await fetch(`${base}/saveinvoiceproduct`, {
2190
+ method: 'POST',
2191
+ body: formData,
2192
+ });
2193
+ const { response } = await res.json();
2194
+ if (response.code === 200) {
2195
+ state.checkoutInvoice = true;
2196
+ state.step = 6;
2197
+ }
2198
+ else {
2199
+ this.formError = 'Vi kan inte ta emot din beställning just nu';
2200
+ this.formState = 'initial';
2201
+ }
2202
+ }
2203
+ catch (error) {
2204
+ this.formError = 'Vi kan inte ta emot din beställning just nu';
2205
+ this.formState = 'initial';
2206
+ }
2207
+ }
2208
+ handleImageDrop(e) {
2209
+ e.preventDefault();
2210
+ const files = e.dataTransfer.files;
2211
+ for (let i = 0; i < files.length; i++) {
2212
+ const file = files[i];
2213
+ if (file.type.startsWith('image/')) {
2214
+ const reader = new FileReader();
2215
+ reader.onload = () => {
2216
+ this.displayImages = [...this.displayImages, reader.result];
2217
+ this.formImages = [...this.formImages, file];
2218
+ };
2219
+ reader.readAsDataURL(file);
2220
+ }
2221
+ }
2222
+ }
2223
+ handleFileInputChange(e) {
2224
+ e.preventDefault();
2225
+ const files = e.target.files;
2226
+ for (let i = 0; i < files.length; i++) {
2227
+ const file = files[i];
2228
+ if (file.type.startsWith('image/')) {
2229
+ const reader = new FileReader();
2230
+ reader.onload = () => {
2231
+ this.displayImages = [...this.displayImages, reader.result];
2232
+ this.formImages = [...this.formImages, file];
2233
+ };
2234
+ reader.readAsDataURL(file);
2235
+ }
2236
+ }
2237
+ }
2238
+ handleImageClick() {
2239
+ this.el.querySelector('.hemfixarna-file-upload').click();
2240
+ }
2241
+ preventDragOver(e) {
2242
+ e.preventDefault();
2243
+ }
2244
+ removeImage(index) {
2245
+ this.displayImages = this.displayImages.filter((_, i) => i !== index);
2246
+ this.formImages = this.formImages.filter((_, i) => i !== index);
2247
+ }
2248
+ render() {
2249
+ const upload = getAssetPath(`./assets/drag-drop.svg`);
2250
+ return (h("div", { class: "invoice" }, h("p", null, state.selectedProduct.invoice_description), h("form", { onSubmit: e => this.submit(e) }, h("textarea", { name: "descriptionInput", placeholder: "Beskriv ditt \u00E4rende" }), h("div", { role: "button", "aria-label": "upload image", onDragOver: e => this.preventDragOver(e), onDrop: e => this.handleImageDrop(e), onClick: () => this.handleImageClick() }, h("img", { src: upload, alt: "hemfixarna_logo", width: 24 }), h("div", null, h("p", null, "Bifoga ev bilder"), h("span", null, "(dra bilder hit)")), h("input", { onChange: e => this.handleFileInputChange(e), class: "hemfixarna-file-upload", accept: "image/*", type: "file", multiple: true, name: "fileInput" })), h("div", { class: "invoice-preview" }, this.displayImages.map((img, i) => (h("div", { key: i }, h("img", { src: img, alt: "uploaded image" }), h("button", { onClick: () => this.removeImage(i) }, h("img", { src: getAssetPath(`./assets/close.svg`), alt: "close" })))))), h("input", { placeholder: "E-post", type: "email", name: "emailInput" }), h("input", { placeholder: "Telefonnummer", type: "tel", name: "telInput" }), state.selectedProduct.terms_show_checkbox ? (h("label", null, h("input", { type: "checkbox", name: "termsInput" }), state.selectedProduct.terms)) : null, this.formError ? h("span", null, this.formError) : null, h("input", { type: "submit", value: this.formState === 'loading' ? 'Skickar' : 'Kontakta mig' }))));
2251
+ }
2252
+ get el() { return getElement(this); }
2253
+ };
2254
+ HemfixarnaInvoice.style = hemfixarnaInvoiceCss;
2255
+
2256
+ const MyComponent$b = class {
2257
+ constructor(hostRef) {
2258
+ registerInstance(this, hostRef);
2259
+ this.id = undefined;
2260
+ this.loadFromQuery = 'true';
2261
+ this.widgetStyle = WidgetStyle.standard;
2262
+ this.buttonColor = undefined;
2263
+ this.buttonBg = undefined;
2264
+ this.isDemo = false;
2265
+ }
2266
+ render() {
2267
+ return (h("hemfixarna-component", { widgetStyle: this.widgetStyle, buttonBg: this.buttonBg, buttonColor: this.buttonColor, nav: { url: 'https://k-bygg.se', logo: 'assets/kbygg.svg', backgroundColor: '#651d32' }, loadFromQuery: Boolean(this.loadFromQuery), id: this.id, business: Business.kbygg, isDemo: this.isDemo }));
2268
+ }
2269
+ };
2270
+
2271
+ const MyComponent$a = class {
2272
+ constructor(hostRef) {
2273
+ registerInstance(this, hostRef);
2274
+ this.id = undefined;
2275
+ this.loadFromQuery = undefined;
2276
+ this.widgetStyle = WidgetStyle.standard;
2277
+ this.buttonColor = undefined;
2278
+ this.buttonBg = undefined;
2279
+ }
2280
+ render() {
2281
+ return (h("hemfixarna-component", { widgetStyle: this.widgetStyle, buttonBg: this.buttonBg, buttonColor: this.buttonColor, loadFromQuery: Boolean(this.loadFromQuery), id: this.id, business: Business.klint }));
2282
+ }
2283
+ };
2284
+
2285
+ const MyComponent$9 = class {
2286
+ constructor(hostRef) {
2287
+ registerInstance(this, hostRef);
2288
+ this.id = undefined;
2289
+ this.loadFromQuery = undefined;
2290
+ this.widgetStyle = WidgetStyle.standard;
2291
+ this.buttonColor = undefined;
2292
+ this.buttonBg = undefined;
2293
+ }
2294
+ render() {
2295
+ return (h("hemfixarna-component", { widgetStyle: this.widgetStyle, buttonBg: this.buttonBg, buttonColor: this.buttonColor, loadFromQuery: Boolean(this.loadFromQuery), id: this.id, business: Business.kund }));
2296
+ }
2297
+ };
2298
+
2299
+ const MyComponent$8 = class {
2300
+ constructor(hostRef) {
2301
+ registerInstance(this, hostRef);
2302
+ this.id = undefined;
2303
+ this.loadFromQuery = 'true';
2304
+ this.widgetStyle = WidgetStyle.standard;
2305
+ this.buttonColor = undefined;
2306
+ this.buttonBg = undefined;
2307
+ this.isDemo = false;
2308
+ }
2309
+ render() {
2310
+ return (h("hemfixarna-component", { widgetStyle: this.widgetStyle, buttonBg: this.buttonBg, buttonColor: this.buttonColor, nav: { url: 'https://norrgavel.se', logo: 'assets/norrgavel.svg' }, loadFromQuery: Boolean(this.loadFromQuery), id: this.id, business: Business.norrgavel, isDemo: this.isDemo }));
2311
+ }
2312
+ };
2313
+
2314
+ const HemfixarnaOrder = class {
2315
+ constructor(hostRef) {
2316
+ registerInstance(this, hostRef);
2317
+ this.render = () => {
2318
+ return (h("div", { style: { background: `url(${state.options.thank_you_image})` }, class: "hemfixarna_order" }, h("div", null), h("div", null, h("h2", null, state.checkoutInvoice ? 'Tack för din förfrågan' : 'Tack för din bokning'), state.checkoutInvoice ? h("p", null, "Vi \u00E5terkommer inom kort till dig p\u00E5 angivet telefonnummer eller epost") : null, state.checkoutInvoice ? h("div", null) : h("hemfixarna-orderrows", { tree: this.tree, cart: false }), h("span", { onClick: () => this.resetShop() }, h("button", null, "G\u00F6r en ny bokning")), h("hemfixarna-info", null))));
2319
+ };
2320
+ this.tree = undefined;
2321
+ }
2322
+ resetShop() {
2323
+ state.step = 1;
2324
+ state.cart = [];
2325
+ state.selectedCategory = null;
2326
+ state.selectedService = null;
2327
+ state.selectedProduct = null;
2328
+ state.maleri = null;
2329
+ state.checkoutStep = 1;
2330
+ }
2331
+ disconnectedCallback() {
2332
+ this.resetShop();
2333
+ }
2334
+ };
2335
+
2336
+ const HemfixarnaOrderrows = class {
2337
+ constructor(hostRef) {
2338
+ registerInstance(this, hostRef);
2339
+ this.cart = true;
2340
+ this.tree = undefined;
2341
+ }
2342
+ goToProduct(id) {
2343
+ if (state.customer) {
2344
+ const products = state.customer.categories
2345
+ .map(c => (c.show_products ? c.products : c.sub_categories ? c.sub_categories.map(c => c.products) : []))
2346
+ .flat()
2347
+ .flat();
2348
+ const product = products.find(p => p && p.fields.ID === id);
2349
+ if (product) {
2350
+ state.selectedProduct = product.fields;
2351
+ state.step = 4;
2352
+ }
2353
+ }
2354
+ else {
2355
+ const services = this.tree.sub_cats.map((c) => c.services).flat();
2356
+ const products = services.map((s) => s.products).flat();
2357
+ const product = products.find((p) => p.ID === id);
2358
+ const service = services.find((s) => s.products.find((p) => p.ID === id));
2359
+ const category = this.tree.sub_cats.find((c) => c.services.find((s) => s.products.find((p) => p.ID === id)));
2360
+ state.selectedCategory = category;
2361
+ state.selectedService = service;
2362
+ state.selectedProduct = product;
2363
+ state.step = 4;
2364
+ }
2365
+ }
2366
+ openRot() {
2367
+ state.modal = {
2368
+ title: state.rotOptions.rot_start_fee_heading,
2369
+ text: [state.rotOptions.rot_start_fee_text, state.rotOptions.rot_start_fee_text_secondary],
2370
+ };
2371
+ }
2372
+ openRut() {
2373
+ state.modal = {
2374
+ title: state.rutOptions.rut_start_fee_heading,
2375
+ text: [state.rutOptions.rut_start_fee_text, state.rutOptions.rut_start_fee_text_secondary],
2376
+ };
2377
+ }
2378
+ openGreen() {
2379
+ state.modal = {
2380
+ title: state.greenOptions.green_start_fee_heading,
2381
+ text: [state.greenOptions.green_start_fee_text, state.greenOptions.green_start_fee_text_secondary],
2382
+ };
2383
+ }
2384
+ getDiscountedInfo(item) {
2385
+ if (item.rut && state.rut) {
2386
+ return ' (efter RUT-avdrag)';
2387
+ }
2388
+ else if (item.rot && state.rot) {
2389
+ return ' (efter ROT-avdrag)';
2390
+ }
2391
+ else if (item.green && state.green) {
2392
+ return ' (efter Grön teknik avdrag)';
2393
+ }
2394
+ else {
2395
+ return '';
2396
+ }
2397
+ }
2398
+ render() {
2399
+ const info = getAssetPath(`./assets/info.svg`);
2400
+ return (h(Fragment, null, h("ul", { class: "hemfixarna_cart--items" }, state.cart.map(item => {
2401
+ var _a;
2402
+ return (h("li", { class: "hemfixarna_cart--item" }, h("div", null, h("div", null, item.icon && h("img", { width: 30, src: (_a = item.icon.url) !== null && _a !== void 0 ? _a : item.icon, alt: item.name }), h("p", null, h("strong", null, item.amount, "x "), item.name)), this.cart && h("button", { onClick: () => this.goToProduct(item.id) }, "\u00C4ndra")), h("p", null, h("strong", null, getProductPrice(item, item.price, item.amount), "kr"), h("span", null, this.getDiscountedInfo(item))), item.parts.length > 0 && (h("ul", null, item.parts.map(part => (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")))))))));
2403
+ })), h("div", { class: "hemfixarna_cart--additional" }, h("div", null, getStartFee().rot > 0 && (h("div", { class: "hemfixarna_cart--startfee" }, h("p", null, h("strong", { onClick: () => this.openRot() }, state.rotOptions.rot_start_fee_heading, h("img", { height: 16, src: info, alt: "info monteringsavgift" }))), h("p", null, getStartFee().rot, "kr"))), getStartFee().rut > 0 && (h("div", { class: "hemfixarna_cart--startfee" }, h("p", null, h("strong", { onClick: () => this.openRut() }, state.rutOptions.rut_start_fee_heading, h("img", { height: 16, src: info, alt: "info monteringsavgift" }))), h("p", null, getStartFee().rut, "kr"))), getStartFee().green > 0 && (h("div", { class: "hemfixarna_cart--startfee" }, h("p", null, h("strong", { onClick: () => this.openGreen() }, state.greenOptions.green_start_fee_heading, h("img", { height: 16, src: info, alt: "info monteringsavgift" }))), h("p", null, getStartFee().green, "kr")))), state.cart.find((item) => item.rot) && (h("div", { class: "hemfixarna_cart--rutrot" }, h("div", null, this.cart && (h("label", { class: "switch" }, h("input", { checked: state.rot, onChange: () => (state.rot = !state.rot), type: "checkbox" }), h("span", { class: "slider" }))), h("p", null, "ROT-avdrag")), h("p", null, "(-", state.rot ? calculateRot() : 0, "kr)"))), state.cart.find((item) => item.rut) && (h("div", { class: "hemfixarna_cart--rutrot" }, h("div", null, h("label", { class: "switch" }, h("input", { onChange: () => (state.rut = !state.rut), checked: state.rut, type: "checkbox" }), h("span", { class: "slider" })), h("p", null, "RUT-avdrag")), h("p", null, "(-", state.rut ? calculateRut() : 0, "kr)"))), state.cart.find((item) => item.green) && (h("div", { class: "hemfixarna_cart--rutrot" }, h("div", null, h("label", { class: "switch" }, h("input", { onChange: () => (state.green = !state.green), checked: state.green, type: "checkbox" }), h("span", { class: "slider" })), h("p", null, "Gr\u00F6n teknik avdrag")), h("p", null, "(-", state.green ? calculateGreenDiscount() : 0, "kr)")))), h("div", { class: "hemfixarna_cart--price" }, h("h2", null, "Totalbelopp: "), h("h2", null, getTotalPrice(), "kr"))));
2404
+ }
2405
+ };
2406
+
2407
+ const MyComponent$7 = class {
2408
+ constructor(hostRef) {
2409
+ registerInstance(this, hostRef);
2410
+ this.id = undefined;
2411
+ this.customer = undefined;
2412
+ this.loadFromQuery = undefined;
2413
+ this.widgetStyle = WidgetStyle.standard;
2414
+ this.buttonColor = undefined;
2415
+ this.buttonBg = undefined;
2416
+ }
2417
+ render() {
2418
+ return (h("hemfixarna-component", { widgetStyle: this.widgetStyle, buttonBg: this.buttonBg, buttonColor: this.buttonColor, loadFromQuery: Boolean(this.loadFromQuery), id: this.id, business: Business.power }));
2419
+ }
2420
+ };
2421
+
2422
+ const hemfixarnaProductCss = "";
2423
+
2424
+ const HemfixarnaProduct = class {
2425
+ constructor(hostRef) {
2426
+ registerInstance(this, hostRef);
2427
+ this.amount = 0;
2428
+ this.hideDescription = true;
2429
+ }
2430
+ addProduct() {
2431
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
2432
+ if (productInCart) {
2433
+ productInCart.amount++;
2434
+ state.cart = [...state.cart];
2435
+ }
2436
+ else {
2437
+ state.cart = [
2438
+ ...state.cart,
2439
+ {
2440
+ id: state.selectedProduct.ID,
2441
+ rut: state.selectedProduct.rut,
2442
+ rot: state.selectedProduct.rot,
2443
+ green: state.selectedProduct.green,
2444
+ amount: 1,
2445
+ parts: [],
2446
+ price: state.selectedProduct.price,
2447
+ name: state.selectedProduct.title,
2448
+ start_fee: !state.selectedProduct.hide_start_fee,
2449
+ terms_checkout: state.selectedProduct.terms_checkout,
2450
+ icon: state.selectedProduct.icon,
2451
+ },
2452
+ ];
2453
+ }
2454
+ }
2455
+ removeProduct() {
2456
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
2457
+ if (productInCart && productInCart.amount > 1) {
2458
+ productInCart.amount--;
2459
+ state.cart = [...state.cart];
2460
+ }
2461
+ else {
2462
+ state.cart = state.cart.filter(p => p.id !== state.selectedProduct.ID);
2463
+ }
2464
+ }
2465
+ //Handle cart and parts
2466
+ addPart(part) {
2467
+ var _a;
2468
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
2469
+ if (productInCart) {
2470
+ const partInCart = productInCart.parts.find(sp => sp.id === part.ID);
2471
+ if (partInCart) {
2472
+ partInCart.amount++;
2473
+ productInCart.parts = [...productInCart.parts];
2474
+ }
2475
+ else {
2476
+ productInCart.parts = [...productInCart.parts, { id: part.ID, amount: 1, price: part.price, name: (_a = part.title) !== null && _a !== void 0 ? _a : part.title }];
2477
+ }
2478
+ state.cart = [...state.cart.filter(p => p.id !== productInCart.id), productInCart];
2479
+ }
2480
+ }
2481
+ removePart(part) {
2482
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
2483
+ if (productInCart) {
2484
+ const partInCart = productInCart.parts.find(sp => sp.id === part.ID);
2485
+ if (partInCart && partInCart.amount > 1) {
2486
+ partInCart.amount--;
2487
+ productInCart.parts = [...productInCart.parts];
2488
+ }
2489
+ else {
2490
+ productInCart.parts = productInCart.parts.filter(sp => sp.id !== part.ID);
2491
+ }
2492
+ state.cart = [...state.cart.filter(p => p.id !== productInCart.id), productInCart];
2493
+ }
2494
+ }
2495
+ goToCart() {
2496
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
2497
+ if (productInCart) {
2498
+ state.step = 5;
2499
+ const el = this.el.closest('.hemfixarna_content');
2500
+ scrollToTop(el);
2501
+ }
2502
+ }
2503
+ getAmount() {
2504
+ var _a;
2505
+ return ((_a = state.cart.find(p => p.id === state.selectedProduct.ID)) === null || _a === void 0 ? void 0 : _a.amount) || 0;
2506
+ }
2507
+ getPartAmount(partId) {
2508
+ var _a;
2509
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
2510
+ return ((_a = productInCart === null || productInCart === void 0 ? void 0 : productInCart.parts.find(sp => sp.id === partId)) === null || _a === void 0 ? void 0 : _a.amount) || 0;
2511
+ }
2512
+ getTotalPrice() {
2513
+ let price = 0;
2514
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
2515
+ if (productInCart) {
2516
+ const partsPrice = productInCart.parts.reduce((acc, curr) => {
2517
+ const part = state.selectedProduct.parts.find(p => p.ID === curr.id);
2518
+ if (part) {
2519
+ return acc + part.price * curr.amount;
2520
+ }
2521
+ return acc;
2522
+ }, 0);
2523
+ price = state.selectedProduct.price * productInCart.amount + partsPrice;
2524
+ }
2525
+ else {
2526
+ price = state.selectedProduct.price;
2527
+ }
2528
+ return getProductPrice(state.selectedProduct, price);
2529
+ }
2530
+ componentDidRender() {
2531
+ const linkElem = document.createElement('link');
2532
+ linkElem.setAttribute('rel', 'stylesheet');
2533
+ linkElem.setAttribute('href', 'https://painting-frontend.vercel.app/static/css/main.css');
2534
+ const fonts = document.createElement('link');
2535
+ fonts.setAttribute('rel', 'stylesheet');
2536
+ fonts.setAttribute('href', 'https://painting-frontend.vercel.app/fonts.css');
2537
+ const checkAndInjectCSS = () => {
2538
+ const parents = this.el.getElementsByTagName('hemfixare-calculator');
2539
+ if (parents.length > 0 && parents[0].shadowRoot !== null) {
2540
+ parents[0].shadowRoot.appendChild(linkElem);
2541
+ parents[0].shadowRoot.appendChild(fonts);
2542
+ }
2543
+ else {
2544
+ setTimeout(checkAndInjectCSS, 1);
2545
+ }
2546
+ };
2547
+ checkAndInjectCSS();
2548
+ }
2549
+ render() {
2550
+ var _a, _b, _c;
2551
+ const checked = getAssetPath(`./assets/checked.svg`);
2552
+ const plus = getAssetPath(`./assets/plus.svg`);
2553
+ const minus = getAssetPath(`./assets/minus.svg`);
2554
+ if (state.maleri) {
2555
+ return (h("div", { class: "hemfixarna_painting" }, h("script", { type: "text/javascript", src: ['localhost', 'vercel'].some(v => window.location.href.includes(v))
2556
+ ? 'https://painting-dev.vercel.app/static/js/main.js'
2557
+ : 'https://painting-frontend.vercel.app/static/js/main.js', defer: true, async: true }), h("hemfixare-calculator", { title: state.options.maleri_title, subtitle: state.options.maleri_text, modal: "true", customer: state.business === Business.string ? 'string' : state.business })));
2558
+ }
2559
+ return state.selectedProduct ? (h("div", { class: "hemfixarna_product" }, h("div", { class: "hemfixarna_product--top" }, state.selectedProduct.icon && (h("img", { width: 80, src: (_a = state.selectedProduct.icon.url) !== null && _a !== void 0 ? _a : state.selectedProduct.icon, alt: state.selectedProduct.title })), h("div", null, h("h1", null, state.selectedProduct.title), !state.selectedProduct.invoice ? h("h2", null, getProductPrice(state.selectedProduct), " kr/st") : h("h2", null, state.selectedProduct.invoice_price))), h("div", { class: "hemfixarna_product--grid" }, h("div", { class: "hemfixarna_product--left" }, ((_b = state.selectedProduct.list) === null || _b === void 0 ? void 0 : _b.length) && (h("ul", { class: "hemfixarna_features" }, state.selectedProduct.list.map(l => (h("li", { key: l.bullet }, h("img", { src: checked, alt: "checked" }), h("p", null, l.bullet)))))), state.selectedProduct.description && (h("p", { onClick: () => (this.hideDescription = false), class: `hemfixarna_description ${this.hideDescription ? 'hemfixarna_description--hidden' : ''}`, innerHTML: state.selectedProduct.description }))), h("div", { class: "hemfixarna_product--right" }, state.selectedProduct.invoice ? (h("hemfixarna-invoice", null)) : (h(Fragment, null, h("ul", null, h("li", { class: "hemfixarna_product--item" }, h("div", null, h("p", null, state.selectedProduct.title), h("p", { class: "hemfixarna_product--price" }, getProductPrice(state.selectedProduct), "kr/st")), h("div", { class: "hemfixarna_counter" }, h("img", { class: `${this.getAmount() === 0 ? 'disabled' : ''}`, src: minus, onClick: () => this.removeProduct() }), h("span", null, this.getAmount()), h("img", { src: plus, onClick: () => this.addProduct() }))), ((_c = state.selectedProduct.parts) === null || _c === void 0 ? void 0 : _c.length) &&
2560
+ state.selectedProduct.parts.map(p => {
2561
+ var _a;
2562
+ return (h("li", { class: "hemfixarna_part" }, h("div", null, h("p", null, (_a = p.title) !== null && _a !== void 0 ? _a : p.title), h("p", { class: "hemfixarna_product--price" }, getPartPrice(p, state.selectedProduct), "kr/st")), h("div", { class: "hemfixarna_counter" }, h("img", { class: `${this.getPartAmount(p.ID) === 0 ? 'disabled' : ''}`, src: minus, onClick: () => this.removePart(p) }), h("span", null, this.getPartAmount(p.ID)), h("img", { class: `${this.getAmount() === 0 ? 'disabled' : ''}`, src: plus, onClick: () => this.addPart(p) }))));
2563
+ })), h("h4", { class: "hemfixarna_product--total" }, "Totalt ", this.getTotalPrice(), " kr"), h("button", { onClick: () => this.goToCart(), class: `hemfixarna_buy ${this.getAmount() === 0 ? 'disabled' : ''}` }, "Forts\u00E4tt"))), !state.selectedProduct.hide_start_fee && (state.selectedProduct.rot || state.selectedProduct.rut) && state.rutOptions && state.rotOptions && (h("p", { class: "hemfixarna_terms" }, h("strong", null, state.selectedProduct.rot ? state.rotOptions.rot_start_fee_heading : state.rutOptions.rut_start_fee_heading), h("br", null), h("span", { innerHTML: state.selectedProduct.rot ? state.rotOptions.rot_start_fee_text : state.rutOptions.rut_start_fee_text }))), state.options && h("hemfixarna-info", null))))) : null;
2564
+ }
2565
+ get el() { return getElement(this); }
2566
+ };
2567
+ HemfixarnaProduct.style = hemfixarnaProductCss;
2568
+
2569
+ const HemfixarnaService = class {
2570
+ constructor(hostRef) {
2571
+ registerInstance(this, hostRef);
2572
+ }
2573
+ render() {
2574
+ return (h("div", null, h("h2", null, state.selectedService.post_title), h("div", { class: "hemfixarna_categories--wrapper" }, h("div", null, h("ul", { class: "hemfixarna_categories" }, state.selectedService.products
2575
+ .sort((a, b) => (a.post_title < b.post_title ? -1 : 1))
2576
+ .map(p => {
2577
+ var _a;
2578
+ return (h("hemfixarna-box", { post: p, icon: (_a = p.icon.url) !== null && _a !== void 0 ? _a : p.icon, postTitle: p.title }));
2579
+ }))), h("hemfixarna-info", null))));
2580
+ }
2581
+ };
2582
+
2583
+ const hemfixarnaSkanskaCss = "";
2584
+
2585
+ const MyComponent$6 = class {
2586
+ constructor(hostRef) {
2587
+ registerInstance(this, hostRef);
2588
+ this.id = undefined;
2589
+ this.customer = undefined;
2590
+ this.loadFromQuery = undefined;
2591
+ this.widgetStyle = WidgetStyle.standard;
2592
+ this.buttonColor = undefined;
2593
+ this.buttonBg = undefined;
2594
+ }
2595
+ render() {
2596
+ return (h("hemfixarna-component", { widgetStyle: this.widgetStyle, buttonBg: this.buttonBg, buttonColor: this.buttonColor, loadFromQuery: Boolean(this.loadFromQuery), id: this.id, business: Business.skanska }));
2597
+ }
2598
+ };
2599
+ MyComponent$6.style = hemfixarnaSkanskaCss;
2600
+
2601
+ const MyComponent$5 = class {
2602
+ constructor(hostRef) {
2603
+ registerInstance(this, hostRef);
2604
+ this.id = undefined;
2605
+ this.customer = undefined;
2606
+ this.loadFromQuery = undefined;
2607
+ this.widgetStyle = WidgetStyle.standard;
2608
+ this.buttonColor = undefined;
2609
+ this.buttonBg = undefined;
2610
+ }
2611
+ render() {
2612
+ return (h("hemfixarna-component", { widgetStyle: this.widgetStyle, buttonBg: this.buttonBg, buttonColor: this.buttonColor, loadFromQuery: Boolean(this.loadFromQuery), id: this.id, business: Business.sparfonster }));
2613
+ }
2614
+ };
2615
+
2616
+ const HemfixarnaGrid = class {
2617
+ constructor(hostRef) {
2618
+ registerInstance(this, hostRef);
2619
+ this.tree = undefined;
2620
+ this.slug = undefined;
2621
+ }
2622
+ isMainCategory(category) {
2623
+ return category.show_products !== undefined;
2624
+ }
2625
+ handleMaleriClick() {
2626
+ state.step = 4;
2627
+ state.maleri = true;
2628
+ }
2629
+ render() {
2630
+ var _a;
2631
+ const maleriLogo = getAssetPath('./assets/gubbe-pensel.svg');
2632
+ return state.customer ? (h("div", null, h("h2", null, state.selectedCustomerCategory ? state.selectedCustomerCategory.name : 'Alla tjänster'), h("div", { class: "hemfixarna_categories--wrapper" }, h("ul", { class: "hemfixarna_categories" }, ((_a = state.selectedCustomerCategory) === null || _a === void 0 ? void 0 : _a.add_painting) ? (h("button", { onClick: () => this.handleMaleriClick(), class: "hemfixarna_maleribox" }, h("img", { height: 64, src: maleriLogo, alt: "M\u00E5leri Logotyp" }), h("p", null, "Ber\u00E4kna fast pris p\u00E5 m\u00E5leri & tapetsering h\u00E4r"))) : null, state.selectedCustomerCategory
2633
+ ? this.isMainCategory(state.selectedCustomerCategory) && state.selectedCustomerCategory.sub_categories && !state.selectedCustomerCategory.show_products
2634
+ ? state.selectedCustomerCategory.sub_categories.map(c => h("hemfixarna-box", { category: c }))
2635
+ : state.selectedCustomerCategory.products
2636
+ ? state.selectedCustomerCategory.products.map(c => h("hemfixarna-box", { category: c.fields }))
2637
+ : null
2638
+ : state.customer.categories.map(c => h("hemfixarna-box", { category: c }))), h("hemfixarna-info", null)))) : (h("div", null, h("h2", null, "Alla tj\u00E4nster"), h("div", { class: "hemfixarna_categories--wrapper" }, h("ul", { class: "hemfixarna_categories" }, this.tree.sub_cats
2639
+ .sort((a, b) => (a.name < b.name ? -1 : 1))
2640
+ .map(c => {
2641
+ var _a;
2642
+ return (h("hemfixarna-box", { post: c, icon: (_a = c.icon.url) !== null && _a !== void 0 ? _a : c.icon, postTitle: c.name }));
2643
+ })), h("hemfixarna-info", null))));
2644
+ }
2645
+ };
2646
+
2647
+ const hemfixarnaStringCss = "";
2648
+
2649
+ const MyComponent$4 = class {
2650
+ constructor(hostRef) {
2651
+ registerInstance(this, hostRef);
2652
+ this.id = undefined;
2653
+ this.loadFromQuery = undefined;
2654
+ this.widgetStyle = WidgetStyle.standard;
2655
+ this.buttonColor = undefined;
2656
+ this.buttonBg = undefined;
2657
+ }
2658
+ render() {
2659
+ return (h("hemfixarna-component", { widgetStyle: this.widgetStyle, buttonBg: this.buttonBg, buttonColor: this.buttonColor, loadFromQuery: Boolean(this.loadFromQuery), id: this.id, business: Business.string }));
2660
+ }
2661
+ };
2662
+ MyComponent$4.style = hemfixarnaStringCss;
2663
+
2664
+ const MyComponent$3 = class {
2665
+ constructor(hostRef) {
2666
+ registerInstance(this, hostRef);
2667
+ this.id = undefined;
2668
+ this.loadFromQuery = undefined;
2669
+ this.widgetStyle = WidgetStyle.standard;
2670
+ this.buttonColor = undefined;
2671
+ this.buttonBg = undefined;
2672
+ }
2673
+ render() {
2674
+ return (h("hemfixarna-component", { widgetStyle: this.widgetStyle, buttonBg: this.buttonBg, buttonColor: this.buttonColor, loadFromQuery: Boolean(this.loadFromQuery), id: this.id, business: Business.superfront }));
2675
+ }
2676
+ };
2677
+
2678
+ const MyComponent$2 = class {
2679
+ constructor(hostRef) {
2680
+ registerInstance(this, hostRef);
2681
+ this.id = undefined;
2682
+ this.loadFromQuery = 'true';
2683
+ this.isDemo = false;
2684
+ this.widgetStyle = WidgetStyle.standard;
2685
+ this.buttonColor = undefined;
2686
+ this.buttonBg = undefined;
2687
+ }
2688
+ render() {
2689
+ return (h("hemfixarna-component", { widgetStyle: this.widgetStyle, buttonBg: this.buttonBg, buttonColor: this.buttonColor, nav: { url: 'https://www.tesla.com/sv_se/home-charging', logo: 'assets/tesla.svg' }, isDemo: this.isDemo, loadFromQuery: Boolean(this.loadFromQuery), id: this.id, business: Business.tesla }));
2690
+ }
2691
+ };
2692
+
2693
+ const MyComponent$1 = class {
2694
+ constructor(hostRef) {
2695
+ registerInstance(this, hostRef);
2696
+ this.id = undefined;
2697
+ this.loadFromQuery = undefined;
2698
+ this.widgetStyle = WidgetStyle.standard;
2699
+ this.buttonColor = undefined;
2700
+ this.buttonBg = undefined;
2701
+ }
2702
+ render() {
2703
+ return (h("hemfixarna-component", { widgetStyle: this.widgetStyle, buttonBg: this.buttonBg, buttonColor: this.buttonColor, loadFromQuery: Boolean(this.loadFromQuery), id: this.id, business: Business.traningspartner }));
2704
+ }
2705
+ };
2706
+
2707
+ const MyComponent = class {
2708
+ constructor(hostRef) {
2709
+ registerInstance(this, hostRef);
2710
+ this.id = undefined;
2711
+ this.loadFromQuery = 'true';
2712
+ this.isDemo = false;
2713
+ this.widgetStyle = WidgetStyle.standard;
2714
+ this.buttonColor = undefined;
2715
+ this.buttonBg = undefined;
2716
+ }
2717
+ render() {
2718
+ return (h("hemfixarna-component", { widgetStyle: this.widgetStyle, buttonBg: this.buttonBg, buttonColor: this.buttonColor, nav: { url: 'https://www.zaptec.com/sv/laddningslosningar/zaptec-go', logo: 'assets/zaptec.svg' }, isDemo: this.isDemo, loadFromQuery: Boolean(this.loadFromQuery), id: this.id, business: Business.zaptec }));
2719
+ }
2720
+ };
2721
+
2722
+ export { HemfixarnaAddress as hemfixarna_address, HemfixarnaBox as hemfixarna_box, HemfixarnaBreadcrumbs as hemfixarna_breadcrumbs, MyComponent$j as hemfixarna_byggmax, HemfixarnaCart as hemfixarna_cart, HemfixarnaCategory as hemfixarna_category, HemfixarnaCheckout as hemfixarna_checkout, HemfixarnaComponent as hemfixarna_component, HemfixarnaInfo$1 as hemfixarna_contact, MyComponent$i as hemfixarna_demo, MyComponent$h as hemfixarna_doro, MyComponent$g as hemfixarna_elfa, MyComponent$f as hemfixarna_fargvaruhuset, MyComponent$e as hemfixarna_flyttsmart, MyComponent$d as hemfixarna_forebygg, HemfixarnaGetuser as hemfixarna_getuser, MyComponent$c as hemfixarna_hornbach, HemfixarnaInfo as hemfixarna_info, HemfixarnaInvoice as hemfixarna_invoice, MyComponent$b as hemfixarna_kbygg, MyComponent$a as hemfixarna_klint, MyComponent$9 as hemfixarna_kund, MyComponent$8 as hemfixarna_norrgavel, HemfixarnaOrder as hemfixarna_order, HemfixarnaOrderrows as hemfixarna_orderrows, MyComponent$7 as hemfixarna_power, HemfixarnaProduct as hemfixarna_product, HemfixarnaService as hemfixarna_service, MyComponent$6 as hemfixarna_skanska, MyComponent$5 as hemfixarna_sparfonster, HemfixarnaGrid as hemfixarna_start, MyComponent$4 as hemfixarna_string_furniture, MyComponent$3 as hemfixarna_superfront, MyComponent$2 as hemfixarna_tesla, MyComponent$1 as hemfixarna_traningspartner, MyComponent as hemfixarna_zaptec };
2723
+
2724
+ //# sourceMappingURL=hemfixarna-address_36.entry.js.map