@salla.sa/twilight-components 2.14.597 → 2.14.599

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 (359) hide show
  1. package/dist/cjs/{filepond-Dw1N5qBB.js → filepond-Dk1cJoJp.js} +1 -1
  2. package/dist/cjs/{filepond-plugin-file-poster-C1ipzdpz.js → filepond-plugin-file-poster-Bg4PCTUm.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-validate-size-DbTJ1H8k.js → filepond-plugin-file-validate-size-DmqmRxXK.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-type-CDOD2WKz.js → filepond-plugin-file-validate-type-BKd2QnuC.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-image-edit-CP7JkpKx.js → filepond-plugin-image-edit-BIPbEbnk.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-exif-orientation-Bm5i6zMO.js → filepond-plugin-image-exif-orientation-eQvkwjqa.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-preview-INllb63L.js → filepond-plugin-image-preview-Ba8K6ft0.js} +1 -1
  8. package/dist/cjs/{index-DIEWuq3M.js → index-Bm1Ew-5K.js} +7 -7
  9. package/dist/cjs/{intlTelInput-bnpl10H7.js → intlTelInput-MWwwr9Td.js} +1 -1
  10. package/dist/cjs/loader.cjs.js +1 -1
  11. package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
  12. package/dist/cjs/salla-accordion_6.cjs.entry.js +1 -1
  13. package/dist/cjs/salla-add-product-button_5.cjs.entry.js +1 -1
  14. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  15. package/dist/cjs/salla-alert_2.cjs.entry.js +1 -1
  16. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  17. package/dist/cjs/salla-applied-filters.cjs.entry.js +1 -1
  18. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  19. package/dist/cjs/salla-attachment-view_9.cjs.entry.js +73 -13
  20. package/dist/cjs/salla-badge.cjs.entry.js +1 -1
  21. package/dist/cjs/salla-basket-gap.cjs.entry.js +1 -1
  22. package/dist/cjs/salla-bullet-delivery_3.cjs.entry.js +1 -1
  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_9.cjs.entry.js +4 -2
  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.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-gift-card-redeem_2.cjs.entry.js +1 -1
  40. package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-hook.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  44. package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
  45. package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
  46. package/dist/cjs/salla-login-modal.cjs.entry.js +14 -3
  47. package/dist/cjs/salla-loyalty-banner_10.cjs.entry.js +1 -1
  48. package/dist/cjs/salla-loyalty-exchange-product-card.cjs.entry.js +1 -1
  49. package/dist/cjs/salla-loyalty-points-banner.cjs.entry.js +1 -1
  50. package/dist/cjs/salla-loyalty-points-history.cjs.entry.js +1 -1
  51. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  52. package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
  53. package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
  54. package/dist/cjs/salla-map_3.cjs.entry.js +1 -1
  55. package/dist/cjs/salla-menu.cjs.entry.js +1 -1
  56. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  57. package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
  58. package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
  59. package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
  60. package/dist/cjs/salla-next-order-coupon.cjs.entry.js +1 -1
  61. package/dist/cjs/salla-notification-item_2.cjs.entry.js +1 -1
  62. package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
  63. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  64. package/dist/cjs/salla-order-branch.cjs.entry.js +1 -1
  65. package/dist/cjs/salla-order-cancel.cjs.entry.js +1 -1
  66. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  67. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  68. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  69. package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
  70. package/dist/cjs/salla-order-edit-product-card.cjs.entry.js +1 -1
  71. package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
  72. package/dist/cjs/salla-order-options-modal.cjs.entry.js +1 -1
  73. package/dist/cjs/salla-order-shipments.cjs.entry.js +1 -1
  74. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  75. package/dist/cjs/salla-order-totals-card.cjs.entry.js +11 -4
  76. package/dist/cjs/salla-orders.cjs.entry.js +32 -2
  77. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  78. package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
  79. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  80. package/dist/cjs/salla-product-card-embed.cjs.entry.js +1 -1
  81. package/dist/cjs/salla-product-card.cjs.entry.js +3 -1
  82. package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
  83. package/dist/cjs/salla-products-list.cjs.entry.js +1 -1
  84. package/dist/cjs/salla-products-slider.cjs.entry.js +1 -1
  85. package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
  86. package/dist/cjs/salla-rating-modal-v2.cjs.entry.js +1 -1
  87. package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
  88. package/dist/cjs/salla-review-factors-tags.cjs.entry.js +1 -1
  89. package/dist/cjs/salla-review-order-item.cjs.entry.js +1 -1
  90. package/dist/cjs/salla-scopes.cjs.entry.js +3 -3
  91. package/dist/cjs/salla-search-product-card.cjs.entry.js +1 -1
  92. package/dist/cjs/salla-search.cjs.entry.js +1 -1
  93. package/dist/cjs/salla-skeleton.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-trust-badges.cjs.entry.js +2 -2
  99. package/dist/cjs/salla-user-menu.cjs.entry.js +33 -2
  100. package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
  101. package/dist/cjs/salla-user-settings.cjs.entry.js +1 -1
  102. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  103. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  104. package/dist/cjs/salla-wishlist-actions.cjs.entry.js +1 -1
  105. package/dist/cjs/salla-wishlist-summary.cjs.entry.js +1 -1
  106. package/dist/cjs/twilight.cjs.js +1 -1
  107. package/dist/cjs/{vanilla-picker-BaSDLxjI.js → vanilla-picker-BpuzEJnJ.js} +1 -1
  108. package/dist/collection/Helpers/money-text.js +37 -0
  109. package/dist/collection/components/salla-comments/salla-comment-item.js +3 -1
  110. package/dist/collection/components/salla-file-upload/salla-file-upload.js +63 -3
  111. package/dist/collection/components/salla-login-modal/salla-login-modal.css +3 -0
  112. package/dist/collection/components/salla-login-modal/salla-login-modal.js +12 -1
  113. package/dist/collection/components/salla-order-totals-card/salla-order-totals-card.js +10 -3
  114. package/dist/collection/components/salla-orders/salla-orders.js +4 -1
  115. package/dist/collection/components/salla-product-card/salla-product-card.js +2 -0
  116. package/dist/collection/components/salla-scopes/salla-scopes.css +14 -0
  117. package/dist/collection/components/salla-scopes/salla-scopes.js +1 -1
  118. package/dist/collection/components/salla-trust-badges/salla-trust-badges.css +17 -12
  119. package/dist/collection/components/salla-user-menu/salla-user-menu.js +32 -1
  120. package/dist/components/index.js +3 -3
  121. package/dist/components/salla-comment-item2.js +3 -1
  122. package/dist/components/salla-file-upload2.js +63 -3
  123. package/dist/components/salla-login-modal2.js +13 -2
  124. package/dist/components/salla-order-totals-card.js +10 -3
  125. package/dist/components/salla-orders.js +31 -1
  126. package/dist/components/salla-product-card2.js +2 -0
  127. package/dist/components/salla-scopes.js +2 -2
  128. package/dist/components/salla-trust-badges.js +1 -1
  129. package/dist/components/salla-user-menu.js +32 -1
  130. package/dist/docs.json +1 -1
  131. package/dist/esm/{filepond-DfLkIBAw.js → filepond-3PnWp9w_.js} +1 -1
  132. package/dist/esm/{filepond-plugin-file-poster-D3ie06bz.js → filepond-plugin-file-poster-DmoyhYlz.js} +1 -1
  133. package/dist/esm/{filepond-plugin-file-validate-size-C_S_eFQe.js → filepond-plugin-file-validate-size-CFkn2RRt.js} +1 -1
  134. package/dist/esm/{filepond-plugin-file-validate-type-BE7nqQRE.js → filepond-plugin-file-validate-type-pyAPn10a.js} +1 -1
  135. package/dist/esm/{filepond-plugin-image-edit-C6jDcMnX.js → filepond-plugin-image-edit-B5Rfgqvi.js} +1 -1
  136. package/dist/esm/{filepond-plugin-image-exif-orientation-nKXdF-ae.js → filepond-plugin-image-exif-orientation-DK15iBED.js} +1 -1
  137. package/dist/esm/{filepond-plugin-image-preview-Dzl44GI1.js → filepond-plugin-image-preview-BIW0XW_M.js} +1 -1
  138. package/dist/esm/{index-BmRQjBRH.js → index-CwwxD-7C.js} +7 -7
  139. package/dist/esm/{intlTelInput-dGrU4Iu9.js → intlTelInput-DYJOvh3V.js} +1 -1
  140. package/dist/esm/loader.js +2 -2
  141. package/dist/esm/salla-accordion-body_2.entry.js +1 -1
  142. package/dist/esm/salla-accordion_6.entry.js +1 -1
  143. package/dist/esm/salla-add-product-button_5.entry.js +1 -1
  144. package/dist/esm/salla-advertisement.entry.js +1 -1
  145. package/dist/esm/salla-alert_2.entry.js +1 -1
  146. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  147. package/dist/esm/salla-applied-filters.entry.js +1 -1
  148. package/dist/esm/salla-apps-icons.entry.js +1 -1
  149. package/dist/esm/salla-attachment-view_9.entry.js +73 -13
  150. package/dist/esm/salla-badge.entry.js +1 -1
  151. package/dist/esm/salla-basket-gap.entry.js +1 -1
  152. package/dist/esm/salla-bullet-delivery_3.entry.js +1 -1
  153. package/dist/esm/salla-cart-coupons.entry.js +1 -1
  154. package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
  155. package/dist/esm/salla-cart-summary-card.entry.js +1 -1
  156. package/dist/esm/salla-cashback-banner.entry.js +1 -1
  157. package/dist/esm/salla-comment-factors.entry.js +1 -1
  158. package/dist/esm/salla-comment-form_9.entry.js +4 -2
  159. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  160. package/dist/esm/salla-contacts.entry.js +1 -1
  161. package/dist/esm/salla-cookies-bar.entry.js +1 -1
  162. package/dist/esm/salla-count-down.entry.js +1 -1
  163. package/dist/esm/salla-custom-fields.entry.js +1 -1
  164. package/dist/esm/salla-delivery-promise.entry.js +1 -1
  165. package/dist/esm/salla-edit-order-button.entry.js +1 -1
  166. package/dist/esm/salla-filters-widget.entry.js +1 -1
  167. package/dist/esm/salla-filters.entry.js +1 -1
  168. package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
  169. package/dist/esm/salla-gift-card-redeem_2.entry.js +1 -1
  170. package/dist/esm/salla-gifting.entry.js +1 -1
  171. package/dist/esm/salla-hook.entry.js +1 -1
  172. package/dist/esm/salla-infinite-scroll.entry.js +1 -1
  173. package/dist/esm/salla-installment.entry.js +1 -1
  174. package/dist/esm/salla-list-tile.entry.js +1 -1
  175. package/dist/esm/salla-localization-modal.entry.js +1 -1
  176. package/dist/esm/salla-login-modal.entry.js +14 -3
  177. package/dist/esm/salla-loyalty-banner_10.entry.js +1 -1
  178. package/dist/esm/salla-loyalty-exchange-product-card.entry.js +1 -1
  179. package/dist/esm/salla-loyalty-points-banner.entry.js +1 -1
  180. package/dist/esm/salla-loyalty-points-history.entry.js +1 -1
  181. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  182. package/dist/esm/salla-loyalty.entry.js +1 -1
  183. package/dist/esm/salla-maintenance-alert.entry.js +1 -1
  184. package/dist/esm/salla-map_3.entry.js +1 -1
  185. package/dist/esm/salla-menu.entry.js +1 -1
  186. package/dist/esm/salla-metadata.entry.js +1 -1
  187. package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
  188. package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
  189. package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
  190. package/dist/esm/salla-next-order-coupon.entry.js +1 -1
  191. package/dist/esm/salla-notification-item_2.entry.js +1 -1
  192. package/dist/esm/salla-offer-modal.entry.js +1 -1
  193. package/dist/esm/salla-offer.entry.js +1 -1
  194. package/dist/esm/salla-order-branch.entry.js +1 -1
  195. package/dist/esm/salla-order-cancel.entry.js +1 -1
  196. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  197. package/dist/esm/salla-order-details-options.entry.js +1 -1
  198. package/dist/esm/salla-order-details.entry.js +1 -1
  199. package/dist/esm/salla-order-edit-item.entry.js +1 -1
  200. package/dist/esm/salla-order-edit-product-card.entry.js +1 -1
  201. package/dist/esm/salla-order-edit.entry.js +1 -1
  202. package/dist/esm/salla-order-options-modal.entry.js +1 -1
  203. package/dist/esm/salla-order-shipments.entry.js +1 -1
  204. package/dist/esm/salla-order-summary.entry.js +1 -1
  205. package/dist/esm/salla-order-totals-card.entry.js +11 -4
  206. package/dist/esm/salla-orders.entry.js +32 -2
  207. package/dist/esm/salla-payments.entry.js +1 -1
  208. package/dist/esm/salla-placeholder.entry.js +1 -1
  209. package/dist/esm/salla-price-range.entry.js +1 -1
  210. package/dist/esm/salla-product-card-embed.entry.js +1 -1
  211. package/dist/esm/salla-product-card.entry.js +3 -1
  212. package/dist/esm/salla-product-size-guide.entry.js +1 -1
  213. package/dist/esm/salla-products-list.entry.js +1 -1
  214. package/dist/esm/salla-products-slider.entry.js +1 -1
  215. package/dist/esm/salla-quick-order.entry.js +1 -1
  216. package/dist/esm/salla-rating-modal-v2.entry.js +1 -1
  217. package/dist/esm/salla-rating-modal.entry.js +1 -1
  218. package/dist/esm/salla-review-factors-tags.entry.js +1 -1
  219. package/dist/esm/salla-review-order-item.entry.js +1 -1
  220. package/dist/esm/salla-scopes.entry.js +3 -3
  221. package/dist/esm/salla-search-product-card.entry.js +1 -1
  222. package/dist/esm/salla-search.entry.js +1 -1
  223. package/dist/esm/salla-skeleton.entry.js +1 -1
  224. package/dist/esm/salla-social-share.entry.js +1 -1
  225. package/dist/esm/salla-social.entry.js +1 -1
  226. package/dist/esm/salla-tab-content_3.entry.js +1 -1
  227. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  228. package/dist/esm/salla-trust-badges.entry.js +2 -2
  229. package/dist/esm/salla-user-menu.entry.js +33 -2
  230. package/dist/esm/salla-user-profile.entry.js +1 -1
  231. package/dist/esm/salla-user-settings.entry.js +1 -1
  232. package/dist/esm/salla-verify.entry.js +1 -1
  233. package/dist/esm/salla-wallet.entry.js +1 -1
  234. package/dist/esm/salla-wishlist-actions.entry.js +1 -1
  235. package/dist/esm/salla-wishlist-summary.entry.js +1 -1
  236. package/dist/esm/twilight.js +2 -2
  237. package/dist/esm/{vanilla-picker-DRghK0RD.js → vanilla-picker-BzVn0xEV.js} +1 -1
  238. package/dist/twilight/{p-aeafb519.entry.js → p-0253bf71.entry.js} +1 -1
  239. package/dist/twilight/{p-e2d1d888.entry.js → p-065f2937.entry.js} +1 -1
  240. package/dist/twilight/{p-e8d94147.entry.js → p-067ad44c.entry.js} +1 -1
  241. package/dist/twilight/{p-db9994c2.entry.js → p-07817ae8.entry.js} +1 -1
  242. package/dist/twilight/{p-1f2844db.entry.js → p-0889368b.entry.js} +1 -1
  243. package/dist/twilight/{p-41248f5f.entry.js → p-0b0c9ecb.entry.js} +1 -1
  244. package/dist/twilight/{p-4235b3c2.entry.js → p-0ba03206.entry.js} +1 -1
  245. package/dist/twilight/{p-dd4bcce0.entry.js → p-0bff8609.entry.js} +1 -1
  246. package/dist/twilight/{p-cca10a34.entry.js → p-10418cc0.entry.js} +1 -1
  247. package/dist/twilight/{p-f70fa2e9.entry.js → p-114e4228.entry.js} +1 -1
  248. package/dist/twilight/{p-3bf933f6.entry.js → p-14b1b664.entry.js} +1 -1
  249. package/dist/twilight/{p-d3be7885.entry.js → p-18e75544.entry.js} +1 -1
  250. package/dist/twilight/{p-68919916.entry.js → p-1b25ea2a.entry.js} +1 -1
  251. package/dist/twilight/{p-d307d40a.entry.js → p-1c191c15.entry.js} +1 -1
  252. package/dist/twilight/{p-12338d19.entry.js → p-1f561241.entry.js} +1 -1
  253. package/dist/twilight/{p-1908ab44.entry.js → p-1fd1c0a3.entry.js} +1 -1
  254. package/dist/twilight/{p-730101ff.entry.js → p-20f98a45.entry.js} +1 -1
  255. package/dist/twilight/{p-3d1842e4.entry.js → p-2213f6eb.entry.js} +1 -1
  256. package/dist/twilight/{p-7e724019.entry.js → p-25fb1508.entry.js} +1 -1
  257. package/dist/twilight/{p-f0180034.entry.js → p-261aff22.entry.js} +1 -1
  258. package/dist/twilight/p-27df0290.entry.js +4 -0
  259. package/dist/twilight/{p-d034a3ba.entry.js → p-2b5242cb.entry.js} +1 -1
  260. package/dist/twilight/{p-00e1f5fd.entry.js → p-2db00d46.entry.js} +1 -1
  261. package/dist/twilight/{p-1c8dde1a.entry.js → p-2f04343f.entry.js} +1 -1
  262. package/dist/twilight/{p-4b111d7a.entry.js → p-3243ab6e.entry.js} +1 -1
  263. package/dist/twilight/{p-8c10cb85.entry.js → p-3de0b3ae.entry.js} +1 -1
  264. package/dist/twilight/p-46c8b068.entry.js +4 -0
  265. package/dist/twilight/{p-7aa15258.entry.js → p-49bba37d.entry.js} +1 -1
  266. package/dist/twilight/{p-8e2488fe.entry.js → p-4ca3b245.entry.js} +1 -1
  267. package/dist/twilight/{p-ece1fecd.entry.js → p-4ebee06a.entry.js} +1 -1
  268. package/dist/twilight/{p-8b21158b.entry.js → p-509b04c7.entry.js} +1 -1
  269. package/dist/twilight/{p-4aa07eca.entry.js → p-55399fed.entry.js} +1 -1
  270. package/dist/twilight/{p-3745be6d.entry.js → p-56c77026.entry.js} +1 -1
  271. package/dist/twilight/{p-87cedb04.entry.js → p-62373e96.entry.js} +1 -1
  272. package/dist/twilight/{p-8248cecd.entry.js → p-62c985bc.entry.js} +1 -1
  273. package/dist/twilight/{p-15ab81d6.entry.js → p-62dc337d.entry.js} +1 -1
  274. package/dist/twilight/{p-fde4cf31.entry.js → p-651db82c.entry.js} +1 -1
  275. package/dist/twilight/{p-3f373f1e.entry.js → p-659e00b7.entry.js} +1 -1
  276. package/dist/twilight/{p-99463d58.entry.js → p-6b2f6957.entry.js} +1 -1
  277. package/dist/twilight/{p-182d7bab.entry.js → p-6d47b269.entry.js} +1 -1
  278. package/dist/twilight/p-6d61d93c.entry.js +4 -0
  279. package/dist/twilight/{p-7dfe99e6.entry.js → p-6e7433f2.entry.js} +1 -1
  280. package/dist/twilight/{p-e9319448.entry.js → p-6fa1498b.entry.js} +1 -1
  281. package/dist/twilight/{p-71cbf7a4.entry.js → p-7148dbad.entry.js} +1 -1
  282. package/dist/twilight/{p-ac7d45b6.entry.js → p-76ca3445.entry.js} +1 -1
  283. package/dist/twilight/p-79ce9e95.entry.js +4 -0
  284. package/dist/twilight/{p-ec1589cf.entry.js → p-7f653481.entry.js} +1 -1
  285. package/dist/twilight/{p-7c7648d7.entry.js → p-83e1c586.entry.js} +1 -1
  286. package/dist/twilight/{p-3f66f717.entry.js → p-84912a5a.entry.js} +1 -1
  287. package/dist/twilight/p-89bba634.entry.js +4 -0
  288. package/dist/twilight/{p-39a16468.entry.js → p-89fddf1e.entry.js} +1 -1
  289. package/dist/twilight/{p-d542e647.entry.js → p-8aa29666.entry.js} +1 -1
  290. package/dist/twilight/{p-ab1d320f.entry.js → p-8d99e9d1.entry.js} +1 -1
  291. package/dist/twilight/{p-5f35b46a.entry.js → p-8e91da09.entry.js} +1 -1
  292. package/dist/twilight/{p-c5d4f71c.entry.js → p-925ba8ce.entry.js} +1 -1
  293. package/dist/twilight/{p-51694dd2.entry.js → p-93d284c4.entry.js} +1 -1
  294. package/dist/twilight/{p-bfdde3db.entry.js → p-96154a67.entry.js} +1 -1
  295. package/dist/twilight/{p-C1XjCBHg.js → p-B8yyit_i.js} +1 -1
  296. package/dist/twilight/{p-CWismw4I.js → p-Bb9AkvT4.js} +1 -1
  297. package/dist/twilight/{p-C48Rktr4.js → p-CYeysHdt.js} +1 -1
  298. package/dist/twilight/{p-B4fbRnFh.js → p-CaabLwI1.js} +1 -1
  299. package/dist/twilight/{p-DnZfyhH5.js → p-CntnRJCa.js} +1 -1
  300. package/dist/twilight/{p-BmRQjBRH.js → p-CwwxD-7C.js} +2 -2
  301. package/dist/twilight/{p-DYEGhE1O.js → p-DFj0n9Nh.js} +1 -1
  302. package/dist/twilight/{p-OCGvfvVA.js → p-DHXSZjVo.js} +1 -1
  303. package/dist/twilight/{p-imI5he7m.js → p-DzBc32wK.js} +1 -1
  304. package/dist/twilight/{p-BIToxPOg.js → p-FcjN5vEx.js} +1 -1
  305. package/dist/twilight/{p-5617656f.entry.js → p-a6594c68.entry.js} +1 -1
  306. package/dist/twilight/{p-c22ea75b.entry.js → p-a743a10a.entry.js} +1 -1
  307. package/dist/twilight/{p-f348601d.entry.js → p-aaac2388.entry.js} +1 -1
  308. package/dist/twilight/p-ac8a7743.entry.js +4 -0
  309. package/dist/twilight/{p-33e769b3.entry.js → p-afd47a18.entry.js} +1 -1
  310. package/dist/twilight/{p-de3c5f91.entry.js → p-b2ff66ed.entry.js} +1 -1
  311. package/dist/twilight/{p-cc46f297.entry.js → p-b7c815f7.entry.js} +1 -1
  312. package/dist/twilight/{p-91326a74.entry.js → p-b7dfb1f1.entry.js} +1 -1
  313. package/dist/twilight/{p-b5829615.entry.js → p-bc5b70e9.entry.js} +1 -1
  314. package/dist/twilight/{p-fa600113.entry.js → p-bcbb4a03.entry.js} +1 -1
  315. package/dist/twilight/{p-96f9eb1f.entry.js → p-c282869e.entry.js} +1 -1
  316. package/dist/twilight/{p-3a996401.entry.js → p-c4f92bae.entry.js} +1 -1
  317. package/dist/twilight/{p-58dcc966.entry.js → p-c7a491ef.entry.js} +1 -1
  318. package/dist/twilight/{p-b5499627.entry.js → p-c84e619a.entry.js} +1 -1
  319. package/dist/twilight/{p-c3d33aee.entry.js → p-c892e962.entry.js} +1 -1
  320. package/dist/twilight/{p-2cf7eb3b.entry.js → p-c98d1097.entry.js} +1 -1
  321. package/dist/twilight/{p-737b93c2.entry.js → p-cce07c4c.entry.js} +1 -1
  322. package/dist/twilight/{p-60e1fb1a.entry.js → p-d01c4ba8.entry.js} +1 -1
  323. package/dist/twilight/{p-6b0d6b9b.entry.js → p-d6886b07.entry.js} +1 -1
  324. package/dist/twilight/{p-6854e982.entry.js → p-d8cf239a.entry.js} +1 -1
  325. package/dist/twilight/{p-b6c5435e.entry.js → p-db1e0bc6.entry.js} +1 -1
  326. package/dist/twilight/{p-cf1cc0d1.entry.js → p-dc090987.entry.js} +1 -1
  327. package/dist/twilight/{p-baaa3e72.entry.js → p-dda47e56.entry.js} +1 -1
  328. package/dist/twilight/{p-feb068a2.entry.js → p-e1fb95cb.entry.js} +1 -1
  329. package/dist/twilight/{p-2de666d8.entry.js → p-e248f0d0.entry.js} +1 -1
  330. package/dist/twilight/{p-3fdaf198.entry.js → p-e4ed760b.entry.js} +1 -1
  331. package/dist/twilight/{p-2de4c351.entry.js → p-ee2a5db7.entry.js} +1 -1
  332. package/dist/twilight/{p-a80acba3.entry.js → p-f1d5ebf4.entry.js} +1 -1
  333. package/dist/twilight/{p-9e196eb0.entry.js → p-f310c72e.entry.js} +1 -1
  334. package/dist/twilight/p-f345a77d.entry.js +4 -0
  335. package/dist/twilight/{p-1a8c7481.entry.js → p-f38d6c1b.entry.js} +1 -1
  336. package/dist/twilight/{p-55b5158c.entry.js → p-f4d52f9b.entry.js} +1 -1
  337. package/dist/twilight/{p-f76349b3.entry.js → p-f5026adf.entry.js} +1 -1
  338. package/dist/twilight/{p-61956814.entry.js → p-f51e9549.entry.js} +1 -1
  339. package/dist/twilight/{p-e6bc3cf4.entry.js → p-f5693509.entry.js} +1 -1
  340. package/dist/twilight/p-f580d024.entry.js +4 -0
  341. package/dist/twilight/{p-f5afeed8.entry.js → p-f8b428cb.entry.js} +1 -1
  342. package/dist/twilight/{p-9108e712.entry.js → p-fe7751a8.entry.js} +1 -1
  343. package/dist/twilight/twilight.esm.js +1 -1
  344. package/dist/types/Helpers/money-text.d.ts +13 -0
  345. package/dist/types/components/salla-file-upload/salla-file-upload.d.ts +10 -0
  346. package/dist/types/components/salla-login-modal/salla-login-modal.d.ts +3 -0
  347. package/dist/types/components/salla-order-totals-card/interfaces.d.ts +3 -3
  348. package/dist/types/components/salla-order-totals-card/salla-order-totals-card.d.ts +2 -0
  349. package/dist/types/components/salla-scopes/interfaces.d.ts +1 -0
  350. package/dist/types/components/salla-user-menu/salla-user-menu.d.ts +13 -0
  351. package/package.json +19 -19
  352. package/dist/twilight/p-1557d0ca.entry.js +0 -4
  353. package/dist/twilight/p-19592be3.entry.js +0 -4
  354. package/dist/twilight/p-1c8bf883.entry.js +0 -4
  355. package/dist/twilight/p-74ccf675.entry.js +0 -4
  356. package/dist/twilight/p-844ebeb6.entry.js +0 -4
  357. package/dist/twilight/p-cdbb6758.entry.js +0 -4
  358. package/dist/twilight/p-d37e6c2f.entry.js +0 -4
  359. package/dist/twilight/p-fe3645b0.entry.js +0 -4
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,h as i,H as e,a as o}from"./p-BmRQjBRH.js";var r,n;!function(t){t.PERCENTAGE="percentage",t.FIXED="fixed",t.FREE_PRODUCT="free_product",t.FREE_SHIPPING="free_shipping"}(r||(r={})),function(t){t.PRODUCT_COUNT="products_count",t.PRODUCT_PURCHASE="order_amount"}(n||(n={}));const s=Object.freeze([]);let a,l=null,c=null,d=!1,f=null,h=null,u=0;function m(t){return"CartNotCreated"===t?.name}function g(){try{const t=salla.api?.cart?.getStoredCartId?salla.api.cart.getStoredCartId():salla.storage?.get?.("cart.id");return null==t||""===t?null:String(t)}catch(t){return null}}function p(){const t=g();void 0!==a&&a!==t&&(u++,l=null,c=null,d=!1,f=null),a=t}function b(t){return null==t?0:"number"==typeof t?isFinite(t)?t:0:"string"==typeof t&&parseFloat(t)||0}function w(t){if(null==t||""===t)return null;const i=b(t);return isFinite(i)?i:null}function y(t,i){if(null!==i)return i.length;const e=w(t?.data?.cart?.count??t?.data?.count??t?.cart?.count??t?.count);return null!==e&&e>=0?e:null}function x(t){for(const i of[t?.original_price,t?.product_price,t?.price]){const t=w(i&&"object"==typeof i?i.amount:i);if(null!==t&&t>0)return t}return null}function v(t,i){const e=t?.free_gift_quantity;return null!=e&&""!==e?b(e):i>0?i:0}function k(t){const i=[];for(const e of t){if(null==e?.id)continue;if(!e.added_by_offer)continue;const t=b(e.quantity),o=v(e,t);o<=0||i.push({id:String(e.id),offerId:w(e.offer_id),quantity:o,freeQuantity:o,lineQuantity:t,name:String(e.product_name??e.name??""),imageUrl:String(e.product_image?.url??e.product_image??e.image?.url??""),imageAlt:String(e.product_image?.alt??e.image?.alt??e.product_name??""),url:String(e.url??""),originalPrice:x(e)})}return i}function _(){if(f)return f;const t=u,i=Promise.resolve().then((()=>salla.api?.cart?.details?.())).then((t=>{const i=function(t){const i=t?.data?.cart?.items??t?.data?.items??t?.cart?.items??t?.items;return Array.isArray(i)?i:null}(t);return{gifts:k(i??[]),count:y(t,i),ok:!0}})).catch((t=>({gifts:l??[],count:m(t)?0:c,ok:!1}))).then((({gifts:i,count:e,ok:o})=>{t===u&&(l=i,c=e,d=o)})).finally((()=>{f===i&&(f=null)}));return f=i,i}const C=-1;var M,T;function z(t){const i="number"==typeof t?t:parseFloat(t);return Number.isFinite(i)?i:null}function S(t){return"boolean"==typeof t?t:1===t||0===t?1===t:"true"===t||"1"===t||"false"!==t&&"0"!==t&&void 0}function L(t){return z(t)??0}function I(t,i,e){return Math.max(i,Math.min(t,e))}function V(t){const i="number"==typeof t?t:parseFloat(t);if(!Number.isFinite(i))return null;const e=Math.trunc(i);return e>=0&&e<=4?e:null}!function(t){t.LOCKED="locked",t.CURRENT="current",t.COMPLETED="completed"}(M||(M={})),function(t){t.CURRENCY="currency",t.COUNT="count"}(T||(T={}));const R=[1e3,2e3,4e3],F='[data-testid^="store-cart-item-"], form[id^="item-"]';let $=0;const j={badges_summary:":completed of :total offers unlocked",congrats:"Congratulations! You’ve unlocked all rewards in this promotion",details_title:"Offer details",free_gift:"Free Gift",free_products_title:"Free products selected from the offer",guidance_conditions_unmet:"Your cart doesn’t meet the conditions for the next reward yet",guidance_next:"Add :remaining and get :reward",guidance_next_generic:"Add :remaining to unlock the next reward",manage_offer:"Manage offer",tier_requirement:"Spend :threshold and get :reward",tier_requirement_count:"Buy :threshold and get :reward",tier_requirement_count_generic:"Buy :threshold to unlock this offer",tier_requirement_generic:"Spend :threshold to unlock this offer",tier_title:"Offer (:number)"},H="pages.checkout.free_charge";function P(t){const i=document.createElement("div");return i.textContent=t??"",i.innerHTML}const O=(t={})=>i("svg",{class:t.class,viewBox:"0 0 10 10",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},i("path",{d:"M5.00016 9.16634C2.69898 9.16634 0.833496 7.30084 0.833496 4.99967C0.833496 2.69849 2.69898 0.833008 5.00016 0.833008C7.30133 0.833008 9.16683 2.69849 9.16683 4.99967C9.16683 7.30084 7.30133 9.16634 5.00016 9.16634ZM4.58458 6.66634L7.53087 3.72006L6.94162 3.13081L4.58458 5.48784L3.40608 4.3093L2.81683 4.89859L4.58458 6.66634Z",fill:"currentColor"})),q=(t={})=>i("svg",{class:t.class,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},i("path",{d:"M12.6667 6.66683H13.3333C13.7015 6.66683 14 6.9653 14 7.3335V14.0002C14 14.3684 13.7015 14.6668 13.3333 14.6668H2.66667C2.29848 14.6668 2 14.3684 2 14.0002V7.3335C2 6.9653 2.29848 6.66683 2.66667 6.66683H3.33333V6.00016C3.33333 3.42284 5.42267 1.3335 8 1.3335C10.5773 1.3335 12.6667 3.42284 12.6667 6.00016V6.66683ZM11.3333 6.66683V6.00016C11.3333 4.15922 9.84093 2.66683 8 2.66683C6.15905 2.66683 4.66667 4.15922 4.66667 6.00016V6.66683H11.3333ZM7.33333 9.3335V12.0002H8.66667V9.3335H7.33333Z",fill:"currentColor"})),B=(t={})=>i("svg",{class:t.class,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},i("path",{d:"M7.00033 12.8337C3.77866 12.8337 1.16699 10.222 1.16699 7.00033C1.16699 3.77866 3.77866 1.16699 7.00033 1.16699C10.222 1.16699 12.8337 3.77866 12.8337 7.00033C12.8337 10.222 10.222 12.8337 7.00033 12.8337ZM6.41699 6.41699V9.91699H7.58366V6.41699H6.41699ZM6.41699 4.08366V5.25033H7.58366V4.08366H6.41699Z",fill:"currentColor"})),N=class{constructor(i){t(this,i),this.offer=null,this.isLoading=!1,this.canRender=!0,this.gifts=[],this.cartItemCount=null,this.isTooltipHovered=!1,this.isTooltipPinned=!1,this.isGiftsOpen=!0,this.instanceId=++$,this.refreshGeneration=0,this.giftsGeneration=0,this.cartRefreshTimer=null,this.cartRefreshPending=!1,this.wantsCartUpdates=!1,this.isListeningToCartUpdates=!1,this.cartLookupRetryTimer=null,this.cartLookupRetries=0,this.cartLookupRetryPending=!1,this.deferredByEmptyCart=!1,this.isDisconnected=!1,this.skeletonWatchdog=null,this.skeletonDeadline=0,this.hasRelocated=!1,this.hasLoaded=!1,this.relocationObserver=null,this.relocationWatchTimer=null,this.relocationWatchExpired=!1,this.relocationLogged=!1,this.cartUpdatedHandler=t=>{this.readCartCountFromEvent(t),this.clearCartLookupRetry(),this.scheduleCartRefresh()}}componentWillLoad(){this.ensureSkeletonIsWatched();try{this.isEnabled()&&this.startLoading(),this.load().catch((t=>{this.stopLoading(),this.safeLog("load() failed",t)}))}catch(t){this.stopLoading(),this.safeLog("componentWillLoad threw synchronously",t)}}safeLog(t,i){try{salla.logger.warn("salla-conditional-offer::",t,i)}catch(t){}}connectedCallback(){this.isDisconnected=!1,this.ensureSkeletonIsWatched(),this.wantsCartUpdates&&!this.isListeningToCartUpdates&&this.subscribeToCartUpdates()&&(this.cartRefreshPending=!0),this.cartRefreshPending&&this.scheduleCartRefresh(),this.cartLookupRetryPending&&this.scheduleCartLookupRetry()}disconnectedCallback(){this.isDisconnected=!0,null!==this.cartRefreshTimer&&(clearTimeout(this.cartRefreshTimer),this.cartRefreshTimer=null),null!==this.cartLookupRetryTimer&&(clearTimeout(this.cartLookupRetryTimer),this.cartLookupRetryTimer=null),Promise.resolve().then((()=>{this.isDisconnected&&this.unsubscribeFromCartUpdates()})),null!==this.skeletonWatchdog&&(clearTimeout(this.skeletonWatchdog),this.skeletonWatchdog=null),this.stopWatchingForItemsColumn()}componentDidLoad(){this.hasLoaded=!0,this.relocateIntoItemsColumn()}isShowingSomething(){return this.canRender&&this.hasCartItems()}componentDidRender(){this.hasLoaded&&this.relocateIntoItemsColumn(),this.positionTooltip(),this.ensureSkeletonIsWatched()}relocateIntoItemsColumn(){if(!this.hasRelocated&&this.isShowingSomething())try{const t=this.hostEl;if(!t?.parentElement)return;const i=this.findItemsColumn(t);if(!i)return void this.watchForItemsColumn();if(this.hasRelocated=!0,this.stopWatchingForItemsColumn(),i===t.parentElement&&i.firstElementChild===t)return;i.insertBefore(t,i.firstChild)}catch(t){this.hasRelocated=!0,this.stopWatchingForItemsColumn(),this.safeLog("relocating the banner into the cart items column failed",t)}}findItemsColumn(t){let i=t;for(let e=0;i&&e<=3;e++){for(const e of this.getFollowingSiblings(i)){if(i===t&&this.matches(e,F))return t.parentElement;const o=this.findColumnWithin(e,t);if(o)return o}if(i=i.parentElement,!i||i===document.body||i===document.documentElement)break}return null}getFollowingSiblings(t){const i=[];for(let e=t.nextElementSibling;e;e=e.nextElementSibling)i.push(e);return i}findColumnWithin(t,i){const e=t.querySelector(F),o=(e?this.climbToChildOf(e,t):null)??t.querySelector(".main-content, [data-cart-items]");return!o||o===i||o.contains(i)?null:o}climbToChildOf(t,i){let e=t;for(;e&&e.parentElement&&e.parentElement!==i;)e=e.parentElement;return e?.parentElement===i?e:null}matches(t,i){return"function"==typeof t.matches&&t.matches(i)}watchForItemsColumn(){this.hasRelocated||this.relocationWatchExpired||this.relocationObserver||("undefined"!=typeof MutationObserver?(this.relocationObserver=new MutationObserver((()=>this.relocateIntoItemsColumn())),this.relocationObserver.observe(document.documentElement,{childList:!0,subtree:!0}),this.relocationWatchTimer=setTimeout((()=>{this.relocationWatchTimer=null,this.relocationWatchExpired=!0,this.stopWatchingForItemsColumn(),this.logNoItemsColumn()}),5e3)):this.logNoItemsColumn())}stopWatchingForItemsColumn(){if(this.relocationObserver){try{this.relocationObserver.disconnect()}catch(t){}this.relocationObserver=null}null!==this.relocationWatchTimer&&(clearTimeout(this.relocationWatchTimer),this.relocationWatchTimer=null)}logNoItemsColumn(){this.relocationLogged||(this.relocationLogged=!0,this.safeLog("no cart items column found — leaving the banner at full page width"))}ensureSkeletonIsWatched(){if(!this.isLoading)return;if(null!==this.skeletonWatchdog)return;const t=Date.now();0===this.skeletonDeadline&&(this.skeletonDeadline=t+8e3);const i=Math.max(0,this.skeletonDeadline-t);this.skeletonWatchdog=setTimeout((()=>{this.skeletonWatchdog=null,this.isLoading&&(Date.now()<this.skeletonDeadline?this.ensureSkeletonIsWatched():(this.isLoading=!1,this.skeletonDeadline=0,this.safeLog("still loading after 8000ms — dropping the skeleton")))}),i)}clearSkeletonWatchdog(){this.skeletonDeadline=0,null!==this.skeletonWatchdog&&(clearTimeout(this.skeletonWatchdog),this.skeletonWatchdog=null)}startLoading(){this.isLoading=!0,this.ensureSkeletonIsWatched()}stopLoading(){this.isLoading=!1,this.clearSkeletonWatchdog()}async load(){this.wantsCartUpdates=!0,this.subscribeToCartUpdates()||this.subscribeWhenSdkIsReady(),this.loadCart(),await this.waitForSdk(),await this.refresh()}waitForSdk(){let t,i;try{t=Promise.resolve(salla.onReady?.())}catch(t){return this.safeLog("salla.onReady() threw",t),Promise.resolve()}const e=new Promise((t=>{i=setTimeout(t,3e3)}));return Promise.race([t.catch((t=>this.safeLog("salla.onReady() rejected",t))),e]).then((()=>{clearTimeout(i)}))}subscribeToCartUpdates(){if(this.isListeningToCartUpdates)return!0;try{salla.event.on("cart::updated",this.cartUpdatedHandler),this.isListeningToCartUpdates=!0}catch(t){this.safeLog("cart::updated subscription failed",t)}return this.isListeningToCartUpdates}unsubscribeFromCartUpdates(){if(this.isListeningToCartUpdates){this.isListeningToCartUpdates=!1;try{salla.event.off("cart::updated",this.cartUpdatedHandler)}catch(t){this.safeLog("cart::updated unsubscription failed",t)}}}subscribeWhenSdkIsReady(){let t;try{t=Promise.resolve(salla.onReady?.())}catch(t){return}const i=()=>{this.isDisconnected||this.subscribeToCartUpdates()};t.then(i,i)}scheduleCartRefresh(){this.cartRefreshPending=!0,null!==this.cartRefreshTimer&&clearTimeout(this.cartRefreshTimer),this.cartRefreshTimer=null,this.isDisconnected||(this.cartRefreshTimer=setTimeout((()=>{this.cartRefreshTimer=null,this.runCartRefresh()}),200))}runCartRefresh(){this.isDisconnected||(this.cartRefreshPending=!1,this.refresh(),function(){if(h)return h;u++,l=null,c=null,d=!1,a=g();const t=()=>(h===i&&(h=null),_()),i=(f??Promise.resolve()).then(t,t).finally((()=>{h===i&&(h=null)}));return h=i,i}().then((()=>this.loadCart()),(()=>this.loadCart())))}readCartCountFromEvent(t){const i=this.toCartCount(t?.count)??this.readCartCountFromStorage();null!==i&&(this.cartItemCount=i)}readCartCountFromStorage(){try{return this.toCartCount(salla.storage?.get?.("cart.summary.count"))}catch(t){return null}}toCartCount(t){return"number"==typeof t&&Number.isFinite(t)&&t>=0?t:null}getFreeLabel(){const t=salla.lang.get(H);return t&&t!==H?t:"Free"}trans(t,i){const e=`blocks.cart_offer.${t}`,o=salla.lang.get(e,i);return o&&o!==e?o:Object.entries(i??{}).reduce(((t,[i,e])=>t.split(`:${i}`).join(e)),j[t])}isEnabled(){try{return!!salla.config.get("store.features")?.includes("conditional-offer")}catch(t){return!1}}async fetchOffer(){const{data:t}=await salla.api.cart.offers(),i=(t||[]).find((t=>"conditional"===t.type));return i?.details?.discounts?.length?i:null}async refresh(){const t=++this.refreshGeneration;if(!this.isEnabled())return this.stopLoading(),void(this.canRender=!1);if(0===this.cartItemCount)return this.stopLoading(),p(),void(d||(this.deferredByEmptyCart=!0,this.loadCart()));this.deferredByEmptyCart=!1,this.offer?this.stopLoading():this.startLoading();try{const i=await this.fetchOffer();if(this.isSuperseded(t))return;if(!i)return this.offer=null,void(this.canRender=!1);this.offer=i,this.canRender=!0,this.loadCart()}catch(i){if(this.isSuperseded(t))return;this.safeLog("offers() failed",i)}finally{t===this.refreshGeneration&&this.stopLoading()}}hasCartItems(){return"number"==typeof this.cartItemCount&&this.cartItemCount>=1}isSuperseded(t){return t!==this.refreshGeneration||this.isDisconnected}loadCart(){const t=++this.giftsGeneration;return Promise.all([(p(),d&&l?Promise.resolve(l):_().then((()=>l??s))),(p(),d&&l?Promise.resolve(c):_().then((()=>c)))]).then((([i,e])=>{t!==this.giftsGeneration||this.isDisconnected||this.cartRefreshPending||(null!==e&&(this.cartItemCount=e),null!==e?this.clearCartLookupRetry():null===this.cartItemCount&&this.scheduleCartLookupRetry(),this.deferredByEmptyCart&&this.hasCartItems()&&(this.deferredByEmptyCart=!1,this.refresh()),this.gifts=this.offer?this.selectOwnGifts(i):[])})).catch((t=>{this.safeLog("cart lookup failed",t)}))}scheduleCartLookupRetry(){this.cartLookupRetries>=R.length||(this.cartLookupRetryPending=!0,null!==this.cartLookupRetryTimer||this.isDisconnected||(this.cartLookupRetryTimer=setTimeout((()=>{this.cartLookupRetryTimer=null,this.cartLookupRetryPending=!1,this.canRender&&(this.cartLookupRetries++,this.loadCart())}),R[this.cartLookupRetries])))}clearCartLookupRetry(){this.cartLookupRetries=0,this.cartLookupRetryPending=!1,null!==this.cartLookupRetryTimer&&(clearTimeout(this.cartLookupRetryTimer),this.cartLookupRetryTimer=null)}selectOwnGifts(t){const i=Number(this.offer?.id);if(!Number.isFinite(i))return t;const e=t.filter((t=>null!==t.offerId&&Number(t.offerId)===i));return e.length?e:t.filter((t=>null===t.offerId))}getStages(){const t=(this.offer?.details?.discounts??[]).filter((({min_spend:t})=>null!==z(t)));return i=({min_spend:t})=>t,e=({id:t})=>t,(t??[]).map(((t,o)=>({item:t,index:o,threshold:L(i(t)),identity:e?z(e(t)):null}))).sort(((t,i)=>t.threshold!==i.threshold?t.threshold-i.threshold:null!==t.identity&&null!==i.identity&&t.identity!==i.identity?t.identity-i.identity:t.index-i.index)).map((({item:t})=>t));var i,e}getProgress(t){return function(t,i,e=0,o=[],r=[]){const n=(i??[]).map(((t,i)=>({index:i,threshold:z(t),applied:S(o?.[i]),tierValue:z(r?.[i])}))).filter((t=>null!==t.threshold)).sort(((t,i)=>t.threshold-i.threshold||t.index-i.index)),s=n.map((t=>t.threshold)),a=n.map((t=>t.applied)),l=a.some((t=>void 0!==t)),c=L(e);if(!s.length)return{thresholds:s,met:[],applied:a,appliedIndex:C,hasEngineVerdict:l,metCount:0,nextUnmetIndex:C,allMet:!1,lastReachedIndex:C,currentIndex:C,isComplete:!1,value:Math.max(0,L(t)),values:[],startValue:c,fills:[],overallPercentage:0};const d=s[s.length-1],f=I(L(t),0,Math.max(0,d)),h=n.map((({tierValue:t})=>null===t?f:I(t,0,Math.max(0,d))));let u=C;for(let t=0;t<s.length;t++)h[t]>=s[t]&&(u=t);const m=u===s.length-1,g=m?C:u+1,p=s.map(((t,i)=>function(t,i,e){return e<=i?t>=e?100:0:I((t-i)/(e-i)*100,0,100)}(h[i],0===i?c:s[i-1],t))),b=m?100:I((u+1+(p[g]??0)/100)/s.length*100,0,100);let w=C;for(let t=0;t<a.length;t++)!0===a[t]&&(w=t);const y=s.map(l?(t,i)=>i<=w:(t,i)=>i<=u),x=y.filter(Boolean).length,v=y.findIndex((t=>!t));return{thresholds:s,met:y,applied:a,appliedIndex:w,hasEngineVerdict:l,metCount:x,nextUnmetIndex:v,allMet:v===C,lastReachedIndex:u,currentIndex:g,isComplete:m,value:f,values:h,startValue:c,fills:p,overallPercentage:b}}(this.offer?.details?.current_value,t.map((({min_spend:t})=>t)),this.offer?.details?.start_value,t.map((({is_applied:t})=>t)),t.map((({current_value:t})=>t)))}tierKey(t,i){const e=Number(t?.id);return Number.isFinite(e)?`tier-${e}`:`pos-${i}`}stageMeasure(){return this.offer?.details?.based_on===n.PRODUCT_COUNT?T.COUNT:T.CURRENCY}formatRequirement(t){const i=this.offer?.details?.based_on;if(i===n.PRODUCT_COUNT)try{return salla.lang.choice("blocks.header.products_count",t)}catch(i){return this.safeLog("invalid products_count interval",i),`${t}`}return i===n.PRODUCT_PURCHASE?salla.money(t):(this.safeLog(`unexpected offer detail's based_on value: ${i}`),`${t}`)}getRewardText(t){return(t?.reward_label??"").trim()}getGuidanceMessage(t,i){if(i.nextUnmetIndex===C)return"";const e=function(t,i,e=T.CURRENCY){const o=i.thresholds[t];if(void 0===o)return 0;const r=Math.max(0,o-(i.values?.[t]??i.value));if(0===r)return 0;const n=e===T.COUNT?0:function(){try{const t="undefined"!=typeof salla?salla:void 0,i=V(t?.config?.currency?.()?.decimals);if(null!==i)return i;const e=V(t?.config?.get?.("store.currency.decimals"));if(null!==e)return e}catch(t){}return 2}(),s=Math.pow(10,n),a=Math.ceil(r*s-1e-6)/s;return a>0?a:1/s}(i.nextUnmetIndex,i,this.stageMeasure());if(e<=0)return this.trans("guidance_conditions_unmet");const o=this.formatRequirement(e),r=this.getRewardText(t[i.nextUnmetIndex]);return r?this.trans("guidance_next",{remaining:o,reward:P(r)}):this.trans("guidance_next_generic",{remaining:o})}getTierSentence(t,i,e){const o=this.formatRequirement(e.thresholds[i]),r=this.getRewardText(t),n=this.stageMeasure()===T.COUNT;return r?this.trans(n?"tier_requirement_count":"tier_requirement",{threshold:o,reward:P(r)}):this.trans(n?"tier_requirement_count_generic":"tier_requirement_generic",{threshold:o})}getRewardIcon(t){switch(t?.type){case r.PERCENTAGE:return"sicon-percentage";case r.FREE_PRODUCT:return"sicon-gift";case r.FIXED:return this.usesSarSymbol()?"sicon-sar":"sicon-banknote";default:return"sicon-tag"}}usesSarSymbol(){try{const t=salla.config.currency?.()?.symbol;return["SAR","ر.س"].includes(t)&&!!salla.config.get("store.settings.use_sar_symbol")}catch(t){return!1}}get isTooltipOpen(){return this.isTooltipHovered||this.isTooltipPinned}toggleTooltip(){this.isTooltipPinned=!this.isTooltipPinned}closeTooltip(t=!1){this.isTooltipOpen&&(this.isTooltipPinned=!1,this.isTooltipHovered=!1,t&&this.infoTriggerEl?.focus?.())}positionTooltip(){const t=this.tooltipEl,i=this.infoTriggerEl;if(this.isTooltipOpen&&t&&i)try{this.setTooltipOffsets(t,0,0);const e=window.innerWidth||document.documentElement?.clientWidth||0,o=t.getBoundingClientRect(),r=i.getBoundingClientRect(),n=o?.width||0;if(n<=0||e<=0)return;const s=r.left+r.width/2-n/2,a=8,l=Math.min(Math.max(s,a),Math.max(a,e-a-n))-s,c=Math.max(0,n/2-16),d=Math.min(Math.max(-l,-c),c);this.setTooltipOffsets(t,l,d)}catch(t){this.safeLog("positioning the offer details popover failed",t)}}setTooltipOffsets(t,i,e){t.style?.setProperty?.("--s-conditional-offer-tooltip-shift",`${Math.round(i)}px`),t.style?.setProperty?.("--s-conditional-offer-tooltip-caret",`${Math.round(e)}px`)}handleWindowResize(){this.positionTooltip()}handleDocumentKeydown(t){"Escape"!==t.key&&"Esc"!==t.key||this.closeTooltip(!0)}handleDocumentClick(t){if(!this.isTooltipPinned||!this.infoAnchorEl)return;const i="function"==typeof t.composedPath?t.composedPath():[];(i.length?i.includes(this.infoAnchorEl):this.infoAnchorEl.contains(t.target))||this.closeTooltip()}elementId(t){return`s-conditional-offer-${t}-${this.instanceId}`}renderBadges(t,e){return i("div",{class:"s-conditional-offer-badges",role:"img","aria-label":this.trans("badges_summary",{completed:`${e.metCount}`,total:`${t.length}`})},t.map(((t,o)=>{const r=e.met[o],n=this.tierKey(t,o);return[o>0?i("span",{key:`${n}-link`,class:{"s-conditional-offer-badge-link":!0,"s-conditional-offer-badge-link-met":r,"s-conditional-offer-badge-link-unmet":!r},"aria-hidden":"true"}):null,i("span",{key:n,class:{"s-conditional-offer-badge":!0,"s-conditional-offer-badge-met":r,"s-conditional-offer-badge-unmet":!r},"data-tier-state":r?"met":"unmet","data-tier-id":t?.id??void 0},i(r?O:q,{class:"s-conditional-offer-badge-icon"}))]})))}renderTooltip(t,e){const o=function(t){const i=t?.details?.rules;if("string"==typeof i){const t=i.trim();return""===t?null:t}if(Array.isArray(i)){const t=i.filter((t=>"string"==typeof t)).map((t=>t.trim())).filter((t=>""!==t)).join(" ");return""===t?null:t}return null}(this.offer);return i("div",{class:"s-conditional-offer-tooltip",id:this.elementId("tooltip"),role:"tooltip",ref:t=>this.tooltipEl=t},i("div",{class:"s-conditional-offer-tooltip-title"},this.offer?.title),o?i("div",{class:"s-conditional-offer-tooltip-description"},o):null,i("ul",{class:"s-conditional-offer-tooltip-list"},t.map(((t,o)=>{const r=e.met[o];return i("li",{key:this.tierKey(t,o),class:"s-conditional-offer-tier","data-tier-state":r?"met":"unmet","data-tier-id":t?.id??void 0},i("span",{class:{"s-conditional-offer-tier-icon":!0,"s-conditional-offer-tier-icon-met":r,"s-conditional-offer-tier-icon-unmet":!r}},i("i",{class:this.getRewardIcon(t),"aria-hidden":"true"}),i("span",{class:{"s-conditional-offer-tier-status":!0,"s-conditional-offer-tier-status-met":r,"s-conditional-offer-tier-status-unmet":!r},"aria-hidden":"true"},r?i(O,{class:"s-conditional-offer-tier-status-check"}):i(q,{class:"s-conditional-offer-tier-status-lock"}))),i("div",{class:"s-conditional-offer-tier-body"},i("div",{class:"s-conditional-offer-tier-title"},this.trans("tier_title",{number:`${o+1}`})),i("div",{class:{"s-conditional-offer-tier-text":!0,"s-conditional-offer-tier-text-met":r},innerHTML:this.getTierSentence(t,o,e)})))}))))}renderGiftsToggle(t){return i("button",{type:"button",id:this.elementId(`toggle-${t}`),class:{"s-conditional-offer-toggle":!0,"s-conditional-offer-toggle-inline":"inline"===t,"s-conditional-offer-toggle-bar":"bar"===t},"aria-expanded":this.isGiftsOpen?"true":"false","aria-controls":this.elementId("gifts"),onClick:()=>this.isGiftsOpen=!this.isGiftsOpen},i("span",null,this.trans("manage_offer")),i("i",{class:{"sicon-keyboard_arrow_down":!0,"s-conditional-offer-toggle-icon":!0,"s-conditional-offer-toggle-icon-open":this.isGiftsOpen},"aria-hidden":"true"}))}renderGiftsCard(){return i("div",{class:"s-conditional-offer-panel",id:this.elementId("gifts")},i("div",{class:"s-conditional-offer-gifts-header"},i("span",{class:"s-conditional-offer-gifts-icon"},i("i",{class:"sicon-gift","aria-hidden":"true"})),i("span",{class:"s-conditional-offer-gifts-title"},this.trans("free_products_title"))),i("ul",{class:"s-conditional-offer-gifts-list"},this.gifts.map((t=>this.renderGiftRow(t)))))}renderGiftRow(t){return i("li",{class:"s-conditional-offer-gift","data-item-id":t.id},i("span",{class:"s-conditional-offer-gift-thumb"},t.imageUrl?i("img",{class:"s-conditional-offer-gift-image",src:t.imageUrl,alt:t.imageAlt||t.name,loading:"lazy",decoding:"async"}):i("i",{class:"sicon-gift","aria-hidden":"true"})),i("div",{class:"s-conditional-offer-gift-body"},i("span",{class:"s-conditional-offer-gift-name"},t.name||this.trans("free_gift")),i("span",{class:"s-conditional-offer-gift-prices"},i("span",{class:"s-conditional-offer-gift-free"},this.getFreeLabel()),null!==t.originalPrice?i("span",{class:"s-conditional-offer-gift-price",innerHTML:salla.money(t.originalPrice)}):null)))}getLoadingSkeletonView(){return i(e,{class:"s-conditional-offer-root"},i("div",{class:"s-conditional-offer-banner"},i("div",{class:"s-conditional-offer-lead"},i("salla-skeleton",{height:"24px",width:"80px"}),i("div",{class:"s-conditional-offer-skeleton-text"},i("salla-skeleton",{height:"12px",width:"35%"}),i("salla-skeleton",{height:"16px",width:"60%"})))))}render(){if(!this.canRender)return null;if(!this.hasCartItems())return null;if(this.isLoading)return this.getLoadingSkeletonView();if(!this.offer)return null;const t=this.getStages(),o=this.getProgress(t),r=this.getGuidanceMessage(t,o),n=this.trans("details_title"),s=this.gifts.length>0;return i(e,{class:"s-conditional-offer-root"},i("div",{class:"s-conditional-offer-banner"},i("div",{class:"s-conditional-offer-lead"},this.renderBadges(t,o),i("div",{class:"s-conditional-offer-text"},i("div",{class:"s-conditional-offer-heading",onMouseEnter:()=>this.isTooltipHovered=!0,onMouseLeave:()=>this.isTooltipHovered=!1},i("span",{class:"s-conditional-offer-name"},this.offer.title),i("span",{class:"s-conditional-offer-info",ref:t=>this.infoAnchorEl=t},i("button",{type:"button",class:"s-conditional-offer-info-trigger",ref:t=>this.infoTriggerEl=t,"aria-label":n,title:n,"aria-expanded":this.isTooltipOpen?"true":"false","aria-describedby":this.elementId("tooltip"),onClick:()=>this.toggleTooltip()},i(B,{class:"s-conditional-offer-info-icon"})),this.isTooltipOpen?this.renderTooltip(t,o):null)),o.allMet?i("div",{class:"s-conditional-offer-message",role:"status"},this.trans("congrats")):r?i("div",{class:"s-conditional-offer-message",innerHTML:r}):null)),s?this.renderGiftsToggle("inline"):null),s&&this.isGiftsOpen?this.renderGiftsCard():null,s?this.renderGiftsToggle("bar"):null)}get hostEl(){return o(this)}};N.style='/*!twlt*/:host{display:block}.s-conditional-offer-root{background-color:rgba(0, 137, 123, 0.06);background-color:color-mix(in srgb, var(--color-primary, #00897b) 7%, transparent)}.s-conditional-offer-badges::-webkit-scrollbar{height:3px}.s-conditional-offer-badges::-webkit-scrollbar-thumb{border-radius:9999px;background-color:rgba(0, 0, 0, 0.15)}.s-conditional-offer-badges::-webkit-scrollbar-track{background-color:transparent}.s-conditional-offer-tooltip{--s-conditional-offer-tooltip-shift:0px;--s-conditional-offer-tooltip-caret:0px;transform:translateX(calc(-50% + var(--s-conditional-offer-tooltip-shift)))}.s-conditional-offer-tooltip::before{content:"";position:absolute;bottom:100%;left:50%;transform:translateX(calc(-50% + var(--s-conditional-offer-tooltip-caret)));border:8px solid transparent;border-bottom-color:#fff}.s-conditional-offer-tier-icon-met,.s-conditional-offer-tier-icon-unmet{color:var(--color-primary-dark, #00695c);background-color:rgba(0, 137, 123, 0.12);background-color:color-mix(in srgb, var(--color-primary, #00897b) 14%, transparent)}.s-conditional-offer-tier:not(:last-child)::before{content:"";position:absolute;top:2.5rem;bottom:-1rem;inset-inline-start:1.125rem;width:1px;background-color:#d1d5db}.visible{visibility:visible}.invisible{visibility:hidden}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.block{display:block}.inline{display:inline}.flex{display:flex}.hidden{display:none}.w-6{width:1.5rem}.resize{resize:both}.gap-1{gap:0.25rem}.rounded{border-radius:var(--s-radius, 0.25rem)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.s-conditional-offer-root{margin-bottom:1.25rem;display:block;width:100%;min-width:0px;max-width:100%;border-radius:0.375rem;padding:0.75rem}@media (min-width: 768px){.s-conditional-offer-root{padding:1rem}}.s-conditional-offer-banner{display:flex;width:100%;min-width:0px;align-items:center;justify-content:space-between;gap:0.75rem}@media (min-width: 768px){.s-conditional-offer-banner{gap:1rem}}.s-conditional-offer-lead{display:flex;min-width:0px;flex:1 1 0%;align-items:center;gap:0.5rem}@media (min-width: 768px){.s-conditional-offer-lead{gap:0.75rem}}.s-conditional-offer-badges{display:flex;max-width:45%;flex-shrink:0;flex-wrap:nowrap;align-items:center;gap:0.25rem;overflow-x:auto;overscroll-behavior-x:contain;scroll-behavior:smooth;scrollbar-width:thin}.s-conditional-offer-badge{display:inline-flex;height:1.5rem;width:1.5rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;font-size:11px;line-height:1;--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.s-conditional-offer-badge-met{background-color:var(--color-primary)}.s-conditional-offer-badge-unmet{--tw-bg-opacity:1;background-color:rgb(156 163 175 / var(--tw-bg-opacity, 1))}.s-conditional-offer-badge-link{width:0.5rem;flex-shrink:0;border-top-width:1px}.s-conditional-offer-badge-link-met{border-color:var(--color-primary)}.s-conditional-offer-badge-link-unmet{border-style:dashed;--tw-border-opacity:1;border-color:rgb(82 82 82 / var(--tw-border-opacity, 1))}.s-conditional-offer-badge-icon{height:0.75rem;width:0.75rem;flex-shrink:0}.s-conditional-offer-text{display:flex;min-width:0px;flex-direction:column;gap:0.125rem;text-align:start}.s-conditional-offer-heading{display:flex;min-width:0px;align-items:center;gap:0.375rem}.s-conditional-offer-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:0.75rem;line-height:1rem;--tw-text-opacity:1;color:rgb(82 82 82 / var(--tw-text-opacity, 1))}.s-conditional-offer-info{position:relative;display:inline-flex;flex-shrink:0;align-items:center}.s-conditional-offer-info-trigger{display:inline-flex;height:1rem;width:1rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;--tw-text-opacity:1;color:rgb(115 115 115 / var(--tw-text-opacity, 1));transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-conditional-offer-info-trigger:hover{color:var(--color-primary-dark)}.s-conditional-offer-info-icon{height:0.875rem;width:0.875rem;flex-shrink:0}.s-conditional-offer-message{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}@media (min-width: 768px){.s-conditional-offer-message{font-size:1rem;line-height:1.5rem}}.s-conditional-offer-toggle{align-items:center;justify-content:center;gap:0.375rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(38 38 38 / var(--tw-text-opacity, 1));transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-conditional-offer-toggle:hover{color:var(--color-primary-dark)}.s-conditional-offer-toggle-inline{display:none;flex-shrink:0}@media (min-width: 768px){.s-conditional-offer-toggle-inline{display:inline-flex}}.s-conditional-offer-toggle-bar{margin-top:0.5rem;display:inline-flex;width:100%;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding-left:0.75rem;padding-right:0.75rem;padding-top:0.625rem;padding-bottom:0.625rem}@media (min-width: 768px){.s-conditional-offer-toggle-bar{display:none}}.s-conditional-offer-toggle-icon{font-size:1rem;line-height:1.5rem;line-height:1;transition-property:transform;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-conditional-offer-toggle-icon-open{--tw-rotate:180deg;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.s-conditional-offer-panel{margin-top:0.75rem;width:100%;min-width:0px;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:0.75rem}.s-conditional-offer-gifts-header{margin-bottom:0.75rem;display:flex;align-items:center;gap:0.5rem}.s-conditional-offer-gifts-icon{display:inline-flex;height:2rem;width:2rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;border-width:1px;border-color:var(--color-primary);font-size:1rem;line-height:1.5rem;line-height:1;color:var(--color-primary)}.s-conditional-offer-gifts-title{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-gifts-list{margin:0px;display:flex;list-style-type:none;flex-direction:column;gap:0.5rem;padding:0px}.s-conditional-offer-gift{display:flex;align-items:center;gap:0.75rem;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));padding:0.5rem}.s-conditional-offer-gift-thumb{display:inline-flex;height:3.5rem;width:3.5rem;flex-shrink:0;align-items:center;justify-content:center;overflow:hidden;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.s-conditional-offer-gift-image{height:100%;width:100%;object-fit:contain}.s-conditional-offer-gift-body{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.125rem;text-align:start}.s-conditional-offer-gift-name{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;font-size:0.875rem;line-height:1.25rem;font-weight:700;--tw-text-opacity:1;color:rgb(38 38 38 / var(--tw-text-opacity, 1))}.s-conditional-offer-gift-prices{display:flex;align-items:center;gap:0.5rem;font-size:0.75rem;line-height:1rem}.s-conditional-offer-gift-free{font-weight:700;--tw-text-opacity:1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.s-conditional-offer-gift-price{--tw-text-opacity:1;color:rgb(115 115 115 / var(--tw-text-opacity, 1));text-decoration-line:line-through}.s-conditional-offer-tooltip{position:absolute;top:calc(100% + 0.75rem);left:50%;z-index:10;width:min(22rem, calc(100vw - 2rem));border-radius:0.5rem;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1rem;text-align:start;--tw-shadow:5px 10px 30px #2B2D340D;--tw-shadow-colored:5px 10px 30px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.s-conditional-offer-tooltip-title{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-tooltip-description{margin-top:0.25rem;font-size:0.75rem;line-height:1rem;line-height:1.625;--tw-text-opacity:1;color:rgb(82 82 82 / var(--tw-text-opacity, 1))}.s-conditional-offer-tooltip-list{margin:0px;margin-top:0.75rem;display:flex;list-style-type:none;flex-direction:column;gap:1rem;padding:0px}.s-conditional-offer-tier{position:relative;display:flex;align-items:flex-start;gap:0.75rem}.s-conditional-offer-tier-icon{position:relative;display:inline-flex;height:2.25rem;width:2.25rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;font-size:1rem;line-height:1.5rem;line-height:1}.s-conditional-offer-tier-icon-unmet{color:var(--color-primary-dark)}.s-conditional-offer-tier-status{position:absolute;bottom:-0.125rem;display:inline-flex;height:1rem;width:1rem;align-items:center;justify-content:center;border-radius:9999px;border-width:2px;--tw-border-opacity:1;border-color:rgb(255 255 255 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));inset-inline-start:-2px}.s-conditional-offer-tier-status-met{color:var(--color-primary-dark)}.s-conditional-offer-tier-status-unmet{--tw-text-opacity:1;color:rgb(163 163 163 / var(--tw-text-opacity, 1))}.s-conditional-offer-tier-status-check{height:0.75rem;width:0.75rem;flex-shrink:0}.s-conditional-offer-tier-status-lock{height:0.625rem;width:0.625rem;flex-shrink:0}.s-conditional-offer-tier-body{display:flex;min-width:0px;flex-direction:column;gap:0.125rem}.s-conditional-offer-tier-title{font-size:0.75rem;line-height:1rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-tier-text{font-size:0.75rem;line-height:1rem;line-height:1.625;--tw-text-opacity:1;color:rgb(82 82 82 / var(--tw-text-opacity, 1))}.s-conditional-offer-tier-text-met{text-decoration-line:line-through}.s-conditional-offer-skeleton-text{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.375rem}';export{N as salla_conditional_offer}
4
+ import{r as t,h as i,H as e,a as o}from"./p-CwwxD-7C.js";var r,n;!function(t){t.PERCENTAGE="percentage",t.FIXED="fixed",t.FREE_PRODUCT="free_product",t.FREE_SHIPPING="free_shipping"}(r||(r={})),function(t){t.PRODUCT_COUNT="products_count",t.PRODUCT_PURCHASE="order_amount"}(n||(n={}));const s=Object.freeze([]);let a,l=null,c=null,d=!1,f=null,h=null,u=0;function g(t){return"CartNotCreated"===t?.name}function m(){try{const t=salla.api?.cart?.getStoredCartId?salla.api.cart.getStoredCartId():salla.storage?.get?.("cart.id");return null==t||""===t?null:String(t)}catch(t){return null}}function p(){const t=m();void 0!==a&&a!==t&&(u++,l=null,c=null,d=!1,f=null),a=t}function b(t){return null==t?0:"number"==typeof t?isFinite(t)?t:0:"string"==typeof t&&parseFloat(t)||0}function w(t){if(null==t||""===t)return null;const i=b(t);return isFinite(i)?i:null}function y(t,i){if(null!==i)return i.length;const e=w(t?.data?.cart?.count??t?.data?.count??t?.cart?.count??t?.count);return null!==e&&e>=0?e:null}function x(t){for(const i of[t?.original_price,t?.product_price,t?.price]){const t=w(i&&"object"==typeof i?i.amount:i);if(null!==t&&t>0)return t}return null}function v(t,i){const e=t?.free_gift_quantity;return null!=e&&""!==e?b(e):i>0?i:0}function k(t){const i=[];for(const e of t){if(null==e?.id)continue;if(!e.added_by_offer)continue;const t=b(e.quantity),o=v(e,t);o<=0||i.push({id:String(e.id),offerId:w(e.offer_id),quantity:o,freeQuantity:o,lineQuantity:t,name:String(e.product_name??e.name??""),imageUrl:String(e.product_image?.url??e.product_image??e.image?.url??""),imageAlt:String(e.product_image?.alt??e.image?.alt??e.product_name??""),url:String(e.url??""),originalPrice:x(e)})}return i}function _(){if(f)return f;const t=u,i=Promise.resolve().then((()=>salla.api?.cart?.details?.())).then((t=>{const i=function(t){const i=t?.data?.cart?.items??t?.data?.items??t?.cart?.items??t?.items;return Array.isArray(i)?i:null}(t);return{gifts:k(i??[]),count:y(t,i),ok:!0}})).catch((t=>({gifts:l??[],count:g(t)?0:c,ok:!1}))).then((({gifts:i,count:e,ok:o})=>{t===u&&(l=i,c=e,d=o)})).finally((()=>{f===i&&(f=null)}));return f=i,i}const C=-1;var M,T;function z(t){const i="number"==typeof t?t:parseFloat(t);return Number.isFinite(i)?i:null}function S(t){return"boolean"==typeof t?t:1===t||0===t?1===t:"true"===t||"1"===t||"false"!==t&&"0"!==t&&void 0}function L(t){return z(t)??0}function I(t,i,e){return Math.max(i,Math.min(t,e))}function V(t){const i="number"==typeof t?t:parseFloat(t);if(!Number.isFinite(i))return null;const e=Math.trunc(i);return e>=0&&e<=4?e:null}!function(t){t.LOCKED="locked",t.CURRENT="current",t.COMPLETED="completed"}(M||(M={})),function(t){t.CURRENCY="currency",t.COUNT="count"}(T||(T={}));const F=[1e3,2e3,4e3],R='[data-testid^="store-cart-item-"], form[id^="item-"]';let $=0;const P={badges_summary:":completed of :total offers unlocked",congrats:"Congratulations! You’ve unlocked all rewards in this promotion",details_title:"Offer details",free_gift:"Free Gift",free_products_title:"Free products selected from the offer",guidance_conditions_unmet:"Your cart doesn’t meet the conditions for the next reward yet",guidance_next:"Add :remaining and get :reward",guidance_next_generic:"Add :remaining to unlock the next reward",manage_offer:"Manage offer",tier_requirement:"Spend :threshold and get :reward",tier_requirement_count:"Buy :threshold and get :reward",tier_requirement_count_generic:"Buy :threshold to unlock this offer",tier_requirement_generic:"Spend :threshold to unlock this offer",tier_title:"Offer (:number)"},j="pages.checkout.free_charge";function H(t){const i=document.createElement("div");return i.textContent=t??"",i.innerHTML}const O=(t={})=>i("svg",{class:t.class,viewBox:"0 0 10 10",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},i("path",{d:"M5.00016 9.16634C2.69898 9.16634 0.833496 7.30084 0.833496 4.99967C0.833496 2.69849 2.69898 0.833008 5.00016 0.833008C7.30133 0.833008 9.16683 2.69849 9.16683 4.99967C9.16683 7.30084 7.30133 9.16634 5.00016 9.16634ZM4.58458 6.66634L7.53087 3.72006L6.94162 3.13081L4.58458 5.48784L3.40608 4.3093L2.81683 4.89859L4.58458 6.66634Z",fill:"currentColor"})),q=(t={})=>i("svg",{class:t.class,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},i("path",{d:"M12.6667 6.66683H13.3333C13.7015 6.66683 14 6.9653 14 7.3335V14.0002C14 14.3684 13.7015 14.6668 13.3333 14.6668H2.66667C2.29848 14.6668 2 14.3684 2 14.0002V7.3335C2 6.9653 2.29848 6.66683 2.66667 6.66683H3.33333V6.00016C3.33333 3.42284 5.42267 1.3335 8 1.3335C10.5773 1.3335 12.6667 3.42284 12.6667 6.00016V6.66683ZM11.3333 6.66683V6.00016C11.3333 4.15922 9.84093 2.66683 8 2.66683C6.15905 2.66683 4.66667 4.15922 4.66667 6.00016V6.66683H11.3333ZM7.33333 9.3335V12.0002H8.66667V9.3335H7.33333Z",fill:"currentColor"})),N=(t={})=>i("svg",{class:t.class,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},i("path",{d:"M7.00033 12.8337C3.77866 12.8337 1.16699 10.222 1.16699 7.00033C1.16699 3.77866 3.77866 1.16699 7.00033 1.16699C10.222 1.16699 12.8337 3.77866 12.8337 7.00033C12.8337 10.222 10.222 12.8337 7.00033 12.8337ZM6.41699 6.41699V9.91699H7.58366V6.41699H6.41699ZM6.41699 4.08366V5.25033H7.58366V4.08366H6.41699Z",fill:"currentColor"})),D=class{constructor(i){t(this,i),this.offer=null,this.isLoading=!1,this.canRender=!0,this.gifts=[],this.cartItemCount=null,this.isTooltipHovered=!1,this.isTooltipPinned=!1,this.isGiftsOpen=!0,this.instanceId=++$,this.refreshGeneration=0,this.giftsGeneration=0,this.cartRefreshTimer=null,this.cartRefreshPending=!1,this.wantsCartUpdates=!1,this.isListeningToCartUpdates=!1,this.cartLookupRetryTimer=null,this.cartLookupRetries=0,this.cartLookupRetryPending=!1,this.deferredByEmptyCart=!1,this.isDisconnected=!1,this.skeletonWatchdog=null,this.skeletonDeadline=0,this.hasRelocated=!1,this.hasLoaded=!1,this.relocationObserver=null,this.relocationWatchTimer=null,this.relocationWatchExpired=!1,this.relocationLogged=!1,this.cartUpdatedHandler=t=>{this.readCartCountFromEvent(t),this.clearCartLookupRetry(),this.scheduleCartRefresh()}}componentWillLoad(){this.ensureSkeletonIsWatched();try{this.isEnabled()&&this.startLoading(),this.load().catch((t=>{this.stopLoading(),this.safeLog("load() failed",t)}))}catch(t){this.stopLoading(),this.safeLog("componentWillLoad threw synchronously",t)}}safeLog(t,i){try{salla.logger.warn("salla-conditional-offer::",t,i)}catch(t){}}connectedCallback(){this.isDisconnected=!1,this.ensureSkeletonIsWatched(),this.wantsCartUpdates&&!this.isListeningToCartUpdates&&this.subscribeToCartUpdates()&&(this.cartRefreshPending=!0),this.cartRefreshPending&&this.scheduleCartRefresh(),this.cartLookupRetryPending&&this.scheduleCartLookupRetry()}disconnectedCallback(){this.isDisconnected=!0,null!==this.cartRefreshTimer&&(clearTimeout(this.cartRefreshTimer),this.cartRefreshTimer=null),null!==this.cartLookupRetryTimer&&(clearTimeout(this.cartLookupRetryTimer),this.cartLookupRetryTimer=null),Promise.resolve().then((()=>{this.isDisconnected&&this.unsubscribeFromCartUpdates()})),null!==this.skeletonWatchdog&&(clearTimeout(this.skeletonWatchdog),this.skeletonWatchdog=null),this.stopWatchingForItemsColumn()}componentDidLoad(){this.hasLoaded=!0,this.relocateIntoItemsColumn()}isShowingSomething(){return this.canRender&&this.hasCartItems()}componentDidRender(){this.hasLoaded&&this.relocateIntoItemsColumn(),this.positionTooltip(),this.ensureSkeletonIsWatched()}relocateIntoItemsColumn(){if(!this.hasRelocated&&this.isShowingSomething())try{const t=this.hostEl;if(!t?.parentElement)return;const i=this.findItemsColumn(t);if(!i)return void this.watchForItemsColumn();if(this.hasRelocated=!0,this.stopWatchingForItemsColumn(),i===t.parentElement&&i.firstElementChild===t)return;i.insertBefore(t,i.firstChild)}catch(t){this.hasRelocated=!0,this.stopWatchingForItemsColumn(),this.safeLog("relocating the banner into the cart items column failed",t)}}findItemsColumn(t){let i=t;for(let e=0;i&&e<=3;e++){for(const e of this.getFollowingSiblings(i)){if(i===t&&this.matches(e,R))return t.parentElement;const o=this.findColumnWithin(e,t);if(o)return o}if(i=i.parentElement,!i||i===document.body||i===document.documentElement)break}return null}getFollowingSiblings(t){const i=[];for(let e=t.nextElementSibling;e;e=e.nextElementSibling)i.push(e);return i}findColumnWithin(t,i){const e=t.querySelector(R),o=(e?this.climbToChildOf(e,t):null)??t.querySelector(".main-content, [data-cart-items]");return!o||o===i||o.contains(i)?null:o}climbToChildOf(t,i){let e=t;for(;e&&e.parentElement&&e.parentElement!==i;)e=e.parentElement;return e?.parentElement===i?e:null}matches(t,i){return"function"==typeof t.matches&&t.matches(i)}watchForItemsColumn(){this.hasRelocated||this.relocationWatchExpired||this.relocationObserver||("undefined"!=typeof MutationObserver?(this.relocationObserver=new MutationObserver((()=>this.relocateIntoItemsColumn())),this.relocationObserver.observe(document.documentElement,{childList:!0,subtree:!0}),this.relocationWatchTimer=setTimeout((()=>{this.relocationWatchTimer=null,this.relocationWatchExpired=!0,this.stopWatchingForItemsColumn(),this.logNoItemsColumn()}),5e3)):this.logNoItemsColumn())}stopWatchingForItemsColumn(){if(this.relocationObserver){try{this.relocationObserver.disconnect()}catch(t){}this.relocationObserver=null}null!==this.relocationWatchTimer&&(clearTimeout(this.relocationWatchTimer),this.relocationWatchTimer=null)}logNoItemsColumn(){this.relocationLogged||(this.relocationLogged=!0,this.safeLog("no cart items column found — leaving the banner at full page width"))}ensureSkeletonIsWatched(){if(!this.isLoading)return;if(null!==this.skeletonWatchdog)return;const t=Date.now();0===this.skeletonDeadline&&(this.skeletonDeadline=t+8e3);const i=Math.max(0,this.skeletonDeadline-t);this.skeletonWatchdog=setTimeout((()=>{this.skeletonWatchdog=null,this.isLoading&&(Date.now()<this.skeletonDeadline?this.ensureSkeletonIsWatched():(this.isLoading=!1,this.skeletonDeadline=0,this.safeLog("still loading after 8000ms — dropping the skeleton")))}),i)}clearSkeletonWatchdog(){this.skeletonDeadline=0,null!==this.skeletonWatchdog&&(clearTimeout(this.skeletonWatchdog),this.skeletonWatchdog=null)}startLoading(){this.isLoading=!0,this.ensureSkeletonIsWatched()}stopLoading(){this.isLoading=!1,this.clearSkeletonWatchdog()}async load(){this.wantsCartUpdates=!0,this.subscribeToCartUpdates()||this.subscribeWhenSdkIsReady(),this.loadCart(),await this.waitForSdk(),await this.refresh()}waitForSdk(){let t,i;try{t=Promise.resolve(salla.onReady?.())}catch(t){return this.safeLog("salla.onReady() threw",t),Promise.resolve()}const e=new Promise((t=>{i=setTimeout(t,3e3)}));return Promise.race([t.catch((t=>this.safeLog("salla.onReady() rejected",t))),e]).then((()=>{clearTimeout(i)}))}subscribeToCartUpdates(){if(this.isListeningToCartUpdates)return!0;try{salla.event.on("cart::updated",this.cartUpdatedHandler),this.isListeningToCartUpdates=!0}catch(t){this.safeLog("cart::updated subscription failed",t)}return this.isListeningToCartUpdates}unsubscribeFromCartUpdates(){if(this.isListeningToCartUpdates){this.isListeningToCartUpdates=!1;try{salla.event.off("cart::updated",this.cartUpdatedHandler)}catch(t){this.safeLog("cart::updated unsubscription failed",t)}}}subscribeWhenSdkIsReady(){let t;try{t=Promise.resolve(salla.onReady?.())}catch(t){return}const i=()=>{this.isDisconnected||this.subscribeToCartUpdates()};t.then(i,i)}scheduleCartRefresh(){this.cartRefreshPending=!0,null!==this.cartRefreshTimer&&clearTimeout(this.cartRefreshTimer),this.cartRefreshTimer=null,this.isDisconnected||(this.cartRefreshTimer=setTimeout((()=>{this.cartRefreshTimer=null,this.runCartRefresh()}),200))}runCartRefresh(){this.isDisconnected||(this.cartRefreshPending=!1,this.refresh(),function(){if(h)return h;u++,l=null,c=null,d=!1,a=m();const t=()=>(h===i&&(h=null),_()),i=(f??Promise.resolve()).then(t,t).finally((()=>{h===i&&(h=null)}));return h=i,i}().then((()=>this.loadCart()),(()=>this.loadCart())))}readCartCountFromEvent(t){const i=this.toCartCount(t?.count)??this.readCartCountFromStorage();null!==i&&(this.cartItemCount=i)}readCartCountFromStorage(){try{return this.toCartCount(salla.storage?.get?.("cart.summary.count"))}catch(t){return null}}toCartCount(t){return"number"==typeof t&&Number.isFinite(t)&&t>=0?t:null}getFreeLabel(){const t=salla.lang.get(j);return t&&t!==j?t:"Free"}trans(t,i){const e=`blocks.cart_offer.${t}`,o=salla.lang.get(e,i);return o&&o!==e?o:Object.entries(i??{}).reduce(((t,[i,e])=>t.split(`:${i}`).join(e)),P[t])}isEnabled(){try{return!!salla.config.get("store.features")?.includes("conditional-offer")}catch(t){return!1}}async fetchOffer(){const{data:t}=await salla.api.cart.offers(),i=(t||[]).find((t=>"conditional"===t.type));return i?.details?.discounts?.length?i:null}async refresh(){const t=++this.refreshGeneration;if(!this.isEnabled())return this.stopLoading(),void(this.canRender=!1);if(0===this.cartItemCount)return this.stopLoading(),p(),void(d||(this.deferredByEmptyCart=!0,this.loadCart()));this.deferredByEmptyCart=!1,this.offer?this.stopLoading():this.startLoading();try{const i=await this.fetchOffer();if(this.isSuperseded(t))return;if(!i)return this.offer=null,void(this.canRender=!1);this.offer=i,this.canRender=!0,this.loadCart()}catch(i){if(this.isSuperseded(t))return;this.safeLog("offers() failed",i)}finally{t===this.refreshGeneration&&this.stopLoading()}}hasCartItems(){return"number"==typeof this.cartItemCount&&this.cartItemCount>=1}isSuperseded(t){return t!==this.refreshGeneration||this.isDisconnected}loadCart(){const t=++this.giftsGeneration;return Promise.all([(p(),d&&l?Promise.resolve(l):_().then((()=>l??s))),(p(),d&&l?Promise.resolve(c):_().then((()=>c)))]).then((([i,e])=>{t!==this.giftsGeneration||this.isDisconnected||this.cartRefreshPending||(null!==e&&(this.cartItemCount=e),null!==e?this.clearCartLookupRetry():null===this.cartItemCount&&this.scheduleCartLookupRetry(),this.deferredByEmptyCart&&this.hasCartItems()&&(this.deferredByEmptyCart=!1,this.refresh()),this.gifts=this.offer?this.selectOwnGifts(i):[])})).catch((t=>{this.safeLog("cart lookup failed",t)}))}scheduleCartLookupRetry(){this.cartLookupRetries>=F.length||(this.cartLookupRetryPending=!0,null!==this.cartLookupRetryTimer||this.isDisconnected||(this.cartLookupRetryTimer=setTimeout((()=>{this.cartLookupRetryTimer=null,this.cartLookupRetryPending=!1,this.canRender&&(this.cartLookupRetries++,this.loadCart())}),F[this.cartLookupRetries])))}clearCartLookupRetry(){this.cartLookupRetries=0,this.cartLookupRetryPending=!1,null!==this.cartLookupRetryTimer&&(clearTimeout(this.cartLookupRetryTimer),this.cartLookupRetryTimer=null)}selectOwnGifts(t){const i=Number(this.offer?.id);if(!Number.isFinite(i))return t;const e=t.filter((t=>null!==t.offerId&&Number(t.offerId)===i));return e.length?e:t.filter((t=>null===t.offerId))}getStages(){const t=(this.offer?.details?.discounts??[]).filter((({min_spend:t})=>null!==z(t)));return i=({min_spend:t})=>t,e=({id:t})=>t,(t??[]).map(((t,o)=>({item:t,index:o,threshold:L(i(t)),identity:e?z(e(t)):null}))).sort(((t,i)=>t.threshold!==i.threshold?t.threshold-i.threshold:null!==t.identity&&null!==i.identity&&t.identity!==i.identity?t.identity-i.identity:t.index-i.index)).map((({item:t})=>t));var i,e}getProgress(t){return function(t,i,e=0,o=[],r=[]){const n=(i??[]).map(((t,i)=>({index:i,threshold:z(t),applied:S(o?.[i]),tierValue:z(r?.[i])}))).filter((t=>null!==t.threshold)).sort(((t,i)=>t.threshold-i.threshold||t.index-i.index)),s=n.map((t=>t.threshold)),a=n.map((t=>t.applied)),l=a.some((t=>void 0!==t)),c=L(e);if(!s.length)return{thresholds:s,met:[],applied:a,appliedIndex:C,hasEngineVerdict:l,metCount:0,nextUnmetIndex:C,allMet:!1,lastReachedIndex:C,currentIndex:C,isComplete:!1,value:Math.max(0,L(t)),values:[],startValue:c,fills:[],overallPercentage:0};const d=s[s.length-1],f=I(L(t),0,Math.max(0,d)),h=n.map((({tierValue:t})=>null===t?f:I(t,0,Math.max(0,d))));let u=C;for(let t=0;t<s.length;t++)h[t]>=s[t]&&(u=t);const g=u===s.length-1,m=g?C:u+1,p=s.map(((t,i)=>function(t,i,e){return e<=i?t>=e?100:0:I((t-i)/(e-i)*100,0,100)}(h[i],0===i?c:s[i-1],t))),b=g?100:I((u+1+(p[m]??0)/100)/s.length*100,0,100);let w=C;for(let t=0;t<a.length;t++)!0===a[t]&&(w=t);const y=s.map(l?(t,i)=>i<=w:(t,i)=>i<=u),x=y.filter(Boolean).length,v=y.findIndex((t=>!t));return{thresholds:s,met:y,applied:a,appliedIndex:w,hasEngineVerdict:l,metCount:x,nextUnmetIndex:v,allMet:v===C,lastReachedIndex:u,currentIndex:m,isComplete:g,value:f,values:h,startValue:c,fills:p,overallPercentage:b}}(this.offer?.details?.current_value,t.map((({min_spend:t})=>t)),this.offer?.details?.start_value,t.map((({is_applied:t})=>t)),t.map((({current_value:t})=>t)))}tierKey(t,i){const e=Number(t?.id);return Number.isFinite(e)?`tier-${e}`:`pos-${i}`}stageMeasure(){return this.offer?.details?.based_on===n.PRODUCT_COUNT?T.COUNT:T.CURRENCY}formatRequirement(t){const i=this.offer?.details?.based_on;if(i===n.PRODUCT_COUNT)try{return salla.lang.choice("blocks.header.products_count",t)}catch(i){return this.safeLog("invalid products_count interval",i),`${t}`}return i===n.PRODUCT_PURCHASE?salla.money(t):(this.safeLog(`unexpected offer detail's based_on value: ${i}`),`${t}`)}getRewardText(t){return(t?.reward_label??"").trim()}getGuidanceMessage(t,i){if(i.nextUnmetIndex===C)return"";const e=function(t,i,e=T.CURRENCY){const o=i.thresholds[t];if(void 0===o)return 0;const r=Math.max(0,o-(i.values?.[t]??i.value));if(0===r)return 0;const n=e===T.COUNT?0:function(){try{const t="undefined"!=typeof salla?salla:void 0,i=V(t?.config?.currency?.()?.decimals);if(null!==i)return i;const e=V(t?.config?.get?.("store.currency.decimals"));if(null!==e)return e}catch(t){}return 2}(),s=Math.pow(10,n),a=Math.ceil(r*s-1e-6)/s;return a>0?a:1/s}(i.nextUnmetIndex,i,this.stageMeasure());if(e<=0)return this.trans("guidance_conditions_unmet");const o=this.formatRequirement(e),r=this.getRewardText(t[i.nextUnmetIndex]);return r?this.trans("guidance_next",{remaining:o,reward:H(r)}):this.trans("guidance_next_generic",{remaining:o})}getTierSentence(t,i,e){const o=this.formatRequirement(e.thresholds[i]),r=this.getRewardText(t),n=this.stageMeasure()===T.COUNT;return r?this.trans(n?"tier_requirement_count":"tier_requirement",{threshold:o,reward:H(r)}):this.trans(n?"tier_requirement_count_generic":"tier_requirement_generic",{threshold:o})}getRewardIcon(t){switch(t?.type){case r.PERCENTAGE:return"sicon-percentage";case r.FREE_PRODUCT:return"sicon-gift";case r.FIXED:return this.usesSarSymbol()?"sicon-sar":"sicon-banknote";default:return"sicon-tag"}}usesSarSymbol(){try{const t=salla.config.currency?.()?.symbol;return["SAR","ر.س"].includes(t)&&!!salla.config.get("store.settings.use_sar_symbol")}catch(t){return!1}}get isTooltipOpen(){return this.isTooltipHovered||this.isTooltipPinned}toggleTooltip(){this.isTooltipPinned=!this.isTooltipPinned}closeTooltip(t=!1){this.isTooltipOpen&&(this.isTooltipPinned=!1,this.isTooltipHovered=!1,t&&this.infoTriggerEl?.focus?.())}positionTooltip(){const t=this.tooltipEl,i=this.infoTriggerEl;if(this.isTooltipOpen&&t&&i)try{this.setTooltipOffsets(t,0,0);const e=window.innerWidth||document.documentElement?.clientWidth||0,o=t.getBoundingClientRect(),r=i.getBoundingClientRect(),n=o?.width||0;if(n<=0||e<=0)return;const s=r.left+r.width/2-n/2,a=8,l=Math.min(Math.max(s,a),Math.max(a,e-a-n))-s,c=Math.max(0,n/2-16),d=Math.min(Math.max(-l,-c),c);this.setTooltipOffsets(t,l,d)}catch(t){this.safeLog("positioning the offer details popover failed",t)}}setTooltipOffsets(t,i,e){t.style?.setProperty?.("--s-conditional-offer-tooltip-shift",`${Math.round(i)}px`),t.style?.setProperty?.("--s-conditional-offer-tooltip-caret",`${Math.round(e)}px`)}handleWindowResize(){this.positionTooltip()}handleDocumentKeydown(t){"Escape"!==t.key&&"Esc"!==t.key||this.closeTooltip(!0)}handleDocumentClick(t){if(!this.isTooltipPinned||!this.infoAnchorEl)return;const i="function"==typeof t.composedPath?t.composedPath():[];(i.length?i.includes(this.infoAnchorEl):this.infoAnchorEl.contains(t.target))||this.closeTooltip()}elementId(t){return`s-conditional-offer-${t}-${this.instanceId}`}renderBadges(t,e){return i("div",{class:"s-conditional-offer-badges",role:"img","aria-label":this.trans("badges_summary",{completed:`${e.metCount}`,total:`${t.length}`})},t.map(((t,o)=>{const r=e.met[o],n=this.tierKey(t,o);return[o>0?i("span",{key:`${n}-link`,class:{"s-conditional-offer-badge-link":!0,"s-conditional-offer-badge-link-met":r,"s-conditional-offer-badge-link-unmet":!r},"aria-hidden":"true"}):null,i("span",{key:n,class:{"s-conditional-offer-badge":!0,"s-conditional-offer-badge-met":r,"s-conditional-offer-badge-unmet":!r},"data-tier-state":r?"met":"unmet","data-tier-id":t?.id??void 0},i(r?O:q,{class:"s-conditional-offer-badge-icon"}))]})))}renderTooltip(t,e){const o=function(t){const i=t?.details?.rules;if("string"==typeof i){const t=i.trim();return""===t?null:t}if(Array.isArray(i)){const t=i.filter((t=>"string"==typeof t)).map((t=>t.trim())).filter((t=>""!==t)).join(" ");return""===t?null:t}return null}(this.offer);return i("div",{class:"s-conditional-offer-tooltip",id:this.elementId("tooltip"),role:"tooltip",ref:t=>this.tooltipEl=t},i("div",{class:"s-conditional-offer-tooltip-title"},this.offer?.title),o?i("div",{class:"s-conditional-offer-tooltip-description"},o):null,i("ul",{class:"s-conditional-offer-tooltip-list"},t.map(((t,o)=>{const r=e.met[o];return i("li",{key:this.tierKey(t,o),class:"s-conditional-offer-tier","data-tier-state":r?"met":"unmet","data-tier-id":t?.id??void 0},i("span",{class:{"s-conditional-offer-tier-icon":!0,"s-conditional-offer-tier-icon-met":r,"s-conditional-offer-tier-icon-unmet":!r}},i("i",{class:this.getRewardIcon(t),"aria-hidden":"true"}),i("span",{class:{"s-conditional-offer-tier-status":!0,"s-conditional-offer-tier-status-met":r,"s-conditional-offer-tier-status-unmet":!r},"aria-hidden":"true"},r?i(O,{class:"s-conditional-offer-tier-status-check"}):i(q,{class:"s-conditional-offer-tier-status-lock"}))),i("div",{class:"s-conditional-offer-tier-body"},i("div",{class:"s-conditional-offer-tier-title"},this.trans("tier_title",{number:`${o+1}`})),i("div",{class:{"s-conditional-offer-tier-text":!0,"s-conditional-offer-tier-text-met":r},innerHTML:this.getTierSentence(t,o,e)})))}))))}renderGiftsToggle(t){return i("button",{type:"button",id:this.elementId(`toggle-${t}`),class:{"s-conditional-offer-toggle":!0,"s-conditional-offer-toggle-inline":"inline"===t,"s-conditional-offer-toggle-bar":"bar"===t},"aria-expanded":this.isGiftsOpen?"true":"false","aria-controls":this.elementId("gifts"),onClick:()=>this.isGiftsOpen=!this.isGiftsOpen},i("span",null,this.trans("manage_offer")),i("i",{class:{"sicon-keyboard_arrow_down":!0,"s-conditional-offer-toggle-icon":!0,"s-conditional-offer-toggle-icon-open":this.isGiftsOpen},"aria-hidden":"true"}))}renderGiftsCard(){return i("div",{class:"s-conditional-offer-panel",id:this.elementId("gifts")},i("div",{class:"s-conditional-offer-gifts-header"},i("span",{class:"s-conditional-offer-gifts-icon"},i("i",{class:"sicon-gift","aria-hidden":"true"})),i("span",{class:"s-conditional-offer-gifts-title"},this.trans("free_products_title"))),i("ul",{class:"s-conditional-offer-gifts-list"},this.gifts.map((t=>this.renderGiftRow(t)))))}renderGiftRow(t){return i("li",{class:"s-conditional-offer-gift","data-item-id":t.id},i("span",{class:"s-conditional-offer-gift-thumb"},t.imageUrl?i("img",{class:"s-conditional-offer-gift-image",src:t.imageUrl,alt:t.imageAlt||t.name,loading:"lazy",decoding:"async"}):i("i",{class:"sicon-gift","aria-hidden":"true"})),i("div",{class:"s-conditional-offer-gift-body"},i("span",{class:"s-conditional-offer-gift-name"},t.name||this.trans("free_gift")),i("span",{class:"s-conditional-offer-gift-prices"},i("span",{class:"s-conditional-offer-gift-free"},this.getFreeLabel()),null!==t.originalPrice?i("span",{class:"s-conditional-offer-gift-price",innerHTML:salla.money(t.originalPrice)}):null)))}getLoadingSkeletonView(){return i(e,{class:"s-conditional-offer-root"},i("div",{class:"s-conditional-offer-banner"},i("div",{class:"s-conditional-offer-lead"},i("salla-skeleton",{height:"24px",width:"80px"}),i("div",{class:"s-conditional-offer-skeleton-text"},i("salla-skeleton",{height:"12px",width:"35%"}),i("salla-skeleton",{height:"16px",width:"60%"})))))}render(){if(!this.canRender)return null;if(!this.hasCartItems())return null;if(this.isLoading)return this.getLoadingSkeletonView();if(!this.offer)return null;const t=this.getStages(),o=this.getProgress(t),r=this.getGuidanceMessage(t,o),n=this.trans("details_title"),s=this.gifts.length>0;return i(e,{class:"s-conditional-offer-root"},i("div",{class:"s-conditional-offer-banner"},i("div",{class:"s-conditional-offer-lead"},this.renderBadges(t,o),i("div",{class:"s-conditional-offer-text"},i("div",{class:"s-conditional-offer-heading",onMouseEnter:()=>this.isTooltipHovered=!0,onMouseLeave:()=>this.isTooltipHovered=!1},i("span",{class:"s-conditional-offer-name"},this.offer.title),i("span",{class:"s-conditional-offer-info",ref:t=>this.infoAnchorEl=t},i("button",{type:"button",class:"s-conditional-offer-info-trigger",ref:t=>this.infoTriggerEl=t,"aria-label":n,title:n,"aria-expanded":this.isTooltipOpen?"true":"false","aria-describedby":this.elementId("tooltip"),onClick:()=>this.toggleTooltip()},i(N,{class:"s-conditional-offer-info-icon"})),this.isTooltipOpen?this.renderTooltip(t,o):null)),o.allMet?i("div",{class:"s-conditional-offer-message",role:"status"},this.trans("congrats")):r?i("div",{class:"s-conditional-offer-message",innerHTML:r}):null)),s?this.renderGiftsToggle("inline"):null),s&&this.isGiftsOpen?this.renderGiftsCard():null,s?this.renderGiftsToggle("bar"):null)}get hostEl(){return o(this)}};D.style='/*!twlt*/:host{display:block}.s-conditional-offer-root{background-color:rgba(0, 137, 123, 0.06);background-color:color-mix(in srgb, var(--color-primary, #00897b) 7%, transparent)}.s-conditional-offer-badges::-webkit-scrollbar{height:3px}.s-conditional-offer-badges::-webkit-scrollbar-thumb{border-radius:9999px;background-color:rgba(0, 0, 0, 0.15)}.s-conditional-offer-badges::-webkit-scrollbar-track{background-color:transparent}.s-conditional-offer-tooltip{--s-conditional-offer-tooltip-shift:0px;--s-conditional-offer-tooltip-caret:0px;transform:translateX(calc(-50% + var(--s-conditional-offer-tooltip-shift)))}.s-conditional-offer-tooltip::before{content:"";position:absolute;bottom:100%;left:50%;transform:translateX(calc(-50% + var(--s-conditional-offer-tooltip-caret)));border:8px solid transparent;border-bottom-color:#fff}.s-conditional-offer-tier-icon-met,.s-conditional-offer-tier-icon-unmet{color:var(--color-primary-dark, #00695c);background-color:rgba(0, 137, 123, 0.12);background-color:color-mix(in srgb, var(--color-primary, #00897b) 14%, transparent)}.s-conditional-offer-tier:not(:last-child)::before{content:"";position:absolute;top:2.5rem;bottom:-1rem;inset-inline-start:1.125rem;width:1px;background-color:#d1d5db}.visible{visibility:visible}.invisible{visibility:hidden}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.block{display:block}.inline{display:inline}.flex{display:flex}.hidden{display:none}.w-6{width:1.5rem}.resize{resize:both}.gap-1{gap:0.25rem}.rounded{border-radius:var(--s-radius, 0.25rem)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.s-conditional-offer-root{margin-bottom:1.25rem;display:block;width:100%;min-width:0px;max-width:100%;border-radius:0.375rem;padding:0.75rem}@media (min-width: 768px){.s-conditional-offer-root{padding:1rem}}.s-conditional-offer-banner{display:flex;width:100%;min-width:0px;align-items:center;justify-content:space-between;gap:0.75rem}@media (min-width: 768px){.s-conditional-offer-banner{gap:1rem}}.s-conditional-offer-lead{display:flex;min-width:0px;flex:1 1 0%;align-items:center;gap:0.5rem}@media (min-width: 768px){.s-conditional-offer-lead{gap:0.75rem}}.s-conditional-offer-badges{display:flex;max-width:45%;flex-shrink:0;flex-wrap:nowrap;align-items:center;gap:0.25rem;overflow-x:auto;overscroll-behavior-x:contain;scroll-behavior:smooth;scrollbar-width:thin}.s-conditional-offer-badge{display:inline-flex;height:1.5rem;width:1.5rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;font-size:11px;line-height:1;--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.s-conditional-offer-badge-met{background-color:var(--color-primary)}.s-conditional-offer-badge-unmet{--tw-bg-opacity:1;background-color:rgb(156 163 175 / var(--tw-bg-opacity, 1))}.s-conditional-offer-badge-link{width:0.5rem;flex-shrink:0;border-top-width:1px}.s-conditional-offer-badge-link-met{border-color:var(--color-primary)}.s-conditional-offer-badge-link-unmet{border-style:dashed;--tw-border-opacity:1;border-color:rgb(82 82 82 / var(--tw-border-opacity, 1))}.s-conditional-offer-badge-icon{height:0.75rem;width:0.75rem;flex-shrink:0}.s-conditional-offer-text{display:flex;min-width:0px;flex-direction:column;gap:0.125rem;text-align:start}.s-conditional-offer-heading{display:flex;min-width:0px;align-items:center;gap:0.375rem}.s-conditional-offer-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:0.75rem;line-height:1rem;--tw-text-opacity:1;color:rgb(82 82 82 / var(--tw-text-opacity, 1))}.s-conditional-offer-info{position:relative;display:inline-flex;flex-shrink:0;align-items:center}.s-conditional-offer-info-trigger{display:inline-flex;height:1rem;width:1rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;--tw-text-opacity:1;color:rgb(115 115 115 / var(--tw-text-opacity, 1));transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-conditional-offer-info-trigger:hover{color:var(--color-primary-dark)}.s-conditional-offer-info-icon{height:0.875rem;width:0.875rem;flex-shrink:0}.s-conditional-offer-message{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}@media (min-width: 768px){.s-conditional-offer-message{font-size:1rem;line-height:1.5rem}}.s-conditional-offer-toggle{align-items:center;justify-content:center;gap:0.375rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(38 38 38 / var(--tw-text-opacity, 1));transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-conditional-offer-toggle:hover{color:var(--color-primary-dark)}.s-conditional-offer-toggle-inline{display:none;flex-shrink:0}@media (min-width: 768px){.s-conditional-offer-toggle-inline{display:inline-flex}}.s-conditional-offer-toggle-bar{margin-top:0.5rem;display:inline-flex;width:100%;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding-left:0.75rem;padding-right:0.75rem;padding-top:0.625rem;padding-bottom:0.625rem}@media (min-width: 768px){.s-conditional-offer-toggle-bar{display:none}}.s-conditional-offer-toggle-icon{font-size:1rem;line-height:1.5rem;line-height:1;transition-property:transform;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-conditional-offer-toggle-icon-open{--tw-rotate:180deg;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.s-conditional-offer-panel{margin-top:0.75rem;width:100%;min-width:0px;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:0.75rem}.s-conditional-offer-gifts-header{margin-bottom:0.75rem;display:flex;align-items:center;gap:0.5rem}.s-conditional-offer-gifts-icon{display:inline-flex;height:2rem;width:2rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;border-width:1px;border-color:var(--color-primary);font-size:1rem;line-height:1.5rem;line-height:1;color:var(--color-primary)}.s-conditional-offer-gifts-title{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-gifts-list{margin:0px;display:flex;list-style-type:none;flex-direction:column;gap:0.5rem;padding:0px}.s-conditional-offer-gift{display:flex;align-items:center;gap:0.75rem;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));padding:0.5rem}.s-conditional-offer-gift-thumb{display:inline-flex;height:3.5rem;width:3.5rem;flex-shrink:0;align-items:center;justify-content:center;overflow:hidden;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.s-conditional-offer-gift-image{height:100%;width:100%;object-fit:contain}.s-conditional-offer-gift-body{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.125rem;text-align:start}.s-conditional-offer-gift-name{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;font-size:0.875rem;line-height:1.25rem;font-weight:700;--tw-text-opacity:1;color:rgb(38 38 38 / var(--tw-text-opacity, 1))}.s-conditional-offer-gift-prices{display:flex;align-items:center;gap:0.5rem;font-size:0.75rem;line-height:1rem}.s-conditional-offer-gift-free{font-weight:700;--tw-text-opacity:1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.s-conditional-offer-gift-price{--tw-text-opacity:1;color:rgb(115 115 115 / var(--tw-text-opacity, 1));text-decoration-line:line-through}.s-conditional-offer-tooltip{position:absolute;top:calc(100% + 0.75rem);left:50%;z-index:10;width:min(22rem, calc(100vw - 2rem));border-radius:0.5rem;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1rem;text-align:start;--tw-shadow:5px 10px 30px #2B2D340D;--tw-shadow-colored:5px 10px 30px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.s-conditional-offer-tooltip-title{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-tooltip-description{margin-top:0.25rem;font-size:0.75rem;line-height:1rem;line-height:1.625;--tw-text-opacity:1;color:rgb(82 82 82 / var(--tw-text-opacity, 1))}.s-conditional-offer-tooltip-list{margin:0px;margin-top:0.75rem;display:flex;list-style-type:none;flex-direction:column;gap:1rem;padding:0px}.s-conditional-offer-tier{position:relative;display:flex;align-items:flex-start;gap:0.75rem}.s-conditional-offer-tier-icon{position:relative;display:inline-flex;height:2.25rem;width:2.25rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;font-size:1rem;line-height:1.5rem;line-height:1}.s-conditional-offer-tier-icon-unmet{color:var(--color-primary-dark)}.s-conditional-offer-tier-status{position:absolute;bottom:-0.125rem;display:inline-flex;height:1rem;width:1rem;align-items:center;justify-content:center;border-radius:9999px;border-width:2px;--tw-border-opacity:1;border-color:rgb(255 255 255 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));inset-inline-start:-2px}.s-conditional-offer-tier-status-met{color:var(--color-primary-dark)}.s-conditional-offer-tier-status-unmet{--tw-text-opacity:1;color:rgb(163 163 163 / var(--tw-text-opacity, 1))}.s-conditional-offer-tier-status-check{height:0.75rem;width:0.75rem;flex-shrink:0}.s-conditional-offer-tier-status-lock{height:0.625rem;width:0.625rem;flex-shrink:0}.s-conditional-offer-tier-body{display:flex;min-width:0px;flex-direction:column;gap:0.125rem}.s-conditional-offer-tier-title{font-size:0.75rem;line-height:1rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-tier-text{font-size:0.75rem;line-height:1rem;line-height:1.625;--tw-text-opacity:1;color:rgb(82 82 82 / var(--tw-text-opacity, 1))}.s-conditional-offer-tier-text-met{text-decoration-line:line-through}.s-conditional-offer-skeleton-text{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.375rem}';export{D as salla_conditional_offer}
@@ -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-BmRQjBRH.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:"f4a66dc2916ad42108b551790e1a1a581a55d6b1",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"fa96a2da58ee5be80c79c1a6fff66fbcf49cd87e",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:"379725e546f6eeb670a23166de2a2d829e48da96",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"5939dfacd285738495dda3481d4974775152dc76",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:"2270a07c784a748e7ffaf48164e5cc8b09116878"}))}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-CwwxD-7C.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:"f4a66dc2916ad42108b551790e1a1a581a55d6b1",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"fa96a2da58ee5be80c79c1a6fff66fbcf49cd87e",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:"379725e546f6eeb670a23166de2a2d829e48da96",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"5939dfacd285738495dda3481d4974775152dc76",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:"2270a07c784a748e7ffaf48164e5cc8b09116878"}))}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}
@@ -0,0 +1,4 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import{r as s,f as e,h as t,H as i}from"./p-CwwxD-7C.js";import{S as o}from"./p-BscTeWDc.js";var r;!function(s){s.DEFAULT="default",s.AVAILABILITY="availability"}(r||(r={}));const a=class{constructor(e){s(this,e),this.loadedScopes={[r.DEFAULT]:null,[r.AVAILABILITY]:null},this.translationLoaded=!1,this.mode=r.DEFAULT,this.scopes=[],this.originalScopesList=[],this.isOpenedBefore=salla.storage.get("branch-choosed-before"),this.hasError=!1,this.loading=!1,this.selection="optional",this.searchDisplayLimit=6,this.getFormTitle=()=>{if(this.originalScopesList?.length<2)return"";const s=salla.config.get("store.features")?.includes("multi-countries");return this.mode===r.DEFAULT?salla.lang.get(s?"blocks.scope.shopping_from_another_market":"blocks.scope.shopping_from_another_branch"):salla.lang.get(s?"blocks.scope.search_for_availability_in_other_markets":"blocks.scope.search_for_availability_in_other_branches")},salla.event.on("scopes::open",(({mode:s=null,product_id:e=null}={})=>{this.open(s,e)}))}connectedCallback(){this.langUnsubscribe=salla.lang.subscribe((()=>{this.translationLoaded=!0,e(this)}))}disconnectedCallback(){this.langUnsubscribe?.()}get isNativeApp(){return!!salla.mobile?.isSpaWebview?.()}async close(){return await(this.modal?.close())}async open(s=r.DEFAULT,e=null){return this.isNativeApp?(salla.log("SallaScope:: delegated open to native app"),void salla.mobile?.openScopes?.()):(this.hasError=!1,this.mode=[r.AVAILABILITY,r.DEFAULT].includes(s)?s:r.DEFAULT,this.loading=!this.loadedScopes[this.mode],this.setScopeValues([]),salla.log("SallaScope:: opened"),this.modal.open(),this.loading?await salla.api.withoutNotifier((()=>s==r.AVAILABILITY?salla.scope.getProductAvailability(e):salla.scope.get())).then((e=>{if(s==r.AVAILABILITY)return this.setScopeValues(this.loadedScopes[r.AVAILABILITY]=e.data);this.setScopeValues(this.loadedScopes[this.mode]=e.data.scopes)})).catch((s=>{console.log(s),this.hasError=!0})).finally((()=>{this.modal.stopLoading(),this.loading=!1})):(this.setScopeValues(this.loadedScopes[this.mode]),this.modal.stopLoading()))}async handleSubmit(){let s={id:this.current_scope.id};return this.changeBtn.load(),await salla.scope.change(s).then((()=>{salla.storage.set("branch-choosed-before",!0),salla.storage.set("scope",{type:this.current_scope.type,id:this.current_scope.id}),salla.cart.reset(),window.location.replace(salla.helpers.addParamToUrl("scope",this.current_scope.id))})).catch((s=>console.log(s))).finally((()=>{this.changeBtn.stop()}))}setScopeValues(s){this.scopes=s,this.originalScopesList=s,1==s?.length?(this.current_scope=s[0],this.selected_scope=s[0],this.scopes=[s[0]]):(this.current_scope=s?.find((s=>s.selected)),this.selected_scope=s?.find((s=>s.selected)))}handleSearchFieldTyping(s){let e=s.target.value.toLocaleLowerCase();this.scopes=e?this.originalScopesList.filter((s=>s.name.toLowerCase().includes(e))):this.originalScopesList}handleScopeSelection(s){this.current_scope=this.scopes?.find((e=>e.id==s.target.value))}placeholderContent(){return t("salla-placeholder",{alignment:"center",class:"s-scopes-placeholder"},t("span",{slot:"title"},salla.lang.get("blocks.scope.branch_looking_for_not_found")),t("span",{slot:"description"},salla.lang.get("blocks.scope.our_services_not_available_in_this_branch")))}defaultContent(){return[t("div",{class:"s-scopes-container s-scrollbar"},this.scopes?.map((s=>t("div",{class:"s-scopes-input-wrap","data-selection":this.selection},t("input",{id:`${this.selection} + '_scope_' + ${s.id}`,name:"lang",type:"radio",value:s.id,onChange:s=>this.handleScopeSelection(s),class:"s-scopes-input",checked:!!this.current_scope&&this.current_scope.id==s.id}),t("label",{htmlFor:`${this.selection} + '_scope_' + ${s.id}`,class:"s-scopes-label s-scopes-clickable"},t("span",null,s.icon&&t("img",{src:s.icon,alt:"",loading:"lazy",class:"s-scopes-icon"}),s.name)))))),this.footerContent()]}availabilityContent(){return t("div",{class:"s-scopes-container"},this.scopes?.map((s=>t("div",{class:"s-scopes-input-wrap","data-selection":this.selection},t("h2",{class:{"s-scopes-label":!0,"s-scopes-clickable":this.mode===r.DEFAULT}},t("span",null,s.name)),t("h2",{style:{color:s?.availability?.color},class:`s-scopes-${s?.availability?.key}`},s?.availability?.label)))))}footerContent(){return t("div",{class:"s-scopes-footer"},t("slot",{name:"footer"},t("salla-button",{ref:s=>this.changeBtn=s,disabled:!this.current_scope,onClick:()=>this.handleSubmit(),class:"s-scopes-submit","loader-position":"center",width:"wide"},salla.lang.get("common.elements.confirm"))))}componentWillLoad(){return salla.onReady()}render(){return this.isNativeApp?null:t(i,null,t("salla-modal",{ref:s=>this.modal=s,isClosable:!(!this.isOpenedBefore&&"optional"!=this.selection),class:"s-scopes-modal",isLoading:this.loading,"has-skeleton":!0},this.loading?t("div",{slot:"loading"},t("div",{class:"s-scopes-skeleton"},t("salla-list-tile",{class:"s-scopes-header"},t("div",{slot:"icon",class:"s-scopes-header-icon"},t("salla-skeleton",{type:"circle"})),t("div",{slot:"title",class:"s-scopes-header-title mb-5"},t("salla-skeleton",{height:"15px",width:"50%"})),t("div",{slot:"subtitle",class:"s-scopes-header-subtitle"},t("salla-skeleton",{height:"10px"}),t("salla-skeleton",{height:"10px",width:"75%"}))),t("div",{class:"s-scopes-skeleton-search"},t("salla-skeleton",{height:"10px",width:"50%"}),t("salla-skeleton",{height:"30px",width:"100%"})),t("div",{class:"s-scopes-skeleton-scopes"},t("salla-skeleton",{height:"10px",width:"30%"}),t("salla-skeleton",{height:"10px",width:"25%"}),t("salla-skeleton",{height:"10px",width:"30%"}),t("salla-skeleton",{height:"10px",width:"25%"}),t("salla-skeleton",{height:"10px",width:"30%"}),t("salla-skeleton",{height:"10px",width:"25%"}),t("salla-skeleton",{height:"10px",width:"30%"}),t("salla-skeleton",{height:"10px",width:"25%"})),t("div",{class:"s-scopes-skeleton-btn"},t("salla-skeleton",{height:"40px",width:"100%"})))):[t("salla-list-tile",{class:this.originalScopesList?.length?"s-scopes-header block":"s-hidden"},t("div",{slot:"icon",class:"s-scopes-header-icon",innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>store-alt</title>\n<path d="M6.667 24h5.333c0.736 0 1.333-0.596 1.333-1.333s-0.597-1.333-1.333-1.333h-5.333c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333zM31.86 10.071l-4-8c-0.227-0.452-0.688-0.737-1.193-0.737h-21.333c-0.505 0-0.967 0.285-1.193 0.737l-4 8c-0.092 0.184-0.14 0.389-0.14 0.596v18.667c0 0.737 0.597 1.333 1.333 1.333h29.333c0.736 0 1.333-0.596 1.333-1.333v-18.667c0-0.207-0.048-0.412-0.14-0.596zM6.157 4h19.685l3.333 6.667h-26.352zM24 28h-5.333v-9.333h5.333zM29.333 28h-2.667v-10.667c0-0.737-0.597-1.333-1.333-1.333h-8c-0.736 0-1.333 0.596-1.333 1.333v10.667h-13.333v-14.667h26.667zM6.667 18.667h5.333c0.736 0 1.333-0.596 1.333-1.333s-0.597-1.333-1.333-1.333h-5.333c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333z"></path>\n</svg>\n'}),t("div",{slot:"title",class:"s-scopes-header-title"},salla.lang.get("blocks.scope.you_are_browse_store_from")),t("div",{slot:"subtitle",class:"s-scopes-header-subtitle"},this.selected_scope?this.selected_scope.name:"")),t("div",{class:"s-scopes-wrap"},!!this.originalScopesList?.length&&t("h4",{class:"s-scopes-title"},this.getFormTitle()),this.originalScopesList?.length>this.searchDisplayLimit?t("div",{class:"s-scopes-search-wrapper"},t("div",{class:"s-scopes-search-icon",innerHTML:o}),t("input",{type:"text",class:"s-scopes-search-input",onInput:s=>this.handleSearchFieldTyping(s),enterkeyhint:"search",placeholder:salla.lang.get("blocks.scope.searching_for_a_branch")})):"",this.hasError||!this.originalScopesList?.length&&this.mode!==r.AVAILABILITY?this.placeholderContent():this.mode===r.DEFAULT?this.defaultContent():this.availabilityContent())]))}async componentDidLoad(){await Salla.hooks.registerComponent("salla-scopes",this),salla.config.isMobileApp()||this.isNativeApp||this.isOpenedBefore||"mandatory"!=this.selection||this.open()}};a.style='/*!twlt*/.s-scopes-availability-content{display:flex;justify-content:center;align-items:center}.s-scopes-placeholder{flex:0 0 85%}.mb-5{margin-bottom:1.25rem}.block{display:block}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.s-hidden{display:none}.btn{display:inline-flex;flex:1 1 0%;align-items:center;justify-content:center;white-space:nowrap;border-radius:0.375rem;padding-left:1.5rem;padding-right:1.5rem;padding-bottom:0.625rem;padding-top:0.5rem;font-size:0.875rem;line-height:1.25rem;font-weight:700;transition-property:color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.btn:hover{opacity:0.8}.s-hidden{display:none}.s-scrollbar::-webkit-scrollbar{width:5px}.s-scrollbar::-webkit-scrollbar-track{background-color:#eee}.s-scrollbar::-webkit-scrollbar-thumb{background-color:var(--color-primary);border-radius:10px;-webkit-border-radius:10px;-moz-border-radius:10px;-ms-border-radius:10px;-o-border-radius:10px}.s-scopes-title{margin-bottom:0.75rem}.s-scopes-header{margin-bottom:0.5rem;display:block;text-align:center}.s-scopes-header-icon{margin:auto;display:flex;height:5rem;width:5rem;align-items:center;justify-content:center;border-radius:9999px;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(252 252 252 / var(--tw-bg-opacity, 1))}.s-scopes-header-icon svg{height:2rem;fill:var(--color-primary)}.s-scopes-header-title{font-size:1.125rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-scopes-header-subtitle{text-align:left;font-size:1.25rem;line-height:1.75rem}.s-scopes-header-subtitle:where([dir="rtl"],[dir="rtl"] *){text-align:right}.s-scopes-search-wrapper{position:relative;width:100%}.s-scopes-search-icon{pointer-events:none;position:absolute;top:0px;bottom:0px;left:0px;display:flex;align-items:center;padding-left:0.75rem}.s-scopes-search-icon:where([dir="rtl"],[dir="rtl"] *){left:auto;right:0px;padding-left:0px;padding-right:0.75rem}.s-scopes-search-icon svg{height:1.25rem;width:1.25rem;fill:#9ca3af}.s-scopes-search-input{display:block;width:100%;border-radius:var(--s-radius, 0.25rem);border-width:1px;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding:0.625rem;padding-left:2.5rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-scopes-search-input:focus{--tw-ring-color:var(--color-primary)}.s-scopes-search-input:where([dir="rtl"],[dir="rtl"] *){padding-left:0px;padding-right:2.5rem}.s-scopes-input-wrap{margin-bottom:1.25rem;display:flex;align-items:center}.s-scopes-input-wrap:last-child{margin-bottom:0px}.s-scopes-input{height:1rem;width:1rem;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));color:var(--color-primary)}.s-scopes-input:focus{--tw-ring-color:var(--color-primary)}.s-scopes-input:where([dir="ltr"],[dir="ltr"] *){margin-right:0.75rem}.s-scopes-input:where([dir="rtl"],[dir="rtl"] *){margin-left:0.75rem}.s-scopes-icon{display:inline-block;height:2rem;width:2rem;border-radius:var(--s-radius, 0.25rem);object-fit:contain;vertical-align:middle}.s-scopes-icon:where([dir="ltr"],[dir="ltr"] *){margin-right:0.75rem}.s-scopes-icon:where([dir="rtl"],[dir="rtl"] *){margin-left:0.75rem}.s-scopes-label{display:flex;flex-grow:1;align-items:center;justify-content:space-between;font-size:1rem;line-height:1.5rem;font-weight:500;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-scopes-select{height:2.5rem;width:100%;appearance:none;border-radius:0.375rem;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));padding-left:1rem;padding-right:1rem;font-size:0.875rem;line-height:1.25rem;transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-scopes-select:focus{border-color:var(--color-primary)}.s-scopes-container{margin-top:1.25rem;max-height:300px;overflow-y:auto;padding-left:0.5rem}.s-scopes-container:where([dir="rtl"],[dir="rtl"] *){padding-left:0px;padding-right:0.5rem}.s-scopes-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}.s-scopes-is-closed{opacity:0.5}.s-scopes-closed-badge{--tw-text-opacity:1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.s-scopes-clickable{cursor:pointer}.s-scopes-submit{margin-top:1.5rem;height:auto}.s-scopes-color-red{--tw-text-opacity:1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.s-scopes-color-green{--tw-text-opacity:1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.s-scopes-color-gray{--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-scopes-hidden{display:none}.s-scopes-input-wrap.is-hidden-branch{display:none}.s-scopes-wrap{display:flex;max-height:350px;flex-direction:column}.s-scopes-wrap .s-placeholder-wrapper{display:flex;height:12rem;flex-direction:column;align-items:center;justify-content:center}.s-scopes-footer{margin-top:auto}.s-scopes-modal .s-modal-header{display:block !important}.s-scopes-skeleton .s-list-tile-item-content{display:block;width:100%}.s-scopes-skeleton .s-scopes-header-title>salla-skeleton{margin-top:0.75rem;margin-bottom:0.75rem;display:block}.s-scopes-skeleton .s-scopes-header-subtitle>salla-skeleton{margin-bottom:0.75rem;display:block}.s-scopes-skeleton .s-scopes-skeleton-scopes>salla-skeleton{margin-bottom:1.25rem;display:block}.s-scopes-skeleton .s-scopes-skeleton-search{margin-top:2rem;margin-bottom:2rem}.s-scopes-skeleton .s-scopes-skeleton-search>salla-skeleton{margin-bottom:0.75rem;display:block}.s-scopes-skeleton .s-list-tile-item-icon{margin-right:2rem}.s-scopes-skeleton .s-list-tile-item-icon:where([dir="rtl"],[dir="rtl"] *){margin-right:0px;margin-left:2rem}.s-scopes-skeleton-btn{margin-top:2rem}';export{a as salla_scopes}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r,h as e}from"./p-BmRQjBRH.js";function t(r){var e,a,s="";if("string"==typeof r||"number"==typeof r)s+=r;else if("object"==typeof r)if(Array.isArray(r))for(e=0;e<r.length;e++)r[e]&&(a=t(r[e]))&&(s&&(s+=" "),s+=a);else for(e in r)r[e]&&(s&&(s+=" "),s+=e);return s}const a=r=>"boolean"==typeof r?"".concat(r):0===r?"0":r,s=function(){for(var r,e,a=0,s="";a<arguments.length;)(r=arguments[a++])&&(e=t(r))&&(s&&(s+=" "),s+=e);return s},i=(o="s-badge-base",l={variants:{size:{xs:"s-badge-xs",sm:"s-badge-sm",md:"s-badge-md"},bg:{transparent:"s-badge-transparent",light:"s-badge-light","primary-100":"s-badge-primary-100"},color:{black:"s-badge-black","primary-900":"s-badge-color-primary-900"}}},r=>{var e;if(null==(null==l?void 0:l.variants))return s(o,null==r?void 0:r.class,null==r?void 0:r.className);const{variants:t,defaultVariants:i}=l,n=Object.keys(t).map((e=>{const s=null==r?void 0:r[e],o=null==i?void 0:i[e];if(null===s)return null;const l=a(s)||a(o);return t[e][l]})),d=r&&Object.entries(r).reduce(((r,e)=>{let[t,a]=e;return void 0===a||(r[t]=a),r}),{}),c=null==l||null===(e=l.compoundVariants)||void 0===e?void 0:e.reduce(((r,e)=>{let{class:t,className:a,...s}=e;return Object.entries(s).every((r=>{let[e,t]=r;return Array.isArray(t)?t.includes({...i,...d}[e]):{...i,...d}[e]===t}))?[...r,t,a]:r}),[]);return s(o,n,c,null==r?void 0:r.class,null==r?void 0:r.className)});var o,l;const n=class{constructor(e){r(this,e),this.size="sm",this.color="black",this.bg="light"}render(){return e("div",{key:"7c7196d49621a58192820725ab40d906344983d1",class:i({size:this.size,bg:this.bg,color:this.color})},e("slot",{key:"7a39f5d916e80809f795b5cc880f1d31238fa7c5"}))}};n.style='/*!twlt*/.s-badge-base{display:flex;max-width:max-content;align-items:center}.s-badge-base>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(0.5rem * var(--tw-space-x-reverse));margin-left:calc(0.5rem * calc(1 - var(--tw-space-x-reverse)))}.s-badge-base{white-space:nowrap;border-radius:0.375rem;padding-left:0.5rem;padding-right:0.5rem;padding-top:0.25rem;padding-bottom:0.25rem;font-weight:500;--tw-text-opacity:1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.s-badge-base:where([dir="rtl"],[dir="rtl"] *)>:not([hidden])~:not([hidden]){--tw-space-x-reverse:1}.s-badge-xs{font-size:0.75rem;line-height:1rem}.s-badge-xs svg{height:0.75rem;width:0.75rem}.s-badge-sm{font-size:0.875rem;line-height:1.25rem}.s-badge-sm svg{height:1rem;width:1rem}.s-badge-md{font-size:1rem;line-height:1.5rem}.s-badge-md svg{height:1.25rem;width:1.25rem}.s-badge-transparent{background-color:transparent}.s-badge-light{--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.s-badge-primary-100{background-color:color-mix(in srgb,var(--color-primary) 20%,white 80%)}.s-badge-color-black{--tw-text-opacity:1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.s-badge-color-primary-900{color:color-mix(in srgb,var(--color-primary) 45%,black 55%)}.s-badge-color-primary-900 svg{fill:currentColor}.s-badge-black{--tw-text-opacity:1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}';export{n as salla_badge}
4
+ import{r,h as e}from"./p-CwwxD-7C.js";function t(r){var e,a,s="";if("string"==typeof r||"number"==typeof r)s+=r;else if("object"==typeof r)if(Array.isArray(r))for(e=0;e<r.length;e++)r[e]&&(a=t(r[e]))&&(s&&(s+=" "),s+=a);else for(e in r)r[e]&&(s&&(s+=" "),s+=e);return s}const a=r=>"boolean"==typeof r?"".concat(r):0===r?"0":r,s=function(){for(var r,e,a=0,s="";a<arguments.length;)(r=arguments[a++])&&(e=t(r))&&(s&&(s+=" "),s+=e);return s},i=(o="s-badge-base",l={variants:{size:{xs:"s-badge-xs",sm:"s-badge-sm",md:"s-badge-md"},bg:{transparent:"s-badge-transparent",light:"s-badge-light","primary-100":"s-badge-primary-100"},color:{black:"s-badge-black","primary-900":"s-badge-color-primary-900"}}},r=>{var e;if(null==(null==l?void 0:l.variants))return s(o,null==r?void 0:r.class,null==r?void 0:r.className);const{variants:t,defaultVariants:i}=l,n=Object.keys(t).map((e=>{const s=null==r?void 0:r[e],o=null==i?void 0:i[e];if(null===s)return null;const l=a(s)||a(o);return t[e][l]})),d=r&&Object.entries(r).reduce(((r,e)=>{let[t,a]=e;return void 0===a||(r[t]=a),r}),{}),c=null==l||null===(e=l.compoundVariants)||void 0===e?void 0:e.reduce(((r,e)=>{let{class:t,className:a,...s}=e;return Object.entries(s).every((r=>{let[e,t]=r;return Array.isArray(t)?t.includes({...i,...d}[e]):{...i,...d}[e]===t}))?[...r,t,a]:r}),[]);return s(o,n,c,null==r?void 0:r.class,null==r?void 0:r.className)});var o,l;const n=class{constructor(e){r(this,e),this.size="sm",this.color="black",this.bg="light"}render(){return e("div",{key:"7c7196d49621a58192820725ab40d906344983d1",class:i({size:this.size,bg:this.bg,color:this.color})},e("slot",{key:"7a39f5d916e80809f795b5cc880f1d31238fa7c5"}))}};n.style='/*!twlt*/.s-badge-base{display:flex;max-width:max-content;align-items:center}.s-badge-base>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(0.5rem * var(--tw-space-x-reverse));margin-left:calc(0.5rem * calc(1 - var(--tw-space-x-reverse)))}.s-badge-base{white-space:nowrap;border-radius:0.375rem;padding-left:0.5rem;padding-right:0.5rem;padding-top:0.25rem;padding-bottom:0.25rem;font-weight:500;--tw-text-opacity:1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.s-badge-base:where([dir="rtl"],[dir="rtl"] *)>:not([hidden])~:not([hidden]){--tw-space-x-reverse:1}.s-badge-xs{font-size:0.75rem;line-height:1rem}.s-badge-xs svg{height:0.75rem;width:0.75rem}.s-badge-sm{font-size:0.875rem;line-height:1.25rem}.s-badge-sm svg{height:1rem;width:1rem}.s-badge-md{font-size:1rem;line-height:1.5rem}.s-badge-md svg{height:1.25rem;width:1.25rem}.s-badge-transparent{background-color:transparent}.s-badge-light{--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.s-badge-primary-100{background-color:color-mix(in srgb,var(--color-primary) 20%,white 80%)}.s-badge-color-black{--tw-text-opacity:1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.s-badge-color-primary-900{color:color-mix(in srgb,var(--color-primary) 45%,black 55%)}.s-badge-color-primary-900 svg{fill:currentColor}.s-badge-black{--tw-text-opacity:1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}';export{n as salla_badge}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,h as e,H as r}from"./p-BmRQjBRH.js";import{g as i,a as o,c as a,u as d,r as s,m as l,b as n,f as c,d as p,e as h,h as m,i as g}from"./p-C8xwacGT.js";import"./p-CoQJOPRz.js";const w=class{constructor(e){t(this,e),this.loading=!0,this.saveLoading=!1,this.payload={items:{update:[],remove:[],add:[]}},this.expired=!1,this.editPreview=null,this.productSearchQuery="",this.productsListKey=0,this.productsListSource="latest",this.productsListSourceValue="",this.selectedProductToAdd=null,this.addProductQuantity=1,this.addProductLoading=!1,this.addProductConfirmLoading=!1,this.mobileProductsModalMounted=!1,this.isMobileViewport=!1,this.isRTL=!0,this.mobileProductsListLoading=!1,this.confirming=!1,this.handleMobileProductSelected=t=>{t.stopPropagation(),this.handleProductSelected(t)},this.productsPanelMobileQuery="(max-width: 768px)",this.handleProductsPanelViewportChange=t=>{this.isMobileViewport=t.matches},this.hasProductTypeFilter=t=>{const e=t.indexOf("?"),r=(e>=0?t.slice(e+1):t).split("#")[0];return Array.from(new URLSearchParams(r)).some((([t,e])=>"product"===e&&/^filters\[types\](?:\[(?:\d*)\])?$/.test(t)))},this.hasExcludedCategoriesFilter=t=>{const e=t.indexOf("?"),r=(e>=0?t.slice(e+1):t).split("#")[0];return Array.from(new URLSearchParams(r)).some((([t])=>/^filters(?:\[|%5B)excluded_categories(?:\]|%5D)(?:\[|%5B)(?:\d*)(?:\]|%5D)$/.test(t)))},this.normalizeProductsListArrayParams=t=>t.replace(/(^|[?&])(includes|source_value|filters(?:\[|%5B)[^&=\]%]+?(?:\]|%5D))(\[|%5B)\d+(\]|%5D)(?==)/gi,((t,e,r,i,o)=>`${e}${r}${i}${o}`)),this.handleBeforeBuildListUrl=t=>{if("salla-order-edit-product-card"!==t.component?.productCardComponent||"string"!=typeof t.url)return;t.url=this.normalizeProductsListArrayParams(t.url),this.hasProductTypeFilter(t.url)||(t.url+=(t.url.includes("?")?"&":"?")+"filters[types][]=product");const e=this.getParsedExcludedCategories();if(e.length>0&&!this.hasExcludedCategoriesFilter(t.url)){const r=e.map((t=>`filters[excluded_categories][]=${encodeURIComponent(t)}`)).join("&");t.url+=`${t.url.includes("?")?"&":"?"}${r}`}},this.defaultProductsListSource="latest",this.debouncedProductSearch=salla.helpers.debounce((t=>this.applyProductSearch(t)),500),salla.onReady((()=>{this.isRTL=salla.config.get("theme.is_rtl",!0)}))}getParsedExcludedCategories(){if(!this.excludedCategories)return[];try{const t="string"==typeof this.excludedCategories?JSON.parse(this.excludedCategories):this.excludedCategories;return Array.isArray(t)?t.filter((t=>Number.isInteger(t)&&t>0)):[]}catch{return[]}}async componentWillLoad(){this.setupProductsPanelViewportQuery(),await salla.onReady(),this.unregisterBeforeBuildListUrlHook=salla.hooks.registerHook("salla-products-list","beforeBuildListUrl",this.handleBeforeBuildListUrl),this.loadFromProp(),this.startExpiryCheck()}disconnectedCallback(){clearInterval(this.expiryInterval),this.unregisterBeforeBuildListUrlHook?.(),this.productsPanelViewportQuery?.removeEventListener("change",this.handleProductsPanelViewportChange),this.mobileProductsModal?.removeEventListener("orderEditProductSelected",this.handleMobileProductSelected)}setupProductsPanelViewportQuery(){"undefined"!=typeof window&&"function"==typeof window.matchMedia&&(this.productsPanelViewportQuery=window.matchMedia(this.productsPanelMobileQuery),this.isMobileViewport=this.productsPanelViewportQuery.matches,this.productsPanelViewportQuery.addEventListener("change",this.handleProductsPanelViewportChange))}startExpiryCheck(){const t=this.order?.customer_editing_session?.ends_at;if(!t)return;const e=()=>new Date(`${t.replace(" ","T")}+03:00`).getTime()<=Date.now();e()?this.expired=!0:this.expiryInterval=setInterval((()=>{e()&&(this.expired=!0,clearInterval(this.expiryInterval))}),1e3)}loadFromProp(){try{if(!this.orderData)return void(this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود"));const t="string"==typeof this.orderData?JSON.parse(this.orderData):this.orderData;this.order={...t,items:t.items.map((t=>({...t,selectedOptions:i(t)})))}}catch(t){this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود")}finally{this.loading=!1}}applyProductSearch(t){const e=t?.trim()||"",r=e?"search":this.defaultProductsListSource,i="search"===r?JSON.stringify(e):"";this.productsListSource===r&&this.productsListSourceValue===i||(this.productsListSource=r,this.productsListSourceValue=i,this.productsListKey+=1)}handleProductSearch(t){const e=t.target?.value||"";this.productSearchQuery=e,this.debouncedProductSearch(e)}getProductsListKey(t){return`${t}-${this.productsListSource}-${this.productsListSourceValue}-${this.productsListKey}`}handleMobileProductsScroll(t){const e=t.currentTarget;if(e.scrollHeight-e.scrollTop-e.clientHeight>200||this.mobileProductsListLoading)return;const r=e.querySelector("salla-products-list");r&&(this.mobileProductsListLoading=!0,r.loadMore().finally((()=>{this.mobileProductsListLoading=!1})))}waitForNextFrame(){return new Promise((t=>requestAnimationFrame((()=>t(void 0)))))}async openMobileProductsModal(){this.mobileProductsModalMounted||(this.mobileProductsModalMounted=!0,await this.waitForNextFrame()),await(this.mobileProductsModal?.open?.())}setMobileProductsModal(t){this.mobileProductsModal!==t&&(this.mobileProductsModal?.removeEventListener("orderEditProductSelected",this.handleMobileProductSelected),this.mobileProductsModal=t,this.mobileProductsModal?.addEventListener("orderEditProductSelected",this.handleMobileProductSelected))}resetAddProductDrawer(){this.selectedProductToAdd=null,this.addProductQuantity=1,this.addProductLoading=!1,this.addProductConfirmLoading=!1,this.addProductOptions=null}getAddProductMaxQuantity(t=this.selectedProductToAdd){return o(t)}clampAddProductQuantity(t,e=this.selectedProductToAdd){return a(t,this.getAddProductMaxQuantity(e))}getApiErrorMessage(t){return t?.response?.data?.error?.message||t?.response?.data?.message}notifyApiError(t){const e=this.getApiErrorMessage(t);e&&salla.notify.error(e)}async validateAddProductOptions(){return!this.selectedProductToAdd?.options?.length||!!this.addProductOptions&&(await(this.addProductOptions.validateAndScroll?.())??await(this.addProductOptions.reportValidity?.())??!1)}updateLocalOrderItem(t,e,r,i){this.order={...this.order,items:d(this.order.items,t,e,r,i)}}removeLocalOrderItem(t){this.order={...this.order,items:s(this.order.items,t)}}setPayloadItems(t){this.payload={...this.payload,items:l(this.payload.items,t)}}handleAddProductQuantityChange(t){const e=t.detail,r=e?.quantity??parseInt(t.target?.value,10);isNaN(r)||r<1||(this.addProductQuantity=this.clampAddProductQuantity(r))}async handleProductSelected(t){const e=t.detail?.product;if(e?.id&&!this.addProductLoading){this.addProductLoading=!0;try{this.selectedProductToAdd=n(e),this.addProductQuantity=1,await(this.mobileProductsModal?.close?.()),await this.waitForNextFrame(),await(this.addProductDrawer?.open?.())}catch(t){this.notifyApiError(t)}finally{this.addProductLoading=!1}}}async confirmAddProduct(){if(this.selectedProductToAdd?.id&&!this.addProductConfirmLoading){this.addProductConfirmLoading=!0;try{const t=this.getAddProductMaxQuantity(),e=this.clampAddProductQuantity(this.addProductQuantity);e!==this.addProductQuantity&&(this.addProductQuantity=e);const r=this.addProductOptions;if(!await this.validateAddProductOptions())return void salla.notify.error(salla.lang.getWithDefault("common.messages.required_fields","يرجى تعبئة الحقول المطلوبة"));const i=await(r?.getSelectedOptionsData?.())||{},o=await(r?.getOptionsData?.())||this.selectedProductToAdd.options||[],d=c(this.order?.items,this.selectedProductToAdd.id,i);if(d){const r=a(d.quantity+e,t);return this.updateLocalOrderItem(d.id,r,o,i),this.setPayloadItems(d.isNew?{add:p(this.payload.items.add,d.id,r,i)}:{update:h(this.payload.items.update,d.id,r,i)}),void await(this.addProductDrawer?.close?.())}const s=m(this.selectedProductToAdd,e,o,i),l={itemId:s.id,product_id:this.selectedProductToAdd.id,quantity:e,options:i};this.order={...this.order,items:[...this.order.items,s]},this.setPayloadItems({add:[...this.payload.items.add,l]}),await(this.addProductDrawer?.close?.())}catch(t){this.notifyApiError(t)}finally{this.addProductConfirmLoading=!1}}}handleItemUpdated(t){if(!this.order)return;const{itemId:e,quantity:r,options:i,optionDefinitions:d}=t.detail,s=this.order.items.find((t=>t.id===e));if(!s)return;const l=a(r,o(s.product));if(s.isNew)return this.setPayloadItems({add:p(this.payload.items.add,e,l,i)}),void this.updateLocalOrderItem(e,l,d,i);this.setPayloadItems({update:h(this.payload.items.update,e,l,i??{})}),this.updateLocalOrderItem(e,l,d,i)}handleItemRemoved(t){if(!this.order)return;if(this.order.items.length<=1)return void salla.notify.error(salla.lang.getWithDefault("pages.orders.order_cannot_be_empty","لا يمكن إزالة جميع المنتجات من الطلب"));const{itemId:e}=t.detail,r=this.order.items.find((t=>t.id===e));if(r){if(r.isNew)return this.setPayloadItems({add:this.payload.items.add.filter((t=>t.itemId!==e))}),void this.removeLocalOrderItem(e);this.setPayloadItems({update:this.payload.items.update.filter((t=>t.id!==e)),remove:[...this.payload.items.remove,e]}),this.removeLocalOrderItem(e)}}get hasChanges(){return this.payload.items.update.length>0||this.payload.items.remove.length>0||this.payload.items.add.length>0}async saveOrder(){if(this.hasChanges){this.saveLoading=!0;try{const t=await salla.order.api.editOrder(this.orderId,g(this.payload));this.editPreview=t?.data?.data||t?.data,await(this.saveModal?.open?.())}catch(t){this.notifyApiError(t)}finally{this.saveLoading=!1}}}navigateToOrder(){const t=new URL(window.location.href);t.pathname=t.pathname.replace(/\/edit\/?$/,""),t.search="",window.location.href=t.href}handleConfirm(){this.confirming=!0,this.editPreview?.payment?.required&&this.editPreview.payment.payment_url?window.location.href=this.editPreview.payment.payment_url:this.navigateToOrder()}returnToOrderDetails(){this.confirming=!0,this.navigateToOrder()}getConfirmButtonIconClass(){return this.isRTL?"sicon-keyboard_arrow_left":"sicon-keyboard_arrow_right"}async cancelEditSession(){try{await salla.order.api.cancelEditSession(this.orderId),this.navigateToOrder()}catch(t){this.notifyApiError(t)}}renderProductsPanel(){const t=salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب");return e("section",{class:"s-order-edit-products-panel"},e("div",{class:"s-order-edit-products-header"},e("h2",{class:"s-order-edit-products-title"},t)),this.renderProductsPickerContent("panel"))}renderProductsPickerContent(t){return e("div",{class:{"s-order-edit-products-picker":!0,"s-order-edit-products-modal-content":"modal"===t}},e("label",{class:"s-order-edit-products-search"},e("i",{class:"sicon-search"}),e("input",{type:"search",class:"s-order-edit-products-search-input",placeholder:salla.lang.getWithDefault("pages.products.search_for_product","ابحث عن منتج"),value:this.productSearchQuery,onInput:t=>this.handleProductSearch(t)})),e("div",{class:"s-order-edit-products-list",onScroll:"modal"===t?t=>this.handleMobileProductsScroll(t):void 0},e("salla-products-list",{key:this.getProductsListKey(t),includes:["options"],source:this.productsListSource,"source-value":this.productsListSourceValue,autoload:!0,"product-card-component":"salla-order-edit-product-card"})))}renderMobileProductsModal(){return e("salla-modal",{ref:t=>this.setMobileProductsModal(t),width:"md",class:"s-order-edit-mobile-products-modal","modal-title":salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب"),onModalVisibilityChanged:t=>{t.detail||(this.mobileProductsModalMounted=!1)}},this.mobileProductsModalMounted?this.renderProductsPickerContent("modal"):null)}renderAddProductDrawer(){const t=this.selectedProductToAdd,r=t?.name||salla.lang.getWithDefault("common.elements.product","منتج"),i=t?.price,o=this.getAddProductMaxQuantity(t),a=t?`order-edit-add-${t.id}`:"order-edit-add",d={value:this.clampAddProductQuantity(this.addProductQuantity,t)};return o&&(d.max=o),e("salla-modal",{ref:t=>this.addProductDrawer=t,width:"md","modal-title":salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب"),onModalVisibilityChanged:t=>{t.detail||this.resetAddProductDrawer()}},e("div",{class:"s-order-edit-add-modal"},this.addProductLoading?e("div",{class:"s-order-edit-add-modal-loading"},e("salla-loading",null)):t?e("div",{class:"s-order-edit-add-modal-content"},e("div",{class:"s-order-edit-add-modal-header"},e("div",{class:"s-order-edit-add-modal-media"},t.image?.url&&e("img",{src:t.image.url,alt:t.image.alt||r,class:"s-order-edit-add-modal-image"}),e("div",{class:"s-order-edit-add-modal-details"},e("h3",{class:"s-order-edit-add-modal-name"},r),null!=i&&e("span",{class:"s-order-edit-add-modal-price",innerHTML:salla.money(i)})))),e("div",{class:"s-order-edit-add-modal-quantity"},e("h3",{class:"s-order-edit-add-modal-section-title"},salla.lang.getWithDefault("common.elements.quantity","الكمية")),e("div",{class:"s-order-edit-add-modal-quantity-input"},e("salla-quantity-input",{...d,onChange:t=>this.handleAddProductQuantityChange(t)}))),t.options?.length>0&&e("form",{onSubmit:t=>t.preventDefault()},e("salla-product-options",{ref:t=>this.addProductOptions=t,"product-id":t.id,"unique-key":a,options:JSON.stringify(t.options),key:`${a}-options`})),e("div",{class:"s-order-edit-add-modal-actions"},e("salla-button",{onClick:()=>this.confirmAddProduct(),loading:this.addProductConfirmLoading},salla.lang.getWithDefault("common.elements.confirm","تأكيد")),e("salla-button",{color:"gray",fill:"outline",onClick:()=>this.addProductDrawer?.close?.()},salla.lang.getWithDefault("common.elements.cancel","الغاء")))):null))}renderSaveModal(){const t=this.editPreview,r=t?.totals?.remaining_amount?.amount>0,i=t?.totals?.refund_amount?.amount>0,o=t?.totals?.tax?.amount?.amount;return e("salla-modal",{ref:t=>this.saveModal=t,width:"md",isClosable:!1,onModalVisibilityChanged:async t=>{t.detail||(this.editPreview=null,this.confirming||await this.cancelEditSession(),this.confirming=!1)}},e("div",{class:"s-order-edit-modal"},e("h2",{class:"s-order-edit-modal-title"},salla.lang.getWithDefault("pages.orders.edit_summary_title","ملخص الطلب بعد التعديل")),e("p",{class:"s-order-edit-modal-subtitle"},salla.lang.getWithDefault("pages.orders.cart_edits_saved","Your cart edits have been saved")),t?.items?.length>0&&e("div",{class:"s-order-edit-modal-items"},t.items.map((t=>{const r=this.order?.items?.find((e=>e.id==t.id)),i=r?.product?.image?.url,o=t.options?.join("/ ");return e("div",{class:"s-order-edit-modal-item"},e("div",{class:"s-order-edit-modal-item-start"},i&&e("img",{src:i,alt:t.name,class:"s-order-edit-modal-item-image"}),e("div",null,e("p",{class:"s-order-edit-modal-item-name"},t.name),o&&e("span",{class:"s-order-edit-modal-item-options"},o))),e("div",{class:"s-order-edit-modal-item-end"},e("span",{class:"s-order-edit-modal-item-quantity",dir:"ltr",innerHTML:t.quantity+" x "+t.price.amount}),e("span",{class:"s-order-edit-modal-item-price",innerHTML:salla.money(t.price.amount*t.quantity)})))}))),t?.totals?.updated_products_total&&e("div",{class:"s-order-edit-modal-row"},e("span",{class:"s-order-edit-modal-row-label"},salla.lang.getWithDefault("pages.orders.modified_products_total","مجموع المنتجات المعدلة")),e("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(t.totals.updated_products_total.amount)})),o>0&&e("div",{class:"s-order-edit-modal-row"},e("span",{class:"s-order-edit-modal-tax-label"},e("i",{class:"sicon-info-circle s-order-edit-modal-tax-icon"}),salla.lang.getWithDefault("pages.orders.vat","ضريبة القيمة المضافة")),e("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(o)})),t?.totals?.total&&e("div",{class:"s-order-edit-modal-total"},e("span",{class:"s-order-edit-modal-total-label"},salla.lang.getWithDefault("pages.orders.order_total","اجمالي الطلب")),e("span",{class:"s-order-edit-modal-total-value",innerHTML:salla.money(t.totals.total.amount)})),i&&e("div",{class:"s-order-edit-modal-refund"},e("i",{class:"sicon-info-circle s-order-edit-modal-refund-icon"}),e("p",{class:"s-order-edit-modal-refund-text"},salla.lang.getWithDefault("pages.orders.refund_message","سيتم تحويل فارق المبلغ على نفس وسيلة الدفع"))),e("div",{class:"s-order-edit-modal-btn-wrapper"},e("salla-button",{onClick:()=>this.handleConfirm()},r?salla.lang.getWithDefault("pages.orders.pay_difference","دفع فارق المبلغ"):i?salla.lang.getWithDefault("pages.orders.confirm_and_receive_difference","تأكيد واستلام فارق المبلغ"):salla.lang.getWithDefault("pages.orders.confirm_changes","تأكيد التعديلات"),e("i",{class:`${this.getConfirmButtonIconClass()} s-order-edit-modal-btn-icon`})),e("salla-button",{color:"gray",fill:"outline",onClick:()=>this.returnToOrderDetails()},salla.lang.getWithDefault("pages.orders.back_to_order_details","العودة إلى تفاصيل الطلب")))))}render(){if(this.loading)return e(r,null,e("salla-loading",null));if(this.expired)return e(r,null,e("div",{class:"s-order-edit-expired"},e("p",null,salla.lang.getWithDefault("pages.orders.edit_session_expired","انتهت مدة التعديل المتاحة")),e("salla-button",{onClick:()=>this.navigateToOrder()},salla.lang.getWithDefault("pages.orders.back_to_order","العودة إلى تفاصيل الطلب"))));if(this.error||!this.order)return e(r,null,e("div",{class:"s-order-edit-no-content-placeholder"},e("i",{class:"sicon-shopping-bag icon"}),e("p",null,this.error)));const t=this.order.items&&this.order.items.length>0,i=this.order.customer_editing_session?.ends_at;return e(r,null,i&&e("div",{class:"s-order-edit-timer-wrapper"},e("salla-count-down",{prefixText:salla.lang.getWithDefault("pages.orders.edit_within","يمكنك التعديل خلال"),date:i,horizontal:!0,withButton:!0,autoSegments:!0,labeled:!1,size:"sm",color:"primary"})),e("div",{class:"s-order-edit-layout"},this.isMobileViewport?null:this.renderProductsPanel(),e("section",{class:"s-order-edit-order-panel"},e("div",{class:"s-order-edit-items-wrapper"},e("h2",{class:"s-order-edit-items-title"},salla.lang.getWithDefault("pages.orders.order_products","منتجات الطلب")),t?this.order.items.map(((t,r)=>[e("salla-order-edit-item",{key:t.id,item:t,orderId:this.orderId}),r<this.order.items.length-1?e("div",{class:"s-order-edit-items-divider"}):null])):e("div",{class:"s-order-edit-no-content-placeholder"},e("i",{class:"sicon-shopping-bag icon"}),e("p",null,salla.lang.getWithDefault("common.elements.no_items","لا توجد عناصر")))),e("div",{class:"s-order-edit-actions"},e("salla-button",{class:"s-order-edit-mobile-products-trigger",color:"gray",size:"small",fill:"outline",onClick:()=>this.openMobileProductsModal()},e("i",{class:"sicon-add s-order-edit-mobile-products-trigger-icon"}),salla.lang.getWithDefault("pages.orders.add_product","إضافة منتج")),e("salla-button",{onClick:()=>this.saveOrder(),loading:this.saveLoading,size:"small",disabled:!this.hasChanges},salla.lang.getWithDefault("pages.orders.save_changes","حفظ التعديلات")),e("salla-button",{size:"small",color:"gray",fill:"outline",onClick:()=>this.cancelEditSession()},salla.lang.getWithDefault("common.elements.cancel","الغاء"))))),this.renderMobileProductsModal(),this.renderAddProductDrawer(),this.renderSaveModal())}};w.style='/*!twlt*/:host{display:block}.outline{outline-style:solid}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.s-order-edit-timer-wrapper{margin-bottom:1rem;display:flex;justify-content:center}.s-order-edit-layout{display:grid;align-items:flex-start;gap:1.5rem;grid-template-columns:minmax(0,1.35fr) minmax(20rem,1fr)}@media (max-width: 1080px){.s-order-edit-layout{grid-template-columns:minmax(0, 1fr)}}.s-order-edit-products-panel{border-radius:1rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.5rem}@media (max-width: 768px){.s-order-edit-products-panel{display:none}}.s-order-edit-order-panel{display:flex;flex-direction:column;gap:1.5rem;border-radius:1rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.5rem}.s-order-edit-products-header{margin-bottom:1rem}.s-order-edit-products-title{margin:0px;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-items-wrapper{display:flex;flex-direction:column;gap:1.25rem}.s-order-edit-items-title{margin:0px;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-items-divider{height:1px;width:100%;--tw-bg-opacity:1;background-color:rgb(238 242 247 / var(--tw-bg-opacity, 1))}.s-order-edit-products-picker{display:flex;min-height:0px;flex-direction:column;gap:1rem}.s-order-edit-products-modal-content{display:flex;min-height:0px;flex-direction:column;gap:1rem;padding:1rem}.s-order-edit-products-search{position:relative;margin-bottom:1.25rem;display:block}.s-order-edit-products-search i{pointer-events:none;position:absolute;top:50%;--tw-translate-y:-50%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));font-size:1rem;line-height:1.5rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-products-search i:where([dir="ltr"],[dir="ltr"] *){left:1rem}.s-order-edit-products-search i:where([dir="rtl"],[dir="rtl"] *){right:1rem}.s-order-edit-products-search-input{min-height:3rem;width:100%;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding-left:1rem;padding-right:1rem;padding-top:0.875rem;padding-bottom:0.875rem;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1));transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:200ms}.s-order-edit-products-search-input:where([dir="ltr"],[dir="ltr"] *){padding-left:2.75rem;padding-right:1rem}.s-order-edit-products-search-input:where([dir="rtl"],[dir="rtl"] *){padding-right:2.75rem;padding-left:1rem}.s-order-edit-products-search-input:focus{--tw-border-opacity:1;border-color:rgb(17 24 39 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));--tw-shadow:0 0 0 3px rgba(17,24,39,0.08);--tw-shadow-colored:0 0 0 3px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}.s-order-edit-products-list{min-height:20rem}.s-order-edit-products-list .s-products-list-wrapper{gap:1rem;grid-template-columns:repeat(2,minmax(0,1fr))}@media (min-width: 769px){.s-order-edit-products-list .s-products-list-wrapper{grid-template-columns:repeat(3, minmax(0, 1fr))}}.s-order-edit-no-content-placeholder{display:flex;min-height:14rem;flex-direction:column;align-items:center;justify-content:center;gap:0.75rem;border-radius:0.875rem;border-width:1px;border-style:dashed;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding:2rem;text-align:center;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-no-content-placeholder .icon{font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-actions{position:sticky;bottom:1.5rem;display:flex;align-items:center;justify-content:space-between;gap:0.75rem;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));background-color:rgba(255,255,255,0.94);padding:1rem;--tw-shadow:0 12px 30px rgba(15,23,42,0.08);--tw-shadow-colored:0 12px 30px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);--tw-backdrop-blur:blur(10px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}@media (max-width: 768px){.s-order-edit-actions{position:static;align-items:center;gap:0.5rem}}.s-order-edit-actions salla-button{flex:0 0 auto}@media (max-width: 768px){.s-order-edit-actions salla-button{display:block;flex:1 1 0;min-width:0}}.s-order-edit-mobile-products-trigger{display:none}@media (max-width: 768px){.s-order-edit-mobile-products-trigger{display:block}}.s-order-edit-mobile-products-trigger-icon:where([dir="ltr"],[dir="ltr"] *){margin-right:0.35rem}.s-order-edit-mobile-products-trigger-icon:where([dir="rtl"],[dir="rtl"] *){margin-left:0.35rem}.s-order-edit-mobile-products-modal .s-order-edit-products-list{max-height:min(24rem, calc(100vh - 11rem));min-height:22rem;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}@media (max-width: 480px){.s-order-edit-mobile-products-modal .s-order-edit-products-list{min-height:20rem;max-height:min(22rem, calc(100vh - 10rem))}}.s-order-edit-mobile-products-modal .products-list .s-products-list-wrapper{gap:0.625rem;grid-template-columns:repeat(2,minmax(0,1fr))}.s-order-edit-modal{display:flex;flex-direction:column;gap:1rem}.s-order-edit-modal-title{margin:0px;text-align:start;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-subtitle{margin:0px;margin-top:-0.75rem;text-align:start;font-size:0.875rem;line-height:1.25rem;line-height:1.5;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-items{display:flex;flex-direction:column;gap:0.75rem}.s-order-edit-modal-item{display:flex;align-items:center;justify-content:space-between;gap:1rem;border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-bottom:0.75rem}.s-order-edit-modal-item-start{display:flex;align-items:center;gap:0.75rem}.s-order-edit-modal-item-image{height:3rem;width:3rem;border-radius:0.75rem;object-fit:cover}.s-order-edit-modal-item-name{margin:0px;font-size:0.875rem;line-height:1.25rem;font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-item-options{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-item-end{display:flex;align-items:center;gap:0.75rem}.s-order-edit-modal-item-price{font-size:0.875rem;line-height:1.25rem;font-weight:500}.s-order-edit-modal-item-quantity{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-row{display:flex;align-items:center;justify-content:space-between;gap:1rem}.s-order-edit-modal-row-label{font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-row-value{font-weight:700}.s-order-edit-modal-tax-label{display:flex;align-items:center;gap:0.5rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-tax-icon{--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total{display:flex;align-items:center;justify-content:space-between;gap:1rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-top:0.75rem;font-weight:700;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total-label{font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total-value{font-size:1.25rem;line-height:1.75rem;font-weight:500}.s-order-edit-modal-refund{display:flex;align-items:flex-start;gap:1rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));padding-left:1rem;padding-right:1rem;padding-top:0.875rem;padding-bottom:0.875rem;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-modal-refund-icon{flex-shrink:0;font-size:1.125rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-refund-text{margin:0px;flex:1 1 0%;font-size:0.875rem;line-height:1.25rem}.s-order-edit-modal-btn-wrapper{margin-top:0.5rem;display:flex;justify-content:space-between}.s-order-edit-modal-btn-wrapper salla-button{width:100%}@media (min-width: 640px){.s-order-edit-modal-btn-wrapper salla-button{width:auto}}.s-order-edit-modal-btn-icon{vertical-align:middle;font-size:1.125rem;line-height:1.75rem}.s-order-edit-expired{display:flex;min-height:14rem;flex-direction:column;align-items:center;justify-content:center;gap:0.75rem;border-radius:0.875rem;border-width:1px;border-style:dashed;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding:2rem;text-align:center;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-expired .icon{font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal{display:flex;min-height:0px;flex:1 1 auto;flex-direction:column;gap:1rem}.s-order-edit-add-modal-content{display:flex;min-height:0px;flex:1 1 auto;flex-direction:column;gap:1rem}.s-order-edit-add-modal-loading{display:flex;min-height:12rem;flex:1 1 auto;align-items:center;justify-content:center}.s-order-edit-add-modal-header{border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-bottom:1rem}.s-order-edit-add-modal-media{display:flex;align-items:flex-start;gap:1rem}.s-order-edit-add-modal-image{height:5.5rem;width:5.5rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));object-fit:cover}.s-order-edit-add-modal-details{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.35rem}.s-order-edit-add-modal-name{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-price{font-size:0.95rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-quantity{display:flex;align-items:center;justify-content:space-between;gap:1rem}.s-order-edit-add-modal-section-title{margin:0px;font-size:0.9375rem;font-weight:600;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-quantity-input{flex-shrink:0}.s-order-edit-add-modal-actions{margin-top:auto;display:flex;align-items:center;justify-content:space-between;gap:0.75rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding-top:1rem}.s-order-edit-add-modal-actions salla-button{min-width:4.75rem;flex:0 0 auto}.s-order-edit-item-header{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem}.s-order-edit-item-media{display:flex;min-width:0px;flex:1 1 0%;gap:1rem}@media (max-width: 640px){.s-order-edit-item-media{width:100%}}.s-order-edit-item-image{height:5.5rem;width:5.5rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));object-fit:cover}.s-order-edit-item-details{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.35rem}.s-order-edit-item-name{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-item-link{color:inherit;text-decoration-line:none}.s-order-edit-item-price{font-size:0.95rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}.s-order-edit-item-weight{margin:0px;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-item-quantity{margin-top:1.25rem;display:flex;align-items:center;justify-content:space-between;gap:1rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-top:1rem}.s-order-edit-item-quantity-label{margin:0px;font-size:0.9375rem;font-weight:600;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-item-quantity-input{flex-shrink:0}.s-order-edit-item-options{margin-top:1rem;display:block}.s-order-edit-product-card{display:flex;min-height:100%;width:100%;cursor:pointer;appearance:none;flex-direction:column;overflow:hidden;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));text-align:start;--tw-shadow:0 10px 24px rgba(15,23,42,0.04);--tw-shadow-colored:0 10px 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:200ms}.s-order-edit-product-card:hover{--tw-translate-y:-2px;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-shadow:0 16px 30px rgba(15,23,42,0.08);--tw-shadow-colored:0 16px 30px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.s-order-edit-product-card:focus-visible{--tw-border-opacity:1;border-color:rgb(17 24 39 / var(--tw-border-opacity, 1));--tw-shadow:0 0 0 3px rgba(17,24,39,0.12);--tw-shadow-colored:0 0 0 3px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}@media (max-width: 768px){.s-order-edit-product-card{border-radius:0.75rem;box-shadow:0 6px 18px rgba(15, 23, 42, 0.05)}}.s-order-edit-product-card-media{display:flex;aspect-ratio:1 / 1;width:100%;flex-shrink:0;align-items:center;justify-content:center;overflow:hidden;background:linear-gradient(180deg,#f8fafc 0%,#f1f5f9 100%)}.s-order-edit-product-card-image{display:block;height:100%;width:100%;object-fit:cover}.s-order-edit-product-card-placeholder{display:flex;height:100%;width:100%;align-items:center;justify-content:center;font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-product-card-content{display:flex;flex:1 1 0%;flex-direction:column;gap:0.5rem;padding:1rem}@media (max-width: 768px){.s-order-edit-product-card-content{gap:0.25rem;padding:0.625rem}}.s-order-edit-product-card-title{margin:0px;font-size:0.95rem;font-weight:600;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}@media (max-width: 768px){.s-order-edit-product-card-title{display:-webkit-box;overflow:hidden;min-height:2.35rem;font-size:0.8125rem;line-height:1.45;-webkit-box-orient:vertical;-webkit-line-clamp:2}}.s-order-edit-product-card-price{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}@media (max-width: 768px){.s-order-edit-product-card-price{font-size:0.875rem}.s-order-edit-products-panel,.s-order-edit-order-panel{padding:1rem}.s-order-edit-actions salla-button .s-button-element{width:100%;min-width:0;padding-inline:0.5rem}.s-order-edit-mobile-products-modal .s-order-edit-products-modal-content{gap:0.75rem;padding:0.875rem}.s-order-edit-add-modal-media,.s-order-edit-add-modal-quantity{flex-direction:column;align-items:stretch}}';export{w as salla_order_edit}
4
+ import{r as t,h as e,H as r}from"./p-CwwxD-7C.js";import{g as i,a as o,c as a,u as d,r as s,m as l,b as n,f as c,d as p,e as h,h as m,i as g}from"./p-C8xwacGT.js";import"./p-CoQJOPRz.js";const w=class{constructor(e){t(this,e),this.loading=!0,this.saveLoading=!1,this.payload={items:{update:[],remove:[],add:[]}},this.expired=!1,this.editPreview=null,this.productSearchQuery="",this.productsListKey=0,this.productsListSource="latest",this.productsListSourceValue="",this.selectedProductToAdd=null,this.addProductQuantity=1,this.addProductLoading=!1,this.addProductConfirmLoading=!1,this.mobileProductsModalMounted=!1,this.isMobileViewport=!1,this.isRTL=!0,this.mobileProductsListLoading=!1,this.confirming=!1,this.handleMobileProductSelected=t=>{t.stopPropagation(),this.handleProductSelected(t)},this.productsPanelMobileQuery="(max-width: 768px)",this.handleProductsPanelViewportChange=t=>{this.isMobileViewport=t.matches},this.hasProductTypeFilter=t=>{const e=t.indexOf("?"),r=(e>=0?t.slice(e+1):t).split("#")[0];return Array.from(new URLSearchParams(r)).some((([t,e])=>"product"===e&&/^filters\[types\](?:\[(?:\d*)\])?$/.test(t)))},this.hasExcludedCategoriesFilter=t=>{const e=t.indexOf("?"),r=(e>=0?t.slice(e+1):t).split("#")[0];return Array.from(new URLSearchParams(r)).some((([t])=>/^filters(?:\[|%5B)excluded_categories(?:\]|%5D)(?:\[|%5B)(?:\d*)(?:\]|%5D)$/.test(t)))},this.normalizeProductsListArrayParams=t=>t.replace(/(^|[?&])(includes|source_value|filters(?:\[|%5B)[^&=\]%]+?(?:\]|%5D))(\[|%5B)\d+(\]|%5D)(?==)/gi,((t,e,r,i,o)=>`${e}${r}${i}${o}`)),this.handleBeforeBuildListUrl=t=>{if("salla-order-edit-product-card"!==t.component?.productCardComponent||"string"!=typeof t.url)return;t.url=this.normalizeProductsListArrayParams(t.url),this.hasProductTypeFilter(t.url)||(t.url+=(t.url.includes("?")?"&":"?")+"filters[types][]=product");const e=this.getParsedExcludedCategories();if(e.length>0&&!this.hasExcludedCategoriesFilter(t.url)){const r=e.map((t=>`filters[excluded_categories][]=${encodeURIComponent(t)}`)).join("&");t.url+=`${t.url.includes("?")?"&":"?"}${r}`}},this.defaultProductsListSource="latest",this.debouncedProductSearch=salla.helpers.debounce((t=>this.applyProductSearch(t)),500),salla.onReady((()=>{this.isRTL=salla.config.get("theme.is_rtl",!0)}))}getParsedExcludedCategories(){if(!this.excludedCategories)return[];try{const t="string"==typeof this.excludedCategories?JSON.parse(this.excludedCategories):this.excludedCategories;return Array.isArray(t)?t.filter((t=>Number.isInteger(t)&&t>0)):[]}catch{return[]}}async componentWillLoad(){this.setupProductsPanelViewportQuery(),await salla.onReady(),this.unregisterBeforeBuildListUrlHook=salla.hooks.registerHook("salla-products-list","beforeBuildListUrl",this.handleBeforeBuildListUrl),this.loadFromProp(),this.startExpiryCheck()}disconnectedCallback(){clearInterval(this.expiryInterval),this.unregisterBeforeBuildListUrlHook?.(),this.productsPanelViewportQuery?.removeEventListener("change",this.handleProductsPanelViewportChange),this.mobileProductsModal?.removeEventListener("orderEditProductSelected",this.handleMobileProductSelected)}setupProductsPanelViewportQuery(){"undefined"!=typeof window&&"function"==typeof window.matchMedia&&(this.productsPanelViewportQuery=window.matchMedia(this.productsPanelMobileQuery),this.isMobileViewport=this.productsPanelViewportQuery.matches,this.productsPanelViewportQuery.addEventListener("change",this.handleProductsPanelViewportChange))}startExpiryCheck(){const t=this.order?.customer_editing_session?.ends_at;if(!t)return;const e=()=>new Date(`${t.replace(" ","T")}+03:00`).getTime()<=Date.now();e()?this.expired=!0:this.expiryInterval=setInterval((()=>{e()&&(this.expired=!0,clearInterval(this.expiryInterval))}),1e3)}loadFromProp(){try{if(!this.orderData)return void(this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود"));const t="string"==typeof this.orderData?JSON.parse(this.orderData):this.orderData;this.order={...t,items:t.items.map((t=>({...t,selectedOptions:i(t)})))}}catch(t){this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود")}finally{this.loading=!1}}applyProductSearch(t){const e=t?.trim()||"",r=e?"search":this.defaultProductsListSource,i="search"===r?JSON.stringify(e):"";this.productsListSource===r&&this.productsListSourceValue===i||(this.productsListSource=r,this.productsListSourceValue=i,this.productsListKey+=1)}handleProductSearch(t){const e=t.target?.value||"";this.productSearchQuery=e,this.debouncedProductSearch(e)}getProductsListKey(t){return`${t}-${this.productsListSource}-${this.productsListSourceValue}-${this.productsListKey}`}handleMobileProductsScroll(t){const e=t.currentTarget;if(e.scrollHeight-e.scrollTop-e.clientHeight>200||this.mobileProductsListLoading)return;const r=e.querySelector("salla-products-list");r&&(this.mobileProductsListLoading=!0,r.loadMore().finally((()=>{this.mobileProductsListLoading=!1})))}waitForNextFrame(){return new Promise((t=>requestAnimationFrame((()=>t(void 0)))))}async openMobileProductsModal(){this.mobileProductsModalMounted||(this.mobileProductsModalMounted=!0,await this.waitForNextFrame()),await(this.mobileProductsModal?.open?.())}setMobileProductsModal(t){this.mobileProductsModal!==t&&(this.mobileProductsModal?.removeEventListener("orderEditProductSelected",this.handleMobileProductSelected),this.mobileProductsModal=t,this.mobileProductsModal?.addEventListener("orderEditProductSelected",this.handleMobileProductSelected))}resetAddProductDrawer(){this.selectedProductToAdd=null,this.addProductQuantity=1,this.addProductLoading=!1,this.addProductConfirmLoading=!1,this.addProductOptions=null}getAddProductMaxQuantity(t=this.selectedProductToAdd){return o(t)}clampAddProductQuantity(t,e=this.selectedProductToAdd){return a(t,this.getAddProductMaxQuantity(e))}getApiErrorMessage(t){return t?.response?.data?.error?.message||t?.response?.data?.message}notifyApiError(t){const e=this.getApiErrorMessage(t);e&&salla.notify.error(e)}async validateAddProductOptions(){return!this.selectedProductToAdd?.options?.length||!!this.addProductOptions&&(await(this.addProductOptions.validateAndScroll?.())??await(this.addProductOptions.reportValidity?.())??!1)}updateLocalOrderItem(t,e,r,i){this.order={...this.order,items:d(this.order.items,t,e,r,i)}}removeLocalOrderItem(t){this.order={...this.order,items:s(this.order.items,t)}}setPayloadItems(t){this.payload={...this.payload,items:l(this.payload.items,t)}}handleAddProductQuantityChange(t){const e=t.detail,r=e?.quantity??parseInt(t.target?.value,10);isNaN(r)||r<1||(this.addProductQuantity=this.clampAddProductQuantity(r))}async handleProductSelected(t){const e=t.detail?.product;if(e?.id&&!this.addProductLoading){this.addProductLoading=!0;try{this.selectedProductToAdd=n(e),this.addProductQuantity=1,await(this.mobileProductsModal?.close?.()),await this.waitForNextFrame(),await(this.addProductDrawer?.open?.())}catch(t){this.notifyApiError(t)}finally{this.addProductLoading=!1}}}async confirmAddProduct(){if(this.selectedProductToAdd?.id&&!this.addProductConfirmLoading){this.addProductConfirmLoading=!0;try{const t=this.getAddProductMaxQuantity(),e=this.clampAddProductQuantity(this.addProductQuantity);e!==this.addProductQuantity&&(this.addProductQuantity=e);const r=this.addProductOptions;if(!await this.validateAddProductOptions())return void salla.notify.error(salla.lang.getWithDefault("common.messages.required_fields","يرجى تعبئة الحقول المطلوبة"));const i=await(r?.getSelectedOptionsData?.())||{},o=await(r?.getOptionsData?.())||this.selectedProductToAdd.options||[],d=c(this.order?.items,this.selectedProductToAdd.id,i);if(d){const r=a(d.quantity+e,t);return this.updateLocalOrderItem(d.id,r,o,i),this.setPayloadItems(d.isNew?{add:p(this.payload.items.add,d.id,r,i)}:{update:h(this.payload.items.update,d.id,r,i)}),void await(this.addProductDrawer?.close?.())}const s=m(this.selectedProductToAdd,e,o,i),l={itemId:s.id,product_id:this.selectedProductToAdd.id,quantity:e,options:i};this.order={...this.order,items:[...this.order.items,s]},this.setPayloadItems({add:[...this.payload.items.add,l]}),await(this.addProductDrawer?.close?.())}catch(t){this.notifyApiError(t)}finally{this.addProductConfirmLoading=!1}}}handleItemUpdated(t){if(!this.order)return;const{itemId:e,quantity:r,options:i,optionDefinitions:d}=t.detail,s=this.order.items.find((t=>t.id===e));if(!s)return;const l=a(r,o(s.product));if(s.isNew)return this.setPayloadItems({add:p(this.payload.items.add,e,l,i)}),void this.updateLocalOrderItem(e,l,d,i);this.setPayloadItems({update:h(this.payload.items.update,e,l,i??{})}),this.updateLocalOrderItem(e,l,d,i)}handleItemRemoved(t){if(!this.order)return;if(this.order.items.length<=1)return void salla.notify.error(salla.lang.getWithDefault("pages.orders.order_cannot_be_empty","لا يمكن إزالة جميع المنتجات من الطلب"));const{itemId:e}=t.detail,r=this.order.items.find((t=>t.id===e));if(r){if(r.isNew)return this.setPayloadItems({add:this.payload.items.add.filter((t=>t.itemId!==e))}),void this.removeLocalOrderItem(e);this.setPayloadItems({update:this.payload.items.update.filter((t=>t.id!==e)),remove:[...this.payload.items.remove,e]}),this.removeLocalOrderItem(e)}}get hasChanges(){return this.payload.items.update.length>0||this.payload.items.remove.length>0||this.payload.items.add.length>0}async saveOrder(){if(this.hasChanges){this.saveLoading=!0;try{const t=await salla.order.api.editOrder(this.orderId,g(this.payload));this.editPreview=t?.data?.data||t?.data,await(this.saveModal?.open?.())}catch(t){this.notifyApiError(t)}finally{this.saveLoading=!1}}}navigateToOrder(){const t=new URL(window.location.href);t.pathname=t.pathname.replace(/\/edit\/?$/,""),t.search="",window.location.href=t.href}handleConfirm(){this.confirming=!0,this.editPreview?.payment?.required&&this.editPreview.payment.payment_url?window.location.href=this.editPreview.payment.payment_url:this.navigateToOrder()}returnToOrderDetails(){this.confirming=!0,this.navigateToOrder()}getConfirmButtonIconClass(){return this.isRTL?"sicon-keyboard_arrow_left":"sicon-keyboard_arrow_right"}async cancelEditSession(){try{await salla.order.api.cancelEditSession(this.orderId),this.navigateToOrder()}catch(t){this.notifyApiError(t)}}renderProductsPanel(){const t=salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب");return e("section",{class:"s-order-edit-products-panel"},e("div",{class:"s-order-edit-products-header"},e("h2",{class:"s-order-edit-products-title"},t)),this.renderProductsPickerContent("panel"))}renderProductsPickerContent(t){return e("div",{class:{"s-order-edit-products-picker":!0,"s-order-edit-products-modal-content":"modal"===t}},e("label",{class:"s-order-edit-products-search"},e("i",{class:"sicon-search"}),e("input",{type:"search",class:"s-order-edit-products-search-input",placeholder:salla.lang.getWithDefault("pages.products.search_for_product","ابحث عن منتج"),value:this.productSearchQuery,onInput:t=>this.handleProductSearch(t)})),e("div",{class:"s-order-edit-products-list",onScroll:"modal"===t?t=>this.handleMobileProductsScroll(t):void 0},e("salla-products-list",{key:this.getProductsListKey(t),includes:["options"],source:this.productsListSource,"source-value":this.productsListSourceValue,autoload:!0,"product-card-component":"salla-order-edit-product-card"})))}renderMobileProductsModal(){return e("salla-modal",{ref:t=>this.setMobileProductsModal(t),width:"md",class:"s-order-edit-mobile-products-modal","modal-title":salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب"),onModalVisibilityChanged:t=>{t.detail||(this.mobileProductsModalMounted=!1)}},this.mobileProductsModalMounted?this.renderProductsPickerContent("modal"):null)}renderAddProductDrawer(){const t=this.selectedProductToAdd,r=t?.name||salla.lang.getWithDefault("common.elements.product","منتج"),i=t?.price,o=this.getAddProductMaxQuantity(t),a=t?`order-edit-add-${t.id}`:"order-edit-add",d={value:this.clampAddProductQuantity(this.addProductQuantity,t)};return o&&(d.max=o),e("salla-modal",{ref:t=>this.addProductDrawer=t,width:"md","modal-title":salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب"),onModalVisibilityChanged:t=>{t.detail||this.resetAddProductDrawer()}},e("div",{class:"s-order-edit-add-modal"},this.addProductLoading?e("div",{class:"s-order-edit-add-modal-loading"},e("salla-loading",null)):t?e("div",{class:"s-order-edit-add-modal-content"},e("div",{class:"s-order-edit-add-modal-header"},e("div",{class:"s-order-edit-add-modal-media"},t.image?.url&&e("img",{src:t.image.url,alt:t.image.alt||r,class:"s-order-edit-add-modal-image"}),e("div",{class:"s-order-edit-add-modal-details"},e("h3",{class:"s-order-edit-add-modal-name"},r),null!=i&&e("span",{class:"s-order-edit-add-modal-price",innerHTML:salla.money(i)})))),e("div",{class:"s-order-edit-add-modal-quantity"},e("h3",{class:"s-order-edit-add-modal-section-title"},salla.lang.getWithDefault("common.elements.quantity","الكمية")),e("div",{class:"s-order-edit-add-modal-quantity-input"},e("salla-quantity-input",{...d,onChange:t=>this.handleAddProductQuantityChange(t)}))),t.options?.length>0&&e("form",{onSubmit:t=>t.preventDefault()},e("salla-product-options",{ref:t=>this.addProductOptions=t,"product-id":t.id,"unique-key":a,options:JSON.stringify(t.options),key:`${a}-options`})),e("div",{class:"s-order-edit-add-modal-actions"},e("salla-button",{onClick:()=>this.confirmAddProduct(),loading:this.addProductConfirmLoading},salla.lang.getWithDefault("common.elements.confirm","تأكيد")),e("salla-button",{color:"gray",fill:"outline",onClick:()=>this.addProductDrawer?.close?.()},salla.lang.getWithDefault("common.elements.cancel","الغاء")))):null))}renderSaveModal(){const t=this.editPreview,r=t?.totals?.remaining_amount?.amount>0,i=t?.totals?.refund_amount?.amount>0,o=t?.totals?.tax?.amount?.amount;return e("salla-modal",{ref:t=>this.saveModal=t,width:"md",isClosable:!1,onModalVisibilityChanged:async t=>{t.detail||(this.editPreview=null,this.confirming||await this.cancelEditSession(),this.confirming=!1)}},e("div",{class:"s-order-edit-modal"},e("h2",{class:"s-order-edit-modal-title"},salla.lang.getWithDefault("pages.orders.edit_summary_title","ملخص الطلب بعد التعديل")),e("p",{class:"s-order-edit-modal-subtitle"},salla.lang.getWithDefault("pages.orders.cart_edits_saved","Your cart edits have been saved")),t?.items?.length>0&&e("div",{class:"s-order-edit-modal-items"},t.items.map((t=>{const r=this.order?.items?.find((e=>e.id==t.id)),i=r?.product?.image?.url,o=t.options?.join("/ ");return e("div",{class:"s-order-edit-modal-item"},e("div",{class:"s-order-edit-modal-item-start"},i&&e("img",{src:i,alt:t.name,class:"s-order-edit-modal-item-image"}),e("div",null,e("p",{class:"s-order-edit-modal-item-name"},t.name),o&&e("span",{class:"s-order-edit-modal-item-options"},o))),e("div",{class:"s-order-edit-modal-item-end"},e("span",{class:"s-order-edit-modal-item-quantity",dir:"ltr",innerHTML:t.quantity+" x "+t.price.amount}),e("span",{class:"s-order-edit-modal-item-price",innerHTML:salla.money(t.price.amount*t.quantity)})))}))),t?.totals?.updated_products_total&&e("div",{class:"s-order-edit-modal-row"},e("span",{class:"s-order-edit-modal-row-label"},salla.lang.getWithDefault("pages.orders.modified_products_total","مجموع المنتجات المعدلة")),e("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(t.totals.updated_products_total.amount)})),o>0&&e("div",{class:"s-order-edit-modal-row"},e("span",{class:"s-order-edit-modal-tax-label"},e("i",{class:"sicon-info-circle s-order-edit-modal-tax-icon"}),salla.lang.getWithDefault("pages.orders.vat","ضريبة القيمة المضافة")),e("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(o)})),t?.totals?.total&&e("div",{class:"s-order-edit-modal-total"},e("span",{class:"s-order-edit-modal-total-label"},salla.lang.getWithDefault("pages.orders.order_total","اجمالي الطلب")),e("span",{class:"s-order-edit-modal-total-value",innerHTML:salla.money(t.totals.total.amount)})),i&&e("div",{class:"s-order-edit-modal-refund"},e("i",{class:"sicon-info-circle s-order-edit-modal-refund-icon"}),e("p",{class:"s-order-edit-modal-refund-text"},salla.lang.getWithDefault("pages.orders.refund_message","سيتم تحويل فارق المبلغ على نفس وسيلة الدفع"))),e("div",{class:"s-order-edit-modal-btn-wrapper"},e("salla-button",{onClick:()=>this.handleConfirm()},r?salla.lang.getWithDefault("pages.orders.pay_difference","دفع فارق المبلغ"):i?salla.lang.getWithDefault("pages.orders.confirm_and_receive_difference","تأكيد واستلام فارق المبلغ"):salla.lang.getWithDefault("pages.orders.confirm_changes","تأكيد التعديلات"),e("i",{class:`${this.getConfirmButtonIconClass()} s-order-edit-modal-btn-icon`})),e("salla-button",{color:"gray",fill:"outline",onClick:()=>this.returnToOrderDetails()},salla.lang.getWithDefault("pages.orders.back_to_order_details","العودة إلى تفاصيل الطلب")))))}render(){if(this.loading)return e(r,null,e("salla-loading",null));if(this.expired)return e(r,null,e("div",{class:"s-order-edit-expired"},e("p",null,salla.lang.getWithDefault("pages.orders.edit_session_expired","انتهت مدة التعديل المتاحة")),e("salla-button",{onClick:()=>this.navigateToOrder()},salla.lang.getWithDefault("pages.orders.back_to_order","العودة إلى تفاصيل الطلب"))));if(this.error||!this.order)return e(r,null,e("div",{class:"s-order-edit-no-content-placeholder"},e("i",{class:"sicon-shopping-bag icon"}),e("p",null,this.error)));const t=this.order.items&&this.order.items.length>0,i=this.order.customer_editing_session?.ends_at;return e(r,null,i&&e("div",{class:"s-order-edit-timer-wrapper"},e("salla-count-down",{prefixText:salla.lang.getWithDefault("pages.orders.edit_within","يمكنك التعديل خلال"),date:i,horizontal:!0,withButton:!0,autoSegments:!0,labeled:!1,size:"sm",color:"primary"})),e("div",{class:"s-order-edit-layout"},this.isMobileViewport?null:this.renderProductsPanel(),e("section",{class:"s-order-edit-order-panel"},e("div",{class:"s-order-edit-items-wrapper"},e("h2",{class:"s-order-edit-items-title"},salla.lang.getWithDefault("pages.orders.order_products","منتجات الطلب")),t?this.order.items.map(((t,r)=>[e("salla-order-edit-item",{key:t.id,item:t,orderId:this.orderId}),r<this.order.items.length-1?e("div",{class:"s-order-edit-items-divider"}):null])):e("div",{class:"s-order-edit-no-content-placeholder"},e("i",{class:"sicon-shopping-bag icon"}),e("p",null,salla.lang.getWithDefault("common.elements.no_items","لا توجد عناصر")))),e("div",{class:"s-order-edit-actions"},e("salla-button",{class:"s-order-edit-mobile-products-trigger",color:"gray",size:"small",fill:"outline",onClick:()=>this.openMobileProductsModal()},e("i",{class:"sicon-add s-order-edit-mobile-products-trigger-icon"}),salla.lang.getWithDefault("pages.orders.add_product","إضافة منتج")),e("salla-button",{onClick:()=>this.saveOrder(),loading:this.saveLoading,size:"small",disabled:!this.hasChanges},salla.lang.getWithDefault("pages.orders.save_changes","حفظ التعديلات")),e("salla-button",{size:"small",color:"gray",fill:"outline",onClick:()=>this.cancelEditSession()},salla.lang.getWithDefault("common.elements.cancel","الغاء"))))),this.renderMobileProductsModal(),this.renderAddProductDrawer(),this.renderSaveModal())}};w.style='/*!twlt*/:host{display:block}.outline{outline-style:solid}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.s-order-edit-timer-wrapper{margin-bottom:1rem;display:flex;justify-content:center}.s-order-edit-layout{display:grid;align-items:flex-start;gap:1.5rem;grid-template-columns:minmax(0,1.35fr) minmax(20rem,1fr)}@media (max-width: 1080px){.s-order-edit-layout{grid-template-columns:minmax(0, 1fr)}}.s-order-edit-products-panel{border-radius:1rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.5rem}@media (max-width: 768px){.s-order-edit-products-panel{display:none}}.s-order-edit-order-panel{display:flex;flex-direction:column;gap:1.5rem;border-radius:1rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.5rem}.s-order-edit-products-header{margin-bottom:1rem}.s-order-edit-products-title{margin:0px;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-items-wrapper{display:flex;flex-direction:column;gap:1.25rem}.s-order-edit-items-title{margin:0px;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-items-divider{height:1px;width:100%;--tw-bg-opacity:1;background-color:rgb(238 242 247 / var(--tw-bg-opacity, 1))}.s-order-edit-products-picker{display:flex;min-height:0px;flex-direction:column;gap:1rem}.s-order-edit-products-modal-content{display:flex;min-height:0px;flex-direction:column;gap:1rem;padding:1rem}.s-order-edit-products-search{position:relative;margin-bottom:1.25rem;display:block}.s-order-edit-products-search i{pointer-events:none;position:absolute;top:50%;--tw-translate-y:-50%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));font-size:1rem;line-height:1.5rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-products-search i:where([dir="ltr"],[dir="ltr"] *){left:1rem}.s-order-edit-products-search i:where([dir="rtl"],[dir="rtl"] *){right:1rem}.s-order-edit-products-search-input{min-height:3rem;width:100%;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding-left:1rem;padding-right:1rem;padding-top:0.875rem;padding-bottom:0.875rem;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1));transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:200ms}.s-order-edit-products-search-input:where([dir="ltr"],[dir="ltr"] *){padding-left:2.75rem;padding-right:1rem}.s-order-edit-products-search-input:where([dir="rtl"],[dir="rtl"] *){padding-right:2.75rem;padding-left:1rem}.s-order-edit-products-search-input:focus{--tw-border-opacity:1;border-color:rgb(17 24 39 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));--tw-shadow:0 0 0 3px rgba(17,24,39,0.08);--tw-shadow-colored:0 0 0 3px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}.s-order-edit-products-list{min-height:20rem}.s-order-edit-products-list .s-products-list-wrapper{gap:1rem;grid-template-columns:repeat(2,minmax(0,1fr))}@media (min-width: 769px){.s-order-edit-products-list .s-products-list-wrapper{grid-template-columns:repeat(3, minmax(0, 1fr))}}.s-order-edit-no-content-placeholder{display:flex;min-height:14rem;flex-direction:column;align-items:center;justify-content:center;gap:0.75rem;border-radius:0.875rem;border-width:1px;border-style:dashed;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding:2rem;text-align:center;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-no-content-placeholder .icon{font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-actions{position:sticky;bottom:1.5rem;display:flex;align-items:center;justify-content:space-between;gap:0.75rem;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));background-color:rgba(255,255,255,0.94);padding:1rem;--tw-shadow:0 12px 30px rgba(15,23,42,0.08);--tw-shadow-colored:0 12px 30px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);--tw-backdrop-blur:blur(10px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}@media (max-width: 768px){.s-order-edit-actions{position:static;align-items:center;gap:0.5rem}}.s-order-edit-actions salla-button{flex:0 0 auto}@media (max-width: 768px){.s-order-edit-actions salla-button{display:block;flex:1 1 0;min-width:0}}.s-order-edit-mobile-products-trigger{display:none}@media (max-width: 768px){.s-order-edit-mobile-products-trigger{display:block}}.s-order-edit-mobile-products-trigger-icon:where([dir="ltr"],[dir="ltr"] *){margin-right:0.35rem}.s-order-edit-mobile-products-trigger-icon:where([dir="rtl"],[dir="rtl"] *){margin-left:0.35rem}.s-order-edit-mobile-products-modal .s-order-edit-products-list{max-height:min(24rem, calc(100vh - 11rem));min-height:22rem;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}@media (max-width: 480px){.s-order-edit-mobile-products-modal .s-order-edit-products-list{min-height:20rem;max-height:min(22rem, calc(100vh - 10rem))}}.s-order-edit-mobile-products-modal .products-list .s-products-list-wrapper{gap:0.625rem;grid-template-columns:repeat(2,minmax(0,1fr))}.s-order-edit-modal{display:flex;flex-direction:column;gap:1rem}.s-order-edit-modal-title{margin:0px;text-align:start;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-subtitle{margin:0px;margin-top:-0.75rem;text-align:start;font-size:0.875rem;line-height:1.25rem;line-height:1.5;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-items{display:flex;flex-direction:column;gap:0.75rem}.s-order-edit-modal-item{display:flex;align-items:center;justify-content:space-between;gap:1rem;border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-bottom:0.75rem}.s-order-edit-modal-item-start{display:flex;align-items:center;gap:0.75rem}.s-order-edit-modal-item-image{height:3rem;width:3rem;border-radius:0.75rem;object-fit:cover}.s-order-edit-modal-item-name{margin:0px;font-size:0.875rem;line-height:1.25rem;font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-item-options{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-item-end{display:flex;align-items:center;gap:0.75rem}.s-order-edit-modal-item-price{font-size:0.875rem;line-height:1.25rem;font-weight:500}.s-order-edit-modal-item-quantity{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-row{display:flex;align-items:center;justify-content:space-between;gap:1rem}.s-order-edit-modal-row-label{font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-row-value{font-weight:700}.s-order-edit-modal-tax-label{display:flex;align-items:center;gap:0.5rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-tax-icon{--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total{display:flex;align-items:center;justify-content:space-between;gap:1rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-top:0.75rem;font-weight:700;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total-label{font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total-value{font-size:1.25rem;line-height:1.75rem;font-weight:500}.s-order-edit-modal-refund{display:flex;align-items:flex-start;gap:1rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));padding-left:1rem;padding-right:1rem;padding-top:0.875rem;padding-bottom:0.875rem;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-modal-refund-icon{flex-shrink:0;font-size:1.125rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-refund-text{margin:0px;flex:1 1 0%;font-size:0.875rem;line-height:1.25rem}.s-order-edit-modal-btn-wrapper{margin-top:0.5rem;display:flex;justify-content:space-between}.s-order-edit-modal-btn-wrapper salla-button{width:100%}@media (min-width: 640px){.s-order-edit-modal-btn-wrapper salla-button{width:auto}}.s-order-edit-modal-btn-icon{vertical-align:middle;font-size:1.125rem;line-height:1.75rem}.s-order-edit-expired{display:flex;min-height:14rem;flex-direction:column;align-items:center;justify-content:center;gap:0.75rem;border-radius:0.875rem;border-width:1px;border-style:dashed;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding:2rem;text-align:center;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-expired .icon{font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal{display:flex;min-height:0px;flex:1 1 auto;flex-direction:column;gap:1rem}.s-order-edit-add-modal-content{display:flex;min-height:0px;flex:1 1 auto;flex-direction:column;gap:1rem}.s-order-edit-add-modal-loading{display:flex;min-height:12rem;flex:1 1 auto;align-items:center;justify-content:center}.s-order-edit-add-modal-header{border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-bottom:1rem}.s-order-edit-add-modal-media{display:flex;align-items:flex-start;gap:1rem}.s-order-edit-add-modal-image{height:5.5rem;width:5.5rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));object-fit:cover}.s-order-edit-add-modal-details{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.35rem}.s-order-edit-add-modal-name{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-price{font-size:0.95rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-quantity{display:flex;align-items:center;justify-content:space-between;gap:1rem}.s-order-edit-add-modal-section-title{margin:0px;font-size:0.9375rem;font-weight:600;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-quantity-input{flex-shrink:0}.s-order-edit-add-modal-actions{margin-top:auto;display:flex;align-items:center;justify-content:space-between;gap:0.75rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding-top:1rem}.s-order-edit-add-modal-actions salla-button{min-width:4.75rem;flex:0 0 auto}.s-order-edit-item-header{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem}.s-order-edit-item-media{display:flex;min-width:0px;flex:1 1 0%;gap:1rem}@media (max-width: 640px){.s-order-edit-item-media{width:100%}}.s-order-edit-item-image{height:5.5rem;width:5.5rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));object-fit:cover}.s-order-edit-item-details{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.35rem}.s-order-edit-item-name{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-item-link{color:inherit;text-decoration-line:none}.s-order-edit-item-price{font-size:0.95rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}.s-order-edit-item-weight{margin:0px;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-item-quantity{margin-top:1.25rem;display:flex;align-items:center;justify-content:space-between;gap:1rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-top:1rem}.s-order-edit-item-quantity-label{margin:0px;font-size:0.9375rem;font-weight:600;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-item-quantity-input{flex-shrink:0}.s-order-edit-item-options{margin-top:1rem;display:block}.s-order-edit-product-card{display:flex;min-height:100%;width:100%;cursor:pointer;appearance:none;flex-direction:column;overflow:hidden;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));text-align:start;--tw-shadow:0 10px 24px rgba(15,23,42,0.04);--tw-shadow-colored:0 10px 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:200ms}.s-order-edit-product-card:hover{--tw-translate-y:-2px;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-shadow:0 16px 30px rgba(15,23,42,0.08);--tw-shadow-colored:0 16px 30px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.s-order-edit-product-card:focus-visible{--tw-border-opacity:1;border-color:rgb(17 24 39 / var(--tw-border-opacity, 1));--tw-shadow:0 0 0 3px rgba(17,24,39,0.12);--tw-shadow-colored:0 0 0 3px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}@media (max-width: 768px){.s-order-edit-product-card{border-radius:0.75rem;box-shadow:0 6px 18px rgba(15, 23, 42, 0.05)}}.s-order-edit-product-card-media{display:flex;aspect-ratio:1 / 1;width:100%;flex-shrink:0;align-items:center;justify-content:center;overflow:hidden;background:linear-gradient(180deg,#f8fafc 0%,#f1f5f9 100%)}.s-order-edit-product-card-image{display:block;height:100%;width:100%;object-fit:cover}.s-order-edit-product-card-placeholder{display:flex;height:100%;width:100%;align-items:center;justify-content:center;font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-product-card-content{display:flex;flex:1 1 0%;flex-direction:column;gap:0.5rem;padding:1rem}@media (max-width: 768px){.s-order-edit-product-card-content{gap:0.25rem;padding:0.625rem}}.s-order-edit-product-card-title{margin:0px;font-size:0.95rem;font-weight:600;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}@media (max-width: 768px){.s-order-edit-product-card-title{display:-webkit-box;overflow:hidden;min-height:2.35rem;font-size:0.8125rem;line-height:1.45;-webkit-box-orient:vertical;-webkit-line-clamp:2}}.s-order-edit-product-card-price{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}@media (max-width: 768px){.s-order-edit-product-card-price{font-size:0.875rem}.s-order-edit-products-panel,.s-order-edit-order-panel{padding:1rem}.s-order-edit-actions salla-button .s-button-element{width:100%;min-width:0;padding-inline:0.5rem}.s-order-edit-mobile-products-modal .s-order-edit-products-modal-content{gap:0.75rem;padding:0.875rem}.s-order-edit-add-modal-media,.s-order-edit-add-modal-quantity{flex-direction:column;align-items:stretch}}';export{w as salla_order_edit}