@salla.sa/twilight-components 2.14.366 → 2.14.367

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 (247) hide show
  1. package/dist/cjs/{filepond-iKAI8_Ua.js → filepond-Dc4v9nRQ.js} +1 -1
  2. package/dist/cjs/{filepond-plugin-file-poster-DBOuyuqE.js → filepond-plugin-file-poster-D580mHPz.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-validate-size-3OjivJWc.js → filepond-plugin-file-validate-size-CirPDkJ5.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-type-C4wPNa1h.js → filepond-plugin-file-validate-type-DlzM2hzF.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-image-edit-D06RnDWS.js → filepond-plugin-image-edit-C-V0_34D.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-exif-orientation-CbwYrnuw.js → filepond-plugin-image-exif-orientation-BzOSGmgz.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-preview-mOmpKkFJ.js → filepond-plugin-image-preview-DPPccyO8.js} +1 -1
  8. package/dist/cjs/{index-TmWujwmX.js → index-B-3J2UiO.js} +1 -1
  9. package/dist/cjs/{index-DL9nqubd.js → index-C4FIMuo-.js} +2 -2
  10. package/dist/cjs/loader.cjs.js +1 -1
  11. package/dist/cjs/salla-accordion-body_3.cjs.entry.js +1 -1
  12. package/dist/cjs/salla-accordion_6.cjs.entry.js +1 -1
  13. package/dist/cjs/salla-add-product-button_4.cjs.entry.js +5 -3
  14. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  15. package/dist/cjs/salla-alert_2.cjs.entry.js +1 -1
  16. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  17. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  18. package/dist/cjs/salla-booking-field_7.cjs.entry.js +10 -10
  19. package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
  20. package/dist/cjs/salla-comment-form_8.cjs.entry.js +1 -1
  21. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  22. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  23. package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
  24. package/dist/cjs/salla-count-down_2.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
  26. package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-filters.cjs.entry.js +1 -1
  28. package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
  29. package/dist/cjs/salla-hook.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
  31. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  35. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  36. package/dist/cjs/salla-loyalty-program.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
  39. package/dist/cjs/salla-menu.cjs.entry.js +1 -1
  40. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
  44. package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
  45. package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
  46. package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
  47. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  48. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  49. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  50. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  51. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  52. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  53. package/dist/cjs/salla-orders.cjs.entry.js +1 -1
  54. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  55. package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
  56. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  57. package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
  58. package/dist/cjs/salla-products-list.cjs.entry.js +1 -6
  59. package/dist/cjs/salla-products-slider.cjs.entry.js +3 -9
  60. package/dist/cjs/salla-progress-bar.cjs.entry.js +1 -1
  61. package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
  62. package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
  63. package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
  64. package/dist/cjs/salla-search.cjs.entry.js +1 -1
  65. package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
  66. package/dist/cjs/salla-slider.cjs.entry.js +1 -1
  67. package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
  68. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  69. package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
  70. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  71. package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
  72. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  73. package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
  74. package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
  75. package/dist/cjs/salla-user-settings.cjs.entry.js +1 -1
  76. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  77. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  78. package/dist/cjs/twilight.cjs.js +1 -1
  79. package/dist/cjs/{vanilla-picker-DPu_Z0gW.js → vanilla-picker-wB5YeUXb.js} +1 -1
  80. package/dist/collection/components/salla-add-product-button/salla-add-product-button.js +4 -1
  81. package/dist/collection/components/salla-products-list/salla-products-list.js +0 -5
  82. package/dist/collection/components/salla-products-slider/salla-products-slider.js +2 -8
  83. package/dist/components/index.js +2 -2
  84. package/dist/components/salla-add-product-button2.js +4 -1
  85. package/dist/components/salla-products-list2.js +0 -5
  86. package/dist/components/salla-products-slider2.js +2 -8
  87. package/dist/esm/{filepond-OIAu6i0O.js → filepond-Pk5LWGeG.js} +1 -1
  88. package/dist/esm/{filepond-plugin-file-poster-BMvjO1cc.js → filepond-plugin-file-poster-BtFMoeoX.js} +1 -1
  89. package/dist/esm/{filepond-plugin-file-validate-size-CMCs88HU.js → filepond-plugin-file-validate-size-BxrR9h6P.js} +1 -1
  90. package/dist/esm/{filepond-plugin-file-validate-type-Bjpeuqen.js → filepond-plugin-file-validate-type-BwgatLbq.js} +1 -1
  91. package/dist/esm/{filepond-plugin-image-edit-Fpoh6xBj.js → filepond-plugin-image-edit-D5zXSV7g.js} +1 -1
  92. package/dist/esm/{filepond-plugin-image-exif-orientation-CPChwYPW.js → filepond-plugin-image-exif-orientation-DCrpf9GE.js} +1 -1
  93. package/dist/esm/{filepond-plugin-image-preview-pLwEytag.js → filepond-plugin-image-preview-B67SPp2M.js} +1 -1
  94. package/dist/esm/{index-Cs4XvAmW.js → index-MNn-Ef4U.js} +1 -1
  95. package/dist/esm/{index-CV1rqKQz.js → index-ea1dIZhh.js} +2 -2
  96. package/dist/esm/loader.js +2 -2
  97. package/dist/esm/salla-accordion-body_3.entry.js +1 -1
  98. package/dist/esm/salla-accordion_6.entry.js +1 -1
  99. package/dist/esm/salla-add-product-button_4.entry.js +5 -3
  100. package/dist/esm/salla-advertisement.entry.js +1 -1
  101. package/dist/esm/salla-alert_2.entry.js +1 -1
  102. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  103. package/dist/esm/salla-apps-icons.entry.js +1 -1
  104. package/dist/esm/salla-booking-field_7.entry.js +10 -10
  105. package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
  106. package/dist/esm/salla-comment-form_8.entry.js +1 -1
  107. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  108. package/dist/esm/salla-contacts.entry.js +1 -1
  109. package/dist/esm/salla-cookies-bar.entry.js +1 -1
  110. package/dist/esm/salla-count-down_2.entry.js +1 -1
  111. package/dist/esm/salla-custom-fields.entry.js +1 -1
  112. package/dist/esm/salla-filters-widget.entry.js +1 -1
  113. package/dist/esm/salla-filters.entry.js +1 -1
  114. package/dist/esm/salla-gifting.entry.js +1 -1
  115. package/dist/esm/salla-hook.entry.js +1 -1
  116. package/dist/esm/salla-infinite-scroll.entry.js +1 -1
  117. package/dist/esm/salla-installment.entry.js +1 -1
  118. package/dist/esm/salla-list-tile.entry.js +1 -1
  119. package/dist/esm/salla-localization-modal.entry.js +1 -1
  120. package/dist/esm/salla-login-modal.entry.js +1 -1
  121. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  122. package/dist/esm/salla-loyalty-program.entry.js +1 -1
  123. package/dist/esm/salla-loyalty.entry.js +1 -1
  124. package/dist/esm/salla-maintenance-alert.entry.js +1 -1
  125. package/dist/esm/salla-menu.entry.js +1 -1
  126. package/dist/esm/salla-metadata.entry.js +1 -1
  127. package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
  128. package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
  129. package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
  130. package/dist/esm/salla-notification-item.entry.js +1 -1
  131. package/dist/esm/salla-notifications.entry.js +1 -1
  132. package/dist/esm/salla-offer-modal.entry.js +1 -1
  133. package/dist/esm/salla-offer.entry.js +1 -1
  134. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  135. package/dist/esm/salla-order-details-options.entry.js +1 -1
  136. package/dist/esm/salla-order-details.entry.js +1 -1
  137. package/dist/esm/salla-order-summary.entry.js +1 -1
  138. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  139. package/dist/esm/salla-orders.entry.js +1 -1
  140. package/dist/esm/salla-payments.entry.js +1 -1
  141. package/dist/esm/salla-placeholder.entry.js +1 -1
  142. package/dist/esm/salla-price-range.entry.js +1 -1
  143. package/dist/esm/salla-product-size-guide.entry.js +1 -1
  144. package/dist/esm/salla-products-list.entry.js +1 -6
  145. package/dist/esm/salla-products-slider.entry.js +3 -9
  146. package/dist/esm/salla-progress-bar.entry.js +1 -1
  147. package/dist/esm/salla-quick-order.entry.js +1 -1
  148. package/dist/esm/salla-rating-modal.entry.js +1 -1
  149. package/dist/esm/salla-scopes.entry.js +1 -1
  150. package/dist/esm/salla-search.entry.js +1 -1
  151. package/dist/esm/salla-skeleton.entry.js +1 -1
  152. package/dist/esm/salla-slider.entry.js +1 -1
  153. package/dist/esm/salla-social-share.entry.js +1 -1
  154. package/dist/esm/salla-social.entry.js +1 -1
  155. package/dist/esm/salla-tab-content_3.entry.js +1 -1
  156. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  157. package/dist/esm/salla-tooltip.entry.js +1 -1
  158. package/dist/esm/salla-trust-badges.entry.js +1 -1
  159. package/dist/esm/salla-user-menu.entry.js +1 -1
  160. package/dist/esm/salla-user-profile.entry.js +1 -1
  161. package/dist/esm/salla-user-settings.entry.js +1 -1
  162. package/dist/esm/salla-verify.entry.js +1 -1
  163. package/dist/esm/salla-wallet.entry.js +1 -1
  164. package/dist/esm/twilight.js +2 -2
  165. package/dist/esm/{vanilla-picker-BASTfXcg.js → vanilla-picker-DyzYo4Sm.js} +1 -1
  166. package/dist/twilight/{p-594d219c.entry.js → p-034d8a67.entry.js} +1 -1
  167. package/dist/twilight/{p-0c385d73.entry.js → p-064c2b11.entry.js} +1 -1
  168. package/dist/twilight/{p-e1bf6d23.entry.js → p-089a72be.entry.js} +1 -1
  169. package/dist/twilight/{p-22b1bd15.entry.js → p-0b3261ac.entry.js} +1 -1
  170. package/dist/twilight/{p-bb0585cc.entry.js → p-0b51caa0.entry.js} +1 -1
  171. package/dist/twilight/{p-c0ab0fc6.entry.js → p-0eb1f375.entry.js} +1 -1
  172. package/dist/twilight/{p-4d35a32b.entry.js → p-0f2acbdc.entry.js} +1 -1
  173. package/dist/twilight/{p-c3f515ae.entry.js → p-25589361.entry.js} +1 -1
  174. package/dist/twilight/{p-2c787ba0.entry.js → p-25787405.entry.js} +1 -1
  175. package/dist/twilight/p-28faa620.entry.js +4 -0
  176. package/dist/twilight/{p-e0e61f73.entry.js → p-2ff31dfc.entry.js} +1 -1
  177. package/dist/twilight/{p-1f6ead7d.entry.js → p-3240a1fe.entry.js} +1 -1
  178. package/dist/twilight/{p-0f1d7449.entry.js → p-36566eca.entry.js} +1 -1
  179. package/dist/twilight/{p-6f09b53e.entry.js → p-39b426d2.entry.js} +1 -1
  180. package/dist/twilight/p-3a82f07b.entry.js +4 -0
  181. package/dist/twilight/{p-75ab49a3.entry.js → p-3f39afe0.entry.js} +1 -1
  182. package/dist/twilight/{p-2dd98664.entry.js → p-443034a4.entry.js} +1 -1
  183. package/dist/twilight/{p-3c09b198.entry.js → p-4719199c.entry.js} +1 -1
  184. package/dist/twilight/{p-af3d4d0d.entry.js → p-47521f54.entry.js} +1 -1
  185. package/dist/twilight/{p-965fe2b3.entry.js → p-48cf39b8.entry.js} +1 -1
  186. package/dist/twilight/{p-db4f5b38.entry.js → p-4964523f.entry.js} +1 -1
  187. package/dist/twilight/{p-134c9d22.entry.js → p-49eedd45.entry.js} +1 -1
  188. package/dist/twilight/{p-3f8b06b3.entry.js → p-4db7b9b8.entry.js} +1 -1
  189. package/dist/twilight/{p-2405c0f7.entry.js → p-50ddd8ae.entry.js} +1 -1
  190. package/dist/twilight/{p-3c418ff7.entry.js → p-57b7835d.entry.js} +1 -1
  191. package/dist/twilight/{p-215ed586.entry.js → p-584a2bcc.entry.js} +1 -1
  192. package/dist/twilight/{p-f1156ab8.entry.js → p-645c1083.entry.js} +1 -1
  193. package/dist/twilight/{p-a0a6a255.entry.js → p-74445a67.entry.js} +1 -1
  194. package/dist/twilight/{p-f1be81ba.entry.js → p-74fec1e4.entry.js} +1 -1
  195. package/dist/twilight/{p-40ec7a33.entry.js → p-7b4b2370.entry.js} +1 -1
  196. package/dist/twilight/{p-fc6ddedc.entry.js → p-7cbebd14.entry.js} +1 -1
  197. package/dist/twilight/{p-721bb258.entry.js → p-7d9e3567.entry.js} +1 -1
  198. package/dist/twilight/{p-e2c6ed54.entry.js → p-93441a3d.entry.js} +1 -1
  199. package/dist/twilight/{p-8c2b148a.entry.js → p-99addee2.entry.js} +1 -1
  200. package/dist/twilight/{p-ac7f094e.entry.js → p-99bcb8d4.entry.js} +1 -1
  201. package/dist/twilight/{p-6daa8bd8.entry.js → p-9a20af32.entry.js} +1 -1
  202. package/dist/twilight/{p-58f562df.entry.js → p-9aaa0b02.entry.js} +1 -1
  203. package/dist/twilight/{p-f2v0udIe.js → p-BTSNi4-Y.js} +1 -1
  204. package/dist/twilight/{p-DbzHZVd1.js → p-BpRlzPzg.js} +1 -1
  205. package/dist/twilight/{p-CofhuO2Z.js → p-Bv6jrsv_.js} +1 -1
  206. package/dist/twilight/{p-CvLPGpFQ.js → p-CDyCpF-q.js} +1 -1
  207. package/dist/twilight/{p-tacIS_Xg.js → p-C_5WDzkV.js} +1 -1
  208. package/dist/twilight/{p-D5AsuzfF.js → p-Cd7SQKFA.js} +1 -1
  209. package/dist/twilight/{p-5mQqqwMU.js → p-DMwKr6kA.js} +1 -1
  210. package/dist/twilight/{p-BLbGjdAU.js → p-LocYOzht.js} +1 -1
  211. package/dist/twilight/{p-90eea1a9.entry.js → p-a591946d.entry.js} +1 -1
  212. package/dist/twilight/{p-3c6f9112.entry.js → p-a6c6f400.entry.js} +1 -1
  213. package/dist/twilight/{p-15242c87.entry.js → p-a7a6c8ad.entry.js} +1 -1
  214. package/dist/twilight/{p-50f5e38d.entry.js → p-a92b3c77.entry.js} +1 -1
  215. package/dist/twilight/{p-233b89ad.entry.js → p-afb766ef.entry.js} +1 -1
  216. package/dist/twilight/{p-1aead6d3.entry.js → p-b053fe1e.entry.js} +1 -1
  217. package/dist/twilight/{p-5485978c.entry.js → p-b06335bd.entry.js} +1 -1
  218. package/dist/twilight/{p-9797a552.entry.js → p-b3152bd4.entry.js} +1 -1
  219. package/dist/twilight/{p-6aecc925.entry.js → p-b870e878.entry.js} +1 -1
  220. package/dist/twilight/{p-6b6e2a52.entry.js → p-bad606d7.entry.js} +1 -1
  221. package/dist/twilight/{p-a08f5eae.entry.js → p-bf3ffab6.entry.js} +1 -1
  222. package/dist/twilight/{p-95db0124.entry.js → p-c045c6b1.entry.js} +1 -1
  223. package/dist/twilight/{p-e0ce2c0d.entry.js → p-c3351b4c.entry.js} +1 -1
  224. package/dist/twilight/{p-c90a6440.entry.js → p-c3b046bc.entry.js} +1 -1
  225. package/dist/twilight/{p-cf64bb24.entry.js → p-c481f4a2.entry.js} +1 -1
  226. package/dist/twilight/{p-c7719ce9.entry.js → p-c48d8192.entry.js} +1 -1
  227. package/dist/twilight/{p-a5df57f9.entry.js → p-c5b4e65a.entry.js} +1 -1
  228. package/dist/twilight/{p-d64027b9.entry.js → p-cb605a9e.entry.js} +1 -1
  229. package/dist/twilight/{p-7bfb9d71.entry.js → p-d2ce1566.entry.js} +1 -1
  230. package/dist/twilight/{p-907b40cd.entry.js → p-d3b0bd92.entry.js} +1 -1
  231. package/dist/twilight/p-d56efab2.entry.js +4 -0
  232. package/dist/twilight/{p-6dbcd99e.entry.js → p-d9741316.entry.js} +1 -1
  233. package/dist/twilight/{p-9d937a82.entry.js → p-dbf28d24.entry.js} +1 -1
  234. package/dist/twilight/{p-dfc75ce2.entry.js → p-e7cd6030.entry.js} +1 -1
  235. package/dist/twilight/{p-CV1rqKQz.js → p-ea1dIZhh.js} +1 -1
  236. package/dist/twilight/{p-64ac4c0c.entry.js → p-ea41c97a.entry.js} +1 -1
  237. package/dist/twilight/{p-f8fb3130.entry.js → p-ee2501d9.entry.js} +1 -1
  238. package/dist/twilight/{p-f9fcf183.entry.js → p-eef758b0.entry.js} +1 -1
  239. package/dist/twilight/{p-0ede455c.entry.js → p-f66c013f.entry.js} +1 -1
  240. package/dist/twilight/{p-04664fcb.entry.js → p-fb93477b.entry.js} +1 -1
  241. package/dist/twilight/{p-585a349f.entry.js → p-fcebbb86.entry.js} +1 -1
  242. package/dist/twilight/{p-BGB1zYFQ.js → p-yvU70SQX.js} +1 -1
  243. package/dist/twilight/twilight.esm.js +1 -1
  244. package/package.json +5 -5
  245. package/dist/twilight/p-7c8c6c47.entry.js +0 -4
  246. package/dist/twilight/p-a386b02a.entry.js +0 -4
  247. package/dist/twilight/p-de42ef8c.entry.js +0 -4
