@salla.sa/twilight-components 2.14.503 → 2.14.505

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 (331) hide show
  1. package/dist/cjs/{filepond-4EL7Y6dJ.js → filepond-DD_rFAOS.js} +1 -1
  2. package/dist/cjs/{filepond-plugin-file-poster-DpfDCEfm.js → filepond-plugin-file-poster-Dd8ZNsxi.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-validate-size-C_vWwsvD.js → filepond-plugin-file-validate-size-CmQS5jpF.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-type-BsPU4Pri.js → filepond-plugin-file-validate-type-BpimuCmP.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-image-edit-CQUu_uxt.js → filepond-plugin-image-edit-Ddpq7EPd.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-exif-orientation-DS_esf9h.js → filepond-plugin-image-exif-orientation-C-rvvxtT.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-preview-MQ9XW9EF.js → filepond-plugin-image-preview-DcWsDFH7.js} +1 -1
  8. package/dist/cjs/{functions-lIj44Kzp.js → functions-CV9ZtvDO.js} +1 -1
  9. package/dist/cjs/{index-BNkAXOaT.js → index-BBzpQqif.js} +1 -1
  10. package/dist/cjs/{index-r130kUIm.js → index-CaEXunge.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 +16 -5
  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-basket-gap.cjs.entry.js +1 -1
  21. package/dist/cjs/salla-booking-field_7.cjs.entry.js +10 -10
  22. package/dist/cjs/salla-bullet-delivery_2.cjs.entry.js +15 -4
  23. package/dist/cjs/salla-cart-coupons.cjs.entry.js +1 -1
  24. package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-cart-summary-card.cjs.entry.js +1 -1
  26. package/dist/cjs/salla-cashback-banner.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-comment-factors.cjs.entry.js +1 -1
  28. package/dist/cjs/salla-comment-form_8.cjs.entry.js +1 -1
  29. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  31. package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-count-down_2.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-delivery-promise.cjs.entry.js +1 -1
  35. package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
  36. package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-filters.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
  39. package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
  40. package/dist/cjs/salla-hook.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
  44. package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
  45. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  46. package/dist/cjs/salla-loyalty-banner.cjs.entry.js +2 -2
  47. package/dist/cjs/salla-loyalty-exchange-product-card_5.cjs.entry.js +3 -3
  48. package/dist/cjs/salla-loyalty-hero_2.cjs.entry.js +2 -2
  49. package/dist/cjs/salla-loyalty-panel.cjs.entry.js +3 -3
  50. package/dist/cjs/salla-loyalty-points-banner.cjs.entry.js +1 -1
  51. package/dist/cjs/salla-loyalty-points-history.cjs.entry.js +1 -1
  52. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  53. package/dist/cjs/salla-loyalty-program.cjs.entry.js +3 -3
  54. package/dist/cjs/salla-loyalty-reward.cjs.entry.js +2 -2
  55. package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
  56. package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
  57. package/dist/cjs/salla-map_2.cjs.entry.js +1 -1
  58. package/dist/cjs/salla-menu.cjs.entry.js +1 -1
  59. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  60. package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
  61. package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
  62. package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
  63. package/dist/cjs/salla-next-order-coupon.cjs.entry.js +1 -1
  64. package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
  65. package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
  66. package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
  67. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  68. package/dist/cjs/salla-order-branch.cjs.entry.js +1 -1
  69. package/dist/cjs/salla-order-cancel.cjs.entry.js +1 -1
  70. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  71. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  72. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  73. package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
  74. package/dist/cjs/salla-order-edit-product-card.cjs.entry.js +1 -1
  75. package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
  76. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  77. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  78. package/dist/cjs/salla-orders.cjs.entry.js +1 -1
  79. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  80. package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
  81. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  82. package/dist/cjs/salla-product-card-embed.cjs.entry.js +1 -1
  83. package/dist/cjs/salla-product-card_2.cjs.entry.js +1 -1
  84. package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
  85. package/dist/cjs/salla-products-list.cjs.entry.js +1 -1
  86. package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
  87. package/dist/cjs/salla-rating-modal-v2.cjs.entry.js +1 -1
  88. package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
  89. package/dist/cjs/salla-review-factors-tags.cjs.entry.js +1 -1
  90. package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
  91. package/dist/cjs/salla-search.cjs.entry.js +1 -1
  92. package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
  93. package/dist/cjs/salla-slider.cjs.entry.js +1 -1
  94. package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
  95. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  96. package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
  97. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  98. package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
  99. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  100. package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
  101. package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
  102. package/dist/cjs/salla-user-settings.cjs.entry.js +1 -1
  103. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  104. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  105. package/dist/cjs/salla-wishlist-actions.cjs.entry.js +1 -1
  106. package/dist/cjs/{tracked-promise-B5M6XIJs.js → tracked-promise-CgPIBiVQ.js} +1 -1
  107. package/dist/cjs/twilight.cjs.js +1 -1
  108. package/dist/cjs/{vanilla-picker-CccSuwv_.js → vanilla-picker-CpYZmdB0.js} +1 -1
  109. package/dist/collection/components/salla-bullet-delivery/salla-bullet-delivery.js +14 -3
  110. package/dist/collection/components/salla-quick-buy/salla-quick-buy.js +4 -4
  111. package/dist/components/index.js +2 -2
  112. package/dist/components/salla-bullet-delivery.js +14 -3
  113. package/dist/components/salla-quick-buy2.js +15 -4
  114. package/dist/esm/{filepond-XsQHT8SM.js → filepond-B-UStH94.js} +1 -1
  115. package/dist/esm/{filepond-plugin-file-poster-Bm4O3j9p.js → filepond-plugin-file-poster-DclqOfrk.js} +1 -1
  116. package/dist/esm/{filepond-plugin-file-validate-size-UhmECxYX.js → filepond-plugin-file-validate-size-BMsBPOJQ.js} +1 -1
  117. package/dist/esm/{filepond-plugin-file-validate-type-Dh3jaIG2.js → filepond-plugin-file-validate-type-C5VEW1-h.js} +1 -1
  118. package/dist/esm/{filepond-plugin-image-edit-CeOXp2ae.js → filepond-plugin-image-edit-B7yXlSpX.js} +1 -1
  119. package/dist/esm/{filepond-plugin-image-exif-orientation-BsjFZBW3.js → filepond-plugin-image-exif-orientation-BD2JbThi.js} +1 -1
  120. package/dist/esm/{filepond-plugin-image-preview-BqeINcJC.js → filepond-plugin-image-preview-cID5YN1G.js} +1 -1
  121. package/dist/esm/{functions-DC6kKxwl.js → functions-VivHV3zU.js} +1 -1
  122. package/dist/esm/{index-Ds_VsqAB.js → index-19doeROM.js} +1 -1
  123. package/dist/esm/{index-BDAOgcq0.js → index-DgmW0rL4.js} +2 -2
  124. package/dist/esm/loader.js +2 -2
  125. package/dist/esm/salla-accordion-body_2.entry.js +1 -1
  126. package/dist/esm/salla-accordion_6.entry.js +1 -1
  127. package/dist/esm/salla-add-product-button_5.entry.js +16 -5
  128. package/dist/esm/salla-advertisement.entry.js +1 -1
  129. package/dist/esm/salla-alert_2.entry.js +1 -1
  130. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  131. package/dist/esm/salla-apps-icons.entry.js +1 -1
  132. package/dist/esm/salla-badge.entry.js +1 -1
  133. package/dist/esm/salla-basket-gap.entry.js +1 -1
  134. package/dist/esm/salla-booking-field_7.entry.js +10 -10
  135. package/dist/esm/salla-bullet-delivery_2.entry.js +15 -4
  136. package/dist/esm/salla-cart-coupons.entry.js +1 -1
  137. package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
  138. package/dist/esm/salla-cart-summary-card.entry.js +1 -1
  139. package/dist/esm/salla-cashback-banner.entry.js +1 -1
  140. package/dist/esm/salla-comment-factors.entry.js +1 -1
  141. package/dist/esm/salla-comment-form_8.entry.js +1 -1
  142. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  143. package/dist/esm/salla-contacts.entry.js +1 -1
  144. package/dist/esm/salla-cookies-bar.entry.js +1 -1
  145. package/dist/esm/salla-count-down_2.entry.js +1 -1
  146. package/dist/esm/salla-custom-fields.entry.js +1 -1
  147. package/dist/esm/salla-delivery-promise.entry.js +1 -1
  148. package/dist/esm/salla-edit-order-button.entry.js +1 -1
  149. package/dist/esm/salla-filters-widget.entry.js +1 -1
  150. package/dist/esm/salla-filters.entry.js +1 -1
  151. package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
  152. package/dist/esm/salla-gifting.entry.js +1 -1
  153. package/dist/esm/salla-hook.entry.js +1 -1
  154. package/dist/esm/salla-infinite-scroll.entry.js +1 -1
  155. package/dist/esm/salla-installment.entry.js +1 -1
  156. package/dist/esm/salla-list-tile.entry.js +1 -1
  157. package/dist/esm/salla-localization-modal.entry.js +1 -1
  158. package/dist/esm/salla-login-modal.entry.js +1 -1
  159. package/dist/esm/salla-loyalty-banner.entry.js +2 -2
  160. package/dist/esm/salla-loyalty-exchange-product-card_5.entry.js +3 -3
  161. package/dist/esm/salla-loyalty-hero_2.entry.js +2 -2
  162. package/dist/esm/salla-loyalty-panel.entry.js +3 -3
  163. package/dist/esm/salla-loyalty-points-banner.entry.js +1 -1
  164. package/dist/esm/salla-loyalty-points-history.entry.js +1 -1
  165. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  166. package/dist/esm/salla-loyalty-program.entry.js +3 -3
  167. package/dist/esm/salla-loyalty-reward.entry.js +2 -2
  168. package/dist/esm/salla-loyalty.entry.js +1 -1
  169. package/dist/esm/salla-maintenance-alert.entry.js +1 -1
  170. package/dist/esm/salla-map_2.entry.js +1 -1
  171. package/dist/esm/salla-menu.entry.js +1 -1
  172. package/dist/esm/salla-metadata.entry.js +1 -1
  173. package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
  174. package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
  175. package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
  176. package/dist/esm/salla-next-order-coupon.entry.js +1 -1
  177. package/dist/esm/salla-notification-item.entry.js +1 -1
  178. package/dist/esm/salla-notifications.entry.js +1 -1
  179. package/dist/esm/salla-offer-modal.entry.js +1 -1
  180. package/dist/esm/salla-offer.entry.js +1 -1
  181. package/dist/esm/salla-order-branch.entry.js +1 -1
  182. package/dist/esm/salla-order-cancel.entry.js +1 -1
  183. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  184. package/dist/esm/salla-order-details-options.entry.js +1 -1
  185. package/dist/esm/salla-order-details.entry.js +1 -1
  186. package/dist/esm/salla-order-edit-item.entry.js +1 -1
  187. package/dist/esm/salla-order-edit-product-card.entry.js +1 -1
  188. package/dist/esm/salla-order-edit.entry.js +1 -1
  189. package/dist/esm/salla-order-summary.entry.js +1 -1
  190. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  191. package/dist/esm/salla-orders.entry.js +1 -1
  192. package/dist/esm/salla-payments.entry.js +1 -1
  193. package/dist/esm/salla-placeholder.entry.js +1 -1
  194. package/dist/esm/salla-price-range.entry.js +1 -1
  195. package/dist/esm/salla-product-card-embed.entry.js +1 -1
  196. package/dist/esm/salla-product-card_2.entry.js +1 -1
  197. package/dist/esm/salla-product-size-guide.entry.js +1 -1
  198. package/dist/esm/salla-products-list.entry.js +1 -1
  199. package/dist/esm/salla-quick-order.entry.js +1 -1
  200. package/dist/esm/salla-rating-modal-v2.entry.js +1 -1
  201. package/dist/esm/salla-rating-modal.entry.js +1 -1
  202. package/dist/esm/salla-review-factors-tags.entry.js +1 -1
  203. package/dist/esm/salla-scopes.entry.js +1 -1
  204. package/dist/esm/salla-search.entry.js +1 -1
  205. package/dist/esm/salla-skeleton.entry.js +1 -1
  206. package/dist/esm/salla-slider.entry.js +1 -1
  207. package/dist/esm/salla-social-share.entry.js +1 -1
  208. package/dist/esm/salla-social.entry.js +1 -1
  209. package/dist/esm/salla-tab-content_3.entry.js +1 -1
  210. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  211. package/dist/esm/salla-tooltip.entry.js +1 -1
  212. package/dist/esm/salla-trust-badges.entry.js +1 -1
  213. package/dist/esm/salla-user-menu.entry.js +1 -1
  214. package/dist/esm/salla-user-profile.entry.js +1 -1
  215. package/dist/esm/salla-user-settings.entry.js +1 -1
  216. package/dist/esm/salla-verify.entry.js +1 -1
  217. package/dist/esm/salla-wallet.entry.js +1 -1
  218. package/dist/esm/salla-wishlist-actions.entry.js +1 -1
  219. package/dist/esm/{tracked-promise-B9jBidlY.js → tracked-promise-BKcvXHlH.js} +1 -1
  220. package/dist/esm/twilight.js +2 -2
  221. package/dist/esm/{vanilla-picker-WYx5-zNH.js → vanilla-picker-Dd_VXZC4.js} +1 -1
  222. package/dist/twilight/{p-13411f43.entry.js → p-04df9e0b.entry.js} +1 -1
  223. package/dist/twilight/{p-1d4df9b9.entry.js → p-07a65b7d.entry.js} +1 -1
  224. package/dist/twilight/{p-a38c8a50.entry.js → p-096d5d28.entry.js} +1 -1
  225. package/dist/twilight/{p-c09f54a6.entry.js → p-09b32c27.entry.js} +1 -1
  226. package/dist/twilight/{p-e0b3dc35.entry.js → p-0b3cd18a.entry.js} +1 -1
  227. package/dist/twilight/{p-93e1fce9.entry.js → p-0d9d9d79.entry.js} +1 -1
  228. package/dist/twilight/{p-f885ceed.entry.js → p-0dc76b8d.entry.js} +1 -1
  229. package/dist/twilight/{p-e1f2e830.entry.js → p-0ff1279b.entry.js} +1 -1
  230. package/dist/twilight/{p-648a3962.entry.js → p-10cffe37.entry.js} +1 -1
  231. package/dist/twilight/{p-833d5b2c.entry.js → p-155e517d.entry.js} +1 -1
  232. package/dist/twilight/{p-58e8f293.entry.js → p-16d84218.entry.js} +1 -1
  233. package/dist/twilight/{p-8829803d.entry.js → p-16ee6031.entry.js} +1 -1
  234. package/dist/twilight/{p-4add663c.entry.js → p-1962f0c0.entry.js} +1 -1
  235. package/dist/twilight/{p-60a8176c.entry.js → p-19ad6321.entry.js} +1 -1
  236. package/dist/twilight/{p-739eb0c7.entry.js → p-1c7323b3.entry.js} +1 -1
  237. package/dist/twilight/{p-66bad139.entry.js → p-1cd06f96.entry.js} +1 -1
  238. package/dist/twilight/{p-4d50512c.entry.js → p-29943826.entry.js} +1 -1
  239. package/dist/twilight/{p-199e8ce2.entry.js → p-2c2b7eea.entry.js} +1 -1
  240. package/dist/twilight/{p-23efc7b2.entry.js → p-2d508573.entry.js} +1 -1
  241. package/dist/twilight/{p-2defa519.entry.js → p-2e132d80.entry.js} +1 -1
  242. package/dist/twilight/{p-a3bf7378.entry.js → p-2f4a2425.entry.js} +1 -1
  243. package/dist/twilight/{p-7766fa26.entry.js → p-363d2512.entry.js} +1 -1
  244. package/dist/twilight/{p-9fe5b58d.entry.js → p-3a51668d.entry.js} +1 -1
  245. package/dist/twilight/p-47b6123d.entry.js +4 -0
  246. package/dist/twilight/{p-9387d8f6.entry.js → p-4911099b.entry.js} +1 -1
  247. package/dist/twilight/{p-5cdbbf4b.entry.js → p-4e0ab6a0.entry.js} +1 -1
  248. package/dist/twilight/{p-fa751c55.entry.js → p-4ebe6127.entry.js} +1 -1
  249. package/dist/twilight/{p-45b5af6c.entry.js → p-501f352c.entry.js} +1 -1
  250. package/dist/twilight/{p-339d0e20.entry.js → p-508b2db2.entry.js} +1 -1
  251. package/dist/twilight/{p-145321f6.entry.js → p-527e00f3.entry.js} +1 -1
  252. package/dist/twilight/{p-3b28110b.entry.js → p-53364bda.entry.js} +1 -1
  253. package/dist/twilight/{p-892fe0dc.entry.js → p-56fb3cfa.entry.js} +1 -1
  254. package/dist/twilight/{p-34779788.entry.js → p-57fa471e.entry.js} +1 -1
  255. package/dist/twilight/{p-70827676.entry.js → p-58f137e4.entry.js} +1 -1
  256. package/dist/twilight/{p-0c0e06ef.entry.js → p-5b95ed84.entry.js} +1 -1
  257. package/dist/twilight/{p-9e1d9a17.entry.js → p-5d8bb043.entry.js} +1 -1
  258. package/dist/twilight/{p-029b107b.entry.js → p-5f93b8c4.entry.js} +1 -1
  259. package/dist/twilight/{p-766c0d0e.entry.js → p-71df210d.entry.js} +1 -1
  260. package/dist/twilight/{p-58d35d9b.entry.js → p-7264d8f5.entry.js} +1 -1
  261. package/dist/twilight/{p-1072712c.entry.js → p-7596fb5c.entry.js} +1 -1
  262. package/dist/twilight/{p-242c9aab.entry.js → p-79f4f459.entry.js} +1 -1
  263. package/dist/twilight/{p-f046adac.entry.js → p-7de68ea9.entry.js} +1 -1
  264. package/dist/twilight/{p-20fa61e5.entry.js → p-7e8973ef.entry.js} +1 -1
  265. package/dist/twilight/{p-da12a9a4.entry.js → p-7f2c9615.entry.js} +1 -1
  266. package/dist/twilight/{p-df1a9f37.entry.js → p-8103412a.entry.js} +1 -1
  267. package/dist/twilight/{p-7ead012e.entry.js → p-8b58a66c.entry.js} +1 -1
  268. package/dist/twilight/{p-3fd91874.entry.js → p-8cac5280.entry.js} +1 -1
  269. package/dist/twilight/{p-2beb2187.entry.js → p-8dd36b54.entry.js} +1 -1
  270. package/dist/twilight/{p-0e3daf3b.entry.js → p-95d46bfb.entry.js} +1 -1
  271. package/dist/twilight/{p-bb8cf342.entry.js → p-979661ca.entry.js} +1 -1
  272. package/dist/twilight/{p-a4200654.entry.js → p-982c4d6e.entry.js} +1 -1
  273. package/dist/twilight/{p-c7bc0e89.entry.js → p-99dfeb4c.entry.js} +2 -2
  274. package/dist/twilight/{p-c53d5de4.entry.js → p-9a1b9892.entry.js} +1 -1
  275. package/dist/twilight/{p-BqhIuaLC.js → p-BFIidK_r.js} +1 -1
  276. package/dist/twilight/{p-BVdpiUHg.js → p-BNLuRnE-.js} +1 -1
  277. package/dist/twilight/{p-x5XPo1DG.js → p-CRrQRrvo.js} +1 -1
  278. package/dist/twilight/{p-BZEaULfj.js → p-CU3ZhU09.js} +1 -1
  279. package/dist/twilight/{p-Cjy9wz83.js → p-CdC1U3cm.js} +1 -1
  280. package/dist/twilight/{p-CFesXKV4.js → p-DXLiwTWx.js} +1 -1
  281. package/dist/twilight/{p-DH0mPIPC.js → p-DZ0KVYQI.js} +1 -1
  282. package/dist/twilight/{p-BDAOgcq0.js → p-DgmW0rL4.js} +1 -1
  283. package/dist/twilight/{p-DzjKtVuN.js → p-HAahk8iL.js} +1 -1
  284. package/dist/twilight/{p-iGz7tppc.js → p-PM-JSky9.js} +1 -1
  285. package/dist/twilight/{p-Brrm0j4S.js → p-WsUy1Vwc.js} +1 -1
  286. package/dist/twilight/{p-adb61085.entry.js → p-a2bf0687.entry.js} +1 -1
  287. package/dist/twilight/{p-8767b2c9.entry.js → p-a348708b.entry.js} +1 -1
  288. package/dist/twilight/{p-b25a5f02.entry.js → p-a444db9e.entry.js} +1 -1
  289. package/dist/twilight/{p-c86304f5.entry.js → p-a57683c6.entry.js} +1 -1
  290. package/dist/twilight/{p-1822d3e1.entry.js → p-a74da1d9.entry.js} +1 -1
  291. package/dist/twilight/{p-e3248ff0.entry.js → p-ab1d1e8d.entry.js} +1 -1
  292. package/dist/twilight/{p-df2851e1.entry.js → p-ac629acb.entry.js} +1 -1
  293. package/dist/twilight/{p-69b72bf4.entry.js → p-ad262ff7.entry.js} +1 -1
  294. package/dist/twilight/{p-28f1d6d3.entry.js → p-ad7729e9.entry.js} +1 -1
  295. package/dist/twilight/{p-bd548fb9.entry.js → p-b0c392f7.entry.js} +1 -1
  296. package/dist/twilight/{p-eabe5998.entry.js → p-b0e5635e.entry.js} +1 -1
  297. package/dist/twilight/{p-bcd09500.entry.js → p-b49457fd.entry.js} +1 -1
  298. package/dist/twilight/{p-7e5146b6.entry.js → p-b513590c.entry.js} +1 -1
  299. package/dist/twilight/{p-560dd097.entry.js → p-b52c612e.entry.js} +1 -1
  300. package/dist/twilight/{p-7f51644d.entry.js → p-b679191f.entry.js} +1 -1
  301. package/dist/twilight/{p-b5d9bb84.entry.js → p-bfe32f25.entry.js} +1 -1
  302. package/dist/twilight/{p-7c74ae05.entry.js → p-c760f4c7.entry.js} +1 -1
  303. package/dist/twilight/{p-dde417c0.entry.js → p-c83b026f.entry.js} +1 -1
  304. package/dist/twilight/{p-7e48a21d.entry.js → p-c87ccd08.entry.js} +1 -1
  305. package/dist/twilight/{p-1a348bbc.entry.js → p-ca914b96.entry.js} +1 -1
  306. package/dist/twilight/{p-a7ad3bc8.entry.js → p-ccdcd135.entry.js} +1 -1
  307. package/dist/twilight/{p-895cb2a3.entry.js → p-cd25a8ed.entry.js} +1 -1
  308. package/dist/twilight/{p-3718a5ca.entry.js → p-cd87f415.entry.js} +1 -1
  309. package/dist/twilight/{p-11b1f479.entry.js → p-d18e34ae.entry.js} +1 -1
  310. package/dist/twilight/{p-62c90e02.entry.js → p-d3136121.entry.js} +1 -1
  311. package/dist/twilight/{p-ca9efb06.entry.js → p-d34d6f74.entry.js} +1 -1
  312. package/dist/twilight/{p-66a4a0c6.entry.js → p-da9cb482.entry.js} +1 -1
  313. package/dist/twilight/{p-74a6a2eb.entry.js → p-db5e358c.entry.js} +1 -1
  314. package/dist/twilight/{p-84b575c9.entry.js → p-dc268526.entry.js} +1 -1
  315. package/dist/twilight/{p-54078768.entry.js → p-de7bbaa9.entry.js} +1 -1
  316. package/dist/twilight/{p-3f6af2a4.entry.js → p-e296dc06.entry.js} +1 -1
  317. package/dist/twilight/{p-ac754175.entry.js → p-e5f88988.entry.js} +1 -1
  318. package/dist/twilight/{p-389ee38e.entry.js → p-e8ffdd82.entry.js} +1 -1
  319. package/dist/twilight/{p-a0159981.entry.js → p-ecaf331f.entry.js} +1 -1
  320. package/dist/twilight/{p-dd37e07e.entry.js → p-ecd335fb.entry.js} +1 -1
  321. package/dist/twilight/{p-00e00a1a.entry.js → p-f6dede5f.entry.js} +1 -1
  322. package/dist/twilight/{p-41fbfac6.entry.js → p-f8f4fa45.entry.js} +1 -1
  323. package/dist/twilight/{p-df8d8064.entry.js → p-faccc612.entry.js} +1 -1
  324. package/dist/twilight/{p-bcdf496c.entry.js → p-fe0875c2.entry.js} +1 -1
  325. package/dist/twilight/{p-7bb98247.entry.js → p-fed7874a.entry.js} +1 -1
  326. package/dist/twilight/{p-f5d6e487.entry.js → p-ff81cfff.entry.js} +1 -1
  327. package/dist/twilight/{p-bJmdZHN0.js → p-tOYoACRZ.js} +1 -1
  328. package/dist/twilight/twilight.esm.js +1 -1
  329. package/dist/types/components/salla-bullet-delivery/salla-bullet-delivery.d.ts +2 -0
  330. package/package.json +5 -5
  331. package/dist/twilight/p-42f6c2a9.entry.js +0 -4
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,f as a,h as s,H as i,a as e}from"./p-BDAOgcq0.js";import{S as r}from"./p-CeFAfcTv.js";import{S as n}from"./p-lMgMt31Q.js";import{C as o}from"./p-BV4kqbdL.js";import{H as l}from"./p-XnA1YTjA.js";import{I as d}from"./p-C-tzSDxw.js";import{W as h}from"./p-CgR-T_ZS.js";import{e as g}from"./p-DzAIgzdz.js";import"./p-CgtvEd63.js";const m=class{constructor(a){t(this,a),this.hasError=!1,this.showContactWidget=!0,this.images=[],this.productImages={},this.editItemImages=[],this.productReviewFactors={},this.editFactorRatings={},this.productMainRatings={},this.productFactorRatings={},this.contact_body=(t,a,s)=>salla.lang.get("pages.rating.contact_subject",{store:t,id:a,customer:s}),this.editMode=!1,this.defaultMode=!1,this.deleteMode=!1,this.shouldOpenDeleteModal=!1,this.editItem=null,this.allowAttachImages=!1,this.allowContactSupport=!1,this.loyaltyImageRatingPoints=0,this.dragAndDropFilesLabel=salla.lang.get("common.uploader.drag_and_drop_files"),this.contactSubjectLabel=salla.lang.get("pages.rating.contact_subject"),this.editReviewLabel=salla.lang.get("pages.rating.edit_review"),this.allowedImagesTypesLabel=salla.lang.get("common.uploader.allowed_images_types"),this.threeImagesMax=salla.lang.get("common.uploader.max_three_images"),this.areYouSureLabel=salla.lang.get("pages.rating.are_you_sure_you_want_to_delete_review"),this.confirmDeletionLabel=salla.lang.get("pages.rating.confirm_deletion"),this.cancelLabel=salla.lang.get("common.elements.cancel"),this.confirmDeleteBtn=salla.lang.get("common.elements.confirm_delete"),this.updatedSuccessfullyLabel=salla.lang.get("pages.rating.review_updated_successfully"),this.deletedSuccessfullyLabel=salla.lang.get("pages.rating.review_deleted_successfully"),this.contactUsLabel=salla.lang.get("blocks.footer.social"),this.requiredFactorsLabel=salla.lang.get("pages.rating.rate_required_factors"),this.overallProductRatingLabel=salla.lang.get("pages.rating.overall_product_rating"),this.loyaltyPointsForImagesLabel=salla.lang.get("pages.rating.loyalty_points_for_images",{points:":points"}),this.contentRefs=[],this.hiddenInputs=[],this.userFilledFactorKeys={},this.boundRatingRows=new WeakSet,this.stepsCount=0,this.currentIndex=0,this.submitted=[],this.MAX_UPLOAD_LIMIT=3,this.thanksCountdownInterval=null,this.scheduleWizardSetup=!1,salla.lang.onLoaded((()=>{this.contactUsLabel=salla.lang.get("blocks.footer.social");const t=(t,a,s)=>new Promise((i=>{salla.helpers.setNested(salla.lang.messages[t],a,s),i(!0)}));(async()=>{await t("ar.trans","common.uploader.drag_and_drop_files","اسحب الملفات وأفلتها هنا"),await t("en.trans","common.uploader.drag_and_drop_files","Drag and drop files here"),await t("ar.trans","common.uploader.allowed_images_types"," .jpg أو jpeg أو png يُسمح بإضافة صور بصيغة"),await t("en.trans","common.uploader.allowed_images_types","Images in jpg, jpeg, or png format are allowed."),await t("ar.trans","pages.rating.add_images","اضافة صور"),await t("en.trans","pages.rating.add_images","Add Images"),await t("ar.trans","pages.rating.edit_images","تعديل الصور"),await t("en.trans","pages.rating.edit_images","Edit Images"),await t("ar.trans","pages.rating.edit_review","تعديل التقييم"),await t("en.trans","pages.rating.edit_review","Edit review"),await t("ar.trans","pages.rating.confirm_deletion","تأكيد حذف التقييم"),await t("en.trans","pages.rating.confirm_deletion","Confirm review deletion"),await t("ar.trans","pages.rating.are_you_sure_you_want_to_delete_review","هل أنت متأكد من حذف تقييمك؟"),await t("en.trans","pages.rating.are_you_sure_you_want_to_delete_review","Are you sure you want to delete your review?"),await t("ar.trans","pages.rating.review_updated_successfully","تم تعديل التقييم بنجاح"),await t("en.trans","pages.rating.review_updated_successfully","The review has been successfully updated."),await t("ar.trans","pages.rating.review_deleted_successfully","تم حذف التقييم بنجاح"),await t("en.trans","pages.rating.review_deleted_successfully","The review has been successfully deleted."),await t("ar.trans","pages.rating.images_count","الصور ( :current من أصل :total )"),await t("en.trans","pages.rating.images_count","Images ( :current of :total )"),await t("ar.trans","common.uploader.max_three_images",`.أضف ${this.MAX_UPLOAD_LIMIT} صور كحد أقصى`),await t("en.trans","common.uploader.max_three_images",`Add up to ${this.MAX_UPLOAD_LIMIT} images maximum.`),await t("ar.trans","common.elements.confirm_delete","تأكيد الحذف"),await t("en.trans","common.elements.confirm_delete","Confirm deletion"),await t("ar.trans","pages.rating.rate_required_factors","يرجى تقييم جميع المعايير لإتمام مراجعتك."),await t("en.trans","pages.rating.rate_required_factors","Please rate all required factors to complete your review."),await t("ar.trans","pages.rating.overall_product_rating","التقييم العام للمنتج"),await t("en.trans","pages.rating.overall_product_rating","Overall product rating"),await t("ar.trans","pages.rating.loyalty_points_for_images","اكسب :points نقطة ولاء عند إضافة صور لتقييمك!"),await t("en.trans","pages.rating.loyalty_points_for_images","Earn :points loyalty points when adding photos to your review!"),this.dragAndDropFilesLabel=salla.lang.get("common.uploader.drag_and_drop_files"),this.allowedImagesTypesLabel=salla.lang.get("common.uploader.allowed_images_types"),this.threeImagesMax=salla.lang.get("common.uploader.max_three_images"),this.contactSubjectLabel=salla.lang.get("pages.rating.contact_subject"),this.editReviewLabel=salla.lang.get("pages.rating.edit_review"),this.areYouSureLabel=salla.lang.get("pages.rating.are_you_sure_you_want_to_delete_review"),this.confirmDeletionLabel=salla.lang.get("pages.rating.confirm_deletion"),this.cancelLabel=salla.lang.get("common.elements.cancel"),this.updatedSuccessfullyLabel=salla.lang.get("pages.rating.review_updated_successfully"),this.deletedSuccessfullyLabel=salla.lang.get("pages.rating.review_deleted_successfully"),this.confirmDeleteBtn=salla.lang.get("common.elements.confirm_delete"),this.requiredFactorsLabel=salla.lang.get("pages.rating.rate_required_factors"),this.overallProductRatingLabel=salla.lang.get("pages.rating.overall_product_rating"),this.loyaltyPointsForImagesLabel=salla.lang.get("pages.rating.loyalty_points_for_images",{points:":points"}),this.contact_body=(t,a,s)=>salla.lang.get("pages.rating.contact_body",{store:t,id:a,customer:s})})()}))}syncStoreSettings(){this.orderId||(this.orderId=salla.config.get("page.id")),this.allowAttachImages=!!salla.config.get("store.settings.rating.allow_attach_images"),this.allowContactSupport=!!salla.config.get("store.settings.rating.allow_contact_support")}getRatingOrderId(){return this.orderId||salla.config.get("page.id")}getSubmitOrderId(){return this.orderId}isCustomerOrderShape(t){if(!t||"object"!=typeof t)return!1;const a=t;return!!a.rating&&(Array.isArray(a.items)||Array.isArray(a.products)||Array.isArray(a.rating?.product)||Array.isArray(a.rating?.products))}getBootstrapOrder(){const t=salla.config.get("page");if(this.isCustomerOrderShape(t))return t;if(t&&"object"==typeof t){const a=t;if(Array.isArray(a.products))return t;const s=a.order;if(this.isCustomerOrderShape(s))return s}}async loadCustomerOrderForEdit(){const t=this.getBootstrapOrder();if(t?.rating?.product||t?.rating?.products)this.order=t;else try{const t=await salla.api.withoutNotifier((()=>salla.order.api.getDetails(this.getRatingOrderId())));t?.data&&(this.order=t.data)}catch(t){if(!this.order){const t=await salla.api.withoutNotifier((()=>salla.rating.api.order(this.getRatingOrderId())));this.order=t.data}}}getOrderProductRatings(t=this.order){return t?.rating?[...this.normalizeToArray(t.rating.product),...this.normalizeToArray(t.rating.products)]:[]}getMatchedProductRating(t=this.order,a,s){return this.getOrderProductRatings(t).find((t=>Number(t?.id??t?.feedback_id)===Number(s)||Number(t?.product_id??t?.product?.id)===Number(a)))}hasRatingFeedback(t){const a=t?.rating;return null!=a&&""!==a&&Number(a)>0}isTestimonialsEnabled(t=this.order){return!(!1===t?.testimonials_enabled||this.hasRatingFeedback(t?.store?.feedback)||!0!==t?.testimonials_enabled&&!t?.allowed_ratings?.testimonials_enabled)}isProductsEnabled(t=this.order){return!1!==t?.products_enabled&&this.getRateableProducts(t).length>0}isShippingEnabled(t=this.order){return!(!1===t?.shipping_enabled||this.hasRatingFeedback(t?.shipping?.feedback)||!t?.shipping?.company||!0!==t?.shipping_enabled&&!t?.allowed_ratings?.shipping_enabled)}getOrderProducts(t=this.order){return Array.isArray(t?.products)?t.products.filter((t=>t?.product?.id)):[]}getRateableProducts(t=this.order){return this.getOrderProducts(t).filter((t=>!this.hasRatingFeedback(t?.feedback)))}getStepsCount(t=this.order){if(!t)return 0;let a=0;return this.isTestimonialsEnabled(t)&&a++,this.isProductsEnabled(t)&&(a+=this.getRateableProducts(t).length),this.isShippingEnabled(t)&&t.shipping?.company&&a++,a}afterOrderLoaded(){this.stepsCount=this.getStepsCount(),this.scheduleWizardSetup=!0,a(this)}async open(){return await salla.onReady(),this.syncStoreSettings(),this.defaultMode=!0,this.currentIndex=0,this.submitted=[],new Promise((t=>{setTimeout((()=>{this.modal.open().then((()=>this.order||salla.api.withoutNotifier((()=>salla.rating.api.order(this.getRatingOrderId()))).then((async t=>{this.order=t.data,this.productReviewFactors=await this.fetchAllProductReviewFactors(t.data)})))).then((()=>this.readyUpLoyaltyPoints())).then((()=>this.modal.setTitle(`${salla.lang.get("pages.rating.rate_order")} <span class="unicode">(#${this.order.id})</span>`))).then((()=>{const t={};for(const a of this.getRateableProducts())t[a.product.id]=[];this.productImages=t})).then((()=>this.modal.stopLoading())).then((()=>this.afterOrderLoaded())).catch((a=>{t(!1),this.hasError=!0,this.errorMessage=a.response?.data?.error?.message||a.response?.data,this.modal.stopLoading()})),t(!0)}),50)}))}async openEditModal(t){await salla.onReady(),this.syncStoreSettings(),this.defaultMode=!1,this.editMode=!0,this.editType=t.type,this.editFeedbackId=t.feedback_id;try{await this.fetchEditItem(t.feedback_id),await this.readyUpLoyaltyPoints(),"product"===this.editType&&this.editItem?.product?.id&&(await this.loadCustomerOrderForEdit(),await this.ensureProductFactorsLoaded(this.editItem.product.id),this.editFactorRatings={...this.buildEditFactorRatings(this.editItem.product.id)},this.markExistingFactorRatingsAsUserFilled(this.editItem.product.id,this.editFactorRatings)),this.editModal.open()}catch(t){this.hasError=!0,this.errorMessage=t.response?.data?.error?.message||t.response?.data}}async fetchEditItem(t){const a=`rating/${t}/show`,s=await salla.api.request(a);this.editItem=s.data,this.allowAttachImages&&"product"==this.editType&&this.editItem.images.length&&(this.editItemImages=this.editItem.images.map((t=>({id:`${Math.floor(100+900*Math.random())}`,url:t}))))}async editReview(){const t=`rating/${this.editFeedbackId}`;let a;if("product"===this.editType){const t=this.editModal.querySelector('[data-type="products"]')||this.currentTab;a=this.buildProductRatingPayload(this.collectFormData(t),t),!a.product_id&&this.editItem?.product?.id&&(a.product_id=String(this.editItem.product.id))}else a=this.collectFormData(this.editModal),a.images&&(a.images=a.images.split(","));await salla.api.request(t,a,"put").then((t=>{this.editModal.close(),salla.notify.success(t.message||this.updatedSuccessfullyLabel),setTimeout((()=>{window.location.reload()}),500)}))}async openDeleteModal(t){return this.defaultMode=!1,this.deleteMode=!0,this.deleteFeedbackId=t.feedback_id,this.shouldOpenDeleteModal=!0,new Promise((t=>{setTimeout((()=>{this.deleteModal.open().then((()=>t(!0)))}),50)}))}async deleteReview(){const t=`rating/${this.deleteFeedbackId}`;await salla.api.request(t,null,"delete").then((()=>{this.deleteModal.close(),salla.notify.success(this.deletedSuccessfullyLabel),setTimeout((()=>{window.location.reload()}),500)}))}async close(){return this.modal.close()}handleWizard(){this.steps=this.modal.querySelectorAll(".s-rating-modal-step"),this.dots=this.modal.querySelectorAll(".s-rating-modal-step-dot"),0!==this.stepsCount?this.showActiveStep():this.showThankYou()}refreshWizardRefs(){this.modal&&(this.steps=this.modal.querySelectorAll(".s-rating-modal-step"),this.dots=this.modal.querySelectorAll(".s-rating-modal-step-dot"))}showActiveStep(t=null){if(this.refreshWizardRefs(),this.currentTab=t||this.steps[this.currentIndex],!this.currentTab)return;l.toggleClassIf(".s-rating-modal-step-dot","s-rating-modal-bg-gray","s-rating-modal-bg-primary",(t=>t!=this.dots[this.currentIndex])).toggleClassIf(".s-rating-modal-step","s-rating-modal-active","s-rating-modal-hidden",(t=>t==this.currentTab)),0!==this.currentIndex&&(l.toggleElementClassIf(this.currentTab,"s-rating-modal-unactive","s-rating-modal-hidden",(()=>!0)),setTimeout((()=>l.toggleElementClassIf(this.currentTab,"s-rating-modal-active","s-rating-modal-unactive",(()=>!0))),300));const a=this.steps[this.currentIndex+1]?.dataset.type;this.nextBtn?.setText(a?`${salla.lang.get("pages.rating.rate")} ${salla.lang.get(`pages.rating.${a}`)}`:salla.lang.get("pages.rating.send_ratings")),setTimeout((()=>this.updateBodyHeight()),0),setTimeout((()=>this.updateBodyHeight()),150)}updateBodyHeight(){this.body&&this.currentTab&&(this.body.style.height="products"!==this.currentTab.dataset.type?`${this.currentTab.offsetHeight+(this.editMode?60:0)}px`:"auto")}previousTab(){this.currentIndex>0&&this.currentIndex--,l.toggleElementClassIf(this.backBtn,"s-rating-modal-unvisiable","block",(()=>0==this.currentIndex)),this.showActiveStep()}async submit(){this.refreshWizardRefs();try{this.submittedBefore()||this.validate(),salla.config.canLeave=!1,await this.nextBtn.load(),this.submittedBefore()||await this.sendFeedback(),this.currentTab?.querySelectorAll("[name],.s-rating-modal-btn-star").forEach((t=>t.setAttribute("disabled",""))),this.currentIndex<this.stepsCount&&this.currentIndex++,this.showActiveStep(),l.toggleClassIf("#prev-btn","block","s-rating-modal-unvisiable",(()=>!0)),this.currentIndex===this.stepsCount&&(this.showThankYou(),this.showContactWidget=!1)}finally{this.nextBtn.stop(),salla.config.canLeave=!0}}submittedBefore(){return this.submitted.includes(this.currentIndex)}getRatingHiddenInput(t){const a=t,s=a.querySelector?.(".rating_hidden_input");if(s?.name)return s;const i=a.querySelector?.("salla-rating-stars");return i?.shadowRoot?.querySelector(".rating_hidden_input")||null}collectNamedInputs(t){const a=new Set,s=[],i=t=>{t?.name&&!a.has(t)&&(a.add(t),s.push(t))};return t.querySelectorAll("[name]").forEach((t=>{i(t)})),t.querySelectorAll("salla-rating-stars").forEach((t=>{i(this.getRatingHiddenInput(t))})),s}normalizeFactorsList(t){return t?Array.isArray(t)?t:"object"==typeof t?Object.values(t).filter((t=>t&&"object"==typeof t)):[]:[]}validate(t=null,a=null){if(!t&&"products"===this.currentTab.dataset.type)return void this.currentTab.querySelectorAll(".rating-outer-form").forEach((t=>this.validate(t,"product")));const s=(t=t||this.currentTab).querySelector(".s-rating-modal-product-rating-row-main"),i=this.getRatingHiddenInput(s||t),e=i?.value,r=t.querySelector(".s-rating-modal-validation-msg");if(a=a||t.dataset.type,!e)throw r.innerHTML=salla.lang.get(`pages.rating.rate_${a}_stars`).replace(" (:item)",""),new Error(r.innerHTML);if("product"===a&&Array.from(t.querySelectorAll('.s-rating-modal-product-factor-row[data-required="true"]')).some((t=>{const a=this.getRatingHiddenInput(t);return!a?.value})))throw r.innerHTML=this.requiredFactorsLabel,new Error(r.innerHTML);r.innerHTML=""}collectFormData(t=this.currentTab){const a={};return this.collectNamedInputs(t).forEach((t=>{const s=salla.helpers.inputData(t.name,t.value,a);a[s.name]=s.value})),a}buildProductRatingPayload(t,a=this.currentTab){if(!t.rating){const s=a.querySelector(".s-rating-modal-product-rating-row-main"),i=this.getRatingHiddenInput(s||a);i?.value&&(t.rating=i.value)}const s=Number(t.product_id);let i=[];t.images?i="string"==typeof t.images?t.images.split(",").filter(Boolean):t.images:this.editMode&&this.allowAttachImages&&s?i=this.editItemImages.map((t=>t.url)):this.allowAttachImages&&s&&(i=(this.productImages[s]||[]).map((t=>t.url)));const e=this.normalizeFactorsList(t.factors).filter((t=>t?.id&&t?.rating)).map((t=>({id:String(t.id),rating:String(t.rating)})));return{order_id:this.getSubmitOrderId(),product_id:String(t.product_id),rating:String(t.rating),comment:t.comment||t.content||"",images:i,factors:e,type:"products"}}async sendFeedback(){this.refreshWizardRefs();const t=this.currentTab?.dataset?.type;if("products"===t){const t=this.collectFormData(this.currentTab),a=this.buildProductRatingPayload(t,this.currentTab);if(!a.product_id||!a.rating)throw new Error("Missing product rating data");const s=await salla.rating.api.products(a);return this.submitted.push(this.currentIndex),s}const a=this.collectFormData(this.currentTab);if(0===Object.keys(a).length)return;a.order_id=this.getSubmitOrderId(),a.type=t;const s=await salla.rating.api[t](a);return this.submitted.push(this.currentIndex),s}clearThanksCountdown(){null!==this.thanksCountdownInterval&&(clearInterval(this.thanksCountdownInterval),this.thanksCountdownInterval=null)}showThankYou(){let t=10;this.clearThanksCountdown(),this.thanksCountdownInterval=setInterval((()=>{this.thanksTime.innerHTML="00:0"+t--,t>0||(this.clearThanksCountdown(),this.thanksTime.remove(),this.close().then((()=>window.location.reload())))}),1e3),this.modal.querySelector(".s-rating-modal-footer").classList.add("s-rating-modal-unvisiable"),this.showActiveStep(this.thanksTab)}getFilepondPlaceholder(){return`<div class="s-rating-modal-filepond-placeholder"><span class="s-rating-modal-filepond-placeholder-icon">${d}</span><p class="s-rating-modal-filepond-placeholder-text">${this.dragAndDropFilesLabel}<br>\n <span> ${this.allowedImagesTypesLabel} <br> ${this.threeImagesMax} </span></p></div>`}getCustomerName(){return`${salla.config.get("user.first_name")||salla.storage.get("user.first_name")||""} ${salla.config.get("user.last_name")||salla.storage.get("user.last_name")||""}`}async readyUpLoyaltyPoints(){const t=salla.loyalty?.isFeatureEnabled?.();if(!t)return void(this.loyaltyImageRatingPoints=0);const a=salla.config.get("store.settings.rating.rating_product_points")||0,s=salla.config.get("store.settings.rating.rating_product_with_image_points")||0;this.loyaltyImageRatingPoints=Number(s)+Number(a)}loyaltyPointsNote(){if(!this.loyaltyImageRatingPoints||!this.loyaltyPointsForImagesLabel)return null;const t=s("svg",{width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s("path",{d:"M10 0C13.6819 0 16.6667 2.98477 16.6667 6.66664C16.6667 9.37047 15.057 11.6984 12.7437 12.7444C11.6978 15.0575 9.3701 16.6666 6.66668 16.6666C2.98477 16.6666 0 13.6819 0 9.99998C0 7.29656 1.60918 4.96894 3.92195 3.92276C4.96827 1.60964 7.29618 0 10 0ZM6.66668 5C3.90524 5 1.66667 7.23856 1.66667 9.99998C1.66667 12.7614 3.90524 15 6.66668 15C9.4281 15 11.6667 12.7614 11.6667 9.99998C11.6667 7.23856 9.4281 5 6.66668 5ZM7.50002 5.83333V6.66664H9.16668V8.33331H5.83333C5.60322 8.33331 5.41667 8.51989 5.41667 8.74998C5.41667 8.95456 5.56407 9.12464 5.75844 9.15998L5.83333 9.16664H7.50002C8.6506 9.16664 9.58335 10.0994 9.58335 11.25C9.58335 12.4006 8.6506 13.3333 7.50002 13.3333V14.1666H5.83333V13.3333H4.16667V11.6666H7.50002C7.7301 11.6666 7.91668 11.4801 7.91668 11.25C7.91668 11.0455 7.76927 10.8753 7.57493 10.8401L7.50002 10.8333H5.83333C4.68274 10.8333 3.75 9.90056 3.75 8.74998C3.75 7.59939 4.68274 6.66664 5.83333 6.66664V5.83333H7.50002ZM10 1.66667C8.51377 1.66667 7.17893 2.31513 6.26313 3.34457C6.39704 3.33736 6.53138 3.33333 6.66668 3.33333C10.3486 3.33333 13.3333 6.3181 13.3333 9.99998C13.3333 10.1356 13.3293 10.2702 13.3213 10.4037C14.3513 9.48814 15 8.15314 15 6.66664C15 3.90524 12.7614 1.66667 10 1.66667Z",fill:"#008C56"}));return s("div",{class:"s-rating-modal-loyalty-points-note-container"},s("span",{class:"s-rating-modal-loyalty-points-note-icon"},t),s("p",{class:"s-rating-modal-loyalty-points-note-text"},this.loyaltyPointsForImagesLabel.replace(":points",String(this.loyaltyImageRatingPoints))))}normalizeReviewFactorsPayload(t){const a=t?.data??t?.factors;return Array.isArray(a)?a.flatMap((t=>{const a=Array.isArray(t?.items)?[...t.items]:null;if(a?.length){a.sort(((t,a)=>(Number(t?.sort)||0)-(Number(a?.sort)||0)));const s=!!t?.is_required;return a.filter((t=>null!=t?.id&&""!==t?.id)).map((t=>({id:t.id,name:t?.name,required:s})))}return null==t?.id||""===t?.id?[]:[{id:t.id,name:t?.name,required:t?.required??t?.is_required??!1}]})):[]}async fetchProductReviewFactors(t){try{const a=await salla.api.request(`review/factors/${t}/form`);return this.normalizeReviewFactorsPayload(a)}catch(t){return[]}}async fetchAllProductReviewFactors(t){const a=this.getRateableProducts(t);if(!a.length)return{};const s=await Promise.all(a.map((async t=>{const a=await this.fetchProductReviewFactors(t.product.id);return[t.product.id,a]})));return Object.fromEntries(s)}async ensureProductFactorsLoaded(t){if(!t||this.productReviewFactors[t])return;const a=await this.fetchProductReviewFactors(t);this.productReviewFactors={...this.productReviewFactors,[t]:a}}getFactorFieldName(t,a,s){return t?`${t}[factors][${a}][${s}]`:`factors[${a}][${s}]`}normalizeToArray(t){return null==t?[]:Array.isArray(t)?t:[t]}isFactorReviewsList(t){return Array.isArray(t)&&t.length>0&&t.every((t=>t&&"object"==typeof t&&(void 0!==t.rating||void 0!==t.stars||void 0!==t.value)))}getFactorReviewsFromRecord(t){if(!t)return[];for(const a of["factor_reviews","review_factors","factors"]){const s=t[a];if(this.isFactorReviewsList(s))return s}return[]}getEditFactorReviewsList(t){const a=[this.order,this.getBootstrapOrder()].filter(Boolean);for(const s of a){const a=this.getMatchedProductRating(s,t,this.editFeedbackId),i=this.getFactorReviewsFromRecord(a);if(i.length)return i}const s=this.getOrderProducts(this.order).find((a=>Number(a.product?.id)===Number(t))),i=[this.editItem?.factor_reviews,this.editItem?.review_factors,this.editItem?.product?.review_factors,this.editItem?.product?.factor_reviews,this.editItem?.factors,s?.factor_reviews,s?.review_factors,s?.feedback?.factor_reviews];for(const t of i)if(Array.isArray(t)&&t.length>0)return t;return[]}getFactorKey(t,a){return null!=t.id&&""!==t.id?`id:${t.id}`:t.name?`name:${t.name.trim()}`:`index:${a}`}getFactorRatingsForProduct(t){return this.editMode?this.editFactorRatings:this.productFactorRatings[t]||{}}setFactorRatingsForProduct(t,a){this.editMode?this.editFactorRatings=a:this.productFactorRatings={...this.productFactorRatings,[t]:a}}markExistingFactorRatingsAsUserFilled(t,a){const s=this.productReviewFactors[t]||[],i=new Set;s.forEach(((t,s)=>{const e=this.getFactorKey(t,s),r=void 0!==t.id?a[String(t.id)]:void 0,n=t.name?a[t.name.trim()]:void 0;void 0===r&&void 0===n&&void 0===a[`__index_${s}`]||i.add(e)})),this.userFilledFactorKeys[t]=i}shouldAutofillFactors(t){return 4===t||5===t}autofillUnfilledFactors(t,a){const s=this.productReviewFactors[t]||[];if(!s.length)return;const i=this.userFilledFactorKeys[t]||new Set,e={...this.getFactorRatingsForProduct(t)},r=this.shouldAutofillFactors(a);let n=!1;s.forEach(((t,s)=>{const o=this.getFactorKey(t,s);if(!i.has(o)){if(r)return void 0!==t.id&&(e[String(t.id)]=a),t.name&&(e[t.name.trim()]=a),e[`__index_${s}`]=a,void(n=!0);void 0!==t.id&&void 0!==e[String(t.id)]&&(delete e[String(t.id)],n=!0),t.name&&void 0!==e[t.name.trim()]&&(delete e[t.name.trim()],n=!0),void 0!==e[`__index_${s}`]&&(delete e[`__index_${s}`],n=!0)}})),n&&this.setFactorRatingsForProduct(t,e)}handleMainRatingChange(t,a){this.editMode?this.editMainRating=a:this.productMainRatings={...this.productMainRatings,[t]:a},this.autofillUnfilledFactors(t,a)}handleFactorRatingChange(t,a,s){this.userFilledFactorKeys[t]||(this.userFilledFactorKeys[t]=new Set),this.userFilledFactorKeys[t].add(a);const i=this.productReviewFactors[t]||[],e=i.findIndex(((t,s)=>this.getFactorKey(t,s)===a));if(e<0)return;const r=i[e],n={...this.getFactorRatingsForProduct(t)};void 0!==r.id&&(n[String(r.id)]=s),r.name&&(n[r.name.trim()]=s),n[`__index_${e}`]=s,this.setFactorRatingsForProduct(t,n)}setupProductRatingAutofill(t,a){t&&!this.boundRatingRows.has(t)&&(this.boundRatingRows.add(t),t.addEventListener("click",(s=>{const i=s.target;if(!i.closest(".s-rating-stars-btn-star"))return;const e=i.closest(".s-rating-modal-product-rating-row-main"),r=i.closest(".s-rating-modal-product-factor-row");requestAnimationFrame((()=>{if(e&&t.contains(e)){const t=Number(this.getRatingHiddenInput(e)?.value);t>0&&this.handleMainRatingChange(a,t)}else if(r&&t.contains(r)){const t=r.getAttribute("data-factor-key"),s=Number(this.getRatingHiddenInput(r)?.value);t&&s>0&&this.handleFactorRatingChange(a,t,s)}}))})))}buildEditFactorRatings(t){return this.getEditFactorReviewsList(t).reduce(((t,a,s)=>{const i=Number(a?.rating??a?.stars??a?.value);if(Number.isNaN(i))return t;const e=a?.id??a?.factor_id;return null!=e&&""!==e&&(t[String(e)]=i),a?.name&&(t[a.name.trim()]=i),t[`__index_${s}`]=i,t}),{})}renderProductStep(t,a){return s("section",{class:"s-rating-modal-step s-rating-modal-hidden","data-type":"products","data-product-id":t.product.id,key:t.product.id},s("div",{class:"s-rating-modal-product"},this.allowAttachImages&&this.loyaltyPointsNote(),s("div",{class:"rating-outer-form","data-stars-error":salla.lang.get("pages.rating.rate_product_stars")},s("div",{class:"s-rating-modal-product-details"},s("div",{class:"s-rating-modal-product-info-row"},s("div",{class:"s-rating-modal-product-img-wrap"},s("img",{src:t.product.thumbnail,alt:t.product.name,class:"s-rating-modal-product-img"})),s("h3",{class:"s-rating-modal-product-title"},t.product.name)),this.renderProductReviewFactors(t.product.id,0,{fieldPrefix:""}),s("input",{type:"hidden",name:"product_id",value:t.product.id}),s("textarea",{placeholder:salla.lang.get("pages.rating.write_product_rate"),name:"comment",class:"s-rating-modal-comment"}),s("small",{class:"s-rating-modal-validation-msg"}))),this.allowAttachImages&&s("div",{class:"s-rating-modal-uploader is-opened",ref:t=>this.contentRefs[a]=t},s("salla-file-upload",{name:"image",maxFilesCount:this.MAX_UPLOAD_LIMIT,imagePreviewHeight:117,"instant-upload":!0,type:"feedback",payloadName:"files[]",id:`file-${t.product.id}`,title:t.product.name,allowMultiple:!0,instantUpload:!0,accept:"image/png, image/jpeg, image/jpg",url:salla.url.api("upload"),onUploaded:s=>{this.productImages={...this.productImages,[t.product.id]:[...this.productImages[t.product.id]||[],s.detail]},this.hiddenInputs[a].value=this.productImages[t.product.id].map((t=>t.url)).join(",")},onRemoved:s=>{const i=s.detail;i&&this.productImages[t.product.id]&&(this.productImages={...this.productImages,[t.product.id]:this.productImages[t.product.id].filter((t=>t.id!==i))},this.hiddenInputs[a].value=this.productImages[t.product.id].map((t=>t.url)).join(","))},labelIdle:this.getFilepondPlaceholder()}),s("input",{type:"hidden",name:"images",value:(this.productImages[t.product.id]||[]).map((t=>t.url)).join(","),ref:t=>this.hiddenInputs[a]=t}),this.renderUploadedImagesCount(t.product.id))))}renderProductReviewFactors(t,a,i={}){const e=this.productReviewFactors[t]||[],r=i.fieldPrefix??`products[${a}]`,n=r?`${r}[rating]`:"rating",o={...this.editMode?{}:this.productFactorRatings[t]||{},...i.factorRatings||{}},l=Number(i.mainRating??(this.editMode?this.editMainRating:this.productMainRatings[t])),d=!Number.isNaN(l),h=(t,a)=>{const s=void 0!==t.id?o[String(t.id)]:void 0,i=t.name?o[t.name.trim()]:void 0,e=Number(s??i??o[`__index_${a}`]);return Number.isNaN(e)?void 0:e};return s("div",{class:"s-rating-modal-product-rating-rows",ref:a=>this.setupProductRatingAutofill(a,t)},s("div",{class:"s-rating-modal-product-rating-row s-rating-modal-product-rating-row-main"},s("span",{class:"s-rating-modal-product-factor-name"},this.overallProductRatingLabel,s("span",{class:"s-rating-modal-product-factor-required"},"*")),s("salla-rating-stars",{size:"medium",name:n,key:d?`main-rating-${l}`:"main-rating-empty",value:d?l:void 0,editable:d,withLabel:!0,labelBeforeStars:!0,tag:!1})),e.map(((t,a)=>s("div",{class:"s-rating-modal-product-rating-row s-rating-modal-product-factor-row px-3","data-required":t.required?"true":"false","data-factor-key":this.getFactorKey(t,a)},s("input",{type:"hidden",name:this.getFactorFieldName(r,a,"name"),value:t.name}),!!t.id&&s("input",{type:"hidden",name:this.getFactorFieldName(r,a,"id"),value:String(t.id)}),s("span",{class:"s-rating-modal-product-factor-name"},t.name,t.required?s("span",{class:"s-rating-modal-product-factor-required"},"*"):""),s("salla-rating-stars",{size:"medium",name:this.getFactorFieldName(r,a,"rating"),key:`factor-rating-${t.id??a}-${h(t,a)??0}`,value:h(t,a),editable:i.alwaysEditable||"number"==typeof h(t,a),withLabel:!0,labelBeforeStars:!0,tag:!1})))))}handleSendEmail(){const t=`${this.contactSubjectLabel} #${this.order.id}`,a=this.contact_body(salla.config.get("store.name"),this.order.id,this.getCustomerName()),s=`mailto:${salla.config.get("store.contacts.email")}?subject=${encodeURIComponent(t)}&body=${encodeURIComponent(a)}`;window.open(s,"_blank")}handleSendWhatsApp(){const t=this.contact_body(salla.config.get("store.name"),this.order.id,this.getCustomerName()),a=`https://wa.me/${salla.config.get("store.contacts.whatsapp")}?text=${encodeURIComponent(t)}`;window.open(a,"_blank")}resetData(t){t.detail||(this.clearThanksCountdown(),this.modal?.close(),this.editItem=null,this.editItemImages=[],this.editFactorRatings={},this.productMainRatings={},this.productFactorRatings={},this.editMainRating=void 0,this.userFilledFactorKeys={},this.hiddenInputs[1]&&(this.hiddenInputs[1].value=""),this.deleteFeedbackId=null,this.editFeedbackId=null,this.shouldOpenDeleteModal=!1,this.editMode=!1,this.deleteMode=!1,this.defaultMode=!1,this.currentIndex=0,this.submitted=[],this.scheduleWizardSetup=!1,this.loyaltyImageRatingPoints=0)}getDeleteModal(){return s("salla-modal",{ref:t=>this.deleteModal=t,width:"xs",onModalVisibilityChanged:t=>this.resetData(t)},s("div",{class:"s-rating-modal-delete-wrapper",ref:t=>this.body=t},s("h3",null,this.confirmDeletionLabel),s("p",null,this.areYouSureLabel),s("div",{class:"s-rating-modal-delete-actions"},s("salla-button",{loaderPosition:"center",onClick:()=>this.deleteReview()},this.confirmDeleteBtn),s("salla-button",{color:"danger",fill:"outline",onClick:()=>this.deleteModal.close()},this.cancelLabel))))}renderUploadedImagesCount(t){const a=this.editMode?this.editItemImages.length:(this.productImages[t]||[]).length;return s("span",{class:"s-rating-modal-upload-count"},salla.lang.choice("pages.rating.images_count",a,{current:a,total:this.MAX_UPLOAD_LIMIT}))}getEditModal(){return s("salla-modal",{ref:t=>this.editModal=t,width:"md",onModalVisibilityChanged:t=>this.resetData(t)},s("div",{class:"s-rating-modal-edit-wrapper",ref:t=>this.body=t},"store"===this.editType&&this.editItem?s("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step","data-type":"store",ref:t=>this.currentTab=t},s("div",{class:"s-rating-modal-rounded-icon"},s("img",{src:salla.config.get("store.logo","https://assets.salla.sa/cp/assets/images/logo-new.png"),alt:"store name",class:"s-rating-modal-store-logo"})),s("h2",{class:"s-rating-modal-title"},salla.lang.get("pages.rating.rate_the_store")),s("div",{class:"s-rating-modal-stars-company"},s("salla-rating-stars",{withLabel:!0,size:"large",editable:!0,value:this.editItem.stars})),s("textarea",{name:"content",value:this.editItem.content,class:"s-rating-modal-comment",placeholder:salla.lang.get("pages.rating.write_store_rate")}),s("small",{class:"s-rating-modal-validation-msg"})):null,"shipping"===this.editType&&this.editItem?s("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step","data-type":"shipping",ref:t=>this.currentTab=t},this.editItem.shipping.logo?s("div",{class:"s-rating-modal-rounded-icon"},s("img",{src:this.editItem.shipping.logo,class:"s-rating-modal-shipping-logo",alt:this.editItem.shipping.name})):s("span",{class:"s-rating-modal-icon",innerHTML:n}),s("div",{class:"s-rating-modal-title"}," ",`${salla.lang.get("pages.rating.rate_shipping")} ${this.editItem.shipping.name}`),s("div",{class:"s-rating-modal-stars-company"},s("salla-rating-stars",{withLabel:!0,size:"large",editable:!0,value:this.editItem.stars})),s("textarea",{name:"content",class:"s-rating-modal-comment",value:this.editItem.content,placeholder:salla.lang.get("pages.rating.write_shipping_rate")}),s("small",{class:"s-rating-modal-validation-msg"})):null,"product"==this.editType&&this.editItem?s("section",{class:"s-rating-modal-step","data-type":"products",ref:t=>this.currentTab=t},s("div",{class:"s-rating-modal-product"},this.allowAttachImages&&this.loyaltyPointsNote(),s("div",{class:"rating-outer-form","data-stars-error":salla.lang.get("pages.rating.rate_product_stars")},s("div",{class:"s-rating-modal-product-details"},s("div",{class:"s-rating-modal-product-info-row"},s("div",{class:"s-rating-modal-product-img-wrap"},s("img",{src:this.editItem.product.image.url,alt:this.editItem.product.name,class:"s-rating-modal-product-img"})),s("h3",{class:"s-rating-modal-product-title"},this.editItem.product.name)),this.renderProductReviewFactors(this.editItem.product.id,0,{fieldPrefix:"",mainRating:this.editMainRating??Number(this.editItem.stars??this.editItem.rating),factorRatings:this.editFactorRatings,alwaysEditable:!0}),s("input",{type:"hidden",name:"product_id",value:this.editItem.product.id}),s("textarea",{value:this.editItem.content,placeholder:salla.lang.get("pages.rating.write_product_rate"),name:"comment",class:"s-rating-modal-comment"}),s("small",{class:"s-rating-modal-validation-msg"}))),this.allowAttachImages&&s("div",{class:"s-rating-modal-uploader is-opened",ref:t=>this.contentRefs[1]=t},s("salla-file-upload",{name:"images",allowMultiple:!0,maxFilesCount:this.MAX_UPLOAD_LIMIT,imagePreviewHeight:117,filePosterHeight:117,"instant-upload":!0,type:"feedback",files:JSON.stringify(this.editItemImages),payloadName:"files[]",id:`file-${this.editItem.product.id}`,title:this.editItem.product.name,instantUpload:!0,accept:"image/png, image/jpeg, image/jpg",url:salla.url.api("upload"),onUploaded:t=>{this.editItemImages=[...this.editItemImages,t.detail],this.hiddenInputs[1].value=this.editItemImages.map((t=>t.url)).join()},onRemoved:t=>{const a=t.detail;a&&(this.editItemImages=this.editItemImages.filter((t=>t.id!==a)),this.hiddenInputs[1].value=this.editItemImages.map((t=>t.url)).join())},labelIdle:this.getFilepondPlaceholder()}),s("input",{type:"hidden",name:"images",value:this.editItemImages.map((t=>t.url)).join(","),ref:t=>this.hiddenInputs[1]=t}),this.renderUploadedImagesCount(this.editItem.product.id)))):null,s("div",{class:"s-rating-modal-footer s-rating-modal-footer-end"},s("salla-button",{"loader-position":"center",onClick:()=>this.editReview()},this.editReviewLabel))))}render(){return this.deleteMode?s(i,{class:"s-rating-modal"},this.getDeleteModal()):this.editMode?s(i,{class:"s-rating-modal"},this.getEditModal()):this.defaultMode?s(i,{class:"s-rating-modal"},s("salla-modal",{class:"s-rating-modal-wrap",onModalVisibilityChanged:t=>this.resetData(t),isLoading:!0,width:"md",ref:t=>this.modal=t},s("div",{slot:"loading"},s("div",{class:"s-rating-modal-skeleton"},s("salla-skeleton",{type:"circle",height:"80px",width:"80px"}),s("salla-skeleton",{height:"15px",width:"60%"}),s("salla-skeleton",{height:"10px",width:"30%"}),s("div",{class:"s-rating-modal-skeleton-stars"},[...Array(5)].map((t=>s("div",{key:t,innerHTML:r})))),s("salla-skeleton",{height:"100px",width:"100%"}),s("div",{class:"s-rating-modal-skeleton-footer"},s("salla-skeleton",{height:"40px",width:"30%"})))),!this.hasError&&this.order?[s("div",{class:"s-rating-modal-wrapper",ref:t=>this.body=t},this.isTestimonialsEnabled()?s("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"store"},s("div",{class:"s-rating-modal-rounded-icon"},s("img",{src:salla.config.get("store.logo","https://assets.salla.sa/cp/assets/images/logo-new.png"),alt:"store name",class:"s-rating-modal-store-logo"})),s("h2",{class:"s-rating-modal-title"},salla.lang.get("pages.rating.rate_the_store")),s("div",{class:"s-rating-modal-stars-company"},s("salla-rating-stars",{withLabel:!0,size:"large"})),s("textarea",{name:"comment",class:"s-rating-modal-comment",placeholder:salla.lang.get("pages.rating.write_store_rate")}),s("small",{class:"s-rating-modal-validation-msg"})):"",this.isProductsEnabled()&&this.getRateableProducts().map(((t,a)=>this.renderProductStep(t,a))),this.isShippingEnabled()&&this.order.shipping?.company?s("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"shipping"},s("input",{type:"hidden",name:"shipping_company_id",value:this.order.shipping.company.id}),this.order.shipping.company.logo?s("div",{class:"s-rating-modal-rounded-icon"},s("img",{src:this.order.shipping.company.logo,class:"s-rating-modal-shipping-logo",alt:this.order.shipping.company.name})):s("span",{class:"s-rating-modal-icon",innerHTML:n}),s("div",{class:"s-rating-modal-title"}," ",`${salla.lang.get("pages.rating.rate_shipping")} ${this.order.shipping.company.name}`),s("div",{class:"s-rating-modal-stars-company"},s("salla-rating-stars",{withLabel:!0,size:"large"})),s("textarea",{name:"comment",class:"s-rating-modal-comment",placeholder:salla.lang.get("pages.rating.write_shipping_rate")}),s("small",{class:"s-rating-modal-validation-msg"})):"",s("div",{class:"s-rating-modal-thanks s-rating-modal-hidden",ref:t=>this.thanksTab=t},s("span",{class:"s-rating-modal-icon",innerHTML:o}),s("h3",{class:"s-rating-modal-thanks-title"},salla.lang.get("pages.rating.thanks")),s("div",{class:"s-rating-modal-thanks-msg",innerHTML:this.order.thanks_message}),s("time",{class:"s-rating-modal-thanks-time",ref:t=>this.thanksTime=t}))),this.allowContactSupport&&this.showContactWidget&&(salla.config.get("store.contacts.whatsapp")||salla.config.get("store.contacts.email"))?s("div",{class:"s-rating-modal-contact"},s("p",null,this.contactUsLabel),s("div",{class:"s-rating-modal-contact-icons"},salla.config.get("store.contacts.whatsapp")&&s("span",{onClick:()=>this.handleSendWhatsApp(),innerHTML:h}),salla.config.get("store.contacts.email")&&s("span",{onClick:()=>this.handleSendEmail(),innerHTML:g}))):"",s("div",{class:"s-rating-modal-footer"},s("button",{ref:t=>this.backBtn=t,onClick:()=>this.previousTab(),class:"s-rating-modal-btn s-rating-modal-unvisiable"},salla.lang.get("common.elements.back")),this.stepsCount>1?s("ul",{class:"s-rating-modal-dots"},[...Array(this.stepsCount)].map(((t,a)=>s("li",{key:a,class:"s-rating-modal-bg-gray s-rating-modal-step-dot"})))):"",s("salla-button",{"loader-position":"center",ref:t=>this.nextBtn=t,onClick:()=>this.submit()},salla.lang.get("common.elements.next")))]:s("salla-placeholder",{alignment:"center"}))):void 0}async componentWillLoad(){await salla.onReady(),this.syncStoreSettings()}componentDidRender(){this.scheduleWizardSetup&&this.defaultMode&&this.order&&(this.scheduleWizardSetup=!1,requestAnimationFrame((()=>this.handleWizard())))}disconnectedCallback(){this.clearThanksCountdown()}get host(){return e(this)}};m.style=".s-rating-modal-product-details{padding-bottom:0.5rem}.s-rating-modal-comment{margin-top:0.35rem}.s-rating-modal-product{margin-bottom:1rem}.s-rating-modal-product-img{position:absolute !important;inset:0;display:block;width:100% !important;max-width:100% !important;height:100% !important;object-fit:cover}.s-rating-modal-product-title{font-size:0.95rem;font-weight:600;line-height:1.5;margin:0}.s-rating-modal-stars-product{margin-top:0.5rem}.s-rating-modal-loyalty-points-note-container{display:flex;align-items:center;gap:0.625rem;width:100%;margin-top:1.5rem;margin-bottom:0.75rem;padding:0.75rem;border-radius:0.5rem;background-color:#E6F4EA}.s-rating-modal-loyalty-points-note-icon{display:flex;flex-shrink:0;align-items:center;justify-content:center;width:1.25rem;height:1.25rem;color:#1B7F5C}.s-rating-modal-loyalty-points-note-icon svg{width:1.5rem;height:1.5rem;fill:currentColor}.s-rating-modal-loyalty-points-note-text{flex:1;margin:0;font-size:0.875rem;line-height:1.25rem;color:#1f2937}.s-rating-modal-product-details-main{display:flex;align-items:center;margin-bottom:0.5rem;padding-bottom:0;border-bottom:0}.s-rating-modal-product-info-row{display:flex;align-items:center;gap:0.6rem;margin-bottom:0.5rem;padding-bottom:0;border-bottom:0}.s-rating-modal-product-main-review{width:100%;text-align:right}.s-rating-modal-product-rating-rows{display:grid;gap:0.45rem;margin:0.2rem 0 0.7rem}.s-rating-modal-product-rating-row{display:flex;align-items:center;justify-content:space-between;gap:0.75rem;min-height:2rem}.s-rating-modal-product-rating-row salla-rating-stars{flex-shrink:0}.s-rating-modal-product-rating-row .s-rating-stars-wrapper{align-items:center;min-height:1.75rem}.s-rating-modal-product-rating-row .s-rating-stars-label,.s-rating-modal-product-rating-row .s-rating-stars-label-without-tag{min-width:auto;min-height:1.25rem;line-height:1.25rem;font-size:0.8rem;color:#5b6470;white-space:nowrap;text-align:end;transition:opacity 0.15s ease}.s-rating-modal-product-rating-row .s-rating-stars-label--empty,.s-rating-modal-product-rating-row .s-rating-stars-label-without-tag--empty{opacity:0}.s-rating-modal-product-rating-row-main{margin-bottom:0.35rem;padding:0.5rem 0.6rem;border:1px solid #d1d5db;border-radius:0.45rem;background:transparent}.s-rating-modal-product-factor-name{color:#5b6470;font-size:0.9rem;line-height:1.25}.s-rating-modal-product-rating-row-main .s-rating-modal-product-factor-name{font-size:1rem;color:#5b6470}.s-rating-modal-product-factor-required{color:#f87171;margin-inline-start:0.2rem}.s-rating-modal-product-img-wrap{position:relative;width:5rem !important;min-width:5rem !important;max-width:5rem !important;height:3.5rem !important;flex-shrink:0 !important;overflow:hidden;border-radius:0.375rem;background:#f3f4f6}.s-rating-modal-uploader.is-opened{height:auto !important;opacity:1 !important;overflow:visible !important;pointer-events:auto !important;margin-bottom:1rem}";export{m as salla_rating_modal_v2}
4
+ import{r as t,f as a,h as s,H as i,a as e}from"./p-DgmW0rL4.js";import{S as r}from"./p-CeFAfcTv.js";import{S as n}from"./p-lMgMt31Q.js";import{C as o}from"./p-BV4kqbdL.js";import{H as l}from"./p-XnA1YTjA.js";import{I as d}from"./p-C-tzSDxw.js";import{W as h}from"./p-CgR-T_ZS.js";import{e as g}from"./p-DzAIgzdz.js";import"./p-CgtvEd63.js";const m=class{constructor(a){t(this,a),this.hasError=!1,this.showContactWidget=!0,this.images=[],this.productImages={},this.editItemImages=[],this.productReviewFactors={},this.editFactorRatings={},this.productMainRatings={},this.productFactorRatings={},this.contact_body=(t,a,s)=>salla.lang.get("pages.rating.contact_subject",{store:t,id:a,customer:s}),this.editMode=!1,this.defaultMode=!1,this.deleteMode=!1,this.shouldOpenDeleteModal=!1,this.editItem=null,this.allowAttachImages=!1,this.allowContactSupport=!1,this.loyaltyImageRatingPoints=0,this.dragAndDropFilesLabel=salla.lang.get("common.uploader.drag_and_drop_files"),this.contactSubjectLabel=salla.lang.get("pages.rating.contact_subject"),this.editReviewLabel=salla.lang.get("pages.rating.edit_review"),this.allowedImagesTypesLabel=salla.lang.get("common.uploader.allowed_images_types"),this.threeImagesMax=salla.lang.get("common.uploader.max_three_images"),this.areYouSureLabel=salla.lang.get("pages.rating.are_you_sure_you_want_to_delete_review"),this.confirmDeletionLabel=salla.lang.get("pages.rating.confirm_deletion"),this.cancelLabel=salla.lang.get("common.elements.cancel"),this.confirmDeleteBtn=salla.lang.get("common.elements.confirm_delete"),this.updatedSuccessfullyLabel=salla.lang.get("pages.rating.review_updated_successfully"),this.deletedSuccessfullyLabel=salla.lang.get("pages.rating.review_deleted_successfully"),this.contactUsLabel=salla.lang.get("blocks.footer.social"),this.requiredFactorsLabel=salla.lang.get("pages.rating.rate_required_factors"),this.overallProductRatingLabel=salla.lang.get("pages.rating.overall_product_rating"),this.loyaltyPointsForImagesLabel=salla.lang.get("pages.rating.loyalty_points_for_images",{points:":points"}),this.contentRefs=[],this.hiddenInputs=[],this.userFilledFactorKeys={},this.boundRatingRows=new WeakSet,this.stepsCount=0,this.currentIndex=0,this.submitted=[],this.MAX_UPLOAD_LIMIT=3,this.thanksCountdownInterval=null,this.scheduleWizardSetup=!1,salla.lang.onLoaded((()=>{this.contactUsLabel=salla.lang.get("blocks.footer.social");const t=(t,a,s)=>new Promise((i=>{salla.helpers.setNested(salla.lang.messages[t],a,s),i(!0)}));(async()=>{await t("ar.trans","common.uploader.drag_and_drop_files","اسحب الملفات وأفلتها هنا"),await t("en.trans","common.uploader.drag_and_drop_files","Drag and drop files here"),await t("ar.trans","common.uploader.allowed_images_types"," .jpg أو jpeg أو png يُسمح بإضافة صور بصيغة"),await t("en.trans","common.uploader.allowed_images_types","Images in jpg, jpeg, or png format are allowed."),await t("ar.trans","pages.rating.add_images","اضافة صور"),await t("en.trans","pages.rating.add_images","Add Images"),await t("ar.trans","pages.rating.edit_images","تعديل الصور"),await t("en.trans","pages.rating.edit_images","Edit Images"),await t("ar.trans","pages.rating.edit_review","تعديل التقييم"),await t("en.trans","pages.rating.edit_review","Edit review"),await t("ar.trans","pages.rating.confirm_deletion","تأكيد حذف التقييم"),await t("en.trans","pages.rating.confirm_deletion","Confirm review deletion"),await t("ar.trans","pages.rating.are_you_sure_you_want_to_delete_review","هل أنت متأكد من حذف تقييمك؟"),await t("en.trans","pages.rating.are_you_sure_you_want_to_delete_review","Are you sure you want to delete your review?"),await t("ar.trans","pages.rating.review_updated_successfully","تم تعديل التقييم بنجاح"),await t("en.trans","pages.rating.review_updated_successfully","The review has been successfully updated."),await t("ar.trans","pages.rating.review_deleted_successfully","تم حذف التقييم بنجاح"),await t("en.trans","pages.rating.review_deleted_successfully","The review has been successfully deleted."),await t("ar.trans","pages.rating.images_count","الصور ( :current من أصل :total )"),await t("en.trans","pages.rating.images_count","Images ( :current of :total )"),await t("ar.trans","common.uploader.max_three_images",`.أضف ${this.MAX_UPLOAD_LIMIT} صور كحد أقصى`),await t("en.trans","common.uploader.max_three_images",`Add up to ${this.MAX_UPLOAD_LIMIT} images maximum.`),await t("ar.trans","common.elements.confirm_delete","تأكيد الحذف"),await t("en.trans","common.elements.confirm_delete","Confirm deletion"),await t("ar.trans","pages.rating.rate_required_factors","يرجى تقييم جميع المعايير لإتمام مراجعتك."),await t("en.trans","pages.rating.rate_required_factors","Please rate all required factors to complete your review."),await t("ar.trans","pages.rating.overall_product_rating","التقييم العام للمنتج"),await t("en.trans","pages.rating.overall_product_rating","Overall product rating"),await t("ar.trans","pages.rating.loyalty_points_for_images","اكسب :points نقطة ولاء عند إضافة صور لتقييمك!"),await t("en.trans","pages.rating.loyalty_points_for_images","Earn :points loyalty points when adding photos to your review!"),this.dragAndDropFilesLabel=salla.lang.get("common.uploader.drag_and_drop_files"),this.allowedImagesTypesLabel=salla.lang.get("common.uploader.allowed_images_types"),this.threeImagesMax=salla.lang.get("common.uploader.max_three_images"),this.contactSubjectLabel=salla.lang.get("pages.rating.contact_subject"),this.editReviewLabel=salla.lang.get("pages.rating.edit_review"),this.areYouSureLabel=salla.lang.get("pages.rating.are_you_sure_you_want_to_delete_review"),this.confirmDeletionLabel=salla.lang.get("pages.rating.confirm_deletion"),this.cancelLabel=salla.lang.get("common.elements.cancel"),this.updatedSuccessfullyLabel=salla.lang.get("pages.rating.review_updated_successfully"),this.deletedSuccessfullyLabel=salla.lang.get("pages.rating.review_deleted_successfully"),this.confirmDeleteBtn=salla.lang.get("common.elements.confirm_delete"),this.requiredFactorsLabel=salla.lang.get("pages.rating.rate_required_factors"),this.overallProductRatingLabel=salla.lang.get("pages.rating.overall_product_rating"),this.loyaltyPointsForImagesLabel=salla.lang.get("pages.rating.loyalty_points_for_images",{points:":points"}),this.contact_body=(t,a,s)=>salla.lang.get("pages.rating.contact_body",{store:t,id:a,customer:s})})()}))}syncStoreSettings(){this.orderId||(this.orderId=salla.config.get("page.id")),this.allowAttachImages=!!salla.config.get("store.settings.rating.allow_attach_images"),this.allowContactSupport=!!salla.config.get("store.settings.rating.allow_contact_support")}getRatingOrderId(){return this.orderId||salla.config.get("page.id")}getSubmitOrderId(){return this.orderId}isCustomerOrderShape(t){if(!t||"object"!=typeof t)return!1;const a=t;return!!a.rating&&(Array.isArray(a.items)||Array.isArray(a.products)||Array.isArray(a.rating?.product)||Array.isArray(a.rating?.products))}getBootstrapOrder(){const t=salla.config.get("page");if(this.isCustomerOrderShape(t))return t;if(t&&"object"==typeof t){const a=t;if(Array.isArray(a.products))return t;const s=a.order;if(this.isCustomerOrderShape(s))return s}}async loadCustomerOrderForEdit(){const t=this.getBootstrapOrder();if(t?.rating?.product||t?.rating?.products)this.order=t;else try{const t=await salla.api.withoutNotifier((()=>salla.order.api.getDetails(this.getRatingOrderId())));t?.data&&(this.order=t.data)}catch(t){if(!this.order){const t=await salla.api.withoutNotifier((()=>salla.rating.api.order(this.getRatingOrderId())));this.order=t.data}}}getOrderProductRatings(t=this.order){return t?.rating?[...this.normalizeToArray(t.rating.product),...this.normalizeToArray(t.rating.products)]:[]}getMatchedProductRating(t=this.order,a,s){return this.getOrderProductRatings(t).find((t=>Number(t?.id??t?.feedback_id)===Number(s)||Number(t?.product_id??t?.product?.id)===Number(a)))}hasRatingFeedback(t){const a=t?.rating;return null!=a&&""!==a&&Number(a)>0}isTestimonialsEnabled(t=this.order){return!(!1===t?.testimonials_enabled||this.hasRatingFeedback(t?.store?.feedback)||!0!==t?.testimonials_enabled&&!t?.allowed_ratings?.testimonials_enabled)}isProductsEnabled(t=this.order){return!1!==t?.products_enabled&&this.getRateableProducts(t).length>0}isShippingEnabled(t=this.order){return!(!1===t?.shipping_enabled||this.hasRatingFeedback(t?.shipping?.feedback)||!t?.shipping?.company||!0!==t?.shipping_enabled&&!t?.allowed_ratings?.shipping_enabled)}getOrderProducts(t=this.order){return Array.isArray(t?.products)?t.products.filter((t=>t?.product?.id)):[]}getRateableProducts(t=this.order){return this.getOrderProducts(t).filter((t=>!this.hasRatingFeedback(t?.feedback)))}getStepsCount(t=this.order){if(!t)return 0;let a=0;return this.isTestimonialsEnabled(t)&&a++,this.isProductsEnabled(t)&&(a+=this.getRateableProducts(t).length),this.isShippingEnabled(t)&&t.shipping?.company&&a++,a}afterOrderLoaded(){this.stepsCount=this.getStepsCount(),this.scheduleWizardSetup=!0,a(this)}async open(){return await salla.onReady(),this.syncStoreSettings(),this.defaultMode=!0,this.currentIndex=0,this.submitted=[],new Promise((t=>{setTimeout((()=>{this.modal.open().then((()=>this.order||salla.api.withoutNotifier((()=>salla.rating.api.order(this.getRatingOrderId()))).then((async t=>{this.order=t.data,this.productReviewFactors=await this.fetchAllProductReviewFactors(t.data)})))).then((()=>this.readyUpLoyaltyPoints())).then((()=>this.modal.setTitle(`${salla.lang.get("pages.rating.rate_order")} <span class="unicode">(#${this.order.id})</span>`))).then((()=>{const t={};for(const a of this.getRateableProducts())t[a.product.id]=[];this.productImages=t})).then((()=>this.modal.stopLoading())).then((()=>this.afterOrderLoaded())).catch((a=>{t(!1),this.hasError=!0,this.errorMessage=a.response?.data?.error?.message||a.response?.data,this.modal.stopLoading()})),t(!0)}),50)}))}async openEditModal(t){await salla.onReady(),this.syncStoreSettings(),this.defaultMode=!1,this.editMode=!0,this.editType=t.type,this.editFeedbackId=t.feedback_id;try{await this.fetchEditItem(t.feedback_id),await this.readyUpLoyaltyPoints(),"product"===this.editType&&this.editItem?.product?.id&&(await this.loadCustomerOrderForEdit(),await this.ensureProductFactorsLoaded(this.editItem.product.id),this.editFactorRatings={...this.buildEditFactorRatings(this.editItem.product.id)},this.markExistingFactorRatingsAsUserFilled(this.editItem.product.id,this.editFactorRatings)),this.editModal.open()}catch(t){this.hasError=!0,this.errorMessage=t.response?.data?.error?.message||t.response?.data}}async fetchEditItem(t){const a=`rating/${t}/show`,s=await salla.api.request(a);this.editItem=s.data,this.allowAttachImages&&"product"==this.editType&&this.editItem.images.length&&(this.editItemImages=this.editItem.images.map((t=>({id:`${Math.floor(100+900*Math.random())}`,url:t}))))}async editReview(){const t=`rating/${this.editFeedbackId}`;let a;if("product"===this.editType){const t=this.editModal.querySelector('[data-type="products"]')||this.currentTab;a=this.buildProductRatingPayload(this.collectFormData(t),t),!a.product_id&&this.editItem?.product?.id&&(a.product_id=String(this.editItem.product.id))}else a=this.collectFormData(this.editModal),a.images&&(a.images=a.images.split(","));await salla.api.request(t,a,"put").then((t=>{this.editModal.close(),salla.notify.success(t.message||this.updatedSuccessfullyLabel),setTimeout((()=>{window.location.reload()}),500)}))}async openDeleteModal(t){return this.defaultMode=!1,this.deleteMode=!0,this.deleteFeedbackId=t.feedback_id,this.shouldOpenDeleteModal=!0,new Promise((t=>{setTimeout((()=>{this.deleteModal.open().then((()=>t(!0)))}),50)}))}async deleteReview(){const t=`rating/${this.deleteFeedbackId}`;await salla.api.request(t,null,"delete").then((()=>{this.deleteModal.close(),salla.notify.success(this.deletedSuccessfullyLabel),setTimeout((()=>{window.location.reload()}),500)}))}async close(){return this.modal.close()}handleWizard(){this.steps=this.modal.querySelectorAll(".s-rating-modal-step"),this.dots=this.modal.querySelectorAll(".s-rating-modal-step-dot"),0!==this.stepsCount?this.showActiveStep():this.showThankYou()}refreshWizardRefs(){this.modal&&(this.steps=this.modal.querySelectorAll(".s-rating-modal-step"),this.dots=this.modal.querySelectorAll(".s-rating-modal-step-dot"))}showActiveStep(t=null){if(this.refreshWizardRefs(),this.currentTab=t||this.steps[this.currentIndex],!this.currentTab)return;l.toggleClassIf(".s-rating-modal-step-dot","s-rating-modal-bg-gray","s-rating-modal-bg-primary",(t=>t!=this.dots[this.currentIndex])).toggleClassIf(".s-rating-modal-step","s-rating-modal-active","s-rating-modal-hidden",(t=>t==this.currentTab)),0!==this.currentIndex&&(l.toggleElementClassIf(this.currentTab,"s-rating-modal-unactive","s-rating-modal-hidden",(()=>!0)),setTimeout((()=>l.toggleElementClassIf(this.currentTab,"s-rating-modal-active","s-rating-modal-unactive",(()=>!0))),300));const a=this.steps[this.currentIndex+1]?.dataset.type;this.nextBtn?.setText(a?`${salla.lang.get("pages.rating.rate")} ${salla.lang.get(`pages.rating.${a}`)}`:salla.lang.get("pages.rating.send_ratings")),setTimeout((()=>this.updateBodyHeight()),0),setTimeout((()=>this.updateBodyHeight()),150)}updateBodyHeight(){this.body&&this.currentTab&&(this.body.style.height="products"!==this.currentTab.dataset.type?`${this.currentTab.offsetHeight+(this.editMode?60:0)}px`:"auto")}previousTab(){this.currentIndex>0&&this.currentIndex--,l.toggleElementClassIf(this.backBtn,"s-rating-modal-unvisiable","block",(()=>0==this.currentIndex)),this.showActiveStep()}async submit(){this.refreshWizardRefs();try{this.submittedBefore()||this.validate(),salla.config.canLeave=!1,await this.nextBtn.load(),this.submittedBefore()||await this.sendFeedback(),this.currentTab?.querySelectorAll("[name],.s-rating-modal-btn-star").forEach((t=>t.setAttribute("disabled",""))),this.currentIndex<this.stepsCount&&this.currentIndex++,this.showActiveStep(),l.toggleClassIf("#prev-btn","block","s-rating-modal-unvisiable",(()=>!0)),this.currentIndex===this.stepsCount&&(this.showThankYou(),this.showContactWidget=!1)}finally{this.nextBtn.stop(),salla.config.canLeave=!0}}submittedBefore(){return this.submitted.includes(this.currentIndex)}getRatingHiddenInput(t){const a=t,s=a.querySelector?.(".rating_hidden_input");if(s?.name)return s;const i=a.querySelector?.("salla-rating-stars");return i?.shadowRoot?.querySelector(".rating_hidden_input")||null}collectNamedInputs(t){const a=new Set,s=[],i=t=>{t?.name&&!a.has(t)&&(a.add(t),s.push(t))};return t.querySelectorAll("[name]").forEach((t=>{i(t)})),t.querySelectorAll("salla-rating-stars").forEach((t=>{i(this.getRatingHiddenInput(t))})),s}normalizeFactorsList(t){return t?Array.isArray(t)?t:"object"==typeof t?Object.values(t).filter((t=>t&&"object"==typeof t)):[]:[]}validate(t=null,a=null){if(!t&&"products"===this.currentTab.dataset.type)return void this.currentTab.querySelectorAll(".rating-outer-form").forEach((t=>this.validate(t,"product")));const s=(t=t||this.currentTab).querySelector(".s-rating-modal-product-rating-row-main"),i=this.getRatingHiddenInput(s||t),e=i?.value,r=t.querySelector(".s-rating-modal-validation-msg");if(a=a||t.dataset.type,!e)throw r.innerHTML=salla.lang.get(`pages.rating.rate_${a}_stars`).replace(" (:item)",""),new Error(r.innerHTML);if("product"===a&&Array.from(t.querySelectorAll('.s-rating-modal-product-factor-row[data-required="true"]')).some((t=>{const a=this.getRatingHiddenInput(t);return!a?.value})))throw r.innerHTML=this.requiredFactorsLabel,new Error(r.innerHTML);r.innerHTML=""}collectFormData(t=this.currentTab){const a={};return this.collectNamedInputs(t).forEach((t=>{const s=salla.helpers.inputData(t.name,t.value,a);a[s.name]=s.value})),a}buildProductRatingPayload(t,a=this.currentTab){if(!t.rating){const s=a.querySelector(".s-rating-modal-product-rating-row-main"),i=this.getRatingHiddenInput(s||a);i?.value&&(t.rating=i.value)}const s=Number(t.product_id);let i=[];t.images?i="string"==typeof t.images?t.images.split(",").filter(Boolean):t.images:this.editMode&&this.allowAttachImages&&s?i=this.editItemImages.map((t=>t.url)):this.allowAttachImages&&s&&(i=(this.productImages[s]||[]).map((t=>t.url)));const e=this.normalizeFactorsList(t.factors).filter((t=>t?.id&&t?.rating)).map((t=>({id:String(t.id),rating:String(t.rating)})));return{order_id:this.getSubmitOrderId(),product_id:String(t.product_id),rating:String(t.rating),comment:t.comment||t.content||"",images:i,factors:e,type:"products"}}async sendFeedback(){this.refreshWizardRefs();const t=this.currentTab?.dataset?.type;if("products"===t){const t=this.collectFormData(this.currentTab),a=this.buildProductRatingPayload(t,this.currentTab);if(!a.product_id||!a.rating)throw new Error("Missing product rating data");const s=await salla.rating.api.products(a);return this.submitted.push(this.currentIndex),s}const a=this.collectFormData(this.currentTab);if(0===Object.keys(a).length)return;a.order_id=this.getSubmitOrderId(),a.type=t;const s=await salla.rating.api[t](a);return this.submitted.push(this.currentIndex),s}clearThanksCountdown(){null!==this.thanksCountdownInterval&&(clearInterval(this.thanksCountdownInterval),this.thanksCountdownInterval=null)}showThankYou(){let t=10;this.clearThanksCountdown(),this.thanksCountdownInterval=setInterval((()=>{this.thanksTime.innerHTML="00:0"+t--,t>0||(this.clearThanksCountdown(),this.thanksTime.remove(),this.close().then((()=>window.location.reload())))}),1e3),this.modal.querySelector(".s-rating-modal-footer").classList.add("s-rating-modal-unvisiable"),this.showActiveStep(this.thanksTab)}getFilepondPlaceholder(){return`<div class="s-rating-modal-filepond-placeholder"><span class="s-rating-modal-filepond-placeholder-icon">${d}</span><p class="s-rating-modal-filepond-placeholder-text">${this.dragAndDropFilesLabel}<br>\n <span> ${this.allowedImagesTypesLabel} <br> ${this.threeImagesMax} </span></p></div>`}getCustomerName(){return`${salla.config.get("user.first_name")||salla.storage.get("user.first_name")||""} ${salla.config.get("user.last_name")||salla.storage.get("user.last_name")||""}`}async readyUpLoyaltyPoints(){const t=salla.loyalty?.isFeatureEnabled?.();if(!t)return void(this.loyaltyImageRatingPoints=0);const a=salla.config.get("store.settings.rating.rating_product_points")||0,s=salla.config.get("store.settings.rating.rating_product_with_image_points")||0;this.loyaltyImageRatingPoints=Number(s)+Number(a)}loyaltyPointsNote(){if(!this.loyaltyImageRatingPoints||!this.loyaltyPointsForImagesLabel)return null;const t=s("svg",{width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s("path",{d:"M10 0C13.6819 0 16.6667 2.98477 16.6667 6.66664C16.6667 9.37047 15.057 11.6984 12.7437 12.7444C11.6978 15.0575 9.3701 16.6666 6.66668 16.6666C2.98477 16.6666 0 13.6819 0 9.99998C0 7.29656 1.60918 4.96894 3.92195 3.92276C4.96827 1.60964 7.29618 0 10 0ZM6.66668 5C3.90524 5 1.66667 7.23856 1.66667 9.99998C1.66667 12.7614 3.90524 15 6.66668 15C9.4281 15 11.6667 12.7614 11.6667 9.99998C11.6667 7.23856 9.4281 5 6.66668 5ZM7.50002 5.83333V6.66664H9.16668V8.33331H5.83333C5.60322 8.33331 5.41667 8.51989 5.41667 8.74998C5.41667 8.95456 5.56407 9.12464 5.75844 9.15998L5.83333 9.16664H7.50002C8.6506 9.16664 9.58335 10.0994 9.58335 11.25C9.58335 12.4006 8.6506 13.3333 7.50002 13.3333V14.1666H5.83333V13.3333H4.16667V11.6666H7.50002C7.7301 11.6666 7.91668 11.4801 7.91668 11.25C7.91668 11.0455 7.76927 10.8753 7.57493 10.8401L7.50002 10.8333H5.83333C4.68274 10.8333 3.75 9.90056 3.75 8.74998C3.75 7.59939 4.68274 6.66664 5.83333 6.66664V5.83333H7.50002ZM10 1.66667C8.51377 1.66667 7.17893 2.31513 6.26313 3.34457C6.39704 3.33736 6.53138 3.33333 6.66668 3.33333C10.3486 3.33333 13.3333 6.3181 13.3333 9.99998C13.3333 10.1356 13.3293 10.2702 13.3213 10.4037C14.3513 9.48814 15 8.15314 15 6.66664C15 3.90524 12.7614 1.66667 10 1.66667Z",fill:"#008C56"}));return s("div",{class:"s-rating-modal-loyalty-points-note-container"},s("span",{class:"s-rating-modal-loyalty-points-note-icon"},t),s("p",{class:"s-rating-modal-loyalty-points-note-text"},this.loyaltyPointsForImagesLabel.replace(":points",String(this.loyaltyImageRatingPoints))))}normalizeReviewFactorsPayload(t){const a=t?.data??t?.factors;return Array.isArray(a)?a.flatMap((t=>{const a=Array.isArray(t?.items)?[...t.items]:null;if(a?.length){a.sort(((t,a)=>(Number(t?.sort)||0)-(Number(a?.sort)||0)));const s=!!t?.is_required;return a.filter((t=>null!=t?.id&&""!==t?.id)).map((t=>({id:t.id,name:t?.name,required:s})))}return null==t?.id||""===t?.id?[]:[{id:t.id,name:t?.name,required:t?.required??t?.is_required??!1}]})):[]}async fetchProductReviewFactors(t){try{const a=await salla.api.request(`review/factors/${t}/form`);return this.normalizeReviewFactorsPayload(a)}catch(t){return[]}}async fetchAllProductReviewFactors(t){const a=this.getRateableProducts(t);if(!a.length)return{};const s=await Promise.all(a.map((async t=>{const a=await this.fetchProductReviewFactors(t.product.id);return[t.product.id,a]})));return Object.fromEntries(s)}async ensureProductFactorsLoaded(t){if(!t||this.productReviewFactors[t])return;const a=await this.fetchProductReviewFactors(t);this.productReviewFactors={...this.productReviewFactors,[t]:a}}getFactorFieldName(t,a,s){return t?`${t}[factors][${a}][${s}]`:`factors[${a}][${s}]`}normalizeToArray(t){return null==t?[]:Array.isArray(t)?t:[t]}isFactorReviewsList(t){return Array.isArray(t)&&t.length>0&&t.every((t=>t&&"object"==typeof t&&(void 0!==t.rating||void 0!==t.stars||void 0!==t.value)))}getFactorReviewsFromRecord(t){if(!t)return[];for(const a of["factor_reviews","review_factors","factors"]){const s=t[a];if(this.isFactorReviewsList(s))return s}return[]}getEditFactorReviewsList(t){const a=[this.order,this.getBootstrapOrder()].filter(Boolean);for(const s of a){const a=this.getMatchedProductRating(s,t,this.editFeedbackId),i=this.getFactorReviewsFromRecord(a);if(i.length)return i}const s=this.getOrderProducts(this.order).find((a=>Number(a.product?.id)===Number(t))),i=[this.editItem?.factor_reviews,this.editItem?.review_factors,this.editItem?.product?.review_factors,this.editItem?.product?.factor_reviews,this.editItem?.factors,s?.factor_reviews,s?.review_factors,s?.feedback?.factor_reviews];for(const t of i)if(Array.isArray(t)&&t.length>0)return t;return[]}getFactorKey(t,a){return null!=t.id&&""!==t.id?`id:${t.id}`:t.name?`name:${t.name.trim()}`:`index:${a}`}getFactorRatingsForProduct(t){return this.editMode?this.editFactorRatings:this.productFactorRatings[t]||{}}setFactorRatingsForProduct(t,a){this.editMode?this.editFactorRatings=a:this.productFactorRatings={...this.productFactorRatings,[t]:a}}markExistingFactorRatingsAsUserFilled(t,a){const s=this.productReviewFactors[t]||[],i=new Set;s.forEach(((t,s)=>{const e=this.getFactorKey(t,s),r=void 0!==t.id?a[String(t.id)]:void 0,n=t.name?a[t.name.trim()]:void 0;void 0===r&&void 0===n&&void 0===a[`__index_${s}`]||i.add(e)})),this.userFilledFactorKeys[t]=i}shouldAutofillFactors(t){return 4===t||5===t}autofillUnfilledFactors(t,a){const s=this.productReviewFactors[t]||[];if(!s.length)return;const i=this.userFilledFactorKeys[t]||new Set,e={...this.getFactorRatingsForProduct(t)},r=this.shouldAutofillFactors(a);let n=!1;s.forEach(((t,s)=>{const o=this.getFactorKey(t,s);if(!i.has(o)){if(r)return void 0!==t.id&&(e[String(t.id)]=a),t.name&&(e[t.name.trim()]=a),e[`__index_${s}`]=a,void(n=!0);void 0!==t.id&&void 0!==e[String(t.id)]&&(delete e[String(t.id)],n=!0),t.name&&void 0!==e[t.name.trim()]&&(delete e[t.name.trim()],n=!0),void 0!==e[`__index_${s}`]&&(delete e[`__index_${s}`],n=!0)}})),n&&this.setFactorRatingsForProduct(t,e)}handleMainRatingChange(t,a){this.editMode?this.editMainRating=a:this.productMainRatings={...this.productMainRatings,[t]:a},this.autofillUnfilledFactors(t,a)}handleFactorRatingChange(t,a,s){this.userFilledFactorKeys[t]||(this.userFilledFactorKeys[t]=new Set),this.userFilledFactorKeys[t].add(a);const i=this.productReviewFactors[t]||[],e=i.findIndex(((t,s)=>this.getFactorKey(t,s)===a));if(e<0)return;const r=i[e],n={...this.getFactorRatingsForProduct(t)};void 0!==r.id&&(n[String(r.id)]=s),r.name&&(n[r.name.trim()]=s),n[`__index_${e}`]=s,this.setFactorRatingsForProduct(t,n)}setupProductRatingAutofill(t,a){t&&!this.boundRatingRows.has(t)&&(this.boundRatingRows.add(t),t.addEventListener("click",(s=>{const i=s.target;if(!i.closest(".s-rating-stars-btn-star"))return;const e=i.closest(".s-rating-modal-product-rating-row-main"),r=i.closest(".s-rating-modal-product-factor-row");requestAnimationFrame((()=>{if(e&&t.contains(e)){const t=Number(this.getRatingHiddenInput(e)?.value);t>0&&this.handleMainRatingChange(a,t)}else if(r&&t.contains(r)){const t=r.getAttribute("data-factor-key"),s=Number(this.getRatingHiddenInput(r)?.value);t&&s>0&&this.handleFactorRatingChange(a,t,s)}}))})))}buildEditFactorRatings(t){return this.getEditFactorReviewsList(t).reduce(((t,a,s)=>{const i=Number(a?.rating??a?.stars??a?.value);if(Number.isNaN(i))return t;const e=a?.id??a?.factor_id;return null!=e&&""!==e&&(t[String(e)]=i),a?.name&&(t[a.name.trim()]=i),t[`__index_${s}`]=i,t}),{})}renderProductStep(t,a){return s("section",{class:"s-rating-modal-step s-rating-modal-hidden","data-type":"products","data-product-id":t.product.id,key:t.product.id},s("div",{class:"s-rating-modal-product"},this.allowAttachImages&&this.loyaltyPointsNote(),s("div",{class:"rating-outer-form","data-stars-error":salla.lang.get("pages.rating.rate_product_stars")},s("div",{class:"s-rating-modal-product-details"},s("div",{class:"s-rating-modal-product-info-row"},s("div",{class:"s-rating-modal-product-img-wrap"},s("img",{src:t.product.thumbnail,alt:t.product.name,class:"s-rating-modal-product-img"})),s("h3",{class:"s-rating-modal-product-title"},t.product.name)),this.renderProductReviewFactors(t.product.id,0,{fieldPrefix:""}),s("input",{type:"hidden",name:"product_id",value:t.product.id}),s("textarea",{placeholder:salla.lang.get("pages.rating.write_product_rate"),name:"comment",class:"s-rating-modal-comment"}),s("small",{class:"s-rating-modal-validation-msg"}))),this.allowAttachImages&&s("div",{class:"s-rating-modal-uploader is-opened",ref:t=>this.contentRefs[a]=t},s("salla-file-upload",{name:"image",maxFilesCount:this.MAX_UPLOAD_LIMIT,imagePreviewHeight:117,"instant-upload":!0,type:"feedback",payloadName:"files[]",id:`file-${t.product.id}`,title:t.product.name,allowMultiple:!0,instantUpload:!0,accept:"image/png, image/jpeg, image/jpg",url:salla.url.api("upload"),onUploaded:s=>{this.productImages={...this.productImages,[t.product.id]:[...this.productImages[t.product.id]||[],s.detail]},this.hiddenInputs[a].value=this.productImages[t.product.id].map((t=>t.url)).join(",")},onRemoved:s=>{const i=s.detail;i&&this.productImages[t.product.id]&&(this.productImages={...this.productImages,[t.product.id]:this.productImages[t.product.id].filter((t=>t.id!==i))},this.hiddenInputs[a].value=this.productImages[t.product.id].map((t=>t.url)).join(","))},labelIdle:this.getFilepondPlaceholder()}),s("input",{type:"hidden",name:"images",value:(this.productImages[t.product.id]||[]).map((t=>t.url)).join(","),ref:t=>this.hiddenInputs[a]=t}),this.renderUploadedImagesCount(t.product.id))))}renderProductReviewFactors(t,a,i={}){const e=this.productReviewFactors[t]||[],r=i.fieldPrefix??`products[${a}]`,n=r?`${r}[rating]`:"rating",o={...this.editMode?{}:this.productFactorRatings[t]||{},...i.factorRatings||{}},l=Number(i.mainRating??(this.editMode?this.editMainRating:this.productMainRatings[t])),d=!Number.isNaN(l),h=(t,a)=>{const s=void 0!==t.id?o[String(t.id)]:void 0,i=t.name?o[t.name.trim()]:void 0,e=Number(s??i??o[`__index_${a}`]);return Number.isNaN(e)?void 0:e};return s("div",{class:"s-rating-modal-product-rating-rows",ref:a=>this.setupProductRatingAutofill(a,t)},s("div",{class:"s-rating-modal-product-rating-row s-rating-modal-product-rating-row-main"},s("span",{class:"s-rating-modal-product-factor-name"},this.overallProductRatingLabel,s("span",{class:"s-rating-modal-product-factor-required"},"*")),s("salla-rating-stars",{size:"medium",name:n,key:d?`main-rating-${l}`:"main-rating-empty",value:d?l:void 0,editable:d,withLabel:!0,labelBeforeStars:!0,tag:!1})),e.map(((t,a)=>s("div",{class:"s-rating-modal-product-rating-row s-rating-modal-product-factor-row px-3","data-required":t.required?"true":"false","data-factor-key":this.getFactorKey(t,a)},s("input",{type:"hidden",name:this.getFactorFieldName(r,a,"name"),value:t.name}),!!t.id&&s("input",{type:"hidden",name:this.getFactorFieldName(r,a,"id"),value:String(t.id)}),s("span",{class:"s-rating-modal-product-factor-name"},t.name,t.required?s("span",{class:"s-rating-modal-product-factor-required"},"*"):""),s("salla-rating-stars",{size:"medium",name:this.getFactorFieldName(r,a,"rating"),key:`factor-rating-${t.id??a}-${h(t,a)??0}`,value:h(t,a),editable:i.alwaysEditable||"number"==typeof h(t,a),withLabel:!0,labelBeforeStars:!0,tag:!1})))))}handleSendEmail(){const t=`${this.contactSubjectLabel} #${this.order.id}`,a=this.contact_body(salla.config.get("store.name"),this.order.id,this.getCustomerName()),s=`mailto:${salla.config.get("store.contacts.email")}?subject=${encodeURIComponent(t)}&body=${encodeURIComponent(a)}`;window.open(s,"_blank")}handleSendWhatsApp(){const t=this.contact_body(salla.config.get("store.name"),this.order.id,this.getCustomerName()),a=`https://wa.me/${salla.config.get("store.contacts.whatsapp")}?text=${encodeURIComponent(t)}`;window.open(a,"_blank")}resetData(t){t.detail||(this.clearThanksCountdown(),this.modal?.close(),this.editItem=null,this.editItemImages=[],this.editFactorRatings={},this.productMainRatings={},this.productFactorRatings={},this.editMainRating=void 0,this.userFilledFactorKeys={},this.hiddenInputs[1]&&(this.hiddenInputs[1].value=""),this.deleteFeedbackId=null,this.editFeedbackId=null,this.shouldOpenDeleteModal=!1,this.editMode=!1,this.deleteMode=!1,this.defaultMode=!1,this.currentIndex=0,this.submitted=[],this.scheduleWizardSetup=!1,this.loyaltyImageRatingPoints=0)}getDeleteModal(){return s("salla-modal",{ref:t=>this.deleteModal=t,width:"xs",onModalVisibilityChanged:t=>this.resetData(t)},s("div",{class:"s-rating-modal-delete-wrapper",ref:t=>this.body=t},s("h3",null,this.confirmDeletionLabel),s("p",null,this.areYouSureLabel),s("div",{class:"s-rating-modal-delete-actions"},s("salla-button",{loaderPosition:"center",onClick:()=>this.deleteReview()},this.confirmDeleteBtn),s("salla-button",{color:"danger",fill:"outline",onClick:()=>this.deleteModal.close()},this.cancelLabel))))}renderUploadedImagesCount(t){const a=this.editMode?this.editItemImages.length:(this.productImages[t]||[]).length;return s("span",{class:"s-rating-modal-upload-count"},salla.lang.choice("pages.rating.images_count",a,{current:a,total:this.MAX_UPLOAD_LIMIT}))}getEditModal(){return s("salla-modal",{ref:t=>this.editModal=t,width:"md",onModalVisibilityChanged:t=>this.resetData(t)},s("div",{class:"s-rating-modal-edit-wrapper",ref:t=>this.body=t},"store"===this.editType&&this.editItem?s("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step","data-type":"store",ref:t=>this.currentTab=t},s("div",{class:"s-rating-modal-rounded-icon"},s("img",{src:salla.config.get("store.logo","https://assets.salla.sa/cp/assets/images/logo-new.png"),alt:"store name",class:"s-rating-modal-store-logo"})),s("h2",{class:"s-rating-modal-title"},salla.lang.get("pages.rating.rate_the_store")),s("div",{class:"s-rating-modal-stars-company"},s("salla-rating-stars",{withLabel:!0,size:"large",editable:!0,value:this.editItem.stars})),s("textarea",{name:"content",value:this.editItem.content,class:"s-rating-modal-comment",placeholder:salla.lang.get("pages.rating.write_store_rate")}),s("small",{class:"s-rating-modal-validation-msg"})):null,"shipping"===this.editType&&this.editItem?s("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step","data-type":"shipping",ref:t=>this.currentTab=t},this.editItem.shipping.logo?s("div",{class:"s-rating-modal-rounded-icon"},s("img",{src:this.editItem.shipping.logo,class:"s-rating-modal-shipping-logo",alt:this.editItem.shipping.name})):s("span",{class:"s-rating-modal-icon",innerHTML:n}),s("div",{class:"s-rating-modal-title"}," ",`${salla.lang.get("pages.rating.rate_shipping")} ${this.editItem.shipping.name}`),s("div",{class:"s-rating-modal-stars-company"},s("salla-rating-stars",{withLabel:!0,size:"large",editable:!0,value:this.editItem.stars})),s("textarea",{name:"content",class:"s-rating-modal-comment",value:this.editItem.content,placeholder:salla.lang.get("pages.rating.write_shipping_rate")}),s("small",{class:"s-rating-modal-validation-msg"})):null,"product"==this.editType&&this.editItem?s("section",{class:"s-rating-modal-step","data-type":"products",ref:t=>this.currentTab=t},s("div",{class:"s-rating-modal-product"},this.allowAttachImages&&this.loyaltyPointsNote(),s("div",{class:"rating-outer-form","data-stars-error":salla.lang.get("pages.rating.rate_product_stars")},s("div",{class:"s-rating-modal-product-details"},s("div",{class:"s-rating-modal-product-info-row"},s("div",{class:"s-rating-modal-product-img-wrap"},s("img",{src:this.editItem.product.image.url,alt:this.editItem.product.name,class:"s-rating-modal-product-img"})),s("h3",{class:"s-rating-modal-product-title"},this.editItem.product.name)),this.renderProductReviewFactors(this.editItem.product.id,0,{fieldPrefix:"",mainRating:this.editMainRating??Number(this.editItem.stars??this.editItem.rating),factorRatings:this.editFactorRatings,alwaysEditable:!0}),s("input",{type:"hidden",name:"product_id",value:this.editItem.product.id}),s("textarea",{value:this.editItem.content,placeholder:salla.lang.get("pages.rating.write_product_rate"),name:"comment",class:"s-rating-modal-comment"}),s("small",{class:"s-rating-modal-validation-msg"}))),this.allowAttachImages&&s("div",{class:"s-rating-modal-uploader is-opened",ref:t=>this.contentRefs[1]=t},s("salla-file-upload",{name:"images",allowMultiple:!0,maxFilesCount:this.MAX_UPLOAD_LIMIT,imagePreviewHeight:117,filePosterHeight:117,"instant-upload":!0,type:"feedback",files:JSON.stringify(this.editItemImages),payloadName:"files[]",id:`file-${this.editItem.product.id}`,title:this.editItem.product.name,instantUpload:!0,accept:"image/png, image/jpeg, image/jpg",url:salla.url.api("upload"),onUploaded:t=>{this.editItemImages=[...this.editItemImages,t.detail],this.hiddenInputs[1].value=this.editItemImages.map((t=>t.url)).join()},onRemoved:t=>{const a=t.detail;a&&(this.editItemImages=this.editItemImages.filter((t=>t.id!==a)),this.hiddenInputs[1].value=this.editItemImages.map((t=>t.url)).join())},labelIdle:this.getFilepondPlaceholder()}),s("input",{type:"hidden",name:"images",value:this.editItemImages.map((t=>t.url)).join(","),ref:t=>this.hiddenInputs[1]=t}),this.renderUploadedImagesCount(this.editItem.product.id)))):null,s("div",{class:"s-rating-modal-footer s-rating-modal-footer-end"},s("salla-button",{"loader-position":"center",onClick:()=>this.editReview()},this.editReviewLabel))))}render(){return this.deleteMode?s(i,{class:"s-rating-modal"},this.getDeleteModal()):this.editMode?s(i,{class:"s-rating-modal"},this.getEditModal()):this.defaultMode?s(i,{class:"s-rating-modal"},s("salla-modal",{class:"s-rating-modal-wrap",onModalVisibilityChanged:t=>this.resetData(t),isLoading:!0,width:"md",ref:t=>this.modal=t},s("div",{slot:"loading"},s("div",{class:"s-rating-modal-skeleton"},s("salla-skeleton",{type:"circle",height:"80px",width:"80px"}),s("salla-skeleton",{height:"15px",width:"60%"}),s("salla-skeleton",{height:"10px",width:"30%"}),s("div",{class:"s-rating-modal-skeleton-stars"},[...Array(5)].map((t=>s("div",{key:t,innerHTML:r})))),s("salla-skeleton",{height:"100px",width:"100%"}),s("div",{class:"s-rating-modal-skeleton-footer"},s("salla-skeleton",{height:"40px",width:"30%"})))),!this.hasError&&this.order?[s("div",{class:"s-rating-modal-wrapper",ref:t=>this.body=t},this.isTestimonialsEnabled()?s("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"store"},s("div",{class:"s-rating-modal-rounded-icon"},s("img",{src:salla.config.get("store.logo","https://assets.salla.sa/cp/assets/images/logo-new.png"),alt:"store name",class:"s-rating-modal-store-logo"})),s("h2",{class:"s-rating-modal-title"},salla.lang.get("pages.rating.rate_the_store")),s("div",{class:"s-rating-modal-stars-company"},s("salla-rating-stars",{withLabel:!0,size:"large"})),s("textarea",{name:"comment",class:"s-rating-modal-comment",placeholder:salla.lang.get("pages.rating.write_store_rate")}),s("small",{class:"s-rating-modal-validation-msg"})):"",this.isProductsEnabled()&&this.getRateableProducts().map(((t,a)=>this.renderProductStep(t,a))),this.isShippingEnabled()&&this.order.shipping?.company?s("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"shipping"},s("input",{type:"hidden",name:"shipping_company_id",value:this.order.shipping.company.id}),this.order.shipping.company.logo?s("div",{class:"s-rating-modal-rounded-icon"},s("img",{src:this.order.shipping.company.logo,class:"s-rating-modal-shipping-logo",alt:this.order.shipping.company.name})):s("span",{class:"s-rating-modal-icon",innerHTML:n}),s("div",{class:"s-rating-modal-title"}," ",`${salla.lang.get("pages.rating.rate_shipping")} ${this.order.shipping.company.name}`),s("div",{class:"s-rating-modal-stars-company"},s("salla-rating-stars",{withLabel:!0,size:"large"})),s("textarea",{name:"comment",class:"s-rating-modal-comment",placeholder:salla.lang.get("pages.rating.write_shipping_rate")}),s("small",{class:"s-rating-modal-validation-msg"})):"",s("div",{class:"s-rating-modal-thanks s-rating-modal-hidden",ref:t=>this.thanksTab=t},s("span",{class:"s-rating-modal-icon",innerHTML:o}),s("h3",{class:"s-rating-modal-thanks-title"},salla.lang.get("pages.rating.thanks")),s("div",{class:"s-rating-modal-thanks-msg",innerHTML:this.order.thanks_message}),s("time",{class:"s-rating-modal-thanks-time",ref:t=>this.thanksTime=t}))),this.allowContactSupport&&this.showContactWidget&&(salla.config.get("store.contacts.whatsapp")||salla.config.get("store.contacts.email"))?s("div",{class:"s-rating-modal-contact"},s("p",null,this.contactUsLabel),s("div",{class:"s-rating-modal-contact-icons"},salla.config.get("store.contacts.whatsapp")&&s("span",{onClick:()=>this.handleSendWhatsApp(),innerHTML:h}),salla.config.get("store.contacts.email")&&s("span",{onClick:()=>this.handleSendEmail(),innerHTML:g}))):"",s("div",{class:"s-rating-modal-footer"},s("button",{ref:t=>this.backBtn=t,onClick:()=>this.previousTab(),class:"s-rating-modal-btn s-rating-modal-unvisiable"},salla.lang.get("common.elements.back")),this.stepsCount>1?s("ul",{class:"s-rating-modal-dots"},[...Array(this.stepsCount)].map(((t,a)=>s("li",{key:a,class:"s-rating-modal-bg-gray s-rating-modal-step-dot"})))):"",s("salla-button",{"loader-position":"center",ref:t=>this.nextBtn=t,onClick:()=>this.submit()},salla.lang.get("common.elements.next")))]:s("salla-placeholder",{alignment:"center"}))):void 0}async componentWillLoad(){await salla.onReady(),this.syncStoreSettings()}componentDidRender(){this.scheduleWizardSetup&&this.defaultMode&&this.order&&(this.scheduleWizardSetup=!1,requestAnimationFrame((()=>this.handleWizard())))}disconnectedCallback(){this.clearThanksCountdown()}get host(){return e(this)}};m.style=".s-rating-modal-product-details{padding-bottom:0.5rem}.s-rating-modal-comment{margin-top:0.35rem}.s-rating-modal-product{margin-bottom:1rem}.s-rating-modal-product-img{position:absolute !important;inset:0;display:block;width:100% !important;max-width:100% !important;height:100% !important;object-fit:cover}.s-rating-modal-product-title{font-size:0.95rem;font-weight:600;line-height:1.5;margin:0}.s-rating-modal-stars-product{margin-top:0.5rem}.s-rating-modal-loyalty-points-note-container{display:flex;align-items:center;gap:0.625rem;width:100%;margin-top:1.5rem;margin-bottom:0.75rem;padding:0.75rem;border-radius:0.5rem;background-color:#E6F4EA}.s-rating-modal-loyalty-points-note-icon{display:flex;flex-shrink:0;align-items:center;justify-content:center;width:1.25rem;height:1.25rem;color:#1B7F5C}.s-rating-modal-loyalty-points-note-icon svg{width:1.5rem;height:1.5rem;fill:currentColor}.s-rating-modal-loyalty-points-note-text{flex:1;margin:0;font-size:0.875rem;line-height:1.25rem;color:#1f2937}.s-rating-modal-product-details-main{display:flex;align-items:center;margin-bottom:0.5rem;padding-bottom:0;border-bottom:0}.s-rating-modal-product-info-row{display:flex;align-items:center;gap:0.6rem;margin-bottom:0.5rem;padding-bottom:0;border-bottom:0}.s-rating-modal-product-main-review{width:100%;text-align:right}.s-rating-modal-product-rating-rows{display:grid;gap:0.45rem;margin:0.2rem 0 0.7rem}.s-rating-modal-product-rating-row{display:flex;align-items:center;justify-content:space-between;gap:0.75rem;min-height:2rem}.s-rating-modal-product-rating-row salla-rating-stars{flex-shrink:0}.s-rating-modal-product-rating-row .s-rating-stars-wrapper{align-items:center;min-height:1.75rem}.s-rating-modal-product-rating-row .s-rating-stars-label,.s-rating-modal-product-rating-row .s-rating-stars-label-without-tag{min-width:auto;min-height:1.25rem;line-height:1.25rem;font-size:0.8rem;color:#5b6470;white-space:nowrap;text-align:end;transition:opacity 0.15s ease}.s-rating-modal-product-rating-row .s-rating-stars-label--empty,.s-rating-modal-product-rating-row .s-rating-stars-label-without-tag--empty{opacity:0}.s-rating-modal-product-rating-row-main{margin-bottom:0.35rem;padding:0.5rem 0.6rem;border:1px solid #d1d5db;border-radius:0.45rem;background:transparent}.s-rating-modal-product-factor-name{color:#5b6470;font-size:0.9rem;line-height:1.25}.s-rating-modal-product-rating-row-main .s-rating-modal-product-factor-name{font-size:1rem;color:#5b6470}.s-rating-modal-product-factor-required{color:#f87171;margin-inline-start:0.2rem}.s-rating-modal-product-img-wrap{position:relative;width:5rem !important;min-width:5rem !important;max-width:5rem !important;height:3.5rem !important;flex-shrink:0 !important;overflow:hidden;border-radius:0.375rem;background:#f3f4f6}.s-rating-modal-uploader.is-opened{height:auto !important;opacity:1 !important;overflow:visible !important;pointer-events:auto !important;margin-bottom:1rem}";export{m as salla_rating_modal_v2}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,c as e,h as s,H as i,a as l}from"./p-BDAOgcq0.js";import{F as a}from"./p-DL4h2bc3.js";import{H as r}from"./p-XnA1YTjA.js";import"./p-CgtvEd63.js";const o=class{constructor(s){t(this,s),this.changed=e(this,"changed"),this.isReady=!1,this.isInitialFetch=!0,this.filtersData={},this.appliedOpen=!0,salla.event.on("filters::hidden",(()=>this.host.style.display="none")),salla.lang.onLoaded((()=>{this.apply=salla.lang.get("pages.checkout.apply"),this.reset=salla.lang.get("pages.categories.filters_reset"),this.selectedTitle=salla.lang.getWithDefault("pages.categories.selected_filters","لقد اخترت")})),salla.event.on("filters::fetched",(({filters:t})=>{this.host.style.display="";let e={};this.filters=t.map((t=>{if(t.label={category_id:salla.lang.get("common.titles.categories"),brand_id:salla.lang.get("common.titles.brands"),rating:salla.lang.get("pages.categories.filter_rating"),price:salla.lang.get("pages.categories.filter_price")}[t.key]||t.label,"rating"==t.key){t.type=a.VALUES;let{max:e,min:s}=t.values;t.values=[5,4,3,2,1].filter((t=>t>=s||t<=e))}this.filtersData.variants&&t.type==a.VARIANTS&&(e.variants=this.filtersData.variants),this.filtersData[t.key]&&t.type!==a.VARIANTS&&(e[t.key]=this.filtersData[t.key]);let s=new URLSearchParams(window.location.search),i=!1;for(let t of s.keys())if(t.includes("filters")){i=!0;break}if(this.isInitialFetch&&"product.index"==salla.config.get("page.slug")&&0==Object.keys(e).length&&!i){let t=window.location.href,s=salla.config.get("page.id"),i=-1!==t.indexOf("?")?"&":"?",l=t+i+"filters[category_id]="+s;e.category_id=s,window.history.pushState({path:l},"",l)}return t})),this.isInitialFetch=!1,this.filtersData=e,this.host.childNodes.forEach((async t=>t.setWidgetHeight&&await t.setWidgetHeight()))}))}async componentWillLoad(){try{const t=new URLSearchParams(window.location.search);this.filtersData=await r.extractFiltersFromUrl(t)}catch(t){console.warn("failed to get filters from URL",t.message)}}async getFilters(){return this.filtersData}async applyFilters(){if(!this.isReady)return;let t=Object.keys(this.filtersData).length>0;setTimeout((()=>{if(t){let t=new URL(window.location.href);for(const[e]of t.searchParams.entries())e.startsWith("filters")&&t.searchParams.delete(e);let e=this.encodeFilters(this.filtersData),s=t.search.split("&").filter((t=>!t.includes("filters"))).join("&");t.search=s?t.search.split("&filters")[0]+"&"+e:`?${e}`,window.history.pushState({},"",t.href)}else{let t=new URL(window.location.href);t.searchParams?.delete("filters"),window.history.pushState({},"",t.toString())}salla.event.emit("salla-filters::changed",this.filtersData),this.changed.emit(this.filtersData)}),300)}encodeFilters(t,e="filters"){const s=[];for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){const l=t[i],a=e?`${e}[${i}]`:i;Array.isArray(l)?l.forEach((t=>s.push(`${a}[]=${t}`))):s.push("object"==typeof l&&null!==l?this.encodeFilters(l,a):`${a}=${l}`)}return s.join("&")}async resetFilters(){return this.removeFiltersQueryParams(),this.filtersData={},this.host.childNodes.forEach((t=>t.reset&&t.reset())),salla.event.emit("salla-filters::reset"),this.applyFilters()}removeFiltersQueryParams(){const t=new URLSearchParams(window.location.search),e=Array.from(t.keys()).filter((t=>!t.startsWith("filters["))).map((e=>`${encodeURIComponent(e)}=${encodeURIComponent(t.get(e))}`)).join("&"),s=e?`${window.location.pathname}?${e}`:window.location.pathname;window.history.pushState({},"",s)}handleOptionChange(t,e,s){e.type===a.RANGE&&(this.filtersData[e.key]=s);let i=t.target.checked;if(e.type===a.VARIANTS)this.filtersData.variants=this.filtersData.variants||{},i&&(this.filtersData.variants[e.key]=s),i||delete this.filtersData.variants[e.key];else if("radio"==t.target.type)i&&(this.filtersData[e.key]=s),i||delete this.filtersData[e.key];else if("checkbox"==t.target.type){const t=this.filtersData[e.key];this.filtersData[e.key]=Array.isArray(t)?t:null!=t?[t]:[],i?this.filtersData[e.key].push(s):this.filtersData[e.key]=this.filtersData[e.key].filter((t=>t!=s)),this.filtersData[e.key].length||delete this.filtersData[e.key]}this.filtersData={...this.filtersData},this.applyFilters()}getAppliedFilters(){const t=[],e=this.filtersData||{};for(const s of Object.keys(e)){if("variants"===s){const i=this.filters?.find((t=>t.type===a.VARIANTS));for(const l of Object.keys(e.variants||{})){const r=e.variants[l],o=i?.values?.find((t=>(t.key||t.value)==r));o&&t.push({key:s,variantKey:l,value:r,type:a.VARIANTS,groupLabel:i?.label,optionLabel:o.value})}continue}const i=this.filters?.find((t=>t.key===s));if(!i)continue;const l=e[s];if(i.type===a.RANGE||l&&"object"==typeof l&&!Array.isArray(l)){t.push({key:s,value:l,type:a.RANGE,groupLabel:i.label,optionLabel:`${l.min} - ${l.max}`});continue}if("category_id"===s&&!Array.isArray(l)&&"product.index"==salla.config.get("page.slug")&&l==salla.config.get("page.id"))continue;const r=Array.isArray(l)?l:[l];for(const e of r){const l=i.values?.find((t=>("number"==typeof t?t:t.key||t.value)==e)),a="rating"===i.key?`${e}`:l&&"number"!=typeof l?l.value:void 0;null!=a&&t.push({key:s,value:e,type:i.type,groupLabel:i.label,optionLabel:a})}}return t}removeFilter(t){if(t.type===a.VARIANTS)this.filtersData.variants&&(delete this.filtersData.variants[t.variantKey],Object.keys(this.filtersData.variants).length||delete this.filtersData.variants);else if(t.type===a.RANGE)delete this.filtersData[t.key];else{const e=this.filtersData[t.key];Array.isArray(e)?(this.filtersData[t.key]=e.filter((e=>e!=t.value)),this.filtersData[t.key].length||delete this.filtersData[t.key]):delete this.filtersData[t.key]}this.filtersData={...this.filtersData},this.applyFilters()}render(){const t=this.getAppliedFilters(),e=salla.lang.getWithDefault("common.elements.delete","Remove");return s(i,{key:"f0493d0e85ebb9e6612a1edc6cd7f45e7473017e"},t.length?s("div",{class:"s-filters-applied s-filters-widget-container"},s("h3",{class:"s-filters-widget-title",onClick:()=>this.appliedOpen=!this.appliedOpen},s("span",null,this.selectedTitle),s("span",{class:"s-filters-widget-plusminus "+(this.appliedOpen?"s-filters-widget-plusminus-active":"")})),s("div",{class:"s-filters-widget-content "+(this.appliedOpen?"s-filters-widget-opened":"s-filters-widget-closed")},s("div",{class:"s-filters-widget-values"},t.map((t=>s("div",{class:"s-filters-label s-filters-applied-item"},s("span",{class:"s-filters-option-name"},t.groupLabel,": ",t.optionLabel),s("button",{type:"button",class:"s-filters-applied-remove","aria-label":`${e} ${t.groupLabel}: ${t.optionLabel}`,onClick:()=>this.removeFilter(t)},s("i",{class:"sicon-cancel","aria-hidden":"true"})))))),s("div",{class:"s-filters-footer"},s("salla-button",{color:"gray",fill:"outline",onClick:()=>this.resetFilters()},this.reset)))):"",this.filters?.map((t=>s("salla-filters-widget",{option:t,filtersData:this.filtersData,onChanged:({detail:{event:t,option:e,value:s}})=>{this.handleOptionChange(t,e,s)}}))))}componentDidLoad(){this.isReady=!0}get host(){return l(this)}};o.style=":host{display:block}.s-rating-stars-small{line-height:12px}.s-filters-radio{background-image:none !important}.s-filters-applied-remove{pointer-events:auto !important;cursor:pointer}";export{o as salla_filters}
4
+ import{r as t,c as e,h as s,H as i,a as l}from"./p-DgmW0rL4.js";import{F as a}from"./p-DL4h2bc3.js";import{H as r}from"./p-XnA1YTjA.js";import"./p-CgtvEd63.js";const o=class{constructor(s){t(this,s),this.changed=e(this,"changed"),this.isReady=!1,this.isInitialFetch=!0,this.filtersData={},this.appliedOpen=!0,salla.event.on("filters::hidden",(()=>this.host.style.display="none")),salla.lang.onLoaded((()=>{this.apply=salla.lang.get("pages.checkout.apply"),this.reset=salla.lang.get("pages.categories.filters_reset"),this.selectedTitle=salla.lang.getWithDefault("pages.categories.selected_filters","لقد اخترت")})),salla.event.on("filters::fetched",(({filters:t})=>{this.host.style.display="";let e={};this.filters=t.map((t=>{if(t.label={category_id:salla.lang.get("common.titles.categories"),brand_id:salla.lang.get("common.titles.brands"),rating:salla.lang.get("pages.categories.filter_rating"),price:salla.lang.get("pages.categories.filter_price")}[t.key]||t.label,"rating"==t.key){t.type=a.VALUES;let{max:e,min:s}=t.values;t.values=[5,4,3,2,1].filter((t=>t>=s||t<=e))}this.filtersData.variants&&t.type==a.VARIANTS&&(e.variants=this.filtersData.variants),this.filtersData[t.key]&&t.type!==a.VARIANTS&&(e[t.key]=this.filtersData[t.key]);let s=new URLSearchParams(window.location.search),i=!1;for(let t of s.keys())if(t.includes("filters")){i=!0;break}if(this.isInitialFetch&&"product.index"==salla.config.get("page.slug")&&0==Object.keys(e).length&&!i){let t=window.location.href,s=salla.config.get("page.id"),i=-1!==t.indexOf("?")?"&":"?",l=t+i+"filters[category_id]="+s;e.category_id=s,window.history.pushState({path:l},"",l)}return t})),this.isInitialFetch=!1,this.filtersData=e,this.host.childNodes.forEach((async t=>t.setWidgetHeight&&await t.setWidgetHeight()))}))}async componentWillLoad(){try{const t=new URLSearchParams(window.location.search);this.filtersData=await r.extractFiltersFromUrl(t)}catch(t){console.warn("failed to get filters from URL",t.message)}}async getFilters(){return this.filtersData}async applyFilters(){if(!this.isReady)return;let t=Object.keys(this.filtersData).length>0;setTimeout((()=>{if(t){let t=new URL(window.location.href);for(const[e]of t.searchParams.entries())e.startsWith("filters")&&t.searchParams.delete(e);let e=this.encodeFilters(this.filtersData),s=t.search.split("&").filter((t=>!t.includes("filters"))).join("&");t.search=s?t.search.split("&filters")[0]+"&"+e:`?${e}`,window.history.pushState({},"",t.href)}else{let t=new URL(window.location.href);t.searchParams?.delete("filters"),window.history.pushState({},"",t.toString())}salla.event.emit("salla-filters::changed",this.filtersData),this.changed.emit(this.filtersData)}),300)}encodeFilters(t,e="filters"){const s=[];for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){const l=t[i],a=e?`${e}[${i}]`:i;Array.isArray(l)?l.forEach((t=>s.push(`${a}[]=${t}`))):s.push("object"==typeof l&&null!==l?this.encodeFilters(l,a):`${a}=${l}`)}return s.join("&")}async resetFilters(){return this.removeFiltersQueryParams(),this.filtersData={},this.host.childNodes.forEach((t=>t.reset&&t.reset())),salla.event.emit("salla-filters::reset"),this.applyFilters()}removeFiltersQueryParams(){const t=new URLSearchParams(window.location.search),e=Array.from(t.keys()).filter((t=>!t.startsWith("filters["))).map((e=>`${encodeURIComponent(e)}=${encodeURIComponent(t.get(e))}`)).join("&"),s=e?`${window.location.pathname}?${e}`:window.location.pathname;window.history.pushState({},"",s)}handleOptionChange(t,e,s){e.type===a.RANGE&&(this.filtersData[e.key]=s);let i=t.target.checked;if(e.type===a.VARIANTS)this.filtersData.variants=this.filtersData.variants||{},i&&(this.filtersData.variants[e.key]=s),i||delete this.filtersData.variants[e.key];else if("radio"==t.target.type)i&&(this.filtersData[e.key]=s),i||delete this.filtersData[e.key];else if("checkbox"==t.target.type){const t=this.filtersData[e.key];this.filtersData[e.key]=Array.isArray(t)?t:null!=t?[t]:[],i?this.filtersData[e.key].push(s):this.filtersData[e.key]=this.filtersData[e.key].filter((t=>t!=s)),this.filtersData[e.key].length||delete this.filtersData[e.key]}this.filtersData={...this.filtersData},this.applyFilters()}getAppliedFilters(){const t=[],e=this.filtersData||{};for(const s of Object.keys(e)){if("variants"===s){const i=this.filters?.find((t=>t.type===a.VARIANTS));for(const l of Object.keys(e.variants||{})){const r=e.variants[l],o=i?.values?.find((t=>(t.key||t.value)==r));o&&t.push({key:s,variantKey:l,value:r,type:a.VARIANTS,groupLabel:i?.label,optionLabel:o.value})}continue}const i=this.filters?.find((t=>t.key===s));if(!i)continue;const l=e[s];if(i.type===a.RANGE||l&&"object"==typeof l&&!Array.isArray(l)){t.push({key:s,value:l,type:a.RANGE,groupLabel:i.label,optionLabel:`${l.min} - ${l.max}`});continue}if("category_id"===s&&!Array.isArray(l)&&"product.index"==salla.config.get("page.slug")&&l==salla.config.get("page.id"))continue;const r=Array.isArray(l)?l:[l];for(const e of r){const l=i.values?.find((t=>("number"==typeof t?t:t.key||t.value)==e)),a="rating"===i.key?`${e}`:l&&"number"!=typeof l?l.value:void 0;null!=a&&t.push({key:s,value:e,type:i.type,groupLabel:i.label,optionLabel:a})}}return t}removeFilter(t){if(t.type===a.VARIANTS)this.filtersData.variants&&(delete this.filtersData.variants[t.variantKey],Object.keys(this.filtersData.variants).length||delete this.filtersData.variants);else if(t.type===a.RANGE)delete this.filtersData[t.key];else{const e=this.filtersData[t.key];Array.isArray(e)?(this.filtersData[t.key]=e.filter((e=>e!=t.value)),this.filtersData[t.key].length||delete this.filtersData[t.key]):delete this.filtersData[t.key]}this.filtersData={...this.filtersData},this.applyFilters()}render(){const t=this.getAppliedFilters(),e=salla.lang.getWithDefault("common.elements.delete","Remove");return s(i,{key:"f0493d0e85ebb9e6612a1edc6cd7f45e7473017e"},t.length?s("div",{class:"s-filters-applied s-filters-widget-container"},s("h3",{class:"s-filters-widget-title",onClick:()=>this.appliedOpen=!this.appliedOpen},s("span",null,this.selectedTitle),s("span",{class:"s-filters-widget-plusminus "+(this.appliedOpen?"s-filters-widget-plusminus-active":"")})),s("div",{class:"s-filters-widget-content "+(this.appliedOpen?"s-filters-widget-opened":"s-filters-widget-closed")},s("div",{class:"s-filters-widget-values"},t.map((t=>s("div",{class:"s-filters-label s-filters-applied-item"},s("span",{class:"s-filters-option-name"},t.groupLabel,": ",t.optionLabel),s("button",{type:"button",class:"s-filters-applied-remove","aria-label":`${e} ${t.groupLabel}: ${t.optionLabel}`,onClick:()=>this.removeFilter(t)},s("i",{class:"sicon-cancel","aria-hidden":"true"})))))),s("div",{class:"s-filters-footer"},s("salla-button",{color:"gray",fill:"outline",onClick:()=>this.resetFilters()},this.reset)))):"",this.filters?.map((t=>s("salla-filters-widget",{option:t,filtersData:this.filtersData,onChanged:({detail:{event:t,option:e,value:s}})=>{this.handleOptionChange(t,e,s)}}))))}componentDidLoad(){this.isReady=!0}get host(){return l(this)}};o.style=":host{display:block}.s-rating-stars-small{line-height:12px}.s-filters-radio{background-image:none !important}.s-filters-applied-remove{pointer-events:auto !important;cursor:pointer}";export{o as salla_filters}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as t,H as a,a as i}from"./p-BDAOgcq0.js";const e=class{constructor(t){s(this,t),this.exclude=[]}componentWillLoad(){return salla.onReady().then((()=>{if("string"==typeof this.exclude)try{this.exclude=JSON.parse(this.exclude)}catch(s){salla.logger.error("salla-payments:: failed to parse the exclude props!",this.exclude),this.exclude=[]}this.paymentSlot=this.host.querySelector('[slot="payment"]')?.innerHTML||'<li class="s-payments-list-item"><img width="100%" height="100%" decoding="async" loading="lazy" src="{image}" alt="{payment}" /></li>',this.sbcSlot=this.host.querySelector('[slot="sbc"]')?.innerHTML||'<li class="s-payments-list-item"><a target="_blank" href="{link}"><img width="100%" height="100%" decoding="async" loading="lazy" src="{image}" class="s-payments-sbc-image" alt="SBC" /></a></li>',this.codSlot=this.host.querySelector('[slot="cod"]')?.innerHTML||'<li class="s-payments-list-item"><img width="100%" height="100%" decoding="async" loading="lazy" src="{image}" alt="COD" /></li>',this.payments=salla.config.get("store.settings.payments")}))}paymentLogo(s){const t=`images/payment/${s}_mini.png`;return e.NEW_CDN_LOGOS.includes(s)?salla.url.assetsCdn(t,58,58):salla.url.cdn(t,58,58)}render(){const s=!this.exclude.includes("made-in-ksa")&&salla.config.get("store.settings.made_in_ksa"),i=this.exclude.includes("sbc")?null:salla.config.get("store.settings.certificate.id");return t(a,{key:"73ab5a6358aa50ec48024274ef18ba9e3628fe4e",class:"s-payments-list-wrap"},t("ul",{key:"819d1b51174aff73023235e6a730463bfaa5ca13",class:"s-payments-list"},s&&t("li",{key:"f10446c5c7981747a3308a45cd090e5e64bef668",class:"s-payments-list-item"},t("img",{key:"91349a29bcf349f20d9d7914ee7991dd29b3f042",width:58,height:58,decoding:"async",loading:"lazy",src:salla.url.cdn("images/made-in-ksa.svg",58,58),alt:"made in KSA certified"})),this.payments.map((s=>t("div","cod"==s?{id:"cod-slot",innerHTML:this.codSlot.replace(/\{image\}/g,this.paymentLogo("cod"))}:{id:"payment-slot",innerHTML:this.paymentSlot.replace(/\{image\}/g,this.paymentLogo(s)).replace(/\{payment\}/g,s)}))),i&&t("div",{key:"df1d5a5532bf4dc5d364ba85ca1c0ad828c18ff0",id:"sbc-slot",innerHTML:this.sbcSlot.replace(/\{image\}/g,salla.url.cdn("images/sbc.png",58,58)).replace(/\{link\}/g,`https://eauthenticate.saudibusiness.gov.sa/certificate-details/${i}`)})))}componentDidRender(){this.host.querySelectorAll("#payment-slot").forEach((s=>s.replaceWith(s.firstChild))),this.host.querySelectorAll("#sbc-slot").forEach((s=>s.replaceWith(s.firstChild))),this.host.querySelectorAll("#cod-slot").forEach((s=>s.replaceWith(s.firstChild))),this.host.querySelector('[slot="payment"]')?.remove(),this.host.querySelector('[slot="sbc"]')?.remove(),this.host.querySelector('[slot="cod"]')?.remove()}get host(){return i(this)}};e.NEW_CDN_LOGOS=["tabby_installment"],e.style=":host{display:block}";export{e as salla_payments}
4
+ import{r as s,h as t,H as a,a as i}from"./p-DgmW0rL4.js";const e=class{constructor(t){s(this,t),this.exclude=[]}componentWillLoad(){return salla.onReady().then((()=>{if("string"==typeof this.exclude)try{this.exclude=JSON.parse(this.exclude)}catch(s){salla.logger.error("salla-payments:: failed to parse the exclude props!",this.exclude),this.exclude=[]}this.paymentSlot=this.host.querySelector('[slot="payment"]')?.innerHTML||'<li class="s-payments-list-item"><img width="100%" height="100%" decoding="async" loading="lazy" src="{image}" alt="{payment}" /></li>',this.sbcSlot=this.host.querySelector('[slot="sbc"]')?.innerHTML||'<li class="s-payments-list-item"><a target="_blank" href="{link}"><img width="100%" height="100%" decoding="async" loading="lazy" src="{image}" class="s-payments-sbc-image" alt="SBC" /></a></li>',this.codSlot=this.host.querySelector('[slot="cod"]')?.innerHTML||'<li class="s-payments-list-item"><img width="100%" height="100%" decoding="async" loading="lazy" src="{image}" alt="COD" /></li>',this.payments=salla.config.get("store.settings.payments")}))}paymentLogo(s){const t=`images/payment/${s}_mini.png`;return e.NEW_CDN_LOGOS.includes(s)?salla.url.assetsCdn(t,58,58):salla.url.cdn(t,58,58)}render(){const s=!this.exclude.includes("made-in-ksa")&&salla.config.get("store.settings.made_in_ksa"),i=this.exclude.includes("sbc")?null:salla.config.get("store.settings.certificate.id");return t(a,{key:"73ab5a6358aa50ec48024274ef18ba9e3628fe4e",class:"s-payments-list-wrap"},t("ul",{key:"819d1b51174aff73023235e6a730463bfaa5ca13",class:"s-payments-list"},s&&t("li",{key:"f10446c5c7981747a3308a45cd090e5e64bef668",class:"s-payments-list-item"},t("img",{key:"91349a29bcf349f20d9d7914ee7991dd29b3f042",width:58,height:58,decoding:"async",loading:"lazy",src:salla.url.cdn("images/made-in-ksa.svg",58,58),alt:"made in KSA certified"})),this.payments.map((s=>t("div","cod"==s?{id:"cod-slot",innerHTML:this.codSlot.replace(/\{image\}/g,this.paymentLogo("cod"))}:{id:"payment-slot",innerHTML:this.paymentSlot.replace(/\{image\}/g,this.paymentLogo(s)).replace(/\{payment\}/g,s)}))),i&&t("div",{key:"df1d5a5532bf4dc5d364ba85ca1c0ad828c18ff0",id:"sbc-slot",innerHTML:this.sbcSlot.replace(/\{image\}/g,salla.url.cdn("images/sbc.png",58,58)).replace(/\{link\}/g,`https://eauthenticate.saudibusiness.gov.sa/certificate-details/${i}`)})))}componentDidRender(){this.host.querySelectorAll("#payment-slot").forEach((s=>s.replaceWith(s.firstChild))),this.host.querySelectorAll("#sbc-slot").forEach((s=>s.replaceWith(s.firstChild))),this.host.querySelectorAll("#cod-slot").forEach((s=>s.replaceWith(s.firstChild))),this.host.querySelector('[slot="payment"]')?.remove(),this.host.querySelector('[slot="sbc"]')?.remove(),this.host.querySelector('[slot="cod"]')?.remove()}get host(){return i(this)}};e.NEW_CDN_LOGOS=["tabby_installment"],e.style=":host{display:block}";export{e as salla_payments}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,h as a,F as s,a as e}from"./p-BDAOgcq0.js";const i=class{constructor(a){t(this,a),this.isMobileAllowed=!0,this.isEmailRequired=!1,this.supportWebAuth=!0,this.withoutReload=!1,this.source="",this.htmlElement=document.documentElement,this.messages=[],this.isClosable=!0,this.iframeLoaded=!1,this.scrolling="no",this.direction=document.dir,this.canRenderIframe=!1,salla.event.on("login::open",(t=>{this.isEmailAllowed||this.isMobileAllowed?(this.source=t?.source??!1,this.withoutReload=t?.withoutReload??this.withoutReload,this.open(t),this.openModal()):salla.logger.warn("Please enable atleast one login type to use this component.")})),salla.event.on("modal::close",(t=>{this.iframe&&this.sendMessageToIframe({source:"login",type:"modal_closed",data:t})})),salla.onReady((()=>{this.api=salla.config.get("store.api"),this.storeId=salla.config.get("store.id")}))}componentDidLoad(){window.addEventListener("message",(t=>{if(!this.isTrustedMessage(t)||"login"!=t.data?.source)return;if(!this.inline&&!this.canRenderIframe)return;salla.log("salla-account:: recived an event",t.data);let a=t.data?.type?.replace("iframe::",""),s=t.data.message;if("ready"==a)return s.isPasskeyPage?void this.createPassKey.postMessage({source:"login",type:"init_passkey_page",data:{token:salla.storage.get("token"),store_id:salla.config.get("store.id"),locale:salla.config.get("user.language_code"),redirect:salla.config.get("store.url")}},salla.config.get("login.url")):void this.handleIframeReadyAction();if("height"==a)return this.iframe.height=s?.height+"px";if("storage"==a)return this.handleIframeStorageAction(s);if("scrolling"==a)return this.scrolling=s,void(this.isClosable=!1);if("direction"==a)return document.dir=this.direction=s?"rtl":"ltr";if("notify"==a)return salla.notify[s.type](s.message);if("authenticated"==a||"authenticated_web_auth"==a)return!s?.withoutClose&&this.close(),salla.auth.api.handlAfterAuthenticatedResponse(s,this.supportWebAuth).then((()=>!(s?.withoutReload||this.withoutReload)&&setTimeout((()=>window.location.reload()),1e3)));if("dispatchEvent"!=a||"auth::verified"!=s.event){if("dispatchEvent"==a)return salla.event.emit(s.event,...s.payload);if("reload"==a)return s?.withClose&&this.modal.close(),window.location.reload();if("open_page"===a){if(!this.isSafeUrl(s?.url))return;return window.location.href=s.url}if("open_passkey_page"!==a)return"guest-checkout"===a?this.handleGuestCheckout():void("close"==a&&this.close());this.createPassKey=window.open(`${salla.config.get("login.url")}/create-passkey`)}else salla.log("Ignored dispatchEvent `auth::verified` from iframe")})),this.observeDarkModeChanges(),setTimeout((()=>Salla.event.emit("salla-login::ready")),1)}async open(t=null){return Salla.config.isGuest()?this.modal.open():this.withoutReload?void 0:location.reload()}close(){Salla.event.emit("salla-login::closing"),this.modal.close(),this.iframeLoaded=!1,this.canRenderIframe=!1,this.host.dispatchEvent(new CustomEvent("salla-login:closed",{cancelable:!0,bubbles:!0,detail:null})),Salla.event.emit("salla-login::closed")}handleIframeReadyAction(){this.sendInitMessage(),this.sendMessageToIframe({source:"login",type:"width",data:document.body.clientWidth})}observeDarkModeChanges(){new MutationObserver((t=>{t.forEach((t=>{"class"===t.attributeName&&this.sendMessageToIframe({source:"login",type:"darkMode",data:{isDark:!!this.htmlElement.classList.contains("dark")}})}))})).observe(this.htmlElement,{attributes:!0})}async handleIframeStorageAction(t){let a,s=salla.storage.get("cart.user_id"),e=!1;if(Object.entries(t).filter((t=>!Salla.storage.get(t[0]))).forEach((([t,i])=>{salla.log("Shared storage from accounts domain",t,i);let l="string"==typeof i?i?.replace(/^"|"$/g,""):i;salla.storage.set(t,l),"token"===t&&(a=l),"user"===t&&s&&l.id!==s&&(e=!0)})),a){this.modal.close(),Salla.auth.event.tokenFetched(a);try{await Salla.api.cart.assign()}catch(t){Salla.log("Error on assign after handle iframe",t)}e&&Salla.cart.reset();try{!Salla.auth.api.isSessionless()&&await Salla.auth.api.request("auth/jwt"),Salla.auth.api.canRedirect()?setTimeout((()=>window.location.reload()),100):await Salla.auth.event.loggedIn({data:{token:a}}).then((()=>Salla.auth.api.afterUserLogin()))}catch(t){this.modal.open(),Salla.log("Error on request auth/jwt after handle iframe",t)}}else e&&Salla.cart.reset()}isTrustedMessage(t){if(!(this.iframe&&t.source===this.iframe.contentWindow||this.createPassKey&&t.source===this.createPassKey))return!1;let a;try{a=new URL(salla.config.get("login.url","https://accounts.salla.com")).origin}catch(t){a="https://accounts.salla.com"}return t.origin===a}isSafeUrl(t){if("string"!=typeof t||!t)return!1;try{const{protocol:a}=new URL(t,location.href);return"https:"===a||"http:"===a}catch(t){return!1}}sendMessageToIframe(t){if(this.iframe)return this.iframe.contentWindow.postMessage(t,"*")}sendInitMessage(){let t=this.headers;try{t="string"==typeof t?JSON.parse(t):t}catch(a){console.error("Failed to parse headers!",this.headers,a),t=void 0}const a={user:salla.storage.get("user"),s_translations:salla.storage.get("s_translations"),token:salla.storage.get("token")};a.user||delete a.user,a.s_translations||delete a.s_translations,a.token||delete a.token,this.sendMessageToIframe({source:"login",type:"init",data:{id:this.storeId,lang:salla.lang.locale,isDark:!!this.htmlElement.classList.contains("dark"),apiUrl:this.api?.replace(/\/+$/,""),supportWebAuth:this.supportWebAuth,withoutReload:this.withoutReload,inline:this.inline,settings:salla.config.all(),headers:t,storage:a}})}async handleGuestCheckout(){if(this.modal.close(),salla.config.isGuest())return salla.cart.submit(!1,!0)}openModal(){this.canRenderIframe||(this.canRenderIframe=!0),this.modal.open()}render(){if(!Salla.config.isUser())return this.inline?this.getLoginDom():a("salla-modal",{class:"s-login-modal",ref:t=>this.modal=t,width:"xs"},this.getLoginDom())}getLoginDom(){if(this.canRenderIframe)return a(s,null,a("iframe",{src:`${salla.config.get("login.url","https://accounts.salla.com")}?src=${this.source}`,title:"Salla Login",class:"hide-scroll",loading:"lazy",ref:t=>{this.iframe=t},allow:"publickey-credentials-get; publickey-credentials-create",scrolling:this.scrolling,frameborder:"0",width:"100%"}))}get host(){return e(this)}};i.style="iframe{-moz-transition:height 0.3s;-ms-transition:height 0.3s;-o-transition:height 0.3s;-webkit-transition:height 0.3s;transition:height 0.3s;width:100%}";export{i as salla_login_modal}
4
+ import{r as t,h as a,F as s,a as e}from"./p-DgmW0rL4.js";const i=class{constructor(a){t(this,a),this.isMobileAllowed=!0,this.isEmailRequired=!1,this.supportWebAuth=!0,this.withoutReload=!1,this.source="",this.htmlElement=document.documentElement,this.messages=[],this.isClosable=!0,this.iframeLoaded=!1,this.scrolling="no",this.direction=document.dir,this.canRenderIframe=!1,salla.event.on("login::open",(t=>{this.isEmailAllowed||this.isMobileAllowed?(this.source=t?.source??!1,this.withoutReload=t?.withoutReload??this.withoutReload,this.open(t),this.openModal()):salla.logger.warn("Please enable atleast one login type to use this component.")})),salla.event.on("modal::close",(t=>{this.iframe&&this.sendMessageToIframe({source:"login",type:"modal_closed",data:t})})),salla.onReady((()=>{this.api=salla.config.get("store.api"),this.storeId=salla.config.get("store.id")}))}componentDidLoad(){window.addEventListener("message",(t=>{if(!this.isTrustedMessage(t)||"login"!=t.data?.source)return;if(!this.inline&&!this.canRenderIframe)return;salla.log("salla-account:: recived an event",t.data);let a=t.data?.type?.replace("iframe::",""),s=t.data.message;if("ready"==a)return s.isPasskeyPage?void this.createPassKey.postMessage({source:"login",type:"init_passkey_page",data:{token:salla.storage.get("token"),store_id:salla.config.get("store.id"),locale:salla.config.get("user.language_code"),redirect:salla.config.get("store.url")}},salla.config.get("login.url")):void this.handleIframeReadyAction();if("height"==a)return this.iframe.height=s?.height+"px";if("storage"==a)return this.handleIframeStorageAction(s);if("scrolling"==a)return this.scrolling=s,void(this.isClosable=!1);if("direction"==a)return document.dir=this.direction=s?"rtl":"ltr";if("notify"==a)return salla.notify[s.type](s.message);if("authenticated"==a||"authenticated_web_auth"==a)return!s?.withoutClose&&this.close(),salla.auth.api.handlAfterAuthenticatedResponse(s,this.supportWebAuth).then((()=>!(s?.withoutReload||this.withoutReload)&&setTimeout((()=>window.location.reload()),1e3)));if("dispatchEvent"!=a||"auth::verified"!=s.event){if("dispatchEvent"==a)return salla.event.emit(s.event,...s.payload);if("reload"==a)return s?.withClose&&this.modal.close(),window.location.reload();if("open_page"===a){if(!this.isSafeUrl(s?.url))return;return window.location.href=s.url}if("open_passkey_page"!==a)return"guest-checkout"===a?this.handleGuestCheckout():void("close"==a&&this.close());this.createPassKey=window.open(`${salla.config.get("login.url")}/create-passkey`)}else salla.log("Ignored dispatchEvent `auth::verified` from iframe")})),this.observeDarkModeChanges(),setTimeout((()=>Salla.event.emit("salla-login::ready")),1)}async open(t=null){return Salla.config.isGuest()?this.modal.open():this.withoutReload?void 0:location.reload()}close(){Salla.event.emit("salla-login::closing"),this.modal.close(),this.iframeLoaded=!1,this.canRenderIframe=!1,this.host.dispatchEvent(new CustomEvent("salla-login:closed",{cancelable:!0,bubbles:!0,detail:null})),Salla.event.emit("salla-login::closed")}handleIframeReadyAction(){this.sendInitMessage(),this.sendMessageToIframe({source:"login",type:"width",data:document.body.clientWidth})}observeDarkModeChanges(){new MutationObserver((t=>{t.forEach((t=>{"class"===t.attributeName&&this.sendMessageToIframe({source:"login",type:"darkMode",data:{isDark:!!this.htmlElement.classList.contains("dark")}})}))})).observe(this.htmlElement,{attributes:!0})}async handleIframeStorageAction(t){let a,s=salla.storage.get("cart.user_id"),e=!1;if(Object.entries(t).filter((t=>!Salla.storage.get(t[0]))).forEach((([t,i])=>{salla.log("Shared storage from accounts domain",t,i);let l="string"==typeof i?i?.replace(/^"|"$/g,""):i;salla.storage.set(t,l),"token"===t&&(a=l),"user"===t&&s&&l.id!==s&&(e=!0)})),a){this.modal.close(),Salla.auth.event.tokenFetched(a);try{await Salla.api.cart.assign()}catch(t){Salla.log("Error on assign after handle iframe",t)}e&&Salla.cart.reset();try{!Salla.auth.api.isSessionless()&&await Salla.auth.api.request("auth/jwt"),Salla.auth.api.canRedirect()?setTimeout((()=>window.location.reload()),100):await Salla.auth.event.loggedIn({data:{token:a}}).then((()=>Salla.auth.api.afterUserLogin()))}catch(t){this.modal.open(),Salla.log("Error on request auth/jwt after handle iframe",t)}}else e&&Salla.cart.reset()}isTrustedMessage(t){if(!(this.iframe&&t.source===this.iframe.contentWindow||this.createPassKey&&t.source===this.createPassKey))return!1;let a;try{a=new URL(salla.config.get("login.url","https://accounts.salla.com")).origin}catch(t){a="https://accounts.salla.com"}return t.origin===a}isSafeUrl(t){if("string"!=typeof t||!t)return!1;try{const{protocol:a}=new URL(t,location.href);return"https:"===a||"http:"===a}catch(t){return!1}}sendMessageToIframe(t){if(this.iframe)return this.iframe.contentWindow.postMessage(t,"*")}sendInitMessage(){let t=this.headers;try{t="string"==typeof t?JSON.parse(t):t}catch(a){console.error("Failed to parse headers!",this.headers,a),t=void 0}const a={user:salla.storage.get("user"),s_translations:salla.storage.get("s_translations"),token:salla.storage.get("token")};a.user||delete a.user,a.s_translations||delete a.s_translations,a.token||delete a.token,this.sendMessageToIframe({source:"login",type:"init",data:{id:this.storeId,lang:salla.lang.locale,isDark:!!this.htmlElement.classList.contains("dark"),apiUrl:this.api?.replace(/\/+$/,""),supportWebAuth:this.supportWebAuth,withoutReload:this.withoutReload,inline:this.inline,settings:salla.config.all(),headers:t,storage:a}})}async handleGuestCheckout(){if(this.modal.close(),salla.config.isGuest())return salla.cart.submit(!1,!0)}openModal(){this.canRenderIframe||(this.canRenderIframe=!0),this.modal.open()}render(){if(!Salla.config.isUser())return this.inline?this.getLoginDom():a("salla-modal",{class:"s-login-modal",ref:t=>this.modal=t,width:"xs"},this.getLoginDom())}getLoginDom(){if(this.canRenderIframe)return a(s,null,a("iframe",{src:`${salla.config.get("login.url","https://accounts.salla.com")}?src=${this.source}`,title:"Salla Login",class:"hide-scroll",loading:"lazy",ref:t=>{this.iframe=t},allow:"publickey-credentials-get; publickey-credentials-create",scrolling:this.scrolling,frameborder:"0",width:"100%"}))}get host(){return e(this)}};i.style="iframe{-moz-transition:height 0.3s;-ms-transition:height 0.3s;-o-transition:height 0.3s;-webkit-transition:height 0.3s;transition:height 0.3s;width:100%}";export{i as salla_login_modal}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,h as s,H as i,a as o}from"./p-BDAOgcq0.js";const e=class{constructor(s){t(this,s),this.size="md",this.color="dark",this.digits="auto",this.autoSegments=!1,this.daysLabel=salla.lang.getWithDefault("pages.checkout.day","يوم"),this.hoursLabel=salla.lang.getWithDefault("pages.checkout.hour","ساعة"),this.minutesLabel=salla.lang.getWithDefault("pages.checkout.minute","دقيقة"),this.secondsLabel=salla.lang.getWithDefault("pages.checkout.second","ثانية"),this.endLabel=salla.lang.getWithDefault("pages.checkout.offer_ended","انتهت مدة العرض"),this.invalidDate=salla.lang.getWithDefault("blocks.buy_as_gift.incorrect_date","الرجاء إدخال الموعد بشكل صحيح"),this.offerEnded=!1,this.parseFailed=!1,this.showDays=!0,this.showHours=!0,this.days=this.number(0),this.hours=this.number(0),this.minutes=this.number(0),this.seconds=this.number(0),salla.lang.onLoaded((()=>{this.daysLabel=salla.lang.getWithDefault("pages.checkout.day","يوم"),this.hoursLabel=salla.lang.getWithDefault("pages.checkout.hour","ساعة"),this.minutesLabel=salla.lang.getWithDefault("pages.checkout.minute","دقيقة"),this.invalidDate=salla.lang.getWithDefault("blocks.buy_as_gift.incorrect_date","الرجاء إدخال الموعد بشكل صحيح"),this.secondsLabel=salla.lang.getWithDefault("pages.checkout.second","ثانية"),this.endLabel=salla.lang.getWithDefault("pages.checkout.offer_ended","انتهت مدة العرض")})),this.date&&this.isValidDate(this.date)&&this.startCountDown()}async endCountDown(){clearInterval(this.countInterval),this.offerEnded=!0,this.days=this.number(0),this.hours=this.number(0),this.minutes=this.number(0),this.seconds=this.number(0)}componentWillLoad(){if("string"==typeof this.preOrder)try{this.normalizedPreOrder=JSON.parse(this.preOrder)}catch{this.normalizedPreOrder=void 0}else this.normalizedPreOrder=this.preOrder;this.normalizedPreOrder?.end_date&&(this.date=this.normalizedPreOrder.end_date),this.date&&this.isValidDate(this.date)&&this.startCountDown()}normalizeDate(t){const s=t.match(/^(\d{1,2})-(\d{1,2})-(\d{4}),(\d{1,2}):(\d{2}):(\d{2})\s*(am|pm)$/i);if(s){const[,t,i,o,e,a,n,l]=s;let h=parseInt(e,10);"pm"===l.toLowerCase()&&h<12&&(h+=12),"am"===l.toLowerCase()&&12===h&&(h=0);const r=String(h).padStart(2,"0");return`${o}-${String(t).padStart(2,"0")}-${String(i).padStart(2,"0")} ${r}:${a}:${n}`}const i=t.match(/^(\d{1,2})-(\d{1,2})-(\d{4})$/);if(i){const[,t,s,o]=i;return`${o}-${String(t).padStart(2,"0")}-${String(s).padStart(2,"0")}`}const o=t.match(/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T](\d{1,2}:\d{2}:\d{2}))?$/);if(o){const[,t,s,i,e]=o,a=String(s).padStart(2,"0"),n=String(i).padStart(2,"0");return e?`${t}-${a}-${n} ${e}`:`${t}-${a}-${n}`}return t}isValidDate(t){const s=this.normalizeDate(t);let i,o=s.includes("-"),e=s.split(" ");return i=o?e[0].replace(/-/g,"/"):e[0],!isNaN(Date.parse(i))}number(t){const s=String(Math.max(0,Math.floor(t))).padStart(2,"0");return salla.helpers.number(s,"en"===this.digits)}startCountDown(){const t=this.normalizeDate(this.date),s=t.includes("-"),i=this.endOfDay||1===t.split(" ").length;let o;if(s){const s=i?`${t.split(" ")[0]}T23:59:59+03:00`:`${t.replace(" ","T")}+03:00`;o=new Date(s).getTime()}else{const s=new Date(t);i&&s.setHours(23,59,59,999),o=s.getTime()}if(Number.isNaN(o))return salla.logger.warn(`[salla-count-down] unable to parse date: "${this.date}"`),void(this.parseFailed=!0);const e=()=>{const t=o-Date.now(),s=Math.floor(t/864e5),i=Math.floor(t%864e5/36e5);this.days=this.number(s),this.hours=this.number(i),this.minutes=this.number(Math.floor(t%36e5/6e4)),this.seconds=this.number(Math.floor(t%6e4/1e3)),this.autoSegments&&(this.showDays=s>0,this.showHours=s>0||i>0),t<0&&this.endCountDown()};this.countInterval=setInterval(e,1e3),e()}renderCountDown(){const t=this.boxTheme?`var(--color-${this.boxTheme})`:this.boxColor,i=this.boxed&&t?{backgroundColor:t}:void 0;return s("ul",{class:`s-count-down-list ${this.boxed?"s-count-down-boxed":""} ${this.offerEnded?"s-count-down-ended":""} s-count-down-${this.size} s-count-down-${this.color}`,style:this.listPadding?{paddingLeft:this.listPadding,paddingRight:this.listPadding}:void 0},s("li",{class:"s-count-down-item",style:i},s("div",{class:"s-count-down-item-value"},this.seconds),this.labeled&&s("div",{class:"s-count-down-item-label"},this.secondsLabel)),s("li",{class:"s-count-down-item",style:i},s("div",{class:"s-count-down-item-value"},this.minutes),this.labeled&&s("div",{class:"s-count-down-item-label"},this.minutesLabel)),(!this.autoSegments||this.showHours)&&s("li",{class:"s-count-down-item",style:i},s("div",{class:"s-count-down-item-value"},this.hours),this.labeled&&s("div",{class:"s-count-down-item-label"},this.hoursLabel)),(!this.autoSegments||this.showDays)&&s("li",{class:"s-count-down-item",style:i},s("div",{class:"s-count-down-item-value"},this.days),this.labeled&&s("div",{class:"s-count-down-item-label"},this.daysLabel)))}renderInvalidDate(){return s("div",{class:"s-count-down-text-center"},this.invalidDate)}renderOfferEnded(){return s("div",{class:"s-count-down-end-text"},this.endText?this.endText:this.endLabel)}renderPreOrderToBeAvailableOn(){return this.normalizedPreOrder?.availability_date&&this.isValidDate(this.normalizedPreOrder?.availability_date)?s("div",{class:"s-count-down-info-message"},s("i",{class:"sicon-info"}),s("span",null,salla.lang.getWithDefault("pages.products.expected_to_be","متوقَّع توفُّره بتاريخ:")),s("span",null,new Date(this.normalizedPreOrder?.availability_date).toLocaleDateString(salla.lang.locale,{weekday:"long",year:"numeric",month:"long",day:"numeric"}))):null}renderPreOrderCountDown(){return this.normalizedPreOrder?.activate_countdown?s("div",{class:"s-count-down-pre-order-container"},s("p",{class:"text-sm "},salla.lang.getWithDefault("pages.products.pre_order_ends_in","ينتهي الطلب المسبق خلال:")),this.renderCountDown()):null}renderPreOrder(){return s("div",null,"object"==typeof this.normalizedPreOrder&&this.normalizedPreOrder?.availability_date&&this.renderPreOrderToBeAvailableOn(),this.renderPreOrderCountDown())}renderPrefixText(){return this.prefixText?s("span",{class:"s-count-down-prefix-text"},this.prefixText):null}renderButton(){return this.withButton&&this.buttonText?s("salla-button",{color:"primary",size:"medium",href:this.buttonHref},this.buttonIcon?s("i",{class:this.buttonIcon}):null,s("span",null,this.buttonText)):null}renderContent(){return this.date?!this.isValidDate(this.date)||this.parseFailed?this.renderInvalidDate():this.preOrder?this.renderPreOrder():this.renderCountDown():null}render(){return s(i,{key:"e2805e528a52b71ad71f4f1f16a473947dafb5bc",class:`s-count-down-wrapper ${this.preOrder&&this.isValidDate(this.date)?"s-count-down-pre-order":""} ${this.horizontal?"s-count-down-horizontal":""} ${this.withButton?"s-count-down-with-button":""} ${this.offerEnded?"s-count-down-ended":""}`},this.renderPrefixText(),this.renderContent(),this.offerEnded&&this.renderOfferEnded(),this.renderButton())}};e.style=".s-count-down-horizontal{background-color:rgba(0, 0, 0, 0.06);background-color:color-mix(in srgb, var(--color-primary) 10%, transparent)}";const a=class{constructor(s){t(this,s),this.resolveFn=null,this.rejectFn=null,this.optionsRefs=new Map,this.changeHandler=null,this.submitCallback=null,this.orderOptions=[],this.basePrice=0,this.liveTotal=0,this.isSubmitting=!1,this.sessionId=0,this.paymentMode="default",this.title="",this.subtitle="",this.submitLabel="",this.totalLabel="",this.requiredMessage="",this.handleClose=()=>{this.isSubmitting||(this.rejectFn?.({reason:"dismissed"}),this.resolveFn=null,this.rejectFn=null,this.detachChangeListener(),this.reset())},salla.lang.onLoaded((()=>this.loadTranslations()))}componentWillLoad(){this.loadTranslations()}loadTranslations(){this.title=salla.lang.get("blocks.order_options.title"),this.subtitle=salla.lang.get("blocks.order_options.subtitle"),this.submitLabel=salla.lang.get("blocks.order_options.continue"),this.totalLabel=salla.lang.get("blocks.order_options.total"),this.requiredMessage=salla.lang.get("blocks.order_options.required_message")}async open(t){return this.orderOptions=(Array.isArray(t.orderOptions)?t.orderOptions:[]).map((t=>({...t,details:t.details??[]}))),this.basePrice=Number(t.basePrice)||0,this.liveTotal=this.basePrice+this.seedOptionsPrice(this.orderOptions),this.isSubmitting=!1,this.sessionId++,this.optionsRefs.clear(),this.submitCallback=t.onSubmit??null,this.paymentMode=t.paymentMode??"default",await(this.modal?.open()),this.attachChangeListener(),new Promise(((t,s)=>{this.resolveFn=t,this.rejectFn=s}))}async close(){await(this.modal?.close())}collectOrderOptionsSync(){const t=[];for(const[,s]of this.optionsRefs)s&&s.querySelectorAll('[name^="options["],[name*="[options]["]').forEach((s=>{if(s instanceof HTMLInputElement&&("radio"===s.type||"checkbox"===s.type)&&!s.checked)return;const i=s.name.match(/(?:^|\[)options\]?\[(\d+)\]/);if(!i)return;const o=s.value;if(""===o||null==o)return;const e=Number(o);t.push({id:Number(i[1]),value:Number.isFinite(e)&&o===String(e)?e:o})}));return t}validateSync(){let t=!0;for(const[,s]of this.optionsRefs)s&&s.querySelectorAll("[required]").forEach((s=>{s.disabled||s.closest(".hidden")||"reportValidity"in s&&!s.reportValidity()&&(t=!1)}));return t}seedOptionsPrice(t){let s=0;return t.forEach((t=>{(t.details||[]).forEach((t=>{t.is_selected&&(s+=Number(t.additional_price)||0)}))})),s}attachChangeListener(){this.detachChangeListener(),this.changeHandler=()=>this.recomputeTotal(),salla.event.on("product-options::change",this.changeHandler)}detachChangeListener(){this.changeHandler&&(salla.event.off("product-options::change",this.changeHandler),this.changeHandler=null)}async recomputeTotal(){let t=0;for(const[,s]of this.optionsRefs)s&&(("function"==typeof s.getSelectedOptions?await s.getSelectedOptions():[])||[]).forEach((s=>{t+=Number(s.additional_price)||0}));this.liveTotal=this.basePrice+t}handleSubmit(){if(this.isSubmitting)return;if(!this.validateSync())return void salla.notify?.error?.(this.requiredMessage);this.isSubmitting=!0;const t=this.collectOrderOptionsSync(),s=Math.round(100*this.liveTotal)/100;try{this.submitCallback?.(t,s)}catch(t){salla?.logger?.warn?.("order-options modal onSubmit threw",t)}this.resolveFn?.({orderOptions:t}),this.resolveFn=null,this.rejectFn=null,this.submitCallback=null,this.detachChangeListener(),this.modal?.close().then((()=>this.reset())),this.isSubmitting=!1}reset(){this.orderOptions=[],this.optionsRefs.clear(),this.liveTotal=0}render(){const t=salla.money(Math.round(100*this.liveTotal)/100);return s("salla-modal",{key:"a7b7c31da2f5fd9f5f3ee601052f84e512368cee",ref:t=>this.modal=t,class:"s-order-options-modal-host",width:"md","modal-title":this.title,onModalVisibilityChanged:t=>{t.detail||this.handleClose()}},s("div",{key:"9a44c4dcec6f0e49a65217b1e1e2cd19ccc80c76",class:"s-order-options-modal-body"},s("p",{key:"66c41a32e2130db4dc1aa402a31cfd6d519544b3",class:"s-order-options-modal-subtitle"},this.subtitle),s("div",{key:"fffe868427973b6426b8a2f8f33f48c017dfb7fb",class:"s-order-options-modal-fields"},this.orderOptions.length>0&&s("salla-product-options",{key:this.sessionId,ref:t=>{t&&(this.optionsRefs.set("order-options",t),t.seedSelectedOptions?.())},"product-id":`order-options-${this.orderOptions[0]?.id}`,"unique-key":"order-options",options:JSON.stringify(this.orderOptions),"hide-out-label":"1","no-padding":!0}))),s("div",{key:"36f3a18380f05a8420d4bc32fa643bf596ac16fb",slot:"footer",class:"s-order-options-modal-footer"},"apple-pay"===this.paymentMode?s("div",{class:"s-order-options-modal-apple-pay-wrap"},s("div",{class:"s-order-options-modal-apple-pay-total"},s("span",{class:"s-order-options-modal-apple-pay-label"},this.totalLabel),s("span",{class:"s-order-options-modal-apple-pay-amount",innerHTML:t})),s("apple-pay-button",{locale:salla?.config?.get?.("user.language_code")||"ar",buttonstyle:"black",type:"buy",class:"s-order-options-modal-apple-pay",onClick:()=>this.handleSubmit()})):s("salla-button",{type:"button",color:"primary",fill:"solid",width:"wide",loading:this.isSubmitting,onClick:()=>this.handleSubmit()},s("span",{class:"s-order-options-modal-cta-content"},s("span",{class:"s-order-options-modal-cta-text"},this.submitLabel),s("span",{class:"s-order-options-modal-cta-total",innerHTML:t})))))}get host(){return o(this)}};a.style=".s-order-options-modal-host .s-modal-header-inner,.s-order-options-modal-host .s-modal-header-content,.s-order-options-modal-host .s-modal-title{text-align:start !important}.s-order-options-modal-apple-pay{display:block;width:100%;--apple-pay-button-width:100%;--apple-pay-button-height:44px;--apple-pay-button-border-radius:0.75rem}.s-order-options-modal-apple-pay-wrap{display:flex;flex-direction:column;gap:0.75rem;width:100%}.s-order-options-modal-apple-pay-total{display:flex;align-items:center;justify-content:space-between;gap:0.5rem}.s-order-options-modal-apple-pay-label,.s-order-options-modal-apple-pay-amount{font-size:1.125rem;line-height:1.5rem;font-weight:700;color:#111827}";export{e as salla_count_down,a as salla_order_options_modal}
4
+ import{r as t,h as s,H as i,a as o}from"./p-DgmW0rL4.js";const e=class{constructor(s){t(this,s),this.size="md",this.color="dark",this.digits="auto",this.autoSegments=!1,this.daysLabel=salla.lang.getWithDefault("pages.checkout.day","يوم"),this.hoursLabel=salla.lang.getWithDefault("pages.checkout.hour","ساعة"),this.minutesLabel=salla.lang.getWithDefault("pages.checkout.minute","دقيقة"),this.secondsLabel=salla.lang.getWithDefault("pages.checkout.second","ثانية"),this.endLabel=salla.lang.getWithDefault("pages.checkout.offer_ended","انتهت مدة العرض"),this.invalidDate=salla.lang.getWithDefault("blocks.buy_as_gift.incorrect_date","الرجاء إدخال الموعد بشكل صحيح"),this.offerEnded=!1,this.parseFailed=!1,this.showDays=!0,this.showHours=!0,this.days=this.number(0),this.hours=this.number(0),this.minutes=this.number(0),this.seconds=this.number(0),salla.lang.onLoaded((()=>{this.daysLabel=salla.lang.getWithDefault("pages.checkout.day","يوم"),this.hoursLabel=salla.lang.getWithDefault("pages.checkout.hour","ساعة"),this.minutesLabel=salla.lang.getWithDefault("pages.checkout.minute","دقيقة"),this.invalidDate=salla.lang.getWithDefault("blocks.buy_as_gift.incorrect_date","الرجاء إدخال الموعد بشكل صحيح"),this.secondsLabel=salla.lang.getWithDefault("pages.checkout.second","ثانية"),this.endLabel=salla.lang.getWithDefault("pages.checkout.offer_ended","انتهت مدة العرض")})),this.date&&this.isValidDate(this.date)&&this.startCountDown()}async endCountDown(){clearInterval(this.countInterval),this.offerEnded=!0,this.days=this.number(0),this.hours=this.number(0),this.minutes=this.number(0),this.seconds=this.number(0)}componentWillLoad(){if("string"==typeof this.preOrder)try{this.normalizedPreOrder=JSON.parse(this.preOrder)}catch{this.normalizedPreOrder=void 0}else this.normalizedPreOrder=this.preOrder;this.normalizedPreOrder?.end_date&&(this.date=this.normalizedPreOrder.end_date),this.date&&this.isValidDate(this.date)&&this.startCountDown()}normalizeDate(t){const s=t.match(/^(\d{1,2})-(\d{1,2})-(\d{4}),(\d{1,2}):(\d{2}):(\d{2})\s*(am|pm)$/i);if(s){const[,t,i,o,e,a,n,l]=s;let r=parseInt(e,10);"pm"===l.toLowerCase()&&r<12&&(r+=12),"am"===l.toLowerCase()&&12===r&&(r=0);const h=String(r).padStart(2,"0");return`${o}-${String(t).padStart(2,"0")}-${String(i).padStart(2,"0")} ${h}:${a}:${n}`}const i=t.match(/^(\d{1,2})-(\d{1,2})-(\d{4})$/);if(i){const[,t,s,o]=i;return`${o}-${String(t).padStart(2,"0")}-${String(s).padStart(2,"0")}`}const o=t.match(/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T](\d{1,2}:\d{2}:\d{2}))?$/);if(o){const[,t,s,i,e]=o,a=String(s).padStart(2,"0"),n=String(i).padStart(2,"0");return e?`${t}-${a}-${n} ${e}`:`${t}-${a}-${n}`}return t}isValidDate(t){const s=this.normalizeDate(t);let i,o=s.includes("-"),e=s.split(" ");return i=o?e[0].replace(/-/g,"/"):e[0],!isNaN(Date.parse(i))}number(t){const s=String(Math.max(0,Math.floor(t))).padStart(2,"0");return salla.helpers.number(s,"en"===this.digits)}startCountDown(){const t=this.normalizeDate(this.date),s=t.includes("-"),i=this.endOfDay||1===t.split(" ").length;let o;if(s){const s=i?`${t.split(" ")[0]}T23:59:59+03:00`:`${t.replace(" ","T")}+03:00`;o=new Date(s).getTime()}else{const s=new Date(t);i&&s.setHours(23,59,59,999),o=s.getTime()}if(Number.isNaN(o))return salla.logger.warn(`[salla-count-down] unable to parse date: "${this.date}"`),void(this.parseFailed=!0);const e=()=>{const t=o-Date.now(),s=Math.floor(t/864e5),i=Math.floor(t%864e5/36e5);this.days=this.number(s),this.hours=this.number(i),this.minutes=this.number(Math.floor(t%36e5/6e4)),this.seconds=this.number(Math.floor(t%6e4/1e3)),this.autoSegments&&(this.showDays=s>0,this.showHours=s>0||i>0),t<0&&this.endCountDown()};this.countInterval=setInterval(e,1e3),e()}renderCountDown(){const t=this.boxTheme?`var(--color-${this.boxTheme})`:this.boxColor,i=this.boxed&&t?{backgroundColor:t}:void 0;return s("ul",{class:`s-count-down-list ${this.boxed?"s-count-down-boxed":""} ${this.offerEnded?"s-count-down-ended":""} s-count-down-${this.size} s-count-down-${this.color}`,style:this.listPadding?{paddingLeft:this.listPadding,paddingRight:this.listPadding}:void 0},s("li",{class:"s-count-down-item",style:i},s("div",{class:"s-count-down-item-value"},this.seconds),this.labeled&&s("div",{class:"s-count-down-item-label"},this.secondsLabel)),s("li",{class:"s-count-down-item",style:i},s("div",{class:"s-count-down-item-value"},this.minutes),this.labeled&&s("div",{class:"s-count-down-item-label"},this.minutesLabel)),(!this.autoSegments||this.showHours)&&s("li",{class:"s-count-down-item",style:i},s("div",{class:"s-count-down-item-value"},this.hours),this.labeled&&s("div",{class:"s-count-down-item-label"},this.hoursLabel)),(!this.autoSegments||this.showDays)&&s("li",{class:"s-count-down-item",style:i},s("div",{class:"s-count-down-item-value"},this.days),this.labeled&&s("div",{class:"s-count-down-item-label"},this.daysLabel)))}renderInvalidDate(){return s("div",{class:"s-count-down-text-center"},this.invalidDate)}renderOfferEnded(){return s("div",{class:"s-count-down-end-text"},this.endText?this.endText:this.endLabel)}renderPreOrderToBeAvailableOn(){return this.normalizedPreOrder?.availability_date&&this.isValidDate(this.normalizedPreOrder?.availability_date)?s("div",{class:"s-count-down-info-message"},s("i",{class:"sicon-info"}),s("span",null,salla.lang.getWithDefault("pages.products.expected_to_be","متوقَّع توفُّره بتاريخ:")),s("span",null,new Date(this.normalizedPreOrder?.availability_date).toLocaleDateString(salla.lang.locale,{weekday:"long",year:"numeric",month:"long",day:"numeric"}))):null}renderPreOrderCountDown(){return this.normalizedPreOrder?.activate_countdown?s("div",{class:"s-count-down-pre-order-container"},s("p",{class:"text-sm "},salla.lang.getWithDefault("pages.products.pre_order_ends_in","ينتهي الطلب المسبق خلال:")),this.renderCountDown()):null}renderPreOrder(){return s("div",null,"object"==typeof this.normalizedPreOrder&&this.normalizedPreOrder?.availability_date&&this.renderPreOrderToBeAvailableOn(),this.renderPreOrderCountDown())}renderPrefixText(){return this.prefixText?s("span",{class:"s-count-down-prefix-text"},this.prefixText):null}renderButton(){return this.withButton&&this.buttonText?s("salla-button",{color:"primary",size:"medium",href:this.buttonHref},this.buttonIcon?s("i",{class:this.buttonIcon}):null,s("span",null,this.buttonText)):null}renderContent(){return this.date?!this.isValidDate(this.date)||this.parseFailed?this.renderInvalidDate():this.preOrder?this.renderPreOrder():this.renderCountDown():null}render(){return s(i,{key:"e2805e528a52b71ad71f4f1f16a473947dafb5bc",class:`s-count-down-wrapper ${this.preOrder&&this.isValidDate(this.date)?"s-count-down-pre-order":""} ${this.horizontal?"s-count-down-horizontal":""} ${this.withButton?"s-count-down-with-button":""} ${this.offerEnded?"s-count-down-ended":""}`},this.renderPrefixText(),this.renderContent(),this.offerEnded&&this.renderOfferEnded(),this.renderButton())}};e.style=".s-count-down-horizontal{background-color:rgba(0, 0, 0, 0.06);background-color:color-mix(in srgb, var(--color-primary) 10%, transparent)}";const a=class{constructor(s){t(this,s),this.resolveFn=null,this.rejectFn=null,this.optionsRefs=new Map,this.changeHandler=null,this.submitCallback=null,this.orderOptions=[],this.basePrice=0,this.liveTotal=0,this.isSubmitting=!1,this.sessionId=0,this.paymentMode="default",this.title="",this.subtitle="",this.submitLabel="",this.totalLabel="",this.requiredMessage="",this.handleClose=()=>{this.isSubmitting||(this.rejectFn?.({reason:"dismissed"}),this.resolveFn=null,this.rejectFn=null,this.detachChangeListener(),this.reset())},salla.lang.onLoaded((()=>this.loadTranslations()))}componentWillLoad(){this.loadTranslations()}loadTranslations(){this.title=salla.lang.get("blocks.order_options.title"),this.subtitle=salla.lang.get("blocks.order_options.subtitle"),this.submitLabel=salla.lang.get("blocks.order_options.continue"),this.totalLabel=salla.lang.get("blocks.order_options.total"),this.requiredMessage=salla.lang.get("blocks.order_options.required_message")}async open(t){return this.orderOptions=(Array.isArray(t.orderOptions)?t.orderOptions:[]).map((t=>({...t,details:t.details??[]}))),this.basePrice=Number(t.basePrice)||0,this.liveTotal=this.basePrice+this.seedOptionsPrice(this.orderOptions),this.isSubmitting=!1,this.sessionId++,this.optionsRefs.clear(),this.submitCallback=t.onSubmit??null,this.paymentMode=t.paymentMode??"default",await(this.modal?.open()),this.attachChangeListener(),new Promise(((t,s)=>{this.resolveFn=t,this.rejectFn=s}))}async close(){await(this.modal?.close())}collectOrderOptionsSync(){const t=[];for(const[,s]of this.optionsRefs)s&&s.querySelectorAll('[name^="options["],[name*="[options]["]').forEach((s=>{if(s instanceof HTMLInputElement&&("radio"===s.type||"checkbox"===s.type)&&!s.checked)return;const i=s.name.match(/(?:^|\[)options\]?\[(\d+)\]/);if(!i)return;const o=s.value;if(""===o||null==o)return;const e=Number(o);t.push({id:Number(i[1]),value:Number.isFinite(e)&&o===String(e)?e:o})}));return t}validateSync(){let t=!0;for(const[,s]of this.optionsRefs)s&&s.querySelectorAll("[required]").forEach((s=>{s.disabled||s.closest(".hidden")||"reportValidity"in s&&!s.reportValidity()&&(t=!1)}));return t}seedOptionsPrice(t){let s=0;return t.forEach((t=>{(t.details||[]).forEach((t=>{t.is_selected&&(s+=Number(t.additional_price)||0)}))})),s}attachChangeListener(){this.detachChangeListener(),this.changeHandler=()=>this.recomputeTotal(),salla.event.on("product-options::change",this.changeHandler)}detachChangeListener(){this.changeHandler&&(salla.event.off("product-options::change",this.changeHandler),this.changeHandler=null)}async recomputeTotal(){let t=0;for(const[,s]of this.optionsRefs)s&&(("function"==typeof s.getSelectedOptions?await s.getSelectedOptions():[])||[]).forEach((s=>{t+=Number(s.additional_price)||0}));this.liveTotal=this.basePrice+t}handleSubmit(){if(this.isSubmitting)return;if(!this.validateSync())return void salla.notify?.error?.(this.requiredMessage);this.isSubmitting=!0;const t=this.collectOrderOptionsSync(),s=Math.round(100*this.liveTotal)/100;try{this.submitCallback?.(t,s)}catch(t){salla?.logger?.warn?.("order-options modal onSubmit threw",t)}this.resolveFn?.({orderOptions:t}),this.resolveFn=null,this.rejectFn=null,this.submitCallback=null,this.detachChangeListener(),this.modal?.close().then((()=>this.reset())),this.isSubmitting=!1}reset(){this.orderOptions=[],this.optionsRefs.clear(),this.liveTotal=0}render(){const t=salla.money(Math.round(100*this.liveTotal)/100);return s("salla-modal",{key:"a7b7c31da2f5fd9f5f3ee601052f84e512368cee",ref:t=>this.modal=t,class:"s-order-options-modal-host",width:"md","modal-title":this.title,onModalVisibilityChanged:t=>{t.detail||this.handleClose()}},s("div",{key:"9a44c4dcec6f0e49a65217b1e1e2cd19ccc80c76",class:"s-order-options-modal-body"},s("p",{key:"66c41a32e2130db4dc1aa402a31cfd6d519544b3",class:"s-order-options-modal-subtitle"},this.subtitle),s("div",{key:"fffe868427973b6426b8a2f8f33f48c017dfb7fb",class:"s-order-options-modal-fields"},this.orderOptions.length>0&&s("salla-product-options",{key:this.sessionId,ref:t=>{t&&(this.optionsRefs.set("order-options",t),t.seedSelectedOptions?.())},"product-id":`order-options-${this.orderOptions[0]?.id}`,"unique-key":"order-options",options:JSON.stringify(this.orderOptions),"hide-out-label":"1","no-padding":!0}))),s("div",{key:"36f3a18380f05a8420d4bc32fa643bf596ac16fb",slot:"footer",class:"s-order-options-modal-footer"},"apple-pay"===this.paymentMode?s("div",{class:"s-order-options-modal-apple-pay-wrap"},s("div",{class:"s-order-options-modal-apple-pay-total"},s("span",{class:"s-order-options-modal-apple-pay-label"},this.totalLabel),s("span",{class:"s-order-options-modal-apple-pay-amount",innerHTML:t})),s("apple-pay-button",{locale:salla?.config?.get?.("user.language_code")||"ar",buttonstyle:"black",type:"buy",class:"s-order-options-modal-apple-pay",onClick:()=>this.handleSubmit()})):s("salla-button",{type:"button",color:"primary",fill:"solid",width:"wide",loading:this.isSubmitting,onClick:()=>this.handleSubmit()},s("span",{class:"s-order-options-modal-cta-content"},s("span",{class:"s-order-options-modal-cta-text"},this.submitLabel),s("span",{class:"s-order-options-modal-cta-total",innerHTML:t})))))}get host(){return o(this)}};a.style=".s-order-options-modal-host .s-modal-header-inner,.s-order-options-modal-host .s-modal-header-content,.s-order-options-modal-host .s-modal-title{text-align:start !important}.s-order-options-modal-apple-pay{display:block;width:100%;--apple-pay-button-width:100%;--apple-pay-button-height:44px;--apple-pay-button-border-radius:0.75rem}.s-order-options-modal-apple-pay-wrap{display:flex;flex-direction:column;gap:0.75rem;width:100%}.s-order-options-modal-apple-pay-total{display:flex;align-items:center;justify-content:space-between;gap:0.5rem}.s-order-options-modal-apple-pay-label,.s-order-options-modal-apple-pay-amount{font-size:1.125rem;line-height:1.5rem;font-weight:700;color:#111827}";export{e as salla_count_down,a as salla_order_options_modal}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,h as e,H as s,a as l,F as i}from"./p-BDAOgcq0.js";const n=class{constructor(e){t(this,e),this.sections=[],this.itemNumber=""}deleteItem(t,e){const s=this.host.closest("form");if(s){const l=s.getAttribute("id");if(l&&"string"==typeof l){const s=l.match(/item-(\d+)/)?.[1];this.itemNumber=s||"";const i=this.host.querySelector(`#accordion-${e.id}`);salla.cart.deleteItem(`${this.itemNumber}?product_id=${e.id}&section_id=${t}`).then((()=>i?.remove()))}}}renderRemoveButton(t,s,l=!1){return e("salla-button",{type:"button",shape:l?"btn":"icon",fill:l?"outline":"solid",size:"small",color:"danger","aria-label":"Remove from the cart",onClick:()=>this.deleteItem(t,s)},l?salla.lang.get("common.elements.delete"):e("i",{class:"sicon-cancel"}))}renderAccordionHeader(t,s){const l=s?.options&&s?.options?.length>0;return e("div",{slot:"html",class:"s-multiple-bundle-product-cart-header-wrapper"},e("div",{class:"s-multiple-bundle-product-cart-header "+(l?"":"s-multiple-bundle-product-cart-header-no-options")},e("div",{class:"s-multiple-bundle-product-cart-header-content"},e("a",{href:s?.url,class:"s-multiple-bundle-product-cart-header-image-wrapper"},e("img",{src:s?.image?.url,alt:s?.image?.alt||s?.name,class:"s-multiple-bundle-product-cart-header-image"})),e("div",{class:"s-multiple-bundle-product-cart-header-content-details"},e("h2",{class:"s-multiple-bundle-product-cart-header-content-details-title"},e("a",{href:s?.url,class:"s-multiple-bundle-product-cart-header-content-details-title-link"},s?.name)),e("div",{class:"s-multiple-bundle-product-cart-header-content-details-price"},e("span",{class:"s-multiple-bundle-product-cart-header-content-details-price-regular"},e("span",{innerHTML:s?.price?salla.money(s?.price):""})),s?.sale_price>0&&e("span",{class:"s-multiple-bundle-product-cart-header-content-details-price-sale"},e("span",{innerHTML:salla.money(s?.sale_price)}))),s?.quantity_in_group>0&&0!==s?.quantity&&e("p",{class:"s-multiple-bundle-product-cart-header-content-details-quantity"},e("span",null,salla.lang.get("pages.products.number_of_pieces")),e("span",null,s?.quantity_in_group)))),!l&&e("div",{class:"s-multiple-bundle-product-cart-header-remove-button"},this.renderRemoveButton(t,s,!1))))}render(){return e(s,{key:"78be7c4a3be811adb01cb1437473fcd9f1c17b41",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"9b0439dffc9a2dd8d31f56dacb5d835cde903e71",class:"s-multiple-bundle-product-wrapper-sections"},this.sections.map(((t,s)=>t.products.map((l=>{const i={sectionId:t.id,sectionIndex:s,productId:l.id};return e("salla-accordion",{key:l.id,collapsed:!1,bordered:!0,collapsible:!!(l.options&&l.options.length>0),size:"sm",id:`accordion-${l.id}`},e("salla-accordion-head",null,this.renderAccordionHeader(String(t.id),l)),l.options&&l.options.length>0&&e("salla-accordion-body",null,e("salla-product-options",{options:JSON.stringify(l.options),key:`${l.id}-persistent`,"product-id":l.id,"bundle-context":JSON.stringify(i)}),e("div",{class:"s-multiple-bundle-product-cart-body-remove-button"},this.renderRemoveButton(String(t.id),l,!0))))}))))))}get host(){return l(this)}};n.style="";const c=class{constructor(e){t(this,e),this.sections=[],this.selectedProducts={},this.productSelectedHandler=null,this.onSelectProduct=(t,e)=>{const s=e.id,l=this.selectedProducts[t]?.has(s)??!1,i=this.sections.find((e=>e.id==t));if(!(l&&i&&this.isProductSelectionLocked(i))){if(!l){if(!i)return;if(1!==this.getEffectiveMax(i)&&this.isAtSelectionLimit(i))return}this.selectedProducts={...this.selectedProducts,[t]:new Set(this.selectedProducts[t]||[])},l?(this.selectedProducts[t].delete(s),this.clearProductFormData(s,t),this.clearProductModalOptions(s,t)):1===this.getEffectiveMax(i)?this.syncSectionSelection(t,s):this.selectedProducts[t].add(s),this.selectedProducts={...this.selectedProducts},salla.event.dispatch("on-bundle-product-selected",{id:e.id,name:e.name,options:e.options,wasSelected:l,isSelected:!l})}},this.ensureProductSelected=(t,e)=>{this.selectedProducts={...this.selectedProducts,[t]:new Set(this.selectedProducts[t]||[])};const s=e.id;if(this.selectedProducts[t].has(s))return;const l=this.sections.find((e=>e.id==t));if(!l)return;const i=this.getEffectiveMax(l);if(1===i)this.syncSectionSelection(t,s);else{if(i>1&&this.isAtSelectionLimit(l))return;this.selectedProducts[t].add(s)}this.selectedProducts={...this.selectedProducts},salla.event.dispatch("on-bundle-product-selected",{id:e.id,name:e.name,options:e.options})},this.onSelectProductOptions=(t,e)=>{const s=this.sections.find((t=>t.id==e));if(!s||!this.canSelectProductInSection(s,t.id))return;const l=this.sections.findIndex((t=>t.id==e)),i=s.products?.findIndex((e=>e.id==t.id))??0,n=this.selectedProducts[e]?.has(t.id)??!1;salla.event.dispatch("multiple-bundle-product-modal::open",{product:t,sectionId:e,sectionIndex:l,productIndex:i,isProductAlreadySelected:n})},this.handleBundleSliderProductSelected=t=>{const{product:e,sectionId:s}=t.detail;this.onSelectProduct(s,e)},this.handleBundleSliderProductOptionsSelected=t=>{const{product:e,sectionId:s}=t.detail;this.onSelectProductOptions(e,s)}}isSingleProductSection(t){return 1===(t.products?.length??0)}getObligatoryMin(t){const e=t.obligatory_products;if(null==e)return 0;const s=Number(e);return Number.isNaN(s)?0:s}isProductSelectionLocked(t){return this.isSingleProductSection(t)&&1===this.getObligatoryMin(t)}getEffectiveMax(t){const e=t.products?.length??0,s=t.max_obligatory_products;return null!=s&&s>0?Math.min(s,e):e}getSelectedCount(t){return this.selectedProducts[t]?.size??0}isAtSelectionLimit(t){return this.getSelectedCount(t.id)>=this.getEffectiveMax(t)}canSelectProductInSection(t,e){return!!this.selectedProducts[t.id]?.has(e)||1===this.getEffectiveMax(t)||!this.isAtSelectionLimit(t)}async canSelectBundleProduct(t,e){const s=this.sections.find((e=>e.id==t));return!!s&&this.canSelectProductInSection(s,e)}queryProductCheckbox(t,e){const s=`input.s-multiple-bundle-product-checkbox[name="bundle[${t}][${e}][id]"]`,l=this.host.closest("form"),i=l?.querySelector(s);if(i)return i;for(const t of this.host.querySelectorAll("salla-multiple-bundle-product-slider")){const e=(t.shadowRoot??t).querySelector(s);if(e)return e}return null}dispatchBubblingChange(t){requestAnimationFrame((()=>{t.dispatchEvent(new window.Event("change",{bubbles:!0}))}))}clearSectionProductSlot(t,e,s){const l=this.queryProductCheckbox(t,s);l&&(l.checked=!1);const i=this.host.closest("form");if(i){const e=`bundle[${t}][${s}]`;Array.from(i.querySelectorAll("input")).forEach((t=>{t.name?.startsWith(e)&&("checkbox"===t.type&&t.name?.endsWith("][id]")?t.checked=!1:t.remove())}))}this.clearProductModalOptions(e,t)}syncSectionSelection(t,e){const s=this.sections.find((e=>e.id==t));s?.products?.forEach(((s,l)=>{s.id!=e&&this.clearSectionProductSlot(t,s.id,l)})),this.selectedProducts[t]=new Set([e]);const l=s?.products?.findIndex((t=>t.id==e))??-1,i=l>=0?this.queryProductCheckbox(t,l):null;i&&(i.checked=!0,this.dispatchBubblingChange(i))}autoSelectSingleProductSections(){if(!this.sections?.length)return;const t={...this.selectedProducts};let e=!1;const s=[];for(const l of this.sections){if(!this.isProductSelectionLocked(l))continue;const i=l.products?.[0];if(!i||!i.unlimited_quantity&&(i.quantity??0)<=0)continue;const n=l.id,c=new Set(t[n]||[]);c.has(i.id)||(c.add(i.id),t[n]=c,e=!0,s.push({product:i}))}e&&(this.selectedProducts=t,s.forEach((({product:t})=>{salla.event.dispatch("on-bundle-product-selected",{id:t.id,name:t.name,options:t.options})})))}clearProductFormData(t,e){if(null!=e){const s=this.sections.find((t=>t.id==e)),l=s?.products?.findIndex((e=>e.id==t))??-1;if(l>=0)return void this.clearSectionProductSlot(e,t,l)}const s=this.host.closest("form");s&&s.querySelectorAll(`[data-product-id="${t}"]`).forEach((t=>t.remove()))}clearProductModalOptions(t,e){let s=null,l=null;if(null!=e&&(s=this.sections.findIndex((t=>t.id==e)),s>-1)){const e=this.sections[s];if(e){const s=e.products?.findIndex((e=>e.id==t));l="number"==typeof s&&s>-1?s:null}}salla.event.dispatch("multiple-bundle-product-modal::clear-options",{productId:t,sectionId:e,sectionIndex:s,productIndex:l})}getProgressStatus(t){const e=this.getSelectedCount(t.id),s=this.getEffectiveMax(t);return s>0?`${e}/${s}`:"0"}getSectionSelectionNote(t){const e=this.getObligatoryMin(t),s=Number(t.max_obligatory_products)||0,l=e>0,i=s>0;return l||i?l&&i?e===s?salla.lang.getWithDefault("pages.products.bundle_select_exact",`اختر ${e} منتجات`,{count:e}):salla.lang.getWithDefault("pages.products.bundle_select_range",`اختر من ${e} إلى ${s} منتجات`,{min:e,max:s}):l?salla.lang.getWithDefault("pages.products.bundle_select_min",`اختر على الأقل ${e} منتجات`,{min:e}):salla.lang.getWithDefault("pages.products.bundle_select_max",`اختر حتى ${s} منتجات`,{max:s}):null}handleSectionsChange(){this.autoSelectSingleProductSections()}componentWillLoad(){this.autoSelectSingleProductSections()}renderAccordionHeader(t){const s=this.getSectionSelectionNote(t);return e(i,null,e("h2",{slot:"title"},t?.name),s?e("span",{slot:"note"},s):null,e("span",{slot:"progress"},this.getProgressStatus(t)))}componentDidLoad(){const t=this.host.querySelector("salla-multiple-bundle-product-options-modal");t&&(this.productSelectedHandler=t=>{const{productId:e,sectionId:s,product:l,fromModal:i}=t.detail;i?this.ensureProductSelected(s,l||{id:e}):this.onSelectProduct(s,l||{id:e})},t.addEventListener("productSelected",this.productSelectedHandler))}disconnectedCallback(){if(this.productSelectedHandler){const t=this.host.querySelector("salla-multiple-bundle-product-options-modal");t&&t.removeEventListener("productSelected",this.productSelectedHandler),this.productSelectedHandler=null}}render(){return e(s,{key:"1ba2cde8fad73b16cfc2ccdd5e68331a9e3fdb7a",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"a72d9fc9f3df30616d3d0696c755db4e76c9a153",class:"s-multiple-bundle-product-wrapper-sections"},this.sections.map(((t,s)=>e("salla-accordion",{key:t.id,collapsed:0!==s},e("salla-accordion-head",null,this.renderAccordionHeader(t)),e("salla-accordion-body",null,e("salla-multiple-bundle-product-slider",{section:t,sectionIndex:s,selectedProducts:this.selectedProducts,selectionLimit:this.getEffectiveMax(t),isSelectionLocked:this.isProductSelectionLocked(t),onProductSelected:this.handleBundleSliderProductSelected,onProductOptionsSelected:this.handleBundleSliderProductOptionsSelected})))))),e("salla-multiple-bundle-product-options-modal",{key:"1e2f996c2d995c62ae29dedc90826a1f1d0a1320"}))}get host(){return l(this)}static get watchers(){return{sections:["handleSectionsChange"]}}};c.style="";export{n as salla_multiple_bundle_product_cart,c as salla_multiple_bundle_product_details}
4
+ import{r as t,h as e,H as s,a as l,F as i}from"./p-DgmW0rL4.js";const n=class{constructor(e){t(this,e),this.sections=[],this.itemNumber=""}deleteItem(t,e){const s=this.host.closest("form");if(s){const l=s.getAttribute("id");if(l&&"string"==typeof l){const s=l.match(/item-(\d+)/)?.[1];this.itemNumber=s||"";const i=this.host.querySelector(`#accordion-${e.id}`);salla.cart.deleteItem(`${this.itemNumber}?product_id=${e.id}&section_id=${t}`).then((()=>i?.remove()))}}}renderRemoveButton(t,s,l=!1){return e("salla-button",{type:"button",shape:l?"btn":"icon",fill:l?"outline":"solid",size:"small",color:"danger","aria-label":"Remove from the cart",onClick:()=>this.deleteItem(t,s)},l?salla.lang.get("common.elements.delete"):e("i",{class:"sicon-cancel"}))}renderAccordionHeader(t,s){const l=s?.options&&s?.options?.length>0;return e("div",{slot:"html",class:"s-multiple-bundle-product-cart-header-wrapper"},e("div",{class:"s-multiple-bundle-product-cart-header "+(l?"":"s-multiple-bundle-product-cart-header-no-options")},e("div",{class:"s-multiple-bundle-product-cart-header-content"},e("a",{href:s?.url,class:"s-multiple-bundle-product-cart-header-image-wrapper"},e("img",{src:s?.image?.url,alt:s?.image?.alt||s?.name,class:"s-multiple-bundle-product-cart-header-image"})),e("div",{class:"s-multiple-bundle-product-cart-header-content-details"},e("h2",{class:"s-multiple-bundle-product-cart-header-content-details-title"},e("a",{href:s?.url,class:"s-multiple-bundle-product-cart-header-content-details-title-link"},s?.name)),e("div",{class:"s-multiple-bundle-product-cart-header-content-details-price"},e("span",{class:"s-multiple-bundle-product-cart-header-content-details-price-regular"},e("span",{innerHTML:s?.price?salla.money(s?.price):""})),s?.sale_price>0&&e("span",{class:"s-multiple-bundle-product-cart-header-content-details-price-sale"},e("span",{innerHTML:salla.money(s?.sale_price)}))),s?.quantity_in_group>0&&0!==s?.quantity&&e("p",{class:"s-multiple-bundle-product-cart-header-content-details-quantity"},e("span",null,salla.lang.get("pages.products.number_of_pieces")),e("span",null,s?.quantity_in_group)))),!l&&e("div",{class:"s-multiple-bundle-product-cart-header-remove-button"},this.renderRemoveButton(t,s,!1))))}render(){return e(s,{key:"78be7c4a3be811adb01cb1437473fcd9f1c17b41",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"9b0439dffc9a2dd8d31f56dacb5d835cde903e71",class:"s-multiple-bundle-product-wrapper-sections"},this.sections.map(((t,s)=>t.products.map((l=>{const i={sectionId:t.id,sectionIndex:s,productId:l.id};return e("salla-accordion",{key:l.id,collapsed:!1,bordered:!0,collapsible:!!(l.options&&l.options.length>0),size:"sm",id:`accordion-${l.id}`},e("salla-accordion-head",null,this.renderAccordionHeader(String(t.id),l)),l.options&&l.options.length>0&&e("salla-accordion-body",null,e("salla-product-options",{options:JSON.stringify(l.options),key:`${l.id}-persistent`,"product-id":l.id,"bundle-context":JSON.stringify(i)}),e("div",{class:"s-multiple-bundle-product-cart-body-remove-button"},this.renderRemoveButton(String(t.id),l,!0))))}))))))}get host(){return l(this)}};n.style="";const c=class{constructor(e){t(this,e),this.sections=[],this.selectedProducts={},this.productSelectedHandler=null,this.onSelectProduct=(t,e)=>{const s=e.id,l=this.selectedProducts[t]?.has(s)??!1,i=this.sections.find((e=>e.id==t));if(!(l&&i&&this.isProductSelectionLocked(i))){if(!l){if(!i)return;if(1!==this.getEffectiveMax(i)&&this.isAtSelectionLimit(i))return}this.selectedProducts={...this.selectedProducts,[t]:new Set(this.selectedProducts[t]||[])},l?(this.selectedProducts[t].delete(s),this.clearProductFormData(s,t),this.clearProductModalOptions(s,t)):1===this.getEffectiveMax(i)?this.syncSectionSelection(t,s):this.selectedProducts[t].add(s),this.selectedProducts={...this.selectedProducts},salla.event.dispatch("on-bundle-product-selected",{id:e.id,name:e.name,options:e.options,wasSelected:l,isSelected:!l})}},this.ensureProductSelected=(t,e)=>{this.selectedProducts={...this.selectedProducts,[t]:new Set(this.selectedProducts[t]||[])};const s=e.id;if(this.selectedProducts[t].has(s))return;const l=this.sections.find((e=>e.id==t));if(!l)return;const i=this.getEffectiveMax(l);if(1===i)this.syncSectionSelection(t,s);else{if(i>1&&this.isAtSelectionLimit(l))return;this.selectedProducts[t].add(s)}this.selectedProducts={...this.selectedProducts},salla.event.dispatch("on-bundle-product-selected",{id:e.id,name:e.name,options:e.options})},this.onSelectProductOptions=(t,e)=>{const s=this.sections.find((t=>t.id==e));if(!s||!this.canSelectProductInSection(s,t.id))return;const l=this.sections.findIndex((t=>t.id==e)),i=s.products?.findIndex((e=>e.id==t.id))??0,n=this.selectedProducts[e]?.has(t.id)??!1;salla.event.dispatch("multiple-bundle-product-modal::open",{product:t,sectionId:e,sectionIndex:l,productIndex:i,isProductAlreadySelected:n})},this.handleBundleSliderProductSelected=t=>{const{product:e,sectionId:s}=t.detail;this.onSelectProduct(s,e)},this.handleBundleSliderProductOptionsSelected=t=>{const{product:e,sectionId:s}=t.detail;this.onSelectProductOptions(e,s)}}isSingleProductSection(t){return 1===(t.products?.length??0)}getObligatoryMin(t){const e=t.obligatory_products;if(null==e)return 0;const s=Number(e);return Number.isNaN(s)?0:s}isProductSelectionLocked(t){return this.isSingleProductSection(t)&&1===this.getObligatoryMin(t)}getEffectiveMax(t){const e=t.products?.length??0,s=t.max_obligatory_products;return null!=s&&s>0?Math.min(s,e):e}getSelectedCount(t){return this.selectedProducts[t]?.size??0}isAtSelectionLimit(t){return this.getSelectedCount(t.id)>=this.getEffectiveMax(t)}canSelectProductInSection(t,e){return!!this.selectedProducts[t.id]?.has(e)||1===this.getEffectiveMax(t)||!this.isAtSelectionLimit(t)}async canSelectBundleProduct(t,e){const s=this.sections.find((e=>e.id==t));return!!s&&this.canSelectProductInSection(s,e)}queryProductCheckbox(t,e){const s=`input.s-multiple-bundle-product-checkbox[name="bundle[${t}][${e}][id]"]`,l=this.host.closest("form"),i=l?.querySelector(s);if(i)return i;for(const t of this.host.querySelectorAll("salla-multiple-bundle-product-slider")){const e=(t.shadowRoot??t).querySelector(s);if(e)return e}return null}dispatchBubblingChange(t){requestAnimationFrame((()=>{t.dispatchEvent(new window.Event("change",{bubbles:!0}))}))}clearSectionProductSlot(t,e,s){const l=this.queryProductCheckbox(t,s);l&&(l.checked=!1);const i=this.host.closest("form");if(i){const e=`bundle[${t}][${s}]`;Array.from(i.querySelectorAll("input")).forEach((t=>{t.name?.startsWith(e)&&("checkbox"===t.type&&t.name?.endsWith("][id]")?t.checked=!1:t.remove())}))}this.clearProductModalOptions(e,t)}syncSectionSelection(t,e){const s=this.sections.find((e=>e.id==t));s?.products?.forEach(((s,l)=>{s.id!=e&&this.clearSectionProductSlot(t,s.id,l)})),this.selectedProducts[t]=new Set([e]);const l=s?.products?.findIndex((t=>t.id==e))??-1,i=l>=0?this.queryProductCheckbox(t,l):null;i&&(i.checked=!0,this.dispatchBubblingChange(i))}autoSelectSingleProductSections(){if(!this.sections?.length)return;const t={...this.selectedProducts};let e=!1;const s=[];for(const l of this.sections){if(!this.isProductSelectionLocked(l))continue;const i=l.products?.[0];if(!i||!i.unlimited_quantity&&(i.quantity??0)<=0)continue;const n=l.id,c=new Set(t[n]||[]);c.has(i.id)||(c.add(i.id),t[n]=c,e=!0,s.push({product:i}))}e&&(this.selectedProducts=t,s.forEach((({product:t})=>{salla.event.dispatch("on-bundle-product-selected",{id:t.id,name:t.name,options:t.options})})))}clearProductFormData(t,e){if(null!=e){const s=this.sections.find((t=>t.id==e)),l=s?.products?.findIndex((e=>e.id==t))??-1;if(l>=0)return void this.clearSectionProductSlot(e,t,l)}const s=this.host.closest("form");s&&s.querySelectorAll(`[data-product-id="${t}"]`).forEach((t=>t.remove()))}clearProductModalOptions(t,e){let s=null,l=null;if(null!=e&&(s=this.sections.findIndex((t=>t.id==e)),s>-1)){const e=this.sections[s];if(e){const s=e.products?.findIndex((e=>e.id==t));l="number"==typeof s&&s>-1?s:null}}salla.event.dispatch("multiple-bundle-product-modal::clear-options",{productId:t,sectionId:e,sectionIndex:s,productIndex:l})}getProgressStatus(t){const e=this.getSelectedCount(t.id),s=this.getEffectiveMax(t);return s>0?`${e}/${s}`:"0"}getSectionSelectionNote(t){const e=this.getObligatoryMin(t),s=Number(t.max_obligatory_products)||0,l=e>0,i=s>0;return l||i?l&&i?e===s?salla.lang.getWithDefault("pages.products.bundle_select_exact",`اختر ${e} منتجات`,{count:e}):salla.lang.getWithDefault("pages.products.bundle_select_range",`اختر من ${e} إلى ${s} منتجات`,{min:e,max:s}):l?salla.lang.getWithDefault("pages.products.bundle_select_min",`اختر على الأقل ${e} منتجات`,{min:e}):salla.lang.getWithDefault("pages.products.bundle_select_max",`اختر حتى ${s} منتجات`,{max:s}):null}handleSectionsChange(){this.autoSelectSingleProductSections()}componentWillLoad(){this.autoSelectSingleProductSections()}renderAccordionHeader(t){const s=this.getSectionSelectionNote(t);return e(i,null,e("h2",{slot:"title"},t?.name),s?e("span",{slot:"note"},s):null,e("span",{slot:"progress"},this.getProgressStatus(t)))}componentDidLoad(){const t=this.host.querySelector("salla-multiple-bundle-product-options-modal");t&&(this.productSelectedHandler=t=>{const{productId:e,sectionId:s,product:l,fromModal:i}=t.detail;i?this.ensureProductSelected(s,l||{id:e}):this.onSelectProduct(s,l||{id:e})},t.addEventListener("productSelected",this.productSelectedHandler))}disconnectedCallback(){if(this.productSelectedHandler){const t=this.host.querySelector("salla-multiple-bundle-product-options-modal");t&&t.removeEventListener("productSelected",this.productSelectedHandler),this.productSelectedHandler=null}}render(){return e(s,{key:"1ba2cde8fad73b16cfc2ccdd5e68331a9e3fdb7a",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"a72d9fc9f3df30616d3d0696c755db4e76c9a153",class:"s-multiple-bundle-product-wrapper-sections"},this.sections.map(((t,s)=>e("salla-accordion",{key:t.id,collapsed:0!==s},e("salla-accordion-head",null,this.renderAccordionHeader(t)),e("salla-accordion-body",null,e("salla-multiple-bundle-product-slider",{section:t,sectionIndex:s,selectedProducts:this.selectedProducts,selectionLimit:this.getEffectiveMax(t),isSelectionLocked:this.isProductSelectionLocked(t),onProductSelected:this.handleBundleSliderProductSelected,onProductOptionsSelected:this.handleBundleSliderProductOptionsSelected})))))),e("salla-multiple-bundle-product-options-modal",{key:"1e2f996c2d995c62ae29dedc90826a1f1d0a1320"}))}get host(){return l(this)}static get watchers(){return{sections:["handleSectionsChange"]}}};c.style="";export{n as salla_multiple_bundle_product_cart,c as salla_multiple_bundle_product_details}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as t}from"./p-BDAOgcq0.js";import{T as o}from"./p-CJUR4sUM.js";import{i as n}from"./p-DqDX5na4.js";const e=class{constructor(t){s(this,t),this.coupon=null,this.isLoading=!0,this.titlePercentTpl="",this.titleFixedTpl="",this.badgeLabel="",this.minSpendTpl="",this.expiresTpl="",this.shopNowLabel="",this.copyLabel="",this.copiedLabel=""}componentWillLoad(){Salla.onReady().then((()=>Salla.lang.onLoaded())).then((()=>(this.loadTranslations(),this.loadCoupon()))).catch((()=>{this.isLoading=!1}))}loadTranslations(){this.titlePercentTpl=Salla.lang.get("pages.thank_you.next_order_coupon_title_percent")||"",this.titleFixedTpl=Salla.lang.get("pages.thank_you.next_order_coupon_title_fixed")||"",this.badgeLabel=Salla.lang.get("pages.thank_you.next_order_coupon_badge")||"",this.minSpendTpl=Salla.lang.get("pages.thank_you.next_order_coupon_min_spend")||"",this.expiresTpl=Salla.lang.get("pages.thank_you.next_order_coupon_expires")||"",this.shopNowLabel=Salla.lang.get("pages.thank_you.next_order_coupon_shop_now")||"",this.copyLabel=Salla.lang.get("common.elements.copy")||"",this.copiedLabel=Salla.lang.get("pages.thank_you.next_order_coupon_copied")||""}async loadCoupon(){try{const s=await salla.api.request("coupons",{params:{type:"thankyou"}}),t=s?.data,o=Array.isArray(t)?t:Array.isArray(t?.data)?t.data:[];this.coupon=o[0]??null}catch{this.coupon=null}finally{this.isLoading=!1}}async copyCode(){if(this.coupon)try{await navigator.clipboard.writeText(this.coupon.code),salla.notify.success(this.copiedLabel),salla.event.dispatch("salla::next-order-coupon.code.copied",{code:this.coupon.code})}catch{}}isPercentage(){return"P"===this.coupon?.type||"percentage"===this.coupon?.type}formatAmount(){if(!this.coupon)return"";if(this.isPercentage())return`${salla.helpers.number(this.coupon.amount)}%`;const s=this.coupon.amount;return t("span","object"==typeof s&&s.amount?{innerHTML:salla.money(s.amount,s.currency)}:{innerHTML:salla.money(s)})}formatMinSpend(){const s=this.coupon?.minimum_amount;return s&&("object"!=typeof s||s.amount)?"string"==typeof s?s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"):salla.money(s.amount,s.currency):""}formatExpiry(){const s=this.coupon?.expiry_date;return s?new Date(s).toLocaleDateString(Salla.lang.locale||"en-GB"):""}renderSkeleton(){return t("div",{class:"s-next-order-coupon-wrapper s-next-order-coupon-skeleton"},t("div",{class:"s-next-order-coupon-inner"},t("div",{class:"s-next-order-coupon-info"},t("salla-skeleton",{type:"normal",width:"48px",height:"48px"}),t("div",{class:"s-next-order-coupon-details"},t("salla-skeleton",{height:"14px",width:"220px"}),t("salla-skeleton",{height:"12px",width:"140px"}))),t("div",{class:"s-next-order-coupon-actions"},t("salla-skeleton",{height:"40px",width:"140px"}),t("salla-skeleton",{height:"40px",width:"100px"}))))}renderTitle(){const s=this.formatAmount(),o=this.isPercentage()?this.titlePercentTpl:this.titleFixedTpl,n=this.isPercentage()?":amount%":":amount",e=o.split(n);return t("p",{class:"s-next-order-coupon-title"},e[0],t("span",{class:"s-next-order-coupon-amount"},s),e[1]||"")}render(){if(this.isLoading)return this.renderSkeleton();if(!this.coupon)return null;const s=this.formatMinSpend(),e=this.formatExpiry();return t("div",{class:"s-next-order-coupon-wrapper"},t("div",{class:"s-next-order-coupon-inner"},t("div",{class:"s-next-order-coupon-info"},t("div",{class:"s-next-order-coupon-icon-wrap"},t("span",{class:"s-next-order-coupon-icon-bg"}),t("span",{class:"s-next-order-coupon-icon",innerHTML:o})),t("div",{class:"s-next-order-coupon-details"},t("div",{class:"s-next-order-coupon-title-row"},this.renderTitle(),t("span",{class:"s-next-order-coupon-badge"},t("span",{class:"s-next-order-coupon-badge-bg"}),t("span",{class:"s-next-order-coupon-badge-text"},this.badgeLabel))),(s||e)&&t("p",{class:"s-next-order-coupon-meta"},s&&t("span",{innerHTML:this.minSpendTpl.replace(":amount",s)}),e&&t("span",null,this.expiresTpl.replace(":date",e))))),t("div",{class:"s-next-order-coupon-actions"},t("div",{class:"s-next-order-coupon-code-box"},t("span",{class:"s-next-order-coupon-code-text"},this.coupon.code),t("salla-button",{shape:"link",class:"s-next-order-coupon-copy-btn",title:this.copyLabel,onClick:()=>this.copyCode()},t("span",{class:"s-next-order-coupon-copy-icon",innerHTML:n}))),t("salla-button",{href:salla.url.get(""),class:"s-next-order-coupon-shop-btn"},this.shopNowLabel))))}};e.style=":host{display:block}";export{e as salla_next_order_coupon}
4
+ import{r as s,h as t}from"./p-DgmW0rL4.js";import{T as o}from"./p-CJUR4sUM.js";import{i as n}from"./p-DqDX5na4.js";const e=class{constructor(t){s(this,t),this.coupon=null,this.isLoading=!0,this.titlePercentTpl="",this.titleFixedTpl="",this.badgeLabel="",this.minSpendTpl="",this.expiresTpl="",this.shopNowLabel="",this.copyLabel="",this.copiedLabel=""}componentWillLoad(){Salla.onReady().then((()=>Salla.lang.onLoaded())).then((()=>(this.loadTranslations(),this.loadCoupon()))).catch((()=>{this.isLoading=!1}))}loadTranslations(){this.titlePercentTpl=Salla.lang.get("pages.thank_you.next_order_coupon_title_percent")||"",this.titleFixedTpl=Salla.lang.get("pages.thank_you.next_order_coupon_title_fixed")||"",this.badgeLabel=Salla.lang.get("pages.thank_you.next_order_coupon_badge")||"",this.minSpendTpl=Salla.lang.get("pages.thank_you.next_order_coupon_min_spend")||"",this.expiresTpl=Salla.lang.get("pages.thank_you.next_order_coupon_expires")||"",this.shopNowLabel=Salla.lang.get("pages.thank_you.next_order_coupon_shop_now")||"",this.copyLabel=Salla.lang.get("common.elements.copy")||"",this.copiedLabel=Salla.lang.get("pages.thank_you.next_order_coupon_copied")||""}async loadCoupon(){try{const s=await salla.api.request("coupons",{params:{type:"thankyou"}}),t=s?.data,o=Array.isArray(t)?t:Array.isArray(t?.data)?t.data:[];this.coupon=o[0]??null}catch{this.coupon=null}finally{this.isLoading=!1}}async copyCode(){if(this.coupon)try{await navigator.clipboard.writeText(this.coupon.code),salla.notify.success(this.copiedLabel),salla.event.dispatch("salla::next-order-coupon.code.copied",{code:this.coupon.code})}catch{}}isPercentage(){return"P"===this.coupon?.type||"percentage"===this.coupon?.type}formatAmount(){if(!this.coupon)return"";if(this.isPercentage())return`${salla.helpers.number(this.coupon.amount)}%`;const s=this.coupon.amount;return t("span","object"==typeof s&&s.amount?{innerHTML:salla.money(s.amount,s.currency)}:{innerHTML:salla.money(s)})}formatMinSpend(){const s=this.coupon?.minimum_amount;return s&&("object"!=typeof s||s.amount)?"string"==typeof s?s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"):salla.money(s.amount,s.currency):""}formatExpiry(){const s=this.coupon?.expiry_date;return s?new Date(s).toLocaleDateString(Salla.lang.locale||"en-GB"):""}renderSkeleton(){return t("div",{class:"s-next-order-coupon-wrapper s-next-order-coupon-skeleton"},t("div",{class:"s-next-order-coupon-inner"},t("div",{class:"s-next-order-coupon-info"},t("salla-skeleton",{type:"normal",width:"48px",height:"48px"}),t("div",{class:"s-next-order-coupon-details"},t("salla-skeleton",{height:"14px",width:"220px"}),t("salla-skeleton",{height:"12px",width:"140px"}))),t("div",{class:"s-next-order-coupon-actions"},t("salla-skeleton",{height:"40px",width:"140px"}),t("salla-skeleton",{height:"40px",width:"100px"}))))}renderTitle(){const s=this.formatAmount(),o=this.isPercentage()?this.titlePercentTpl:this.titleFixedTpl,n=this.isPercentage()?":amount%":":amount",e=o.split(n);return t("p",{class:"s-next-order-coupon-title"},e[0],t("span",{class:"s-next-order-coupon-amount"},s),e[1]||"")}render(){if(this.isLoading)return this.renderSkeleton();if(!this.coupon)return null;const s=this.formatMinSpend(),e=this.formatExpiry();return t("div",{class:"s-next-order-coupon-wrapper"},t("div",{class:"s-next-order-coupon-inner"},t("div",{class:"s-next-order-coupon-info"},t("div",{class:"s-next-order-coupon-icon-wrap"},t("span",{class:"s-next-order-coupon-icon-bg"}),t("span",{class:"s-next-order-coupon-icon",innerHTML:o})),t("div",{class:"s-next-order-coupon-details"},t("div",{class:"s-next-order-coupon-title-row"},this.renderTitle(),t("span",{class:"s-next-order-coupon-badge"},t("span",{class:"s-next-order-coupon-badge-bg"}),t("span",{class:"s-next-order-coupon-badge-text"},this.badgeLabel))),(s||e)&&t("p",{class:"s-next-order-coupon-meta"},s&&t("span",{innerHTML:this.minSpendTpl.replace(":amount",s)}),e&&t("span",null,this.expiresTpl.replace(":date",e))))),t("div",{class:"s-next-order-coupon-actions"},t("div",{class:"s-next-order-coupon-code-box"},t("span",{class:"s-next-order-coupon-code-text"},this.coupon.code),t("salla-button",{shape:"link",class:"s-next-order-coupon-copy-btn",title:this.copyLabel,onClick:()=>this.copyCode()},t("span",{class:"s-next-order-coupon-copy-icon",innerHTML:n}))),t("salla-button",{href:salla.url.get(""),class:"s-next-order-coupon-shop-btn"},this.shopNowLabel))))}};e.style=":host{display:block}";export{e as salla_next_order_coupon}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as a,h as e,H as s,c,a as d}from"./p-BDAOgcq0.js";import{p as t,m as o}from"./p-DfeagqF1.js";const i=class{constructor(e){a(this,e)}render(){return e(s,{key:"6407cbdb46897f683d1339287bcd0dc0df3dd409",class:"s-accordion-body-wrapper"},e("slot",{key:"ca050dff0df1dbee3d42a35582386829390dbdd3"}))}};i.style="";const r=class{constructor(e){a(this,e),this.accordionToggle=c(this,"accordionToggle"),this.collapsible=!1,this.collapsed=!0}emitCollapsePanel(){this.accordionToggle.emit({payload:{collapsed:this.collapsed}})}toggleCollapse(){this.collapsible&&(this.collapsed=!this.collapsed,this.host.parentElement?.setAttribute("data-collapsed",this.collapsed.toString()),this.host.parentElement?.querySelector("salla-accordion-body")?.setAttribute("data-collapsed",this.collapsed.toString()),this.emitCollapsePanel())}render(){return e(s,{key:"8fea8adefb7bd0b6aa4d88be25cb4e3f62bd4b0c","data-collapsed":this.collapsed.toString(),onClick:()=>this.toggleCollapse(),class:"s-accordion-head-wrapper"},e("div",{key:"d64952e2ec87c3f4de27f85800a0659b8cfbe08b",class:"s-accordion-head-wrapper-start"},e("slot",{key:"876bb377bef979afdb3b88e35d66ebe95e90ada8",name:"title"}),e("slot",{key:"b2a81aa92c0032098dd271931933679815660e6d",name:"progress"}),e("slot",{key:"9df2e816a0308cdd632bf13a7f16b553b5e877c2",name:"html"})),(this.collapsible||this.host.querySelector('[slot="note"]'))&&e("div",{key:"06f75d18708331176cdb1c80fd67dae352bd0550",class:"s-accordion-head-wrapper-end"},e("slot",{key:"04c7b9f174b6fff7aed4b1a045f160c4b11bbf55",name:"note"}),this.collapsible&&e("button",{key:"311aa1946afea02eb64b1c8e15c7e2fe97c76ecf",class:{"s-accordion-head-wrapper-toggle":!0,active:!this.collapsed},onClick:a=>{a.stopPropagation(),this.toggleCollapse()}},e("span",{key:"9758c580c6ca64c88079a76c0775ec727e0c488f",class:"s-accordion-head-wrapper-toggle-icon",innerHTML:this.collapsed?t:o}))))}get host(){return d(this)}};r.style="";export{i as salla_accordion_body,r as salla_accordion_head}
4
+ import{r as a,h as e,H as s,c,a as d}from"./p-DgmW0rL4.js";import{p as t,m as o}from"./p-DfeagqF1.js";const r=class{constructor(e){a(this,e)}render(){return e(s,{key:"6407cbdb46897f683d1339287bcd0dc0df3dd409",class:"s-accordion-body-wrapper"},e("slot",{key:"ca050dff0df1dbee3d42a35582386829390dbdd3"}))}};r.style="";const i=class{constructor(e){a(this,e),this.accordionToggle=c(this,"accordionToggle"),this.collapsible=!1,this.collapsed=!0}emitCollapsePanel(){this.accordionToggle.emit({payload:{collapsed:this.collapsed}})}toggleCollapse(){this.collapsible&&(this.collapsed=!this.collapsed,this.host.parentElement?.setAttribute("data-collapsed",this.collapsed.toString()),this.host.parentElement?.querySelector("salla-accordion-body")?.setAttribute("data-collapsed",this.collapsed.toString()),this.emitCollapsePanel())}render(){return e(s,{key:"8fea8adefb7bd0b6aa4d88be25cb4e3f62bd4b0c","data-collapsed":this.collapsed.toString(),onClick:()=>this.toggleCollapse(),class:"s-accordion-head-wrapper"},e("div",{key:"d64952e2ec87c3f4de27f85800a0659b8cfbe08b",class:"s-accordion-head-wrapper-start"},e("slot",{key:"876bb377bef979afdb3b88e35d66ebe95e90ada8",name:"title"}),e("slot",{key:"b2a81aa92c0032098dd271931933679815660e6d",name:"progress"}),e("slot",{key:"9df2e816a0308cdd632bf13a7f16b553b5e877c2",name:"html"})),(this.collapsible||this.host.querySelector('[slot="note"]'))&&e("div",{key:"06f75d18708331176cdb1c80fd67dae352bd0550",class:"s-accordion-head-wrapper-end"},e("slot",{key:"04c7b9f174b6fff7aed4b1a045f160c4b11bbf55",name:"note"}),this.collapsible&&e("button",{key:"311aa1946afea02eb64b1c8e15c7e2fe97c76ecf",class:{"s-accordion-head-wrapper-toggle":!0,active:!this.collapsed},onClick:a=>{a.stopPropagation(),this.toggleCollapse()}},e("span",{key:"9758c580c6ca64c88079a76c0775ec727e0c488f",class:"s-accordion-head-wrapper-toggle-icon",innerHTML:this.collapsed?t:o}))))}get host(){return d(this)}};i.style="";export{r as salla_accordion_body,i as salla_accordion_head}