@salla.sa/twilight-components 2.14.445 → 2.14.447

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 (307) hide show
  1. package/dist/cjs/{filepond-DHzf3TcL.js → filepond-H0V09y77.js} +1 -1
  2. package/dist/cjs/{filepond-plugin-file-poster-BXm87rQo.js → filepond-plugin-file-poster-z_Pgx1za.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-validate-size-C5UIq4A2.js → filepond-plugin-file-validate-size-BgbBSmud.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-type-DuhBUbfK.js → filepond-plugin-file-validate-type-D2zmv3Bc.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-image-edit-B9-VYsWc.js → filepond-plugin-image-edit-B74CXTZm.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-exif-orientation-DMpSTznq.js → filepond-plugin-image-exif-orientation-DyaNWpnA.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-preview-CMGkdkZi.js → filepond-plugin-image-preview-C0XDHIb0.js} +1 -1
  8. package/dist/cjs/{functions-9Nj0nrLx.js → functions-Bs97hO7_.js} +1 -1
  9. package/dist/cjs/{index-rElwQMYM.js → index-B5-Obq5h.js} +1 -1
  10. package/dist/cjs/{index-DQZXng_4.js → index-CBTkKuC2.js} +2 -2
  11. package/dist/cjs/loader.cjs.js +1 -1
  12. package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
  13. package/dist/cjs/salla-accordion_6.cjs.entry.js +1 -1
  14. package/dist/cjs/salla-add-product-button_5.cjs.entry.js +2 -2
  15. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  16. package/dist/cjs/salla-alert_2.cjs.entry.js +1 -1
  17. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  18. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  19. package/dist/cjs/salla-badge.cjs.entry.js +1 -1
  20. package/dist/cjs/salla-booking-field_7.cjs.entry.js +10 -10
  21. package/dist/cjs/salla-bullet-delivery_2.cjs.entry.js +1 -1
  22. package/dist/cjs/salla-cart-coupons.cjs.entry.js +1 -1
  23. package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
  24. package/dist/cjs/salla-cashback-banner.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-comment-form_8.cjs.entry.js +1 -1
  26. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  28. package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
  29. package/dist/cjs/salla-count-down.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
  31. package/dist/cjs/salla-delivery-promise.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-filters.cjs.entry.js +1 -1
  35. package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
  36. package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-hook.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
  39. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  40. package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-loyalty-banner.cjs.entry.js +2 -2
  44. package/dist/cjs/salla-loyalty-hero_2.cjs.entry.js +2 -2
  45. package/dist/cjs/salla-loyalty-panel.cjs.entry.js +3 -3
  46. package/dist/cjs/salla-loyalty-points-banner.cjs.entry.js +1 -1
  47. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  48. package/dist/cjs/salla-loyalty-program.cjs.entry.js +3 -3
  49. package/dist/cjs/salla-loyalty-reward.cjs.entry.js +2 -2
  50. package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
  51. package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
  52. package/dist/cjs/salla-map.cjs.entry.js +1 -1
  53. package/dist/cjs/salla-menu.cjs.entry.js +1 -1
  54. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  55. package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
  56. package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
  57. package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
  58. package/dist/cjs/salla-next-order-coupon.cjs.entry.js +1 -1
  59. package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
  60. package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
  61. package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
  62. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  63. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  64. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  65. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  66. package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
  67. package/dist/cjs/salla-order-edit-product-card.cjs.entry.js +1 -1
  68. package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
  69. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  70. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  71. package/dist/cjs/salla-orders.cjs.entry.js +1 -1
  72. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  73. package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
  74. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  75. package/dist/cjs/salla-product-card-embed.cjs.entry.js +1 -1
  76. package/dist/cjs/salla-product-card_2.cjs.entry.js +1 -1
  77. package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
  78. package/dist/cjs/salla-products-list.cjs.entry.js +33 -32
  79. package/dist/cjs/salla-progress-bar.cjs.entry.js +1 -1
  80. package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
  81. package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
  82. package/dist/cjs/salla-reward-action_4.cjs.entry.js +3 -3
  83. package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
  84. package/dist/cjs/salla-search.cjs.entry.js +1 -1
  85. package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
  86. package/dist/cjs/salla-slider.cjs.entry.js +1 -1
  87. package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
  88. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  89. package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
  90. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  91. package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
  92. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  93. package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
  94. package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
  95. package/dist/cjs/salla-user-settings.cjs.entry.js +1 -1
  96. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  97. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  98. package/dist/cjs/{tracked-promise-YvbHmmFp.js → tracked-promise-CyZ6P0Ww.js} +1 -1
  99. package/dist/cjs/twilight.cjs.js +1 -1
  100. package/dist/cjs/{vanilla-picker-C02drqC1.js → vanilla-picker-Bd-KMT3o.js} +1 -1
  101. package/dist/collection/components/salla-bought-together/salla-bought-together.js +1 -1
  102. package/dist/collection/components/salla-products-list/salla-products-list.js +32 -31
  103. package/dist/components/index.js +2 -2
  104. package/dist/components/salla-bought-together.js +1 -1
  105. package/dist/components/salla-products-list2.js +32 -31
  106. package/dist/esm/{filepond-D3RXwxDJ.js → filepond-DO_Qk3JK.js} +1 -1
  107. package/dist/esm/{filepond-plugin-file-poster-Bn0h-4qC.js → filepond-plugin-file-poster-Btb31Xcs.js} +1 -1
  108. package/dist/esm/{filepond-plugin-file-validate-size-CN-3nZup.js → filepond-plugin-file-validate-size-Bs8yCeGp.js} +1 -1
  109. package/dist/esm/{filepond-plugin-file-validate-type-BbLjL14b.js → filepond-plugin-file-validate-type-B5rUPm_4.js} +1 -1
  110. package/dist/esm/{filepond-plugin-image-edit-Dr_0Kpj1.js → filepond-plugin-image-edit-XOXQA_f1.js} +1 -1
  111. package/dist/esm/{filepond-plugin-image-exif-orientation-Bo8gf--w.js → filepond-plugin-image-exif-orientation-DUyferIn.js} +1 -1
  112. package/dist/esm/{filepond-plugin-image-preview-CkgdmQBn.js → filepond-plugin-image-preview-BHVQ0frN.js} +1 -1
  113. package/dist/esm/{functions-CsLl2GF-.js → functions-CHwbDaMQ.js} +1 -1
  114. package/dist/esm/{index-BZR5x5kv.js → index-DECtOcJg.js} +1 -1
  115. package/dist/esm/{index-DNtvpIPH.js → index-DtunYVY8.js} +2 -2
  116. package/dist/esm/loader.js +2 -2
  117. package/dist/esm/salla-accordion-body_2.entry.js +1 -1
  118. package/dist/esm/salla-accordion_6.entry.js +1 -1
  119. package/dist/esm/salla-add-product-button_5.entry.js +2 -2
  120. package/dist/esm/salla-advertisement.entry.js +1 -1
  121. package/dist/esm/salla-alert_2.entry.js +1 -1
  122. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  123. package/dist/esm/salla-apps-icons.entry.js +1 -1
  124. package/dist/esm/salla-badge.entry.js +1 -1
  125. package/dist/esm/salla-booking-field_7.entry.js +10 -10
  126. package/dist/esm/salla-bullet-delivery_2.entry.js +1 -1
  127. package/dist/esm/salla-cart-coupons.entry.js +1 -1
  128. package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
  129. package/dist/esm/salla-cashback-banner.entry.js +1 -1
  130. package/dist/esm/salla-comment-form_8.entry.js +1 -1
  131. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  132. package/dist/esm/salla-contacts.entry.js +1 -1
  133. package/dist/esm/salla-cookies-bar.entry.js +1 -1
  134. package/dist/esm/salla-count-down.entry.js +1 -1
  135. package/dist/esm/salla-custom-fields.entry.js +1 -1
  136. package/dist/esm/salla-delivery-promise.entry.js +1 -1
  137. package/dist/esm/salla-edit-order-button.entry.js +1 -1
  138. package/dist/esm/salla-filters-widget.entry.js +1 -1
  139. package/dist/esm/salla-filters.entry.js +1 -1
  140. package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
  141. package/dist/esm/salla-gifting.entry.js +1 -1
  142. package/dist/esm/salla-hook.entry.js +1 -1
  143. package/dist/esm/salla-infinite-scroll.entry.js +1 -1
  144. package/dist/esm/salla-installment.entry.js +1 -1
  145. package/dist/esm/salla-list-tile.entry.js +1 -1
  146. package/dist/esm/salla-localization-modal.entry.js +1 -1
  147. package/dist/esm/salla-login-modal.entry.js +1 -1
  148. package/dist/esm/salla-loyalty-banner.entry.js +2 -2
  149. package/dist/esm/salla-loyalty-hero_2.entry.js +2 -2
  150. package/dist/esm/salla-loyalty-panel.entry.js +3 -3
  151. package/dist/esm/salla-loyalty-points-banner.entry.js +1 -1
  152. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  153. package/dist/esm/salla-loyalty-program.entry.js +3 -3
  154. package/dist/esm/salla-loyalty-reward.entry.js +2 -2
  155. package/dist/esm/salla-loyalty.entry.js +1 -1
  156. package/dist/esm/salla-maintenance-alert.entry.js +1 -1
  157. package/dist/esm/salla-map.entry.js +1 -1
  158. package/dist/esm/salla-menu.entry.js +1 -1
  159. package/dist/esm/salla-metadata.entry.js +1 -1
  160. package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
  161. package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
  162. package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
  163. package/dist/esm/salla-next-order-coupon.entry.js +1 -1
  164. package/dist/esm/salla-notification-item.entry.js +1 -1
  165. package/dist/esm/salla-notifications.entry.js +1 -1
  166. package/dist/esm/salla-offer-modal.entry.js +1 -1
  167. package/dist/esm/salla-offer.entry.js +1 -1
  168. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  169. package/dist/esm/salla-order-details-options.entry.js +1 -1
  170. package/dist/esm/salla-order-details.entry.js +1 -1
  171. package/dist/esm/salla-order-edit-item.entry.js +1 -1
  172. package/dist/esm/salla-order-edit-product-card.entry.js +1 -1
  173. package/dist/esm/salla-order-edit.entry.js +1 -1
  174. package/dist/esm/salla-order-summary.entry.js +1 -1
  175. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  176. package/dist/esm/salla-orders.entry.js +1 -1
  177. package/dist/esm/salla-payments.entry.js +1 -1
  178. package/dist/esm/salla-placeholder.entry.js +1 -1
  179. package/dist/esm/salla-price-range.entry.js +1 -1
  180. package/dist/esm/salla-product-card-embed.entry.js +1 -1
  181. package/dist/esm/salla-product-card_2.entry.js +1 -1
  182. package/dist/esm/salla-product-size-guide.entry.js +1 -1
  183. package/dist/esm/salla-products-list.entry.js +33 -32
  184. package/dist/esm/salla-progress-bar.entry.js +1 -1
  185. package/dist/esm/salla-quick-order.entry.js +1 -1
  186. package/dist/esm/salla-rating-modal.entry.js +1 -1
  187. package/dist/esm/salla-reward-action_4.entry.js +3 -3
  188. package/dist/esm/salla-scopes.entry.js +1 -1
  189. package/dist/esm/salla-search.entry.js +1 -1
  190. package/dist/esm/salla-skeleton.entry.js +1 -1
  191. package/dist/esm/salla-slider.entry.js +1 -1
  192. package/dist/esm/salla-social-share.entry.js +1 -1
  193. package/dist/esm/salla-social.entry.js +1 -1
  194. package/dist/esm/salla-tab-content_3.entry.js +1 -1
  195. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  196. package/dist/esm/salla-tooltip.entry.js +1 -1
  197. package/dist/esm/salla-trust-badges.entry.js +1 -1
  198. package/dist/esm/salla-user-menu.entry.js +1 -1
  199. package/dist/esm/salla-user-profile.entry.js +1 -1
  200. package/dist/esm/salla-user-settings.entry.js +1 -1
  201. package/dist/esm/salla-verify.entry.js +1 -1
  202. package/dist/esm/salla-wallet.entry.js +1 -1
  203. package/dist/esm/{tracked-promise-BnC5Z9K7.js → tracked-promise-BcnHGy9I.js} +1 -1
  204. package/dist/esm/twilight.js +2 -2
  205. package/dist/esm/{vanilla-picker-CF_W6ne1.js → vanilla-picker-CKYy2jA4.js} +1 -1
  206. package/dist/twilight/{p-08344e0e.entry.js → p-041fe75d.entry.js} +1 -1
  207. package/dist/twilight/{p-43e90789.entry.js → p-071f9c31.entry.js} +1 -1
  208. package/dist/twilight/{p-52d2d246.entry.js → p-0c3c496e.entry.js} +1 -1
  209. package/dist/twilight/{p-87978156.entry.js → p-0e1a6208.entry.js} +1 -1
  210. package/dist/twilight/{p-06496953.entry.js → p-1431bedb.entry.js} +1 -1
  211. package/dist/twilight/{p-589b4b5e.entry.js → p-158c0fd9.entry.js} +1 -1
  212. package/dist/twilight/{p-fa350b8c.entry.js → p-1c54fe1c.entry.js} +1 -1
  213. package/dist/twilight/{p-42e59b60.entry.js → p-1d86e9f5.entry.js} +1 -1
  214. package/dist/twilight/{p-67a36054.entry.js → p-1e8c6aca.entry.js} +1 -1
  215. package/dist/twilight/{p-9e1f454d.entry.js → p-22eac711.entry.js} +1 -1
  216. package/dist/twilight/{p-c86c3e12.entry.js → p-23ef52d4.entry.js} +1 -1
  217. package/dist/twilight/{p-7f805c47.entry.js → p-2460406e.entry.js} +1 -1
  218. package/dist/twilight/{p-ab565608.entry.js → p-2733190a.entry.js} +1 -1
  219. package/dist/twilight/{p-7ffd3938.entry.js → p-2934beff.entry.js} +1 -1
  220. package/dist/twilight/{p-46f82b50.entry.js → p-2c04d113.entry.js} +1 -1
  221. package/dist/twilight/{p-ed107904.entry.js → p-2e9679fb.entry.js} +1 -1
  222. package/dist/twilight/p-33968d21.entry.js +4 -0
  223. package/dist/twilight/{p-83a08f07.entry.js → p-360e32b5.entry.js} +1 -1
  224. package/dist/twilight/{p-062e5544.entry.js → p-36df6391.entry.js} +1 -1
  225. package/dist/twilight/{p-ccf623d3.entry.js → p-38069747.entry.js} +1 -1
  226. package/dist/twilight/{p-13cbd6eb.entry.js → p-39c65bfc.entry.js} +1 -1
  227. package/dist/twilight/{p-007bf4b3.entry.js → p-3a8af7f6.entry.js} +1 -1
  228. package/dist/twilight/{p-564007ad.entry.js → p-3f2201f2.entry.js} +1 -1
  229. package/dist/twilight/{p-058d72ba.entry.js → p-429c2869.entry.js} +1 -1
  230. package/dist/twilight/{p-73409575.entry.js → p-44b9b2ac.entry.js} +1 -1
  231. package/dist/twilight/{p-318e0847.entry.js → p-452601b5.entry.js} +1 -1
  232. package/dist/twilight/{p-f48a00a8.entry.js → p-49077075.entry.js} +1 -1
  233. package/dist/twilight/{p-2fb3d665.entry.js → p-493258d1.entry.js} +1 -1
  234. package/dist/twilight/{p-beb60b7e.entry.js → p-4f8ea699.entry.js} +1 -1
  235. package/dist/twilight/{p-0aea9987.entry.js → p-50dd7bd2.entry.js} +1 -1
  236. package/dist/twilight/{p-ecb8c538.entry.js → p-51e35559.entry.js} +1 -1
  237. package/dist/twilight/{p-0418d2eb.entry.js → p-5374824f.entry.js} +1 -1
  238. package/dist/twilight/{p-53c2b30e.entry.js → p-54a3559b.entry.js} +1 -1
  239. package/dist/twilight/{p-38c677fb.entry.js → p-5571c0bb.entry.js} +1 -1
  240. package/dist/twilight/{p-c81203f3.entry.js → p-5648016f.entry.js} +1 -1
  241. package/dist/twilight/{p-3af39ede.entry.js → p-6272d023.entry.js} +1 -1
  242. package/dist/twilight/{p-2282abc4.entry.js → p-62f3f1f7.entry.js} +1 -1
  243. package/dist/twilight/{p-2134195f.entry.js → p-664fb7b8.entry.js} +1 -1
  244. package/dist/twilight/{p-e902b0b4.entry.js → p-6b65c0d5.entry.js} +1 -1
  245. package/dist/twilight/{p-df7d2c53.entry.js → p-6c788e1e.entry.js} +1 -1
  246. package/dist/twilight/{p-c583a907.entry.js → p-70b75d07.entry.js} +1 -1
  247. package/dist/twilight/{p-185b629e.entry.js → p-75f8c604.entry.js} +1 -1
  248. package/dist/twilight/{p-6c45e8fa.entry.js → p-76c1ba40.entry.js} +1 -1
  249. package/dist/twilight/{p-561b7f43.entry.js → p-7749da52.entry.js} +1 -1
  250. package/dist/twilight/{p-28e39ff0.entry.js → p-7d5cff28.entry.js} +1 -1
  251. package/dist/twilight/{p-a8aea13b.entry.js → p-7f7d1bf1.entry.js} +1 -1
  252. package/dist/twilight/{p-dd706055.entry.js → p-8116827d.entry.js} +1 -1
  253. package/dist/twilight/{p-186df566.entry.js → p-814a9889.entry.js} +1 -1
  254. package/dist/twilight/{p-14b4b77f.entry.js → p-83807c54.entry.js} +1 -1
  255. package/dist/twilight/{p-d6dba947.entry.js → p-84ec609c.entry.js} +1 -1
  256. package/dist/twilight/{p-89bdd5e6.entry.js → p-86c39145.entry.js} +1 -1
  257. package/dist/twilight/{p-eb8a0d2f.entry.js → p-8815596b.entry.js} +1 -1
  258. package/dist/twilight/{p-D9eZofcJ.js → p-8MUZ2pqK.js} +1 -1
  259. package/dist/twilight/{p-56bdf925.entry.js → p-8c78f5b7.entry.js} +1 -1
  260. package/dist/twilight/{p-2b9deb4c.entry.js → p-8d335191.entry.js} +1 -1
  261. package/dist/twilight/{p-69498df8.entry.js → p-8e0ee5ac.entry.js} +1 -1
  262. package/dist/twilight/{p-788c870c.entry.js → p-9396295d.entry.js} +1 -1
  263. package/dist/twilight/{p-16e2e0a8.entry.js → p-951e437f.entry.js} +1 -1
  264. package/dist/twilight/{p-3953d2cc.entry.js → p-98dc6f0f.entry.js} +1 -1
  265. package/dist/twilight/{p-5da3194a.entry.js → p-99804fec.entry.js} +1 -1
  266. package/dist/twilight/{p-BxtnkpUH.js → p-AGKwl7ld.js} +1 -1
  267. package/dist/twilight/{p-6Cm0Ixpa.js → p-BBI8lVBK.js} +1 -1
  268. package/dist/twilight/{p-NWWejksc.js → p-BOSt2xT-.js} +1 -1
  269. package/dist/twilight/{p-D_Gt_HbS.js → p-Be4qhkKw.js} +1 -1
  270. package/dist/twilight/{p-C5-SqAXv.js → p-BkdZznAG.js} +1 -1
  271. package/dist/twilight/{p-Bc7fLLSC.js → p-C6iDVPJi.js} +1 -1
  272. package/dist/twilight/{p-DEbQVTrF.js → p-Cdkh5eMM.js} +1 -1
  273. package/dist/twilight/{p-BGCZ19oG.js → p-DInJVX-i.js} +1 -1
  274. package/dist/twilight/{p-CCzp4vsg.js → p-DY_H4fO3.js} +1 -1
  275. package/dist/twilight/{p-J5XAqGwq.js → p-DpPRVQAV.js} +1 -1
  276. package/dist/twilight/{p-DNtvpIPH.js → p-DtunYVY8.js} +1 -1
  277. package/dist/twilight/{p-4168d56d.entry.js → p-a5205495.entry.js} +1 -1
  278. package/dist/twilight/{p-52686e7d.entry.js → p-a6cbb062.entry.js} +1 -1
  279. package/dist/twilight/{p-ab4d2172.entry.js → p-a7c81e63.entry.js} +1 -1
  280. package/dist/twilight/{p-ada82ecc.entry.js → p-afe87123.entry.js} +1 -1
  281. package/dist/twilight/{p-3da82405.entry.js → p-b6e37661.entry.js} +1 -1
  282. package/dist/twilight/{p-46bd695f.entry.js → p-b9965792.entry.js} +1 -1
  283. package/dist/twilight/{p-d8c3e606.entry.js → p-bfe9f635.entry.js} +1 -1
  284. package/dist/twilight/{p-d34e48ce.entry.js → p-c2b5570d.entry.js} +1 -1
  285. package/dist/twilight/{p-8f0d2c32.entry.js → p-c351436d.entry.js} +1 -1
  286. package/dist/twilight/{p-be76e4e7.entry.js → p-c987d08e.entry.js} +1 -1
  287. package/dist/twilight/{p-8d942086.entry.js → p-ca674d67.entry.js} +1 -1
  288. package/dist/twilight/{p-108fff84.entry.js → p-cc9246b7.entry.js} +1 -1
  289. package/dist/twilight/{p-717782f4.entry.js → p-ce2e72a2.entry.js} +1 -1
  290. package/dist/twilight/{p-db06baf6.entry.js → p-ce81c02d.entry.js} +1 -1
  291. package/dist/twilight/{p-dfc9dac3.entry.js → p-d2617fba.entry.js} +1 -1
  292. package/dist/twilight/{p-68fa49cc.entry.js → p-d5d4347d.entry.js} +1 -1
  293. package/dist/twilight/{p-ee83c195.entry.js → p-d7f22d4e.entry.js} +1 -1
  294. package/dist/twilight/{p-b25fd2a3.entry.js → p-d9a9ab0e.entry.js} +1 -1
  295. package/dist/twilight/{p-45f78030.entry.js → p-df88d27a.entry.js} +1 -1
  296. package/dist/twilight/{p-554e905e.entry.js → p-e1e75d50.entry.js} +1 -1
  297. package/dist/twilight/{p-455c6c0b.entry.js → p-e6f940d8.entry.js} +1 -1
  298. package/dist/twilight/{p-d618c0ee.entry.js → p-e701a5e1.entry.js} +1 -1
  299. package/dist/twilight/{p-86be6cee.entry.js → p-e8551517.entry.js} +1 -1
  300. package/dist/twilight/{p-09aa60ca.entry.js → p-f2b78b99.entry.js} +1 -1
  301. package/dist/twilight/{p-bb2ecab7.entry.js → p-f6a86eab.entry.js} +1 -1
  302. package/dist/twilight/{p-819992c7.entry.js → p-f92bd80a.entry.js} +1 -1
  303. package/dist/twilight/{p-34c2e75f.entry.js → p-f95d2671.entry.js} +1 -1
  304. package/dist/twilight/twilight.esm.js +1 -1
  305. package/dist/types/components/salla-products-list/salla-products-list.d.ts +1 -0
  306. package/package.json +5 -5
  307. package/dist/twilight/p-9b4d472b.entry.js +0 -4
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,c as s,h as i,H as e,a}from"./p-DNtvpIPH.js";import{a as r}from"./p-CgtvEd63.js";import{S as o}from"./p-DiKTtDW5.js";import{H as h}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=h.parseJson(this.includes||this.host.getAttribute("includes")),Array.isArray(this.includes)||(this.includes=null),h.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),await 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(){r({targets:"salla-products-list salla-product-card",opacity:[0,1],duration:1200,translateY:[20,0],delay:function(t,s){return 100*s}})}async 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)}`;this.nextPage=await this.applyBeforeBuildListUrl(this.nextPage)}async 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(await 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")&&(h.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"),r=salla.url.is_page("index"),o=salla.url.is_page("product.single"),h=e?i!==e:i!==String(a);if(i&&h&&!r&&!o||r&&!this.hasInfiniteScroll)return this.removeScrollRestorationSession(),this.switchToNormalBehavior=!0,!1;if(o)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 h.getProductsSource(this.source)}isAuxiliaryProductsListSource(){return["json","selected","related","landing-page","recently"].includes(this.getSource())}getSourceValue(){return this.currentCategoryIdFilter?this.currentCategoryIdFilter:h.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,s,i)=>{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=await this.handleResponse(t);this.infiniteScroll.appendItems(s),2===this.infiniteScroll.pageIndex&&(!this.autoload&&this.nextPage&&(this.loadMoreWrapper.style.display="block"),this.animateItems())}catch(e){console.error("Error during load:",e);try{const a=i;salla.analytics?.log("salla::products.list.fetch.error",{source:this.getSource(),nextPage:this.nextPage,pageIndex:this.infiniteScroll?.pageIndex,fetchPath:"string"==typeof s?s:void 0,httpStatus:a?.status,httpStatusText:a?.statusText,responseUrl:a?.url,itemsLength:Array.isArray(t?.data)?t.data.length:void 0,responseKeys:t&&"object"==typeof t?Object.keys(t).slice(0,30):void 0,errorMessage:e instanceof Error?e.message:String(e)})}catch{}}finally{this.isProcessing=!1}}})),this.infiniteScroll?.on("error",((t,s,i)=>{console.log("Error occurred during request");try{const e=i;salla.analytics?.log("salla::products.list.fetch.error",{source:this.getSource(),nextPage:this.nextPage,pageIndex:this.infiniteScroll?.pageIndex,fetchPath:s,httpStatus:e?.status,httpStatusText:e?.statusText,responseUrl:e?.url,errorMessage:t instanceof Error?t.message:String(t)})}catch{}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 applyBeforeBuildListUrl(t){try{const s={component:this,url:t};return await salla.hooks.call("salla-products-list","beforeBuildListUrl",s),s.url}catch(s){return salla.logger.warn("beforeBuildListUrl hook failed",s?.message),t}}async resolveNextPageFromCursor(t){return t.cursor?t.cursor.next?await this.applyBeforeBuildListUrl(t.cursor.next):t.cursor.next:this.nextPage}async injectAndProcessData(t){try{await h.injectExtraFieldsToResponse(t)}catch(t){console.error("Error injecting data:",t)}}getInitialData(){return this.loading(),salla.api.withoutNotifier((()=>salla.product.api.fetch({source:h.getApiSource(this.getSource()),source_value:this.getSourceValue(),limit:this.limit}).then((async t=>t.data.length?(await h.injectExtraFieldsToResponse(t),this.firstPageResponse?void(await this.handleResponse(t)).forEach((t=>this.wrapper.append(t))):(this.firstPageResponse=t,void(this.nextPage=await this.resolveNextPageFromCursor(t)))):(this.showPlaceholder=!0,this.placeholderLoader&&this.placeholderLoader.remove(),void this.loading(!1))))))}async loadMore(){this.infiniteScroll?.loadNextPage()}componentWillLoad(){return salla.onReady().then((async()=>{this.hasCustomComponent=!!customElements.get(this.productCardComponent),this.sourceValueIsValid=!(!this.getSourceValue()&&!this.isSourceWithoutValue()),this.hasInfiniteScroll=!this.isAuxiliaryProductsListSource()&&!this.limit;let t=new URLSearchParams(window.location.search);try{this.sortBy=this.sortBy||t.get("sort")||t.get("by"),this.parsedFilters=h.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(await 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((async()=>{this.firstPageResponse?((await 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&&(await 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:o}),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()}async handleResponse(t,s=!0){if(!t)return[];let i=this.getSource();if(1===t.cursor?.current){if(!this.isAuxiliaryProductsListSource()){let s=h.getPageTitleForSource(i);try{if("search"===this.getSource())s=salla.lang.get("common.elements.search_about",{word:this.getSourceValue()});else if(!s){let i=this.parsedFilters.category_id||this.getSourceValue()[0];s=t.filters?.find((t=>"category_id"===t.key))?.values?.find((t=>t.key===i))?.value??"",this.filtersSnapshot=t.filters}s+=(s?" - ":"")+salla.lang.choice("blocks.header.products_count",t.data?.length),15===t.data.length&&(s=s.replace(t.data.length,salla.lang.get("common.elements.more_than")+" "+t.data.length)),t.title=s}catch(t){salla.logger.error("Error::falid to handle response",t)}}h.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=await this.resolveNextPageFromCursor(t)),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 e=[];for(let s=0;s<t.data.length;s++)e.push(this.getItemHTML(t.data?.[s]));return e}get host(){return a(this)}};l.style="";export{l as salla_products_list}
4
+ import{r as t,c as s,h as i,H as e,a}from"./p-DtunYVY8.js";import{a as r}from"./p-CgtvEd63.js";import{S as o}from"./p-DiKTtDW5.js";import{H as h}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=h.parseJson(this.includes||this.host.getAttribute("includes")),Array.isArray(this.includes)||(this.includes=null),h.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),await 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(){r({targets:"salla-products-list salla-product-card",opacity:[0,1],duration:1200,translateY:[20,0],delay:function(t,s){return 100*s}})}async 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)}`;this.nextPage=await this.applyBeforeBuildListUrl(this.nextPage)}async 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(await 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")&&(h.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"),r=salla.url.is_page("index"),o=salla.url.is_page("product.single"),h=e?i!==e:i!==String(a);if(i&&h&&!r&&!o||r&&!this.hasInfiniteScroll)return this.removeScrollRestorationSession(),this.switchToNormalBehavior=!0,!1;if(o)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 h.getProductsSource(this.source)}isAuxiliaryProductsListSource(){return["json","selected","related","landing-page","recently"].includes(this.getSource())}getSourceValue(){return this.currentCategoryIdFilter?this.currentCategoryIdFilter:h.getProductsSourceValue(this.source,this.sourceValue)}logFetchError(t,s,i,e,a){try{const r=a&&"object"==typeof a?a:null,o=this.getSourceValue();salla.analytics?.log("salla::products.list.fetch.error",{errorPhase:t,source:this.getSource(),sourceValue:"string"==typeof o&&o.length>200?`${o.slice(0,200)}…`:Array.isArray(o)?{length:o.length}:o,pageIndex:this.infiniteScroll?.pageIndex,fetchPath:i,httpStatus:e?.status,httpStatusText:e?.statusText,responseUrl:e?.url,...r&&{dataCount:Array.isArray(r.data)?r.data.length:void 0,responseKeys:Object.keys(r).slice(0,15),filtersCount:Array.isArray(r.filters)?r.filters.length:void 0},errorMessage:s instanceof Error?s.message:String(s),..."processing"===t&&s instanceof Error&&s.stack?{errorStack:s.stack.slice(0,500)}:{}})}catch{}}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,s,i)=>{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=await this.handleResponse(t);this.infiniteScroll.appendItems(s),2===this.infiniteScroll.pageIndex&&(!this.autoload&&this.nextPage&&(this.loadMoreWrapper.style.display="block"),this.animateItems())}catch(e){console.error("Error during load:",e),this.logFetchError("processing",e,"string"==typeof s?s:void 0,i,t)}finally{this.isProcessing=!1}}})),this.infiniteScroll?.on("error",((t,s,i)=>{const e=i;this.status.querySelector(".s-infinite-scroll-error").classList.remove("s-hidden"),this.placeholderLoader&&this.placeholderLoader.remove(),this.loading(!1),this.isProcessing=!1,this.logFetchError("fetch",t,s,e)})),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 applyBeforeBuildListUrl(t){try{const s={component:this,url:t};return await salla.hooks.call("salla-products-list","beforeBuildListUrl",s),s.url}catch(s){return salla.logger.warn("beforeBuildListUrl hook failed",s?.message),t}}async resolveNextPageFromCursor(t){return t.cursor?t.cursor.next?await this.applyBeforeBuildListUrl(t.cursor.next):t.cursor.next:this.nextPage}async injectAndProcessData(t){try{await h.injectExtraFieldsToResponse(t)}catch(t){console.error("Error injecting data:",t)}}getInitialData(){return this.loading(),salla.api.withoutNotifier((()=>salla.product.api.fetch({source:h.getApiSource(this.getSource()),source_value:this.getSourceValue(),limit:this.limit}).then((async t=>t.data.length?(await h.injectExtraFieldsToResponse(t),this.firstPageResponse?void(await this.handleResponse(t)).forEach((t=>this.wrapper.append(t))):(this.firstPageResponse=t,void(this.nextPage=await this.resolveNextPageFromCursor(t)))):(this.showPlaceholder=!0,this.placeholderLoader&&this.placeholderLoader.remove(),void this.loading(!1))))))}async loadMore(){this.infiniteScroll?.loadNextPage()}componentWillLoad(){return salla.onReady().then((async()=>{this.hasCustomComponent=!!customElements.get(this.productCardComponent),this.sourceValueIsValid=!(!this.getSourceValue()&&!this.isSourceWithoutValue()),this.hasInfiniteScroll=!this.isAuxiliaryProductsListSource()&&!this.limit;let t=new URLSearchParams(window.location.search);try{this.sortBy=this.sortBy||t.get("sort")||t.get("by"),this.parsedFilters=h.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(await 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((async()=>{this.firstPageResponse?((await 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&&(await 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:o}),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()}async handleResponse(t,s=!0){if(!t)return[];let i=this.getSource();if(1===t.cursor?.current){if(!this.isAuxiliaryProductsListSource()){let s=h.getPageTitleForSource(i);try{if("search"===this.getSource())s=salla.lang.get("common.elements.search_about",{word:this.getSourceValue()});else if(!s){let i=this.parsedFilters.category_id||this.getSourceValue()[0];s=t.filters?.find((t=>"category_id"===t.key))?.values?.find((t=>t.key===i))?.value??"",this.filtersSnapshot=t.filters}s+=(s?" - ":"")+salla.lang.choice("blocks.header.products_count",t.data?.length),15===t.data.length&&(s=s.replace(t.data.length,salla.lang.get("common.elements.more_than")+" "+t.data.length)),t.title=s}catch(t){salla.logger.error("Error::falid to handle response",t)}}h.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=await this.resolveNextPageFromCursor(t)),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 e=[];for(let s=0;s<t.data.length;s++)e.push(this.getItemHTML(t.data?.[s]));return e}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 s,h as e,H as i}from"./p-DNtvpIPH.js";import{a}from"./p-BedNk7k1.js";const l=class{constructor(e){t(this,e),this.changed=s(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 s=0;s<this.option.values.length;s+=t)this.filterValues.push(this.option.values.slice(s,s+t).reduce(((t,s)=>(t.to=s.to,t.count+=s.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 s=this.minPrice?1*+this.minPrice:null,e=this.maxPrice?1*+this.maxPrice:null;this.maxPrice||(this.maxPrice=""),this.isMin?this.minInputValidation(s):(this.minPrice||(this.minPrice=0),this.maxInputValidation(e)),this.isReady&&this.changed.emit({event:t,option:this.option,value:{max:this.maxPrice,min:this.minPrice}})}handleMinMaxPrice(t,s){this.minPrice=s.from,this.maxPrice="*"!==s.to?s.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 s=t.target.value;this.minPrice=""===s?0:s}handleMaxPrice(t){this.isMin=!1;const s=t.target.value;this.maxPrice=void 0===s?"":s}render(){return e(i,{key:"b3292086c1beb0d5df51712839daabb25dad2658"},this.filterValues.map(((t,s)=>e("label",{class:"s-filters-label",htmlFor:`${this.option.key}-${s}`,key:s},e("input",{id:`${this.option.key}-${s}`,name:"price",type:"radio",checked:this.isChecked(t),class:"s-filters-radio",onChange:s=>this.handleMinMaxPrice(s,t)}),e("span",{innerHTML:this.getPriceLabel(t)})))),e("div",{key:"d987fea90281b884a1db631f0f3f90a53353ce65",class:"flex justify-center items-center"},e("div",{key:"17aec2dff1433bae4f8d06679a86af7d41019a7d",class:"relative max-w-xl w-full"},e("div",{key:"fad234797e87821b0df33a5275a3c4bd3ea75fa9",class:"s-price-range-inputs"},e("div",{key:"7099b01a40271f0757149260a560d038763b0322",class:"s-price-range-relative"},e("div",{key:"44178266832f05eaf0ca33aa0a2f6436da846100",class:"s-price-range-currency"}," ",salla.config.currency().symbol),e("input",{key:"70cda3b471c177958870527a4f0008cf951a381a",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"})),e("div",{key:"be3f732538589997f52d2340c72b16e419406666",class:"s-price-range-gray-text"}," -"),e("div",{key:"5de9d9ba6e5925da36c3483b82167894e49b0088",class:"s-price-range-relative"},e("div",{key:"903371ebc01237214fc143447789dd8011f86045",class:"s-price-range-currency"}," ",salla.config.currency().symbol),e("input",{key:"88dbf3b5930adb70fc16fc2a95d471185fcf760a",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"})),e("salla-button",{key:"8b10d455ca665e4a0df80fa3a6c05b3501e769f4",color:"gray",shape:"icon",size:"small",fill:"outline",onClick:t=>this.changedEventHandler(t)},e("span",{key:"8935d722de14843a1efaa4b784e5aa487e80be77",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 s,h as e,H as i}from"./p-DtunYVY8.js";import{a}from"./p-BedNk7k1.js";const l=class{constructor(e){t(this,e),this.changed=s(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 s=0;s<this.option.values.length;s+=t)this.filterValues.push(this.option.values.slice(s,s+t).reduce(((t,s)=>(t.to=s.to,t.count+=s.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 s=this.minPrice?1*+this.minPrice:null,e=this.maxPrice?1*+this.maxPrice:null;this.maxPrice||(this.maxPrice=""),this.isMin?this.minInputValidation(s):(this.minPrice||(this.minPrice=0),this.maxInputValidation(e)),this.isReady&&this.changed.emit({event:t,option:this.option,value:{max:this.maxPrice,min:this.minPrice}})}handleMinMaxPrice(t,s){this.minPrice=s.from,this.maxPrice="*"!==s.to?s.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 s=t.target.value;this.minPrice=""===s?0:s}handleMaxPrice(t){this.isMin=!1;const s=t.target.value;this.maxPrice=void 0===s?"":s}render(){return e(i,{key:"b3292086c1beb0d5df51712839daabb25dad2658"},this.filterValues.map(((t,s)=>e("label",{class:"s-filters-label",htmlFor:`${this.option.key}-${s}`,key:s},e("input",{id:`${this.option.key}-${s}`,name:"price",type:"radio",checked:this.isChecked(t),class:"s-filters-radio",onChange:s=>this.handleMinMaxPrice(s,t)}),e("span",{innerHTML:this.getPriceLabel(t)})))),e("div",{key:"d987fea90281b884a1db631f0f3f90a53353ce65",class:"flex justify-center items-center"},e("div",{key:"17aec2dff1433bae4f8d06679a86af7d41019a7d",class:"relative max-w-xl w-full"},e("div",{key:"fad234797e87821b0df33a5275a3c4bd3ea75fa9",class:"s-price-range-inputs"},e("div",{key:"7099b01a40271f0757149260a560d038763b0322",class:"s-price-range-relative"},e("div",{key:"44178266832f05eaf0ca33aa0a2f6436da846100",class:"s-price-range-currency"}," ",salla.config.currency().symbol),e("input",{key:"70cda3b471c177958870527a4f0008cf951a381a",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"})),e("div",{key:"be3f732538589997f52d2340c72b16e419406666",class:"s-price-range-gray-text"}," -"),e("div",{key:"5de9d9ba6e5925da36c3483b82167894e49b0088",class:"s-price-range-relative"},e("div",{key:"903371ebc01237214fc143447789dd8011f86045",class:"s-price-range-currency"}," ",salla.config.currency().symbol),e("input",{key:"88dbf3b5930adb70fc16fc2a95d471185fcf760a",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"})),e("salla-button",{key:"8b10d455ca665e4a0df80fa3a6c05b3501e769f4",color:"gray",shape:"icon",size:"small",fill:"outline",onClick:t=>this.changedEventHandler(t)},e("span",{key:"8935d722de14843a1efaa4b784e5aa487e80be77",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 t,h as s,H as e}from"./p-DNtvpIPH.js";const r=class{constructor(s){t(this,s),this.parsedSections=[]}parseProducts(t){let s=[];if("string"==typeof t)try{const e=JSON.parse(t);s=this.extractSections(e)}catch(e){console.error("Invalid JSON passed to bundleSections prop:",t),s=[]}else t&&(s=this.extractSections(t));this.parsedSections=s}extractSections(t){return t.bundle&&t.bundle.sections&&Array.isArray(t.bundle.sections)?t.bundle.sections:Array.isArray(t)?t:t.sections&&Array.isArray(t.sections)?t.sections:(console.warn("No valid sections found in data:",t),[])}isCartPage(){return salla.url.is_page("cart")}renderCartPage(){return s("salla-multiple-bundle-product-cart",{sections:this.parsedSections})}renderDetailsPage(){return s("salla-multiple-bundle-product-details",{sections:this.parsedSections})}componentWillLoad(){this.parseProducts(this.bundleSections)}render(){return s(e,{key:"abf18a8e3e255a7615ffd6cab7f10a1b4ababdea",class:"s-multiple-bundle-product-wrapper"},this.isCartPage()?this.renderCartPage():this.renderDetailsPage())}static get watchers(){return{bundleSections:["parseProducts"]}}};r.style=":host{display:block}";export{r as salla_multiple_bundle_product}
4
+ import{r as t,h as s,H as e}from"./p-DtunYVY8.js";const r=class{constructor(s){t(this,s),this.parsedSections=[]}parseProducts(t){let s=[];if("string"==typeof t)try{const e=JSON.parse(t);s=this.extractSections(e)}catch(e){console.error("Invalid JSON passed to bundleSections prop:",t),s=[]}else t&&(s=this.extractSections(t));this.parsedSections=s}extractSections(t){return t.bundle&&t.bundle.sections&&Array.isArray(t.bundle.sections)?t.bundle.sections:Array.isArray(t)?t:t.sections&&Array.isArray(t.sections)?t.sections:(console.warn("No valid sections found in data:",t),[])}isCartPage(){return salla.url.is_page("cart")}renderCartPage(){return s("salla-multiple-bundle-product-cart",{sections:this.parsedSections})}renderDetailsPage(){return s("salla-multiple-bundle-product-details",{sections:this.parsedSections})}componentWillLoad(){this.parseProducts(this.bundleSections)}render(){return s(e,{key:"abf18a8e3e255a7615ffd6cab7f10a1b4ababdea",class:"s-multiple-bundle-product-wrapper"},this.isCartPage()?this.renderCartPage():this.renderDetailsPage())}static get watchers(){return{bundleSections:["parseProducts"]}}};r.style=":host{display:block}";export{r as salla_multiple_bundle_product}
@@ -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}from"./p-DNtvpIPH.js";const a=class{constructor(e){s(this,e),this.type="normal",this.width="100%",this.height="100%"}render(){return e(t,{key:"bbd3b59181da4c7c97a2fbf862eedebbedbe0634",class:"s-skeleton-wrapper",style:{width:this.width,height:this.height}},e("div",{key:"137814e704aabda9931441f744bac595dd506d0e",class:{"s-skeleton-item":!0,"s-skeleton-item-circular":"circle"==this.type}}," "))}};a.style=":host{display:block}";export{a as salla_skeleton}
4
+ import{r as s,h as e,H as t}from"./p-DtunYVY8.js";const a=class{constructor(e){s(this,e),this.type="normal",this.width="100%",this.height="100%"}render(){return e(t,{key:"bbd3b59181da4c7c97a2fbf862eedebbedbe0634",class:"s-skeleton-wrapper",style:{width:this.width,height:this.height}},e("div",{key:"137814e704aabda9931441f744bac595dd506d0e",class:{"s-skeleton-item":!0,"s-skeleton-item-circular":"circle"==this.type}}," "))}};a.style=":host{display:block}";export{a as salla_skeleton}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as e,a as t}from"./p-DNtvpIPH.js";var o,i;!function(s){s.ProductDetail="product.single",s.Cart="cart"}(o||(o={})),function(s){s.Conditional="conditional",s.PercentageOrFixed="fixed",s.DiscountsTable="discounts_table",s.Bank="bank",s.BuyXGetY="buy_x_get_y",s.SpecialPrice="special_price",s.Percentage="percentage",s.FixedAmount="fixed_amount"}(i||(i={}));const r=class{constructor(e){s(this,e),this.productCardComponent="salla-product-card",this.offersList=[],this.canRender=!1,this.showOffer=salla.config.get("store.settings.product.show_special_offers"),this.showAllOffersModal=!1,this.showProductsModal=!1,this.selectedOfferProducts=[],this.collapsedOffers={},this.expandedCategories={},this.productsLoaded=!1,this.offer_with_price_text=salla.lang.get("pages.offer.with_price",{price:""}),this.with_discount_text=salla.lang.get("pages.products.with_a_discount"),this.product_discount_text=salla.lang.get("pages.products.discount"),this.special_offer_text=salla.lang.get("pages.products.special_offer"),this.buy_quantity_text=s=>salla.lang.get("pages.offer.buy_quantity",{quantity:s}),this.products_link_text=salla.lang.get("pages.offer.included_products","المنتجات المشمولة"),this.min_spend_text=(s,e)=>salla.lang.get("pages.offer.min_spend_amount",{amount:s,currency:e},`بحد أدنى ${s} ${e} من مبلغ الشراء`),this.min_items_text=s=>salla.lang.get("pages.offer.min_items",{items:s},`بحد أدنى ${s} منتجات`),this.product_text=salla.lang.get("common.elements.product","منتج"),salla.lang.onLoaded((()=>{this.offer_with_price_text=salla.lang.get("pages.offer.with_price"),this.with_discount_text=salla.lang.get("pages.products.with_a_discount"),this.product_discount_text=salla.lang.get("pages.products.discount"),this.special_offer_text=salla.lang.get("pages.products.special_offer"),this.buy_quantity_text(0),this.products_link_text=salla.lang.get("pages.offer.included_products","المنتجات المشمولة"),this.min_spend_text=(s,e)=>salla.lang.get("pages.offer.min_spend_amount",{amount:s,currency:e},`بحد أدنى ${s} ${e} من مبلغ الشراء`),this.min_items_text=s=>salla.lang.get("pages.offer.min_items",{items:s},`بحد أدنى ${s} منتجات`),this.product_text=salla.lang.get("common.elements.product","منتج")})),salla.onReady((()=>{this.currentPage=salla.config.get("page.slug");const s=salla.config.get("currencies")||{},e=salla.config.get("user.currency_code");this.userCurrency=s[e]||{symbol:"",code:e||"SAR",name:""}}))}async getEndpointByPageName(){return this.currentPage==o.Cart?`offers/cart/${await Salla.cart.getCurrentCartId()}`:this.currentPage==o.ProductDetail?`offers/product/${salla.config.get("page.id")}`:"offers"}emitPromotionViewed(){if(!(this.offersList.length&&this.canRender&&this.showOffer))return;const s=this.offersList.slice(0,5).map(((s,e)=>({id:s.id,name:s.title,creative:s.description||"",position:e+1})));salla.event.emit("salla::offer.promotion.viewed",s)}emitPromotionClicked(s,e=1){if(!(this.offersList.length&&this.canRender&&this.showOffer))return;const t=s||this.offersList[0];salla.event.emit("salla::offer.promotion.clicked",[{id:t.id,name:t.title,creative:t.description||"",position:e}])}componentWillLoad(){return this.hasCustomComponent=!!customElements.get(this.productCardComponent),new Promise((s=>salla.onReady(s))).then((()=>{if(this.showOffer=!salla.url.is_page("product.single")||salla.config.get("store.settings.product.show_special_offers"),!this.showOffer)throw new Error("Merchant disabled showing the offers on product page")})).then((async()=>salla.api.request(await this.getEndpointByPageName()))).then((async s=>{if(!(this.offersList=s.data).length)throw new Error("salla-offers:: There is no offers!");if(this.offersList=this.offersList.filter((s=>[i.SpecialPrice,i.Bank,i.BuyXGetY,i.DiscountsTable,i.PercentageOrFixed,i.Percentage,i.FixedAmount].includes(s.type))),!this.offersList.length)throw new Error("salla-offers:: No supported offer types found!");let e=null;this.offersList.some((s=>{const e=s.details;return"category"===e.apply_to&&e.targets||"categories"===e.apply_to&&e.targets||s.type===i.BuyXGetY&&("categories"===e.get?.source||"category"===e.get?.source)}))&&(e=(await salla.product.api.categories()).data);const t=new Set;for(const s of this.offersList){const e=s.details;"product"!==e.apply_to&&"products"!==e.apply_to||!e.targets||e.targets.forEach((s=>t.add(s))),s.type===i.BuyXGetY&&"products"===e.get?.source&&e.get?.source_value&&e.get.source_value.forEach((s=>t.add(s))),s.type!==i.BuyXGetY||"products"!==e.buy?.source&&"product"!==e.buy?.source||!e.buy?.source_value||e.buy.source_value.forEach((s=>t.add(s)))}let o={};if(t.size>0)try{const s=await salla.product.api.fetch({source:"selected",source_value:Array.from(t)});o=Object.fromEntries(s.data.map((s=>[s.id,s])))}catch(s){o={}}for(const s of this.offersList){const t=s.details;if(("category"===t.apply_to&&t.targets||"categories"===t.apply_to&&t.targets)&&e&&(t.categories=this.findCategories(e,t.targets)),"product"!==t.apply_to&&"products"!==t.apply_to||!t.targets||(t.products=t.targets.map((s=>o[s])).filter(Boolean)),"brand"===t.apply_to&&t.targets&&(t.brands=t.targets),"tag"===t.apply_to&&t.targets&&(t.tags=t.targets),s.type===i.BuyXGetY&&t.get){const s=t.get;"products"===s.source&&s.source_value?s.products=s.source_value.map((s=>o[s])).filter(Boolean):("categories"===s.source||"category"===s.source)&&e&&s.source_value&&(s.categories=this.findCategories(e,s.source_value),t.categories=s.categories)}if(s.type===i.BuyXGetY&&t.buy){const s=t.buy;"products"!==s.source&&"product"!==s.source||!s.source_value||(s.products=s.source_value.map((s=>o[s])).filter(Boolean))}}return this.offersList})).then((()=>{this.canRender=!0})).catch((s=>{salla.logger.warn(s)}))}componentDidLoad(){let s=this.host.querySelector(".s-slider-block__title-nav");s?.classList.add("s-offer-bank-payment-nav"),this.emitPromotionViewed()}findCategories(s,e){let t=[];for(const o of s)e.includes(o.id_||o.id)&&t.push(o),o.sub_categories?.length>0&&(t=t.concat(this.findCategories(o.sub_categories,e)));return t}render(){if(!this.offersList.length||!this.canRender||!this.showOffer)return null;const s=salla.lang.get("pages.offer.offers_title","عروض المنتج"),t=salla.lang.get("pages.offer.offers_subtitle","احصل على المنتج بسعر مخفض مع أفضل العروض");return[e("div",{class:"s-offer-wrapper"},e("salla-slider",{type:"carousel",id:"offers-slider","block-title":s,"block-subTitle":t,"show-controls":this.offersList.length>1},e("div",{slot:"items"},this.offersList.slice(0,5).map(((s,e)=>this.renderOfferCard(s,e+1))),this.offersList.length>5&&this.renderShowMoreCard()))),this.renderAllOffersModal(),this.renderProductsModal()]}renderShowMoreCard(){return e("div",{class:"s-offer-slide-one-fourth swiper-slide",onClick:s=>{s.preventDefault(),s.stopPropagation(),this.openAllOffersModal()}},e("div",{class:"s-offer-card s-offer-show-more-card"},e("i",{class:"sicon-add s-offer-show-more-icon"}),e("h3",{class:"s-offer-show-more-title"},salla.lang.get("pages.offer.show_more_offers","عرض المزيد من العروض"))))}openAllOffersModal(){this.showAllOffersModal=!0}closeAllOffersModal(){this.showAllOffersModal=!1}closeProductsModal(){this.showProductsModal=!1,this.selectedOfferProducts=[],this.productsLoaded=!1}handleAccordionToggle(s,e){this.collapsedOffers={...this.collapsedOffers,[s]:e}}getOfferProducts(s){const e=s.details;return e.products&&e.products.length>0?e.products:s.type===i.BuyXGetY&&e.get?.products?e.get.products:[]}renderProductsLinkForModalCard(s,t){const o=this.getOfferProducts(s);return o&&0!==o.length?e("div",{class:"s-offer-products-link",onClick:s=>{s.stopPropagation(),this.selectedOfferProducts=o,this.showProductsModal=!0}},e("span",{class:"s-offer-products-link-text"},this.products_link_text),t&&e("i",{class:"sicon-keyboard_arrow_down s-offer-products-link-icon"})):null}renderAllOffersModal(){return e("salla-drawer",{visible:this.showAllOffersModal,position:"right",width:"md","no-padding":!0,"drawer-title":salla.lang.get("pages.offer.all_offers_title","جميع العروض"),onDrawerVisibilityChanged:s=>!s.detail&&this.closeAllOffersModal()},e("div",{class:"s-offer-drawer-content"},this.offersList.map(((s,e)=>this.renderModalOfferCard(s,e+1)))))}renderProductsModal(){return e("salla-drawer",{visible:this.showProductsModal,width:"md",position:"right","no-padding":!0,"drawer-title":this.products_link_text,onDrawerVisibilityChanged:s=>!s.detail&&this.closeProductsModal()},e("div",{class:"s-offer-products-drawer-content"},this.selectedOfferProducts?.length>0?e("div",null,!this.productsLoaded&&e("div",{class:"flex items-center justify-center p-8"},e("salla-loading",{size:"24"})),e("salla-products-list",{source:"selected","source-value":JSON.stringify(this.selectedOfferProducts.map((s=>s.id))),"product-card-component":this.productCardComponent,"horizontal-cards":!0,"compact-cards":!0,includes:["images"],onProductsFetched:()=>this.productsLoaded=!0})):e("div",{class:"p-4 text-center text-gray-500"},salla.lang.get("blocks.products.no_products_found","لا توجد منتجات"))))}renderModalOfferCard(s,t=1){const o=this.getOfferProducts(s),r=o&&o.length>0,a=!1!==this.collapsedOffers[s.id];return e("div",{class:"s-offer-drawer-card"},e("div",{class:"s-offer-card-main",onClick:()=>this.emitPromotionClicked(s,t)},e("div",{class:"s-offer-card-icon"},this.getOfferIcon(s.type)),e("div",{class:"s-offer-card-content"},e("h3",{class:"s-offer-card-title",title:s.title},s.title),s.description&&e("p",{class:"s-offer-card-description"},s.description),s.type===i.DiscountsTable?e("div",{class:"s-offer-card-details"},this.renderDiscountTableOfferContent(s)):s.type===i.PercentageOrFixed||s.type===i.Percentage||s.type===i.FixedAmount?e("div",{class:"s-offer-card-details"},this.renderPercentageOrFixedOfferContent(s),this.renderOfferCategories(s),this.renderOfferBrands(s),this.renderOfferTags(s)):e("div",{class:"s-offer-card-details"},this.renderOfferCategories(s),this.renderOfferBrands(s),this.renderOfferTags(s)))),r&&e("salla-accordion",{collapsed:a,collapsible:!0,size:"sm",onClick:s=>s.stopPropagation(),onAccordionToggle:e=>this.handleAccordionToggle(s.id,e.detail.payload.collapsed)},e("salla-accordion-head",{collapsible:!0,collapsed:a},e("div",{slot:"title",class:"s-offer-products-thumbnails"},e("span",{class:"s-offer-products-title"},this.products_link_text,e("i",{class:`sicon-keyboard_arrow_${a?"down":"up"} s-offer-products-link-icon`})),e("div",{class:"s-offer-products-thumbnails-stack"},o.slice(0,3).map(((s,t)=>e("div",{class:"s-offer-product-thumbnail",style:{zIndex:`${t+1}`}},e("img",{src:s.thumbnail||s.image?.url||salla.url.cdn("images/s-empty.png"),alt:s.name})))),o.length>3&&e("div",{class:"s-offer-products-more-count",style:{zIndex:"7"}},"+",o.length-3)))),e("salla-accordion-body",null,e("div",{class:"s-offer-products-content"},e("salla-products-list",{source:"selected","source-value":JSON.stringify(o.map((s=>s.id))),"product-card-component":this.productCardComponent,"horizontal-cards":!0,"compact-cards":!0,includes:["images"]})))))}renderOfferCard(s,t=1){return e("div",{class:"s-offer-slide-one-fourth swiper-slide",onClick:()=>this.emitPromotionClicked(s,t)},e("div",{class:"s-offer-card"},e("div",{class:"s-offer-card-icon"},this.getOfferIcon(s.type)),e("div",{class:"s-offer-card-content"},e("h3",{class:"s-offer-card-title",title:s.title},s.title),s.description&&e("p",{class:"s-offer-card-description"},s.description),e("div",{class:"s-offer-card-details"},s.type===i.DiscountsTable?this.renderDiscountTableOfferContent(s):s.type===i.PercentageOrFixed||s.type===i.Percentage||s.type===i.FixedAmount?[this.renderPercentageOrFixedOfferContent(s),this.renderOfferCategories(s),this.renderOfferBrands(s),this.renderOfferTags(s)]:[this.renderOfferCategories(s),this.renderOfferBrands(s),this.renderOfferTags(s)],this.renderProductsLinkForModalCard(s,!1)))))}getOfferIcon(s){return e("i",{class:{[i.DiscountsTable]:"sicon-discount-calculator",[i.Bank]:"sicon-bank",[i.SpecialPrice]:"sicon-fire",[i.BuyXGetY]:"sicon-gift",[i.PercentageOrFixed]:"sicon-special-discount",[i.Percentage]:"sicon-special-discount",[i.FixedAmount]:"sicon-special-discount"}[s]||"sicon-discount"})}renderDiscountTableOfferContent(s){const t=s.details.discounts||[];return t.length?e("div",null,e("div",{class:"s-offer-card-description"},salla.lang.get("pages.offer.discount_table_subtitle","وفر اكتر بشراء منتجات أكثر")),e("table",{class:"s-offer-discount-table"},e("tbody",null,this.groupDiscountsByRows(t,3).map(((s,t)=>e("tr",{key:t},s.map(((s,t)=>e("td",{key:t},e("div",{class:"s-offer-discount-percentage"},s.percentage,"%"),e("div",{class:"s-offer-discount-condition"},this.formatDiscountCondition(s))))))))))):null}renderPercentageOrFixedOfferContent(s){const t=s.details;return t.discount_value||t.min_spend>0||t.min_items>0?e("div",{class:"s-offer-percentage-fixed-content"},t.min_spend>0&&e("div",{class:"s-offer-min-spend"},this.min_spend_text(t.min_spend,this.userCurrency?.symbol||"")),t.min_items>0&&e("div",{class:"s-offer-min-items"},this.min_items_text(t.min_items))):null}groupDiscountsByRows(s,e){const t=[];for(let o=0;o<s.length;o+=e)t.push(s.slice(o,o+e));return t}formatDiscountCondition(s){return s.discounted_amount?`${s.discounted_amount} ${this.userCurrency?.symbol||""}`:null!=s.quantity?this.buy_quantity_text(s.quantity):`1 ${this.product_text}`}renderOfferCategories(s){const t=s.details;let o=t.categories||[];if(s.type===i.BuyXGetY&&t.get?.categories&&(o=t.get.categories),!o.length)return null;const r=this.expandedCategories[s.id],a=o.length>3,l=r?o:o.slice(0,3);return e("div",{class:"s-offer-categories"},e("div",{class:"s-offer-categories-list"},l.map(((s,t)=>e("a",{key:t,class:"s-offer-category-item",href:s.url||salla.url.create("categories",s.id||s.id_)},s.name))),a&&e("span",{class:"s-offer-categories-toggle",onClick:e=>{e.preventDefault(),e.stopPropagation(),this.toggleCategoryExpansion(s.id)}},r?e("span",null,e("i",{class:"sicon-keyboard_arrow_up"})," ",salla.lang.get("common.elements.hide","إخفاء")):e("span",null,salla.lang.get("common.elements.show","عرض")," ","+"+(o.length-3)," ",e("i",{class:"sicon-keyboard_arrow_down"})))))}renderOfferBrands(s){const t=s.details.brands||[];if(!t.length)return null;const o=this.expandedCategories[s.id],i=t.length>3,r=o?t:t.slice(0,3);return e("div",{class:"s-offer-categories"},e("div",{class:"s-offer-categories-list"},r.map(((s,t)=>e("a",{key:t,class:"s-offer-category-item",href:s.url},s.name))),i&&e("span",{class:"s-offer-categories-toggle",onClick:e=>{e.preventDefault(),e.stopPropagation(),this.toggleCategoryExpansion(s.id)}},o?e("span",null,e("i",{class:"sicon-keyboard_arrow_up"})," ",salla.lang.get("common.elements.hide","إخفاء")):e("span",null,salla.lang.get("common.elements.show","عرض")," ","+"+(t.length-3)," ",e("i",{class:"sicon-keyboard_arrow_down"})))))}renderOfferTags(s){const t=s.details.tags||[];if(!t.length)return null;const o=this.expandedCategories[s.id],i=t.length>3,r=o?t:t.slice(0,3);return e("div",{class:"s-offer-categories"},e("div",{class:"s-offer-categories-list"},r.map(((s,t)=>e("a",{key:t,class:"s-offer-category-item",href:s.url||salla.url.create("tags",s.id)},s.name))),i&&e("span",{class:"s-offer-categories-toggle",onClick:e=>{e.preventDefault(),e.stopPropagation(),this.toggleCategoryExpansion(s.id)}},o?e("span",null,e("i",{class:"sicon-keyboard_arrow_up"})," ",salla.lang.get("common.elements.hide","إخفاء")):e("span",null,salla.lang.get("common.elements.show","عرض")," ","+"+(t.length-3)," ",e("i",{class:"sicon-keyboard_arrow_down"})))))}toggleCategoryExpansion(s){this.expandedCategories={...this.expandedCategories,[s]:!this.expandedCategories[s]}}get host(){return t(this)}};r.style=":host .s-drawer-close:where([dir=rtl],[dir=rtl] *){left:0}";export{r as salla_offer}
4
+ import{r as s,h as e,a as t}from"./p-DtunYVY8.js";var o,i;!function(s){s.ProductDetail="product.single",s.Cart="cart"}(o||(o={})),function(s){s.Conditional="conditional",s.PercentageOrFixed="fixed",s.DiscountsTable="discounts_table",s.Bank="bank",s.BuyXGetY="buy_x_get_y",s.SpecialPrice="special_price",s.Percentage="percentage",s.FixedAmount="fixed_amount"}(i||(i={}));const r=class{constructor(e){s(this,e),this.productCardComponent="salla-product-card",this.offersList=[],this.canRender=!1,this.showOffer=salla.config.get("store.settings.product.show_special_offers"),this.showAllOffersModal=!1,this.showProductsModal=!1,this.selectedOfferProducts=[],this.collapsedOffers={},this.expandedCategories={},this.productsLoaded=!1,this.offer_with_price_text=salla.lang.get("pages.offer.with_price",{price:""}),this.with_discount_text=salla.lang.get("pages.products.with_a_discount"),this.product_discount_text=salla.lang.get("pages.products.discount"),this.special_offer_text=salla.lang.get("pages.products.special_offer"),this.buy_quantity_text=s=>salla.lang.get("pages.offer.buy_quantity",{quantity:s}),this.products_link_text=salla.lang.get("pages.offer.included_products","المنتجات المشمولة"),this.min_spend_text=(s,e)=>salla.lang.get("pages.offer.min_spend_amount",{amount:s,currency:e},`بحد أدنى ${s} ${e} من مبلغ الشراء`),this.min_items_text=s=>salla.lang.get("pages.offer.min_items",{items:s},`بحد أدنى ${s} منتجات`),this.product_text=salla.lang.get("common.elements.product","منتج"),salla.lang.onLoaded((()=>{this.offer_with_price_text=salla.lang.get("pages.offer.with_price"),this.with_discount_text=salla.lang.get("pages.products.with_a_discount"),this.product_discount_text=salla.lang.get("pages.products.discount"),this.special_offer_text=salla.lang.get("pages.products.special_offer"),this.buy_quantity_text(0),this.products_link_text=salla.lang.get("pages.offer.included_products","المنتجات المشمولة"),this.min_spend_text=(s,e)=>salla.lang.get("pages.offer.min_spend_amount",{amount:s,currency:e},`بحد أدنى ${s} ${e} من مبلغ الشراء`),this.min_items_text=s=>salla.lang.get("pages.offer.min_items",{items:s},`بحد أدنى ${s} منتجات`),this.product_text=salla.lang.get("common.elements.product","منتج")})),salla.onReady((()=>{this.currentPage=salla.config.get("page.slug");const s=salla.config.get("currencies")||{},e=salla.config.get("user.currency_code");this.userCurrency=s[e]||{symbol:"",code:e||"SAR",name:""}}))}async getEndpointByPageName(){return this.currentPage==o.Cart?`offers/cart/${await Salla.cart.getCurrentCartId()}`:this.currentPage==o.ProductDetail?`offers/product/${salla.config.get("page.id")}`:"offers"}emitPromotionViewed(){if(!(this.offersList.length&&this.canRender&&this.showOffer))return;const s=this.offersList.slice(0,5).map(((s,e)=>({id:s.id,name:s.title,creative:s.description||"",position:e+1})));salla.event.emit("salla::offer.promotion.viewed",s)}emitPromotionClicked(s,e=1){if(!(this.offersList.length&&this.canRender&&this.showOffer))return;const t=s||this.offersList[0];salla.event.emit("salla::offer.promotion.clicked",[{id:t.id,name:t.title,creative:t.description||"",position:e}])}componentWillLoad(){return this.hasCustomComponent=!!customElements.get(this.productCardComponent),new Promise((s=>salla.onReady(s))).then((()=>{if(this.showOffer=!salla.url.is_page("product.single")||salla.config.get("store.settings.product.show_special_offers"),!this.showOffer)throw new Error("Merchant disabled showing the offers on product page")})).then((async()=>salla.api.request(await this.getEndpointByPageName()))).then((async s=>{if(!(this.offersList=s.data).length)throw new Error("salla-offers:: There is no offers!");if(this.offersList=this.offersList.filter((s=>[i.SpecialPrice,i.Bank,i.BuyXGetY,i.DiscountsTable,i.PercentageOrFixed,i.Percentage,i.FixedAmount].includes(s.type))),!this.offersList.length)throw new Error("salla-offers:: No supported offer types found!");let e=null;this.offersList.some((s=>{const e=s.details;return"category"===e.apply_to&&e.targets||"categories"===e.apply_to&&e.targets||s.type===i.BuyXGetY&&("categories"===e.get?.source||"category"===e.get?.source)}))&&(e=(await salla.product.api.categories()).data);const t=new Set;for(const s of this.offersList){const e=s.details;"product"!==e.apply_to&&"products"!==e.apply_to||!e.targets||e.targets.forEach((s=>t.add(s))),s.type===i.BuyXGetY&&"products"===e.get?.source&&e.get?.source_value&&e.get.source_value.forEach((s=>t.add(s))),s.type!==i.BuyXGetY||"products"!==e.buy?.source&&"product"!==e.buy?.source||!e.buy?.source_value||e.buy.source_value.forEach((s=>t.add(s)))}let o={};if(t.size>0)try{const s=await salla.product.api.fetch({source:"selected",source_value:Array.from(t)});o=Object.fromEntries(s.data.map((s=>[s.id,s])))}catch(s){o={}}for(const s of this.offersList){const t=s.details;if(("category"===t.apply_to&&t.targets||"categories"===t.apply_to&&t.targets)&&e&&(t.categories=this.findCategories(e,t.targets)),"product"!==t.apply_to&&"products"!==t.apply_to||!t.targets||(t.products=t.targets.map((s=>o[s])).filter(Boolean)),"brand"===t.apply_to&&t.targets&&(t.brands=t.targets),"tag"===t.apply_to&&t.targets&&(t.tags=t.targets),s.type===i.BuyXGetY&&t.get){const s=t.get;"products"===s.source&&s.source_value?s.products=s.source_value.map((s=>o[s])).filter(Boolean):("categories"===s.source||"category"===s.source)&&e&&s.source_value&&(s.categories=this.findCategories(e,s.source_value),t.categories=s.categories)}if(s.type===i.BuyXGetY&&t.buy){const s=t.buy;"products"!==s.source&&"product"!==s.source||!s.source_value||(s.products=s.source_value.map((s=>o[s])).filter(Boolean))}}return this.offersList})).then((()=>{this.canRender=!0})).catch((s=>{salla.logger.warn(s)}))}componentDidLoad(){let s=this.host.querySelector(".s-slider-block__title-nav");s?.classList.add("s-offer-bank-payment-nav"),this.emitPromotionViewed()}findCategories(s,e){let t=[];for(const o of s)e.includes(o.id_||o.id)&&t.push(o),o.sub_categories?.length>0&&(t=t.concat(this.findCategories(o.sub_categories,e)));return t}render(){if(!this.offersList.length||!this.canRender||!this.showOffer)return null;const s=salla.lang.get("pages.offer.offers_title","عروض المنتج"),t=salla.lang.get("pages.offer.offers_subtitle","احصل على المنتج بسعر مخفض مع أفضل العروض");return[e("div",{class:"s-offer-wrapper"},e("salla-slider",{type:"carousel",id:"offers-slider","block-title":s,"block-subTitle":t,"show-controls":this.offersList.length>1},e("div",{slot:"items"},this.offersList.slice(0,5).map(((s,e)=>this.renderOfferCard(s,e+1))),this.offersList.length>5&&this.renderShowMoreCard()))),this.renderAllOffersModal(),this.renderProductsModal()]}renderShowMoreCard(){return e("div",{class:"s-offer-slide-one-fourth swiper-slide",onClick:s=>{s.preventDefault(),s.stopPropagation(),this.openAllOffersModal()}},e("div",{class:"s-offer-card s-offer-show-more-card"},e("i",{class:"sicon-add s-offer-show-more-icon"}),e("h3",{class:"s-offer-show-more-title"},salla.lang.get("pages.offer.show_more_offers","عرض المزيد من العروض"))))}openAllOffersModal(){this.showAllOffersModal=!0}closeAllOffersModal(){this.showAllOffersModal=!1}closeProductsModal(){this.showProductsModal=!1,this.selectedOfferProducts=[],this.productsLoaded=!1}handleAccordionToggle(s,e){this.collapsedOffers={...this.collapsedOffers,[s]:e}}getOfferProducts(s){const e=s.details;return e.products&&e.products.length>0?e.products:s.type===i.BuyXGetY&&e.get?.products?e.get.products:[]}renderProductsLinkForModalCard(s,t){const o=this.getOfferProducts(s);return o&&0!==o.length?e("div",{class:"s-offer-products-link",onClick:s=>{s.stopPropagation(),this.selectedOfferProducts=o,this.showProductsModal=!0}},e("span",{class:"s-offer-products-link-text"},this.products_link_text),t&&e("i",{class:"sicon-keyboard_arrow_down s-offer-products-link-icon"})):null}renderAllOffersModal(){return e("salla-drawer",{visible:this.showAllOffersModal,position:"right",width:"md","no-padding":!0,"drawer-title":salla.lang.get("pages.offer.all_offers_title","جميع العروض"),onDrawerVisibilityChanged:s=>!s.detail&&this.closeAllOffersModal()},e("div",{class:"s-offer-drawer-content"},this.offersList.map(((s,e)=>this.renderModalOfferCard(s,e+1)))))}renderProductsModal(){return e("salla-drawer",{visible:this.showProductsModal,width:"md",position:"right","no-padding":!0,"drawer-title":this.products_link_text,onDrawerVisibilityChanged:s=>!s.detail&&this.closeProductsModal()},e("div",{class:"s-offer-products-drawer-content"},this.selectedOfferProducts?.length>0?e("div",null,!this.productsLoaded&&e("div",{class:"flex items-center justify-center p-8"},e("salla-loading",{size:"24"})),e("salla-products-list",{source:"selected","source-value":JSON.stringify(this.selectedOfferProducts.map((s=>s.id))),"product-card-component":this.productCardComponent,"horizontal-cards":!0,"compact-cards":!0,includes:["images"],onProductsFetched:()=>this.productsLoaded=!0})):e("div",{class:"p-4 text-center text-gray-500"},salla.lang.get("blocks.products.no_products_found","لا توجد منتجات"))))}renderModalOfferCard(s,t=1){const o=this.getOfferProducts(s),r=o&&o.length>0,a=!1!==this.collapsedOffers[s.id];return e("div",{class:"s-offer-drawer-card"},e("div",{class:"s-offer-card-main",onClick:()=>this.emitPromotionClicked(s,t)},e("div",{class:"s-offer-card-icon"},this.getOfferIcon(s.type)),e("div",{class:"s-offer-card-content"},e("h3",{class:"s-offer-card-title",title:s.title},s.title),s.description&&e("p",{class:"s-offer-card-description"},s.description),s.type===i.DiscountsTable?e("div",{class:"s-offer-card-details"},this.renderDiscountTableOfferContent(s)):s.type===i.PercentageOrFixed||s.type===i.Percentage||s.type===i.FixedAmount?e("div",{class:"s-offer-card-details"},this.renderPercentageOrFixedOfferContent(s),this.renderOfferCategories(s),this.renderOfferBrands(s),this.renderOfferTags(s)):e("div",{class:"s-offer-card-details"},this.renderOfferCategories(s),this.renderOfferBrands(s),this.renderOfferTags(s)))),r&&e("salla-accordion",{collapsed:a,collapsible:!0,size:"sm",onClick:s=>s.stopPropagation(),onAccordionToggle:e=>this.handleAccordionToggle(s.id,e.detail.payload.collapsed)},e("salla-accordion-head",{collapsible:!0,collapsed:a},e("div",{slot:"title",class:"s-offer-products-thumbnails"},e("span",{class:"s-offer-products-title"},this.products_link_text,e("i",{class:`sicon-keyboard_arrow_${a?"down":"up"} s-offer-products-link-icon`})),e("div",{class:"s-offer-products-thumbnails-stack"},o.slice(0,3).map(((s,t)=>e("div",{class:"s-offer-product-thumbnail",style:{zIndex:`${t+1}`}},e("img",{src:s.thumbnail||s.image?.url||salla.url.cdn("images/s-empty.png"),alt:s.name})))),o.length>3&&e("div",{class:"s-offer-products-more-count",style:{zIndex:"7"}},"+",o.length-3)))),e("salla-accordion-body",null,e("div",{class:"s-offer-products-content"},e("salla-products-list",{source:"selected","source-value":JSON.stringify(o.map((s=>s.id))),"product-card-component":this.productCardComponent,"horizontal-cards":!0,"compact-cards":!0,includes:["images"]})))))}renderOfferCard(s,t=1){return e("div",{class:"s-offer-slide-one-fourth swiper-slide",onClick:()=>this.emitPromotionClicked(s,t)},e("div",{class:"s-offer-card"},e("div",{class:"s-offer-card-icon"},this.getOfferIcon(s.type)),e("div",{class:"s-offer-card-content"},e("h3",{class:"s-offer-card-title",title:s.title},s.title),s.description&&e("p",{class:"s-offer-card-description"},s.description),e("div",{class:"s-offer-card-details"},s.type===i.DiscountsTable?this.renderDiscountTableOfferContent(s):s.type===i.PercentageOrFixed||s.type===i.Percentage||s.type===i.FixedAmount?[this.renderPercentageOrFixedOfferContent(s),this.renderOfferCategories(s),this.renderOfferBrands(s),this.renderOfferTags(s)]:[this.renderOfferCategories(s),this.renderOfferBrands(s),this.renderOfferTags(s)],this.renderProductsLinkForModalCard(s,!1)))))}getOfferIcon(s){return e("i",{class:{[i.DiscountsTable]:"sicon-discount-calculator",[i.Bank]:"sicon-bank",[i.SpecialPrice]:"sicon-fire",[i.BuyXGetY]:"sicon-gift",[i.PercentageOrFixed]:"sicon-special-discount",[i.Percentage]:"sicon-special-discount",[i.FixedAmount]:"sicon-special-discount"}[s]||"sicon-discount"})}renderDiscountTableOfferContent(s){const t=s.details.discounts||[];return t.length?e("div",null,e("div",{class:"s-offer-card-description"},salla.lang.get("pages.offer.discount_table_subtitle","وفر اكتر بشراء منتجات أكثر")),e("table",{class:"s-offer-discount-table"},e("tbody",null,this.groupDiscountsByRows(t,3).map(((s,t)=>e("tr",{key:t},s.map(((s,t)=>e("td",{key:t},e("div",{class:"s-offer-discount-percentage"},s.percentage,"%"),e("div",{class:"s-offer-discount-condition"},this.formatDiscountCondition(s))))))))))):null}renderPercentageOrFixedOfferContent(s){const t=s.details;return t.discount_value||t.min_spend>0||t.min_items>0?e("div",{class:"s-offer-percentage-fixed-content"},t.min_spend>0&&e("div",{class:"s-offer-min-spend"},this.min_spend_text(t.min_spend,this.userCurrency?.symbol||"")),t.min_items>0&&e("div",{class:"s-offer-min-items"},this.min_items_text(t.min_items))):null}groupDiscountsByRows(s,e){const t=[];for(let o=0;o<s.length;o+=e)t.push(s.slice(o,o+e));return t}formatDiscountCondition(s){return s.discounted_amount?`${s.discounted_amount} ${this.userCurrency?.symbol||""}`:null!=s.quantity?this.buy_quantity_text(s.quantity):`1 ${this.product_text}`}renderOfferCategories(s){const t=s.details;let o=t.categories||[];if(s.type===i.BuyXGetY&&t.get?.categories&&(o=t.get.categories),!o.length)return null;const r=this.expandedCategories[s.id],a=o.length>3,l=r?o:o.slice(0,3);return e("div",{class:"s-offer-categories"},e("div",{class:"s-offer-categories-list"},l.map(((s,t)=>e("a",{key:t,class:"s-offer-category-item",href:s.url||salla.url.create("categories",s.id||s.id_)},s.name))),a&&e("span",{class:"s-offer-categories-toggle",onClick:e=>{e.preventDefault(),e.stopPropagation(),this.toggleCategoryExpansion(s.id)}},r?e("span",null,e("i",{class:"sicon-keyboard_arrow_up"})," ",salla.lang.get("common.elements.hide","إخفاء")):e("span",null,salla.lang.get("common.elements.show","عرض")," ","+"+(o.length-3)," ",e("i",{class:"sicon-keyboard_arrow_down"})))))}renderOfferBrands(s){const t=s.details.brands||[];if(!t.length)return null;const o=this.expandedCategories[s.id],i=t.length>3,r=o?t:t.slice(0,3);return e("div",{class:"s-offer-categories"},e("div",{class:"s-offer-categories-list"},r.map(((s,t)=>e("a",{key:t,class:"s-offer-category-item",href:s.url},s.name))),i&&e("span",{class:"s-offer-categories-toggle",onClick:e=>{e.preventDefault(),e.stopPropagation(),this.toggleCategoryExpansion(s.id)}},o?e("span",null,e("i",{class:"sicon-keyboard_arrow_up"})," ",salla.lang.get("common.elements.hide","إخفاء")):e("span",null,salla.lang.get("common.elements.show","عرض")," ","+"+(t.length-3)," ",e("i",{class:"sicon-keyboard_arrow_down"})))))}renderOfferTags(s){const t=s.details.tags||[];if(!t.length)return null;const o=this.expandedCategories[s.id],i=t.length>3,r=o?t:t.slice(0,3);return e("div",{class:"s-offer-categories"},e("div",{class:"s-offer-categories-list"},r.map(((s,t)=>e("a",{key:t,class:"s-offer-category-item",href:s.url||salla.url.create("tags",s.id)},s.name))),i&&e("span",{class:"s-offer-categories-toggle",onClick:e=>{e.preventDefault(),e.stopPropagation(),this.toggleCategoryExpansion(s.id)}},o?e("span",null,e("i",{class:"sicon-keyboard_arrow_up"})," ",salla.lang.get("common.elements.hide","إخفاء")):e("span",null,salla.lang.get("common.elements.show","عرض")," ","+"+(t.length-3)," ",e("i",{class:"sicon-keyboard_arrow_down"})))))}toggleCategoryExpansion(s){this.expandedCategories={...this.expandedCategories,[s]:!this.expandedCategories[s]}}get host(){return t(this)}};r.style=":host .s-drawer-close:where([dir=rtl],[dir=rtl] *){left:0}";export{r as salla_offer}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,h as s,H as a}from"./p-DNtvpIPH.js";const l=class{constructor(s){t(this,s),this.order=null,this.loading=!0}async componentWillLoad(){await salla.onReady(),await this.loadOrder()}async onOrderIdChange(){this.loading=!0,this.order=null,await this.loadOrder()}get paymentUrl(){return this.order?.customer_editing?.payment_url}async loadOrder(){const t=this.orderId||salla.config.get("page.id");if(t)try{const s=await salla.order.api.getDetails(t);this.order=s?.data??s??null}catch(t){salla.logger?.warn?.("[salla-edit-order-button] failed to fetch order details",t),this.order=null}finally{this.loading=!1}else this.loading=!1}renderEditButton(){return s("salla-count-down",{prefixText:salla.lang.getWithDefault("pages.orders.edit_within","يمكنك التعديل خلال"),buttonHref:this.order?.edit_url,buttonText:salla.lang.getWithDefault("pages.orders.edit_order","تعديل الطلب"),buttonIcon:"sicon-edit",date:this.order?.editable_until,horizontal:!0,autoSegments:!0,withButton:!0,labeled:!1,size:"sm",color:"primary"})}render(){return this.loading||!this.order?null:this.order?.is_editable?s(a,null,this.renderEditButton()):this.paymentUrl?s(a,null,s("salla-button",{href:this.paymentUrl,color:"primary",size:"small"},s("i",{class:"sicon-wallet"}),salla.lang.getWithDefault("pages.orders.pay_difference","دفع فارق المبلغ"))):null}static get watchers(){return{orderId:["onOrderIdChange"]}}};l.style=":host{display:block}";export{l as salla_edit_order_button}
4
+ import{r as t,h as s,H as a}from"./p-DtunYVY8.js";const l=class{constructor(s){t(this,s),this.order=null,this.loading=!0}async componentWillLoad(){await salla.onReady(),await this.loadOrder()}async onOrderIdChange(){this.loading=!0,this.order=null,await this.loadOrder()}get paymentUrl(){return this.order?.customer_editing?.payment_url}async loadOrder(){const t=this.orderId||salla.config.get("page.id");if(t)try{const s=await salla.order.api.getDetails(t);this.order=s?.data??s??null}catch(t){salla.logger?.warn?.("[salla-edit-order-button] failed to fetch order details",t),this.order=null}finally{this.loading=!1}else this.loading=!1}renderEditButton(){return s("salla-count-down",{prefixText:salla.lang.getWithDefault("pages.orders.edit_within","يمكنك التعديل خلال"),buttonHref:this.order?.edit_url,buttonText:salla.lang.getWithDefault("pages.orders.edit_order","تعديل الطلب"),buttonIcon:"sicon-edit",date:this.order?.editable_until,horizontal:!0,autoSegments:!0,withButton:!0,labeled:!1,size:"sm",color:"primary"})}render(){return this.loading||!this.order?null:this.order?.is_editable?s(a,null,this.renderEditButton()):this.paymentUrl?s(a,null,s("salla-button",{href:this.paymentUrl,color:"primary",size:"small"},s("i",{class:"sicon-wallet"}),salla.lang.getWithDefault("pages.orders.pay_difference","دفع فارق المبلغ"))):null}static get watchers(){return{orderId:["onOrderIdChange"]}}};l.style=":host{display:block}";export{l as salla_edit_order_button}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as a,h as l,a as s}from"./p-DNtvpIPH.js";const i=class{constructor(l){a(this,l),this.languageNames={ar:"العربية",en:"English",sq:"shqip",hy:"հայերէն",bg:"български",zh:"汉语",hr:"hrvatski",cs:"čeština",da:"dansk",nl:"dutch",et:"eesti keel",fi:"suomen kieli",fr:"Français",de:"Deutsch",el:"Ελληνικά",hi:"हिन्दी",hu:"magyar",ind:"bahasa Indonesia",ga:"Gaeilge",it:"Italiano",ja:"日本語",ko:"한국어",lv:"latviešu",mt:"Maltese",fa:"فارسی",pl:"Polish",pt:"português",ro:"română",ru:"русский",sl:"slovenščina",es:"Español",sv:"svenska",tl:"Tagalog (Filipino)",tr:"Türkçe",uk:"украї́нська",ur:"اُردُو",ms:"Bahasa Malaysia"},this.currenciesList={SAR:{en:"Saudi Riyal",ar:"ريال سعودي",symbol:"ر.س"},USD:{en:"US Dollar",ar:"دولار أمريكي",symbol:"$"},EUR:{en:"Euro",ar:"يورو",symbol:"€"},AED:{en:"UAE Dirham",ar:"درهم اماراتي",symbol:"د.إ"},KWD:{en:"Kuwaiti Dinar",ar:"دينار كويتي",symbol:"د.ك"},BHD:{en:"Bahraini Dinar",ar:"دينار بحريني",symbol:"د.ب"},QAR:{en:"Qatari Riyal",ar:"ريال قطري",symbol:"ر.ق"},OMR:{en:"Omani Rial",ar:"ريال عماني",symbol:"ر.ع"},AUD:{en:"Australian Dollar",ar:"دولار استرالي",symbol:"$"},CAD:{en:"Canadian Dollar",ar:"دولار كندي",symbol:"$"},CNY:{en:"Renminbi",ar:"رنمينبي",symbol:"¥"},EGP:{en:"Egyptian Pound",ar:"جنيه مصري",symbol:"ج.م"},GBP:{en:"Pound Sterling",ar:"جنيه استرليني",symbol:"£"},IDR:{en:"Indonesian Rupiah",ar:"روبية إندونيسية",symbol:"Rp"},INR:{en:"Indian Rupee",ar:"روبية هندية",symbol:"₹"},JPY:{en:"Japanese Yen",ar:"ين ياباني",symbol:"¥"},MYR:{en:"Malaysian Ringgit",ar:"رينغيت ماليزي",symbol:"RM"},PKR:{en:"Pakistani Rupee",ar:"روبية باكستانية",symbol:"Rs."},SEK:{en:"Swedish Krona",ar:"كرونة سويدية",symbol:"kr"},SGD:{en:"Singapore Dollar",ar:"دولار سنغافوري",symbol:"$"},TRY:{en:"Turkish Lira",ar:"ليرة تركية",symbol:"₺"},IQD:{en:"Iraqi Dinar",ar:"دينار عراقي",symbol:"د.ع"},LBP:{en:"Lebanese Pound",ar:"ليرة لبنانية",symbol:"ل.ل"},MRO:{en:"Mauritanian Ouguiya",ar:"أوقية موريتانية",symbol:"UM"},SDG:{en:"Sudanese Pound",ar:"جنيه سوداني",symbol:"SDG"},SYP:{en:"Syrian Pound",ar:"ليرة سورية",symbol:"ل.س"},TND:{en:"Tunisian Dinar",ar:"دينار تونسي",symbol:"د.ت"},JOD:{en:"Jordanian Dinar",ar:"دينار أردني",symbol:"JOD"},DZD:{en:"Algerian Dinar",ar:"دينار جزائري",symbol:"دج"},MAD:{en:"Moroccan Dirham",ar:"درهم مغربي",symbol:"د.م."},LYD:{en:"Libyan Dinar",ar:"دينار ليبي",symbol:"LD"},YER:{en:"Yemeni Riyal",ar:"ريال يمني",symbol:"ر.ي"}},this.arabicCurrencies=["SAR","AED","KWD","BHD","QAR","OMR","EGP","IQD","LBP","SYP","TND","DZD","MAD","YER"],this.languages=[],this.currencies=[],this.hasError=!1,this.showTrigger=!1,this.languageSlot=this.host.querySelector('[slot="language"]')?.innerHTML||'<label class="s-localization-modal-label" for="lang-{code}"><span>{name}</span></label>',this.currencySlot=this.host.querySelector('[slot="currency"]')?.innerHTML||'<label class="s-localization-modal-label" for="currency-{code}"><span>{name}</span><small class="s-localization-modal-currency">{symbol}</small></label>'}async componentWillLoad(){await Salla.onReady(),await Salla.lang.onLoaded(),Salla.event.on("localization::open",(()=>this.open())),this.language||(this.language=Salla.config.get("user.language_code")),this.currency||(this.currency=Salla.config.get("user.currency_code"))}async open(){return this.modal.open(),await Salla.api.withoutNotifier((()=>this.getLanguages())).then((()=>this.getCurrencies())).then((()=>{this.languages.length<2&&this.currencies.length<2&&this.modal.close()})).catch((a=>{console.log(a),this.hasError=!0,this.errorMessage=a.response?.data?.error?.message||a.response?.data})).finally((()=>this.modal.stopLoading()))}async close(){return this.modal.close()}getCurrency(a){return this.currenciesList[a||this.currency]||{en:"Saudi Riyal",ar:"ريال سعودي",symbol:"ر.س"}}getLanguageName(){return this.languageNames[this.language]||this.language||""}getCurrencySymbol(a){return"SAR"===(a=a||this.currency)?'<i class="sicon-sar"></i>':"ar"!==this.language&&this.arabicCurrencies.includes(a)?a:this.getCurrency(a).symbol}getCurrencyName(a){return"ar"===this.language?this.getCurrency(a).ar:this.getCurrency(a).en}async getLanguages(){return this.languages.length>1?null:await Salla.config.languages().then((a=>this.languages=a))}async getCurrencies(){return this.currencies.length>1?null:await Salla.config.currencies().then((a=>this.currencies=Object.values(a||{})))}onChangeCurrency(a){this.currency=a.target.value}onChangeLanguage(a){this.language=a.target.value}async submit(){let a;this.btn.load().then((()=>{if(this.currency){if(this.currency!==Salla.config.get("user.currency_code","SAR"))return a=window.location.href,Salla.currency.api.change(this.currency)}else Salla.log("There is no currency!")})).then((()=>{this.language!==Salla.config.get("user.language_code","ar")&&(a=Salla.helpers.addParamToUrl("lang",this.language))})).then((()=>{Salla.cookie.set("s-lang",this.language),Salla.cookie.set("s-curr",this.currency)})).then((()=>this.btn.stop())).then((()=>this.close())).then((()=>{a&&(window.location.href=a.replace(`/${Salla.config.get("user.language_code")}/`,`/${this.language}/`))}))}render(){return[this.showTrigger?l("button",{type:"button",onClick:()=>this.open(),class:"s-localization-modal-trigger-btn"},l("span",null,this.getLanguageName()),l("span",{class:"s-localization-modal-trigger-separator"},"|")," ",l("span",{innerHTML:this.getCurrencySymbol()})):"",l("salla-modal",{key:"862b768f3a0f9abe079703030bb686178d418ca7",isLoading:!0,class:"s-hidden",ref:a=>this.modal=a,width:"xs"},l("div",{key:"96ce8b449b2c96718de083df1b39bf19d18e4543",slot:"loading"},l("div",{key:"44ba3efdf44d8758b9824dfbee98081549aad41f",class:"s-localization-modal-skeleton"},l("salla-skeleton",{key:"66c85016f14871d05eb296691962ddf0e5b8a512",width:"25%",height:"15px"}),l("div",{key:"e3e0a9cf51572f13456f82d9b08a14a132a01657",class:"s-localization-modal-skeleton-content"},[...Array(4)].map((()=>l("div",{class:"s-localization-modal-skeleton-item"},l("div",{class:"s-localization-modal-skeleton-item-flex"},l("salla-skeleton",{type:"circle",height:"16px",width:"16px"}),l("salla-skeleton",{height:"10px",width:"100px"})),l("salla-skeleton",{height:"15px",width:"20px"}))))),l("salla-skeleton",{key:"4c60b249bd54e0850471967d176a789f38f95841",width:"25%",height:"15px"}),l("div",{key:"7da8613b052a1dab1b34cf54fad755f703b68e5a",class:"s-localization-modal-skeleton-content"},[...Array(4)].map((()=>l("div",{class:"s-localization-modal-skeleton-item"},l("div",{class:"s-localization-modal-skeleton-item-flex"},l("salla-skeleton",{type:"circle",height:"16px",width:"16px"}),l("salla-skeleton",{height:"10px",width:"100px"})),l("salla-skeleton",{height:"15px",width:"20px"}))))),l("salla-skeleton",{key:"b465504898a6861d5cce2456444cc81e7bc61376",height:"40px",width:"100%"}))),this.hasError?l("salla-placeholder",{alignment:"center"},l("span",{slot:"description"},this.errorMessage)):l("div",{class:"s-localization-modal-inner"},this.languages.length>1?l("div",{class:"s-localization-modal-section"},l("label",{class:"s-localization-modal-title"},Salla.lang.get("common.titles.language")),l("div",{class:"s-localization-modal-section-inner"},this.languages.length<6?this.languages.map((a=>l("div",{class:"s-localization-modal-item"},l("input",{class:"s-localization-modal-input",type:"radio",checked:this.language==a.iso_code,onChange:()=>this.language=a.iso_code,name:"language",id:"lang-"+a.code.toLowerCase(),value:a.code}),l("div",{class:"s-localization-modal-label-slot",id:"language-slot",innerHTML:this.languageSlot.replace(/\{name\}/g,a.name).replace(/\{code\}/g,a.code).replace(/\{country_code\}/g,a.country_code)})))):l("select",{class:"s-localization-modal-select",name:"language",onChange:a=>this.onChangeLanguage(a)},this.languages.map((a=>l("option",{value:a.code,selected:this.language==a.code},a.name)))))):"",this.currencies.length>1?l("div",{class:"s-localization-modal-section"},l("label",{class:"s-localization-modal-title"},Salla.lang.get("common.titles.currency")),l("div",{class:"s-localization-modal-section-inner"},this.currencies.length<6?this.currencies.map((a=>l("div",{class:"s-localization-modal-item"},l("input",{class:"s-localization-modal-input",type:"radio",name:"currency",checked:this.currency==a.code,onChange:()=>this.currency=a.code,id:"currency-"+a.code,value:a.code}),l("div",{class:"s-localization-modal-label-slot",id:"currency-slot",innerHTML:this.currencySlot.replace(/\{name\}/g,this.getCurrencyName(a.code)).replace(/\{code\}/g,a.code).replace(/\{symbol\}/g,this.getCurrencySymbol(a.code)).replace(/\{country_code\}/g,a.country_code)})))):l("select",{class:"s-localization-modal-select",name:"currency",onChange:a=>this.onChangeCurrency(a)},this.currencies.map((a=>l("option",{value:a.code,selected:this.currency==a.code},a.name)))))):"",l("salla-button",{width:"wide",ref:a=>this.btn=a,onClick:()=>this.submit()},Salla.lang.get("common.elements.ok"))))]}componentDidRender(){this.host.querySelectorAll("#currency-slot").forEach((a=>a.replaceWith(a.firstChild))),this.host.querySelectorAll("#language-slot").forEach((a=>a.replaceWith(a.firstChild)))}get host(){return s(this)}};export{i as salla_localization_modal}
4
+ import{r as a,h as l,a as s}from"./p-DtunYVY8.js";const i=class{constructor(l){a(this,l),this.languageNames={ar:"العربية",en:"English",sq:"shqip",hy:"հայերէն",bg:"български",zh:"汉语",hr:"hrvatski",cs:"čeština",da:"dansk",nl:"dutch",et:"eesti keel",fi:"suomen kieli",fr:"Français",de:"Deutsch",el:"Ελληνικά",hi:"हिन्दी",hu:"magyar",ind:"bahasa Indonesia",ga:"Gaeilge",it:"Italiano",ja:"日本語",ko:"한국어",lv:"latviešu",mt:"Maltese",fa:"فارسی",pl:"Polish",pt:"português",ro:"română",ru:"русский",sl:"slovenščina",es:"Español",sv:"svenska",tl:"Tagalog (Filipino)",tr:"Türkçe",uk:"украї́нська",ur:"اُردُو",ms:"Bahasa Malaysia"},this.currenciesList={SAR:{en:"Saudi Riyal",ar:"ريال سعودي",symbol:"ر.س"},USD:{en:"US Dollar",ar:"دولار أمريكي",symbol:"$"},EUR:{en:"Euro",ar:"يورو",symbol:"€"},AED:{en:"UAE Dirham",ar:"درهم اماراتي",symbol:"د.إ"},KWD:{en:"Kuwaiti Dinar",ar:"دينار كويتي",symbol:"د.ك"},BHD:{en:"Bahraini Dinar",ar:"دينار بحريني",symbol:"د.ب"},QAR:{en:"Qatari Riyal",ar:"ريال قطري",symbol:"ر.ق"},OMR:{en:"Omani Rial",ar:"ريال عماني",symbol:"ر.ع"},AUD:{en:"Australian Dollar",ar:"دولار استرالي",symbol:"$"},CAD:{en:"Canadian Dollar",ar:"دولار كندي",symbol:"$"},CNY:{en:"Renminbi",ar:"رنمينبي",symbol:"¥"},EGP:{en:"Egyptian Pound",ar:"جنيه مصري",symbol:"ج.م"},GBP:{en:"Pound Sterling",ar:"جنيه استرليني",symbol:"£"},IDR:{en:"Indonesian Rupiah",ar:"روبية إندونيسية",symbol:"Rp"},INR:{en:"Indian Rupee",ar:"روبية هندية",symbol:"₹"},JPY:{en:"Japanese Yen",ar:"ين ياباني",symbol:"¥"},MYR:{en:"Malaysian Ringgit",ar:"رينغيت ماليزي",symbol:"RM"},PKR:{en:"Pakistani Rupee",ar:"روبية باكستانية",symbol:"Rs."},SEK:{en:"Swedish Krona",ar:"كرونة سويدية",symbol:"kr"},SGD:{en:"Singapore Dollar",ar:"دولار سنغافوري",symbol:"$"},TRY:{en:"Turkish Lira",ar:"ليرة تركية",symbol:"₺"},IQD:{en:"Iraqi Dinar",ar:"دينار عراقي",symbol:"د.ع"},LBP:{en:"Lebanese Pound",ar:"ليرة لبنانية",symbol:"ل.ل"},MRO:{en:"Mauritanian Ouguiya",ar:"أوقية موريتانية",symbol:"UM"},SDG:{en:"Sudanese Pound",ar:"جنيه سوداني",symbol:"SDG"},SYP:{en:"Syrian Pound",ar:"ليرة سورية",symbol:"ل.س"},TND:{en:"Tunisian Dinar",ar:"دينار تونسي",symbol:"د.ت"},JOD:{en:"Jordanian Dinar",ar:"دينار أردني",symbol:"JOD"},DZD:{en:"Algerian Dinar",ar:"دينار جزائري",symbol:"دج"},MAD:{en:"Moroccan Dirham",ar:"درهم مغربي",symbol:"د.م."},LYD:{en:"Libyan Dinar",ar:"دينار ليبي",symbol:"LD"},YER:{en:"Yemeni Riyal",ar:"ريال يمني",symbol:"ر.ي"}},this.arabicCurrencies=["SAR","AED","KWD","BHD","QAR","OMR","EGP","IQD","LBP","SYP","TND","DZD","MAD","YER"],this.languages=[],this.currencies=[],this.hasError=!1,this.showTrigger=!1,this.languageSlot=this.host.querySelector('[slot="language"]')?.innerHTML||'<label class="s-localization-modal-label" for="lang-{code}"><span>{name}</span></label>',this.currencySlot=this.host.querySelector('[slot="currency"]')?.innerHTML||'<label class="s-localization-modal-label" for="currency-{code}"><span>{name}</span><small class="s-localization-modal-currency">{symbol}</small></label>'}async componentWillLoad(){await Salla.onReady(),await Salla.lang.onLoaded(),Salla.event.on("localization::open",(()=>this.open())),this.language||(this.language=Salla.config.get("user.language_code")),this.currency||(this.currency=Salla.config.get("user.currency_code"))}async open(){return this.modal.open(),await Salla.api.withoutNotifier((()=>this.getLanguages())).then((()=>this.getCurrencies())).then((()=>{this.languages.length<2&&this.currencies.length<2&&this.modal.close()})).catch((a=>{console.log(a),this.hasError=!0,this.errorMessage=a.response?.data?.error?.message||a.response?.data})).finally((()=>this.modal.stopLoading()))}async close(){return this.modal.close()}getCurrency(a){return this.currenciesList[a||this.currency]||{en:"Saudi Riyal",ar:"ريال سعودي",symbol:"ر.س"}}getLanguageName(){return this.languageNames[this.language]||this.language||""}getCurrencySymbol(a){return"SAR"===(a=a||this.currency)?'<i class="sicon-sar"></i>':"ar"!==this.language&&this.arabicCurrencies.includes(a)?a:this.getCurrency(a).symbol}getCurrencyName(a){return"ar"===this.language?this.getCurrency(a).ar:this.getCurrency(a).en}async getLanguages(){return this.languages.length>1?null:await Salla.config.languages().then((a=>this.languages=a))}async getCurrencies(){return this.currencies.length>1?null:await Salla.config.currencies().then((a=>this.currencies=Object.values(a||{})))}onChangeCurrency(a){this.currency=a.target.value}onChangeLanguage(a){this.language=a.target.value}async submit(){let a;this.btn.load().then((()=>{if(this.currency){if(this.currency!==Salla.config.get("user.currency_code","SAR"))return a=window.location.href,Salla.currency.api.change(this.currency)}else Salla.log("There is no currency!")})).then((()=>{this.language!==Salla.config.get("user.language_code","ar")&&(a=Salla.helpers.addParamToUrl("lang",this.language))})).then((()=>{Salla.cookie.set("s-lang",this.language),Salla.cookie.set("s-curr",this.currency)})).then((()=>this.btn.stop())).then((()=>this.close())).then((()=>{a&&(window.location.href=a.replace(`/${Salla.config.get("user.language_code")}/`,`/${this.language}/`))}))}render(){return[this.showTrigger?l("button",{type:"button",onClick:()=>this.open(),class:"s-localization-modal-trigger-btn"},l("span",null,this.getLanguageName()),l("span",{class:"s-localization-modal-trigger-separator"},"|")," ",l("span",{innerHTML:this.getCurrencySymbol()})):"",l("salla-modal",{key:"862b768f3a0f9abe079703030bb686178d418ca7",isLoading:!0,class:"s-hidden",ref:a=>this.modal=a,width:"xs"},l("div",{key:"96ce8b449b2c96718de083df1b39bf19d18e4543",slot:"loading"},l("div",{key:"44ba3efdf44d8758b9824dfbee98081549aad41f",class:"s-localization-modal-skeleton"},l("salla-skeleton",{key:"66c85016f14871d05eb296691962ddf0e5b8a512",width:"25%",height:"15px"}),l("div",{key:"e3e0a9cf51572f13456f82d9b08a14a132a01657",class:"s-localization-modal-skeleton-content"},[...Array(4)].map((()=>l("div",{class:"s-localization-modal-skeleton-item"},l("div",{class:"s-localization-modal-skeleton-item-flex"},l("salla-skeleton",{type:"circle",height:"16px",width:"16px"}),l("salla-skeleton",{height:"10px",width:"100px"})),l("salla-skeleton",{height:"15px",width:"20px"}))))),l("salla-skeleton",{key:"4c60b249bd54e0850471967d176a789f38f95841",width:"25%",height:"15px"}),l("div",{key:"7da8613b052a1dab1b34cf54fad755f703b68e5a",class:"s-localization-modal-skeleton-content"},[...Array(4)].map((()=>l("div",{class:"s-localization-modal-skeleton-item"},l("div",{class:"s-localization-modal-skeleton-item-flex"},l("salla-skeleton",{type:"circle",height:"16px",width:"16px"}),l("salla-skeleton",{height:"10px",width:"100px"})),l("salla-skeleton",{height:"15px",width:"20px"}))))),l("salla-skeleton",{key:"b465504898a6861d5cce2456444cc81e7bc61376",height:"40px",width:"100%"}))),this.hasError?l("salla-placeholder",{alignment:"center"},l("span",{slot:"description"},this.errorMessage)):l("div",{class:"s-localization-modal-inner"},this.languages.length>1?l("div",{class:"s-localization-modal-section"},l("label",{class:"s-localization-modal-title"},Salla.lang.get("common.titles.language")),l("div",{class:"s-localization-modal-section-inner"},this.languages.length<6?this.languages.map((a=>l("div",{class:"s-localization-modal-item"},l("input",{class:"s-localization-modal-input",type:"radio",checked:this.language==a.iso_code,onChange:()=>this.language=a.iso_code,name:"language",id:"lang-"+a.code.toLowerCase(),value:a.code}),l("div",{class:"s-localization-modal-label-slot",id:"language-slot",innerHTML:this.languageSlot.replace(/\{name\}/g,a.name).replace(/\{code\}/g,a.code).replace(/\{country_code\}/g,a.country_code)})))):l("select",{class:"s-localization-modal-select",name:"language",onChange:a=>this.onChangeLanguage(a)},this.languages.map((a=>l("option",{value:a.code,selected:this.language==a.code},a.name)))))):"",this.currencies.length>1?l("div",{class:"s-localization-modal-section"},l("label",{class:"s-localization-modal-title"},Salla.lang.get("common.titles.currency")),l("div",{class:"s-localization-modal-section-inner"},this.currencies.length<6?this.currencies.map((a=>l("div",{class:"s-localization-modal-item"},l("input",{class:"s-localization-modal-input",type:"radio",name:"currency",checked:this.currency==a.code,onChange:()=>this.currency=a.code,id:"currency-"+a.code,value:a.code}),l("div",{class:"s-localization-modal-label-slot",id:"currency-slot",innerHTML:this.currencySlot.replace(/\{name\}/g,this.getCurrencyName(a.code)).replace(/\{code\}/g,a.code).replace(/\{symbol\}/g,this.getCurrencySymbol(a.code)).replace(/\{country_code\}/g,a.country_code)})))):l("select",{class:"s-localization-modal-select",name:"currency",onChange:a=>this.onChangeCurrency(a)},this.currencies.map((a=>l("option",{value:a.code,selected:this.currency==a.code},a.name)))))):"",l("salla-button",{width:"wide",ref:a=>this.btn=a,onClick:()=>this.submit()},Salla.lang.get("common.elements.ok"))))]}componentDidRender(){this.host.querySelectorAll("#currency-slot").forEach((a=>a.replaceWith(a.firstChild))),this.host.querySelectorAll("#language-slot").forEach((a=>a.replaceWith(a.firstChild)))}get host(){return s(this)}};export{i as salla_localization_modal}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as a,h as s,H as t,a as o}from"./p-DNtvpIPH.js";const n=class{constructor(s){a(this,s)}async mount(a){this.host.before(a)}render(){return s(t,{key:"499483c55f2e1122d80768cd43e47f8e127a62b4"})}async componentDidLoad(){await Salla.hooks.registerComponent("salla-hook",this)}get host(){return o(this)}};n.style=":host {\n all: unset;\n display: none; /* marker only */\n }";export{n as salla_hook}
4
+ import{r as a,h as s,H as t,a as n}from"./p-DtunYVY8.js";const o=class{constructor(s){a(this,s)}async mount(a){this.host.before(a)}render(){return s(t,{key:"499483c55f2e1122d80768cd43e47f8e127a62b4"})}async componentDidLoad(){await Salla.hooks.registerComponent("salla-hook",this)}get host(){return n(this)}};o.style=":host {\n all: unset;\n display: none; /* marker only */\n }";export{o as salla_hook}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as l,H as t}from"./p-DNtvpIPH.js";const i=class{constructor(l){s(this,l),this.methods=[],this.shouldRender=!1}async componentDidLoad(){await Salla.onReady(),await Salla.lang.onLoaded(),Salla.config.get("store.shipping.support_pickup")&&(this.shouldRender=!0,this.setLabels())}setLabels(){this.methods=[{id:"delivery",title:Salla.lang.getWithDefault("pages.products.promise_delivery_title","متاح للتوصيل"),subtitle:Salla.lang.getWithDefault("pages.products.promise_delivery_subtitle","طلبك يوصلك لباب البيت بسهولة."),iconClass:"sicon-location"},{id:"pickup",title:Salla.lang.getWithDefault("pages.products.promise_pickup_title","متاح للاستلام"),subtitle:Salla.lang.getWithDefault("pages.products.promise_pickup_subtitle","استلام فوري من أقرب فرع."),iconClass:"sicon-store"}]}render(){return this.shouldRender?l(t,{class:"s-fulfillment-methods"},l("div",{class:"s-fulfillment-methods-list"},this.methods.map((s=>l("div",{key:s.id,class:"s-fulfillment-methods-card"},l("div",{class:"s-fulfillment-methods-content"},l("div",{class:"s-fulfillment-methods-icon-wrap"},l("i",{class:`${s.iconClass} s-fulfillment-methods-icon`})),l("div",{class:"s-fulfillment-methods-text"},l("span",{class:"s-fulfillment-methods-title"},s.title),l("span",{class:"s-fulfillment-methods-subtitle"},s.subtitle)))))))):null}};export{i as salla_fulfillment_methods}
4
+ import{r as s,h as l,H as t}from"./p-DtunYVY8.js";const i=class{constructor(l){s(this,l),this.methods=[],this.shouldRender=!1}async componentDidLoad(){await Salla.onReady(),await Salla.lang.onLoaded(),Salla.config.get("store.shipping.support_pickup")&&(this.shouldRender=!0,this.setLabels())}setLabels(){this.methods=[{id:"delivery",title:Salla.lang.getWithDefault("pages.products.promise_delivery_title","متاح للتوصيل"),subtitle:Salla.lang.getWithDefault("pages.products.promise_delivery_subtitle","طلبك يوصلك لباب البيت بسهولة."),iconClass:"sicon-location"},{id:"pickup",title:Salla.lang.getWithDefault("pages.products.promise_pickup_title","متاح للاستلام"),subtitle:Salla.lang.getWithDefault("pages.products.promise_pickup_subtitle","استلام فوري من أقرب فرع."),iconClass:"sicon-store"}]}render(){return this.shouldRender?l(t,{class:"s-fulfillment-methods"},l("div",{class:"s-fulfillment-methods-list"},this.methods.map((s=>l("div",{key:s.id,class:"s-fulfillment-methods-card"},l("div",{class:"s-fulfillment-methods-content"},l("div",{class:"s-fulfillment-methods-icon-wrap"},l("i",{class:`${s.iconClass} s-fulfillment-methods-icon`})),l("div",{class:"s-fulfillment-methods-text"},l("span",{class:"s-fulfillment-methods-title"},s.title),l("span",{class:"s-fulfillment-methods-subtitle"},s.subtitle)))))))):null}};export{i as salla_fulfillment_methods}