@@ -0,0 +1,4 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import{r as t,c as a,h as s,H as i,a as e,e as l}from"./p-ea1dIZhh.js";import{P as o}from"./p-DY4LZmNP.js";import{H as n}from"./p-CHf8XdiS.js";import{B as p}from"./p-D3mWkc-3.js";import{i as r}from"./p-BsXh13x8.js";import{C as d}from"./p-C6jIkM-X.js";import"./p-CgtvEd63.js";const c=class{constructor(s){t(this,s),this.success=a(this,"success"),this.failed=a(this,"failed"),this.hostAttributes={},this.hasPreOrder=!1,this.productStatus="sale",this.productType="product",this.selectedOptions=[],this.buyNowText=salla.lang.get("pages.products.buy_now"),this.isDesktopViewport="undefined"==typeof window||window.matchMedia("(min-width: 768px)").matches,this.viewportMediaQuery=null,this.onViewportChange=t=>{this.isDesktopViewport=t.matches,this.btn?.setText(t.matches&&this.passedLabel?this.passedLabel:this.getLabel())},salla.lang.onLoaded((()=>{this.buyNowText=salla.lang.get("pages.products.buy_now")}))}getLabel(){return"sale"===this.productStatus&&this.supportStickyBar&&!this.isDesktopViewport&&this.showQuickBuy&&this.isApplePayActive?o:this.hasPreOrder?salla.lang.get("pages.products.pre_order_now"):"sale"===this.productStatus&&"booking"===this.productType?salla.lang.get("pages.cart.book_now"):"sale"===this.productStatus?salla.lang.get("pages.cart.add_to_cart"):"donating"!==this.productType?salla.lang.get("pages.products.out_of_stock"):salla.lang.get("pages.products.donation_exceed")}addProductToCart(t){if("booking"===this.productType)return t.preventDefault(),this.addBookingProduct();if("submit"===this.hostAttributes.type)return!1;t.preventDefault(),this.btn?.disable();const a=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);return a&&"function"==typeof a.validateAndScroll?a.validateAndScroll().then((async t=>{const a={isValid:t,component:this};if(await salla.hooks.call("salla-add-product-button","validate",a),a.isValid)return this._proceedAddToCart();this.btn?.enable()})).catch((()=>{this.btn?.enable()})):this._proceedAddToCart()}async _proceedAddToCart(){const t=this.host.closest("salla-products-list, salla-products-slider"),a=Object.entries({id:this.productId,donation_amount:this.donatingAmount,quantity:this.quantity,endpoint:"quickAdd",source:n.getProductsSource(t?.getAttribute("source"))}).reduce(((t,[a,s])=>s?(t[a]=s,t):t),{});return salla.cart.addItem(a).then((async t=>(this.selectedOptions=[],this.btn?.enable(),this.success.emit(t),t))).catch((t=>{this.failed.emit(t),this.btn?.enable()}))}addBookingProduct(){return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("booking::add",this.productId),void salla.event.dispatch("login::open")):salla.booking.add(this.productId).then((t=>this.success.emit(t))).catch((t=>this.failed.emit(t)))}getBtnAttributes(){for(let t=0;t<this.host.attributes.length;t++)["id","class"].includes(this.host.attributes[t].name)||(this.hostAttributes[this.host.attributes[t].name]=this.host.attributes[t].value);return this.hostAttributes}getQuickBuyBtnAttributes(){return{...this.getBtnAttributes(),type:this.supportStickyBar&&!this.isDesktopViewport?"plain":"donating"==this.productType?"donate":"buy"}}miniCheckoutWidget(){let t=salla.config.get("store.id");if(t)return s("salla-mini-checkout-widget",{language:salla.lang.locale,"store-id":t,config:{user:salla.config.get("user"),failure_url:window.location.href},products:[this.productId],api:salla.config.get("store.api"),outline:!0,"form-selector":"form.product-form",class:"s-add-product-button-mini-checkout"},s("div",{slot:"widget-label",class:"s-add-product-button-mini-checkout-content"},s("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>full-wallet</title>\n<path d="M29 12h-26c-0.668-0.008-1.284-0.226-1.787-0.59l0.009 0.006c-0.744-0.552-1.222-1.428-1.222-2.416 0-1.657 1.343-3 2.999-3h6c0.552 0 1 0.448 1 1s-0.448 1-1 1v0h-6c-0.552 0-1 0.448-1 1 0 0.326 0.156 0.616 0.397 0.798l0.002 0.002c0.167 0.12 0.374 0.194 0.599 0.2l0.001 0h26c0.552 0 1 0.448 1 1s-0.448 1-1 1v0zM27 12c-0.552 0-1-0.448-1-1v0-3h-3c-0.552 0-1-0.448-1-1s0.448-1 1-1v0h4c0.552 0 1 0.448 1 1v0 4c0 0.552-0.448 1-1 1v0zM29 30h-26c-1.657 0-3-1.343-3-3v0-18c0-0.552 0.448-1 1-1s1 0.448 1 1v0 18c0 0.552 0.448 1 1 1v0h25v-5c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM29 18c-0.552 0-1-0.448-1-1v0-6c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM31 24h-7c-2.209 0-4-1.791-4-4s1.791-4 4-4v0h7c0.552 0 1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM24 18c-1.105 0-2 0.895-2 2s0.895 2 2 2v0h6v-4zM25 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-2.306 1.152c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 3.2-1.6c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1v0zM21 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-15.104 7.552c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 16-8c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1-0.001 0-0.001 0-0.002 0h0z"></path>\n</svg>\n'}),this.buyNowText))}componentWillLoad(){return salla.onReady().then((()=>{if(document.documentElement.classList.add("hydrated"),this.showQuickBuy=this.quickBuy&&salla.config.get("store.settings.buy_now")&&"sale"==this.productStatus&&"booking"!==this.productType,this.isApplePayActive=window.ApplePaySession?.canMakePayments()&&salla.config.get("store.settings.payments")?.includes("apple_pay")&&salla.config.get("store.settings.is_salla_gateway",!1),this.passedLabel=this.host.innerHTML.replace("\x3c!----\x3e","").trim(),this.passedLabel&&this.isDesktopViewport)return this.btn?.setText(this.passedLabel);"submit"===this.host.getAttribute("type")&&this.supportStickyBar&&(this.viewportMediaQuery=window.matchMedia("(min-width: 768px)"),this.viewportMediaQuery.addEventListener("change",this.onViewportChange))}))}render(){return this.host.closest(".swiper-slide")?.classList.contains("swiper-slide-duplicate")?"":this.hasSubscribedOptions?s(i,null,s("salla-product-availability",{...this.getBtnAttributes(),"is-subscribed":!0},s("span",{class:"s-hidden"},s("slot",null)))):"out-and-notify"===this.productStatus&&this.channels||this.hasOutOfStockOption?s(i,null,s("salla-product-availability",{...this.getBtnAttributes()},s("span",{class:"s-hidden"},s("slot",null)))):s(i,{class:{"s-add-product-button-with-quick-buy":this.showQuickBuy,"s-add-product-button-with-sticky-bar":this.supportStickyBar,"s-add-product-button-with-apple-pay":this.showQuickBuy&&this.isApplePayActive}},s("div",{class:{"s-add-product-button-main":this.showQuickBuy,"w-full":!document.getElementById("fast-checkout-js")||["financial_support","donating"].includes(this.productType)}},s("salla-button",{color:"sale"===this.productStatus?"primary":"light",type:"button",fill:"sale"===this.productStatus?"solid":"outline",ref:t=>this.btn=t,onClick:t=>this.addProductToCart(t),disabled:"sale"!==this.productStatus,...this.getBtnAttributes(),"loader-position":"center"},s("slot",null)),this.showQuickBuy&&document.getElementById("fast-checkout-js")&&!["financial_support","donating"].includes(this.productType)?this.miniCheckoutWidget():""),this.showQuickBuy&&this.isApplePayActive?s("salla-quick-buy",{...this.getQuickBuyBtnAttributes()}):"")}async componentDidLoad(){await Salla.hooks.registerComponent("salla-add-product-button",this),this.notifyOptionsAvailability&&salla.event.on("product-options::change",(async t=>{if(!["thumbnail","color","single-option"].includes(t.option.type))return;this.hasSubscribedOptions=!1,this.selectedOptions=await(document.querySelector(`salla-product-options[product-id="${this.productId}"]`)?.getSelectedOptions()),this.hasOutOfStockOption=await(document.querySelector(`salla-product-options[product-id="${this.productId}"]`)?.hasOutOfStockOption());let a=salla.storage.get(`product-${this.productId}-subscribed-options`);if((a||this.subscribedOptions)&&this.hasOutOfStockOption)if(salla.config.isGuest()){const t=a?a.map((t=>t.split(",").map((t=>parseInt(t))))):[];this.hasSubscribedOptions=t.length>0&&t.some((t=>t.every((t=>this.selectedOptions.some((a=>a.id===t))))))}else this.hasSubscribedOptions=!(!this.subscribedOptions||"null"===this.subscribedOptions||"[]"===this.subscribedOptions)&&JSON.parse(this.subscribedOptions).some((t=>t.every((t=>this.selectedOptions.some((a=>a.id===t))))))}))}componentDidRender(){!this.passedLabel||this.supportStickyBar&&!this.isDesktopViewport?(this.btn?.setText(this.getLabel()),salla.lang.onLoaded((()=>this.btn?.setText(this.getLabel())))):this.btn?.setText(this.passedLabel)}disconnectedCallback(){this.viewportMediaQuery?.removeEventListener("change",this.onViewportChange)}get host(){return e(this)}};c.style=":host{display:block}salla-add-product-button[width=wide]{width:100%}";const h=class{constructor(a){t(this,a),this.isUser=salla.config.isUser(),this.translationLoaded=!1,this.notifyOptionsAvailability=!1,this.isSubscribed=!1,this.handleSubmitOptions=async()=>{let t={id:this.productId};if(!this.notifyOptionsAvailability)return t;let a=document.querySelector(`salla-product-options[product-id="${this.productId}"]`),s=Object.values(await(a?.getSelectedOptionsData())||{});if(s.length&&!await(a?.reportValidity())){let t=salla.lang.get("common.messages.required_fields");throw salla.error(t),t}return t.options=[],s.forEach((a=>{a&&!isNaN(a)&&t.options.push(Number(a))})),t},this.typing=t=>{const a=t.target.nextElementSibling;t.target.classList.remove("s-has-error"),a?.classList.contains("s-product-availability-error-msg")&&(a.innerText=""),13===t.keyCode&&this.submit()},salla.lang.onLoaded((()=>{this.translationLoaded=!0,this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.modal?.setTitle(this.title_)})),this.productId||(this.productId=salla.config.get("page.id")),this.isUser||(this.channelsWatcher(this.channels),this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.host.removeAttribute("title"),this.isVisitorSubscribed=this.notifyOptionsAvailability?"":salla.storage.get(`product-${this.productId}-subscribed`))}channelsWatcher(t){this.channels_=t?t.split(","):[]}openModel(){this.handleSubmitOptions().then((t=>t?this.modal.open():null))}async submit(){let t=await this.handleSubmitOptions();if(this.isUser)return salla.api.product.availabilitySubscribe(t).then((()=>this.isSubscribed=!0));if(this.channels_.includes("sms")){let{phone:a,countryCode:s}=await this.mobileInput.getValues();t.country_code=s,t.phone=a}return this.channels_.includes("email")&&""!==this.email.value&&(t.email=this.email.value),await this.validateform(),this.btn.load().then((()=>this.btn.disable())).then((()=>salla.api.product.availabilitySubscribe(t))).then((()=>{if(!this.notifyOptionsAvailability)return salla.storage.set(`product-${this.productId}-subscribed`,!0),void(this.isSubscribed=!0);if(t.options.length){let a=salla.storage.get(`product-${this.productId}-subscribed-options`)||[],s=t.options.join(",");a.includes(s)?salla.log("already subscribed to this options"):(a.push(s),salla.storage.set(`product-${this.productId}-subscribed-options`,a),this.isSubscribed=!0)}})).then((()=>this.btn.stop())).then((()=>this.modal.close())).catch((()=>this.btn.stop()&&this.btn.enable()))}async validateform(){try{if(this.channels_.includes("email")){const t=n.isValidEmail(this.email.value);if(t)return;!t&&this.validateField(this.email,salla.lang.get("common.elements.email_is_valid"))}if(this.channels_.includes("sms")&&await this.mobileInput.isValid())return}catch(t){throw"Please insert required fields"}}validateField(t,a){t.classList.add("s-has-error"),t.nextElementSibling.innerText="* "+a}render(){return s(i,{key:"e5b3121a6e352338ff666ba419100150e838e0d2",class:"s-product-availability-wrap"},this.isSubscribed||this.isVisitorSubscribed?s("div",{class:"s-product-availability-subscribed"},s("span",{innerHTML:p,class:"s-product-availability-subs-icon"}),salla.lang.get("pages.products.notify_availability_success")):s("salla-button",{width:"wide",onClick:()=>this.isUser?this.submit():this.openModel()},salla.lang.get("pages.products.notify_availability")),this.isUser||this.isSubscribed||this.isVisitorSubscribed?"":this.renderModal())}renderModal(){return s("salla-modal",{ref:t=>this.modal=t,"modal-title":this.title_,subTitle:salla.lang.get("pages.products.notify_availability_subtitle"),width:"sm"},s("span",{slot:"icon",class:"s-product-availability-header-icon",innerHTML:p}),s("div",{class:"s-product-availability-body"},this.channels_.includes("email")?[s("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.email")),s("input",{class:"s-product-availability-input",onKeyDown:t=>this.typing(t),placeholder:salla.lang.get("common.elements.email_placeholder")||"your@email.com",ref:t=>this.email=t,type:"email"}),s("span",{class:"s-product-availability-error-msg"})]:"",this.channels_.includes("sms")?[s("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.mobile")),s("salla-tel-input",{ref:t=>this.mobileInput=t,onKeyDown:t=>this.typing(t)})]:""),s("div",{slot:"footer",class:"s-product-availability-footer"},s("salla-button",{class:"modal-cancel-btn",width:"wide",color:"light",fill:"outline",onClick:()=>this.modal.close()},salla.lang.get("common.elements.cancel")),s("salla-button",{class:"submit-btn","loader-position":"center",width:"wide",ref:t=>this.btn=t,onClick:()=>this.submit()},salla.lang.get("common.elements.submit"))))}get host(){return e(this)}static get watchers(){return{channels:["channelsWatcher"]}}};var u,y;h.style="",function(t){t.COLOR="color",t.DATE="date",t.DATETIME="datetime",t.DONATION="donation",t.IMAGE="image",t.MULTIPLE_OPTIONS="multiple-options",t.NUMBER="number",t.SINGLE_OPTION="single-option",t.DIGITAL_CARD_VALUE="digital-code-value",t.COUNTRY="country",t.SPLITTER="splitter",t.TEXT="text",t.TEXTAREA="textarea",t.THUMBNAIL="thumbnail",t.TIME="time",t.RADIO="radio",t.CHECKBOX="checkbox",t.MAP="map",t.FILE="file",t.COLOR_PICKER="color_picker",t.BOOKING="booking"}(u||(u={})),function(t){t.Sar="SAR"}(y||(y={}));const m=class{constructor(i){if(t(this,i),this.changed=a(this,"changed"),this.fileTypes={pdf:"application/pdf",png:"image/png",jpg:"image/jpeg",word:"application/doc,application/ms-doc,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",exl:"application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",txt:"text/plain"},this.outOfStockText="",this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.selectDonationAmount=salla.lang.getWithDefault("pages.products.select_donation_amount","تحديد مبلغ التبرع"),this.selectAmount=salla.lang.getWithDefault("pages.products.select_amount","اختر المبلغ"),this.isCustomDonation=!1,this.selectedOptions=[],this.canDisabled=!1,this.disableCardValue=!0,this.availableDigitalCardValues=[],this.userInitiatedValidation=!1,this.isCartMode=!1,this.outSkus=[],this.ignoreDefaultCardValue=!1,this.productId=salla.config.get("page.id"),this.handleDonationOptions=(t,a,s)=>{if("custom"===a&&"input"===s){const a=t.target;return salla.helpers.inputDigitsOnly(a),salla.event.emit("product-options::donation-changed",{id:this.productId,price:a.value}),void a.dispatchEvent(new window.Event("change",{bubbles:!0}))}const i="option"===s?String(t.target?.value??""):"";if("option"===s&&"custom"===a&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()),this.isCustomDonation="custom"===i,this.donationInput){if("custom"===i?(this.donationInput.value="",this.donationInput.focus()):this.donationInput.value=i,"custom"===a)return;salla.event.emit("product-options::donation-changed",{id:this.productId,price:i})}},this.hideLabel=t=>!(t.type!==u.DONATION||!t.donation||t.donation.can_donate),this.getExpireDonationMessage=t=>{if(!t.donation)return;const a=t.donation.target_amount<=t.donation.collected_amount;return s("div",{class:{"s-product-options-donation-message":!0,"s-product-options-donation-completed":a,"s-product-options-donation-expired":!a}},s("p",null,t.donation.target_message),s("span",{innerHTML:a?salla.money(t.donation.target_amount):""}))},salla.lang.onLoaded((()=>{this.outOfStockText=salla.lang.get("pages.products.out_of_stock"),this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.selectDonationAmount=salla.lang.getWithDefault("pages.products.select_donation_amount","تحديد مبلغ التبرع"),this.selectAmount=salla.lang.getWithDefault("pages.products.select_amount","اختر المبلغ")})),this.options)try{return void this.setOptionsData(Array.isArray(this.options)?this.options:JSON.parse(this.options))}catch(t){salla.log("Bad json passed via options prop")}Array.isArray(this.optionsData)||(salla.log("Options is not an array[] ---\x3e ",this.optionsData),this.setOptionsData([])),this.productId&&!salla.url.is_page("cart")&&salla.api.product.getDetails(this.productId,["options"]).then((t=>this.setOptionsData(t.data.options)))}async setOptionsData(t){this.optionsData=t;const a=this;this.optionsData[0]?.details?.forEach((function(t){Object.entries(t.skus_availability||{}).filter((t=>!t[1])).map((t=>a.outSkus.push(Number(t[0]))))}))}async getSelectedOptionsData(){const t={},a=this.host.getElementSallaData(),s=void 0!==this.bundleContext?this.bundleContext:null;return a.forEach(((a,i)=>{if(s){if(i.startsWith("bundle[")&&i.includes("[options][")){const s=i.split("[options][")[1].replace("]","");t[s]=a}}else i.startsWith("options[")&&(t[i.replace("options[","").replace("]","")]=a)})),t}async reportValidity(){const t=this.host.querySelectorAll("[required]");let a=!0;for(let s=0;s<t.length;s++)"reportValidity"in t[s]&&!t[s].reportValidity()&&(a=!1);return a}async hasOutOfStockOption(){return this.selectedOptions.some((t=>t.is_out))||this.selectedSkus?.length&&this.selectedSkus?.every((t=>this.outSkus.includes(t)))}async getSelectedOptions(){return this.selectedOptions}async getOption(t){return this.optionsData.find((a=>a.id===t))}invalidHandler(t,a){const s=t.target.closest(".s-product-options-option");s.classList.contains("s-product-options-option-error")||s.classList.add("s-product-options-option-error"),!this.userInitiatedValidation&&!salla.helpers.isIOSDevice()||salla.url.is_page("cart")||this.host.querySelector(".s-product-options-option-error")===s&&this.scrollToElement(s)}scrollToElement(t){t&&t.scrollIntoView({behavior:"smooth",block:"center"})}changedHandler(t,a,s=!0){const i={event:t,option:a,detail:null,productId:this.productId};if(a.details){const s=a.details.find((a=>Number(a.id)===Number(t.target.value)));i.detail=s}"country"===a.type&&this.handleCountryOptionChange(t,i.detail);const e=t.target.closest(".s-product-options-option");(t.target.value||(a.type===u.FILE||a.type===u.IMAGE)&&"added"===t.type||a.type===u.MAP&&"selected"===t.type&&t.target.lat&&t.target.lng)&&setTimeout((()=>{e.classList.remove("s-product-options-option-error")}),200),a.type===u.DONATION&&salla.event.emit("product-options::donation-changed",{id:this.productId,price:t.target.value}),this.setSelectedSkus(),this.handleRequiredMultipleOptions(a);const l=this.selectedOptions.findIndex((t=>t.option_id===i.option.id));if(i.option.type===u.MULTIPLE_OPTIONS){const t=this.selectedOptions.findIndex((t=>t.option_id===i.option.id&&t?.id===i.detail?.id));t>-1?this.selectedOptions.splice(t,1):this.selectedOptions.push({...i.detail,option_id:i.option.id})}else i.detail&&0!==Object.keys(i.detail).length?l>-1?this.selectedOptions[l]={...i.detail,option_id:i.option.id}:this.selectedOptions.push({...i.detail,option_id:i.option.id}):l>-1&&this.selectedOptions.splice(l,1);this.optionsData=this.optionsData.map((t=>t.id===i.option.id?{...t,details:t.details.map((t=>({...t,is_selected:i.option.type===u.MULTIPLE_OPTIONS?this.selectedOptions.some((a=>a.id===t.id)):Number(t.id)===Number(i.detail?.id),value:i.detail?.value})))}:t)),s&&(this.changed.emit(i),salla.event.emit("product-options::change",i))}setSelectedSkus(){this.selectedSkus=this.selectedOptions.map((t=>Object.keys(t.skus_availability||{}))).reduce(((t,a)=>t.filter((t=>a.includes(t)))),[]).map((t=>Number(t)))}handleRequiredMultipleOptions(t){if(t.type!==u.MULTIPLE_OPTIONS||!t.required)return;const a=this.host.querySelector(`[data-option-id="${t.id}"]`),s=a.querySelectorAll("input:checked").length;a.querySelectorAll("input").forEach((t=>t.toggleAttribute("required",!s)))}getLatLng(t,a){return t?t.split(",")["lat"===a?0:1]:""}getDisplayForType(t){return this[`${t.type}Option`]?this[`${t.type}Option`](t):t.type===u.COLOR_PICKER?this.colorPickerOption(t):t.type===u.MULTIPLE_OPTIONS?this.multipleOptions(t):t.type===u.SINGLE_OPTION?this.singleOption(t):t.type===u.RADIO?this.radioOption(t):t.type===u.DIGITAL_CARD_VALUE?this.digitalCardValuesOption(t):t.type===u.COUNTRY?this.countryOption(t):t.type===u.BOOKING&&salla.url.is_page("cart")?s("salla-booking-field",{onInvalidInput:a=>this.invalidHandler(a,t),option:t,productId:t.value}):(salla.log(`Couldn't find options type(${t.type})😢`),"")}getOptionShownWhen(t){return t.visibility_condition?{"data-show-when":`options[${t.visibility_condition.option}] ${t.visibility_condition.operator} ${t.visibility_condition.value}`}:{}}getAvailableDigitalCardSKUs(t){const a=this.optionsData.find((({type:t})=>"digital-code-value"===t));if(!a)throw new Error("product-options:: No digital card options found");const s=Object.keys(t.skus_availability).filter((a=>!1===t.skus_availability[a]));this.availableDigitalCardValues=a.details.filter((t=>!Object.keys(t.skus_availability).filter((t=>s.includes(t))).length))}handleCountryOptionChange(t,a){t.stopImmediatePropagation(),this.ignoreDefaultCardValue=!0;const s=this.host.querySelector("input[data-code-value]:checked");if(s&&(s.checked=!1),!this.optionsData.find((({type:t})=>"digital-code-value"===t)))throw new Error("product-options:: No digital card options found");this.getAvailableDigitalCardSKUs(a)}getSelectedDigitalCardOptions(t){const a=t.details.find((t=>t.is_selected)),s=t.details.find((t=>!!t.is_default))||t.details[0];if(["digital-code-value","country"].includes(t.type))return a||s}async componentWillLoad(){if(salla.url.is_page("cart")&&(this.disableCardValue=!1,this.fillSelectedOptions()),this.config)try{this.optionConfig="string"==typeof this.config?JSON.parse(this.config):this.config}catch(t){console.error("Failed to parse JSON in config prop:",t)}if(this.optionsData.filter((({type:t})=>["country","digital-card-value"].includes(t))).length>0&&salla.url.is_page("cart")){const t=this.optionsData.find((t=>"country"===t.type)),a=t&&this.getSelectedDigitalCardOptions(t);a&&this.getAvailableDigitalCardSKUs(a)}return this.outOfStockText=salla.lang.get("pages.products.out_of_stock"),await salla.onReady(),this.canDisabled=!salla.config.get("store.settings.product.notify_options_availability")||salla.url.is_page("cart"),this.pasteHandler=this.handlePaste.bind(this),document.addEventListener("paste",this.pasteHandler),!salla.storage.get("cart.id")&&this.optionsData.some((t=>["file","image"].includes(t.type)))?salla.api.cart.getCurrentCartId(!1,"salla-product-options"):null}disconnectedCallback(){this.pasteHandler&&document.removeEventListener("paste",this.pasteHandler)}handlePaste(t){const a=t.target;if(!(Salla.helpers.isAppleDevice()&&(a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement)&&a.classList.contains("s-form-control")&&this.host.contains(a)))return;t.preventDefault();const s=t.clipboardData?.getData("text")||"",i=a.selectionStart,e=a.selectionEnd,l=a.value.slice(0,i)+s+a.value.slice(e);a.value=l,a.setSelectionRange(i+s.length,i+s.length);try{a.dispatchEvent(new window.Event("change",{bubbles:!0}))}catch(t){Salla.log("Error on change")}}hideDigitalCardsOptions(t){return this.disableCardValue&&t.type===u.DIGITAL_CARD_VALUE&&!salla.url.is_page("cart")}render(){if(0!==this.optionsData?.length)return s(i,{class:"s-product-options-wrapper"},s("salla-conditional-fields",null,this.optionsData.map((t=>s("div",{key:t.id,class:"s-product-options-option-container"+(t.visibility_condition||this.hideDigitalCardsOptions(t)?" hidden":""),"data-option-id":t.id,...this.getOptionShownWhen(t)},"splitter"===t.name?this.splitterOption():s("div",{class:{"s-product-options-option":!0,"s-product-options-option-booking":t.type===u.BOOKING&&salla.url.is_page("cart")},"data-option-type":t.type,"data-option-required":`${t.required}`},s("label",{htmlFor:this.generateInputId(t.id),class:"s-product-options-option-label "+(this.hideLabel(t)?"s-product-options-option-label-hidden":"")},s("b",null,t.name,t.required&&s("span",null," * ")," "),s("small",null,t.placeholder)),s("div",{class:"s-product-options-option-content "+(this.hideLabel(t)||t.type===u.BOOKING&&salla.url.is_page("cart")?"s-product-options-option-content-full-width":"")},this.getDisplayForType(t))))))))}generateUniqueKey(t){const a=this.bundleContext;let s=this.uniqueKey?`${t}-${this.uniqueKey}`:t;if(a)try{const t="string"==typeof a?JSON.parse(a):a,{sectionId:i,productId:e}=t;s=`${s}-bundle-${i}-${e}`}catch(t){}return s}generateInputId(t){return this.generateUniqueKey(`option-${t}`)}generateInputName(t){const a=this.bundleContext,s=t.toString();if(a)try{const t="string"==typeof a?JSON.parse(a):a,{sectionId:i,productId:e}=t;return`bundle[${i}][${e}][options][${s}]`}catch(t){return`options[${s}]`}return`options[${s}]`}fillSelectedOptions(){this.selectedOptions=this.optionsData.reduce(((t,a)=>{const s=a.details.filter((t=>t.is_selected)).map((t=>({...t,option_id:a.id})));return t.concat(s)}),[])}async componentDidLoad(){if(!this.optionsData?.length)return;await Salla.hooks.registerComponent("salla-product-options",this);const t=this.optionsData.find((t=>t.type===u.DONATION))?.details?.find((t=>t.is_selected));if(t&&setTimeout((()=>{salla.event.emit("product-options::donation-changed",{id:this.productId,price:t.additional_price})}),1e3),!salla.url.is_page("cart")&&!this.isCartMode){const t=[u.SINGLE_OPTION,u.MULTIPLE_OPTIONS,u.COLOR,u.THUMBNAIL,u.DONATION,u.DIGITAL_CARD_VALUE,u.COUNTRY];this.optionsData.some((a=>t.includes(a.type)&&a.details?.some((t=>t.is_selected))))&&requestAnimationFrame((()=>{try{const t=this.host.closest("form");if(!t)return;const a=new FormData(t),s=a.get("id")||a.get("product_id");if(s&&String(s)!==String(this.productId))return;salla.product.getPrice(a)}catch(t){salla.log("Error updating price for pre-selected options:",t)}}))}}async enterCartMode(){this.isCartMode=!0,this.disableCardValue=!1,this.canDisabled=!0,this.fillSelectedOptions()}async enableUserInitiatedValidation(){this.userInitiatedValidation=!0}async validateAndScroll(){return await this.enableUserInitiatedValidation(),this.reportValidity()}donationOption(t,a){return s("div",{class:"s-product-options-donation-wrapper"},t.donation?.can_donate?[t.donation?s("div",{key:t.id,class:"s-product-options-donation-progress"},s("salla-progress-bar",{donation:t.donation})):"",t.details.length?[s("h4",{key:t.id},this.selectAmount),s("div",{key:t.id,class:"s-product-options-donation-options"},t.details.map(((a,i)=>s("div",{key:t.id,class:"s-product-options-donation-options-item"},s("input",{id:this.generateUniqueKey(`donation-option-${i}`),type:"radio",name:"donating_option",checked:a.is_selected,value:a.additional_price,onChange:s=>this.handleDonationOptions(s,a,"option",t)}),s("label",{htmlFor:this.generateUniqueKey(`donation-option-${i}`)},s("span",{innerHTML:salla.money(a.name)}))))),t.donation?.custom_amount_enabled?s("div",{class:"s-product-options-donation-options-item"},s("input",{id:this.generateUniqueKey("donation-option-custom"),type:"radio",name:"donating_option",value:"custom",onChange:a=>this.handleDonationOptions(a,"custom","option",t)}),s("label",{htmlFor:this.generateUniqueKey("donation-option-custom")},s("span",null," ",this.selectDonationAmount," "))):"")]:"",s("div",{key:t.id,class:{"s-product-options-donation-input-group":!0,shown:!t.details.length||t.details.length&&this.isCustomDonation}},s("input",{type:"text",id:"donating-amount",name:"donation_amount",class:"s-form-control",ref:t=>{this.donationInput=t},value:t.details.length&&t.details.some((t=>t.is_selected))?t.details.find((t=>t.is_selected)).additional_price:t.value,placeholder:t.placeholder,onInput:a=>this.handleDonationOptions(a,"custom","input",t),onBlur:a=>this.changedHandler(a,t),onInvalid:a=>this.invalidHandler(a,t)}),s("span",{class:"s-product-options-donation-amount-currency"},salla.config.currency(salla.config.get("user.currency_code")).symbol))]:this.getExpireDonationMessage(t))}fileUploader(t,a=null){return s("salla-file-upload",{...a||{},"payload-name":"file",value:t.value,"instant-upload":!0,name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,height:"120px",onAdded:a=>this.changedHandler(a,t),url:salla.cart.api.getUploadImageEndpoint(),"form-data":{cart_item_id:this.productId,product_id:this.productId},onInvalidInput:a=>this.invalidHandler(a,t),class:{"s-product-options-image-input":!0,required:t.required}},s("div",{class:"s-product-options-filepond-placeholder"},s("span",{class:"s-product-options-filepond-placeholder-icon",innerHTML:a.accept?.split(",").every((t=>t.includes("image")))?d:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>file-upload</title>\n<path d="M21.333 24c0.341 0 0.683-0.131 0.943-0.391 0.521-0.521 0.521-1.364 0-1.885l-5.333-5.333c-0.123-0.123-0.271-0.22-0.433-0.288-0.327-0.135-0.693-0.135-1.019 0-0.163 0.068-0.311 0.165-0.433 0.288l-5.333 5.333c-0.521 0.521-0.521 1.364 0 1.885s1.364 0.521 1.885 0l3.057-3.057v10.115c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-10.115l3.057 3.057c0.26 0.26 0.601 0.391 0.943 0.391zM28.943 9.724l-9.333-9.333c-0.249-0.251-0.589-0.391-0.943-0.391h-12c-2.205 0-4 1.795-4 4v24c0 2.205 1.795 4 4 4h4c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333h-4c-0.735 0-1.333-0.599-1.333-1.333v-24c0-0.735 0.599-1.333 1.333-1.333h11.448l8.552 8.552v16.781c0 0.735-0.599 1.333-1.333 1.333h-4c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h4c2.205 0 4-1.795 4-4v-17.333c0-0.353-0.14-0.693-0.391-0.943z"></path>\n</svg>\n'}),s("p",{class:"s-product-options-filepond-placeholder-text"},salla.lang.get("common.uploader.drag_and_drop")),s("span",{class:"filepond--label-action"},salla.lang.get("common.uploader.browse"))))}imageOption(t){return this.fileUploader(t,{accept:"image/png,image/jpeg,image/jpg,image/gif"})}fileOption(t){const a=t.details.map((t=>this.fileTypes[t.name])).filter(Boolean);return a?.length?this.fileUploader(t,{accept:a.join(",")}):"File types not selected."}numberOption(t){return s("input",{type:"text",value:t.value,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onBlur:a=>this.changedHandler(a,t),onInvalid:a=>this.invalidHandler(a,t),onInput:t=>salla.helpers.inputDigitsOnly(t.target)})}splitterOption(){return s("div",{class:"s-product-options-splitter"})}textOption(t){return s("div",{class:"s-product-options-text"},s("input",{type:"text",value:t.value,maxLength:t?.length,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t)}))}textareaOption(t){return s("div",{class:"s-product-options-textarea"},s("div",{class:"mt-1"},s("textarea",{rows:4,value:t.value,maxLength:t?.length,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t)})))}mapOption(t){return s("salla-map",{zoom:15,lat:this.getLatLng(t.value,"lat"),lng:this.getLatLng(t.value,"lng"),name:this.generateInputName(t.id),searchable:!0,required:t.required,onInvalidInput:a=>this.invalidHandler(a,t),onSelected:a=>this.changedHandler(a,t)})}colorPickerOption(t){return s("salla-color-picker",{onSubmitted:a=>this.changedHandler(a,t),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,onInvalidInput:a=>this.invalidHandler(a,t),color:t.value})}timeOption(t){return s("salla-datetime-picker",{noCalendar:!0,enableTime:!0,dateFormat:"h:i K",value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,name:this.generateInputName(t.id),class:"s-product-options-time-element",onInvalidInput:a=>this.invalidHandler(a,t),onPicked:a=>this.changedHandler(a,t)})}dateOption(t){return s("div",{class:"s-product-options-date-element"},s("salla-datetime-picker",{value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,minDate:new Date,name:this.generateInputName(t.id),onInvalidInput:a=>this.invalidHandler(a,t),onPicked:a=>this.changedHandler(a,t)}))}datetimeOption(t){return s("div",{class:"s-product-options-datetime-element"},s("salla-datetime-picker",{enableTime:!0,value:t.value,dateFormat:"Y-m-d G:i:K",placeholder:t.name,required:!t.visibility_condition&&t.required,name:this.generateInputName(t.id),maxDate:t.to_date_time,minDate:t.from_date_time,onInvalidInput:a=>this.invalidHandler(a,t),onPicked:a=>this.changedHandler(a,t)}))}getOptionDetailName(t,a=!0,s){let i;return s&&s===u.COLOR&&(i=t.name+(a&&this.isOptionDetailOut(t)&&!salla.url.is_page("cart")&&!this.hideOutLabel?` <br/> <p> ${this.outOfStockText} </p>`:"")+(t.additional_price?` <p> (${salla.money(t.additional_price,!1)}) </p>`:"")),i||(i=t.name+(a&&this.isOptionDetailOut(t)&&!salla.url.is_page("cart")&&!this.hideOutLabel?` - ${this.outOfStockText}`:"")+(t.additional_price?` (${salla.money(t.additional_price,!1)})`:"")),i.replace("<i class=sicon-sar></i>",salla.config.currency()?.symbol||"ر.س")}isOptionDetailOut(t){if(t.is_out||!t.skus_availability||!this.selectedSkus?.length)return t.is_out;const a=this.selectedOptions.filter((a=>a.id===t.id)).length;if(a&&1===this.selectedOptions.length)return!1;if(a){const a=this.selectedSkus.filter((t=>this.outSkus.includes(t)));return Object.keys(t.skus_availability).some((t=>a.includes(Number(t))))}return this.selectedOptions.some((a=>a.is_out&&a.option_id!==t.option_id))}renderInput(t,a,i,e,l,o){const n=this.generateUniqueKey(`${t}-${i.id}-${a.id}`),p=this.isOptionDetailOut(a);return s("label",{class:{"s-product-options-disabled":p}},s("input",{id:n,type:t,name:l,value:a.id,disabled:p,required:e,checked:a.is_selected,onInvalid:t=>this.invalidHandler(t,i),onChange:t=>this.changedHandler(t,i)}),s("div",{class:{"s-product-options-grid-mode-span":o,"s-product-options-disabled":p}},this.getOptionDetailName(a)))}renderOptionDetails(t,a,s,i=!1){const e=this.generateInputName(a.id),l="radio"===t?e:`${e}[]`;return a?.details.map((e=>this.renderInput(t,e,a,s,l,i)))}renderSelect(t){return s("div",null,s("select",{id:this.generateInputId(t.id),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,class:"s-form-control",onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t)},s("option",{value:""},t.placeholder),t?.details.map((t=>s("option",{key:t.id,value:t.id,disabled:this.canDisabled&&this.isOptionDetailOut(t),selected:t.is_selected},this.getOptionDetailName(t))))))}renderButtonStyle(t,a,i){return s("div",{class:"s-product-options-grid-mode"},this.renderOptionDetails(t,a,i,!0))}singleOption(t){return"button"===this.optionConfig?.["single-option"]?.type?this.renderButtonStyle("radio",t,!t.visibility_condition&&t.required):this.renderSelect(t)}multipleOptions(t){const a="button"===this.optionConfig?.["multiple-option"]?.type,i=t.required&&!t.details.some((t=>t.is_selected))&&!t.visibility_condition;return a?this.renderButtonStyle("checkbox",t,i):s("div",{class:{"s-product-options-multiple-options-wrapper":!0,required:t.required}},this.renderOptionDetails("checkbox",t,i))}radioOption(t){return this.singleOption(t)}colorOption(t){return s("fieldset",{class:"s-product-options-colors-wrapper"},t?.details.map((a=>s("div",{class:"s-product-options-colors-item",key:a.id},s("input",{type:"radio",value:a.id,required:!t.visibility_condition&&t.required,checked:a.is_selected,name:this.generateInputName(t.id),disabled:this.canDisabled&&this.isOptionDetailOut(a),id:this.generateUniqueKey(`color-${this.productId}-${t.id}-${a.id}`),onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t)}),s("label",{htmlFor:this.generateUniqueKey(`color-${this.productId}-${t.id}-${a.id}`)},s("span",{style:{backgroundColor:a.color}}),s("div",{innerHTML:this.getOptionDetailName(a,!0,t.type)}))))))}thumbnailOption(t){return s("div",{class:"s-product-options-thumbnails-wrapper"},t.details.map((a=>s("div",{key:a.id},s("input",{type:"radio",value:a.id,"data-itemid":a.id,required:!t.visibility_condition&&t.required,checked:a.is_selected,name:this.generateInputName(t.id),"data-img-id":a.option_value,disabled:this.canDisabled&&this.isOptionDetailOut(a),id:this.generateUniqueKey(`option_${this.productId}-${t.id}_${a.id}`),onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t)}),s("label",{htmlFor:this.generateUniqueKey(`option_${this.productId}-${t.id}_${a.id}`),"data-img-id":a.option_value,class:"go-to-slide"},s("img",{"data-src":a.image,src:a.image,title:a.name,alt:a.name}),s("span",{innerHTML:r,class:"s-product-options-thumbnails-icon"}),this.isOptionDetailOut(a)?[s("small",{key:a.id,class:"s-product-options-thumbnails-stock-badge"},this.outOfStockText),this.canDisabled?s("div",{key:a.id,class:"s-product-options-thumbnails-badge-overlay"}):""]:""),s("p",null,this.getOptionDetailName(a,!1)," ")))))}digitalCardValuesOption(t){return s("div",{class:"s-product-options-digital-card-wrapper"},this.availableDigitalCardValues.length>0?this.availableDigitalCardValues.map((a=>{const i=String(a.id);return s("label",{htmlFor:this.generateUniqueKey(i.toString()),key:i,class:"s-product-options-digital-card-option"},s("input",{type:"radio","data-code-value":!0,class:"s-form-control s-product-options-digital-card-input",value:a.id,name:this.generateInputName(t.id),id:this.generateUniqueKey(i.toString()),required:!t.visibility_condition&&t.required,onInvalid:a=>this.invalidHandler(a,t),...this.ignoreDefaultCardValue?{}:{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===a.id}}),s("span",null,a.name," ",salla.config?.currency()?.symbol))})):s("div",{class:"s-product-options-digital-card-out-of-stock"}))}countryOption(t){return s("div",{class:"s-product-options-digital-card-wrapper"},t.details.map((a=>s("label",{htmlFor:this.generateUniqueKey(a.id.toString()),key:a.id,class:{"s-product-options-digital-card-option":!0,"s-product-options-digital-card-option-stock-out":a.is_out}},s("input",{id:this.generateUniqueKey(a.id.toString()),type:"radio",class:"s-form-control s-product-options-digital-card-input",value:a.id,name:this.generateInputName(t.id),disabled:a.is_out,required:!t.visibility_condition&&t.required,onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t),onClick:()=>{this.disableCardValue=!1},...salla.url.is_page("cart")?{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===a.id}:{}}),s("img",{loading:"lazy",alt:a.code,height:24,width:24,class:"s-product-options-country-flag",src:`https://cdn.assets.salla.network/prod/admin/cp/assets/flags/1x1/${String(a.code).toLocaleLowerCase()}.svg`,onError:t=>{t.currentTarget.onerror=null,t.currentTarget.src=salla.url.cdn("images/globe.svg")}}),s("span",null,a.name)))))}get host(){return e(this)}};m.style="";var g={request:(t,a,s,i=null,e=null)=>l.request({url:a,data:s,method:t.toLowerCase(),responseType:"json"}).then(i).catch(e),get:(t,a=null,s=null,i)=>l.get(t,{params:i}).then(a).catch(s),post(t,a,s=null,i=null){return this.request("post",t,a,s,i)},put(t,a,s=null,i=null){return this.request("put",t,a,s,i)},delete(t,a,s=null,i=null){return this.request("delete",t,a,s,i)},requestWithSupportAjax(t,a,s="post"){return new Promise(((i,e)=>{if(!window?.isLegacyTheme)return this.request(s,t,a,(({data:t})=>i(t)),(({response:t})=>e(t)));$.ajax({url:t,method:s.toUpperCase(),data:a,async:!1,success:function({data:t}){return i(t)},error:function({response:t}){return e(t)}})}))}},v={options:[],header:[navigator.platform,navigator.userAgent,navigator.appVersion,navigator.vendor,window.opera],dataos:[{name:"Windows Phone",value:"Windows Phone",version:"OS"},{name:"Windows",value:"Win",version:"NT"},{name:"iPhone",value:"iPhone",version:"OS"},{name:"iPad",value:"iPad",version:"OS"},{name:"Kindle",value:"Silk",version:"Silk"},{name:"Android",value:"Android",version:"Android"},{name:"PlayBook",value:"PlayBook",version:"OS"},{name:"BlackBerry",value:"BlackBerry",version:"/"},{name:"Macintosh",value:"Mac",version:"OS X"},{name:"Linux",value:"Linux",version:"rv"},{name:"Palm",value:"Palm",version:"PalmOS"}],databrowser:[{name:"Chrome",value:"Chrome",version:"Chrome"},{name:"Firefox",value:"Firefox",version:"Firefox"},{name:"Safari",value:"Safari",version:"Version"},{name:"Internet Explorer",value:"MSIE",version:"MSIE"},{name:"Opera",value:"Opera",version:"Opera"},{name:"BlackBerry",value:"CLDC",version:"CLDC"},{name:"Mozilla",value:"Mozilla",version:"Mozilla"}],init:function(){var t=this.header.join(" ");return{os:this.matchItem(t,this.dataos),browser:this.matchItem(t,this.databrowser)}},matchItem:function(t,a){var s,i,e,l=0,o=0;for(l=0;l<a.length;l+=1)if(new RegExp(a[l].value,"i").test(t)){if(s=new RegExp(a[l].version+"[- /:;]([\\d._]+)","i"),e="",(i=t.match(s))&&i[1]&&(i=i[1]),i)for(i=i.split(/[._]+/),o=0;o<i.length;o+=1)e+=0===o?i[o]+".":i[o];else e="0";return{name:a[l].name,version:parseFloat(e)}}return{name:"unknown",version:0}}};async function w(t,a,s=!1){if(salla.logger.log("🍏 Pay: mutateShippingContact called",a,s),t.detail.requiredShippingContactFields&&0!=t.detail.requiredShippingContactFields.length)if(s){if(salla.config.isGuest()&&salla.config.get("store.features").includes("guest-checkout")){if(!(a.emailAddress&&a.givenName&&a.familyName&&a.phoneNumber)){salla.logger.warn("🍏 Pay: Guest contact fields are required",a);const s=[];return a.emailAddress||s.push(new window.ApplePayError("shippingContactInvalid","emailAddress","Email address is required")),a.phoneNumber||s.push(new window.ApplePayError("shippingContactInvalid","phoneNumber","Phone number is required")),a.givenName&&a.familyName||s.push(new window.ApplePayError("shippingContactInvalid","name","Name is required")),void t.session.completePayment({status:t.session.STATUS_INVALID_SHIPPING_CONTACT,errors:s})}await async function(t,a){return salla.logger.log("🍏 Pay: Updating guest contact",a),new Promise(((s,i)=>{g.post(t.detail.guestContactSelected.url.replace("{id}",t.id),{email:a.emailAddress||null,first_name:a.givenName||null,last_name:a.familyName||null,phone_number:a.phoneNumber||null,country_code:a.countryCode||null},(async({data:a})=>{"function"==typeof t.detail.guestContactSelected?.onSuccess&&t.detail.guestContactSelected.onSuccess(a),s(a)}),(({response:a})=>{salla.logger.warn("🍏 Pay: Failed to update guest contact via api",a),"function"==typeof t.detail.guestContactSelected?.onFailed&&t.detail.guestContactSelected.onFailed(a),i({response:a})}))}))}(t,a)}}else if(t.detail.requiredShippingContactFields.includes("postalAddress"))return g.post(t.detail.shippingContactSelected.url.replace("{id}",t.id),{country:a.country,city:a.locality,local:a.subLocality||a.administrativeArea||a.locality,description:a.subAdministrativeArea,street:a.addressLines?.join(", ")||a.administrativeArea,country_code:a.countryCode,postal_code:a.postalCode},(async({data:a})=>{if("function"==typeof t.detail.shippingContactSelected.onSuccess&&t.detail.shippingContactSelected.onSuccess(a),t.address_id=a.data.address_id,t.shipping_methods=a.data.shipping_methods,!t.shipping_methods||t.shipping_methods&&!t.shipping_methods.length)return salla.logger.warn("🍏 Pay: We dont found any supported methods",a),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]});try{await t.selectApplePayShippingMethod(t.shipping_methods[0])}catch(a){return salla.logger.warn("Failed set the shipping details to api",a),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}try{await t.recalculateTotal()}catch(a){return salla.logger.warn("🍏 Pay: Failed recalculate total",a),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}const s={newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),newShippingMethods:t.mappingShippingMethods(t.shipping_methods)};salla.logger.log("🍏 Pay: completeShippingContactSelection",s),t.session.completeShippingContactSelection(s)}),(({response:a})=>{salla.logger.warn("🍏 Pay: Failed add address via api",a),"function"==typeof t.detail.shippingContactSelected.onFailed&&t.detail.shippingContactSelected.onFailed(a);let s=a?.data?.error?.fields,i=function(t){return Object.entries(t).filter((([t,a])=>a&&a.length>0)).map((([t,a])=>new window.ApplePayError("shippingContactInvalid",t,a[0])))}({countryCode:s?.country_code&&s.country_code.length>0?s.country_code[0]:null,locality:s?.city&&s.city.length>0?s.city[0]:null,country:s?.country&&s.country.length>0?s.country[0]:null});0===i.length&&a?.data?.error?.message&&i.push(new window.ApplePayError("shippingContactInvalid","locality",a?.data?.error?.message)),t.session.completeShippingContactSelection({newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:i})}))}window.Salla=window.Salla||{},window.Salla.Payments=window.Salla.Payments||{},window.SallaApplePay={session:null,detail:null,address_id:null,shipping_methods:[],total:void 0,request:void 0,id:void 0,countryCode:null,totals:[],shippingCompany:null,init:function(){document.removeEventListener("payments::apple-pay.start-transaction",SallaApplePay.startSession),Salla.event.addEventListener("payments::apple-pay.start-transaction",SallaApplePay.startSession)},initDefault:function(){SallaApplePay.detail.onError||(SallaApplePay.detail.onError=function(t){salla.notify.error(t)}),SallaApplePay.detail.authorized.onFailed||(SallaApplePay.detail.authorized.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse(t),SallaApplePay.onCancel({},t.data.error.message)}),SallaApplePay.detail.validateMerchant.onFailed||(SallaApplePay.detail.validateMerchant.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse({response:t}),SallaApplePay.onCancel({},t.data.error.message)}),SallaApplePay.detail.authorized.onSuccess||(SallaApplePay.detail.authorized.onSuccess=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleAfterResponseActions(t)})},prepareLineItems:function(){return SallaApplePay.detail?.items?.length||(SallaApplePay.detail.items=[{label:salla.lang.get("pages.cart.items_total"),amount:parseFloat(SallaApplePay.detail.amount).toString()}]),SallaApplePay.detail.items},prepareTotal:function(){return{label:window.location.hostname||"Salla",amount:parseFloat(SallaApplePay.detail.amount).toString()}},isPhysical:()=>SallaApplePay.detail?.requiredShippingContactFields?.includes("postalAddress"),startSession:async function(t){SallaApplePay.detail=t.detail||t,salla.log("🍏 Pay: payments::apple-pay.start-transaction",SallaApplePay.detail),SallaApplePay.initDefault();let a=SallaApplePay.getApplePaySessionVersion(),s=SallaApplePay.detail.supportedNetworks||["masterCard","visa"];5===a&&s.push("mada"),SallaApplePay.request={countryCode:SallaApplePay.detail.countryCode||"SA",supportsCouponCode:!0,couponCode:"",currencyCode:SallaApplePay.detail.currency||"SAR",requiredShippingContactFields:SallaApplePay.detail.requiredShippingContactFields?SallaApplePay.detail.requiredShippingContactFields:[],merchantCapabilities:["supports3DS"],supportedNetworks:s,supportedCountries:SallaApplePay.detail.supportedCountries||["SA"],total:SallaApplePay.prepareTotal(),shippingContact:SallaApplePay.detail.shippingContact?SallaApplePay.detail.shippingContact:{},shippingMethods:SallaApplePay.detail.shippingMethods&&SallaApplePay.detail.shippingMethods.length?SallaApplePay.mappingShippingMethods(t.detail.shippingMethods):[],lineItems:SallaApplePay.prepareLineItems()},salla.log("🍏 Pay: init ",SallaApplePay.request),SallaApplePay.session=new ApplePaySession(a,SallaApplePay.request),SallaApplePay.session.onshippingcontactselected=SallaApplePay.onShippingContactSelected,SallaApplePay.session.onshippingmethodselected=SallaApplePay.onShippingMethodSelected,SallaApplePay.session.onvalidatemerchant=SallaApplePay.onValidateMerchant,SallaApplePay.session.onpaymentauthorized=SallaApplePay.onPaymentAuthorized,SallaApplePay.session.oncancel=SallaApplePay.onCancel,SallaApplePay.session.oncouponcodechanged=SallaApplePay.onCouponCodeChanged,SallaApplePay.session.onpaymentmethodselected=SallaApplePay.onPaymentMethodSelected,SallaApplePay.session.begin()},onPaymentMethodSelected:async t=>{if(salla.logger.log("🍏 Pay: onPaymentMethodSelected",t),SallaApplePay.isPhysical())salla.logger.log("🍏 Pay: completePaymentMethodSelection",{newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()}),SallaApplePay.session.completePaymentMethodSelection({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()});else try{await SallaApplePay.recalculateTotal();const t={newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()};salla.logger.log("🍏 Pay: completePaymentMethodSelection",t),SallaApplePay.session.completePaymentMethodSelection(t)}catch(t){salla.logger.warn("🍏 Pay: Failed recalculate total",t),SallaApplePay.session.completePaymentMethodSelection({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems(),status:SallaApplePay.session.STATUS_FAILURE,errors:[new window.ApplePayError("unknown",void 0,t?.response?.data?.error?.message||t?.response?.data?.error?.code||"Failed to recalculate total")]})}},onCouponCodeChanged:t=>(Salla.event.dispatch("payments::apple-pay.coupon.change",t),g.post(SallaApplePay.detail.onCouponCodeChanged.url.replace("{id}",SallaApplePay.id),{coupon:t.couponCode,payment_method:"apple_pay"},(async({data:t})=>{"function"==typeof SallaApplePay.detail.onCouponCodeChanged.onSuccess&&SallaApplePay.detail.onCouponCodeChanged.onSuccess(t),salla.log("🍏 Pay: Coupon applied success"),await SallaApplePay.recalculateTotal(),SallaApplePay.session.completeCouponCodeChange({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()})}),(async t=>{let a=t?.response;Salla.event.dispatch("payments::apple-pay.coupon.failed",a),"function"==typeof SallaApplePay.detail.onCouponCodeChanged.onFailed&&SallaApplePay.detail.onCouponCodeChanged.onFailed(a),await SallaApplePay.recalculateTotal(),SallaApplePay.session.completeCouponCodeChange({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems(),errors:[new window.ApplePayError("couponCodeInvalid")]})}))),onCancel:(t={},a=null)=>{SallaApplePay.detail.onError(a||salla.lang.get("pages.checkout.payment_failed")),Salla.event.createAndDispatch("payments::apple-pay.canceled",t)},onPaymentAuthorized:async t=>{salla.logger.log("🍏 Pay: onPaymentAuthorized",t.payment);try{await w(SallaApplePay,t.payment.shippingContact,!0)}catch(t){salla.logger.error("🍏 Pay: Failed to update guest contact details",t);const a=t?.response||t,s=a?.data?.error?.fields||{},i=[];return s?.email&&s.email.length>0&&i.push(new window.ApplePayError("shippingContactInvalid","emailAddress",s.email[0])),s?.phone&&s.phone.length>0&&i.push(new window.ApplePayError("shippingContactInvalid","phoneNumber",s.phone[0])),s?.first_name&&s.first_name.length>0?i.push(new window.ApplePayError("shippingContactInvalid","name",s.first_name[0])):s?.last_name&&s.last_name.length>0&&i.push(new window.ApplePayError("shippingContactInvalid","name",s.last_name[0])),0===i.length&&i.push(new window.ApplePayError("shippingContactInvalid","name",a?.data?.error?.message||a?.data?.error?.code||"Invalid shipping contact details")),Salla.event.dispatch("payments::apple-pay.authorized.failed",a),"function"==typeof SallaApplePay.detail.authorized.onFailed&&SallaApplePay.detail.authorized.onFailed(a),void SallaApplePay.session.completePayment({status:ApplePaySession.STATUS_INVALID_SHIPPING_CONTACT,errors:i})}Salla.event.dispatch("payments::apple-pay.authorized.init",t),g.post(SallaApplePay.detail.authorized.url.replace("{id}",SallaApplePay.id),{payment_method:"apple_pay",applepay_token:JSON.stringify(t.payment)},(({data:t})=>{Salla.event.dispatch("payments::apple-pay.authorized.success",t),"function"==typeof SallaApplePay.detail.authorized.onSuccess&&SallaApplePay.detail.authorized.onSuccess(t),SallaApplePay.session.completePayment(ApplePaySession.STATUS_SUCCESS)}),(t=>{let a=t?.response;Salla.event.dispatch("payments::apple-pay.authorized.failed",a),"function"==typeof SallaApplePay.detail.authorized.onFailed&&SallaApplePay.detail.authorized.onFailed(a),SallaApplePay.session.completePayment({status:ApplePaySession.STATUS_FAILURE,errors:[new window.ApplePayError("unknown",void 0,a?.data?.error?.message||a?.data?.error?.code||"Failed to parse authorized response")]})}))},onValidateMerchant:async t=>{try{Salla.event.dispatch("payments::apple-pay.validate-merchant.init",t);const{data:a}=await g.post(SallaApplePay.detail.validateMerchant.url.replace("{id}",SallaApplePay.id),{validation_url:t.validationURL});Salla.event.dispatch("payments::apple-pay.validate-merchant.success",a);const s=t=>{SallaApplePay.session.completeMerchantValidation(t)};if("function"==typeof SallaApplePay.detail.validateMerchant.onSuccess){const t=await SallaApplePay.detail.validateMerchant.onSuccess(a);if(t?.redirect)return window.location=t.redirect,SallaApplePay.abortValidateMerchant(t)}s(a.data)}catch(t){console.error(t),SallaApplePay.abortValidateMerchant(t?.response)}},abortValidateMerchant:(t=null)=>{SallaApplePay.abortSession(),Salla.event.dispatch("payments::apple-pay.validate-merchant.failed",t),"function"==typeof SallaApplePay.detail.validateMerchant.onFailed&&SallaApplePay.detail.validateMerchant.onFailed(t)},onShippingContactSelected:async t=>{salla.logger.log("🍏 Pay: onShippingContactSelected",t.shippingContact),await w(SallaApplePay,t.shippingContact)},onShippingMethodSelected:async t=>{let a=t.shippingMethod.identifier.split(","),s={ship_id:a[0],private_ship_id:void 0===a[1]?null:a[1],type:void 0===a[2]?null:a[2],route_id:void 0===a[3]?null:a[3]};if(salla.logger.log("🍏 Pay: onShippingMethodSelected",{event:t,previous:SallaApplePay.shippingCompany,current:s}),SallaApplePay.shouldUpdateShippingCompany(s))try{await SallaApplePay.selectApplePayShippingMethod(s),await SallaApplePay.recalculateTotal()}catch(t){return salla.logger.warn("🍏 Pay: Failed set the shipping details to api",t),void SallaApplePay.session.completeShippingMethodSelection({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems(),status:SallaApplePay.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}salla.logger.log("🍏 Pay: completeShippingMethodSelection",{newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()}),SallaApplePay.session.completeShippingMethodSelection({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()})},abortSession:()=>{SallaApplePay.session&&SallaApplePay.session.abort()},shouldUpdateShippingCompany:t=>SallaApplePay.shippingCompany?.ship_id!=t?.ship_id||SallaApplePay.shippingCompany?.private_ship_id!=t?.private_ship_id,getApplePaySessionVersion:()=>{if("sallapp"===(navigator.userAgent||navigator.vendor||window.opera))return 5;let t=v.init(),a=parseFloat(t.os.version);if("Macintosh"===t.os.name){if(a<10.142)return 1}else if(a<12.11)return 1;return 5},recalculateTotal:()=>(salla.logger.log("🍏 Pay: recalculate total"),g.get(SallaApplePay.detail.recalculateTotal.url.replace("{id}",SallaApplePay.id),(({data:t})=>{salla.logger.log("🍏 Pay: recalculate total success",t);let a=t.data.initial_data?.cart||t.data.cart,s=t.data.initial_data?.payments||t.data.payments;salla.logger.log("🍏 Pay: recalculate total success",{cart:a,payments:s}),SallaApplePay.detail.amount=s?.gateways?.applePay?.supportedMultiCurrency?a.total_in_customer_currency:a.total,SallaApplePay.detail.items=(a.totals||a.items).map((t=>({label:t.title,amount:"مجاني"===t.amount||"Free"===t.amount?0:t.amount.toString().replace("+","")}))),SallaApplePay.detail.items.pop(),SallaApplePay.totals=SallaApplePay.detail.items}),(t=>(salla.logger.warn("🍏 Pay: recalculate total failed",t),t?.response?.data?.message)))),selectApplePayShippingMethod:t=>{salla.logger.log("🍏 Pay: select shipping method ",t),SallaApplePay.shippingCompany=t;const a={address_id:SallaApplePay.address_id,company_id:t.ship_id,private_company_id:t.private_ship_id,type:t.type||void 0,route_id:t.route_id||void 0,payment_method:"apple_pay"};return g.post(SallaApplePay.detail.shippingMethodSelected.url.replace("{id}",SallaApplePay.id),a,(({data:t})=>("function"==typeof SallaApplePay.detail.shippingMethodSelected.onSuccess&&SallaApplePay.detail.shippingMethodSelected.onSuccess(t),!0)),(t=>{salla.logger.warn("🍏 Pay: Set shipping method failed",t),"function"==typeof SallaApplePay.detail.shippingMethodSelected.onFailed&&SallaApplePay.detail.shippingMethodSelected.onFailed(t);let a=t?.response?.data?.error;return a?.data?.fields?.address_id?a?.data?.fields?.address_id[0]:a?.data?.message}))},mappingShippingMethods:t=>t.map((t=>({label:t.shipping_title,amount:t.enable_free_shipping?0:t.ship_cost,detail:"",identifier:t.ship_id.toString()+(t.private_ship_id?","+t.private_ship_id.toString():"")+(t.type?","+t.type:"")+(t.route_id?","+t.route_id:"")})))},window.ApplePaySession?.canMakePayments()?SallaApplePay.init():document.querySelectorAll("data-show-if-apple-pay-supported").forEach((t=>t.style.display="none"));const S=class{constructor(s){t(this,s),this.validationFailed=a(this,"validationFailed"),this.requireLogin=a(this,"requireLogin"),this.type="buy",this.productType="product",this.options={},this.quickBuy=salla.lang.get("pages.products.buy_now"),salla.lang.onLoaded((()=>{this.quickBuy=salla.lang.get("pages.products.buy_now")}))}async quickBuyHandler(){if(salla.config.isGuest()&&!this.isGuestCheckout()){this.requireLogin.emit({productId:this.productId});let t="salla-quick-buy::user.logged-in";return salla.event.on(t,(()=>this.settlePayment())),salla.api.auth.setAfterLoginEvent(t),salla.auth.event.dispatch("login::open",{withoutReload:!0})}await this.settlePayment()}async settlePayment(){let t=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);if(t&&!await t.reportValidity())return this.validationFailed.emit({productId:this.productId}),salla.error(salla.lang.get("common.messages.required_fields"));let a=this.host.getElementSallaData();if(!this.isApplePayActive)return salla.api.request("checkout/quick-purchase/"+this.productId,a,"post").then((t=>(t.data.redirect&&(window.location.href=t.data.redirect),t)));a.is_applepay=!0,"append"in a&&a.append("is_applepay",!0),salla.event.dispatch("payments::apple-pay.start-transaction",{amount:this.amount,currency:this.currency||"SAR",requiredShippingContactFields:this.getRequiredShippingContactFields(),shippingMethods:this.isRequireShipping?[]:void 0,supportedNetworks:salla.config.get("store.settings.buy_now.networks"),supportedCountries:salla.config.get("store.settings.buy_now.countries"),countryCode:salla.config.get("store.store_country")||"SA",validateMerchant:{url:this.validateHost?`${this.validateHost}/checkout/applepay/validate`:salla.url.get("checkout/applepay/validate"),onSuccess:t=>this.applePayOnly&&!this.productId?this.cartId?(window.SallaApplePay.id=this.cartId,salla.log("🍏 Pay: create checkout success: with id #"+this.cartId),Promise.resolve(t)):(salla.logger.warn("🍏 Pay: trying to create applePay transaction without cartId/ProductId !"),Promise.resolve(t)):salla.api.request("checkout/quick-purchase/"+this.productId,"object"==typeof a?a:void 0,"post",{}).then((t=>t?.data?.redirect?(salla.log("🍏 Pay: create checkout success: redirect exits, go to checkout page"),window.location.href=t.data.redirect.url,t):t?.data?.id?(window.SallaApplePay.id=t.data.id,void salla.log("🍏 Pay: create checkout success: with id #"+window.SallaApplePay.id)):(salla.logger.warn("🍏 Pay: create checkout success: No id, or redirect"),t)))},authorized:{url:salla.url.get("checkout/{id}/payments/submit"),onFailed:t=>{window.SallaApplePay.onCancel({},t?.data?.error?.message||t?.data?.error?.code||salla.lang.get("pages.checkout.payment_failed"))},onSuccess:t=>{window.location.href=t.redirect.url,salla.log("🍏 Pay: authorized Success:: redirect to thank you page, order placed")}},shippingMethodSelected:this.isRequireShipping?{url:salla.url.get("checkout/{id}/shipping/details")}:void 0,shippingContactSelected:this.isRequireShipping?{url:salla.url.get("checkout/{id}/address/add")}:void 0,guestContactSelected:this.isGuestCheckout()?{url:salla.url.get("checkout/{id}/customer")}:void 0,onCouponCodeChanged:{url:salla.url.get("checkout/{id}/coupons")},recalculateTotal:{url:salla.url.get("checkout/{id}/payments/recalculate?payment_method=apple_pay")},onError:function(t){salla.log(t),salla.notify.error(t)}})}isGuestCheckout(){return salla.config.isGuest()&&salla.config.get("store.features").includes("guest-checkout")&&this.isPhysicalProduct()}getRequiredShippingContactFields(){let t=[];return this.isRequireShipping&&t.push("postalAddress"),this.isGuestCheckout()&&t.push("email","phone","name"),t}componentWillLoad(){console.log("🍏 Pay: Quick Buy Component Loaded");const t="undefined"!=typeof window&&!!window.ApplePaySession?.canMakePayments?.(),a=salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??!0,s=salla?.config?.get?.("store.settings.is_salla_gateway",!1)??!0;this.isApplePayActive=t&&a&&s;const i=async()=>{if(!this.currency&&salla?.config?.get&&(this.currency=salla.config.get("store.settings.buy_now.multi_currency")?salla.config.get("user.currency_code"):"SAR"),!this.productId&&salla?.config?.get&&salla.url?.is_page&&(this.productId=salla.config.get("page.id")),this.applePayOnly||this.productId){if(this.amount&&this.isRequireShipping||!this.productId||!salla?.product?.getDetails||await salla.product.getDetails(this.productId,[]).then((t=>{this.amount=t.data.price,this.isRequireShipping=t?.data?.is_require_shipping||!1})).catch((t=>{salla?.logger?.warn?.("🍏 Pay: Failed load the quick buy, get the product details failed: ",t)})),"donate"===this.type&&salla?.event?.on?salla.event.on("product-options::donation-changed",(t=>{String(t.id)===String(this.productId)&&(this.amount=t.price)})):salla?.url?.is_page?.("product.single")&&salla?.product?.event?.onPriceUpdated&&salla.product.event.onPriceUpdated((t=>{this.amount=t.data.price})),this.isApplePayActive=(salla?.helpers?.hasApplePay?.()??t)&&(salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??a)&&(salla?.config?.get?.("store.settings.is_salla_gateway",!1)??s),!document.getElementById("apple-pay-sdk")&&this.isApplePayActive){const t=document.createElement("script");t.src="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",t.setAttribute("id","apple-pay-sdk"),t.async=!0,document.body.appendChild(t)}}else salla?.logger?.warn?.("🍏 Pay: Failed load the quick buy, the product id is missing")};return new Promise((t=>{"function"==typeof salla?.onReady?salla.onReady((()=>i().then((()=>t(!0))))):i().then((()=>t(!0)))}))}render(){return s(i,{key:"88125eb8c3bb1e1b016f39ea84ce6234267587a4"},this.quickBuyButton())}quickBuyButton(){return s("apple-pay-button",{locale:salla?.config?.get?.("user.language_code")||"ar",onClick:()=>this.quickBuyHandler(),"data-quick-purchase":"applepay",class:"s-quick-buy-apple-pay","data-is-applepay":"1",buttonstyle:"black",type:this.type})}isPhysicalProduct(){return"product"===this.productType||"group_products"===this.productType||"food"===this.productType}get host(){return e(this)}};S.style=".s-quick-buy-button .s-button-text{display:flex}apple-pay-button{--apple-pay-button-width:100%;--apple-pay-button-height:40px;--apple-pay-button-border-radius:.75rem;--apple-pay-button-box-sizing:content-box}";export{c as salla_add_product_button,h as salla_product_availability,m as salla_product_options,S as salla_quick_buy}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as t,H as i,a as n}from"./p-CV1rqKQz.js";import{H as l}from"./p-CHf8XdiS.js";import"./p-CgtvEd63.js";const e=class{constructor(t){s(this,t),this.nextPage="",this.autoload=!1,this.container="salla-infinite-scroll",this.item="salla-infinite-scroll > *",this.status=document.createElement("div"),this.status.className="s-infinite-scroll-wrapper",this.status.innerHTML=`<div class="s-infinite-scroll-status" style="display:none">\n <p class="s-infinite-scroll-last infinite-scroll-last"></p>\n <p class="s-infinite-scroll-error infinite-scroll-error"></p>\n </div>\n <a href="${this.nextPage}" class="s-infinite-scroll-btn s-button-btn s-button-primary">\n <span class="s-button-text s-infinite-scroll-btn-text">${this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more")}</span>\n <span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader" style="display: none"></span>\n </a>`,this.btnLoader=this.status.querySelector(".s-button-loader"),salla.lang.onLoaded((()=>{this.status.querySelector(".s-button-text").innerHTML=this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more"),this.status.querySelector(".s-infinite-scroll-last").innerHTML=salla.lang.get("common.elements.end_of_content"),this.status.querySelector(".s-infinite-scroll-error").innerHTML=salla.lang.get("common.elements.failed_to_load_more")}))}loading(s=!0){let t=this.status.querySelector(".s-button-text");l.toggleElementClassIf(t,"s-button-hide","s-button-show",(()=>s)),this.btnLoader.style.display=s?"inherit":"none"}render(){return this.nextPage.length>1?t(i,{class:"s-infinite-scroll-container"},t("slot",null)):""}componentDidLoad(){if(0===this.nextPage.length)return;this.host.insertAdjacentElement("afterend",this.status);let s=this,t=salla.infiniteScroll.initiate(this.container,{history:!!this.autoload&&"push",scrollThreshold:!!this.autoload&&400,nextPage:this.nextPage,checkLastPage:'salla-infinite-scroll[next-page*=":"],salla-infinite-scroll[next-page*="."]',status:".s-infinite-scroll-status",button:this.status.querySelector(".s-button-btn"),append:this.item,path:function(){return s.nextPage.replace(/page\=(\d)/g,"page="+(this.loadCount+2))}}).on("request",(()=>this.loading())).on("load",(()=>{this.loading(!1),2==t.pageIndex&&t.option({loadOnScroll:!1}),3==t.pageIndex&&t.option({loadOnScroll:!0})})).on("error",(()=>this.loading(!1)))}get host(){return n(this)}};e.style="";export{e as salla_infinite_scroll}
4
+ import{r as s,h as t,H as i,a as n}from"./p-ea1dIZhh.js";import{H as l}from"./p-CHf8XdiS.js";import"./p-CgtvEd63.js";const e=class{constructor(t){s(this,t),this.nextPage="",this.autoload=!1,this.container="salla-infinite-scroll",this.item="salla-infinite-scroll > *",this.status=document.createElement("div"),this.status.className="s-infinite-scroll-wrapper",this.status.innerHTML=`<div class="s-infinite-scroll-status" style="display:none">\n <p class="s-infinite-scroll-last infinite-scroll-last"></p>\n <p class="s-infinite-scroll-error infinite-scroll-error"></p>\n </div>\n <a href="${this.nextPage}" class="s-infinite-scroll-btn s-button-btn s-button-primary">\n <span class="s-button-text s-infinite-scroll-btn-text">${this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more")}</span>\n <span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader" style="display: none"></span>\n </a>`,this.btnLoader=this.status.querySelector(".s-button-loader"),salla.lang.onLoaded((()=>{this.status.querySelector(".s-button-text").innerHTML=this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more"),this.status.querySelector(".s-infinite-scroll-last").innerHTML=salla.lang.get("common.elements.end_of_content"),this.status.querySelector(".s-infinite-scroll-error").innerHTML=salla.lang.get("common.elements.failed_to_load_more")}))}loading(s=!0){let t=this.status.querySelector(".s-button-text");l.toggleElementClassIf(t,"s-button-hide","s-button-show",(()=>s)),this.btnLoader.style.display=s?"inherit":"none"}render(){return this.nextPage.length>1?t(i,{class:"s-infinite-scroll-container"},t("slot",null)):""}componentDidLoad(){if(0===this.nextPage.length)return;this.host.insertAdjacentElement("afterend",this.status);let s=this,t=salla.infiniteScroll.initiate(this.container,{history:!!this.autoload&&"push",scrollThreshold:!!this.autoload&&400,nextPage:this.nextPage,checkLastPage:'salla-infinite-scroll[next-page*=":"],salla-infinite-scroll[next-page*="."]',status:".s-infinite-scroll-status",button:this.status.querySelector(".s-button-btn"),append:this.item,path:function(){return s.nextPage.replace(/page\=(\d)/g,"page="+(this.loadCount+2))}}).on("request",(()=>this.loading())).on("load",(()=>{this.loading(!1),2==t.pageIndex&&t.option({loadOnScroll:!1}),3==t.pageIndex&&t.option({loadOnScroll:!0})})).on("error",(()=>this.loading(!1)))}get host(){return n(this)}};e.style="";export{e as salla_infinite_scroll}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as e,H as t,a as o}from"./p-CV1rqKQz.js";const i=class{constructor(e){s(this,e),this.isVisible=!0,this.isMobile=!1,this.mobileBreakpoint=768,this.mobileQueryHandler=s=>this.isMobile=s.matches,this.message="We use cookies to improve your experience on our site. By continuing to browse, you agree to our use of cookies."}componentWillLoad(){Salla.storage.get("cookies-consent")&&(this.isVisible=!1)}componentDidLoad(){this.mobileQuery=window.matchMedia(`(max-width: ${this.mobileBreakpoint-1}px)`),this.isMobile=this.mobileQuery.matches,this.mobileQuery.addEventListener("change",this.mobileQueryHandler)}disconnectedCallback(){this.mobileQuery?.removeEventListener("change",this.mobileQueryHandler)}async accept(){return this.isVisible=!1,Salla.event.emit("salla-cookies-bar::accepted"),Salla.storage.set("cookies-consent","accepted"),this.host}async reject(){return this.isVisible=!1,Salla.event.emit("salla-cookies-bar::rejected"),Salla.storage.set("cookies-consent","rejected"),this.host}isRtl(){return Salla.config.get("theme.is_rtl",!0)}render(){return this.isVisible?e(t,null,e("div",{dir:this.isRtl()?"rtl":"ltr",class:"s-cookies-bar fixed bottom-0 inset-x-0 z-50 bg-white p-4"},e("div",{class:"s-cookies-bar-content flex flex-col justify-center gap-6 max-w-screen-xl mx-auto px-4"},e("p",{class:"s-cookies-bar-message text-sm font-medium leading-relaxed text-gray-500 m-0"},this.message||Salla.lang.get("blocks.footer.cookies_message")),e("div",{class:"s-cookies-bar-actions flex flex-row gap-2 shrink-0"},e("salla-button",{class:"s-cookies-bar-btn--accept",color:"primary",fill:"solid",type:"button",size:this.isMobile?"small":"medium",onClick:()=>this.accept()},this.acceptLabel||Salla.lang.get("blocks.footer.cookies_accept")),e("salla-button",{class:"s-cookies-bar-btn--reject",fill:"outline",type:"button",size:this.isMobile?"small":"medium",onClick:()=>this.reject()},this.rejectLabel||Salla.lang.get("blocks.footer.cookies_reject")))))):e(t,null)}get host(){return o(this)}};i.style=":host{display:block;overflow:visible}.s-cookies-bar{box-shadow:0 0 20px 4px rgba(0, 0, 0, 0.15)}";export{i as salla_cookies_bar}
4
+ import{r as s,h as e,H as t,a as o}from"./p-ea1dIZhh.js";const i=class{constructor(e){s(this,e),this.isVisible=!0,this.isMobile=!1,this.mobileBreakpoint=768,this.mobileQueryHandler=s=>this.isMobile=s.matches,this.message="We use cookies to improve your experience on our site. By continuing to browse, you agree to our use of cookies."}componentWillLoad(){Salla.storage.get("cookies-consent")&&(this.isVisible=!1)}componentDidLoad(){this.mobileQuery=window.matchMedia(`(max-width: ${this.mobileBreakpoint-1}px)`),this.isMobile=this.mobileQuery.matches,this.mobileQuery.addEventListener("change",this.mobileQueryHandler)}disconnectedCallback(){this.mobileQuery?.removeEventListener("change",this.mobileQueryHandler)}async accept(){return this.isVisible=!1,Salla.event.emit("salla-cookies-bar::accepted"),Salla.storage.set("cookies-consent","accepted"),this.host}async reject(){return this.isVisible=!1,Salla.event.emit("salla-cookies-bar::rejected"),Salla.storage.set("cookies-consent","rejected"),this.host}isRtl(){return Salla.config.get("theme.is_rtl",!0)}render(){return this.isVisible?e(t,null,e("div",{dir:this.isRtl()?"rtl":"ltr",class:"s-cookies-bar fixed bottom-0 inset-x-0 z-50 bg-white p-4"},e("div",{class:"s-cookies-bar-content flex flex-col justify-center gap-6 max-w-screen-xl mx-auto px-4"},e("p",{class:"s-cookies-bar-message text-sm font-medium leading-relaxed text-gray-500 m-0"},this.message||Salla.lang.get("blocks.footer.cookies_message")),e("div",{class:"s-cookies-bar-actions flex flex-row gap-2 shrink-0"},e("salla-button",{class:"s-cookies-bar-btn--accept",color:"primary",fill:"solid",type:"button",size:this.isMobile?"small":"medium",onClick:()=>this.accept()},this.acceptLabel||Salla.lang.get("blocks.footer.cookies_accept")),e("salla-button",{class:"s-cookies-bar-btn--reject",fill:"outline",type:"button",size:this.isMobile?"small":"medium",onClick:()=>this.reject()},this.rejectLabel||Salla.lang.get("blocks.footer.cookies_reject")))))):e(t,null)}get host(){return o(this)}};i.style=":host{display:block;overflow:visible}.s-cookies-bar{box-shadow:0 0 20px 4px rgba(0, 0, 0, 0.15)}";export{i as salla_cookies_bar}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as e,h as t,H as s,c as a,a as i}from"./p-CV1rqKQz.js";import{p as l,m as o}from"./p-DfeagqF1.js";const r=class{constructor(t){e(this,t)}render(){return t(s,{key:"298d42a5bf1bcefdb181ec35060220cf749b56ed",class:"s-accordion-body-wrapper"},t("slot",{key:"6ab081e8b71b5dc69fb66fbdec82b4725ab53b0d"}))}};r.style="";const h=class{constructor(t){e(this,t),this.accordionToggle=a(this,"accordionToggle"),this.collapsible=!1,this.collapsed=!0}emitCollapsePanel(){this.accordionToggle.emit({payload:{collapsed:this.collapsed}})}toggleCollapse(){this.collapsible&&(this.collapsed=!this.collapsed,this.host.parentElement?.setAttribute("data-collapsed",this.collapsed.toString()),this.host.parentElement?.querySelector("salla-accordion-body")?.setAttribute("data-collapsed",this.collapsed.toString()),this.emitCollapsePanel())}render(){return t(s,{key:"9d88d243306cdf451c20d7068fbb9f48807b22e9","data-collapsed":this.collapsed.toString(),onClick:()=>this.toggleCollapse(),class:"s-accordion-head-wrapper"},t("div",{key:"bad4c5a913ce1c4581b09c0b6d96fcbdb4236638",class:"s-accordion-head-wrapper-start"},t("slot",{key:"acb83cec8cbca5771a9f84e81c0b955c3edad731",name:"title"}),t("slot",{key:"a4ad42ea6fad4f452c4c218a9ee02dca0adb4a67",name:"progress"}),t("slot",{key:"96ab95d413dc906ac299079f4008816f01881990",name:"html"})),(this.collapsible||this.host.querySelector('[slot="note"]'))&&t("div",{key:"8f9666a5038cd7b1ac6e357c6920ea26d31c5f03",class:"s-accordion-head-wrapper-end"},t("slot",{key:"14895e8c1385e91c14f046c9ae38ce5e4a4c9a60",name:"note"}),this.collapsible&&t("button",{key:"97dc7fabbb207fcc8b68ebf0a86f6c8a980dca13",class:{"s-accordion-head-wrapper-toggle":!0,active:!this.collapsed},onClick:e=>{e.stopPropagation(),this.toggleCollapse()}},t("span",{key:"3b24faf71dcd332663a354310b2ce09f7879eddc",class:"s-accordion-head-wrapper-toggle-icon",innerHTML:this.collapsed?l:o}))))}get host(){return i(this)}};h.style="";var c={light:[{featureType:"water",elementType:"geometry",stylers:[{color:"#e9e9e9"},{lightness:17}]},{featureType:"landscape",elementType:"geometry",stylers:[{color:"#f5f5f5"},{lightness:20}]},{featureType:"road.highway",elementType:"geometry.fill",stylers:[{color:"#ffffff"},{lightness:17}]},{featureType:"road.highway",elementType:"geometry.stroke",stylers:[{color:"#ffffff"},{lightness:29},{weight:.2}]},{featureType:"road.arterial",elementType:"geometry",stylers:[{color:"#ffffff"},{lightness:18}]},{featureType:"road.local",elementType:"geometry",stylers:[{color:"#ffffff"},{lightness:16}]},{featureType:"poi",elementType:"geometry",stylers:[{color:"#f5f5f5"},{lightness:21}]},{featureType:"poi.park",elementType:"geometry",stylers:[{color:"#dedede"},{lightness:21}]},{elementType:"labels.text.stroke",stylers:[{visibility:"on"},{color:"#ffffff"},{lightness:16}]},{elementType:"labels.text.fill",stylers:[{saturation:36},{color:"#333333"},{lightness:40}]},{elementType:"labels.icon",stylers:[{visibility:"off"}]},{featureType:"transit",elementType:"geometry",stylers:[{color:"#f2f2f2"},{lightness:19}]},{featureType:"administrative",elementType:"geometry.fill",stylers:[{color:"#fefefe"},{lightness:20}]},{featureType:"administrative",elementType:"geometry.stroke",stylers:[{color:"#fefefe"},{lightness:17},{weight:1.2}]}],dark:[{elementType:"geometry",stylers:[{color:"#242f3e"}]},{elementType:"labels.text.fill",stylers:[{color:"#746855"}]},{elementType:"labels.text.stroke",stylers:[{color:"#242f3e"}]},{featureType:"administrative.locality",elementType:"labels.text.fill",stylers:[{color:"#d59563"}]},{featureType:"poi",elementType:"labels.text.fill",stylers:[{color:"#d59563"}]},{featureType:"poi.park",elementType:"geometry",stylers:[{color:"#263c3f"}]},{featureType:"poi.park",elementType:"labels.text.fill",stylers:[{color:"#6b9a76"}]},{featureType:"road",elementType:"geometry",stylers:[{color:"#38414e"}]},{featureType:"road",elementType:"geometry.stroke",stylers:[{color:"#212a37"}]},{featureType:"road",elementType:"labels.text.fill",stylers:[{color:"#9ca5b3"}]},{featureType:"road.highway",elementType:"geometry",stylers:[{color:"#746855"}]},{featureType:"road.highway",elementType:"geometry.stroke",stylers:[{color:"#1f2835"}]},{featureType:"road.highway",elementType:"labels.text.fill",stylers:[{color:"#f3d19c"}]},{featureType:"transit",elementType:"geometry",stylers:[{color:"#2f3948"}]},{featureType:"transit.station",elementType:"labels.text.fill",stylers:[{color:"#d59563"}]},{featureType:"water",elementType:"geometry",stylers:[{color:"#17263c"}]},{featureType:"water",elementType:"labels.text.fill",stylers:[{color:"#515c6d"}]},{featureType:"water",elementType:"labels.text.stroke",stylers:[{color:"#17263c"}]}]};class n{constructor(e=null,t={}){if(this.apiKey=e,this.options=t,"undefined"==typeof window)throw new Error("google-maps is supported only in browser environment")}load(){return void 0!==this.api?Promise.resolve(this.api):void 0!==this.loader?this.loader:(window[n.CALLBACK_NAME]=()=>{if(this.api=window.google,void 0===this.resolve)throw new Error("Should not happen");this.resolve(this.api)},window.gm_authFailure=()=>{if(void 0===this.reject)throw new Error("Should not happen");this.reject(new Error("google-maps: authentication error"))},this.loader=new Promise(((e,t)=>{this.resolve=e,this.reject=t;const s=document.createElement("script");s.src=this.createUrl(),s.async=!0,s.onerror=e=>t(e),document.head.appendChild(s)})))}createUrl(){const e=[`callback=${n.CALLBACK_NAME}`];this.apiKey&&e.push(`key=${this.apiKey}`);for(let t in this.options)if(this.options.hasOwnProperty(t)){let s=this.options[t];"version"===t&&(t="v"),"libraries"===t&&(s=s.join(",")),e.push(`${t}=${s}`)}return`https://maps.googleapis.com/maps/api/js?${e.join("&")}`}}n.CALLBACK_NAME="_dk_google_maps_loader_cb";const d=class{constructor(t){e(this,t),this.selected=a(this,"selected"),this.mapClicked=a(this,"mapClicked"),this.currentLocationChanged=a(this,"currentLocationChanged"),this.invalidInput=a(this,"invalidInput"),this.defaultLat=21.419421,this.defaultLng=39.82553,this.modalActivityTitle=salla.lang.get("pages.checkout.select_your_address_from_map"),this.confirmButtonTitle=salla.lang.get("pages.checkout.confirm_address"),this.locateButtonTitle=salla.lang.get("pages.cart.detect_location"),this.locateButtonEdit=salla.lang.get("common.elements.edit"),this.searchPlaceholder=salla.lang.get("pages.checkout.search_for_address"),this.searchInputValue=null,this.formattedAddress="",this.geolocationError=!1,this.name="location",this.required=!1,this.readonly=!1,this.searchable=!1,this.zoom=10,this.theme="light",salla.lang.onLoaded((()=>{this.modalActivityTitle=salla.lang.get("pages.checkout.select_your_address_from_map"),this.confirmButtonTitle=salla.lang.get("pages.checkout.confirm_address"),this.locateButtonTitle=salla.lang.get("pages.cart.detect_location"),this.locateButtonEdit=salla.lang.get("common.elements.edit"),this.searchPlaceholder=salla.lang.get("pages.checkout.search_for_address")})),salla.onReady((()=>{this.apiKey=salla.config.get("store.settings.keys.maps","AIzaSyBFgFISAizDP3YVWj0y5rF8JKKNQ2vohdc")}))}formatAddress(e){return e.length>25?e.substring(0,25)+"...":e}getLatLng(){return this.selectedLat&&this.selectedLng?`${this.selectedLat}, ${this.selectedLng}`:null}getPositionAddress(e,t=!1){(new google.maps.Geocoder).geocode({location:e},((e,s)=>{s===google.maps.GeocoderStatus.OK&&(this.searchable&&(this.searchInputValue=e[0].formatted_address,this.searchInput.value=e[0].formatted_address),t&&(this.formattedAddress=e[0].formatted_address))}))}initGoogleMaps(e,t){new n(this.apiKey,e).load().then((e=>{if(this.map=new e.maps.Map(t,{center:this.lat||this.lng?{lat:this.lat,lng:this.lng}:{lat:this.defaultLat,lng:this.defaultLng},zoom:this.zoom,zoomControl:!0,mapTypeControl:!1,scaleControl:!1,streetViewControl:!1,rotateControl:!1,fullscreenControl:!1,disableDefaultUI:!1}),this.map.setOptions({styles:"light"===this.theme?c.light:c.dark}),this.marker=new e.maps.Marker({position:this.map.getCenter(),map:this.map,icon:{url:"data:image/svg+xml;utf8,"+encodeURIComponent('<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">\n<rect width="36" height="36" rx="18" fill="#5CD5C4"/>\n<path d="M18 10C17.0104 10 16.1458 10.1771 15.4062 10.5312C14.6562 10.8854 14.026 11.3542 13.5156 11.9375C13.0156 12.5104 12.6406 13.1667 12.3906 13.9062C12.1302 14.6458 12 15.401 12 16.1719C12 16.8906 12.2604 17.7656 12.7812 18.7969C13.3021 19.8281 13.8854 20.8333 14.5312 21.8125C15.1875 22.7812 15.8073 23.6406 16.3906 24.3906C16.9844 25.1302 17.349 25.5885 17.4844 25.7656C17.5469 25.8385 17.625 25.8958 17.7188 25.9375C17.8125 25.9792 17.9062 26 18 26C18.1042 26 18.1979 25.9792 18.2812 25.9375C18.375 25.8958 18.4531 25.8385 18.5156 25.7656C18.651 25.5885 19.0156 25.1302 19.6094 24.3906C20.1927 23.6406 20.8073 22.7812 21.4531 21.8125C22.1094 20.8333 22.6979 19.8281 23.2188 18.7969C23.7396 17.7656 24 16.8906 24 16.1719C24 15.401 23.8698 14.6458 23.6094 13.9062C23.3594 13.1667 22.9792 12.5104 22.4688 11.9375C21.9688 11.3542 21.3438 10.8854 20.5938 10.5312C19.8542 10.1771 18.9896 10 18 10ZM18 24.2812C17.5833 23.75 17.1094 23.1198 16.5781 22.3906C16.0365 21.651 15.526 20.901 15.0469 20.1406C14.5677 19.3698 14.1615 18.6302 13.8281 17.9219C13.4948 17.2135 13.3281 16.6302 13.3281 16.1719C13.3281 15.5885 13.4219 15.0052 13.6094 14.4219C13.7969 13.849 14.0781 13.3333 14.4531 12.875C14.8385 12.4167 15.3281 12.0469 15.9219 11.7656C16.5052 11.474 17.1979 11.3281 18 11.3281C18.8021 11.3281 19.4948 11.474 20.0781 11.7656C20.6719 12.0469 21.1562 12.4167 21.5312 12.875C21.9167 13.3333 22.2031 13.849 22.3906 14.4219C22.5781 15.0052 22.6719 15.5885 22.6719 16.1719C22.6719 16.6302 22.5052 17.2135 22.1719 17.9219C21.8385 18.6302 21.4323 19.3698 20.9531 20.1406C20.474 20.901 19.9688 21.651 19.4375 22.3906C18.8958 23.1198 18.4167 23.75 18 24.2812ZM18 13.3281C17.2604 13.3281 16.6302 13.5885 16.1094 14.1094C15.5885 14.6302 15.3281 15.2604 15.3281 16C15.3281 16.7396 15.5885 17.3698 16.1094 17.8906C16.6302 18.4115 17.2604 18.6719 18 18.6719C18.7396 18.6719 19.3698 18.4115 19.8906 17.8906C20.4115 17.3698 20.6719 16.7396 20.6719 16C20.6719 15.2604 20.4115 14.6302 19.8906 14.1094C19.3698 13.5885 18.7396 13.3281 18 13.3281ZM18 17.3281C17.6354 17.3281 17.3229 17.1979 17.0625 16.9375C16.8021 16.6771 16.6719 16.3646 16.6719 16C16.6719 15.6354 16.8021 15.3229 17.0625 15.0625C17.3229 14.8021 17.6354 14.6719 18 14.6719C18.3646 14.6719 18.6771 14.8021 18.9375 15.0625C19.1979 15.3229 19.3281 15.6354 19.3281 16C19.3281 16.3646 19.1979 16.6771 18.9375 16.9375C18.6771 17.1979 18.3646 17.3281 18 17.3281Z" fill="white"/>\n</svg>\n'),scaledSize:new e.maps.Size(30,30)}}),this.searchable){const t=new e.maps.places.SearchBox(this.searchInput);e.maps.event.addListener(t,"places_changed",(()=>{const e=t.getPlaces();e.length>0&&this.map&&(this.map.setCenter(e[0].geometry.location),this.lat=e[0].geometry.location.lat(),this.lng=e[0].geometry.location.lng(),this.marker.setPosition(e[0].geometry.location),this.searchInputValue=e[0].formatted_address,this.formattedAddress=e[0].formatted_address)}))}e.maps.event.addListener(this.map,"click",(e=>{this.readonly||(this.marker.setPosition(e.latLng),this.lat=e.latLng.lat(),this.lng=e.latLng.lng(),this.getPositionAddress(e.latLng),this.mapClicked.emit({lat:e.latLng.lat(),lng:e.latLng.lng(),address:this.formattedAddress?this.formattedAddress:null}))})),this.lat||this.lng||(this.getCurrentLocation(),this.geolocationError&&(this.map.setCenter({lat:this.lat,lng:this.lng}),this.marker.setPosition({lat:this.lat,lng:this.lng})))}))}getCurrentLocation(){navigator.geolocation&&this.map?navigator.geolocation.getCurrentPosition((e=>{const t={center:new google.maps.LatLng(e.coords.latitude,e.coords.longitude),zoom:15};this.map.setOptions(t),this.marker.setPosition(t.center),this.getPositionAddress(t.center),this.lat=e.coords.latitude,this.lng=e.coords.longitude,this.currentLocationChanged.emit({lat:e.coords.latitude,lng:e.coords.longitude,address:this.formattedAddress?this.formattedAddress:null})}),this.handleLocationError.bind(this)):(salla.log("Geolocation is not supported by this browser."),this.geolocationError=!0)}handleLocationError(e){switch(this.geolocationError=!0,e.code){case e.PERMISSION_DENIED:salla.log("User denied the request for Geolocation.");break;case e.POSITION_UNAVAILABLE:salla.log("Location information is unavailable.");break;case e.TIMEOUT:salla.log("The request to get user location timed out.");break;case e.UNKNOWN_ERROR:salla.log("An unknown error occurred.")}}componentDidLoad(){this.lat&&this.lng&&fetch(`https://maps.googleapis.com/maps/api/geocode/json?latlng=${this.lat},${this.lng}&key=${this.apiKey}&language=${salla.config.get("user.language_code")||document.documentElement.lang||"ar"}`).then((e=>e.json())).then((e=>{"OK"===e.status&&(this.formattedAddress=e.results[0].formatted_address,this.searchInputValue=e.results[0].formatted_address,this.searchInput.value=e.results[0].formatted_address,this.selectedLng=this.lng,this.selectedLat=this.lat)})),this.mapInput.addEventListener("invalid",(e=>{this.invalidInput.emit(e)})),this.mapInput.addEventListener("input",(()=>{this.mapInput.setCustomValidity(""),this.mapInput.reportValidity()}))}async open(){return this.map||this.initGoogleMaps({libraries:this.searchable?["places","search"]:[],language:salla.config.get("user.language_code")||document.documentElement.lang||"ar"},this.mapElement),await this.locationModal.open()}getLocationModal(){return t("div",null,t("div",{class:"s-map-modal-title"},this.modalTitle?this.modalTitle:this.modalActivityTitle),t("div",{class:"s-map-modal-body"},t("div",{class:"s-map-element",ref:e=>this.mapElement=e}),this.readonly?"":[this.searchable&&t("div",{class:"s-map-search-wrapper"},t("input",{class:"s-map-search-input",ref:e=>this.searchInput=e,placeholder:this.searchPlaceholder})),t("salla-button",{class:"s-map-my-location-button",onClick:()=>{this.getCurrentLocation()},shape:"icon",color:"primary"},t("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>location-target</title>\n<path d="M16 9.333c-3.676 0-6.667 2.991-6.667 6.667s2.991 6.667 6.667 6.667 6.667-2.991 6.667-6.667-2.991-6.667-6.667-6.667zM16 20c-2.205 0-4-1.795-4-4s1.795-4 4-4 4 1.795 4 4-1.795 4-4 4zM30.667 14.667h-1.401c-0.627-6.289-5.643-11.305-11.932-11.932v-1.401c0-0.736-0.597-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v1.401c-6.289 0.627-11.305 5.643-11.932 11.932h-1.401c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h1.401c0.628 6.289 5.643 11.305 11.932 11.932v1.401c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-1.401c6.289-0.628 11.305-5.643 11.932-11.932h1.401c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333zM16 26.667c-5.881 0-10.667-4.785-10.667-10.667s4.785-10.667 10.667-10.667 10.667 4.785 10.667 10.667-4.785 10.667-10.667 10.667z"></path>\n</svg>\n'})),t("salla-button",{class:"s-map-submit-button",color:"primary",width:"wide",onClick:()=>{let e={lat:this.lat,lng:this.lng,address:this.formattedAddress?this.formattedAddress:null};salla.event.emit("salla-map::selected",e),this.selected.emit(e),this.selectedLat=e.lat,this.selectedLng=e.lng,this.getPositionAddress(new google.maps.LatLng(e.lat,e.lng),!0),this.mapInput.value=this.selectedLat&&this.selectedLng?`${this.selectedLat}, ${this.selectedLng}`:null,this.mapInput.dispatchEvent(new window.Event("change",{bubbles:!0})),this.locationModal.close()}},this.confirmButtonTitle)]))}render(){return t(s,{key:"f3b0f4e444e266a4f9c60782bea7920a1b4c34b4",class:"s-map-wrapper"},t("salla-modal",{key:"5066a0f19b59509656350bd0a02bc8ff8bb3d9d7",class:"s-map-modal-wrapper",noPadding:!0,ref:e=>{this.locationModal=e}},this.getLocationModal()),t("slot",{key:"884266b42b7c5532486c4e8bd1aba8b0e6bf2f89",name:"button"},t("salla-button",{key:"32b96c45aca7589681a3819d165b38e8f9ee036e",onClick:()=>{this.open()},color:"primary",class:"s-map-location-button"},t("span",{key:"d73a9837cb6a6df740300a4f52c35dd7f9499e73",class:"s-map-location-icon",innerHTML:this.formattedAddress?'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>edit</title>\n<path d="M30.583 1.417c-1.828-1.829-5.019-1.829-6.847 0l-13.396 13.396c-0.161 0.161-0.279 0.361-0.341 0.581l-1.949 6.911c-0.131 0.464 0 0.964 0.341 1.305 0.253 0.252 0.593 0.389 0.943 0.389 0.121 0 0.243-0.016 0.361-0.051l6.911-1.949c0.22-0.061 0.419-0.179 0.581-0.34l10.455-10.453s0 0 0 0l2.941-2.941c1.887-1.888 1.887-4.96 0-6.848zM15.547 19.528l-4.284 1.208 1.208-4.284 9.265-9.265 3.076 3.076zM28.696 6.38l-1.999 1.999-3.076-3.076 1.999-1.999c0.849-0.848 2.227-0.848 3.076 0 0.848 0.848 0.848 2.227 0 3.076zM24 20c-0.737 0-1.333 0.597-1.333 1.333v4c0 2.205-1.795 4-4 4h-12c-2.205 0-4-1.795-4-4v-12c0-2.205 1.795-4 4-4h4c0.737 0 1.333-0.597 1.333-1.333s-0.596-1.333-1.333-1.333h-4c-3.676 0-6.667 2.991-6.667 6.667v12c0 3.676 2.991 6.667 6.667 6.667h12c3.676 0 6.667-2.991 6.667-6.667v-4c0-0.736-0.596-1.333-1.333-1.333z"></path>\n</svg>\n':'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>location</title>\n<path d="M16.001 0c-7.879 0-12.001 6.204-12.001 12.333 0 5.813 9.853 17.833 10.976 19.185 0.253 0.305 0.629 0.481 1.025 0.481s0.772-0.176 1.027-0.481c1.121-1.352 10.972-13.372 10.972-19.185 0-6.129-4.121-12.333-11.999-12.333zM16.001 28.549c-3.32-4.184-9.335-12.527-9.335-16.216 0-4.656 2.92-9.667 9.335-9.667 6.412 0 9.332 5.011 9.332 9.667 0 3.689-6.013 12.032-9.332 16.216zM16 6.667c-2.941 0-5.333 2.392-5.333 5.333s2.392 5.333 5.333 5.333 5.333-2.392 5.333-5.333-2.392-5.333-5.333-5.333zM16 14.667c-1.471 0-2.667-1.196-2.667-2.667s1.196-2.667 2.667-2.667 2.667 1.196 2.667 2.667-1.196 2.667-2.667 2.667z"></path>\n</svg>\n'}),this.formattedAddress?t("div",null,this.locateButtonEdit," | ",this.formatAddress(this.formattedAddress)):this.locateButtonTitle)),t("input",{key:"77a53ca7c0b51268813238d80db56a9b9449c3f9",class:"s-hidden",name:this.name,required:this.required,value:this.getLatLng(),ref:e=>this.mapInput=e}))}get host(){return i(this)}};d.style="";export{r as salla_accordion_body,h as salla_accordion_head,d as salla_map}
4
+ import{r as e,h as t,H as s,c as a,a as i}from"./p-ea1dIZhh.js";import{p as l,m as o}from"./p-DfeagqF1.js";const r=class{constructor(t){e(this,t)}render(){return t(s,{key:"298d42a5bf1bcefdb181ec35060220cf749b56ed",class:"s-accordion-body-wrapper"},t("slot",{key:"6ab081e8b71b5dc69fb66fbdec82b4725ab53b0d"}))}};r.style="";const h=class{constructor(t){e(this,t),this.accordionToggle=a(this,"accordionToggle"),this.collapsible=!1,this.collapsed=!0}emitCollapsePanel(){this.accordionToggle.emit({payload:{collapsed:this.collapsed}})}toggleCollapse(){this.collapsible&&(this.collapsed=!this.collapsed,this.host.parentElement?.setAttribute("data-collapsed",this.collapsed.toString()),this.host.parentElement?.querySelector("salla-accordion-body")?.setAttribute("data-collapsed",this.collapsed.toString()),this.emitCollapsePanel())}render(){return t(s,{key:"9d88d243306cdf451c20d7068fbb9f48807b22e9","data-collapsed":this.collapsed.toString(),onClick:()=>this.toggleCollapse(),class:"s-accordion-head-wrapper"},t("div",{key:"bad4c5a913ce1c4581b09c0b6d96fcbdb4236638",class:"s-accordion-head-wrapper-start"},t("slot",{key:"acb83cec8cbca5771a9f84e81c0b955c3edad731",name:"title"}),t("slot",{key:"a4ad42ea6fad4f452c4c218a9ee02dca0adb4a67",name:"progress"}),t("slot",{key:"96ab95d413dc906ac299079f4008816f01881990",name:"html"})),(this.collapsible||this.host.querySelector('[slot="note"]'))&&t("div",{key:"8f9666a5038cd7b1ac6e357c6920ea26d31c5f03",class:"s-accordion-head-wrapper-end"},t("slot",{key:"14895e8c1385e91c14f046c9ae38ce5e4a4c9a60",name:"note"}),this.collapsible&&t("button",{key:"97dc7fabbb207fcc8b68ebf0a86f6c8a980dca13",class:{"s-accordion-head-wrapper-toggle":!0,active:!this.collapsed},onClick:e=>{e.stopPropagation(),this.toggleCollapse()}},t("span",{key:"3b24faf71dcd332663a354310b2ce09f7879eddc",class:"s-accordion-head-wrapper-toggle-icon",innerHTML:this.collapsed?l:o}))))}get host(){return i(this)}};h.style="";var c={light:[{featureType:"water",elementType:"geometry",stylers:[{color:"#e9e9e9"},{lightness:17}]},{featureType:"landscape",elementType:"geometry",stylers:[{color:"#f5f5f5"},{lightness:20}]},{featureType:"road.highway",elementType:"geometry.fill",stylers:[{color:"#ffffff"},{lightness:17}]},{featureType:"road.highway",elementType:"geometry.stroke",stylers:[{color:"#ffffff"},{lightness:29},{weight:.2}]},{featureType:"road.arterial",elementType:"geometry",stylers:[{color:"#ffffff"},{lightness:18}]},{featureType:"road.local",elementType:"geometry",stylers:[{color:"#ffffff"},{lightness:16}]},{featureType:"poi",elementType:"geometry",stylers:[{color:"#f5f5f5"},{lightness:21}]},{featureType:"poi.park",elementType:"geometry",stylers:[{color:"#dedede"},{lightness:21}]},{elementType:"labels.text.stroke",stylers:[{visibility:"on"},{color:"#ffffff"},{lightness:16}]},{elementType:"labels.text.fill",stylers:[{saturation:36},{color:"#333333"},{lightness:40}]},{elementType:"labels.icon",stylers:[{visibility:"off"}]},{featureType:"transit",elementType:"geometry",stylers:[{color:"#f2f2f2"},{lightness:19}]},{featureType:"administrative",elementType:"geometry.fill",stylers:[{color:"#fefefe"},{lightness:20}]},{featureType:"administrative",elementType:"geometry.stroke",stylers:[{color:"#fefefe"},{lightness:17},{weight:1.2}]}],dark:[{elementType:"geometry",stylers:[{color:"#242f3e"}]},{elementType:"labels.text.fill",stylers:[{color:"#746855"}]},{elementType:"labels.text.stroke",stylers:[{color:"#242f3e"}]},{featureType:"administrative.locality",elementType:"labels.text.fill",stylers:[{color:"#d59563"}]},{featureType:"poi",elementType:"labels.text.fill",stylers:[{color:"#d59563"}]},{featureType:"poi.park",elementType:"geometry",stylers:[{color:"#263c3f"}]},{featureType:"poi.park",elementType:"labels.text.fill",stylers:[{color:"#6b9a76"}]},{featureType:"road",elementType:"geometry",stylers:[{color:"#38414e"}]},{featureType:"road",elementType:"geometry.stroke",stylers:[{color:"#212a37"}]},{featureType:"road",elementType:"labels.text.fill",stylers:[{color:"#9ca5b3"}]},{featureType:"road.highway",elementType:"geometry",stylers:[{color:"#746855"}]},{featureType:"road.highway",elementType:"geometry.stroke",stylers:[{color:"#1f2835"}]},{featureType:"road.highway",elementType:"labels.text.fill",stylers:[{color:"#f3d19c"}]},{featureType:"transit",elementType:"geometry",stylers:[{color:"#2f3948"}]},{featureType:"transit.station",elementType:"labels.text.fill",stylers:[{color:"#d59563"}]},{featureType:"water",elementType:"geometry",stylers:[{color:"#17263c"}]},{featureType:"water",elementType:"labels.text.fill",stylers:[{color:"#515c6d"}]},{featureType:"water",elementType:"labels.text.stroke",stylers:[{color:"#17263c"}]}]};class n{constructor(e=null,t={}){if(this.apiKey=e,this.options=t,"undefined"==typeof window)throw new Error("google-maps is supported only in browser environment")}load(){return void 0!==this.api?Promise.resolve(this.api):void 0!==this.loader?this.loader:(window[n.CALLBACK_NAME]=()=>{if(this.api=window.google,void 0===this.resolve)throw new Error("Should not happen");this.resolve(this.api)},window.gm_authFailure=()=>{if(void 0===this.reject)throw new Error("Should not happen");this.reject(new Error("google-maps: authentication error"))},this.loader=new Promise(((e,t)=>{this.resolve=e,this.reject=t;const s=document.createElement("script");s.src=this.createUrl(),s.async=!0,s.onerror=e=>t(e),document.head.appendChild(s)})))}createUrl(){const e=[`callback=${n.CALLBACK_NAME}`];this.apiKey&&e.push(`key=${this.apiKey}`);for(let t in this.options)if(this.options.hasOwnProperty(t)){let s=this.options[t];"version"===t&&(t="v"),"libraries"===t&&(s=s.join(",")),e.push(`${t}=${s}`)}return`https://maps.googleapis.com/maps/api/js?${e.join("&")}`}}n.CALLBACK_NAME="_dk_google_maps_loader_cb";const d=class{constructor(t){e(this,t),this.selected=a(this,"selected"),this.mapClicked=a(this,"mapClicked"),this.currentLocationChanged=a(this,"currentLocationChanged"),this.invalidInput=a(this,"invalidInput"),this.defaultLat=21.419421,this.defaultLng=39.82553,this.modalActivityTitle=salla.lang.get("pages.checkout.select_your_address_from_map"),this.confirmButtonTitle=salla.lang.get("pages.checkout.confirm_address"),this.locateButtonTitle=salla.lang.get("pages.cart.detect_location"),this.locateButtonEdit=salla.lang.get("common.elements.edit"),this.searchPlaceholder=salla.lang.get("pages.checkout.search_for_address"),this.searchInputValue=null,this.formattedAddress="",this.geolocationError=!1,this.name="location",this.required=!1,this.readonly=!1,this.searchable=!1,this.zoom=10,this.theme="light",salla.lang.onLoaded((()=>{this.modalActivityTitle=salla.lang.get("pages.checkout.select_your_address_from_map"),this.confirmButtonTitle=salla.lang.get("pages.checkout.confirm_address"),this.locateButtonTitle=salla.lang.get("pages.cart.detect_location"),this.locateButtonEdit=salla.lang.get("common.elements.edit"),this.searchPlaceholder=salla.lang.get("pages.checkout.search_for_address")})),salla.onReady((()=>{this.apiKey=salla.config.get("store.settings.keys.maps","AIzaSyBFgFISAizDP3YVWj0y5rF8JKKNQ2vohdc")}))}formatAddress(e){return e.length>25?e.substring(0,25)+"...":e}getLatLng(){return this.selectedLat&&this.selectedLng?`${this.selectedLat}, ${this.selectedLng}`:null}getPositionAddress(e,t=!1){(new google.maps.Geocoder).geocode({location:e},((e,s)=>{s===google.maps.GeocoderStatus.OK&&(this.searchable&&(this.searchInputValue=e[0].formatted_address,this.searchInput.value=e[0].formatted_address),t&&(this.formattedAddress=e[0].formatted_address))}))}initGoogleMaps(e,t){new n(this.apiKey,e).load().then((e=>{if(this.map=new e.maps.Map(t,{center:this.lat||this.lng?{lat:this.lat,lng:this.lng}:{lat:this.defaultLat,lng:this.defaultLng},zoom:this.zoom,zoomControl:!0,mapTypeControl:!1,scaleControl:!1,streetViewControl:!1,rotateControl:!1,fullscreenControl:!1,disableDefaultUI:!1}),this.map.setOptions({styles:"light"===this.theme?c.light:c.dark}),this.marker=new e.maps.Marker({position:this.map.getCenter(),map:this.map,icon:{url:"data:image/svg+xml;utf8,"+encodeURIComponent('<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">\n<rect width="36" height="36" rx="18" fill="#5CD5C4"/>\n<path d="M18 10C17.0104 10 16.1458 10.1771 15.4062 10.5312C14.6562 10.8854 14.026 11.3542 13.5156 11.9375C13.0156 12.5104 12.6406 13.1667 12.3906 13.9062C12.1302 14.6458 12 15.401 12 16.1719C12 16.8906 12.2604 17.7656 12.7812 18.7969C13.3021 19.8281 13.8854 20.8333 14.5312 21.8125C15.1875 22.7812 15.8073 23.6406 16.3906 24.3906C16.9844 25.1302 17.349 25.5885 17.4844 25.7656C17.5469 25.8385 17.625 25.8958 17.7188 25.9375C17.8125 25.9792 17.9062 26 18 26C18.1042 26 18.1979 25.9792 18.2812 25.9375C18.375 25.8958 18.4531 25.8385 18.5156 25.7656C18.651 25.5885 19.0156 25.1302 19.6094 24.3906C20.1927 23.6406 20.8073 22.7812 21.4531 21.8125C22.1094 20.8333 22.6979 19.8281 23.2188 18.7969C23.7396 17.7656 24 16.8906 24 16.1719C24 15.401 23.8698 14.6458 23.6094 13.9062C23.3594 13.1667 22.9792 12.5104 22.4688 11.9375C21.9688 11.3542 21.3438 10.8854 20.5938 10.5312C19.8542 10.1771 18.9896 10 18 10ZM18 24.2812C17.5833 23.75 17.1094 23.1198 16.5781 22.3906C16.0365 21.651 15.526 20.901 15.0469 20.1406C14.5677 19.3698 14.1615 18.6302 13.8281 17.9219C13.4948 17.2135 13.3281 16.6302 13.3281 16.1719C13.3281 15.5885 13.4219 15.0052 13.6094 14.4219C13.7969 13.849 14.0781 13.3333 14.4531 12.875C14.8385 12.4167 15.3281 12.0469 15.9219 11.7656C16.5052 11.474 17.1979 11.3281 18 11.3281C18.8021 11.3281 19.4948 11.474 20.0781 11.7656C20.6719 12.0469 21.1562 12.4167 21.5312 12.875C21.9167 13.3333 22.2031 13.849 22.3906 14.4219C22.5781 15.0052 22.6719 15.5885 22.6719 16.1719C22.6719 16.6302 22.5052 17.2135 22.1719 17.9219C21.8385 18.6302 21.4323 19.3698 20.9531 20.1406C20.474 20.901 19.9688 21.651 19.4375 22.3906C18.8958 23.1198 18.4167 23.75 18 24.2812ZM18 13.3281C17.2604 13.3281 16.6302 13.5885 16.1094 14.1094C15.5885 14.6302 15.3281 15.2604 15.3281 16C15.3281 16.7396 15.5885 17.3698 16.1094 17.8906C16.6302 18.4115 17.2604 18.6719 18 18.6719C18.7396 18.6719 19.3698 18.4115 19.8906 17.8906C20.4115 17.3698 20.6719 16.7396 20.6719 16C20.6719 15.2604 20.4115 14.6302 19.8906 14.1094C19.3698 13.5885 18.7396 13.3281 18 13.3281ZM18 17.3281C17.6354 17.3281 17.3229 17.1979 17.0625 16.9375C16.8021 16.6771 16.6719 16.3646 16.6719 16C16.6719 15.6354 16.8021 15.3229 17.0625 15.0625C17.3229 14.8021 17.6354 14.6719 18 14.6719C18.3646 14.6719 18.6771 14.8021 18.9375 15.0625C19.1979 15.3229 19.3281 15.6354 19.3281 16C19.3281 16.3646 19.1979 16.6771 18.9375 16.9375C18.6771 17.1979 18.3646 17.3281 18 17.3281Z" fill="white"/>\n</svg>\n'),scaledSize:new e.maps.Size(30,30)}}),this.searchable){const t=new e.maps.places.SearchBox(this.searchInput);e.maps.event.addListener(t,"places_changed",(()=>{const e=t.getPlaces();e.length>0&&this.map&&(this.map.setCenter(e[0].geometry.location),this.lat=e[0].geometry.location.lat(),this.lng=e[0].geometry.location.lng(),this.marker.setPosition(e[0].geometry.location),this.searchInputValue=e[0].formatted_address,this.formattedAddress=e[0].formatted_address)}))}e.maps.event.addListener(this.map,"click",(e=>{this.readonly||(this.marker.setPosition(e.latLng),this.lat=e.latLng.lat(),this.lng=e.latLng.lng(),this.getPositionAddress(e.latLng),this.mapClicked.emit({lat:e.latLng.lat(),lng:e.latLng.lng(),address:this.formattedAddress?this.formattedAddress:null}))})),this.lat||this.lng||(this.getCurrentLocation(),this.geolocationError&&(this.map.setCenter({lat:this.lat,lng:this.lng}),this.marker.setPosition({lat:this.lat,lng:this.lng})))}))}getCurrentLocation(){navigator.geolocation&&this.map?navigator.geolocation.getCurrentPosition((e=>{const t={center:new google.maps.LatLng(e.coords.latitude,e.coords.longitude),zoom:15};this.map.setOptions(t),this.marker.setPosition(t.center),this.getPositionAddress(t.center),this.lat=e.coords.latitude,this.lng=e.coords.longitude,this.currentLocationChanged.emit({lat:e.coords.latitude,lng:e.coords.longitude,address:this.formattedAddress?this.formattedAddress:null})}),this.handleLocationError.bind(this)):(salla.log("Geolocation is not supported by this browser."),this.geolocationError=!0)}handleLocationError(e){switch(this.geolocationError=!0,e.code){case e.PERMISSION_DENIED:salla.log("User denied the request for Geolocation.");break;case e.POSITION_UNAVAILABLE:salla.log("Location information is unavailable.");break;case e.TIMEOUT:salla.log("The request to get user location timed out.");break;case e.UNKNOWN_ERROR:salla.log("An unknown error occurred.")}}componentDidLoad(){this.lat&&this.lng&&fetch(`https://maps.googleapis.com/maps/api/geocode/json?latlng=${this.lat},${this.lng}&key=${this.apiKey}&language=${salla.config.get("user.language_code")||document.documentElement.lang||"ar"}`).then((e=>e.json())).then((e=>{"OK"===e.status&&(this.formattedAddress=e.results[0].formatted_address,this.searchInputValue=e.results[0].formatted_address,this.searchInput.value=e.results[0].formatted_address,this.selectedLng=this.lng,this.selectedLat=this.lat)})),this.mapInput.addEventListener("invalid",(e=>{this.invalidInput.emit(e)})),this.mapInput.addEventListener("input",(()=>{this.mapInput.setCustomValidity(""),this.mapInput.reportValidity()}))}async open(){return this.map||this.initGoogleMaps({libraries:this.searchable?["places","search"]:[],language:salla.config.get("user.language_code")||document.documentElement.lang||"ar"},this.mapElement),await this.locationModal.open()}getLocationModal(){return t("div",null,t("div",{class:"s-map-modal-title"},this.modalTitle?this.modalTitle:this.modalActivityTitle),t("div",{class:"s-map-modal-body"},t("div",{class:"s-map-element",ref:e=>this.mapElement=e}),this.readonly?"":[this.searchable&&t("div",{class:"s-map-search-wrapper"},t("input",{class:"s-map-search-input",ref:e=>this.searchInput=e,placeholder:this.searchPlaceholder})),t("salla-button",{class:"s-map-my-location-button",onClick:()=>{this.getCurrentLocation()},shape:"icon",color:"primary"},t("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>location-target</title>\n<path d="M16 9.333c-3.676 0-6.667 2.991-6.667 6.667s2.991 6.667 6.667 6.667 6.667-2.991 6.667-6.667-2.991-6.667-6.667-6.667zM16 20c-2.205 0-4-1.795-4-4s1.795-4 4-4 4 1.795 4 4-1.795 4-4 4zM30.667 14.667h-1.401c-0.627-6.289-5.643-11.305-11.932-11.932v-1.401c0-0.736-0.597-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v1.401c-6.289 0.627-11.305 5.643-11.932 11.932h-1.401c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h1.401c0.628 6.289 5.643 11.305 11.932 11.932v1.401c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-1.401c6.289-0.628 11.305-5.643 11.932-11.932h1.401c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333zM16 26.667c-5.881 0-10.667-4.785-10.667-10.667s4.785-10.667 10.667-10.667 10.667 4.785 10.667 10.667-4.785 10.667-10.667 10.667z"></path>\n</svg>\n'})),t("salla-button",{class:"s-map-submit-button",color:"primary",width:"wide",onClick:()=>{let e={lat:this.lat,lng:this.lng,address:this.formattedAddress?this.formattedAddress:null};salla.event.emit("salla-map::selected",e),this.selected.emit(e),this.selectedLat=e.lat,this.selectedLng=e.lng,this.getPositionAddress(new google.maps.LatLng(e.lat,e.lng),!0),this.mapInput.value=this.selectedLat&&this.selectedLng?`${this.selectedLat}, ${this.selectedLng}`:null,this.mapInput.dispatchEvent(new window.Event("change",{bubbles:!0})),this.locationModal.close()}},this.confirmButtonTitle)]))}render(){return t(s,{key:"f3b0f4e444e266a4f9c60782bea7920a1b4c34b4",class:"s-map-wrapper"},t("salla-modal",{key:"5066a0f19b59509656350bd0a02bc8ff8bb3d9d7",class:"s-map-modal-wrapper",noPadding:!0,ref:e=>{this.locationModal=e}},this.getLocationModal()),t("slot",{key:"884266b42b7c5532486c4e8bd1aba8b0e6bf2f89",name:"button"},t("salla-button",{key:"32b96c45aca7589681a3819d165b38e8f9ee036e",onClick:()=>{this.open()},color:"primary",class:"s-map-location-button"},t("span",{key:"d73a9837cb6a6df740300a4f52c35dd7f9499e73",class:"s-map-location-icon",innerHTML:this.formattedAddress?'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>edit</title>\n<path d="M30.583 1.417c-1.828-1.829-5.019-1.829-6.847 0l-13.396 13.396c-0.161 0.161-0.279 0.361-0.341 0.581l-1.949 6.911c-0.131 0.464 0 0.964 0.341 1.305 0.253 0.252 0.593 0.389 0.943 0.389 0.121 0 0.243-0.016 0.361-0.051l6.911-1.949c0.22-0.061 0.419-0.179 0.581-0.34l10.455-10.453s0 0 0 0l2.941-2.941c1.887-1.888 1.887-4.96 0-6.848zM15.547 19.528l-4.284 1.208 1.208-4.284 9.265-9.265 3.076 3.076zM28.696 6.38l-1.999 1.999-3.076-3.076 1.999-1.999c0.849-0.848 2.227-0.848 3.076 0 0.848 0.848 0.848 2.227 0 3.076zM24 20c-0.737 0-1.333 0.597-1.333 1.333v4c0 2.205-1.795 4-4 4h-12c-2.205 0-4-1.795-4-4v-12c0-2.205 1.795-4 4-4h4c0.737 0 1.333-0.597 1.333-1.333s-0.596-1.333-1.333-1.333h-4c-3.676 0-6.667 2.991-6.667 6.667v12c0 3.676 2.991 6.667 6.667 6.667h12c3.676 0 6.667-2.991 6.667-6.667v-4c0-0.736-0.596-1.333-1.333-1.333z"></path>\n</svg>\n':'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>location</title>\n<path d="M16.001 0c-7.879 0-12.001 6.204-12.001 12.333 0 5.813 9.853 17.833 10.976 19.185 0.253 0.305 0.629 0.481 1.025 0.481s0.772-0.176 1.027-0.481c1.121-1.352 10.972-13.372 10.972-19.185 0-6.129-4.121-12.333-11.999-12.333zM16.001 28.549c-3.32-4.184-9.335-12.527-9.335-16.216 0-4.656 2.92-9.667 9.335-9.667 6.412 0 9.332 5.011 9.332 9.667 0 3.689-6.013 12.032-9.332 16.216zM16 6.667c-2.941 0-5.333 2.392-5.333 5.333s2.392 5.333 5.333 5.333 5.333-2.392 5.333-5.333-2.392-5.333-5.333-5.333zM16 14.667c-1.471 0-2.667-1.196-2.667-2.667s1.196-2.667 2.667-2.667 2.667 1.196 2.667 2.667-1.196 2.667-2.667 2.667z"></path>\n</svg>\n'}),this.formattedAddress?t("div",null,this.locateButtonEdit," | ",this.formatAddress(this.formattedAddress)):this.locateButtonTitle)),t("input",{key:"77a53ca7c0b51268813238d80db56a9b9449c3f9",class:"s-hidden",name:this.name,required:this.required,value:this.getLatLng(),ref:e=>this.mapInput=e}))}get host(){return i(this)}};d.style="";export{r as salla_accordion_body,h as salla_accordion_head,d as salla_map}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,c as s,h as e,H as i,a}from"./p-CV1rqKQz.js";import{F as l}from"./p-DL4h2bc3.js";import{H as r}from"./p-CHf8XdiS.js";import"./p-CgtvEd63.js";const o=class{constructor(e){t(this,e),this.changed=s(this,"changed"),this.isReady=!1,this.filtersData={},salla.event.on("filters::hidden",(()=>this.host.style.display="none")),salla.lang.onLoaded((()=>{this.apply=salla.lang.get("pages.checkout.apply"),this.reset=salla.lang.get("pages.categories.filters_reset")})),salla.event.on("filters::fetched",(({filters:t})=>{this.host.style.display="";let s={};this.filters=t.map((t=>{if(t.label={category_id:salla.lang.get("common.titles.categories"),brand_id:salla.lang.get("common.titles.brands"),rating:salla.lang.get("pages.categories.filter_rating"),price:salla.lang.get("pages.categories.filter_price")}[t.key]||t.label,"rating"==t.key){t.type=l.VALUES;let{max:s,min:e}=t.values;t.values=[5,4,3,2,1].filter((t=>t>=e||t<=s))}this.filtersData.variants&&t.type==l.VARIANTS&&(s.variants=this.filtersData.variants),this.filtersData[t.key]&&t.type!==l.VARIANTS&&(s[t.key]=this.filtersData[t.key]);let e=new URLSearchParams(window.location.search),i=!1;for(let t of e.keys())if(t.includes("filters")){i=!0;break}if("product.index"==salla.config.get("page.slug")&&0==Object.keys(s).length&&!i){let t=window.location.href,e=salla.config.get("page.id"),i=-1!==t.indexOf("?")?"&":"?",a=t+i+"filters[category_id]="+e;s.category_id=e,window.history.pushState({path:a},"",a)}return t})),this.filtersData=s,this.host.childNodes.forEach((async t=>t.setWidgetHeight&&await t.setWidgetHeight()))}))}async componentWillLoad(){try{const t=new URLSearchParams(window.location.search);this.filtersData=await r.extractFiltersFromUrl(t)}catch(t){console.warn("failed to get filters from URL",t.message)}}async getFilters(){return this.filtersData}async applyFilters(){if(!this.isReady)return;let t=Object.keys(this.filtersData).length>0;setTimeout((()=>{if(t){let t=new URL(window.location.href);for(const[s]of t.searchParams.entries())s.startsWith("filters")&&t.searchParams.delete(s);let s=this.encodeFilters(this.filtersData),e=t.search.split("&").filter((t=>!t.includes("filters"))).join("&");t.search=e?t.search.split("&filters")[0]+"&"+s:`?${s}`,window.history.pushState({},"",t.href)}else{let t=new URL(window.location.href);t.searchParams?.delete("filters"),window.history.pushState({},"",t.toString())}salla.event.emit("salla-filters::changed",this.filtersData),this.changed.emit(this.filtersData)}),300)}encodeFilters(t,s="filters"){const e=[];for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){const a=t[i],l=s?`${s}[${i}]`:i;if(Array.isArray(a))for(let t=0;t<a.length;t++)e.push(`${l}[${t}]=${a[t]}`);else e.push("object"==typeof a&&null!==a?this.encodeFilters(a,l):`${l}=${a}`)}return e.join("&")}async resetFilters(){return this.removeFiltersQueryParams(),this.filtersData={},this.host.childNodes.forEach((t=>t.reset&&t.reset())),salla.event.emit("salla-filters::reset"),this.applyFilters()}removeFiltersQueryParams(){const t=new URLSearchParams(window.location.search),s=Array.from(t.keys()).filter((t=>!t.startsWith("filters["))).map((s=>`${encodeURIComponent(s)}=${encodeURIComponent(t.get(s))}`)).join("&"),e=s?`${window.location.pathname}?${s}`:window.location.pathname;window.history.pushState({},"",e)}handleOptionChange(t,s,e){s.type===l.RANGE&&(this.filtersData[s.key]=e);let i=t.target.checked;s.type===l.VARIANTS?(this.filtersData.variants=this.filtersData.variants||{},i&&(this.filtersData.variants[s.key]=e),i||delete this.filtersData.variants[s.key]):"radio"==t.target.type?(i&&(this.filtersData[s.key]=e),i||delete this.filtersData[s.key]):"checkbox"==t.target.type&&(this.filtersData[s.key]=this.filtersData[s.key]||[],i&&this.filtersData[s.key].push(e),this.filtersData[s.key]=this.filtersData[s.key].filter((t=>t!=e))),this.applyFilters()}render(){return e(i,{key:"cee91d1495df18bbdbd71625ff85f582fe93f90a"},this.filters?.map((t=>e("salla-filters-widget",{option:t,filtersData:this.filtersData,onChanged:({detail:{event:t,option:s,value:e}})=>{this.handleOptionChange(t,s,e)}}))),this.filters?.length?e("div",{class:"s-filters-footer"},e("salla-button",{color:"gray",fill:"outline",onClick:()=>this.resetFilters()},this.reset)):"")}componentDidLoad(){this.isReady=!0}get host(){return a(this)}};o.style=":host{display:block}.s-rating-stars-small{line-height:12px}.s-filters-radio{background-image:none !important}";export{o as salla_filters}
4
+ import{r as t,c as s,h as e,H as i,a}from"./p-ea1dIZhh.js";import{F as l}from"./p-DL4h2bc3.js";import{H as r}from"./p-CHf8XdiS.js";import"./p-CgtvEd63.js";const o=class{constructor(e){t(this,e),this.changed=s(this,"changed"),this.isReady=!1,this.filtersData={},salla.event.on("filters::hidden",(()=>this.host.style.display="none")),salla.lang.onLoaded((()=>{this.apply=salla.lang.get("pages.checkout.apply"),this.reset=salla.lang.get("pages.categories.filters_reset")})),salla.event.on("filters::fetched",(({filters:t})=>{this.host.style.display="";let s={};this.filters=t.map((t=>{if(t.label={category_id:salla.lang.get("common.titles.categories"),brand_id:salla.lang.get("common.titles.brands"),rating:salla.lang.get("pages.categories.filter_rating"),price:salla.lang.get("pages.categories.filter_price")}[t.key]||t.label,"rating"==t.key){t.type=l.VALUES;let{max:s,min:e}=t.values;t.values=[5,4,3,2,1].filter((t=>t>=e||t<=s))}this.filtersData.variants&&t.type==l.VARIANTS&&(s.variants=this.filtersData.variants),this.filtersData[t.key]&&t.type!==l.VARIANTS&&(s[t.key]=this.filtersData[t.key]);let e=new URLSearchParams(window.location.search),i=!1;for(let t of e.keys())if(t.includes("filters")){i=!0;break}if("product.index"==salla.config.get("page.slug")&&0==Object.keys(s).length&&!i){let t=window.location.href,e=salla.config.get("page.id"),i=-1!==t.indexOf("?")?"&":"?",a=t+i+"filters[category_id]="+e;s.category_id=e,window.history.pushState({path:a},"",a)}return t})),this.filtersData=s,this.host.childNodes.forEach((async t=>t.setWidgetHeight&&await t.setWidgetHeight()))}))}async componentWillLoad(){try{const t=new URLSearchParams(window.location.search);this.filtersData=await r.extractFiltersFromUrl(t)}catch(t){console.warn("failed to get filters from URL",t.message)}}async getFilters(){return this.filtersData}async applyFilters(){if(!this.isReady)return;let t=Object.keys(this.filtersData).length>0;setTimeout((()=>{if(t){let t=new URL(window.location.href);for(const[s]of t.searchParams.entries())s.startsWith("filters")&&t.searchParams.delete(s);let s=this.encodeFilters(this.filtersData),e=t.search.split("&").filter((t=>!t.includes("filters"))).join("&");t.search=e?t.search.split("&filters")[0]+"&"+s:`?${s}`,window.history.pushState({},"",t.href)}else{let t=new URL(window.location.href);t.searchParams?.delete("filters"),window.history.pushState({},"",t.toString())}salla.event.emit("salla-filters::changed",this.filtersData),this.changed.emit(this.filtersData)}),300)}encodeFilters(t,s="filters"){const e=[];for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){const a=t[i],l=s?`${s}[${i}]`:i;if(Array.isArray(a))for(let t=0;t<a.length;t++)e.push(`${l}[${t}]=${a[t]}`);else e.push("object"==typeof a&&null!==a?this.encodeFilters(a,l):`${l}=${a}`)}return e.join("&")}async resetFilters(){return this.removeFiltersQueryParams(),this.filtersData={},this.host.childNodes.forEach((t=>t.reset&&t.reset())),salla.event.emit("salla-filters::reset"),this.applyFilters()}removeFiltersQueryParams(){const t=new URLSearchParams(window.location.search),s=Array.from(t.keys()).filter((t=>!t.startsWith("filters["))).map((s=>`${encodeURIComponent(s)}=${encodeURIComponent(t.get(s))}`)).join("&"),e=s?`${window.location.pathname}?${s}`:window.location.pathname;window.history.pushState({},"",e)}handleOptionChange(t,s,e){s.type===l.RANGE&&(this.filtersData[s.key]=e);let i=t.target.checked;s.type===l.VARIANTS?(this.filtersData.variants=this.filtersData.variants||{},i&&(this.filtersData.variants[s.key]=e),i||delete this.filtersData.variants[s.key]):"radio"==t.target.type?(i&&(this.filtersData[s.key]=e),i||delete this.filtersData[s.key]):"checkbox"==t.target.type&&(this.filtersData[s.key]=this.filtersData[s.key]||[],i&&this.filtersData[s.key].push(e),this.filtersData[s.key]=this.filtersData[s.key].filter((t=>t!=e))),this.applyFilters()}render(){return e(i,{key:"cee91d1495df18bbdbd71625ff85f582fe93f90a"},this.filters?.map((t=>e("salla-filters-widget",{option:t,filtersData:this.filtersData,onChanged:({detail:{event:t,option:s,value:e}})=>{this.handleOptionChange(t,s,e)}}))),this.filters?.length?e("div",{class:"s-filters-footer"},e("salla-button",{color:"gray",fill:"outline",onClick:()=>this.resetFilters()},this.reset)):"")}componentDidLoad(){this.isReady=!0}get host(){return a(this)}};o.style=":host{display:block}.s-rating-stars-small{line-height:12px}.s-filters-radio{background-image:none !important}";export{o as salla_filters}
@@ -0,0 +1,4 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import{r as t,c as s,h as i,H as e,a}from"./p-ea1dIZhh.js";import{a as o}from"./p-CgtvEd63.js";import{S as h}from"./p-DiKTtDW5.js";import{H as r}from"./p-CHf8XdiS.js";const l=class{constructor(i){t(this,i),this.productsFetched=s(this,"productsFetched"),this.autoload=!1,this.productCardComponent="custom-salla-product-card",this.page=1,this.placeholderText=salla.lang.get("pages.categories.no_products"),this.endOfText=salla.lang.get("common.elements.end_of_content"),this.failedLoadMore=salla.lang.get("common.elements.failed_to_load_more"),this.currentPage=salla.config.get("page"),this.filtersSnapshot=[],this.lastViewedProductKey="lastViewedProductId",this.filtersKey="filters",this.infiniteScrollStateKey="infiniteScrollState",this.prevCategoryIdKey="prevCategoryId",this.isProcessing=!1,this.scrollTimeout=null,this.boundScrollToLastViewedProduct=()=>this.scrollToLastViewedProduct(),this.boundHandleScroll=()=>this.handleScroll(),this.specialPagesWithoutIds={"product.index.latest":"latest","product.index.offers":"offers","product.index.search":"search","product.index.sales":"sales"},this.includes=r.parseJson(this.includes||this.host.getAttribute("includes")),Array.isArray(this.includes)||(this.includes=null),r.setIncludes(this.includes),salla.lang.onLoaded((()=>{this.placeholderText=salla.lang.get("pages.categories.no_products"),this.endOfText=salla.lang.get("common.elements.end_of_content"),this.failedLoadMore=salla.lang.get("common.elements.failed_to_load_more"),this.currentPage=salla.config.get("page")}))}connectedCallback(){"scrollRestoration"in history&&(history.scrollRestoration="manual"),window.addEventListener("DOMContentLoaded",this.boundScrollToLastViewedProduct),salla.event.on("salla-filters::changed",(t=>this.setFilters(t)))}disconnectedCallback(){window.removeEventListener("DOMContentLoaded",this.boundScrollToLastViewedProduct),window.removeEventListener("scroll",this.boundHandleScroll)}async setFilters(t){if(t&&JSON.stringify(t)!==JSON.stringify(this.parsedFilters))return window.scrollTo({top:0,behavior:"smooth"}),this.parsedFilters=JSON.parse(JSON.stringify(t)),this.filtersSnapshot=this.parsedFilters,"product.index"==this.currentPage?.slug&&this.parsedFilters&&this.parsedFilters.category_id&&(this.currentCategoryIdFilter=[this.parsedFilters.category_id]),this.reload()}async reload(){!this.autoload&&this.loadMoreWrapper&&(this.loadMoreWrapper.style.display="none"),this.hasInfiniteScroll&&salla.infiniteScroll.destroy(this.infiniteScroll),this.buildNextPageUrl(),this.wrapper.innerHTML="",this.hasInfiniteScroll?this.init():this.getInitialData(),this.showPlaceholder&&(this.showPlaceholder=!1,this.placeholderLoader=document.createElement("div"),this.placeholderLoader.classList.add("s-products-list-loading-wrapper"),this.placeholderLoader.style.display="inherit",this.placeholderLoader.innerHTML='<span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader"></span>',this.host.insertAdjacentElement("afterend",this.placeholderLoader))}isFilterable(){return salla.config.get("store.settings.product.filters")&&this.filtersResults}isSourceWithoutValue(){return["offers","latest","sales","wishlist","top-rated","reorder"].includes(this.getSource())}animateItems(){o({targets:"salla-products-list salla-product-card",opacity:[0,1],duration:1200,translateY:[20,0],delay:function(t,s){return 100*s}})}initBaseNextPageUrl(t){this.nextPage=salla.url.api(`products?source=${t}`),this.includes?.length&&(this.nextPage+=`&includes[]=${this.includes.join("&includes[]=")}`),this.limit&&(this.nextPage+=`&per_page=${this.limit>32?32:this.limit}`),this.sortBy&&(this.nextPage+=`&sort=${this.sortBy}`),"preview"===salla.config.get("theme.mode")&&(this.nextPage+="&use_username_url=1"),this.nextPage+="&filterable=1";for(const[t,s]of Object.entries(this.parsedFilters||{}))if(["string","number"].includes(typeof s))this.nextPage+=`&filters[${encodeURIComponent(t)}]=${encodeURIComponent(s)}`;else if(Array.isArray(s))s.forEach((s=>this.nextPage+=`&filters[${encodeURIComponent(t)}][]=${encodeURIComponent(s)}`));else if("object"==typeof s)for(const[i,e]of Object.entries(s))this.nextPage+=`&filters[${encodeURIComponent(t)}][${encodeURIComponent(i)}]=${encodeURIComponent(e)}`}buildNextPageUrl(){let t=this.getSource();if("json"===t)return;const s=sessionStorage.getItem(this.infiniteScrollStateKey);if(s){const{nextPage:t}=JSON.parse(s);if(!t)return}if(this.initBaseNextPageUrl(t),!this.isSourceWithoutValue())if(["search","related","landing-page"].includes(t))this.nextPage+=`&source_value=${this.getSourceValue()}`;else try{this.nextPage+=`&source_value[]=${this.getSourceValue().join("&source_value[]=")}`}catch(s){salla.logger.warn(`source-value prop should be array of ids ex source-value="[1,2,3]" for the source [${t}]`),this.sourceValueIsValid=!1}}loading(t=!0,s=!1){if(t){let t=s&&!this.autoload?this.btnLoader:this.loader;t&&(t.style.display="inherit")}else this.autoload||this.btnLoader&&(this.btnLoader.style.display="none"),this.loader&&(this.loader.style.display="none")}getItemHTML(t){"landing-page"===this.getSource()&&(t.url="");const s=document.createElement(this.hasCustomComponent?this.productCardComponent:"salla-product-card");return s.product=t,this.compactCards&&(s.compact=!0,s.toggleAttribute("compact",!0)),this.applyLandingPageStyles(s),this.applyHorizontalCardStyles(s),s.addEventListener("click",(s=>{s.target.closest("a")&&(r.saveProductSource(this.getSource()),this.hasInfiniteScroll&&(this.takeStateSnapshot(),sessionStorage.setItem(this.lastViewedProductKey,t.id)))})),s}applyLandingPageStyles(t){"landing-page"!==this.getSource()||this.hasCustomComponent||(t.toggleAttribute("hide-add-btn",!0),t.classList.add("s-product-card-fit-height"))}applyHorizontalCardStyles(t){this.horizontalCards&&(t.toggleAttribute("horizontal",!0),this.hasCustomComponent||t.toggleAttribute("shadow-on-hover",!0))}waitForResizing(t){let s=null;return new Promise((i=>{const e=new ResizeObserver((()=>{clearTimeout(s),s=setTimeout((()=>{e.disconnect(),i(null)}),160)}));e.observe(t)}))}waitForLayoutStable(t){let s=null;return new Promise((i=>{const e=new MutationObserver((()=>{clearTimeout(s),s=setTimeout((()=>{e.disconnect(),i(null)}),160)}));e.observe(t,{childList:!0,subtree:!0,attributes:!0})}))}async waitForStableLayout(t){return await Promise.allSettled([this.waitForResizing(t),this.waitForLayoutStable(t)])}scrollToLastViewedProduct(){const t=sessionStorage.getItem(this.lastViewedProductKey);t&&!salla.url.is_page("product.single")&&this.isElementLoaded(`[id*="${t}"]`).then((()=>{const s=this.wrapper?.querySelector(`[id*="${t}"]`);if(!s)return;const i=()=>{const t=()=>{s.scrollIntoView({block:"start",behavior:"instant"});const t=matchMedia("(max-width: 1024px)").matches?"header .inner":"ul.main-menu",i=window?.header_is_sticky?document.querySelector(t)?.getBoundingClientRect()?.height??56:0,e=parseInt(getComputedStyle(this.wrapper).rowGap)??16;scrollBy({top:-1*(i+e),behavior:"instant"})};requestAnimationFrame(t),s.querySelectorAll("img.lazy").forEach((s=>{const i=s,e=()=>{requestAnimationFrame(t),i.onload=i.onerror=null};i.onload=e,i.onerror=e})),this.removeScrollRestorationSession()};this.waitForStableLayout(this.host).then((()=>requestAnimationFrame(i)))}))}isElementLoaded(t){return new Promise((s=>{const i=setInterval((()=>{if(document.querySelector(t))return clearInterval(i),s(document.querySelector(t))}),50)}))}takeStateSnapshot(){const t=[];for(let s=0;s<this.wrapper.children.length;s++){const i=this.wrapper.children?.[s];t.push(i.product)}const s={pageIndex:Math.max((this.infiniteScroll?.pageIndex??1)-1,1),nextPage:this.nextPage,currentPageData:t};if(this.isFilterable()){const t=sessionStorage.getItem(this.filtersKey);sessionStorage.setItem(this.filtersKey,t||JSON.stringify(this.filtersSnapshot))}sessionStorage.setItem(this.infiniteScrollStateKey,JSON.stringify(s));let i=salla.config.get("page.id");const e=Object.keys(this.specialPagesWithoutIds).find((t=>salla.url.is_page(t)));e?i=this.specialPagesWithoutIds[e]:null!==i&&(i=String(i)),sessionStorage.setItem(this.prevCategoryIdKey,i)}removeScrollRestorationSession(){this.isFilterable()||sessionStorage.removeItem(this.filtersKey),sessionStorage.removeItem(this.infiniteScrollStateKey),sessionStorage.removeItem(this.lastViewedProductKey),sessionStorage.removeItem(this.prevCategoryIdKey)}loadStoredScrollState(){const t=sessionStorage.getItem(this.infiniteScrollStateKey),s=sessionStorage.getItem(this.filtersKey),i=sessionStorage.getItem(this.prevCategoryIdKey),e=this.specialPagesWithoutIds[salla.config.get("page.slug")]||null,a=salla.config.get("page.id"),o=salla.url.is_page("index"),h=salla.url.is_page("product.single"),r=e?i!==e:i!==String(a);if(i&&r&&!o&&!h||o&&!this.hasInfiniteScroll)return this.removeScrollRestorationSession(),this.switchToNormalBehavior=!0,!1;if(h)return this.switchToNormalBehavior=!0,!1;if(t)try{const{pageIndex:i,nextPage:e,currentPageData:a}=JSON.parse(t);if("undefined"!==s){const t=JSON.parse(s);salla.event.emit("filters::fetched",{filters:t})}this.page=i,this.nextPage=e;for(let t=0;t<a.length;t++)this.wrapper.append(this.getItemHTML(a?.[t]));return!0}catch(t){console.error("Failed to load stored scroll state:",t),this.removeScrollRestorationSession()}return!1}getSource(){return r.getProductsSource(this.source)}getSourceValue(){return this.currentCategoryIdFilter?this.currentCategoryIdFilter:r.getProductsSourceValue(this.source,this.sourceValue)}appendDataLayer(t){"object"==typeof dataLayer&&Array.isArray(dataLayer)&&dataLayer.push({event:"impressions",ecommerce:{currencyCode:salla.config.currency().code,impressions:t.map(((t,s)=>({id:t.id,name:t.name,price:t.price,brand:t.brand?.name||"",quantity:t.quantity,categories:[{name:t.category?.name||salla.config.get("page.title"),id:salla.config.get("page.id")}],category:t.category?.name||salla.config.get("page.title"),position:s+1})))}})}initiateInfiniteScroll(){if(!this.hasInfiniteScroll)return;const t=this.autoload&&this.includes&&this.includes.length>0;this.infiniteScroll=salla.infiniteScroll.initiate(this.wrapper,this.wrapper,{path:()=>this.nextPage,history:!1,nextPage:this.nextPage,scrollThreshold:!t&&!!this.autoload&&100,loadOnScroll:!t&&this.autoload},!0),this.infiniteScroll.pageIndex=this.page,this.infiniteScroll?.on("request",(()=>{this.loading(!0,!this.autoload)})),t&&window.addEventListener("scroll",this.boundHandleScroll),this.infiniteScroll?.on("load",(async t=>{if(!this.isProcessing){this.isProcessing=!0;try{if(!t.data?.length&&2===this.infiniteScroll.pageIndex)return this.showPlaceholder=!0,salla.infiniteScroll.destroy(this.infiniteScroll),this.loading(!1),void(this.placeholderLoader&&this.placeholderLoader.remove());this.includes&&await this.injectAndProcessData(t);const s=this.handleResponse(t);this.infiniteScroll.appendItems(s),2===this.infiniteScroll.pageIndex&&(!this.autoload&&this.nextPage&&(this.loadMoreWrapper.style.display="block"),this.animateItems())}catch(t){console.error("Error during load:",t)}finally{this.isProcessing=!1}}})),this.infiniteScroll?.on("error",(()=>{console.log("Error occurred during request"),this.status.querySelector(".s-infinite-scroll-error").classList.remove("s-hidden"),this.placeholderLoader&&this.placeholderLoader.remove(),this.loading(!1),this.isProcessing=!1})),salla.onReady((()=>{sessionStorage.getItem(this.infiniteScrollStateKey)||this.manualLoadNextPage()}))}handleScroll(){this.isProcessing||this.scrollTimeout||(this.scrollTimeout=setTimeout((()=>{this.scrollTimeout=null,requestAnimationFrame((()=>{const t=this.wrapper.getBoundingClientRect(),s=window.innerHeight;t.bottom-s<=200&&!this.isProcessing&&this.nextPage&&this.manualLoadNextPage()}))}),200))}manualLoadNextPage(){this.nextPage&&this.infiniteScroll.loadNextPage()}async injectAndProcessData(t){try{await r.injectExtraFieldsToResponse(t)}catch(t){console.error("Error injecting data:",t)}}getInitialData(){return this.loading(),salla.product.api.fetch({source:r.getApiSource(this.getSource()),source_value:this.getSourceValue(),limit:this.limit}).then((async t=>t.data.length?(await r.injectExtraFieldsToResponse(t),this.firstPageResponse?void this.handleResponse(t).forEach((t=>this.wrapper.append(t))):(this.firstPageResponse=t,void(this.nextPage=t.cursor?t.cursor.next:this.nextPage))):(this.showPlaceholder=!0,this.placeholderLoader&&this.placeholderLoader.remove(),void this.loading(!1))))}async loadMore(){this.infiniteScroll?.loadNextPage()}componentWillLoad(){return salla.onReady().then((()=>{this.hasCustomComponent=!!customElements.get(this.productCardComponent),this.sourceValueIsValid=!(!this.getSourceValue()&&!this.isSourceWithoutValue()),this.hasInfiniteScroll=!["json","selected","related","landing-page","recently"].includes(this.getSource())&&!this.limit;let t=new URLSearchParams(window.location.search);try{this.sortBy=this.sortBy||t.get("sort")||t.get("by"),this.parsedFilters=r.extractFiltersFromUrl(t),this.parsedFilters&&this.parsedFilters.category_id&&(this.currentCategoryIdFilter=[this.parsedFilters.category_id])}catch(t){salla.logger.warn("failed to get filters from url",t.message)}if(this.buildNextPageUrl(),this.isReady=!0,!sessionStorage.getItem(this.infiniteScrollStateKey))if(this.sourceValueIsValid){if(!this.hasInfiniteScroll){if("json"===this.getSource())return this.getSourceValue().length?void setTimeout((()=>{this.getSourceValue().map((t=>this.wrapper.append(this.getItemHTML(t))))})):void(this.showPlaceholder=!0);if("selected"!==this.getSource()||this.getSourceValue().length)return this.getInitialData();this.showPlaceholder=!0}}else salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`)}))}async componentDidLoad(){this.hasInfiniteScroll&&this.init(),await Salla.hooks.registerComponent("salla-products-list",this),this.loadStoredScrollState()?(this.autoload?!this.nextPage&&this.loading(!1):this.nextPage?this.loadMoreWrapper&&(this.loadMoreWrapper.style.display="block"):(this.loadMoreWrapper&&(this.loadMoreWrapper.style.display="none"),this.status.querySelector(".s-infinite-scroll-last").classList.remove("s-hidden")),this.scrollToLastViewedProduct()):!this.firstPageResponse&&this.switchToNormalBehavior?this.getInitialData().then((()=>{this.firstPageResponse?(this.handleResponse(this.firstPageResponse,!1).forEach((t=>{this.wrapper.append(t)})),setTimeout((()=>{if(!this.autoload&&this.nextPage&&1==this.infiniteScroll.pageIndex){const t=this.host.querySelector(".s-infinite-scroll-wrapper");t&&(t.style.display="block")}}))):console.error("No response received after getInitialData.")})).catch((t=>{console.error("Error during initial data fetch:",t)})):this.firstPageResponse&&this.handleResponse(this.firstPageResponse,!1).forEach((t=>this.wrapper.append(t)))}canRender(){return this.sourceValueIsValid&&this.isReady}render(){return this.canRender()?this.showPlaceholder?i("div",{class:"s-products-list-placeholder"},i("span",{innerHTML:h}),i("p",null,this.placeholderText)):i(e,{class:"s-products-list"},i("div",{class:{"s-products-list-wrapper":!0,"s-products-list-horizontal-cards":this.horizontalCards&&!this.filtersResults,"s-products-list-vertical-cards":!this.horizontalCards&&!this.rowCards&&!this.filtersResults,"s-products-list-row-cards":this.rowCards,"s-products-list-compact-cards":this.compactCards,"s-products-list-filters-results":this.filtersResults},ref:t=>this.wrapper=t}),i("div",{class:"s-infinite-scroll-status",ref:t=>this.status=t},i("p",{class:"s-infinite-scroll-last infinite-scroll-last s-hidden"},this.endOfText),i("p",{class:"s-infinite-scroll-error infinite-scroll-error s-hidden"},this.failedLoadMore)),this.autoload&&i("div",{class:"s-products-list-loading-wrapper",style:{display:"none"},ref:t=>this.loader=t},i("span",{class:"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader"})),this.hasInfiniteScroll&&this.nextPage&&!this.autoload?i("div",{class:"s-infinite-scroll-wrapper",style:{display:"none"},ref:t=>this.loadMoreWrapper=t},i("button",{onClick:()=>this.loadMore(),class:"s-infinite-scroll-btn s-button-btn s-button-primary"},i("span",{class:"s-button-text s-infinite-scroll-btn-text"},this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more")),i("span",{class:"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader",ref:t=>this.btnLoader=t,style:{display:"none"}}))):""):""}init(){this.initiateInfiniteScroll(),this.loading()}handleResponse(t,s=!0){if(!t)return[];let i=this.getSource(),e="";if(1===t.cursor?.current){e=r.getPageTitleForSource(i);try{if("search"===this.getSource())e=salla.lang.get("common.elements.search_about",{word:this.getSourceValue()});else if(!e){let s=this.parsedFilters.category_id||this.getSourceValue()[0];e=t.filters?.find((t=>"category_id"===t.key))?.values?.find((t=>t.key===s))?.value??"",this.filtersSnapshot=t.filters}e+=(e?" - ":"")+salla.lang.choice("blocks.header.products_count",t.data?.length),15===t.data.length&&(e=e.replace(t.data.length,salla.lang.get("common.elements.more_than")+" "+t.data.length)),t.title=e}catch(t){salla.logger.error("Error::falid to handle response",t)}r.generateProductSchema(t.data)}this.appendDataLayer(t.data),t.nextPage=this.nextPage,t.source=this.getSource(),t.sourceValue=this.getSourceValue(),salla.event.emit("salla-products-list::products.fetched",t),this.productsFetched.emit(t),t.filters&&this.isFilterable()?(this.filtersResults=!0,this.filtersSnapshot=JSON.parse(JSON.stringify(t.filters)),salla.event.emit("filters::fetched",{filters:t.filters})):this.isFilterable()&&salla.event.emit("filters::hidden"),s&&(this.nextPage=t.cursor?t.cursor.next:this.nextPage),this.loading(!1),this.placeholderLoader&&this.placeholderLoader.remove(),this.hasInfiniteScroll&&!this.nextPage&&(this.infiniteScroll.option({scrollThreshold:!1,loadOnScroll:!1}),this.status.querySelector(".s-infinite-scroll-last").classList.remove("s-hidden"));const a=[];for(let s=0;s<t.data.length;s++)a.push(this.getItemHTML(t.data?.[s]));return a}get host(){return a(this)}};l.style="";export{l as salla_products_list}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,c as e,h as s,H as i}from"./p-CV1rqKQz.js";import{a}from"./p-BedNk7k1.js";const l=class{constructor(s){t(this,s),this.changed=e(this,"changed"),this.min=0,this.max=1e4,this.moreThanLabel="أكثر من",this.lessThanLabel="أقل من",this.toLabel="الى",this.fromLabel="من",this.typing=!1,this.isMin=!1,this.isRTL=salla.config.get("theme.is_rtl",!0),this.filterValues=[]}connectedCallback(){if(this.filtersData&&this.filtersData?.price&&(this.minPrice=this.filtersData.price.min,this.maxPrice=this.filtersData.price.max),salla.lang.onLoaded((()=>{this.moreThanLabel=salla.lang.getWithDefault("common.elements.more_than",this.moreThanLabel),this.lessThanLabel=salla.lang.getWithDefault("common.elements.less_than",this.lessThanLabel),this.toLabel=salla.lang.getWithDefault("common.elements.to",this.toLabel),this.fromLabel=salla.lang.getWithDefault("common.elements.from",this.fromLabel)})),1==this.option.values.length)return;if(this.option.values.length<=5)return void(this.filterValues=this.option.values);const t=Math.ceil(this.option.values.length/5);for(let e=0;e<this.option.values.length;e+=t)this.filterValues.push(this.option.values.slice(e,e+t).reduce(((t,e)=>(t.to=e.to,t.count+=e.count,t))))}async reset(){this.minInput.value=null,this.maxInput.value=null,this.minPrice=null,this.maxPrice=null}getPriceLabel(t){return isNaN(t.from)||t.from<1?`${this.lessThanLabel} ${salla.money(t.to)}`:isNaN(t.to)||t.to<1?`${this.moreThanLabel} ${salla.money(t.from)}`:`${salla.money(t.from)} ${this.toLabel} ${salla.money(t.to)}`}minInputValidation(t){t&&(t>this.max||this.maxPrice&&t>this.maxPrice)||(t<this.min?this.minPrice=this.min:t&&(this.minPrice=t))}maxInputValidation(t){t&&(t<this.min||this.minPrice&&t<this.minPrice)||t>this.max&&(this.maxPrice=this.max)}async changedEventHandler(t){salla.helpers.inputDigitsOnly(this.minInput),salla.helpers.inputDigitsOnly(this.maxInput);const e=this.minPrice?1*+this.minPrice:null,s=this.maxPrice?1*+this.maxPrice:null;this.maxPrice||(this.maxPrice=""),this.isMin?this.minInputValidation(e):(this.minPrice||(this.minPrice=0),this.maxInputValidation(s)),this.isReady&&this.changed.emit({event:t,option:this.option,value:{max:this.maxPrice,min:this.minPrice}})}handleMinMaxPrice(t,e){this.minPrice=e.from,this.maxPrice="*"!==e.to?e.to:"",this.changedEventHandler(t)}isChecked(t){return!(!this.minPrice&&!this.maxPrice)&&(((t.from<1||"*"==t.from)&&0==this.minPrice||t.from==this.minPrice)&&("*"==t.to||!t.to||t.to==this.maxPrice))}handleMinPrice(t){this.isMin=!0;const e=t.target.value;this.minPrice=""===e?0:e}handleMaxPrice(t){this.isMin=!1;const e=t.target.value;this.maxPrice=void 0===e?"":e}render(){return s(i,{key:"38e861565eba32f7905401f18c4ca56af7a12c99"},this.filterValues.map(((t,e)=>s("label",{class:"s-filters-label",htmlFor:`${this.option.key}-${e}`,key:e},s("input",{id:`${this.option.key}-${e}`,name:"price",type:"radio",checked:this.isChecked(t),class:"s-filters-radio",onChange:e=>this.handleMinMaxPrice(e,t)}),s("span",{innerHTML:this.getPriceLabel(t)})))),s("div",{key:"0d36c5e34fa0aeffc82cb6d43069d568c7f60e27",class:"flex justify-center items-center"},s("div",{key:"92d12aec4ad4cafe4cc234697a2b8da941d79e2f",class:"relative max-w-xl w-full"},s("div",{key:"1cc8f2de52169095a130d386f0670c802508ba35",class:"s-price-range-inputs"},s("div",{key:"509a518a8de8177101805a4c81fd5f7a53007960",class:"s-price-range-relative"},s("div",{key:"b0cf4876758e86e676e850c3d2ac8610536892c0",class:"s-price-range-currency"}," ",salla.config.currency().symbol),s("input",{key:"00b6a1d73249153329b376eaf871d6be830d2d40",type:"number",maxlength:"5",ref:t=>this.minInput=t,onBlur:t=>this.handleMinPrice(t),value:this.minPrice,placeholder:this.fromLabel,class:"s-price-range-number-input"})),s("div",{key:"5517e97d2cb19bf2791c190b7803bc415394a3f6",class:"s-price-range-gray-text"}," -"),s("div",{key:"182a0cfae1c328e60116e6537872a7dc5ffab563",class:"s-price-range-relative"},s("div",{key:"6f936938df035b95288a683eeceb4f7962b1e0ac",class:"s-price-range-currency"}," ",salla.config.currency().symbol),s("input",{key:"5e143013b6ad7537a042c6801f581bf0cfa62b94",type:"number",maxlength:"5",ref:t=>this.maxInput=t,onBlur:t=>this.handleMaxPrice(t),value:this.maxPrice,placeholder:this.toLabel,class:"s-price-range-number-input","aria-describedby":"price-currency"})),s("salla-button",{key:"5ac9d08136618280814266d1108c042b1aac6822",color:"gray",shape:"icon",size:"small",fill:"outline",onClick:t=>this.changedEventHandler(t)},s("span",{key:"03795b3bf5881e5a39f8272c867bdbad049d203d",innerHTML:this.isRTL?a:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>arrow-right</title>\n<path d="M29.217 15.465c-0.019-0.044-0.056-0.077-0.080-0.119-0.067-0.116-0.139-0.227-0.236-0.317-0.011-0.009-0.013-0.024-0.024-0.033l-10.667-9.333c-0.553-0.484-1.396-0.429-1.881 0.125-0.484 0.555-0.428 1.396 0.127 1.881l7.996 6.997h-20.452c-0.737 0-1.333 0.597-1.333 1.333s0.596 1.333 1.333 1.333h20.452l-7.996 6.997c-0.555 0.485-0.611 1.327-0.127 1.881 0.264 0.3 0.633 0.455 1.004 0.455 0.312 0 0.625-0.109 0.877-0.331l10.667-9.333c0.011-0.009 0.015-0.024 0.024-0.033 0.097-0.091 0.169-0.201 0.236-0.317 0.024-0.041 0.060-0.075 0.080-0.119 0.073-0.163 0.116-0.343 0.116-0.533s-0.043-0.371-0.116-0.535z"></path>\n</svg>\n'}))))))}componentDidLoad(){this.isReady=!0}};l.style=":host{display:block}.rtl .rtl-range-slider,[dir=rtl] .rtl-range-slider{transform:rotateY(180deg)}.rtl .rtl-range-numbers,[dir=rtl] .rtl-range-numbers{flex-direction:row-reverse}.rtl .form-select,.rtl select,[dir=rtl] .form-select,[dir=rtl] select{background-position:left 0.5rem center;padding-right:12px}.rtl .menu-divide li:not(:last-child):after,[dir=rtl] .menu-divide li:not(:last-child):after{left:0;right:auto}input[type=range]::-webkit-slider-thumb{pointer-events:all;width:24px;height:24px;-webkit-appearance:none}[type=checkbox]:checked{background-size:80%}";export{l as salla_price_range}
4
+ import{r as t,c as e,h as s,H as i}from"./p-ea1dIZhh.js";import{a}from"./p-BedNk7k1.js";const l=class{constructor(s){t(this,s),this.changed=e(this,"changed"),this.min=0,this.max=1e4,this.moreThanLabel="أكثر من",this.lessThanLabel="أقل من",this.toLabel="الى",this.fromLabel="من",this.typing=!1,this.isMin=!1,this.isRTL=salla.config.get("theme.is_rtl",!0),this.filterValues=[]}connectedCallback(){if(this.filtersData&&this.filtersData?.price&&(this.minPrice=this.filtersData.price.min,this.maxPrice=this.filtersData.price.max),salla.lang.onLoaded((()=>{this.moreThanLabel=salla.lang.getWithDefault("common.elements.more_than",this.moreThanLabel),this.lessThanLabel=salla.lang.getWithDefault("common.elements.less_than",this.lessThanLabel),this.toLabel=salla.lang.getWithDefault("common.elements.to",this.toLabel),this.fromLabel=salla.lang.getWithDefault("common.elements.from",this.fromLabel)})),1==this.option.values.length)return;if(this.option.values.length<=5)return void(this.filterValues=this.option.values);const t=Math.ceil(this.option.values.length/5);for(let e=0;e<this.option.values.length;e+=t)this.filterValues.push(this.option.values.slice(e,e+t).reduce(((t,e)=>(t.to=e.to,t.count+=e.count,t))))}async reset(){this.minInput.value=null,this.maxInput.value=null,this.minPrice=null,this.maxPrice=null}getPriceLabel(t){return isNaN(t.from)||t.from<1?`${this.lessThanLabel} ${salla.money(t.to)}`:isNaN(t.to)||t.to<1?`${this.moreThanLabel} ${salla.money(t.from)}`:`${salla.money(t.from)} ${this.toLabel} ${salla.money(t.to)}`}minInputValidation(t){t&&(t>this.max||this.maxPrice&&t>this.maxPrice)||(t<this.min?this.minPrice=this.min:t&&(this.minPrice=t))}maxInputValidation(t){t&&(t<this.min||this.minPrice&&t<this.minPrice)||t>this.max&&(this.maxPrice=this.max)}async changedEventHandler(t){salla.helpers.inputDigitsOnly(this.minInput),salla.helpers.inputDigitsOnly(this.maxInput);const e=this.minPrice?1*+this.minPrice:null,s=this.maxPrice?1*+this.maxPrice:null;this.maxPrice||(this.maxPrice=""),this.isMin?this.minInputValidation(e):(this.minPrice||(this.minPrice=0),this.maxInputValidation(s)),this.isReady&&this.changed.emit({event:t,option:this.option,value:{max:this.maxPrice,min:this.minPrice}})}handleMinMaxPrice(t,e){this.minPrice=e.from,this.maxPrice="*"!==e.to?e.to:"",this.changedEventHandler(t)}isChecked(t){return!(!this.minPrice&&!this.maxPrice)&&(((t.from<1||"*"==t.from)&&0==this.minPrice||t.from==this.minPrice)&&("*"==t.to||!t.to||t.to==this.maxPrice))}handleMinPrice(t){this.isMin=!0;const e=t.target.value;this.minPrice=""===e?0:e}handleMaxPrice(t){this.isMin=!1;const e=t.target.value;this.maxPrice=void 0===e?"":e}render(){return s(i,{key:"38e861565eba32f7905401f18c4ca56af7a12c99"},this.filterValues.map(((t,e)=>s("label",{class:"s-filters-label",htmlFor:`${this.option.key}-${e}`,key:e},s("input",{id:`${this.option.key}-${e}`,name:"price",type:"radio",checked:this.isChecked(t),class:"s-filters-radio",onChange:e=>this.handleMinMaxPrice(e,t)}),s("span",{innerHTML:this.getPriceLabel(t)})))),s("div",{key:"0d36c5e34fa0aeffc82cb6d43069d568c7f60e27",class:"flex justify-center items-center"},s("div",{key:"92d12aec4ad4cafe4cc234697a2b8da941d79e2f",class:"relative max-w-xl w-full"},s("div",{key:"1cc8f2de52169095a130d386f0670c802508ba35",class:"s-price-range-inputs"},s("div",{key:"509a518a8de8177101805a4c81fd5f7a53007960",class:"s-price-range-relative"},s("div",{key:"b0cf4876758e86e676e850c3d2ac8610536892c0",class:"s-price-range-currency"}," ",salla.config.currency().symbol),s("input",{key:"00b6a1d73249153329b376eaf871d6be830d2d40",type:"number",maxlength:"5",ref:t=>this.minInput=t,onBlur:t=>this.handleMinPrice(t),value:this.minPrice,placeholder:this.fromLabel,class:"s-price-range-number-input"})),s("div",{key:"5517e97d2cb19bf2791c190b7803bc415394a3f6",class:"s-price-range-gray-text"}," -"),s("div",{key:"182a0cfae1c328e60116e6537872a7dc5ffab563",class:"s-price-range-relative"},s("div",{key:"6f936938df035b95288a683eeceb4f7962b1e0ac",class:"s-price-range-currency"}," ",salla.config.currency().symbol),s("input",{key:"5e143013b6ad7537a042c6801f581bf0cfa62b94",type:"number",maxlength:"5",ref:t=>this.maxInput=t,onBlur:t=>this.handleMaxPrice(t),value:this.maxPrice,placeholder:this.toLabel,class:"s-price-range-number-input","aria-describedby":"price-currency"})),s("salla-button",{key:"5ac9d08136618280814266d1108c042b1aac6822",color:"gray",shape:"icon",size:"small",fill:"outline",onClick:t=>this.changedEventHandler(t)},s("span",{key:"03795b3bf5881e5a39f8272c867bdbad049d203d",innerHTML:this.isRTL?a:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>arrow-right</title>\n<path d="M29.217 15.465c-0.019-0.044-0.056-0.077-0.080-0.119-0.067-0.116-0.139-0.227-0.236-0.317-0.011-0.009-0.013-0.024-0.024-0.033l-10.667-9.333c-0.553-0.484-1.396-0.429-1.881 0.125-0.484 0.555-0.428 1.396 0.127 1.881l7.996 6.997h-20.452c-0.737 0-1.333 0.597-1.333 1.333s0.596 1.333 1.333 1.333h20.452l-7.996 6.997c-0.555 0.485-0.611 1.327-0.127 1.881 0.264 0.3 0.633 0.455 1.004 0.455 0.312 0 0.625-0.109 0.877-0.331l10.667-9.333c0.011-0.009 0.015-0.024 0.024-0.033 0.097-0.091 0.169-0.201 0.236-0.317 0.024-0.041 0.060-0.075 0.080-0.119 0.073-0.163 0.116-0.343 0.116-0.533s-0.043-0.371-0.116-0.535z"></path>\n</svg>\n'}))))))}componentDidLoad(){this.isReady=!0}};l.style=":host{display:block}.rtl .rtl-range-slider,[dir=rtl] .rtl-range-slider{transform:rotateY(180deg)}.rtl .rtl-range-numbers,[dir=rtl] .rtl-range-numbers{flex-direction:row-reverse}.rtl .form-select,.rtl select,[dir=rtl] .form-select,[dir=rtl] select{background-position:left 0.5rem center;padding-right:12px}.rtl .menu-divide li:not(:last-child):after,[dir=rtl] .menu-divide li:not(:last-child):after{left:0;right:auto}input[type=range]::-webkit-slider-thumb{pointer-events:all;width:24px;height:24px;-webkit-appearance:none}[type=checkbox]:checked{background-size:80%}";export{l as salla_price_range}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as t,H as e,a as l}from"./p-CV1rqKQz.js";import{A as i}from"./p-DCZbpt2a.js";import{B as a}from"./p-D3mWkc-3.js";import{P as o}from"./p-DY4LZmNP.js";import{W as n}from"./p-ZT7ehBBk.js";import{C as r}from"./p-BsLF_HK7.js";import{S as h}from"./p-D4oPi1Ov.js";import{l as c}from"./p-BChI23pG.js";var m='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>user-circle</title>\n<path d="M16 22.964c-4.525 0-8.447 1.713-9.993 4.365-0.371 0.636-0.156 1.452 0.48 1.823s1.453 0.156 1.823-0.48c0.855-1.465 3.624-3.041 7.689-3.041s6.835 1.576 7.689 3.041c0.249 0.424 0.696 0.661 1.155 0.661 0.228 0 0.459-0.059 0.669-0.181 0.637-0.371 0.852-1.187 0.48-1.823-1.545-2.652-5.467-4.365-9.992-4.365zM22.667 13.631c0-3.676-2.991-6.667-6.667-6.667s-6.667 2.991-6.667 6.667 2.991 6.667 6.667 6.667 6.667-2.992 6.667-6.667zM12 13.631c0-2.205 1.795-4 4-4s4 1.795 4 4-1.795 4-4 4-4-1.795-4-4zM16 0.297c-8.823 0-16 7.177-16 16 0 2.941 0.821 5.831 2.373 8.357 0.252 0.411 0.689 0.636 1.137 0.636 0.239 0 0.479-0.064 0.696-0.197 0.628-0.385 0.824-1.207 0.439-1.833-1.295-2.108-1.979-4.516-1.979-6.963 0-7.352 5.981-13.333 13.333-13.333s13.333 5.981 13.333 13.333c0 2.448-0.684 4.856-1.979 6.961-0.385 0.628-0.189 1.448 0.437 1.835 0.627 0.384 1.448 0.189 1.835-0.437 1.553-2.527 2.373-5.416 2.373-8.359 0-8.823-7.177-16-16-16z"></path>\n</svg>\n';const u=class{constructor(t){s(this,t),this.accountLoading=!1,this.opened=!1,this.notifications=salla.lang.get("common.titles.notifications"),this.orders=salla.lang.get("common.titles.orders"),this.pending_orders=salla.lang.get("common.titles.pending_orders"),this.wishlist=salla.lang.get("common.titles.wishlist"),this.profile=salla.lang.get("common.titles.profile"),this.rating=salla.lang.get("common.titles.rating"),this.wallet=salla.lang.get("common.titles.wallet"),this.settings=salla.lang.get("common.titles.settings"),this.loyalty_program=salla.lang.get("pages.loyalty_program.loyalty_points"),this.logout=salla.lang.get("blocks.header.logout"),this.hello=salla.lang.get("pages.checkout.hello"),this.first_name=salla.storage.get("user.first_name")||"",this.last_name=salla.storage.get("user.last_name")||"",this.avatar=salla.storage.get("user.avatar")||salla.url.cdn("images/avatar.png",40,40),this.badges={notifications:salla.helpers.number(salla.storage.get("user.notifications")||0),pending_orders:salla.helpers.number(salla.storage.get("user.pending_orders")||0)},this.sallaAccountEnabled=!1,this.hasBadges=Number(salla.storage.get("user.pending_orders"))>0||Number(salla.storage.get("user.notifications"))>0,this.inline=!1,this.avatarOnly=!1,this.showHeader=!1,this.relativeDropdown=!1,this.autoMount=!1,this.onClickOutside=()=>{this.opened=!1},this.OrderUpdate=0,this.items={notifications:a,orders:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>box-bankers</title>\n<path d="M28 1.333h-24c-2.205 0-4 1.795-4 4v5.333c0 0.736 0.597 1.333 1.333 1.333v14.667c0 2.205 1.795 4 4 4h21.333c2.205 0 4-1.795 4-4v-14.667c0.736 0 1.333-0.597 1.333-1.333v-5.333c0-2.205-1.795-4-4-4zM28 26.667c0 0.735-0.599 1.333-1.333 1.333h-21.333c-0.735 0-1.333-0.599-1.333-1.333v-14.667h5.333v2.667c0 1.471 1.196 2.667 2.667 2.667h8c1.471 0 2.667-1.196 2.667-2.667v-2.667h5.333zM12 14.667v-2.667h8v2.667zM29.333 9.333h-26.667v-4c0-0.735 0.599-1.333 1.333-1.333h24c0.735 0 1.333 0.599 1.333 1.333z"></path>\n</svg>\n',pending_orders:o,wishlist:n,wallet:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>wallet</title>\n<path d="M28 6.667h-24c-0.736 0-1.333-0.597-1.333-1.333s0.597-1.333 1.333-1.333h24c0.737 0 1.333-0.596 1.333-1.333s-0.596-1.333-1.333-1.333h-24c-2.204 0-3.999 1.793-4 3.997v18.669c0 3.676 2.991 6.667 6.667 6.667h21.333c2.205 0 4-1.795 4-4v-16c0-2.205-1.795-4-4-4zM29.333 26.667c0 0.736-0.597 1.333-1.333 1.333h-21.333c-2.205 0-4-1.795-4-4v-14.895c0.416 0.147 0.865 0.228 1.333 0.228h24c0.736 0 1.333 0.597 1.333 1.333zM22.667 14.667c-2.205 0-4 1.795-4 4s1.795 4 4 4 4-1.795 4-4-1.795-4-4-4zM22.667 20c-0.736 0-1.333-0.597-1.333-1.333s0.597-1.333 1.333-1.333 1.333 0.597 1.333 1.333-0.597 1.333-1.333 1.333z"></path>\n</svg>\n',loyalty_program:c,profile:m}}async componentWillLoad(){await salla.onReady(),await salla.lang.onLoaded(),this.loadTranslations(),this.initiate(),Salla.event.on("api::token.injected",(s=>this.profileUrl=this.buildProfileUrl(s))),this.sallaAccountEnabled=Salla.config.get("store.features")?.includes("salla-account"),this.items=this.sallaAccountEnabled?{...this.items,settings:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>settings</title>\n<path d="M29.717 19.037l-1.817-1.499c0.067-0.512 0.1-1.028 0.1-1.539s-0.033-1.027-0.1-1.54l1.817-1.499c1.177-0.969 1.479-2.633 0.716-3.956l-1.159-2.009c-0.761-1.324-2.349-1.895-3.784-1.359l-2.212 0.829c-0.817-0.627-1.704-1.139-2.649-1.535l-0.388-2.332c-0.251-1.507-1.54-2.6-3.067-2.6h-2.319c-1.525 0-2.815 1.093-3.065 2.6l-0.388 2.332c-0.945 0.396-1.833 0.909-2.649 1.535l-2.212-0.829c-1.428-0.533-3.021 0.036-3.783 1.359l-1.16 2.011c-0.763 1.323-0.46 2.985 0.716 3.955l1.817 1.499c-0.067 0.513-0.1 1.029-0.1 1.54s0.033 1.027 0.1 1.539l-1.819 1.5c-1.176 0.971-1.476 2.635-0.715 3.955l1.159 2.011c0.763 1.324 2.356 1.899 3.784 1.36l2.212-0.831c0.816 0.625 1.703 1.139 2.649 1.535l0.388 2.332c0.251 1.507 1.54 2.6 3.067 2.6h2.319c1.527 0 2.816-1.093 3.065-2.6l0.389-2.332c0.947-0.396 1.833-0.909 2.649-1.535l2.212 0.831c1.432 0.539 3.023-0.035 3.783-1.36l1.16-2.011c0.76-1.32 0.459-2.984-0.717-3.956zM28.123 21.663l-1.16 2.011c-0.108 0.188-0.336 0.267-0.536 0.193l-2.931-1.1c-0.459-0.173-0.979-0.079-1.349 0.248-0.923 0.811-1.979 1.423-3.139 1.819-0.464 0.157-0.804 0.559-0.885 1.043l-0.515 3.087c-0.033 0.215-0.216 0.371-0.433 0.371h-2.319c-0.217 0-0.4-0.156-0.436-0.371l-0.513-3.087c-0.080-0.484-0.42-0.884-0.885-1.043-1.16-0.396-2.216-1.008-3.139-1.819-0.248-0.217-0.561-0.332-0.88-0.332-0.157 0-0.316 0.028-0.469 0.084l-2.931 1.1c-0.199 0.079-0.428-0.004-0.537-0.193l-1.159-2.011c-0.109-0.191-0.067-0.428 0.101-0.568l2.409-1.985c0.379-0.312 0.555-0.807 0.46-1.288-0.119-0.605-0.179-1.219-0.179-1.821 0-0.604 0.060-1.217 0.181-1.823 0.095-0.481-0.081-0.976-0.46-1.288l-2.409-1.985c-0.168-0.139-0.211-0.376-0.101-0.567l1.16-2.011c0.107-0.188 0.332-0.268 0.536-0.193l2.931 1.1c0.459 0.172 0.979 0.079 1.348-0.247 0.924-0.812 1.98-1.424 3.139-1.817 0.465-0.159 0.805-0.559 0.885-1.044l0.513-3.088c0.036-0.215 0.219-0.371 0.436-0.371h2.319c0.217 0 0.4 0.156 0.436 0.371l0.515 3.088c0.081 0.484 0.42 0.885 0.885 1.044 1.157 0.393 2.213 1.005 3.139 1.817 0.371 0.325 0.889 0.42 1.349 0.247l2.929-1.099c0.203-0.076 0.428 0.005 0.537 0.193l1.159 2.009c0.109 0.191 0.067 0.428-0.101 0.567l-2.409 1.985c-0.379 0.312-0.555 0.807-0.46 1.288 0.119 0.605 0.179 1.219 0.179 1.823 0 0.603-0.060 1.216-0.181 1.821-0.095 0.48 0.081 0.975 0.46 1.288l2.408 1.984c0.169 0.141 0.212 0.379 0.103 0.569zM16.016 10.667c-2.941 0-5.333 2.392-5.333 5.333s2.392 5.333 5.333 5.333 5.333-2.392 5.333-5.333-2.392-5.333-5.333-5.333zM16.016 18.667c-1.471 0-2.667-1.196-2.667-2.667s1.196-2.667 2.667-2.667 2.667 1.196 2.667 2.667-1.196 2.667-2.667 2.667z"></path>\n</svg>\n'}:this.items,this.host.hasAttribute("with-rating")&&(this.items.rating=h),this.items.logout='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>send-out</title>\n<path d="M16 26.667h-9.333c-0.736 0-1.333-0.597-1.333-1.333v-18.667c0-0.736 0.597-1.333 1.333-1.333h9.333c0.737 0 1.333-0.596 1.333-1.333s-0.596-1.333-1.333-1.333h-9.333c-2.205 0-4 1.795-4 4v18.667c0 2.205 1.795 4 4 4h9.333c0.737 0 1.333-0.596 1.333-1.333s-0.596-1.333-1.333-1.333zM29.231 15.491c-0.068-0.164-0.167-0.312-0.289-0.436l-5.332-5.332c-0.521-0.521-1.364-0.521-1.885 0s-0.521 1.364 0 1.885l3.057 3.059h-12.781c-0.737 0-1.333 0.596-1.333 1.333s0.596 1.333 1.333 1.333h12.781l-3.057 3.057c-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391l5.332-5.332c0.124-0.123 0.221-0.271 0.289-0.435 0.135-0.325 0.135-0.693 0-1.019z"></path>\n</svg>\n';let s=Salla.storage.get("token");s||(s=""),this.profileUrl=this.buildProfileUrl(s);const t=this.host.querySelector('[slot="trigger"]');this.triggerSlot='<div class="s-user-menu-trigger"><div class="s-user-menu-avatar-wrap"><img class="s-user-menu-trigger-avatar" src="{avatar}" alt="{first_name}{last_name}" /></div><div class="s-user-menu-trigger-content"><span class="s-user-menu-trigger-hello">{hello}</span><p class="s-user-menu-trigger-name">{first_name} {last_name}</p></div> <i class="s-user-menu-trigger-icon">{icon}</i></div>',t&&(this.triggerSlot=t.innerHTML,t.innerHTML=this.replaceParams(t.innerHTML))}loadTranslations(){this.notifications=Salla.lang.get("common.titles.notifications"),this.orders=Salla.lang.get("common.titles.orders"),this.pending_orders=Salla.lang.get("common.titles.pending_orders"),this.wishlist=Salla.lang.get("common.titles.wishlist"),this.profile=Salla.lang.get("common.titles.profile"),this.hello=Salla.lang.get("pages.checkout.hello"),this.rating=Salla.lang.get("common.titles.rating"),this.wallet=Salla.lang.get("common.titles.wallet"),this.settings=Salla.lang.get("common.titles.settings"),this.loyalty_program=Salla.lang.get("pages.loyalty_program.loyalty_points"),this.logout=Salla.lang.get("blocks.header.logout")}initiate(){return Salla.config.isGuest()?this.autoMountLoginModal():(this.is_loggedIn=!0,!this.inline&&(salla.url.is_page("customer.notifications")||salla.url.is_page("customer.orders.index.pending")||salla.url.is_page("customer.profile")||(Date.now()-(salla.storage.get("user.fetched_at")||0))/1e3/60>30)?this.fetchFreshProfile():void salla.event.on("profile::info.fetched",(s=>{this.updateProfileState(s)})))}autoMountLoginModal(){this.autoMount&&(document.querySelector("salla-login-modal")||Salla.hooks.mount("body:end",document.createElement("salla-login-modal")))}fetchFreshProfile(){salla.api.token?salla.profile.api.info().then((s=>{this.updateProfileState(s)})):salla.log("trying to fetchFreshProfile before injected the token!!")}updateProfileState(s){this.badges={notifications:salla.helpers.number(s.data.notifications||0),pending_orders:salla.helpers.number(s.data.pending_orders||0)},this.hasBadges=Number(s.data.pending_orders)>0||Number(s.data.notifications)>0,this.first_name=s.data.first_name,this.last_name=s.data.last_name,this.avatar=s.data.avatar||salla.url.cdn("images/avatar.png",40,40)}async open(s){this.opened=!this.opened,s.stopPropagation(),this.opened&&window.addEventListener("click",this.onClickOutside)}menuItemClicked(s,t){"logout"===t&&(s.preventDefault(),salla.auth.logout("sall-user-menu"))}replaceParams(s){return s.replace(/\{hello\}/g,this.hello).replace(/\{first_name\}/g,this.first_name).replace(/\{last_name\}/g,this.last_name).replace(/\{avatar\}/g,this.avatar).replace(/\{icon\}/g,i)}getTheHeader(){return t("div",{class:{"s-user-menu-trigger-slot":!0,"s-user-menu-red-dot":this.hasBadges,"s-user-menu-trigger-avatar-only":this.avatarOnly},id:"trigger-slot",onClick:s=>this.open(s),onKeyUp:s=>this.open(s),innerHTML:this.replaceParams(this.triggerSlot)})}getItemAnchorLinkAttrs(s){return"profile"===s&&this.profileUrl&&this.sallaAccountEnabled?{href:this.profileUrl,target:"_blank",rel:"noopener noreferrer"}:{href:Salla.url.get("loyalty_program"===s?"loyalty":s)}}getMenuItem([s,e],l){if(("wallet"!==s||window.can_access_wallet)&&("loyalty_program"!==s||Salla.config.get("store.features").includes("loyalty-system")))return t("li",{class:{"s-user-menu-dropdown-item":!0,"s-user-menu-dropdown-item-logout":l+1===Object.entries(this.items).length}},t("a",{...this.getItemAnchorLinkAttrs(s),class:"s-user-menu-dropdown-item-link",onClick:t=>this.menuItemClicked(t,s)},t("i",{class:"s-user-menu-dropdown-item-prefix",innerHTML:e}),t("span",{class:"s-user-menu-dropdown-item-title"},this[s]),["٠","0",void 0].includes(this.badges[s])?"":t("span",{class:"s-user-menu-dropdown-item-badge"},this.badges[s])))}componentShouldUpdate(){this.opened||window.removeEventListener("click",this.onClickOutside)}render(){return t(e,null,this.is_loggedIn?this.inline?t("ul",{class:"s-user-menu-inline"},Object.entries(this.items).map(((s,t)=>this.getMenuItem(s,t)))):t("div",{class:{"s-user-menu-wrapper":!0,"s-user-menu-relative-dropdown":this.relativeDropdown}},this.getTheHeader(),t("div",{class:{"s-user-menu-toggler":!0,opened:this.opened}},t("div",{class:"s-user-menu-dropdown",onClick:s=>s.stopPropagation(),onKeyUp:s=>s.stopPropagation()},this.showHeader?t("div",{class:"s-user-menu-dropdown-header"},t("img",{src:this.avatar,alt:`${this.first_name} ${this.last_name}`}),t("div",{class:"s-user-menu-dropdown-header-content"},t("span",null,this.hello),t("p",null,this.first_name," ",this.last_name)),t("button",{type:"button",class:"s-user-menu-dropdown-header-close",innerHTML:r,onClick:()=>{this.opened=!1}})):"",t("ul",{class:"s-user-menu-dropdown-list"},Object.entries(this.items).map(((s,t)=>this.getMenuItem(s,t))))))):t("slot",{name:"login-btn"},t("button",{type:"button",class:"s-user-menu-login-btn",onClick:()=>salla.event.dispatch("login::open"),innerHTML:m})))}componentDidLoad(){document.lazyLoadInstance?.update(this.host.querySelectorAll(".lazy"))}buildProfileUrl(s){return`${Salla.config.get("account.url","https://accounts.salla.com")}/${salla.config.get("user.language_code")}/user?store=${Salla.config.get("store.id")}&info=${encodeURIComponent(s)}`}get host(){return l(this)}};u.style="";export{u as salla_user_menu}
4
+ import{r as s,h as t,H as e,a as l}from"./p-ea1dIZhh.js";import{A as i}from"./p-DCZbpt2a.js";import{B as a}from"./p-D3mWkc-3.js";import{P as o}from"./p-DY4LZmNP.js";import{W as n}from"./p-ZT7ehBBk.js";import{C as r}from"./p-BsLF_HK7.js";import{S as h}from"./p-D4oPi1Ov.js";import{l as c}from"./p-BChI23pG.js";var m='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>user-circle</title>\n<path d="M16 22.964c-4.525 0-8.447 1.713-9.993 4.365-0.371 0.636-0.156 1.452 0.48 1.823s1.453 0.156 1.823-0.48c0.855-1.465 3.624-3.041 7.689-3.041s6.835 1.576 7.689 3.041c0.249 0.424 0.696 0.661 1.155 0.661 0.228 0 0.459-0.059 0.669-0.181 0.637-0.371 0.852-1.187 0.48-1.823-1.545-2.652-5.467-4.365-9.992-4.365zM22.667 13.631c0-3.676-2.991-6.667-6.667-6.667s-6.667 2.991-6.667 6.667 2.991 6.667 6.667 6.667 6.667-2.992 6.667-6.667zM12 13.631c0-2.205 1.795-4 4-4s4 1.795 4 4-1.795 4-4 4-4-1.795-4-4zM16 0.297c-8.823 0-16 7.177-16 16 0 2.941 0.821 5.831 2.373 8.357 0.252 0.411 0.689 0.636 1.137 0.636 0.239 0 0.479-0.064 0.696-0.197 0.628-0.385 0.824-1.207 0.439-1.833-1.295-2.108-1.979-4.516-1.979-6.963 0-7.352 5.981-13.333 13.333-13.333s13.333 5.981 13.333 13.333c0 2.448-0.684 4.856-1.979 6.961-0.385 0.628-0.189 1.448 0.437 1.835 0.627 0.384 1.448 0.189 1.835-0.437 1.553-2.527 2.373-5.416 2.373-8.359 0-8.823-7.177-16-16-16z"></path>\n</svg>\n';const u=class{constructor(t){s(this,t),this.accountLoading=!1,this.opened=!1,this.notifications=salla.lang.get("common.titles.notifications"),this.orders=salla.lang.get("common.titles.orders"),this.pending_orders=salla.lang.get("common.titles.pending_orders"),this.wishlist=salla.lang.get("common.titles.wishlist"),this.profile=salla.lang.get("common.titles.profile"),this.rating=salla.lang.get("common.titles.rating"),this.wallet=salla.lang.get("common.titles.wallet"),this.settings=salla.lang.get("common.titles.settings"),this.loyalty_program=salla.lang.get("pages.loyalty_program.loyalty_points"),this.logout=salla.lang.get("blocks.header.logout"),this.hello=salla.lang.get("pages.checkout.hello"),this.first_name=salla.storage.get("user.first_name")||"",this.last_name=salla.storage.get("user.last_name")||"",this.avatar=salla.storage.get("user.avatar")||salla.url.cdn("images/avatar.png",40,40),this.badges={notifications:salla.helpers.number(salla.storage.get("user.notifications")||0),pending_orders:salla.helpers.number(salla.storage.get("user.pending_orders")||0)},this.sallaAccountEnabled=!1,this.hasBadges=Number(salla.storage.get("user.pending_orders"))>0||Number(salla.storage.get("user.notifications"))>0,this.inline=!1,this.avatarOnly=!1,this.showHeader=!1,this.relativeDropdown=!1,this.autoMount=!1,this.onClickOutside=()=>{this.opened=!1},this.OrderUpdate=0,this.items={notifications:a,orders:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>box-bankers</title>\n<path d="M28 1.333h-24c-2.205 0-4 1.795-4 4v5.333c0 0.736 0.597 1.333 1.333 1.333v14.667c0 2.205 1.795 4 4 4h21.333c2.205 0 4-1.795 4-4v-14.667c0.736 0 1.333-0.597 1.333-1.333v-5.333c0-2.205-1.795-4-4-4zM28 26.667c0 0.735-0.599 1.333-1.333 1.333h-21.333c-0.735 0-1.333-0.599-1.333-1.333v-14.667h5.333v2.667c0 1.471 1.196 2.667 2.667 2.667h8c1.471 0 2.667-1.196 2.667-2.667v-2.667h5.333zM12 14.667v-2.667h8v2.667zM29.333 9.333h-26.667v-4c0-0.735 0.599-1.333 1.333-1.333h24c0.735 0 1.333 0.599 1.333 1.333z"></path>\n</svg>\n',pending_orders:o,wishlist:n,wallet:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>wallet</title>\n<path d="M28 6.667h-24c-0.736 0-1.333-0.597-1.333-1.333s0.597-1.333 1.333-1.333h24c0.737 0 1.333-0.596 1.333-1.333s-0.596-1.333-1.333-1.333h-24c-2.204 0-3.999 1.793-4 3.997v18.669c0 3.676 2.991 6.667 6.667 6.667h21.333c2.205 0 4-1.795 4-4v-16c0-2.205-1.795-4-4-4zM29.333 26.667c0 0.736-0.597 1.333-1.333 1.333h-21.333c-2.205 0-4-1.795-4-4v-14.895c0.416 0.147 0.865 0.228 1.333 0.228h24c0.736 0 1.333 0.597 1.333 1.333zM22.667 14.667c-2.205 0-4 1.795-4 4s1.795 4 4 4 4-1.795 4-4-1.795-4-4-4zM22.667 20c-0.736 0-1.333-0.597-1.333-1.333s0.597-1.333 1.333-1.333 1.333 0.597 1.333 1.333-0.597 1.333-1.333 1.333z"></path>\n</svg>\n',loyalty_program:c,profile:m}}async componentWillLoad(){await salla.onReady(),await salla.lang.onLoaded(),this.loadTranslations(),this.initiate(),Salla.event.on("api::token.injected",(s=>this.profileUrl=this.buildProfileUrl(s))),this.sallaAccountEnabled=Salla.config.get("store.features")?.includes("salla-account"),this.items=this.sallaAccountEnabled?{...this.items,settings:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>settings</title>\n<path d="M29.717 19.037l-1.817-1.499c0.067-0.512 0.1-1.028 0.1-1.539s-0.033-1.027-0.1-1.54l1.817-1.499c1.177-0.969 1.479-2.633 0.716-3.956l-1.159-2.009c-0.761-1.324-2.349-1.895-3.784-1.359l-2.212 0.829c-0.817-0.627-1.704-1.139-2.649-1.535l-0.388-2.332c-0.251-1.507-1.54-2.6-3.067-2.6h-2.319c-1.525 0-2.815 1.093-3.065 2.6l-0.388 2.332c-0.945 0.396-1.833 0.909-2.649 1.535l-2.212-0.829c-1.428-0.533-3.021 0.036-3.783 1.359l-1.16 2.011c-0.763 1.323-0.46 2.985 0.716 3.955l1.817 1.499c-0.067 0.513-0.1 1.029-0.1 1.54s0.033 1.027 0.1 1.539l-1.819 1.5c-1.176 0.971-1.476 2.635-0.715 3.955l1.159 2.011c0.763 1.324 2.356 1.899 3.784 1.36l2.212-0.831c0.816 0.625 1.703 1.139 2.649 1.535l0.388 2.332c0.251 1.507 1.54 2.6 3.067 2.6h2.319c1.527 0 2.816-1.093 3.065-2.6l0.389-2.332c0.947-0.396 1.833-0.909 2.649-1.535l2.212 0.831c1.432 0.539 3.023-0.035 3.783-1.36l1.16-2.011c0.76-1.32 0.459-2.984-0.717-3.956zM28.123 21.663l-1.16 2.011c-0.108 0.188-0.336 0.267-0.536 0.193l-2.931-1.1c-0.459-0.173-0.979-0.079-1.349 0.248-0.923 0.811-1.979 1.423-3.139 1.819-0.464 0.157-0.804 0.559-0.885 1.043l-0.515 3.087c-0.033 0.215-0.216 0.371-0.433 0.371h-2.319c-0.217 0-0.4-0.156-0.436-0.371l-0.513-3.087c-0.080-0.484-0.42-0.884-0.885-1.043-1.16-0.396-2.216-1.008-3.139-1.819-0.248-0.217-0.561-0.332-0.88-0.332-0.157 0-0.316 0.028-0.469 0.084l-2.931 1.1c-0.199 0.079-0.428-0.004-0.537-0.193l-1.159-2.011c-0.109-0.191-0.067-0.428 0.101-0.568l2.409-1.985c0.379-0.312 0.555-0.807 0.46-1.288-0.119-0.605-0.179-1.219-0.179-1.821 0-0.604 0.060-1.217 0.181-1.823 0.095-0.481-0.081-0.976-0.46-1.288l-2.409-1.985c-0.168-0.139-0.211-0.376-0.101-0.567l1.16-2.011c0.107-0.188 0.332-0.268 0.536-0.193l2.931 1.1c0.459 0.172 0.979 0.079 1.348-0.247 0.924-0.812 1.98-1.424 3.139-1.817 0.465-0.159 0.805-0.559 0.885-1.044l0.513-3.088c0.036-0.215 0.219-0.371 0.436-0.371h2.319c0.217 0 0.4 0.156 0.436 0.371l0.515 3.088c0.081 0.484 0.42 0.885 0.885 1.044 1.157 0.393 2.213 1.005 3.139 1.817 0.371 0.325 0.889 0.42 1.349 0.247l2.929-1.099c0.203-0.076 0.428 0.005 0.537 0.193l1.159 2.009c0.109 0.191 0.067 0.428-0.101 0.567l-2.409 1.985c-0.379 0.312-0.555 0.807-0.46 1.288 0.119 0.605 0.179 1.219 0.179 1.823 0 0.603-0.060 1.216-0.181 1.821-0.095 0.48 0.081 0.975 0.46 1.288l2.408 1.984c0.169 0.141 0.212 0.379 0.103 0.569zM16.016 10.667c-2.941 0-5.333 2.392-5.333 5.333s2.392 5.333 5.333 5.333 5.333-2.392 5.333-5.333-2.392-5.333-5.333-5.333zM16.016 18.667c-1.471 0-2.667-1.196-2.667-2.667s1.196-2.667 2.667-2.667 2.667 1.196 2.667 2.667-1.196 2.667-2.667 2.667z"></path>\n</svg>\n'}:this.items,this.host.hasAttribute("with-rating")&&(this.items.rating=h),this.items.logout='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>send-out</title>\n<path d="M16 26.667h-9.333c-0.736 0-1.333-0.597-1.333-1.333v-18.667c0-0.736 0.597-1.333 1.333-1.333h9.333c0.737 0 1.333-0.596 1.333-1.333s-0.596-1.333-1.333-1.333h-9.333c-2.205 0-4 1.795-4 4v18.667c0 2.205 1.795 4 4 4h9.333c0.737 0 1.333-0.596 1.333-1.333s-0.596-1.333-1.333-1.333zM29.231 15.491c-0.068-0.164-0.167-0.312-0.289-0.436l-5.332-5.332c-0.521-0.521-1.364-0.521-1.885 0s-0.521 1.364 0 1.885l3.057 3.059h-12.781c-0.737 0-1.333 0.596-1.333 1.333s0.596 1.333 1.333 1.333h12.781l-3.057 3.057c-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391l5.332-5.332c0.124-0.123 0.221-0.271 0.289-0.435 0.135-0.325 0.135-0.693 0-1.019z"></path>\n</svg>\n';let s=Salla.storage.get("token");s||(s=""),this.profileUrl=this.buildProfileUrl(s);const t=this.host.querySelector('[slot="trigger"]');this.triggerSlot='<div class="s-user-menu-trigger"><div class="s-user-menu-avatar-wrap"><img class="s-user-menu-trigger-avatar" src="{avatar}" alt="{first_name}{last_name}" /></div><div class="s-user-menu-trigger-content"><span class="s-user-menu-trigger-hello">{hello}</span><p class="s-user-menu-trigger-name">{first_name} {last_name}</p></div> <i class="s-user-menu-trigger-icon">{icon}</i></div>',t&&(this.triggerSlot=t.innerHTML,t.innerHTML=this.replaceParams(t.innerHTML))}loadTranslations(){this.notifications=Salla.lang.get("common.titles.notifications"),this.orders=Salla.lang.get("common.titles.orders"),this.pending_orders=Salla.lang.get("common.titles.pending_orders"),this.wishlist=Salla.lang.get("common.titles.wishlist"),this.profile=Salla.lang.get("common.titles.profile"),this.hello=Salla.lang.get("pages.checkout.hello"),this.rating=Salla.lang.get("common.titles.rating"),this.wallet=Salla.lang.get("common.titles.wallet"),this.settings=Salla.lang.get("common.titles.settings"),this.loyalty_program=Salla.lang.get("pages.loyalty_program.loyalty_points"),this.logout=Salla.lang.get("blocks.header.logout")}initiate(){return Salla.config.isGuest()?this.autoMountLoginModal():(this.is_loggedIn=!0,!this.inline&&(salla.url.is_page("customer.notifications")||salla.url.is_page("customer.orders.index.pending")||salla.url.is_page("customer.profile")||(Date.now()-(salla.storage.get("user.fetched_at")||0))/1e3/60>30)?this.fetchFreshProfile():void salla.event.on("profile::info.fetched",(s=>{this.updateProfileState(s)})))}autoMountLoginModal(){this.autoMount&&(document.querySelector("salla-login-modal")||Salla.hooks.mount("body:end",document.createElement("salla-login-modal")))}fetchFreshProfile(){salla.api.token?salla.profile.api.info().then((s=>{this.updateProfileState(s)})):salla.log("trying to fetchFreshProfile before injected the token!!")}updateProfileState(s){this.badges={notifications:salla.helpers.number(s.data.notifications||0),pending_orders:salla.helpers.number(s.data.pending_orders||0)},this.hasBadges=Number(s.data.pending_orders)>0||Number(s.data.notifications)>0,this.first_name=s.data.first_name,this.last_name=s.data.last_name,this.avatar=s.data.avatar||salla.url.cdn("images/avatar.png",40,40)}async open(s){this.opened=!this.opened,s.stopPropagation(),this.opened&&window.addEventListener("click",this.onClickOutside)}menuItemClicked(s,t){"logout"===t&&(s.preventDefault(),salla.auth.logout("sall-user-menu"))}replaceParams(s){return s.replace(/\{hello\}/g,this.hello).replace(/\{first_name\}/g,this.first_name).replace(/\{last_name\}/g,this.last_name).replace(/\{avatar\}/g,this.avatar).replace(/\{icon\}/g,i)}getTheHeader(){return t("div",{class:{"s-user-menu-trigger-slot":!0,"s-user-menu-red-dot":this.hasBadges,"s-user-menu-trigger-avatar-only":this.avatarOnly},id:"trigger-slot",onClick:s=>this.open(s),onKeyUp:s=>this.open(s),innerHTML:this.replaceParams(this.triggerSlot)})}getItemAnchorLinkAttrs(s){return"profile"===s&&this.profileUrl&&this.sallaAccountEnabled?{href:this.profileUrl,target:"_blank",rel:"noopener noreferrer"}:{href:Salla.url.get("loyalty_program"===s?"loyalty":s)}}getMenuItem([s,e],l){if(("wallet"!==s||window.can_access_wallet)&&("loyalty_program"!==s||Salla.config.get("store.features").includes("loyalty-system")))return t("li",{class:{"s-user-menu-dropdown-item":!0,"s-user-menu-dropdown-item-logout":l+1===Object.entries(this.items).length}},t("a",{...this.getItemAnchorLinkAttrs(s),class:"s-user-menu-dropdown-item-link",onClick:t=>this.menuItemClicked(t,s)},t("i",{class:"s-user-menu-dropdown-item-prefix",innerHTML:e}),t("span",{class:"s-user-menu-dropdown-item-title"},this[s]),["٠","0",void 0].includes(this.badges[s])?"":t("span",{class:"s-user-menu-dropdown-item-badge"},this.badges[s])))}componentShouldUpdate(){this.opened||window.removeEventListener("click",this.onClickOutside)}render(){return t(e,null,this.is_loggedIn?this.inline?t("ul",{class:"s-user-menu-inline"},Object.entries(this.items).map(((s,t)=>this.getMenuItem(s,t)))):t("div",{class:{"s-user-menu-wrapper":!0,"s-user-menu-relative-dropdown":this.relativeDropdown}},this.getTheHeader(),t("div",{class:{"s-user-menu-toggler":!0,opened:this.opened}},t("div",{class:"s-user-menu-dropdown",onClick:s=>s.stopPropagation(),onKeyUp:s=>s.stopPropagation()},this.showHeader?t("div",{class:"s-user-menu-dropdown-header"},t("img",{src:this.avatar,alt:`${this.first_name} ${this.last_name}`}),t("div",{class:"s-user-menu-dropdown-header-content"},t("span",null,this.hello),t("p",null,this.first_name," ",this.last_name)),t("button",{type:"button",class:"s-user-menu-dropdown-header-close",innerHTML:r,onClick:()=>{this.opened=!1}})):"",t("ul",{class:"s-user-menu-dropdown-list"},Object.entries(this.items).map(((s,t)=>this.getMenuItem(s,t))))))):t("slot",{name:"login-btn"},t("button",{type:"button",class:"s-user-menu-login-btn",onClick:()=>salla.event.dispatch("login::open"),innerHTML:m})))}componentDidLoad(){document.lazyLoadInstance?.update(this.host.querySelectorAll(".lazy"))}buildProfileUrl(s){return`${Salla.config.get("account.url","https://accounts.salla.com")}/${salla.config.get("user.language_code")}/user?store=${Salla.config.get("store.id")}&info=${encodeURIComponent(s)}`}get host(){return l(this)}};u.style="";export{u as salla_user_menu}