@salla.sa/twilight-components 3.0.25 → 3.0.26

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 (368) hide show
  1. package/dist/cjs/{Helper-BSFw7uVh.js → Helper-Di1G8EnP.js} +1 -1
  2. package/dist/cjs/{filepond-DzJcpvBM.js → filepond-DU_-t59i.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-poster-BILkbyw_.js → filepond-plugin-file-poster-CYpSqb6i.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-size-DIJUAZji.js → filepond-plugin-file-validate-size-a_tUhUBx.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-file-validate-type-4lpOf3hf.js → filepond-plugin-file-validate-type-D_X7irXu.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-edit-DtE3Wj_4.js → filepond-plugin-image-edit-BRP3GZ31.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-exif-orientation-Dc_jwifJ.js → filepond-plugin-image-exif-orientation-CiHIpg-4.js} +1 -1
  8. package/dist/cjs/{filepond-plugin-image-preview-D_8qt0dd.js → filepond-plugin-image-preview-CKT6x8T1.js} +1 -1
  9. package/dist/cjs/{index-D0d25H-r.js → index-BLPUgwXq.js} +6 -6
  10. package/dist/cjs/info-Do5bVPmK.js +13 -0
  11. package/dist/cjs/{intlTelInput-DqmuleM6.js → intlTelInput-CyL5UDfU.js} +1 -1
  12. package/dist/cjs/loader.cjs.js +2 -2
  13. package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
  14. package/dist/cjs/salla-accordion_6.cjs.entry.js +2 -2
  15. package/dist/cjs/salla-add-product-button_5.cjs.entry.js +2 -2
  16. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  17. package/dist/cjs/salla-alert_2.cjs.entry.js +3 -9
  18. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  19. package/dist/cjs/salla-applied-filters.cjs.entry.js +2 -2
  20. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  21. package/dist/cjs/salla-attachment-view_9.cjs.entry.js +11 -11
  22. package/dist/cjs/salla-badge.cjs.entry.js +1 -1
  23. package/dist/cjs/salla-basket-gap.cjs.entry.js +1 -1
  24. package/dist/cjs/salla-bullet-delivery_3.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-cart-coupons.cjs.entry.js +1 -1
  26. package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-cart-summary-card.cjs.entry.js +120 -5
  28. package/dist/cjs/salla-cashback-banner.cjs.entry.js +1 -1
  29. package/dist/cjs/salla-comment-factors.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-comment-form_9.cjs.entry.js +2 -2
  31. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-count-down.cjs.entry.js +1 -1
  35. package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
  36. package/dist/cjs/salla-delivery-promise.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-filters-widget.cjs.entry.js +2 -2
  39. package/dist/cjs/salla-filters.cjs.entry.js +2 -2
  40. package/dist/cjs/salla-free-shipping-banner.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-free-shipping-tag.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-gift-card-redeem_2.cjs.entry.js +1 -1
  44. package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
  45. package/dist/cjs/salla-hook.cjs.entry.js +1 -1
  46. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +2 -2
  47. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  48. package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
  49. package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
  50. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  51. package/dist/cjs/salla-loyalty-banner_10.cjs.entry.js +1 -1
  52. package/dist/cjs/salla-loyalty-exchange-product-card.cjs.entry.js +1 -1
  53. package/dist/cjs/salla-loyalty-points-banner.cjs.entry.js +1 -1
  54. package/dist/cjs/salla-loyalty-points-history.cjs.entry.js +1 -1
  55. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  56. package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
  57. package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
  58. package/dist/cjs/salla-map_3.cjs.entry.js +1 -1
  59. package/dist/cjs/salla-menu.cjs.entry.js +1 -1
  60. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  61. package/dist/cjs/salla-mobile-update-modal.cjs.entry.js +1 -1
  62. package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
  63. package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
  64. package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
  65. package/dist/cjs/salla-next-order-coupon.cjs.entry.js +1 -1
  66. package/dist/cjs/salla-notification-item_2.cjs.entry.js +2 -2
  67. package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
  68. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  69. package/dist/cjs/salla-order-branch.cjs.entry.js +1 -1
  70. package/dist/cjs/salla-order-cancel.cjs.entry.js +1 -1
  71. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  72. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  73. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  74. package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
  75. package/dist/cjs/salla-order-edit-product-card.cjs.entry.js +1 -1
  76. package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
  77. package/dist/cjs/salla-order-items.cjs.entry.js +1 -1
  78. package/dist/cjs/salla-order-options-modal.cjs.entry.js +1 -1
  79. package/dist/cjs/salla-order-payment.cjs.entry.js +1 -1
  80. package/dist/cjs/salla-order-rewards.cjs.entry.js +1 -1
  81. package/dist/cjs/salla-order-shipments.cjs.entry.js +1 -1
  82. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  83. package/dist/cjs/salla-order-totals-card.cjs.entry.js +27 -6
  84. package/dist/cjs/salla-orders.cjs.entry.js +2 -2
  85. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  86. package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
  87. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  88. package/dist/cjs/salla-product-card-embed.cjs.entry.js +1 -1
  89. package/dist/cjs/salla-product-card.cjs.entry.js +1 -1
  90. package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
  91. package/dist/cjs/salla-products-list.cjs.entry.js +2 -2
  92. package/dist/cjs/salla-products-slider.cjs.entry.js +2 -2
  93. package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
  94. package/dist/cjs/salla-rating-modal-v2.cjs.entry.js +2 -2
  95. package/dist/cjs/salla-rating-modal.cjs.entry.js +2 -2
  96. package/dist/cjs/salla-review-factors-tags.cjs.entry.js +1 -1
  97. package/dist/cjs/salla-review-order-item.cjs.entry.js +1 -1
  98. package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
  99. package/dist/cjs/salla-search-product-card.cjs.entry.js +1 -1
  100. package/dist/cjs/salla-search.cjs.entry.js +2 -2
  101. package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
  102. package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
  103. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  104. package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
  105. package/dist/cjs/salla-thank-you-header.cjs.entry.js +1 -1
  106. package/dist/cjs/salla-thank-you-page.cjs.entry.js +1 -1
  107. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  108. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  109. package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
  110. package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
  111. package/dist/cjs/salla-user-settings.cjs.entry.js +1 -1
  112. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  113. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  114. package/dist/cjs/salla-wishlist-actions.cjs.entry.js +1 -1
  115. package/dist/cjs/salla-wishlist-summary.cjs.entry.js +2 -2
  116. package/dist/cjs/twilight.cjs.js +2 -2
  117. package/dist/cjs/{vanilla-picker-DP9Hy8IR.js → vanilla-picker-C9AVuYe1.js} +1 -1
  118. package/dist/collection/components/salla-cart-summary-card/salla-cart-summary-card.css +152 -59
  119. package/dist/collection/components/salla-cart-summary-card/salla-cart-summary-card.js +123 -4
  120. package/dist/collection/components/salla-order-totals-card/salla-order-totals-card.css +3 -0
  121. package/dist/collection/components/salla-order-totals-card/salla-order-totals-card.js +25 -4
  122. package/dist/components/index.js +2 -2
  123. package/dist/components/info.js +11 -0
  124. package/dist/components/salla-bottom-alert.js +2 -8
  125. package/dist/components/salla-cart-summary-card.js +124 -5
  126. package/dist/components/salla-order-totals-card.js +26 -5
  127. package/dist/docs.json +3 -3
  128. package/dist/esm/{Helper-DmnUAusv.js → Helper-CFEqaSN-.js} +1 -1
  129. package/dist/esm/{filepond-DZbzdjkK.js → filepond-BfW_OXid.js} +1 -1
  130. package/dist/esm/{filepond-plugin-file-poster-D9cjvoj-.js → filepond-plugin-file-poster-CsMiL-wZ.js} +1 -1
  131. package/dist/esm/{filepond-plugin-file-validate-size-D-kjllC-.js → filepond-plugin-file-validate-size-BuxVUFKn.js} +1 -1
  132. package/dist/esm/{filepond-plugin-file-validate-type-D9hsNaJl.js → filepond-plugin-file-validate-type-Dq94isoe.js} +1 -1
  133. package/dist/esm/{filepond-plugin-image-edit-CDHAxJY8.js → filepond-plugin-image-edit-CEVstXlA.js} +1 -1
  134. package/dist/esm/{filepond-plugin-image-exif-orientation-BGKiclwK.js → filepond-plugin-image-exif-orientation-BhViRs-X.js} +1 -1
  135. package/dist/esm/{filepond-plugin-image-preview-BUjvnt8G.js → filepond-plugin-image-preview-BrscXNqJ.js} +1 -1
  136. package/dist/esm/{index-ze9e0dxM.js → index-g-_4am8C.js} +6 -6
  137. package/dist/esm/info-OdOOjQZO.js +11 -0
  138. package/dist/esm/{intlTelInput-BkYRB6km.js → intlTelInput-PsSXBr__.js} +1 -1
  139. package/dist/esm/loader.js +3 -3
  140. package/dist/esm/salla-accordion-body_2.entry.js +1 -1
  141. package/dist/esm/salla-accordion_6.entry.js +2 -2
  142. package/dist/esm/salla-add-product-button_5.entry.js +2 -2
  143. package/dist/esm/salla-advertisement.entry.js +1 -1
  144. package/dist/esm/salla-alert_2.entry.js +3 -9
  145. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  146. package/dist/esm/salla-applied-filters.entry.js +2 -2
  147. package/dist/esm/salla-apps-icons.entry.js +1 -1
  148. package/dist/esm/salla-attachment-view_9.entry.js +11 -11
  149. package/dist/esm/salla-badge.entry.js +1 -1
  150. package/dist/esm/salla-basket-gap.entry.js +1 -1
  151. package/dist/esm/salla-bullet-delivery_3.entry.js +1 -1
  152. package/dist/esm/salla-cart-coupons.entry.js +1 -1
  153. package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
  154. package/dist/esm/salla-cart-summary-card.entry.js +120 -5
  155. package/dist/esm/salla-cashback-banner.entry.js +1 -1
  156. package/dist/esm/salla-comment-factors.entry.js +1 -1
  157. package/dist/esm/salla-comment-form_9.entry.js +2 -2
  158. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  159. package/dist/esm/salla-contacts.entry.js +1 -1
  160. package/dist/esm/salla-cookies-bar.entry.js +1 -1
  161. package/dist/esm/salla-count-down.entry.js +1 -1
  162. package/dist/esm/salla-custom-fields.entry.js +1 -1
  163. package/dist/esm/salla-delivery-promise.entry.js +1 -1
  164. package/dist/esm/salla-edit-order-button.entry.js +1 -1
  165. package/dist/esm/salla-filters-widget.entry.js +2 -2
  166. package/dist/esm/salla-filters.entry.js +2 -2
  167. package/dist/esm/salla-free-shipping-banner.entry.js +1 -1
  168. package/dist/esm/salla-free-shipping-tag.entry.js +1 -1
  169. package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
  170. package/dist/esm/salla-gift-card-redeem_2.entry.js +1 -1
  171. package/dist/esm/salla-gifting.entry.js +1 -1
  172. package/dist/esm/salla-hook.entry.js +1 -1
  173. package/dist/esm/salla-infinite-scroll.entry.js +2 -2
  174. package/dist/esm/salla-installment.entry.js +1 -1
  175. package/dist/esm/salla-list-tile.entry.js +1 -1
  176. package/dist/esm/salla-localization-modal.entry.js +1 -1
  177. package/dist/esm/salla-login-modal.entry.js +1 -1
  178. package/dist/esm/salla-loyalty-banner_10.entry.js +1 -1
  179. package/dist/esm/salla-loyalty-exchange-product-card.entry.js +1 -1
  180. package/dist/esm/salla-loyalty-points-banner.entry.js +1 -1
  181. package/dist/esm/salla-loyalty-points-history.entry.js +1 -1
  182. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  183. package/dist/esm/salla-loyalty.entry.js +1 -1
  184. package/dist/esm/salla-maintenance-alert.entry.js +1 -1
  185. package/dist/esm/salla-map_3.entry.js +1 -1
  186. package/dist/esm/salla-menu.entry.js +1 -1
  187. package/dist/esm/salla-metadata.entry.js +1 -1
  188. package/dist/esm/salla-mobile-update-modal.entry.js +1 -1
  189. package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
  190. package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
  191. package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
  192. package/dist/esm/salla-next-order-coupon.entry.js +1 -1
  193. package/dist/esm/salla-notification-item_2.entry.js +2 -2
  194. package/dist/esm/salla-offer-modal.entry.js +1 -1
  195. package/dist/esm/salla-offer.entry.js +1 -1
  196. package/dist/esm/salla-order-branch.entry.js +1 -1
  197. package/dist/esm/salla-order-cancel.entry.js +1 -1
  198. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  199. package/dist/esm/salla-order-details-options.entry.js +1 -1
  200. package/dist/esm/salla-order-details.entry.js +1 -1
  201. package/dist/esm/salla-order-edit-item.entry.js +1 -1
  202. package/dist/esm/salla-order-edit-product-card.entry.js +1 -1
  203. package/dist/esm/salla-order-edit.entry.js +1 -1
  204. package/dist/esm/salla-order-items.entry.js +1 -1
  205. package/dist/esm/salla-order-options-modal.entry.js +1 -1
  206. package/dist/esm/salla-order-payment.entry.js +1 -1
  207. package/dist/esm/salla-order-rewards.entry.js +1 -1
  208. package/dist/esm/salla-order-shipments.entry.js +1 -1
  209. package/dist/esm/salla-order-summary.entry.js +1 -1
  210. package/dist/esm/salla-order-totals-card.entry.js +27 -6
  211. package/dist/esm/salla-orders.entry.js +2 -2
  212. package/dist/esm/salla-payments.entry.js +1 -1
  213. package/dist/esm/salla-placeholder.entry.js +1 -1
  214. package/dist/esm/salla-price-range.entry.js +1 -1
  215. package/dist/esm/salla-product-card-embed.entry.js +1 -1
  216. package/dist/esm/salla-product-card.entry.js +1 -1
  217. package/dist/esm/salla-product-size-guide.entry.js +1 -1
  218. package/dist/esm/salla-products-list.entry.js +2 -2
  219. package/dist/esm/salla-products-slider.entry.js +2 -2
  220. package/dist/esm/salla-quick-order.entry.js +1 -1
  221. package/dist/esm/salla-rating-modal-v2.entry.js +2 -2
  222. package/dist/esm/salla-rating-modal.entry.js +2 -2
  223. package/dist/esm/salla-review-factors-tags.entry.js +1 -1
  224. package/dist/esm/salla-review-order-item.entry.js +1 -1
  225. package/dist/esm/salla-scopes.entry.js +1 -1
  226. package/dist/esm/salla-search-product-card.entry.js +1 -1
  227. package/dist/esm/salla-search.entry.js +2 -2
  228. package/dist/esm/salla-skeleton.entry.js +1 -1
  229. package/dist/esm/salla-social-share.entry.js +1 -1
  230. package/dist/esm/salla-social.entry.js +1 -1
  231. package/dist/esm/salla-tab-content_3.entry.js +1 -1
  232. package/dist/esm/salla-thank-you-header.entry.js +1 -1
  233. package/dist/esm/salla-thank-you-page.entry.js +1 -1
  234. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  235. package/dist/esm/salla-trust-badges.entry.js +1 -1
  236. package/dist/esm/salla-user-menu.entry.js +1 -1
  237. package/dist/esm/salla-user-profile.entry.js +1 -1
  238. package/dist/esm/salla-user-settings.entry.js +1 -1
  239. package/dist/esm/salla-verify.entry.js +1 -1
  240. package/dist/esm/salla-wallet.entry.js +1 -1
  241. package/dist/esm/salla-wishlist-actions.entry.js +1 -1
  242. package/dist/esm/salla-wishlist-summary.entry.js +2 -2
  243. package/dist/esm/twilight.js +3 -3
  244. package/dist/esm/{vanilla-picker-CxhuwWDi.js → vanilla-picker-D3lgt9go.js} +1 -1
  245. package/dist/twilight/{p-2dcd24fe.entry.js → p-02006b3a.entry.js} +1 -1
  246. package/dist/twilight/{p-67cf7454.entry.js → p-0207dae4.entry.js} +1 -1
  247. package/dist/twilight/{p-75f7f1d8.entry.js → p-025e30c7.entry.js} +1 -1
  248. package/dist/twilight/{p-97c5b11d.entry.js → p-058e4be3.entry.js} +1 -1
  249. package/dist/twilight/{p-dfde387f.entry.js → p-0ce6514e.entry.js} +1 -1
  250. package/dist/twilight/{p-474d882c.entry.js → p-0d94c90e.entry.js} +1 -1
  251. package/dist/twilight/{p-5b118b5b.entry.js → p-0e423424.entry.js} +1 -1
  252. package/dist/twilight/{p-a7566af2.entry.js → p-0f7db4a1.entry.js} +1 -1
  253. package/dist/twilight/{p-57fafaba.entry.js → p-12038aef.entry.js} +1 -1
  254. package/dist/twilight/{p-770142fe.entry.js → p-12dcb9a0.entry.js} +1 -1
  255. package/dist/twilight/{p-024ecda2.entry.js → p-14311053.entry.js} +1 -1
  256. package/dist/twilight/{p-e3dd9502.entry.js → p-151df172.entry.js} +1 -1
  257. package/dist/twilight/{p-8077d8b6.entry.js → p-152ac425.entry.js} +1 -1
  258. package/dist/twilight/{p-11eb8675.entry.js → p-1b6d84a8.entry.js} +1 -1
  259. package/dist/twilight/{p-78c04993.entry.js → p-1d31b983.entry.js} +1 -1
  260. package/dist/twilight/{p-7fffa509.entry.js → p-1dcbbbbf.entry.js} +1 -1
  261. package/dist/twilight/{p-ed96c703.entry.js → p-1df3fe4a.entry.js} +1 -1
  262. package/dist/twilight/{p-73649c81.entry.js → p-22271248.entry.js} +1 -1
  263. package/dist/twilight/{p-b6098938.entry.js → p-2834a4d3.entry.js} +1 -1
  264. package/dist/twilight/{p-9fe5c0f5.entry.js → p-2907057d.entry.js} +1 -1
  265. package/dist/twilight/{p-455a4702.entry.js → p-2d3b29d9.entry.js} +1 -1
  266. package/dist/twilight/{p-fb955257.entry.js → p-2db9ee05.entry.js} +1 -1
  267. package/dist/twilight/{p-2aa9147c.entry.js → p-2e4ce75b.entry.js} +1 -1
  268. package/dist/twilight/{p-bf5b5f52.entry.js → p-329b7cc2.entry.js} +1 -1
  269. package/dist/twilight/{p-7a985fe3.entry.js → p-3c2e7bef.entry.js} +1 -1
  270. package/dist/twilight/{p-9acfe389.entry.js → p-3fedd652.entry.js} +1 -1
  271. package/dist/twilight/{p-446e3f38.entry.js → p-4247db1a.entry.js} +1 -1
  272. package/dist/twilight/{p-d89328d7.entry.js → p-496f950b.entry.js} +1 -1
  273. package/dist/twilight/{p-0fd15433.entry.js → p-49cd89d1.entry.js} +1 -1
  274. package/dist/twilight/p-4b8bb969.entry.js +4 -0
  275. package/dist/twilight/{p-97fa91db.entry.js → p-5166cd84.entry.js} +1 -1
  276. package/dist/twilight/{p-dbb4db25.entry.js → p-5350ba07.entry.js} +1 -1
  277. package/dist/twilight/{p-c122e9c1.entry.js → p-54eec74a.entry.js} +1 -1
  278. package/dist/twilight/{p-93571975.entry.js → p-55861492.entry.js} +1 -1
  279. package/dist/twilight/{p-6d6b99fe.entry.js → p-6070b995.entry.js} +1 -1
  280. package/dist/twilight/{p-4c191ab4.entry.js → p-62a3394a.entry.js} +1 -1
  281. package/dist/twilight/{p-d300a117.entry.js → p-63c982e1.entry.js} +1 -1
  282. package/dist/twilight/{p-08be494e.entry.js → p-6432401e.entry.js} +1 -1
  283. package/dist/twilight/{p-e23b84bf.entry.js → p-64ae09b4.entry.js} +1 -1
  284. package/dist/twilight/{p-c6f09614.entry.js → p-685a61fa.entry.js} +1 -1
  285. package/dist/twilight/{p-7731e280.entry.js → p-710a42d2.entry.js} +1 -1
  286. package/dist/twilight/{p-d089ac6d.entry.js → p-72e13a12.entry.js} +1 -1
  287. package/dist/twilight/{p-d2396143.entry.js → p-73612f04.entry.js} +1 -1
  288. package/dist/twilight/{p-f054cf8e.entry.js → p-74602eb0.entry.js} +1 -1
  289. package/dist/twilight/{p-7790a9a1.entry.js → p-76e238b3.entry.js} +1 -1
  290. package/dist/twilight/{p-5ceda3d5.entry.js → p-78240cb3.entry.js} +1 -1
  291. package/dist/twilight/{p-331003bc.entry.js → p-78a7b46e.entry.js} +1 -1
  292. package/dist/twilight/{p-3a2ff4d6.entry.js → p-79f9403a.entry.js} +1 -1
  293. package/dist/twilight/{p-bd06c200.entry.js → p-7f4f300a.entry.js} +1 -1
  294. package/dist/twilight/{p-a865995d.entry.js → p-7fc9a0bf.entry.js} +1 -1
  295. package/dist/twilight/{p-e849f5ef.entry.js → p-8016f122.entry.js} +1 -1
  296. package/dist/twilight/{p-5e0f85ae.entry.js → p-801eb7d8.entry.js} +1 -1
  297. package/dist/twilight/{p-5d8937c5.entry.js → p-81ec67d8.entry.js} +1 -1
  298. package/dist/twilight/{p-89598ad3.entry.js → p-83a1123b.entry.js} +1 -1
  299. package/dist/twilight/{p-776f9492.entry.js → p-84b9416e.entry.js} +1 -1
  300. package/dist/twilight/{p-b297fe2e.entry.js → p-8783aa81.entry.js} +1 -1
  301. package/dist/twilight/{p-02b7dfcc.entry.js → p-87ba0ca2.entry.js} +1 -1
  302. package/dist/twilight/{p-bb137dbb.entry.js → p-8cbbe961.entry.js} +1 -1
  303. package/dist/twilight/{p-75ad7f14.entry.js → p-8ec7866e.entry.js} +1 -1
  304. package/dist/twilight/{p-45a7d444.entry.js → p-92cbac49.entry.js} +1 -1
  305. package/dist/twilight/{p-1ca39f1c.entry.js → p-93a85463.entry.js} +1 -1
  306. package/dist/twilight/{p-0c022fbd.entry.js → p-95f8caa0.entry.js} +1 -1
  307. package/dist/twilight/{p-ffc7f526.entry.js → p-965c3ee8.entry.js} +1 -1
  308. package/dist/twilight/{p-519cf4c2.entry.js → p-98b24f1d.entry.js} +1 -1
  309. package/dist/twilight/{p-BpJsOjKP.js → p-9h9-vkr9.js} +1 -1
  310. package/dist/twilight/{p-CNQaYCUJ.js → p-B6WlUws-.js} +1 -1
  311. package/dist/twilight/{p-C9ldyQUq.js → p-ByR59DTl.js} +2 -2
  312. package/dist/twilight/{p-DOUAavek.js → p-CB552NRi.js} +1 -1
  313. package/dist/twilight/{p-CICtuB_u.js → p-CWi90iJ1.js} +1 -1
  314. package/dist/twilight/{p-BjUh9YCs.js → p-DjCyIWR1.js} +1 -1
  315. package/dist/twilight/{p-wYYV5ykR.js → p-EXd4paYi.js} +1 -1
  316. package/dist/twilight/{p-BlPdaFn2.js → p-MEqjtc_i.js} +1 -1
  317. package/dist/twilight/p-OdOOjQZO.js +4 -0
  318. package/dist/twilight/{p-cykIAOlk.js → p-WsiD2WP-.js} +1 -1
  319. package/dist/twilight/{p-B8nGVDvQ.js → p-_ulhlUUw.js} +1 -1
  320. package/dist/twilight/{p-47c79c49.entry.js → p-a185d836.entry.js} +1 -1
  321. package/dist/twilight/p-a2147ef3.entry.js +4 -0
  322. package/dist/twilight/{p-71ce8e4f.entry.js → p-a21bc7ee.entry.js} +1 -1
  323. package/dist/twilight/{p-37b64e36.entry.js → p-a255167f.entry.js} +1 -1
  324. package/dist/twilight/{p-bf65d2fa.entry.js → p-a76a2a5d.entry.js} +1 -1
  325. package/dist/twilight/{p-4ec15515.entry.js → p-a7aa162c.entry.js} +1 -1
  326. package/dist/twilight/{p-f9dd6b3e.entry.js → p-aa5be7cf.entry.js} +1 -1
  327. package/dist/twilight/{p-b71673ee.entry.js → p-ac31a382.entry.js} +1 -1
  328. package/dist/twilight/{p-9a2567e2.entry.js → p-ad95bb9a.entry.js} +1 -1
  329. package/dist/twilight/{p-8b0b6bca.entry.js → p-ae4ea8c9.entry.js} +1 -1
  330. package/dist/twilight/{p-c0301e00.entry.js → p-ba601791.entry.js} +1 -1
  331. package/dist/twilight/{p-008740fe.entry.js → p-c0423cfc.entry.js} +1 -1
  332. package/dist/twilight/{p-8d3c5d1f.entry.js → p-c861b955.entry.js} +1 -1
  333. package/dist/twilight/{p-792494c8.entry.js → p-c96e9150.entry.js} +1 -1
  334. package/dist/twilight/{p-d61298f8.entry.js → p-cdd8e44a.entry.js} +1 -1
  335. package/dist/twilight/{p-830abcc1.entry.js → p-cf3285f1.entry.js} +1 -1
  336. package/dist/twilight/p-d02dee6d.entry.js +4 -0
  337. package/dist/twilight/{p-f7c06bee.entry.js → p-d204326c.entry.js} +1 -1
  338. package/dist/twilight/{p-cbd056ba.entry.js → p-d304b8fc.entry.js} +1 -1
  339. package/dist/twilight/{p-9dd7cf71.entry.js → p-da63cbf0.entry.js} +1 -1
  340. package/dist/twilight/p-db2b9499.entry.js +4 -0
  341. package/dist/twilight/{p-59694c45.entry.js → p-dba5b89a.entry.js} +1 -1
  342. package/dist/twilight/{p-f23ada45.entry.js → p-e0387b79.entry.js} +1 -1
  343. package/dist/twilight/{p-12a52f1b.entry.js → p-e0dc2c2d.entry.js} +1 -1
  344. package/dist/twilight/{p-16e2a110.entry.js → p-e3d37ab2.entry.js} +1 -1
  345. package/dist/twilight/{p-5f9d87ec.entry.js → p-e59a8901.entry.js} +1 -1
  346. package/dist/twilight/{p-dceb3725.entry.js → p-e776afcd.entry.js} +1 -1
  347. package/dist/twilight/{p-03b2df97.entry.js → p-e8921db3.entry.js} +1 -1
  348. package/dist/twilight/{p-da0349f9.entry.js → p-ec9434d9.entry.js} +1 -1
  349. package/dist/twilight/{p-cdeaf60b.entry.js → p-ee7e6ce9.entry.js} +1 -1
  350. package/dist/twilight/{p-3ec3e9fb.entry.js → p-f0ab3933.entry.js} +1 -1
  351. package/dist/twilight/{p-cb961f05.entry.js → p-f16bdaf5.entry.js} +1 -1
  352. package/dist/twilight/{p-a7849674.entry.js → p-f2718aec.entry.js} +1 -1
  353. package/dist/twilight/{p-da60995f.entry.js → p-f581bb32.entry.js} +1 -1
  354. package/dist/twilight/{p-de10d0c3.entry.js → p-f6981856.entry.js} +1 -1
  355. package/dist/twilight/{p-a1a650ab.entry.js → p-f7f8d758.entry.js} +1 -1
  356. package/dist/twilight/{p-20949dfb.entry.js → p-fbff3efd.entry.js} +1 -1
  357. package/dist/twilight/{p-07e581af.entry.js → p-ff890108.entry.js} +1 -1
  358. package/dist/twilight/{p-4cf81a44.entry.js → p-fffd562d.entry.js} +1 -1
  359. package/dist/twilight/{p-ze9e0dxM.js → p-g-_4am8C.js} +1 -1
  360. package/dist/twilight/twilight.esm.js +1 -1
  361. package/dist/types/components/salla-cart-summary-card/salla-cart-summary-card.d.ts +26 -0
  362. package/dist/types/components/salla-order-totals-card/interfaces.d.ts +8 -3
  363. package/dist/types/components/salla-order-totals-card/salla-order-totals-card.d.ts +2 -1
  364. package/package.json +5 -5
  365. package/dist/twilight/p-0c0b2b36.entry.js +0 -4
  366. package/dist/twilight/p-61b98119.entry.js +0 -4
  367. package/dist/twilight/p-8d096f95.entry.js +0 -4
  368. package/dist/twilight/p-be8c42f1.entry.js +0 -4
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as t,H as i,a as e}from"./p-ze9e0dxM.js";import{C as o}from"./p-BsLF_HK7.js";const a=class{constructor(t){s(this,t),this.isVisible=!0,this.step="consent",this.isMobile=!1,this.mobileBreakpoint=768,this.mobileQueryHandler=s=>this.isMobile=s.matches,this.openRequestedHandler=()=>this.open(),this.authLoggedInHandler=()=>this.syncConsentAfterLogin(),this.authLoggedOutHandler=()=>this.handleLogout(),this.necessaryCookieKey="necessary_cookies",this.performanceCookieKey="performance_cookies",this.functionalCookieKey="functional_cookies",this.advertisingCookieKey="advertising_cookies",this.consentCookieDays=365,this.consentStorageKey="cookies-consent",this.sessionConsentPointsKey="cookies-consent-points",this.consentByUserKey="cookies-consent-by-user",this.trackingCookiesByCategory={performance_cookies:["_ga","_ga_*","_gid","_gat","_gat_gtag_*","_hjSessionUser_*","_hjSession_*","_hjIncludedInSessionSample_*","_hjAbsoluteSessionInProgress","_hjFirstSeen","_clck","_clsk","MUID","MR","ANONCHK","_ym_uid","_ym_d","_ym_isad"],advertising_cookies:["_gcl_au","_gcl_aw","_gcl_dc","IDE","test_cookie","1P_JAR","NID","_fbp","_fbc","fr","_ttp","_scid","sc_at","personalization_id","guest_id","muc_ads","_pin_unauth","_pinterest_ct_ua","li_sugr","bcookie","lidc","UserMatchHistory","AnalyticsSyncHistory"],functional_cookies:["intercom-id-*","intercom-session-*","__zlcmid","crisp-client%2Fsession%2F*","YSC","VISITOR_INFO1_LIVE","PREF"]},this.performanceEnabled=!1,this.functionsEnabled=!1,this.adsEnabled=!1}storeKey(s){return`${s}_${Salla.config.get("store.id")}`}async componentWillLoad(){await Salla.onReady(),await Salla.lang.onLoaded(),this.loadTranslations(),Salla.event.on("salla-cookies-bar::open",this.openRequestedHandler),Salla.event.on("auth::logged.in",this.authLoggedInHandler),Salla.event.on("auth::logged.out",this.authLoggedOutHandler),this.unregisterAfterFetchMenuItemsHook=Salla.hooks.registerHook("salla-menu","afterFetchMenuItems",(s=>this.appendCookiesSettingsLink(s))),this.hydrateToggleState(),this.currentConsentPoints()&&(this.isVisible=!1),this.enforceCurrentConsent()}isArabicLocale(){return(Salla.lang.getLocale?.()??document.documentElement.lang??"ar").toLowerCase().startsWith("ar")}translate(s,t,i){const e=Salla.lang.get(s);return e&&e!==s?e:this.isArabicLocale()?t:i}loadTranslations(){this.titleLabel=this.translate("common.cookies.settings_title","تخصيص إعدادات ملفات تعريف الارتباط","Customize Cookie Preferences Settings"),this.saveLabel=this.translate("common.cookies.save","حفظ الخيارات","Save Options"),this.messageLabel=Salla.lang.get("common.cookies.message"),this.linkLabel=Salla.lang.get("common.cookies.link"),this.acceptLabel=this.translate("common.cookies.accept","قبول","Accept"),this.acceptAllLabel=this.translate("common.cookies.accept_all","قبول الكل","Accept All"),this.customizeLabel=this.translate("common.cookies.customize","تخصيص","Customize"),this.essentialTitleLabel=this.translate("common.cookies.categories.essential.title","ملفات تعريف الارتباط الضرورية","Essential Cookies"),this.essentialDescriptionLabel=this.translate("common.cookies.categories.essential.description","ضروريه لتشغيل الوظائف الأساسية للموقع الإلكتروني.","Required for the website's basic functions."),this.essentialBadgeLabel=this.translate("common.cookies.categories.essential.badge","إجباري","Required"),this.performanceTitleLabel=this.translate("common.cookies.categories.performance.title","ملفات تعريف الارتباط الخاصة بالأداء","Performance Cookies"),this.performanceDescriptionLabel=this.translate("common.cookies.categories.performance.description","تساعدنا في تحليل كيفية استخدامك للموقع وتحسين أدائه.","Help us analyze site usage and improve performance."),this.functionsTitleLabel=this.translate("common.cookies.categories.functions.title","ملفات تعريف الارتباط الوظيفية","Functional Cookies"),this.functionsDescriptionLabel=this.translate("common.cookies.categories.functions.description","تُتيح لك تجربة مخصصة وتفعيل ميزات متقدمة داخل الموقع.","Enable enhanced functionality and personalization."),this.adsTitleLabel=this.translate("common.cookies.categories.ads.title","ملفات تعريف الارتباط الإعلانية","Advertising Cookies"),this.adsDescriptionLabel=this.translate("common.cookies.categories.ads.description","تُستخدم لعرض محتوى تسويقي مخصص يناسب اهتماماتك.","Allow personalized content.")}componentDidLoad(){this.mobileQuery=window.matchMedia(`(max-width: ${this.mobileBreakpoint-1}px)`),this.isMobile=this.mobileQuery.matches,this.mobileQuery.addEventListener("change",this.mobileQueryHandler)}disconnectedCallback(){this.mobileQuery?.removeEventListener("change",this.mobileQueryHandler),Salla.event.off("salla-cookies-bar::open",this.openRequestedHandler),Salla.event.off("auth::logged.in",this.authLoggedInHandler),Salla.event.off("auth::logged.out",this.authLoggedOutHandler),this.unregisterAfterFetchMenuItemsHook?.(),this.unregisterAfterFetchMenuItemsHook=void 0}allCategoryKeys(){return[this.necessaryCookieKey,this.performanceCookieKey,this.functionalCookieKey,this.advertisingCookieKey]}writeLocalConsentCookies(s){for(const t of this.allCategoryKeys())Salla.cookie.set(t,String(t===this.necessaryCookieKey||s.includes(t)),this.consentCookieDays)}applyConsent(s){this.writeLocalConsentCookies(s),this.clearSessionConsent(),Salla.storage.set(this.storeKey(this.consentByUserKey),!Salla.config.isGuest()),this.sweepDisabledCategoryCookies(s),Salla.config.isGuest()||Salla.api.request("account/data-privacy",{points:s},"post").catch((()=>{}))}currentConsentPoints(){return this.persistentConsentPoints()??this.sessionConsentPoints()}persistentConsentPoints(){return Salla.storage.get(this.consentStorageKey)?this.allCategoryKeys().filter((s=>s===this.necessaryCookieKey||"true"===Salla.cookie.get(s))):null}sessionConsentPoints(){if(!Salla.config.isGuest())return null;if(!Salla.storage.session?.get(this.storeKey(this.consentStorageKey)))return null;const s=Salla.storage.session.get(this.storeKey(this.sessionConsentPointsKey)),t=Array.isArray(s)?s:[];return this.allCategoryKeys().filter((s=>s===this.necessaryCookieKey||t.includes(s)))}clearSessionConsent(){Salla.storage.session?.remove(this.storeKey(this.consentStorageKey)),Salla.storage.session?.remove(this.storeKey(this.sessionConsentPointsKey))}enforceCurrentConsent(){const s=this.currentConsentPoints();s&&this.sweepDisabledCategoryCookies(s)}hydrateToggleState(){const s=this.currentConsentPoints();s&&(this.performanceEnabled=s.includes(this.performanceCookieKey),this.functionsEnabled=s.includes(this.functionalCookieKey),this.adsEnabled=s.includes(this.advertisingCookieKey))}handleLogout(){if(Salla.config.isGuest()&&!Salla.storage.get(this.storeKey(this.consentByUserKey)))return;const s=Salla.storage.get(this.consentStorageKey),t=this.persistentConsentPoints();s&&t&&(Salla.storage.session?.set(this.storeKey(this.consentStorageKey),s),Salla.storage.session?.set(this.storeKey(this.sessionConsentPointsKey),t));for(const s of this.allCategoryKeys())Salla.cookie.remove(s);Salla.storage.remove(this.consentStorageKey),Salla.storage.remove(this.storeKey(this.consentByUserKey))}syncConsentAfterLogin(){if(Salla.config.isGuest())return;this.clearSessionConsent();const s=this.persistentConsentPoints();if(!s)return this.step="consent",void(this.isVisible=!0);if(Salla.storage.get(this.storeKey(this.consentByUserKey)))return;const t=Salla.config.get("user.id");Salla.api.request("account/data-privacy",{points:s},"post").then((()=>{const i=this.persistentConsentPoints();!Salla.config.isGuest()&&Salla.config.get("user.id")===t&&i?.length===s.length&&s.every((s=>i.includes(s)))&&Salla.storage.set(this.storeKey(this.consentByUserKey),!0)})).catch((()=>{}))}cookieNameMatchesPattern(s,t){return t.endsWith("*")?s.startsWith(t.slice(0,-1)):s===t}sweepDisabledCategoryCookies(s){const t=Object.keys(this.trackingCookiesByCategory).filter((t=>!s.includes(t)));if(!t.length)return;const i=t.flatMap((s=>this.trackingCookiesByCategory[s]));document.cookie.split(";").map((s=>s.split("=")[0].trim())).filter((s=>i.some((t=>this.cookieNameMatchesPattern(s,t))))).forEach((s=>Salla.cookie.remove(s)))}dismiss(s){this.isVisible=!1;try{Salla.event.emit(`salla-cookies-bar::${s}`)}finally{Salla.storage.set(this.consentStorageKey,s)}}savePreferences(){const s=[this.necessaryCookieKey];this.performanceEnabled&&s.push(this.performanceCookieKey),this.functionsEnabled&&s.push(this.functionalCookieKey),this.adsEnabled&&s.push(this.advertisingCookieKey),this.applyConsent(s),this.dismiss("accepted")}async accept(){return this.applyConsent(this.allCategoryKeys()),this.dismiss("accepted"),this.host}async reject(){return this.applyConsent([this.necessaryCookieKey]),this.dismiss("rejected"),this.host}async open(){return this.hydrateToggleState(),this.step="consent",this.isVisible=!0,this.host}openPreferences(){this.hydrateToggleState(),this.step="preferences"}isRtl(){return Salla.config.get("theme.is_rtl",!0)}appendCookiesSettingsLink(s){const t=Salla.config.get("store.features")?.includes("website-cookies");if(!t||!s?.withCookiePreferences||"footer"!==s?.source)return;const i="#cookies-settings",e=s?.menus.some((s=>s?.url===i));e||(s.menus=[...s.menus,{id:"cookies-settings",order:null,title:Salla.lang.get("common.cookies.settings"),url:i,target:"_self",is_by_form_builder:!1,children:[],image:null,callback:()=>Salla.event.emit("salla-cookies-bar::open")}])}renderToggle(s,i,e,o){return t("label",{class:{"s-toggle":!0,"s-toggle--disabled":i}},t("input",{class:"s-toggle-input",type:"checkbox",checked:s,disabled:i,"aria-label":e,onChange:()=>o?.()}),t("div",{class:"s-toggle-switcher"}))}renderCategory(s,i,e,o){return t("div",{class:"s-cookies-bar-category"},t("div",{class:"s-cookies-bar-category-content"},t("div",{class:"s-cookies-bar-category-title-row"},t("span",{class:"s-cookies-bar-category-title"},s),o&&t("span",{class:"s-cookies-bar-badge"},o)),t("p",{class:"s-cookies-bar-category-description m-0"},i)),e)}renderMessage(){return t("p",{class:"s-cookies-bar-message m-0"},this.messageLabel,Salla.config.get("policy_url")&&t("a",{href:Salla.config.get("policy_url"),target:"_blank",class:"s-cookies-bar-link text-primary ms-1"}," ",this.linkLabel))}renderConsentStep(){return t("div",{class:"s-cookies-bar-consent"},this.renderMessage(),t("div",{class:"s-cookies-bar-consent-actions"},t("salla-button",{class:"s-cookies-bar-btn--customize",color:"primary",fill:"outline",type:"button",size:this.isMobile?"small":"medium",onClick:()=>this.openPreferences()},this.customizeLabel),t("salla-button",{class:"s-cookies-bar-btn--accept",color:"primary",fill:"solid",type:"button",size:this.isMobile?"small":"medium",onClick:()=>this.accept()},this.acceptAllLabel)))}renderPreferencesStep(){return t("div",null,t("div",{class:"s-cookies-bar-header"},t("h3",{class:"s-cookies-bar-title m-0"},this.titleLabel),t("button",{type:"button",class:"s-cookies-bar-close","aria-label":this.titleLabel,onClick:()=>this.reject()},t("span",{innerHTML:o}))),t("div",{class:"s-cookies-bar-categories"},this.renderCategory(this.essentialTitleLabel,this.essentialDescriptionLabel,this.renderToggle(!0,!0,this.essentialTitleLabel),this.essentialBadgeLabel),this.renderCategory(this.performanceTitleLabel,this.performanceDescriptionLabel,this.renderToggle(this.performanceEnabled,!1,this.performanceTitleLabel,(()=>this.performanceEnabled=!this.performanceEnabled))),this.renderCategory(this.functionsTitleLabel,this.functionsDescriptionLabel,this.renderToggle(this.functionsEnabled,!1,this.functionsTitleLabel,(()=>this.functionsEnabled=!this.functionsEnabled))),this.renderCategory(this.adsTitleLabel,this.adsDescriptionLabel,this.renderToggle(this.adsEnabled,!1,this.adsTitleLabel,(()=>this.adsEnabled=!this.adsEnabled)))),t("div",{class:"s-cookies-bar-footer"},this.renderMessage(),t("salla-button",{class:"s-cookies-bar-btn--save",color:"primary",fill:"solid",type:"button",size:this.isMobile?"small":"medium",onClick:()=>this.savePreferences()},this.saveLabel)))}render(){return this.isVisible?t(i,null,t("div",{dir:this.isRtl()?"rtl":"ltr",class:"s-cookies-bar"},"consent"===this.step?this.renderConsentStep():this.renderPreferencesStep())):t(i,null)}get host(){return e(this)}};a.style='/*!twlt*/:host{display:block;overflow:visible}.s-cookies-bar{position:fixed;bottom:1rem;left:50%;transform:translateX(-50%);z-index:100;background-color:#fff;border-radius:1rem;padding:1.25rem;width:calc(100% - 2rem);max-width:48rem;box-shadow:0 10px 30px -5px rgba(0, 0, 0, 0.2)}.s-cookies-bar-consent{display:flex;flex-direction:row;align-items:center;gap:1rem;flex-wrap:wrap}@media (max-width: 640px){.s-cookies-bar-consent{flex-direction:column;align-items:end}}.s-cookies-bar-consent-actions{display:flex;align-items:center;gap:0.75rem;flex-shrink:0}.s-cookies-bar-header{display:flex;align-items:center;justify-content:space-between;gap:1rem;margin-bottom:1.25rem}.s-cookies-bar-title{font-size:1rem;font-weight:bold;color:#1f2937}.s-cookies-bar-close{display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;padding:0;border:none;background:transparent;cursor:pointer;flex-shrink:0}.s-cookies-bar-close svg{width:1.125rem;height:1.125rem;fill:currentColor}.s-cookies-bar-close:hover{color:#4b5563}.s-cookies-bar-categories{display:flex;flex-direction:column;gap:1rem}.s-cookies-bar-category{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem}.s-cookies-bar-category .s-toggle{flex-shrink:0}.s-cookies-bar-category .s-toggle--disabled{cursor:not-allowed}.s-cookies-bar-category-title-row{display:flex;align-items:center;gap:0.5rem}.s-cookies-bar-category-title{font-size:0.875rem;font-weight:500;color:#1f2937}.s-cookies-bar-category-description{font-size:0.75rem;color:#9ca3af;margin-top:0.25rem}.s-cookies-bar-badge{display:inline-flex;align-items:center;padding:0.0625rem 0.5rem;border-radius:9999px;background-color:#f3f4f6;color:#6b7280;font-size:0.6875rem;font-weight:500;white-space:nowrap}.s-cookies-bar-footer{display:flex;align-items:center;gap:0.75rem;margin-top:1.25rem;padding-top:1.25rem;border-top:1px solid #e5e7eb}.s-cookies-bar-message{flex:1;font-size:0.75rem;line-height:1.625;font-weight:700}.s-cookies-bar-btn--save{flex-shrink:0}.visible{visibility:visible}.invisible{visibility:hidden}.m-0{margin:0px}.ms-1{margin-inline-start:0.25rem}.hidden{display:none}.resize{resize:both}.text-primary{color:var(--color-primary)}.shadow{--tw-shadow:0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px 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{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)}.toggle-checkbox .s-toggle-input{position:absolute;visibility:hidden}.toggle-checkbox .s-toggle-switcher{display:inline-block;background:#ccc;border-radius:16px;width:40px;height:25px;position:relative;vertical-align:middle;transition:background 0.25s}.toggle-checkbox .s-toggle-switcher:before,.toggle-checkbox .s-toggle-switcher:after{content:""}.toggle-checkbox .s-toggle-switcher:before{display:block;background:#fff;border-radius:50%;box-shadow:0 0 0 1px rgba(0,0,0,0.25);width:20px;height:21px;position:absolute;top:2.2px;left:1px;transition:left 0.25s}.toggle-checkbox .s-toggle-input:checked+div{background:#30D158}.toggle-checkbox .s-toggle-input:checked+div:before{left:18px}.s-toggle{cursor:pointer;display:inline-block}.s-toggle .s-toggle-input{position:absolute;visibility:hidden}.s-toggle .s-toggle-label{margin-left:5px;position:relative;top:2px}.s-toggle .s-toggle-switcher{display:inline-block;background:#ccc;border-radius:16px;width:40px;height:25px;position:relative;vertical-align:middle;transition:background 0.25s}.s-toggle .s-toggle-switcher:before,.s-toggle .s-toggle-switcher:after{content:""}.s-toggle .s-toggle-switcher:before{display:block;background:#fff;border-radius:50%;box-shadow:0 0 0 1px rgba(0,0,0,0.25);width:20px;height:21px;position:absolute;top:2.2px;left:1px;transition:left 0.25s}.s-toggle .s-toggle-input:checked+div{background:#30D158}.s-toggle .s-toggle-input:checked+div:before{left:18px}';export{a as salla_cookies_bar}
4
+ import{r as s,h as t,H as i,a as e}from"./p-g-_4am8C.js";import{C as o}from"./p-BsLF_HK7.js";const a=class{constructor(t){s(this,t),this.isVisible=!0,this.step="consent",this.isMobile=!1,this.mobileBreakpoint=768,this.mobileQueryHandler=s=>this.isMobile=s.matches,this.openRequestedHandler=()=>this.open(),this.authLoggedInHandler=()=>this.syncConsentAfterLogin(),this.authLoggedOutHandler=()=>this.handleLogout(),this.necessaryCookieKey="necessary_cookies",this.performanceCookieKey="performance_cookies",this.functionalCookieKey="functional_cookies",this.advertisingCookieKey="advertising_cookies",this.consentCookieDays=365,this.consentStorageKey="cookies-consent",this.sessionConsentPointsKey="cookies-consent-points",this.consentByUserKey="cookies-consent-by-user",this.trackingCookiesByCategory={performance_cookies:["_ga","_ga_*","_gid","_gat","_gat_gtag_*","_hjSessionUser_*","_hjSession_*","_hjIncludedInSessionSample_*","_hjAbsoluteSessionInProgress","_hjFirstSeen","_clck","_clsk","MUID","MR","ANONCHK","_ym_uid","_ym_d","_ym_isad"],advertising_cookies:["_gcl_au","_gcl_aw","_gcl_dc","IDE","test_cookie","1P_JAR","NID","_fbp","_fbc","fr","_ttp","_scid","sc_at","personalization_id","guest_id","muc_ads","_pin_unauth","_pinterest_ct_ua","li_sugr","bcookie","lidc","UserMatchHistory","AnalyticsSyncHistory"],functional_cookies:["intercom-id-*","intercom-session-*","__zlcmid","crisp-client%2Fsession%2F*","YSC","VISITOR_INFO1_LIVE","PREF"]},this.performanceEnabled=!1,this.functionsEnabled=!1,this.adsEnabled=!1}storeKey(s){return`${s}_${Salla.config.get("store.id")}`}async componentWillLoad(){await Salla.onReady(),await Salla.lang.onLoaded(),this.loadTranslations(),Salla.event.on("salla-cookies-bar::open",this.openRequestedHandler),Salla.event.on("auth::logged.in",this.authLoggedInHandler),Salla.event.on("auth::logged.out",this.authLoggedOutHandler),this.unregisterAfterFetchMenuItemsHook=Salla.hooks.registerHook("salla-menu","afterFetchMenuItems",(s=>this.appendCookiesSettingsLink(s))),this.hydrateToggleState(),this.currentConsentPoints()&&(this.isVisible=!1),this.enforceCurrentConsent()}isArabicLocale(){return(Salla.lang.getLocale?.()??document.documentElement.lang??"ar").toLowerCase().startsWith("ar")}translate(s,t,i){const e=Salla.lang.get(s);return e&&e!==s?e:this.isArabicLocale()?t:i}loadTranslations(){this.titleLabel=this.translate("common.cookies.settings_title","تخصيص إعدادات ملفات تعريف الارتباط","Customize Cookie Preferences Settings"),this.saveLabel=this.translate("common.cookies.save","حفظ الخيارات","Save Options"),this.messageLabel=Salla.lang.get("common.cookies.message"),this.linkLabel=Salla.lang.get("common.cookies.link"),this.acceptLabel=this.translate("common.cookies.accept","قبول","Accept"),this.acceptAllLabel=this.translate("common.cookies.accept_all","قبول الكل","Accept All"),this.customizeLabel=this.translate("common.cookies.customize","تخصيص","Customize"),this.essentialTitleLabel=this.translate("common.cookies.categories.essential.title","ملفات تعريف الارتباط الضرورية","Essential Cookies"),this.essentialDescriptionLabel=this.translate("common.cookies.categories.essential.description","ضروريه لتشغيل الوظائف الأساسية للموقع الإلكتروني.","Required for the website's basic functions."),this.essentialBadgeLabel=this.translate("common.cookies.categories.essential.badge","إجباري","Required"),this.performanceTitleLabel=this.translate("common.cookies.categories.performance.title","ملفات تعريف الارتباط الخاصة بالأداء","Performance Cookies"),this.performanceDescriptionLabel=this.translate("common.cookies.categories.performance.description","تساعدنا في تحليل كيفية استخدامك للموقع وتحسين أدائه.","Help us analyze site usage and improve performance."),this.functionsTitleLabel=this.translate("common.cookies.categories.functions.title","ملفات تعريف الارتباط الوظيفية","Functional Cookies"),this.functionsDescriptionLabel=this.translate("common.cookies.categories.functions.description","تُتيح لك تجربة مخصصة وتفعيل ميزات متقدمة داخل الموقع.","Enable enhanced functionality and personalization."),this.adsTitleLabel=this.translate("common.cookies.categories.ads.title","ملفات تعريف الارتباط الإعلانية","Advertising Cookies"),this.adsDescriptionLabel=this.translate("common.cookies.categories.ads.description","تُستخدم لعرض محتوى تسويقي مخصص يناسب اهتماماتك.","Allow personalized content.")}componentDidLoad(){this.mobileQuery=window.matchMedia(`(max-width: ${this.mobileBreakpoint-1}px)`),this.isMobile=this.mobileQuery.matches,this.mobileQuery.addEventListener("change",this.mobileQueryHandler)}disconnectedCallback(){this.mobileQuery?.removeEventListener("change",this.mobileQueryHandler),Salla.event.off("salla-cookies-bar::open",this.openRequestedHandler),Salla.event.off("auth::logged.in",this.authLoggedInHandler),Salla.event.off("auth::logged.out",this.authLoggedOutHandler),this.unregisterAfterFetchMenuItemsHook?.(),this.unregisterAfterFetchMenuItemsHook=void 0}allCategoryKeys(){return[this.necessaryCookieKey,this.performanceCookieKey,this.functionalCookieKey,this.advertisingCookieKey]}writeLocalConsentCookies(s){for(const t of this.allCategoryKeys())Salla.cookie.set(t,String(t===this.necessaryCookieKey||s.includes(t)),this.consentCookieDays)}applyConsent(s){this.writeLocalConsentCookies(s),this.clearSessionConsent(),Salla.storage.set(this.storeKey(this.consentByUserKey),!Salla.config.isGuest()),this.sweepDisabledCategoryCookies(s),Salla.config.isGuest()||Salla.api.request("account/data-privacy",{points:s},"post").catch((()=>{}))}currentConsentPoints(){return this.persistentConsentPoints()??this.sessionConsentPoints()}persistentConsentPoints(){return Salla.storage.get(this.consentStorageKey)?this.allCategoryKeys().filter((s=>s===this.necessaryCookieKey||"true"===Salla.cookie.get(s))):null}sessionConsentPoints(){if(!Salla.config.isGuest())return null;if(!Salla.storage.session?.get(this.storeKey(this.consentStorageKey)))return null;const s=Salla.storage.session.get(this.storeKey(this.sessionConsentPointsKey)),t=Array.isArray(s)?s:[];return this.allCategoryKeys().filter((s=>s===this.necessaryCookieKey||t.includes(s)))}clearSessionConsent(){Salla.storage.session?.remove(this.storeKey(this.consentStorageKey)),Salla.storage.session?.remove(this.storeKey(this.sessionConsentPointsKey))}enforceCurrentConsent(){const s=this.currentConsentPoints();s&&this.sweepDisabledCategoryCookies(s)}hydrateToggleState(){const s=this.currentConsentPoints();s&&(this.performanceEnabled=s.includes(this.performanceCookieKey),this.functionsEnabled=s.includes(this.functionalCookieKey),this.adsEnabled=s.includes(this.advertisingCookieKey))}handleLogout(){if(Salla.config.isGuest()&&!Salla.storage.get(this.storeKey(this.consentByUserKey)))return;const s=Salla.storage.get(this.consentStorageKey),t=this.persistentConsentPoints();s&&t&&(Salla.storage.session?.set(this.storeKey(this.consentStorageKey),s),Salla.storage.session?.set(this.storeKey(this.sessionConsentPointsKey),t));for(const s of this.allCategoryKeys())Salla.cookie.remove(s);Salla.storage.remove(this.consentStorageKey),Salla.storage.remove(this.storeKey(this.consentByUserKey))}syncConsentAfterLogin(){if(Salla.config.isGuest())return;this.clearSessionConsent();const s=this.persistentConsentPoints();if(!s)return this.step="consent",void(this.isVisible=!0);if(Salla.storage.get(this.storeKey(this.consentByUserKey)))return;const t=Salla.config.get("user.id");Salla.api.request("account/data-privacy",{points:s},"post").then((()=>{const i=this.persistentConsentPoints();!Salla.config.isGuest()&&Salla.config.get("user.id")===t&&i?.length===s.length&&s.every((s=>i.includes(s)))&&Salla.storage.set(this.storeKey(this.consentByUserKey),!0)})).catch((()=>{}))}cookieNameMatchesPattern(s,t){return t.endsWith("*")?s.startsWith(t.slice(0,-1)):s===t}sweepDisabledCategoryCookies(s){const t=Object.keys(this.trackingCookiesByCategory).filter((t=>!s.includes(t)));if(!t.length)return;const i=t.flatMap((s=>this.trackingCookiesByCategory[s]));document.cookie.split(";").map((s=>s.split("=")[0].trim())).filter((s=>i.some((t=>this.cookieNameMatchesPattern(s,t))))).forEach((s=>Salla.cookie.remove(s)))}dismiss(s){this.isVisible=!1;try{Salla.event.emit(`salla-cookies-bar::${s}`)}finally{Salla.storage.set(this.consentStorageKey,s)}}savePreferences(){const s=[this.necessaryCookieKey];this.performanceEnabled&&s.push(this.performanceCookieKey),this.functionsEnabled&&s.push(this.functionalCookieKey),this.adsEnabled&&s.push(this.advertisingCookieKey),this.applyConsent(s),this.dismiss("accepted")}async accept(){return this.applyConsent(this.allCategoryKeys()),this.dismiss("accepted"),this.host}async reject(){return this.applyConsent([this.necessaryCookieKey]),this.dismiss("rejected"),this.host}async open(){return this.hydrateToggleState(),this.step="consent",this.isVisible=!0,this.host}openPreferences(){this.hydrateToggleState(),this.step="preferences"}isRtl(){return Salla.config.get("theme.is_rtl",!0)}appendCookiesSettingsLink(s){const t=Salla.config.get("store.features")?.includes("website-cookies");if(!t||!s?.withCookiePreferences||"footer"!==s?.source)return;const i="#cookies-settings",e=s?.menus.some((s=>s?.url===i));e||(s.menus=[...s.menus,{id:"cookies-settings",order:null,title:Salla.lang.get("common.cookies.settings"),url:i,target:"_self",is_by_form_builder:!1,children:[],image:null,callback:()=>Salla.event.emit("salla-cookies-bar::open")}])}renderToggle(s,i,e,o){return t("label",{class:{"s-toggle":!0,"s-toggle--disabled":i}},t("input",{class:"s-toggle-input",type:"checkbox",checked:s,disabled:i,"aria-label":e,onChange:()=>o?.()}),t("div",{class:"s-toggle-switcher"}))}renderCategory(s,i,e,o){return t("div",{class:"s-cookies-bar-category"},t("div",{class:"s-cookies-bar-category-content"},t("div",{class:"s-cookies-bar-category-title-row"},t("span",{class:"s-cookies-bar-category-title"},s),o&&t("span",{class:"s-cookies-bar-badge"},o)),t("p",{class:"s-cookies-bar-category-description m-0"},i)),e)}renderMessage(){return t("p",{class:"s-cookies-bar-message m-0"},this.messageLabel,Salla.config.get("policy_url")&&t("a",{href:Salla.config.get("policy_url"),target:"_blank",class:"s-cookies-bar-link text-primary ms-1"}," ",this.linkLabel))}renderConsentStep(){return t("div",{class:"s-cookies-bar-consent"},this.renderMessage(),t("div",{class:"s-cookies-bar-consent-actions"},t("salla-button",{class:"s-cookies-bar-btn--customize",color:"primary",fill:"outline",type:"button",size:this.isMobile?"small":"medium",onClick:()=>this.openPreferences()},this.customizeLabel),t("salla-button",{class:"s-cookies-bar-btn--accept",color:"primary",fill:"solid",type:"button",size:this.isMobile?"small":"medium",onClick:()=>this.accept()},this.acceptAllLabel)))}renderPreferencesStep(){return t("div",null,t("div",{class:"s-cookies-bar-header"},t("h3",{class:"s-cookies-bar-title m-0"},this.titleLabel),t("button",{type:"button",class:"s-cookies-bar-close","aria-label":this.titleLabel,onClick:()=>this.reject()},t("span",{innerHTML:o}))),t("div",{class:"s-cookies-bar-categories"},this.renderCategory(this.essentialTitleLabel,this.essentialDescriptionLabel,this.renderToggle(!0,!0,this.essentialTitleLabel),this.essentialBadgeLabel),this.renderCategory(this.performanceTitleLabel,this.performanceDescriptionLabel,this.renderToggle(this.performanceEnabled,!1,this.performanceTitleLabel,(()=>this.performanceEnabled=!this.performanceEnabled))),this.renderCategory(this.functionsTitleLabel,this.functionsDescriptionLabel,this.renderToggle(this.functionsEnabled,!1,this.functionsTitleLabel,(()=>this.functionsEnabled=!this.functionsEnabled))),this.renderCategory(this.adsTitleLabel,this.adsDescriptionLabel,this.renderToggle(this.adsEnabled,!1,this.adsTitleLabel,(()=>this.adsEnabled=!this.adsEnabled)))),t("div",{class:"s-cookies-bar-footer"},this.renderMessage(),t("salla-button",{class:"s-cookies-bar-btn--save",color:"primary",fill:"solid",type:"button",size:this.isMobile?"small":"medium",onClick:()=>this.savePreferences()},this.saveLabel)))}render(){return this.isVisible?t(i,null,t("div",{dir:this.isRtl()?"rtl":"ltr",class:"s-cookies-bar"},"consent"===this.step?this.renderConsentStep():this.renderPreferencesStep())):t(i,null)}get host(){return e(this)}};a.style='/*!twlt*/:host{display:block;overflow:visible}.s-cookies-bar{position:fixed;bottom:1rem;left:50%;transform:translateX(-50%);z-index:100;background-color:#fff;border-radius:1rem;padding:1.25rem;width:calc(100% - 2rem);max-width:48rem;box-shadow:0 10px 30px -5px rgba(0, 0, 0, 0.2)}.s-cookies-bar-consent{display:flex;flex-direction:row;align-items:center;gap:1rem;flex-wrap:wrap}@media (max-width: 640px){.s-cookies-bar-consent{flex-direction:column;align-items:end}}.s-cookies-bar-consent-actions{display:flex;align-items:center;gap:0.75rem;flex-shrink:0}.s-cookies-bar-header{display:flex;align-items:center;justify-content:space-between;gap:1rem;margin-bottom:1.25rem}.s-cookies-bar-title{font-size:1rem;font-weight:bold;color:#1f2937}.s-cookies-bar-close{display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;padding:0;border:none;background:transparent;cursor:pointer;flex-shrink:0}.s-cookies-bar-close svg{width:1.125rem;height:1.125rem;fill:currentColor}.s-cookies-bar-close:hover{color:#4b5563}.s-cookies-bar-categories{display:flex;flex-direction:column;gap:1rem}.s-cookies-bar-category{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem}.s-cookies-bar-category .s-toggle{flex-shrink:0}.s-cookies-bar-category .s-toggle--disabled{cursor:not-allowed}.s-cookies-bar-category-title-row{display:flex;align-items:center;gap:0.5rem}.s-cookies-bar-category-title{font-size:0.875rem;font-weight:500;color:#1f2937}.s-cookies-bar-category-description{font-size:0.75rem;color:#9ca3af;margin-top:0.25rem}.s-cookies-bar-badge{display:inline-flex;align-items:center;padding:0.0625rem 0.5rem;border-radius:9999px;background-color:#f3f4f6;color:#6b7280;font-size:0.6875rem;font-weight:500;white-space:nowrap}.s-cookies-bar-footer{display:flex;align-items:center;gap:0.75rem;margin-top:1.25rem;padding-top:1.25rem;border-top:1px solid #e5e7eb}.s-cookies-bar-message{flex:1;font-size:0.75rem;line-height:1.625;font-weight:700}.s-cookies-bar-btn--save{flex-shrink:0}.visible{visibility:visible}.invisible{visibility:hidden}.m-0{margin:0px}.ms-1{margin-inline-start:0.25rem}.hidden{display:none}.resize{resize:both}.text-primary{color:var(--color-primary)}.shadow{--tw-shadow:0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px 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{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)}.toggle-checkbox .s-toggle-input{position:absolute;visibility:hidden}.toggle-checkbox .s-toggle-switcher{display:inline-block;background:#ccc;border-radius:16px;width:40px;height:25px;position:relative;vertical-align:middle;transition:background 0.25s}.toggle-checkbox .s-toggle-switcher:before,.toggle-checkbox .s-toggle-switcher:after{content:""}.toggle-checkbox .s-toggle-switcher:before{display:block;background:#fff;border-radius:50%;box-shadow:0 0 0 1px rgba(0,0,0,0.25);width:20px;height:21px;position:absolute;top:2.2px;left:1px;transition:left 0.25s}.toggle-checkbox .s-toggle-input:checked+div{background:#30D158}.toggle-checkbox .s-toggle-input:checked+div:before{left:18px}.s-toggle{cursor:pointer;display:inline-block}.s-toggle .s-toggle-input{position:absolute;visibility:hidden}.s-toggle .s-toggle-label{margin-left:5px;position:relative;top:2px}.s-toggle .s-toggle-switcher{display:inline-block;background:#ccc;border-radius:16px;width:40px;height:25px;position:relative;vertical-align:middle;transition:background 0.25s}.s-toggle .s-toggle-switcher:before,.s-toggle .s-toggle-switcher:after{content:""}.s-toggle .s-toggle-switcher:before{display:block;background:#fff;border-radius:50%;box-shadow:0 0 0 1px rgba(0,0,0,0.25);width:20px;height:21px;position:absolute;top:2.2px;left:1px;transition:left 0.25s}.s-toggle .s-toggle-input:checked+div{background:#30D158}.s-toggle .s-toggle-input:checked+div:before{left:18px}';export{a as salla_cookies_bar}
@@ -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 r}from"./p-ze9e0dxM.js";var o,n;!function(t){t.PERCENTAGE="percentage",t.FIXED="fixed",t.FREE_PRODUCT="free_product",t.FREE_SHIPPING="free_shipping"}(o||(o={})),function(t){t.PRODUCT_COUNT="products_count",t.PRODUCT_PURCHASE="order_amount"}(n||(n={}));const s=Object.freeze([]),a=Object.freeze([]);let l,c=null,d=null,h=null,f=!1,u=null,p=null,g=0;function m(t){return"CartNotCreated"===t?.name}function b(){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 w(){const t=b();void 0!==l&&l!==t&&(g++,d=null,c=null,h=null,f=!1,u=null),l=t}function y(t){return null==t?0:"number"==typeof t?isFinite(t)?t:0:"string"==typeof t&&parseFloat(t)||0}function x(t){if(null==t||""===t)return null;const i=y(t);return isFinite(i)?i:null}function v(t,i){if(null!==i)return i.length;const e=x(t?.data?.cart?.count??t?.data?.count??t?.cart?.count??t?.count);return null!==e&&e>=0?e:null}function k(t){for(const i of[t?.original_price,t?.product_price,t?.price]){const t=x(i&&"object"==typeof i?i.amount:i);if(null!==t&&t>0)return t}return null}function _(t,i){const e=t?.free_gift_quantity;return null!=e&&""!==e?y(e):i>0?i:0}function C(t){const i=[];for(const e of t){if(null==e?.id)continue;if(!e.added_by_offer)continue;const t=y(e.quantity),r=_(e,t);r<=0||i.push({id:String(e.id),offerId:x(e.offer_id),quantity:r,freeQuantity:r,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:k(e)})}return i}function M(t){const i=[];for(const e of t){if(null==e?.id)continue;const t=y(e.quantity);i.push({id:String(e.id),productId:x(e.product_id),quantity:t,freeQuantity:e.added_by_offer?Math.max(0,_(e,t)):0,offerId:e.added_by_offer?x(e.offer_id):null})}return i}function P(){if(u)return u;const t=g,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),e=i??[];return{gifts:C(e),lines:M(e),count:v(t,i),ok:!0}})).catch((t=>({gifts:d??[],lines:c??[],count:m(t)?0:h,ok:!1}))).then((({gifts:i,lines:e,count:r,ok:o})=>{t===g&&(d=i,c=e,h=r,f=o)})).finally((()=>{u===i&&(u=null)}));return u=i,i}function S(){return w(),f}function T(){if(p)return p;g++,d=null,c=null,h=null,f=!1,l=b();const t=()=>(p===i&&(p=null),P()),i=(u??Promise.resolve()).then(t,t).finally((()=>{p===i&&(p=null)}));return p=i,i}const z=-1;var L,$;function F(t){const i="number"==typeof t?t:parseFloat(t);return Number.isFinite(i)?i:null}function I(t){return"boolean"==typeof t?t:1===t||0===t?1===t:"true"===t||"1"===t||"false"!==t&&"0"!==t&&void 0}function N(t){return F(t)??0}function R(t,i,e){return Math.max(i,Math.min(t,e))}function j(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"}(L||(L={})),function(t){t.CURRENCY="currency",t.COUNT="count"}($||($={}));const V=[1e3,2e3,4e3],A='[data-testid^="store-cart-item-"], form[id^="item-"]',H="salla-conditional-offer:reloaded-for",O='form[id^="item-"]:not(.cart-options form)';let q=0;const B={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",free_products_unavailable:"The free products are currently unavailable",free_products_choose:"Choose :count free products",free_products_choose_two:"Choose 2 free products",free_product_choose_one:"Choose your free product",free_product_got_one:"You got a free product",free_product_got_pick_one:"You got a free product! Choose it now",free_products_got:"You got :count free products",free_products_got_pick:"You got :count free products! Choose them now",free_products_got_pick_two:"You got 2 free products! Choose them now",free_products_got_two:"You got 2 free products",free_product_reward_one:"a free product",free_products_reward:":count free products",free_products_reward_two:"2 free products",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",offer_toggle:"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)"},D="pages.checkout.free_charge";function G(t){const i=document.createElement("div");return i.textContent=t??"",i.innerHTML}const Y=(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"})),E=(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"})),W=(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"})),Z=class{constructor(i){t(this,i),this.offer=null,this.isLoading=!1,this.canRender=!0,this.gifts=[],this.cartLines=[],this.cartLinesLoaded=!1,this.freeProductCards={},this.pendingFreeProduct=null,this.pendingFreeProductSettledAt=null,this.pendingFreeProductTimer=null,this.cartPageCheckAfter=null,this.insertingCartLines=!1,this.pendingCartPageLines=null,this.pickerLookupRetries=0,this.pickerLookupTimer=null,this.cartItemCount=null,this.isTooltipHovered=!1,this.isTooltipPinned=!1,this.isGiftsOpen=!0,this.instanceId=++q,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),this.unlockFreeProduct(),this.clearPickerLookupRetry(),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,A))return t.parentElement;const r=this.findColumnWithin(e,t);if(r)return r}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(A),r=(e?this.climbToChildOf(e,t):null)??t.querySelector(".main-content, [data-cart-items]");return!r||r===i||r.contains(i)?null:r}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(),this.clearPickerLookupRetry(),T().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(D);return t&&t!==D?t:"Free"}getAddLabel(){return this.sharedLabel("common.elements.add","Add")}sharedLabel(t,i){const e=salla.lang.get(t);return e&&e!==t?e:i}trans(t,i){const e=`blocks.cart_offer.${t}`,r=salla.lang.get(e,i);return r&&r!==e?r:Object.entries(i??{}).reduce(((t,[i,e])=>t.split(`:${i}`).join(e)),B[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(),void(S()||(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(),this.loadFreeProductCards()}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([(w(),f&&d?Promise.resolve(d):P().then((()=>d??s))),(w(),f&&d?Promise.resolve(h):P().then((()=>h))),(w(),f&&d?Promise.resolve(c??a):P().then((()=>c??a)))]).then((([i,e,r])=>{if(t!==this.giftsGeneration||this.isDisconnected)return;if(this.cartRefreshPending)return;const o=S();null!==e&&(this.cartItemCount=e),null!==e?this.clearCartLookupRetry():null===this.cartItemCount&&this.scheduleCartLookupRetry(),this.deferredByEmptyCart&&this.hasCartItems()&&(this.deferredByEmptyCart=!1,this.refresh());const n=null!==this.getPickerStage(this.getStages()),s=null!==this.pendingFreeProductSettledAt||null!==this.cartPageCheckAfter;o||!n&&!s?(this.clearPickerLookupRetry(),this.gifts=this.offer?this.selectOwnGifts(i):[],this.cartLines=this.offer?r:[],this.cartLinesLoaded=!!this.offer,null!==this.pendingFreeProductSettledAt&&t>this.pendingFreeProductSettledAt&&this.unlockFreeProduct(),null!==this.cartPageCheckAfter&&t>this.cartPageCheckAfter&&(this.cartPageCheckAfter=null,this.showMissingCartLines(r))):(s||!this.cartLinesLoaded&&this.hasCartItems())&&this.retryPickerCartLookup()})).catch((t=>{this.safeLog("cart lookup failed",t)}))}scheduleCartLookupRetry(){this.cartLookupRetries>=V.length||(this.cartLookupRetryPending=!0,null!==this.cartLookupRetryTimer||this.isDisconnected||(this.cartLookupRetryTimer=setTimeout((()=>{this.cartLookupRetryTimer=null,this.cartLookupRetryPending=!1,this.canRender&&(this.cartLookupRetries++,this.loadCart())}),V[this.cartLookupRetries])))}retryPickerCartLookup(){null!==this.pickerLookupTimer||this.pickerLookupRetries>=V.length||(this.pickerLookupTimer=setTimeout((()=>{this.pickerLookupTimer=null,this.pickerLookupRetries++,this.loadCart()}),V[this.pickerLookupRetries]))}clearPickerLookupRetry(){this.pickerLookupRetries=0,null!==this.pickerLookupTimer&&(clearTimeout(this.pickerLookupTimer),this.pickerLookupTimer=null)}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!==F(t)));return i=({min_spend:t})=>t,e=({id:t})=>t,(t??[]).map(((t,r)=>({item:t,index:r,threshold:N(i(t)),identity:e?F(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,r=[],o=[],n=[]){const s=(i??[]).map(((t,i)=>({index:i,threshold:F(t),applied:I(r?.[i]),tierValue:F(o?.[i]),canAddFree:"boolean"==typeof n?.[i]?n[i]:void 0}))).filter((t=>null!==t.threshold)).sort(((t,i)=>t.threshold-i.threshold||t.index-i.index)),a=s.map((t=>t.threshold)),l=s.map((t=>t.applied)),c=l.some((t=>void 0!==t)),d=N(e);if(!a.length)return{thresholds:a,met:[],applied:l,appliedIndex:z,hasEngineVerdict:c,metCount:0,nextUnmetIndex:z,allMet:!1,lastReachedIndex:z,currentIndex:z,isComplete:!1,value:Math.max(0,N(t)),values:[],startValue:d,fills:[],overallPercentage:0};const h=a[a.length-1],f=R(N(t),0,Math.max(0,h)),u=s.map((({tierValue:t})=>null===t?f:R(t,0,Math.max(0,h))));let p=z;for(let t=0;t<a.length;t++)u[t]>=a[t]&&(p=t);const g=p===a.length-1,m=g?z:p+1,b=a.map(((t,i)=>function(t,i,e){return e<=i?t>=e?100:0:R((t-i)/(e-i)*100,0,100)}(u[i],0===i?d:a[i-1],t))),w=g?100:R((p+1+(b[m]??0)/100)/a.length*100,0,100);let y=z;for(let t=0;t<l.length;t++)!0===l[t]&&(y=t);let x=z;for(let t=0;t<a.length;t++){const i=s[t].canAddFree;(void 0===i?u[t]>=a[t]:i)&&(x=t)}const v=a.map(c?(t,i)=>i<=y:(t,i)=>i<=x),k=v.filter(Boolean).length,_=v.findIndex((t=>!t));return{thresholds:a,met:v,applied:l,appliedIndex:y,hasEngineVerdict:c,metCount:k,nextUnmetIndex:_,allMet:_===z,lastReachedIndex:p,currentIndex:m,isComplete:g,value:f,values:u,startValue:d,fills:b,overallPercentage:w}}(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)),t.map((({can_add_free: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?$.COUNT:$.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){if(this.isPickerTier(t)){const i=Math.max(1,Math.floor(Number(t.max_free_products)||1));return 1===i?this.trans("free_product_reward_one"):2===i?this.trans("free_products_reward_two"):this.trans("free_products_reward",{count:`${i}`})}return(t?.reward_label??"").trim()}getGuidanceMessage(t,i){if(i.nextUnmetIndex===z)return"";const e=Number(t[i.nextUnmetIndex]?.amount_needed),r=this.isPickerTier(t[i.nextUnmetIndex])&&Number.isFinite(e)&&e>0?e:function(t,i,e=$.CURRENCY){const r=i.thresholds[t];if(void 0===r)return 0;const o=Math.max(0,r-(i.values?.[t]??i.value));if(0===o)return 0;const n=e===$.COUNT?0:function(){try{const t="undefined"!=typeof salla?salla:void 0,i=j(t?.config?.currency?.()?.decimals);if(null!==i)return i;const e=j(t?.config?.get?.("store.currency.decimals"));if(null!==e)return e}catch(t){}return 2}(),s=Math.pow(10,n),a=Math.ceil(o*s-1e-6)/s;return a>0?a:1/s}(i.nextUnmetIndex,i,this.stageMeasure());if(r<=0)return this.trans("guidance_conditions_unmet");const o=this.formatRequirement(r),n=this.getRewardText(t[i.nextUnmetIndex]);return n?this.trans("guidance_next",{remaining:o,reward:G(n)}):this.trans("guidance_next_generic",{remaining:o})}getTierSentence(t,i,e){const r=this.formatRequirement(e.thresholds[i]),o=this.getRewardText(t),n=this.stageMeasure()===$.COUNT;return o?this.trans(n?"tier_requirement_count":"tier_requirement",{threshold:r,reward:G(o)}):this.trans(n?"tier_requirement_count_generic":"tier_requirement_generic",{threshold:r})}getRewardIcon(t){switch(t?.type){case o.PERCENTAGE:return"sicon-percentage";case o.FREE_PRODUCT:return"sicon-gift";case o.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,r=t.getBoundingClientRect(),o=i.getBoundingClientRect(),n=r?.width||0;if(n<=0||e<=0)return;const s=o.left+o.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,r)=>{const o=e.met[r],n=this.tierKey(t,r);return[r>0?i("span",{key:`${n}-link`,class:{"s-conditional-offer-badge-link":!0,"s-conditional-offer-badge-link-met":o,"s-conditional-offer-badge-link-unmet":!o},"aria-hidden":"true"}):null,i("span",{key:n,class:{"s-conditional-offer-badge":!0,"s-conditional-offer-badge-met":o,"s-conditional-offer-badge-unmet":!o},"data-tier-state":o?"met":"unmet","data-tier-id":t?.id??void 0},i(o?Y:E,{class:"s-conditional-offer-badge-icon"}))]})))}renderTooltip(t,e){const r=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),r?i("div",{class:"s-conditional-offer-tooltip-description"},r):null,i("ul",{class:"s-conditional-offer-tooltip-list"},t.map(((t,r)=>{const o=e.met[r];return i("li",{key:this.tierKey(t,r),class:"s-conditional-offer-tier","data-tier-state":o?"met":"unmet","data-tier-id":t?.id??void 0},i("span",{class:{"s-conditional-offer-tier-icon":!0,"s-conditional-offer-tier-icon-met":o,"s-conditional-offer-tier-icon-unmet":!o}},i("i",{class:this.getRewardIcon(t),"aria-hidden":"true"}),i("span",{class:{"s-conditional-offer-tier-status":!0,"s-conditional-offer-tier-status-met":o,"s-conditional-offer-tier-status-unmet":!o},"aria-hidden":"true"},o?i(Y,{class:"s-conditional-offer-tier-status-check"}):i(E,{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:`${r+1}`})),i("div",{class:{"s-conditional-offer-tier-text":!0,"s-conditional-offer-tier-text-met":o},innerHTML:this.getTierSentence(t,r,e)})))}))))}getPickerStage(t){return t.find((t=>this.isPickerTier(t)))??null}isPickerTier(t){return t?.type===o.FREE_PRODUCT&&Array.isArray(t.free_products)&&t.free_products.length>0}areGiftsUnavailable(t,i){const e=t[i.lastReachedIndex];return e?.type===o.FREE_PRODUCT&&Array.isArray(e.free_products)&&0===e.free_products.length&&0===this.gifts.length}loadFreeProductCards(){const t=this.getPickerStage(this.getStages()),i=(t?.free_products??[]).map((t=>String(t.id))).filter((t=>t&&!this.freeProductCards[t]));if(!i.length)return Promise.resolve();const e=new Set((t.free_products??[]).map((t=>String(t.id))));return Promise.resolve().then((()=>salla.product.fetch({source:"selected",source_value:i}))).then((t=>{if(this.isDisconnected)return;const i={...this.freeProductCards};(Array.isArray(t?.data)?t.data:[]).forEach((t=>{const r=String(t?.id??"");r&&e.has(r)&&(i[r]={id:r,name:String(t.name??""),imageUrl:String(t.image?.url??""),imageAlt:String(t.image?.alt??t.name??""),price:Number.isFinite(Number(t.price))?Number(t.price):null})})),this.freeProductCards=i})).catch((t=>this.safeLog("free product lookup failed",t)))}getPickerState(t){const i=this.cartLines.filter((t=>t.freeQuantity>0)),e=this.selectOwnFreeLines(i),r=new Set(e.map((t=>t.productId)).filter((t=>null!==t))),o=Math.max(1,Math.floor(Number(t.max_free_products)||1)),n=Number(t.current_value??this.offer?.details?.current_value??0);return{limit:o,reached:"boolean"==typeof t.can_add_free?t.can_add_free:Number.isFinite(n)&&n>=Number(t.min_spend),freeCount:r.size}}selectOwnFreeLines(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))}addFreeProduct(t){this.pendingFreeProduct||(this.pendingFreeProduct=t.id,this.runFreeProductChange((()=>Promise.resolve(salla.cart.addItem(t.id)).then((()=>{this.cartPageCheckAfter=this.giftsGeneration}))),"free product add failed"))}reloadPage(){window.location.reload()}fetchCartPageHtml(){const t=new AbortController,i=setTimeout((()=>t.abort()),8e3);return fetch(window.location.href,{cache:"no-store",credentials:"same-origin",headers:{Accept:"text/html"},signal:t.signal}).then((t=>t.ok?t.text():Promise.reject(new Error(`cart page ${t.status}`)))).finally((()=>clearTimeout(i)))}showMissingCartLines(t){this.insertingCartLines?this.pendingCartPageLines=t:this.missingCartLineIds(t).length&&(this.insertingCartLines=!0,Promise.resolve().then((()=>this.fetchCartPageHtml())).then((t=>{if(this.isDisconnected||this.cartChangedDuringPageFetch())return;const i=this.missingCartLineIds(this.cartLines);i.length&&!this.insertCartLineForms(t,i)&&this.reloadForMissingCartLines(i)})).catch((t=>{this.safeLog("cart page fetch for the new lines failed, reloading",t),this.isDisconnected||this.cartChangedDuringPageFetch()||this.reloadForMissingCartLines(this.missingCartLineIds(this.cartLines))})).finally((()=>{this.insertingCartLines=!1;const t=this.pendingCartPageLines;this.pendingCartPageLines=null,t&&!this.isDisconnected&&this.showMissingCartLines(t)})))}cartChangedDuringPageFetch(){return!(null===this.pendingFreeProduct&&this.cartLinesLoaded||(null===this.cartPageCheckAfter&&(this.cartPageCheckAfter=this.giftsGeneration),0))}missingCartLineIds(t){try{return document.querySelector(O)?t.map((t=>t.id)).filter((t=>!document.getElementById(`item-${t}`))).sort():[]}catch(t){return this.safeLog("cart page check after a free product add failed",t),[]}}insertCartLineForms(t,i){try{const e=Array.from((new DOMParser).parseFromString(t,"text/html").querySelectorAll(O)),r=e.map((t=>t.getAttribute("id")));return!i.some((t=>!r.includes(`item-${t}`)))&&(e.forEach(((t,e)=>{const o=r[e];if(!i.includes(o.slice(5))||document.getElementById(o))return;const n=r.slice(e+1).map((t=>document.getElementById(t))).find(Boolean);if(n)n.parentNode.insertBefore(t,n);else{const i=document.querySelectorAll(O),e=i[i.length-1];e.parentNode.insertBefore(t,e.nextSibling)}})),i.every((t=>document.getElementById(`item-${t}`))))}catch(t){return this.safeLog("cart line insert failed",t),!1}}reloadForMissingCartLines(t){if(!t.length)return;const i=t.join(","),e=this.readReloadGuard();e!==i&&(void 0===e&&this.pageWasReloaded()||(this.writeReloadGuard(i),this.reloadPage()))}readReloadGuard(){try{return window.sessionStorage.getItem(H)}catch{return}}writeReloadGuard(t){try{window.sessionStorage.setItem(H,t)}catch{}}pageWasReloaded(){try{const t=window.performance?.getEntriesByType?.("navigation")?.[0];return"reload"===t?.type}catch{return!1}}runFreeProductChange(t,i){Promise.resolve().then(t).then((()=>{if(this.isDisconnected)return this.unlockFreeProduct();this.pendingFreeProductSettledAt=this.giftsGeneration,this.pendingFreeProductTimer=setTimeout((()=>this.unlockOnStaleLines()),5e3)})).catch((t=>{this.safeLog(i,t),this.unlockFreeProduct(),null!==this.cartPageCheckAfter&&this.loadCart()}))}unlockOnStaleLines(){this.unlockFreeProduct(),this.cartLinesLoaded=!1,this.clearPickerLookupRetry(),T().then((()=>this.loadCart()),(()=>this.loadCart()))}unlockFreeProduct(){null!==this.pendingFreeProductTimer&&clearTimeout(this.pendingFreeProductTimer),this.pendingFreeProductTimer=null,this.pendingFreeProductSettledAt=null,this.pendingFreeProduct=null}pickerGotMessage(t,i){return 1===t?this.trans(i?"free_product_got_pick_one":"free_product_got_one"):2===t?this.trans(i?"free_products_got_pick_two":"free_products_got_two"):this.trans(i?"free_products_got_pick":"free_products_got",{count:`${t}`})}getPickerCards(t){return(t.free_products??[]).map((t=>this.freeProductCards[String(t.id)])).filter(Boolean)}renderPicker(t){const e=this.getPickerState(t),r=this.getPickerCards(t);return r.length?i("div",{class:"s-conditional-offer-picker","data-picker-reached":e.reached?"true":"false"},i("div",{class:"s-conditional-offer-picker-header"},i("span",{class:"s-conditional-offer-picker-counter","aria-label":`${e.freeCount}/${e.limit}`},`${e.freeCount}/${e.limit}`),i("span",{class:"s-conditional-offer-picker-title"},1===e.limit?this.trans("free_product_choose_one"):2===e.limit?this.trans("free_products_choose_two"):this.trans("free_products_choose",{count:`${e.limit}`}))),i("ul",{class:"s-conditional-offer-picker-list"},r.map((t=>this.renderPickerCard(t))))):null}renderPickerCard(t){return i("li",{class:"s-conditional-offer-picker-card","data-product-id":t.id},i("span",{class:"s-conditional-offer-picker-thumb"},t.imageUrl?i("img",{class:"s-conditional-offer-picker-image",src:t.imageUrl,alt:t.imageAlt||t.name,loading:"lazy",decoding:"async"}):i("i",{class:"sicon-gift","aria-hidden":"true"})),i("span",{class:"s-conditional-offer-picker-name"},t.name),null!==t.price?i("span",{class:"s-conditional-offer-picker-prices"},i("span",{class:"s-conditional-offer-picker-price-regular",innerHTML:salla.money(t.price)})):null,i("span",{class:"s-conditional-offer-picker-actions"},i("button",{type:"button",class:"s-conditional-offer-picker-add",onClick:()=>this.addFreeProduct(t)},this.getAddLabel())))}renderGiftsToggle(t,e){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(e?"offer_toggle":"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(t=null){if(!t)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)))));const e=this.getPickerState(t);return i("div",{class:"s-conditional-offer-panel",id:this.elementId("gifts")},e.reached?this.renderPicker(t):null,this.gifts.length?i("div",{class:"s-conditional-offer-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.sharedLabel("pages.loyalty_program.free_product_title","Free products"))),i("ul",{class:"s-conditional-offer-gifts-list"},this.gifts.map((t=>this.renderGiftRow(t))))):null)}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(),r=this.getProgress(t),o=this.getGuidanceMessage(t,r),n=this.trans("details_title"),s=this.getPickerStage(t),a=null!==s?this.getPickerState(s):null,l=a?.reached??!1,c=this.gifts.length>0||l&&this.getPickerCards(s).length>0,d=l&&this.cartLinesLoaded&&0===a.freeCount,h=r.allMet&&l&&a.freeCount>0&&t[t.length-1]===s;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,r),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(W,{class:"s-conditional-offer-info-icon"})),this.isTooltipOpen?this.renderTooltip(t,r):null)),d||h?i("div",{class:"s-conditional-offer-message",role:"status"},this.pickerGotMessage(a.limit,d)):this.areGiftsUnavailable(t,r)?i("div",{class:"s-conditional-offer-message",role:"status"},this.trans("free_products_unavailable")):r.allMet?i("div",{class:"s-conditional-offer-message",role:"status"},this.trans("congrats")):o?i("div",{class:"s-conditional-offer-message",innerHTML:o}):null)),c?this.renderGiftsToggle("inline",!!s):null),c&&this.isGiftsOpen?this.renderGiftsCard(s):null,c?this.renderGiftsToggle("bar",!!s):null)}get hostEl(){return r(this)}};Z.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-gifts{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(249 250 251 / var(--tw-bg-opacity, 1));padding:0.75rem}.s-conditional-offer-picker{display:flex;width:100%;min-width:0px;flex-direction:column;gap:0.75rem}.s-conditional-offer-picker-header{display:flex;align-items:center;gap:0.5rem}.s-conditional-offer-picker-counter{display:inline-flex;height:2.25rem;width:2.25rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;border-width:2px;border-color:var(--color-primary);font-size:0.75rem;line-height:1rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-picker-title{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-picker-list{margin:0px;display:flex;list-style-type:none;gap:0.75rem;overflow-x:auto;overscroll-behavior-x:contain;scroll-behavior:smooth;padding:0px;padding-bottom:0.25rem;scrollbar-width:thin}.s-conditional-offer-picker-card{display:flex;width:9rem;flex-shrink:0;flex-direction:column;gap:0.375rem;text-align:start}.s-conditional-offer-picker-thumb{display:inline-flex;height:7rem;width:100%;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.5rem;line-height:2rem;--tw-text-opacity:1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.s-conditional-offer-picker-image{height:100%;width:100%;object-fit:contain}.s-conditional-offer-picker-name{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(38 38 38 / var(--tw-text-opacity, 1))}.s-conditional-offer-picker-prices{display:flex;align-items:center;gap:0.5rem;font-size:0.75rem;line-height:1rem}.s-conditional-offer-picker-price-regular{font-weight:700;--tw-text-opacity:1;color:rgb(23 23 23 / var(--tw-text-opacity, 1))}.s-conditional-offer-picker-actions{margin-top:auto;display:flex;width:100%;align-items:center;gap:0.375rem}.s-conditional-offer-picker-add{display:inline-flex;height:2.25rem;flex:1 1 0%;align-items:center;justify-content:center;border-radius:0.375rem;border-width:1px;border-color:var(--color-primary);font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark);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-picker-add:hover{background-color:var(--color-primary);--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.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{Z as salla_conditional_offer}
4
+ import{r as t,h as i,H as e,a as r}from"./p-g-_4am8C.js";var o,n;!function(t){t.PERCENTAGE="percentage",t.FIXED="fixed",t.FREE_PRODUCT="free_product",t.FREE_SHIPPING="free_shipping"}(o||(o={})),function(t){t.PRODUCT_COUNT="products_count",t.PRODUCT_PURCHASE="order_amount"}(n||(n={}));const s=Object.freeze([]),a=Object.freeze([]);let l,c=null,d=null,h=null,f=!1,u=null,p=null,g=0;function m(t){return"CartNotCreated"===t?.name}function b(){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 w(){const t=b();void 0!==l&&l!==t&&(g++,d=null,c=null,h=null,f=!1,u=null),l=t}function y(t){return null==t?0:"number"==typeof t?isFinite(t)?t:0:"string"==typeof t&&parseFloat(t)||0}function x(t){if(null==t||""===t)return null;const i=y(t);return isFinite(i)?i:null}function v(t,i){if(null!==i)return i.length;const e=x(t?.data?.cart?.count??t?.data?.count??t?.cart?.count??t?.count);return null!==e&&e>=0?e:null}function k(t){for(const i of[t?.original_price,t?.product_price,t?.price]){const t=x(i&&"object"==typeof i?i.amount:i);if(null!==t&&t>0)return t}return null}function _(t,i){const e=t?.free_gift_quantity;return null!=e&&""!==e?y(e):i>0?i:0}function C(t){const i=[];for(const e of t){if(null==e?.id)continue;if(!e.added_by_offer)continue;const t=y(e.quantity),r=_(e,t);r<=0||i.push({id:String(e.id),offerId:x(e.offer_id),quantity:r,freeQuantity:r,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:k(e)})}return i}function M(t){const i=[];for(const e of t){if(null==e?.id)continue;const t=y(e.quantity);i.push({id:String(e.id),productId:x(e.product_id),quantity:t,freeQuantity:e.added_by_offer?Math.max(0,_(e,t)):0,offerId:e.added_by_offer?x(e.offer_id):null})}return i}function P(){if(u)return u;const t=g,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),e=i??[];return{gifts:C(e),lines:M(e),count:v(t,i),ok:!0}})).catch((t=>({gifts:d??[],lines:c??[],count:m(t)?0:h,ok:!1}))).then((({gifts:i,lines:e,count:r,ok:o})=>{t===g&&(d=i,c=e,h=r,f=o)})).finally((()=>{u===i&&(u=null)}));return u=i,i}function S(){return w(),f}function T(){if(p)return p;g++,d=null,c=null,h=null,f=!1,l=b();const t=()=>(p===i&&(p=null),P()),i=(u??Promise.resolve()).then(t,t).finally((()=>{p===i&&(p=null)}));return p=i,i}const z=-1;var L,$;function F(t){const i="number"==typeof t?t:parseFloat(t);return Number.isFinite(i)?i:null}function I(t){return"boolean"==typeof t?t:1===t||0===t?1===t:"true"===t||"1"===t||"false"!==t&&"0"!==t&&void 0}function N(t){return F(t)??0}function R(t,i,e){return Math.max(i,Math.min(t,e))}function j(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"}(L||(L={})),function(t){t.CURRENCY="currency",t.COUNT="count"}($||($={}));const V=[1e3,2e3,4e3],A='[data-testid^="store-cart-item-"], form[id^="item-"]',H="salla-conditional-offer:reloaded-for",O='form[id^="item-"]:not(.cart-options form)';let q=0;const B={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",free_products_unavailable:"The free products are currently unavailable",free_products_choose:"Choose :count free products",free_products_choose_two:"Choose 2 free products",free_product_choose_one:"Choose your free product",free_product_got_one:"You got a free product",free_product_got_pick_one:"You got a free product! Choose it now",free_products_got:"You got :count free products",free_products_got_pick:"You got :count free products! Choose them now",free_products_got_pick_two:"You got 2 free products! Choose them now",free_products_got_two:"You got 2 free products",free_product_reward_one:"a free product",free_products_reward:":count free products",free_products_reward_two:"2 free products",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",offer_toggle:"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)"},D="pages.checkout.free_charge";function G(t){const i=document.createElement("div");return i.textContent=t??"",i.innerHTML}const Y=(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"})),E=(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"})),W=(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"})),Z=class{constructor(i){t(this,i),this.offer=null,this.isLoading=!1,this.canRender=!0,this.gifts=[],this.cartLines=[],this.cartLinesLoaded=!1,this.freeProductCards={},this.pendingFreeProduct=null,this.pendingFreeProductSettledAt=null,this.pendingFreeProductTimer=null,this.cartPageCheckAfter=null,this.insertingCartLines=!1,this.pendingCartPageLines=null,this.pickerLookupRetries=0,this.pickerLookupTimer=null,this.cartItemCount=null,this.isTooltipHovered=!1,this.isTooltipPinned=!1,this.isGiftsOpen=!0,this.instanceId=++q,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),this.unlockFreeProduct(),this.clearPickerLookupRetry(),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,A))return t.parentElement;const r=this.findColumnWithin(e,t);if(r)return r}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(A),r=(e?this.climbToChildOf(e,t):null)??t.querySelector(".main-content, [data-cart-items]");return!r||r===i||r.contains(i)?null:r}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(),this.clearPickerLookupRetry(),T().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(D);return t&&t!==D?t:"Free"}getAddLabel(){return this.sharedLabel("common.elements.add","Add")}sharedLabel(t,i){const e=salla.lang.get(t);return e&&e!==t?e:i}trans(t,i){const e=`blocks.cart_offer.${t}`,r=salla.lang.get(e,i);return r&&r!==e?r:Object.entries(i??{}).reduce(((t,[i,e])=>t.split(`:${i}`).join(e)),B[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(),void(S()||(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(),this.loadFreeProductCards()}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([(w(),f&&d?Promise.resolve(d):P().then((()=>d??s))),(w(),f&&d?Promise.resolve(h):P().then((()=>h))),(w(),f&&d?Promise.resolve(c??a):P().then((()=>c??a)))]).then((([i,e,r])=>{if(t!==this.giftsGeneration||this.isDisconnected)return;if(this.cartRefreshPending)return;const o=S();null!==e&&(this.cartItemCount=e),null!==e?this.clearCartLookupRetry():null===this.cartItemCount&&this.scheduleCartLookupRetry(),this.deferredByEmptyCart&&this.hasCartItems()&&(this.deferredByEmptyCart=!1,this.refresh());const n=null!==this.getPickerStage(this.getStages()),s=null!==this.pendingFreeProductSettledAt||null!==this.cartPageCheckAfter;o||!n&&!s?(this.clearPickerLookupRetry(),this.gifts=this.offer?this.selectOwnGifts(i):[],this.cartLines=this.offer?r:[],this.cartLinesLoaded=!!this.offer,null!==this.pendingFreeProductSettledAt&&t>this.pendingFreeProductSettledAt&&this.unlockFreeProduct(),null!==this.cartPageCheckAfter&&t>this.cartPageCheckAfter&&(this.cartPageCheckAfter=null,this.showMissingCartLines(r))):(s||!this.cartLinesLoaded&&this.hasCartItems())&&this.retryPickerCartLookup()})).catch((t=>{this.safeLog("cart lookup failed",t)}))}scheduleCartLookupRetry(){this.cartLookupRetries>=V.length||(this.cartLookupRetryPending=!0,null!==this.cartLookupRetryTimer||this.isDisconnected||(this.cartLookupRetryTimer=setTimeout((()=>{this.cartLookupRetryTimer=null,this.cartLookupRetryPending=!1,this.canRender&&(this.cartLookupRetries++,this.loadCart())}),V[this.cartLookupRetries])))}retryPickerCartLookup(){null!==this.pickerLookupTimer||this.pickerLookupRetries>=V.length||(this.pickerLookupTimer=setTimeout((()=>{this.pickerLookupTimer=null,this.pickerLookupRetries++,this.loadCart()}),V[this.pickerLookupRetries]))}clearPickerLookupRetry(){this.pickerLookupRetries=0,null!==this.pickerLookupTimer&&(clearTimeout(this.pickerLookupTimer),this.pickerLookupTimer=null)}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!==F(t)));return i=({min_spend:t})=>t,e=({id:t})=>t,(t??[]).map(((t,r)=>({item:t,index:r,threshold:N(i(t)),identity:e?F(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,r=[],o=[],n=[]){const s=(i??[]).map(((t,i)=>({index:i,threshold:F(t),applied:I(r?.[i]),tierValue:F(o?.[i]),canAddFree:"boolean"==typeof n?.[i]?n[i]:void 0}))).filter((t=>null!==t.threshold)).sort(((t,i)=>t.threshold-i.threshold||t.index-i.index)),a=s.map((t=>t.threshold)),l=s.map((t=>t.applied)),c=l.some((t=>void 0!==t)),d=N(e);if(!a.length)return{thresholds:a,met:[],applied:l,appliedIndex:z,hasEngineVerdict:c,metCount:0,nextUnmetIndex:z,allMet:!1,lastReachedIndex:z,currentIndex:z,isComplete:!1,value:Math.max(0,N(t)),values:[],startValue:d,fills:[],overallPercentage:0};const h=a[a.length-1],f=R(N(t),0,Math.max(0,h)),u=s.map((({tierValue:t})=>null===t?f:R(t,0,Math.max(0,h))));let p=z;for(let t=0;t<a.length;t++)u[t]>=a[t]&&(p=t);const g=p===a.length-1,m=g?z:p+1,b=a.map(((t,i)=>function(t,i,e){return e<=i?t>=e?100:0:R((t-i)/(e-i)*100,0,100)}(u[i],0===i?d:a[i-1],t))),w=g?100:R((p+1+(b[m]??0)/100)/a.length*100,0,100);let y=z;for(let t=0;t<l.length;t++)!0===l[t]&&(y=t);let x=z;for(let t=0;t<a.length;t++){const i=s[t].canAddFree;(void 0===i?u[t]>=a[t]:i)&&(x=t)}const v=a.map(c?(t,i)=>i<=y:(t,i)=>i<=x),k=v.filter(Boolean).length,_=v.findIndex((t=>!t));return{thresholds:a,met:v,applied:l,appliedIndex:y,hasEngineVerdict:c,metCount:k,nextUnmetIndex:_,allMet:_===z,lastReachedIndex:p,currentIndex:m,isComplete:g,value:f,values:u,startValue:d,fills:b,overallPercentage:w}}(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)),t.map((({can_add_free: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?$.COUNT:$.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){if(this.isPickerTier(t)){const i=Math.max(1,Math.floor(Number(t.max_free_products)||1));return 1===i?this.trans("free_product_reward_one"):2===i?this.trans("free_products_reward_two"):this.trans("free_products_reward",{count:`${i}`})}return(t?.reward_label??"").trim()}getGuidanceMessage(t,i){if(i.nextUnmetIndex===z)return"";const e=Number(t[i.nextUnmetIndex]?.amount_needed),r=this.isPickerTier(t[i.nextUnmetIndex])&&Number.isFinite(e)&&e>0?e:function(t,i,e=$.CURRENCY){const r=i.thresholds[t];if(void 0===r)return 0;const o=Math.max(0,r-(i.values?.[t]??i.value));if(0===o)return 0;const n=e===$.COUNT?0:function(){try{const t="undefined"!=typeof salla?salla:void 0,i=j(t?.config?.currency?.()?.decimals);if(null!==i)return i;const e=j(t?.config?.get?.("store.currency.decimals"));if(null!==e)return e}catch(t){}return 2}(),s=Math.pow(10,n),a=Math.ceil(o*s-1e-6)/s;return a>0?a:1/s}(i.nextUnmetIndex,i,this.stageMeasure());if(r<=0)return this.trans("guidance_conditions_unmet");const o=this.formatRequirement(r),n=this.getRewardText(t[i.nextUnmetIndex]);return n?this.trans("guidance_next",{remaining:o,reward:G(n)}):this.trans("guidance_next_generic",{remaining:o})}getTierSentence(t,i,e){const r=this.formatRequirement(e.thresholds[i]),o=this.getRewardText(t),n=this.stageMeasure()===$.COUNT;return o?this.trans(n?"tier_requirement_count":"tier_requirement",{threshold:r,reward:G(o)}):this.trans(n?"tier_requirement_count_generic":"tier_requirement_generic",{threshold:r})}getRewardIcon(t){switch(t?.type){case o.PERCENTAGE:return"sicon-percentage";case o.FREE_PRODUCT:return"sicon-gift";case o.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,r=t.getBoundingClientRect(),o=i.getBoundingClientRect(),n=r?.width||0;if(n<=0||e<=0)return;const s=o.left+o.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,r)=>{const o=e.met[r],n=this.tierKey(t,r);return[r>0?i("span",{key:`${n}-link`,class:{"s-conditional-offer-badge-link":!0,"s-conditional-offer-badge-link-met":o,"s-conditional-offer-badge-link-unmet":!o},"aria-hidden":"true"}):null,i("span",{key:n,class:{"s-conditional-offer-badge":!0,"s-conditional-offer-badge-met":o,"s-conditional-offer-badge-unmet":!o},"data-tier-state":o?"met":"unmet","data-tier-id":t?.id??void 0},i(o?Y:E,{class:"s-conditional-offer-badge-icon"}))]})))}renderTooltip(t,e){const r=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),r?i("div",{class:"s-conditional-offer-tooltip-description"},r):null,i("ul",{class:"s-conditional-offer-tooltip-list"},t.map(((t,r)=>{const o=e.met[r];return i("li",{key:this.tierKey(t,r),class:"s-conditional-offer-tier","data-tier-state":o?"met":"unmet","data-tier-id":t?.id??void 0},i("span",{class:{"s-conditional-offer-tier-icon":!0,"s-conditional-offer-tier-icon-met":o,"s-conditional-offer-tier-icon-unmet":!o}},i("i",{class:this.getRewardIcon(t),"aria-hidden":"true"}),i("span",{class:{"s-conditional-offer-tier-status":!0,"s-conditional-offer-tier-status-met":o,"s-conditional-offer-tier-status-unmet":!o},"aria-hidden":"true"},o?i(Y,{class:"s-conditional-offer-tier-status-check"}):i(E,{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:`${r+1}`})),i("div",{class:{"s-conditional-offer-tier-text":!0,"s-conditional-offer-tier-text-met":o},innerHTML:this.getTierSentence(t,r,e)})))}))))}getPickerStage(t){return t.find((t=>this.isPickerTier(t)))??null}isPickerTier(t){return t?.type===o.FREE_PRODUCT&&Array.isArray(t.free_products)&&t.free_products.length>0}areGiftsUnavailable(t,i){const e=t[i.lastReachedIndex];return e?.type===o.FREE_PRODUCT&&Array.isArray(e.free_products)&&0===e.free_products.length&&0===this.gifts.length}loadFreeProductCards(){const t=this.getPickerStage(this.getStages()),i=(t?.free_products??[]).map((t=>String(t.id))).filter((t=>t&&!this.freeProductCards[t]));if(!i.length)return Promise.resolve();const e=new Set((t.free_products??[]).map((t=>String(t.id))));return Promise.resolve().then((()=>salla.product.fetch({source:"selected",source_value:i}))).then((t=>{if(this.isDisconnected)return;const i={...this.freeProductCards};(Array.isArray(t?.data)?t.data:[]).forEach((t=>{const r=String(t?.id??"");r&&e.has(r)&&(i[r]={id:r,name:String(t.name??""),imageUrl:String(t.image?.url??""),imageAlt:String(t.image?.alt??t.name??""),price:Number.isFinite(Number(t.price))?Number(t.price):null})})),this.freeProductCards=i})).catch((t=>this.safeLog("free product lookup failed",t)))}getPickerState(t){const i=this.cartLines.filter((t=>t.freeQuantity>0)),e=this.selectOwnFreeLines(i),r=new Set(e.map((t=>t.productId)).filter((t=>null!==t))),o=Math.max(1,Math.floor(Number(t.max_free_products)||1)),n=Number(t.current_value??this.offer?.details?.current_value??0);return{limit:o,reached:"boolean"==typeof t.can_add_free?t.can_add_free:Number.isFinite(n)&&n>=Number(t.min_spend),freeCount:r.size}}selectOwnFreeLines(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))}addFreeProduct(t){this.pendingFreeProduct||(this.pendingFreeProduct=t.id,this.runFreeProductChange((()=>Promise.resolve(salla.cart.addItem(t.id)).then((()=>{this.cartPageCheckAfter=this.giftsGeneration}))),"free product add failed"))}reloadPage(){window.location.reload()}fetchCartPageHtml(){const t=new AbortController,i=setTimeout((()=>t.abort()),8e3);return fetch(window.location.href,{cache:"no-store",credentials:"same-origin",headers:{Accept:"text/html"},signal:t.signal}).then((t=>t.ok?t.text():Promise.reject(new Error(`cart page ${t.status}`)))).finally((()=>clearTimeout(i)))}showMissingCartLines(t){this.insertingCartLines?this.pendingCartPageLines=t:this.missingCartLineIds(t).length&&(this.insertingCartLines=!0,Promise.resolve().then((()=>this.fetchCartPageHtml())).then((t=>{if(this.isDisconnected||this.cartChangedDuringPageFetch())return;const i=this.missingCartLineIds(this.cartLines);i.length&&!this.insertCartLineForms(t,i)&&this.reloadForMissingCartLines(i)})).catch((t=>{this.safeLog("cart page fetch for the new lines failed, reloading",t),this.isDisconnected||this.cartChangedDuringPageFetch()||this.reloadForMissingCartLines(this.missingCartLineIds(this.cartLines))})).finally((()=>{this.insertingCartLines=!1;const t=this.pendingCartPageLines;this.pendingCartPageLines=null,t&&!this.isDisconnected&&this.showMissingCartLines(t)})))}cartChangedDuringPageFetch(){return!(null===this.pendingFreeProduct&&this.cartLinesLoaded||(null===this.cartPageCheckAfter&&(this.cartPageCheckAfter=this.giftsGeneration),0))}missingCartLineIds(t){try{return document.querySelector(O)?t.map((t=>t.id)).filter((t=>!document.getElementById(`item-${t}`))).sort():[]}catch(t){return this.safeLog("cart page check after a free product add failed",t),[]}}insertCartLineForms(t,i){try{const e=Array.from((new DOMParser).parseFromString(t,"text/html").querySelectorAll(O)),r=e.map((t=>t.getAttribute("id")));return!i.some((t=>!r.includes(`item-${t}`)))&&(e.forEach(((t,e)=>{const o=r[e];if(!i.includes(o.slice(5))||document.getElementById(o))return;const n=r.slice(e+1).map((t=>document.getElementById(t))).find(Boolean);if(n)n.parentNode.insertBefore(t,n);else{const i=document.querySelectorAll(O),e=i[i.length-1];e.parentNode.insertBefore(t,e.nextSibling)}})),i.every((t=>document.getElementById(`item-${t}`))))}catch(t){return this.safeLog("cart line insert failed",t),!1}}reloadForMissingCartLines(t){if(!t.length)return;const i=t.join(","),e=this.readReloadGuard();e!==i&&(void 0===e&&this.pageWasReloaded()||(this.writeReloadGuard(i),this.reloadPage()))}readReloadGuard(){try{return window.sessionStorage.getItem(H)}catch{return}}writeReloadGuard(t){try{window.sessionStorage.setItem(H,t)}catch{}}pageWasReloaded(){try{const t=window.performance?.getEntriesByType?.("navigation")?.[0];return"reload"===t?.type}catch{return!1}}runFreeProductChange(t,i){Promise.resolve().then(t).then((()=>{if(this.isDisconnected)return this.unlockFreeProduct();this.pendingFreeProductSettledAt=this.giftsGeneration,this.pendingFreeProductTimer=setTimeout((()=>this.unlockOnStaleLines()),5e3)})).catch((t=>{this.safeLog(i,t),this.unlockFreeProduct(),null!==this.cartPageCheckAfter&&this.loadCart()}))}unlockOnStaleLines(){this.unlockFreeProduct(),this.cartLinesLoaded=!1,this.clearPickerLookupRetry(),T().then((()=>this.loadCart()),(()=>this.loadCart()))}unlockFreeProduct(){null!==this.pendingFreeProductTimer&&clearTimeout(this.pendingFreeProductTimer),this.pendingFreeProductTimer=null,this.pendingFreeProductSettledAt=null,this.pendingFreeProduct=null}pickerGotMessage(t,i){return 1===t?this.trans(i?"free_product_got_pick_one":"free_product_got_one"):2===t?this.trans(i?"free_products_got_pick_two":"free_products_got_two"):this.trans(i?"free_products_got_pick":"free_products_got",{count:`${t}`})}getPickerCards(t){return(t.free_products??[]).map((t=>this.freeProductCards[String(t.id)])).filter(Boolean)}renderPicker(t){const e=this.getPickerState(t),r=this.getPickerCards(t);return r.length?i("div",{class:"s-conditional-offer-picker","data-picker-reached":e.reached?"true":"false"},i("div",{class:"s-conditional-offer-picker-header"},i("span",{class:"s-conditional-offer-picker-counter","aria-label":`${e.freeCount}/${e.limit}`},`${e.freeCount}/${e.limit}`),i("span",{class:"s-conditional-offer-picker-title"},1===e.limit?this.trans("free_product_choose_one"):2===e.limit?this.trans("free_products_choose_two"):this.trans("free_products_choose",{count:`${e.limit}`}))),i("ul",{class:"s-conditional-offer-picker-list"},r.map((t=>this.renderPickerCard(t))))):null}renderPickerCard(t){return i("li",{class:"s-conditional-offer-picker-card","data-product-id":t.id},i("span",{class:"s-conditional-offer-picker-thumb"},t.imageUrl?i("img",{class:"s-conditional-offer-picker-image",src:t.imageUrl,alt:t.imageAlt||t.name,loading:"lazy",decoding:"async"}):i("i",{class:"sicon-gift","aria-hidden":"true"})),i("span",{class:"s-conditional-offer-picker-name"},t.name),null!==t.price?i("span",{class:"s-conditional-offer-picker-prices"},i("span",{class:"s-conditional-offer-picker-price-regular",innerHTML:salla.money(t.price)})):null,i("span",{class:"s-conditional-offer-picker-actions"},i("button",{type:"button",class:"s-conditional-offer-picker-add",onClick:()=>this.addFreeProduct(t)},this.getAddLabel())))}renderGiftsToggle(t,e){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(e?"offer_toggle":"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(t=null){if(!t)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)))));const e=this.getPickerState(t);return i("div",{class:"s-conditional-offer-panel",id:this.elementId("gifts")},e.reached?this.renderPicker(t):null,this.gifts.length?i("div",{class:"s-conditional-offer-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.sharedLabel("pages.loyalty_program.free_product_title","Free products"))),i("ul",{class:"s-conditional-offer-gifts-list"},this.gifts.map((t=>this.renderGiftRow(t))))):null)}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(),r=this.getProgress(t),o=this.getGuidanceMessage(t,r),n=this.trans("details_title"),s=this.getPickerStage(t),a=null!==s?this.getPickerState(s):null,l=a?.reached??!1,c=this.gifts.length>0||l&&this.getPickerCards(s).length>0,d=l&&this.cartLinesLoaded&&0===a.freeCount,h=r.allMet&&l&&a.freeCount>0&&t[t.length-1]===s;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,r),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(W,{class:"s-conditional-offer-info-icon"})),this.isTooltipOpen?this.renderTooltip(t,r):null)),d||h?i("div",{class:"s-conditional-offer-message",role:"status"},this.pickerGotMessage(a.limit,d)):this.areGiftsUnavailable(t,r)?i("div",{class:"s-conditional-offer-message",role:"status"},this.trans("free_products_unavailable")):r.allMet?i("div",{class:"s-conditional-offer-message",role:"status"},this.trans("congrats")):o?i("div",{class:"s-conditional-offer-message",innerHTML:o}):null)),c?this.renderGiftsToggle("inline",!!s):null),c&&this.isGiftsOpen?this.renderGiftsCard(s):null,c?this.renderGiftsToggle("bar",!!s):null)}get hostEl(){return r(this)}};Z.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-gifts{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(249 250 251 / var(--tw-bg-opacity, 1));padding:0.75rem}.s-conditional-offer-picker{display:flex;width:100%;min-width:0px;flex-direction:column;gap:0.75rem}.s-conditional-offer-picker-header{display:flex;align-items:center;gap:0.5rem}.s-conditional-offer-picker-counter{display:inline-flex;height:2.25rem;width:2.25rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;border-width:2px;border-color:var(--color-primary);font-size:0.75rem;line-height:1rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-picker-title{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-picker-list{margin:0px;display:flex;list-style-type:none;gap:0.75rem;overflow-x:auto;overscroll-behavior-x:contain;scroll-behavior:smooth;padding:0px;padding-bottom:0.25rem;scrollbar-width:thin}.s-conditional-offer-picker-card{display:flex;width:9rem;flex-shrink:0;flex-direction:column;gap:0.375rem;text-align:start}.s-conditional-offer-picker-thumb{display:inline-flex;height:7rem;width:100%;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.5rem;line-height:2rem;--tw-text-opacity:1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.s-conditional-offer-picker-image{height:100%;width:100%;object-fit:contain}.s-conditional-offer-picker-name{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(38 38 38 / var(--tw-text-opacity, 1))}.s-conditional-offer-picker-prices{display:flex;align-items:center;gap:0.5rem;font-size:0.75rem;line-height:1rem}.s-conditional-offer-picker-price-regular{font-weight:700;--tw-text-opacity:1;color:rgb(23 23 23 / var(--tw-text-opacity, 1))}.s-conditional-offer-picker-actions{margin-top:auto;display:flex;width:100%;align-items:center;gap:0.375rem}.s-conditional-offer-picker-add{display:inline-flex;height:2.25rem;flex:1 1 0%;align-items:center;justify-content:center;border-radius:0.375rem;border-width:1px;border-color:var(--color-primary);font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark);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-picker-add:hover{background-color:var(--color-primary);--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.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{Z 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 s,H as i,a as e}from"./p-ze9e0dxM.js";const a=class{constructor(s){t(this,s),this.menuOpen=!1,this.hasProducts=!1,this.specificMode=!1,this.selectedIds=[],this.loadedProductCount=0,this.isSharing=!1,this.shareUrl="",this.isListSyncPaused=!1,this.translationDefaults={"pages.wishlist.share":{ar:"شارك",en:"Share"},"pages.wishlist.share_all":{ar:"مشاركة القائمة",en:"Share the list"},"pages.wishlist.share_specific":{ar:"مشاركة منتجات محددة",en:"Share specific items"},"pages.wishlist.share_list_title":{ar:"مشاركة قائمة الأمنيات",en:"Share wishlist"},"pages.wishlist.select_all":{ar:"تحديد الكل",en:"Select all"},"common.elements.cancel":{ar:"إلغاء",en:"Cancel"}},this.onSelectionChanged=t=>{this.selectedIds=t?.ids||[],this.shareUrl="",this.socialShare?.close(),this.syncLoadedProductCount()},this.onDocumentClick=t=>{this.menuOpen&&!this.host.contains(t.target)&&(this.menuOpen=!1)},this.onProductsFetched=t=>{"wishlist"===t?.source&&(this.isListSyncPaused=!1,this.syncHasProducts(!!t?.data?.length),this.syncLoadedProductCount())}}async componentWillLoad(){await Salla.onReady(),await Salla.lang.onLoaded(),this.registerTranslationDefaults(),this.loadTranslations(),Salla.event.on("salla-products-list::selection.changed",this.onSelectionChanged),Salla.event.on("salla-products-list::products.fetched",this.onProductsFetched),document.addEventListener("click",this.onDocumentClick)}componentDidLoad(){this.initPageTitleAlignment(),this.productsList=this.host.parentElement?.querySelector("salla-products-list"),this.productsList?(this.syncHasProducts(),this.productsObserver=new MutationObserver((()=>{this.syncHasProducts()})),this.productsObserver.observe(this.productsList,{childList:!0,subtree:!0})):Salla.logger?.warn?.("[salla-wishlist-actions] no sibling salla-products-list found")}disconnectedCallback(){Salla.event.off("salla-products-list::selection.changed",this.onSelectionChanged),Salla.event.off("salla-products-list::products.fetched",this.onProductsFetched),document.removeEventListener("click",this.onDocumentClick),this.productsObserver?.disconnect(),this.pageTitleObserver?.disconnect(),this.pageTitleRetryTimeout&&window.clearTimeout(this.pageTitleRetryTimeout),this.resetPageTitleAlignment()}initPageTitleAlignment(){if(this.syncPageTitleAlignment(),this.pageTitle)return;requestAnimationFrame((()=>this.syncPageTitleAlignment())),this.pageTitleRetryTimeout=window.setTimeout((()=>this.syncPageTitleAlignment()),300);const t=this.host.closest(".main-content")??this.host.parentElement;t&&!this.pageTitle&&(this.pageTitleObserver=new MutationObserver((()=>{this.pageTitle?this.pageTitleObserver?.disconnect():(this.syncPageTitleAlignment(),this.pageTitle&&this.pageTitleObserver?.disconnect())})),this.pageTitleObserver.observe(t,{childList:!0,subtree:!0}))}findPageTitle(){const t=this.host.parentElement;if(t)for(const s of Array.from(t.children)){if(s===this.host)break;if("H1"===s.tagName)return s;const t=s.querySelector("h1");if(t)return t}const s=this.host.closest(".main-content");if(s){const t=s.querySelector("h1");if(t&&!this.host.contains(t))return t}return document.querySelector(".main-content h1, main h1")}syncPageTitleAlignment(){if(this.pageTitle)return;const t=this.findPageTitle();t&&(this.pageTitle=t,t.classList.add(a.pageTitleClass))}resetPageTitleAlignment(){this.pageTitle?.classList.remove(a.pageTitleClass),this.pageTitle=void 0}registerTranslationDefaults(){const t=Object.entries(this.translationDefaults).reduce(((t,[s,i])=>(Salla.lang.get(s)===s&&(t[s]=i),t)),{});Object.keys(t).length&&Salla.lang.addBulk(t)}loadTranslations(){this.shareLabel=Salla.lang.get("pages.wishlist.share"),this.shareAllLabel=Salla.lang.get("pages.wishlist.share_all"),this.shareSpecificLabel=Salla.lang.get("pages.wishlist.share_specific"),this.selectAllLabel=Salla.lang.get("pages.wishlist.select_all"),this.cancelLabel=Salla.lang.get("common.elements.cancel"),this.shareModalTitle=Salla.lang.get("pages.wishlist.share_list_title")}get selectedCount(){return this.selectedIds.length}get isAllSelected(){return this.loadedProductCount>0&&this.selectedCount===this.loadedProductCount}get isPartiallySelected(){return this.selectedCount>0&&this.selectedCount<this.loadedProductCount}async syncLoadedProductCount(){if(!this.productsList)return void(this.loadedProductCount=0);if(this.isListSyncPaused&&this.specificMode)return;const t=await this.productsList.getLoadedProducts();this.loadedProductCount=t.length}syncSelectAllCheckboxState(){this.selectAllCheckbox&&(this.selectAllCheckbox.checked=this.isAllSelected,this.selectAllCheckbox.indeterminate=this.isPartiallySelected)}componentDidRender(){this.syncSelectAllCheckboxState()}pauseListSync(){this.isListSyncPaused=!0,window.setTimeout((()=>{this.isListSyncPaused&&(this.isListSyncPaused=!1,this.syncHasProducts())}),3e3)}async syncHasProducts(t){if(!this.isListSyncPaused||"boolean"==typeof t){if("boolean"==typeof t)this.hasProducts=t;else if(this.productsList){const t=await this.productsList.getLoadedProducts();if(0===t.length&&this.specificMode)return;this.hasProducts=t.length>0,this.loadedProductCount=t.length}else this.hasProducts=!1,this.loadedProductCount=0;this.hasProducts||(this.menuOpen=!1,this.specificMode&&await this.cancelSpecific())}}toggleMenu(){this.hasProducts&&(this.menuOpen=!this.menuOpen)}async toggleSelectAll(){this.productsList&&(this.isAllSelected?await this.productsList.clearSelection():await this.productsList.selectAll())}async shareSpecific(){this.menuOpen=!1,this.specificMode=!0,this.pauseListSync(),this.productsList&&(this.productsList.selectable=!0)}async cancelSpecific(){this.specificMode=!1,this.selectedIds=[],this.pauseListSync(),this.productsList&&(await this.productsList.clearSelection(),this.productsList.selectable=!1)}async shareAll(){this.menuOpen=!1,await this.processShare([],!0)}async shareSelected(){this.selectedCount&&await this.processShare(this.selectedIds,!1)}async processShare(t,s=!1){if((s||t?.length)&&!this.isSharing){this.isSharing=!0;try{const i=await salla.wishlist.share(t,s),e=i?.data?.url||i?.url||"";if(!e||!this.socialShare)return;this.shareUrl=e,this.socialShare.url=e,await this.socialShare.refresh(),await this.socialShare.open()}catch(t){Salla.logger?.warn?.("[salla-wishlist-actions] share failed",t)}finally{this.isSharing=!1}}}render(){return s(i,{key:"ed2bb2b4e6db13b5dc2a8ceb47d0abb4b91da7ea"},s("div",{key:"9a368503611af6ccce78d35b76ec17bd3ddd296b",class:"s-wishlist-actions"},s("div",{key:"a9dc9b280bd46673892d6c72ffc535eb443beb0f",class:"s-wishlist-actions-bar flex items-center justify-end gap-3 mb-3"},s("div",{key:"90d6ea21a46becdeffca1a9b722a3a20eb3ed341",class:"s-wishlist-actions-dropdown relative"},s("salla-button",{key:"9edc9eeea5282fc61d48fce5b29ed095793265cf",color:"primary",fill:"outline",type:"button",disabled:!this.hasProducts,"aria-haspopup":"true","aria-expanded":this.menuOpen?"true":"false",onClick:()=>this.toggleMenu()},s("div",{key:"a5a30a3676d304614ec2e8b14172694d00f2e28c",class:"flex flex-row justify-center items-center gap-2"},s("svg",{key:"6842723fa0aa1f12fba6b91ddc6095a1e8da20af",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 32 32",style:{width:"16px",height:"16px"}},s("path",{key:"c7aa82770d3ce0a04240ee4ab44b8a4f0cf2d8b3",d:"M26.667 21.333c-1.699 0-3.196 0.812-4.173 2.052l-11.912-5.211c0.044-0.276 0.085-0.553 0.085-0.841 0-0.472-0.081-0.923-0.197-1.359l12.361-6.952c0.971 1.009 2.328 1.644 3.836 1.644 2.941 0 5.333-2.392 5.333-5.333s-2.392-5.333-5.333-5.333-5.333 2.392-5.333 5.333c0 0.472 0.081 0.923 0.197 1.359l-12.361 6.952c-0.971-1.009-2.328-1.644-3.836-1.644-2.941 0-5.333 2.392-5.333 5.333s2.392 5.333 5.333 5.333c1.699 0 3.196-0.812 4.173-2.052l11.912 5.211c-0.044 0.276-0.085 0.553-0.085 0.841 0 2.941 2.392 5.333 5.333 5.333s5.333-2.392 5.333-5.333-2.392-5.333-5.333-5.333zM26.667 2.667c1.471 0 2.667 1.196 2.667 2.667s-1.196 2.667-2.667 2.667-2.667-1.196-2.667-2.667 1.196-2.667 2.667-2.667zM5.333 20c-1.471 0-2.667-1.196-2.667-2.667s1.196-2.667 2.667-2.667 2.667 1.196 2.667 2.667-1.196 2.667-2.667 2.667zM26.667 29.333c-1.471 0-2.667-1.196-2.667-2.667s1.196-2.667 2.667-2.667 2.667 1.196 2.667 2.667-1.196 2.667-2.667 2.667z"})),this.shareLabel,s("svg",{key:"08c44a8306ba2b183aa0549fac2da24c64f3b285",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 32 32",style:{width:"16px",height:"16px"}},s("path",{key:"216163cc1b84ceb0b9035c23ef002b80c69ab9bf",d:"M26.212 10.996c-0.556-0.484-1.396-0.428-1.881 0.127l-8.331 9.519-8.331-9.52c-0.485-0.555-1.327-0.611-1.881-0.125s-0.609 1.328-0.124 1.881l9.333 10.667c0.253 0.291 0.617 0.456 1.003 0.456s0.749-0.165 1.003-0.456l9.333-10.667c0.485-0.553 0.429-1.396-0.124-1.881z"})))),this.menuOpen&&s("ul",{key:"57f73a8af50dc9280efde259d639bf3d41434fed",class:"s-wishlist-actions-menu absolute z-20 mt-1 bg-white rounded-lg shadow overflow-hidden"},s("li",{key:"d3b5fc449eef1b2af914dcae0dea0b67af599b84"},s("button",{key:"e3689eb4db62ff5ee42122819faa28500c555479",type:"button",class:"s-wishlist-actions-menu-item",onClick:()=>this.shareAll()},this.shareAllLabel)),s("li",{key:"ad40221d90b2ca52ad9544e8d19324ef8af812c4"},s("button",{key:"9fde093db8640855d4871972b02e3282e9aed6ad",type:"button",class:"s-wishlist-actions-menu-item",onClick:()=>this.shareSpecific()},this.shareSpecificLabel)))),s("salla-social-share",{key:"91287b112e76c9039170ebe54fcbfe7bfcb2dfb1",class:"s-wishlist-actions-social",ref:t=>this.socialShare=t,url:this.shareUrl,mode:"modal",modalTitle:this.shareModalTitle},s("span",{key:"e97a4249a046a17d65f214e5c2ecbca2ff21358c",slot:"widget",class:"s-wishlist-actions-social-anchor","aria-hidden":"true"}))),this.specificMode&&s("div",{key:"50ba30cc24e590986b6031a373f9334e3d8c97a7",class:"s-wishlist-actions-panel flex items-center justify-between gap-4 flex-wrap p-4 mt-3 mb-3 bg-white rounded-lg"},s("label",{key:"5dbb40eed9828355189d6242131dd07343d19603",class:"s-wishlist-actions-panel-select-all flex items-center gap-2 cursor-pointer"},s("input",{key:"5bb2571ed6e9d074739fe130d3b3b3bbe77a2393",type:"checkbox",class:"s-products-list-select-checkbox s-wishlist-actions-select-all",checked:this.isAllSelected,ref:t=>this.selectAllCheckbox=t,"aria-label":this.selectAllLabel,onChange:()=>this.toggleSelectAll()}),s("span",{key:"60853767d68f23affc964822e41f19fb93b2f380",class:"s-wishlist-actions-panel-title text-sm font-bold text-gray-700"},this.shareSpecificLabel," (",this.selectedCount,")")),s("div",{key:"5d4cab056b372ff6c2d9de0dfa32e1f1870b536a",class:"s-wishlist-actions-panel-buttons flex items-center gap-2"},s("salla-button",{key:"2ef6d0388714b348ce2e039662c704d0ea9c3afa",class:"s-wishlist-actions-cancel",color:"light",fill:"outline",type:"button",onClick:()=>this.cancelSpecific()},this.cancelLabel),s("salla-button",{key:"0077c263a4eea12fc0b2b1316d4195916d771417",class:"s-wishlist-actions-share",color:"primary",fill:"outline",type:"button",disabled:!this.selectedCount,loading:this.isSharing,onClick:()=>this.shareSelected()},this.shareLabel)))))}get host(){return e(this)}};a.pageTitleClass="s-wishlist-actions-page-title",a.style='/*!twlt*/:host{display:block}.s-wishlist-actions-menu{min-width:200px;inset-inline-end:0;inset-inline-start:auto;list-style:none;margin:0;padding:4px 0;box-shadow:0 4px 16px rgba(0, 0, 0, 0.12)}.s-wishlist-actions-menu-item{display:block;width:100%;padding:10px 16px;text-align:start;font-size:0.875rem;color:#374151;background:transparent;cursor:pointer;white-space:nowrap}.s-wishlist-actions-menu-item:hover{background-color:#f3f4f6;color:var(--color-primary)}.s-wishlist-actions-panel{box-shadow:0 1px 3px rgba(0, 0, 0, 0.08)}.s-wishlist-actions-panel-select-all{user-select:none}.s-wishlist-actions-select-all:indeterminate,.s-wishlist-actions-select-all:indeterminate:hover,.s-wishlist-actions-select-all:indeterminate:focus{background-color:var(--color-primary);border-color:var(--color-primary)}.s-wishlist-actions-select-all:indeterminate::after{content:"";position:absolute;top:50%;left:50%;width:10px;height:2px;background:#fff;border:none;transform:translate(-50%, -50%)}.s-wishlist-actions-social-anchor{display:none}h1.s-wishlist-actions-page-title{text-align:start !important}.static{position:static}.absolute{position:absolute}.relative{position:relative}.z-20{z-index:20}.mb-3{margin-bottom:0.75rem}.mt-1{margin-top:0.25rem}.mt-3{margin-top:0.75rem}.flex{display:flex}.cursor-pointer{cursor:pointer}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-2{gap:0.5rem}.gap-3{gap:0.75rem}.gap-4{gap:1rem}.overflow-hidden{overflow:hidden}.rounded-lg{border-radius:0.5rem}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.p-4{padding:1rem}.text-sm{font-size:0.875rem;line-height:1.25rem}.font-bold{font-weight:700}.text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.shadow{--tw-shadow:0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px 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{outline-style:solid}';export{a as salla_wishlist_actions}
4
+ import{r as t,h as s,H as i,a as e}from"./p-g-_4am8C.js";const a=class{constructor(s){t(this,s),this.menuOpen=!1,this.hasProducts=!1,this.specificMode=!1,this.selectedIds=[],this.loadedProductCount=0,this.isSharing=!1,this.shareUrl="",this.isListSyncPaused=!1,this.translationDefaults={"pages.wishlist.share":{ar:"شارك",en:"Share"},"pages.wishlist.share_all":{ar:"مشاركة القائمة",en:"Share the list"},"pages.wishlist.share_specific":{ar:"مشاركة منتجات محددة",en:"Share specific items"},"pages.wishlist.share_list_title":{ar:"مشاركة قائمة الأمنيات",en:"Share wishlist"},"pages.wishlist.select_all":{ar:"تحديد الكل",en:"Select all"},"common.elements.cancel":{ar:"إلغاء",en:"Cancel"}},this.onSelectionChanged=t=>{this.selectedIds=t?.ids||[],this.shareUrl="",this.socialShare?.close(),this.syncLoadedProductCount()},this.onDocumentClick=t=>{this.menuOpen&&!this.host.contains(t.target)&&(this.menuOpen=!1)},this.onProductsFetched=t=>{"wishlist"===t?.source&&(this.isListSyncPaused=!1,this.syncHasProducts(!!t?.data?.length),this.syncLoadedProductCount())}}async componentWillLoad(){await Salla.onReady(),await Salla.lang.onLoaded(),this.registerTranslationDefaults(),this.loadTranslations(),Salla.event.on("salla-products-list::selection.changed",this.onSelectionChanged),Salla.event.on("salla-products-list::products.fetched",this.onProductsFetched),document.addEventListener("click",this.onDocumentClick)}componentDidLoad(){this.initPageTitleAlignment(),this.productsList=this.host.parentElement?.querySelector("salla-products-list"),this.productsList?(this.syncHasProducts(),this.productsObserver=new MutationObserver((()=>{this.syncHasProducts()})),this.productsObserver.observe(this.productsList,{childList:!0,subtree:!0})):Salla.logger?.warn?.("[salla-wishlist-actions] no sibling salla-products-list found")}disconnectedCallback(){Salla.event.off("salla-products-list::selection.changed",this.onSelectionChanged),Salla.event.off("salla-products-list::products.fetched",this.onProductsFetched),document.removeEventListener("click",this.onDocumentClick),this.productsObserver?.disconnect(),this.pageTitleObserver?.disconnect(),this.pageTitleRetryTimeout&&window.clearTimeout(this.pageTitleRetryTimeout),this.resetPageTitleAlignment()}initPageTitleAlignment(){if(this.syncPageTitleAlignment(),this.pageTitle)return;requestAnimationFrame((()=>this.syncPageTitleAlignment())),this.pageTitleRetryTimeout=window.setTimeout((()=>this.syncPageTitleAlignment()),300);const t=this.host.closest(".main-content")??this.host.parentElement;t&&!this.pageTitle&&(this.pageTitleObserver=new MutationObserver((()=>{this.pageTitle?this.pageTitleObserver?.disconnect():(this.syncPageTitleAlignment(),this.pageTitle&&this.pageTitleObserver?.disconnect())})),this.pageTitleObserver.observe(t,{childList:!0,subtree:!0}))}findPageTitle(){const t=this.host.parentElement;if(t)for(const s of Array.from(t.children)){if(s===this.host)break;if("H1"===s.tagName)return s;const t=s.querySelector("h1");if(t)return t}const s=this.host.closest(".main-content");if(s){const t=s.querySelector("h1");if(t&&!this.host.contains(t))return t}return document.querySelector(".main-content h1, main h1")}syncPageTitleAlignment(){if(this.pageTitle)return;const t=this.findPageTitle();t&&(this.pageTitle=t,t.classList.add(a.pageTitleClass))}resetPageTitleAlignment(){this.pageTitle?.classList.remove(a.pageTitleClass),this.pageTitle=void 0}registerTranslationDefaults(){const t=Object.entries(this.translationDefaults).reduce(((t,[s,i])=>(Salla.lang.get(s)===s&&(t[s]=i),t)),{});Object.keys(t).length&&Salla.lang.addBulk(t)}loadTranslations(){this.shareLabel=Salla.lang.get("pages.wishlist.share"),this.shareAllLabel=Salla.lang.get("pages.wishlist.share_all"),this.shareSpecificLabel=Salla.lang.get("pages.wishlist.share_specific"),this.selectAllLabel=Salla.lang.get("pages.wishlist.select_all"),this.cancelLabel=Salla.lang.get("common.elements.cancel"),this.shareModalTitle=Salla.lang.get("pages.wishlist.share_list_title")}get selectedCount(){return this.selectedIds.length}get isAllSelected(){return this.loadedProductCount>0&&this.selectedCount===this.loadedProductCount}get isPartiallySelected(){return this.selectedCount>0&&this.selectedCount<this.loadedProductCount}async syncLoadedProductCount(){if(!this.productsList)return void(this.loadedProductCount=0);if(this.isListSyncPaused&&this.specificMode)return;const t=await this.productsList.getLoadedProducts();this.loadedProductCount=t.length}syncSelectAllCheckboxState(){this.selectAllCheckbox&&(this.selectAllCheckbox.checked=this.isAllSelected,this.selectAllCheckbox.indeterminate=this.isPartiallySelected)}componentDidRender(){this.syncSelectAllCheckboxState()}pauseListSync(){this.isListSyncPaused=!0,window.setTimeout((()=>{this.isListSyncPaused&&(this.isListSyncPaused=!1,this.syncHasProducts())}),3e3)}async syncHasProducts(t){if(!this.isListSyncPaused||"boolean"==typeof t){if("boolean"==typeof t)this.hasProducts=t;else if(this.productsList){const t=await this.productsList.getLoadedProducts();if(0===t.length&&this.specificMode)return;this.hasProducts=t.length>0,this.loadedProductCount=t.length}else this.hasProducts=!1,this.loadedProductCount=0;this.hasProducts||(this.menuOpen=!1,this.specificMode&&await this.cancelSpecific())}}toggleMenu(){this.hasProducts&&(this.menuOpen=!this.menuOpen)}async toggleSelectAll(){this.productsList&&(this.isAllSelected?await this.productsList.clearSelection():await this.productsList.selectAll())}async shareSpecific(){this.menuOpen=!1,this.specificMode=!0,this.pauseListSync(),this.productsList&&(this.productsList.selectable=!0)}async cancelSpecific(){this.specificMode=!1,this.selectedIds=[],this.pauseListSync(),this.productsList&&(await this.productsList.clearSelection(),this.productsList.selectable=!1)}async shareAll(){this.menuOpen=!1,await this.processShare([],!0)}async shareSelected(){this.selectedCount&&await this.processShare(this.selectedIds,!1)}async processShare(t,s=!1){if((s||t?.length)&&!this.isSharing){this.isSharing=!0;try{const i=await salla.wishlist.share(t,s),e=i?.data?.url||i?.url||"";if(!e||!this.socialShare)return;this.shareUrl=e,this.socialShare.url=e,await this.socialShare.refresh(),await this.socialShare.open()}catch(t){Salla.logger?.warn?.("[salla-wishlist-actions] share failed",t)}finally{this.isSharing=!1}}}render(){return s(i,{key:"ed2bb2b4e6db13b5dc2a8ceb47d0abb4b91da7ea"},s("div",{key:"9a368503611af6ccce78d35b76ec17bd3ddd296b",class:"s-wishlist-actions"},s("div",{key:"a9dc9b280bd46673892d6c72ffc535eb443beb0f",class:"s-wishlist-actions-bar flex items-center justify-end gap-3 mb-3"},s("div",{key:"90d6ea21a46becdeffca1a9b722a3a20eb3ed341",class:"s-wishlist-actions-dropdown relative"},s("salla-button",{key:"9edc9eeea5282fc61d48fce5b29ed095793265cf",color:"primary",fill:"outline",type:"button",disabled:!this.hasProducts,"aria-haspopup":"true","aria-expanded":this.menuOpen?"true":"false",onClick:()=>this.toggleMenu()},s("div",{key:"a5a30a3676d304614ec2e8b14172694d00f2e28c",class:"flex flex-row justify-center items-center gap-2"},s("svg",{key:"6842723fa0aa1f12fba6b91ddc6095a1e8da20af",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 32 32",style:{width:"16px",height:"16px"}},s("path",{key:"c7aa82770d3ce0a04240ee4ab44b8a4f0cf2d8b3",d:"M26.667 21.333c-1.699 0-3.196 0.812-4.173 2.052l-11.912-5.211c0.044-0.276 0.085-0.553 0.085-0.841 0-0.472-0.081-0.923-0.197-1.359l12.361-6.952c0.971 1.009 2.328 1.644 3.836 1.644 2.941 0 5.333-2.392 5.333-5.333s-2.392-5.333-5.333-5.333-5.333 2.392-5.333 5.333c0 0.472 0.081 0.923 0.197 1.359l-12.361 6.952c-0.971-1.009-2.328-1.644-3.836-1.644-2.941 0-5.333 2.392-5.333 5.333s2.392 5.333 5.333 5.333c1.699 0 3.196-0.812 4.173-2.052l11.912 5.211c-0.044 0.276-0.085 0.553-0.085 0.841 0 2.941 2.392 5.333 5.333 5.333s5.333-2.392 5.333-5.333-2.392-5.333-5.333-5.333zM26.667 2.667c1.471 0 2.667 1.196 2.667 2.667s-1.196 2.667-2.667 2.667-2.667-1.196-2.667-2.667 1.196-2.667 2.667-2.667zM5.333 20c-1.471 0-2.667-1.196-2.667-2.667s1.196-2.667 2.667-2.667 2.667 1.196 2.667 2.667-1.196 2.667-2.667 2.667zM26.667 29.333c-1.471 0-2.667-1.196-2.667-2.667s1.196-2.667 2.667-2.667 2.667 1.196 2.667 2.667-1.196 2.667-2.667 2.667z"})),this.shareLabel,s("svg",{key:"08c44a8306ba2b183aa0549fac2da24c64f3b285",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 32 32",style:{width:"16px",height:"16px"}},s("path",{key:"216163cc1b84ceb0b9035c23ef002b80c69ab9bf",d:"M26.212 10.996c-0.556-0.484-1.396-0.428-1.881 0.127l-8.331 9.519-8.331-9.52c-0.485-0.555-1.327-0.611-1.881-0.125s-0.609 1.328-0.124 1.881l9.333 10.667c0.253 0.291 0.617 0.456 1.003 0.456s0.749-0.165 1.003-0.456l9.333-10.667c0.485-0.553 0.429-1.396-0.124-1.881z"})))),this.menuOpen&&s("ul",{key:"57f73a8af50dc9280efde259d639bf3d41434fed",class:"s-wishlist-actions-menu absolute z-20 mt-1 bg-white rounded-lg shadow overflow-hidden"},s("li",{key:"d3b5fc449eef1b2af914dcae0dea0b67af599b84"},s("button",{key:"e3689eb4db62ff5ee42122819faa28500c555479",type:"button",class:"s-wishlist-actions-menu-item",onClick:()=>this.shareAll()},this.shareAllLabel)),s("li",{key:"ad40221d90b2ca52ad9544e8d19324ef8af812c4"},s("button",{key:"9fde093db8640855d4871972b02e3282e9aed6ad",type:"button",class:"s-wishlist-actions-menu-item",onClick:()=>this.shareSpecific()},this.shareSpecificLabel)))),s("salla-social-share",{key:"91287b112e76c9039170ebe54fcbfe7bfcb2dfb1",class:"s-wishlist-actions-social",ref:t=>this.socialShare=t,url:this.shareUrl,mode:"modal",modalTitle:this.shareModalTitle},s("span",{key:"e97a4249a046a17d65f214e5c2ecbca2ff21358c",slot:"widget",class:"s-wishlist-actions-social-anchor","aria-hidden":"true"}))),this.specificMode&&s("div",{key:"50ba30cc24e590986b6031a373f9334e3d8c97a7",class:"s-wishlist-actions-panel flex items-center justify-between gap-4 flex-wrap p-4 mt-3 mb-3 bg-white rounded-lg"},s("label",{key:"5dbb40eed9828355189d6242131dd07343d19603",class:"s-wishlist-actions-panel-select-all flex items-center gap-2 cursor-pointer"},s("input",{key:"5bb2571ed6e9d074739fe130d3b3b3bbe77a2393",type:"checkbox",class:"s-products-list-select-checkbox s-wishlist-actions-select-all",checked:this.isAllSelected,ref:t=>this.selectAllCheckbox=t,"aria-label":this.selectAllLabel,onChange:()=>this.toggleSelectAll()}),s("span",{key:"60853767d68f23affc964822e41f19fb93b2f380",class:"s-wishlist-actions-panel-title text-sm font-bold text-gray-700"},this.shareSpecificLabel," (",this.selectedCount,")")),s("div",{key:"5d4cab056b372ff6c2d9de0dfa32e1f1870b536a",class:"s-wishlist-actions-panel-buttons flex items-center gap-2"},s("salla-button",{key:"2ef6d0388714b348ce2e039662c704d0ea9c3afa",class:"s-wishlist-actions-cancel",color:"light",fill:"outline",type:"button",onClick:()=>this.cancelSpecific()},this.cancelLabel),s("salla-button",{key:"0077c263a4eea12fc0b2b1316d4195916d771417",class:"s-wishlist-actions-share",color:"primary",fill:"outline",type:"button",disabled:!this.selectedCount,loading:this.isSharing,onClick:()=>this.shareSelected()},this.shareLabel)))))}get host(){return e(this)}};a.pageTitleClass="s-wishlist-actions-page-title",a.style='/*!twlt*/:host{display:block}.s-wishlist-actions-menu{min-width:200px;inset-inline-end:0;inset-inline-start:auto;list-style:none;margin:0;padding:4px 0;box-shadow:0 4px 16px rgba(0, 0, 0, 0.12)}.s-wishlist-actions-menu-item{display:block;width:100%;padding:10px 16px;text-align:start;font-size:0.875rem;color:#374151;background:transparent;cursor:pointer;white-space:nowrap}.s-wishlist-actions-menu-item:hover{background-color:#f3f4f6;color:var(--color-primary)}.s-wishlist-actions-panel{box-shadow:0 1px 3px rgba(0, 0, 0, 0.08)}.s-wishlist-actions-panel-select-all{user-select:none}.s-wishlist-actions-select-all:indeterminate,.s-wishlist-actions-select-all:indeterminate:hover,.s-wishlist-actions-select-all:indeterminate:focus{background-color:var(--color-primary);border-color:var(--color-primary)}.s-wishlist-actions-select-all:indeterminate::after{content:"";position:absolute;top:50%;left:50%;width:10px;height:2px;background:#fff;border:none;transform:translate(-50%, -50%)}.s-wishlist-actions-social-anchor{display:none}h1.s-wishlist-actions-page-title{text-align:start !important}.static{position:static}.absolute{position:absolute}.relative{position:relative}.z-20{z-index:20}.mb-3{margin-bottom:0.75rem}.mt-1{margin-top:0.25rem}.mt-3{margin-top:0.75rem}.flex{display:flex}.cursor-pointer{cursor:pointer}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-2{gap:0.5rem}.gap-3{gap:0.75rem}.gap-4{gap:1rem}.overflow-hidden{overflow:hidden}.rounded-lg{border-radius:0.5rem}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.p-4{padding:1rem}.text-sm{font-size:0.875rem;line-height:1.25rem}.font-bold{font-weight:700}.text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.shadow{--tw-shadow:0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px 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{outline-style:solid}';export{a as salla_wishlist_actions}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as a,f as e,h as i,a as t}from"./p-ze9e0dxM.js";const l=class{constructor(e){a(this,e),this.hasLoaded=!1,this.isAttached=!1,this.localizationOpenListener=()=>this.open(),this.currencyOpenListener=()=>this.openUnlessNative(),this.languageOpenListener=()=>this.openUnlessNative(),this.languageNames={ar:"العربية",en:"English",sq:"shqip",hy:"հայերէն",bg:"български",zh:"汉语",hr:"hrvatski",cs:"čeština",da:"dansk",nl:"dutch",et:"eesti keel",fi:"suomen kieli",fr:"Français",de:"Deutsch",el:"Ελληνικά",hi:"हिन्दी",hu:"magyar",ind:"bahasa Indonesia",ga:"Gaeilge",it:"Italiano",ja:"日本語",ko:"한국어",lv:"latviešu",mt:"Maltese",fa:"فارسی",pl:"Polish",pt:"português",ro:"română",ru:"русский",sl:"slovenščina",es:"Español",sv:"svenska",tl:"Tagalog (Filipino)",tr:"Türkçe",uk:"украї́нська",ur:"اُردُو",ms:"Bahasa Malaysia"},this.currenciesList={SAR:{en:"Saudi Riyal",ar:"ريال سعودي",symbol:"ر.س"},USD:{en:"US Dollar",ar:"دولار أمريكي",symbol:"$"},EUR:{en:"Euro",ar:"يورو",symbol:"€"},AED:{en:"UAE Dirham",ar:"درهم اماراتي",symbol:"د.إ"},KWD:{en:"Kuwaiti Dinar",ar:"دينار كويتي",symbol:"د.ك"},BHD:{en:"Bahraini Dinar",ar:"دينار بحريني",symbol:"د.ب"},QAR:{en:"Qatari Riyal",ar:"ريال قطري",symbol:"ر.ق"},OMR:{en:"Omani Rial",ar:"ريال عماني",symbol:"ر.ع"},AUD:{en:"Australian Dollar",ar:"دولار استرالي",symbol:"$"},CAD:{en:"Canadian Dollar",ar:"دولار كندي",symbol:"$"},CNY:{en:"Renminbi",ar:"رنمينبي",symbol:"¥"},EGP:{en:"Egyptian Pound",ar:"جنيه مصري",symbol:"ج.م"},GBP:{en:"Pound Sterling",ar:"جنيه استرليني",symbol:"£"},IDR:{en:"Indonesian Rupiah",ar:"روبية إندونيسية",symbol:"Rp"},INR:{en:"Indian Rupee",ar:"روبية هندية",symbol:"₹"},JPY:{en:"Japanese Yen",ar:"ين ياباني",symbol:"¥"},MYR:{en:"Malaysian Ringgit",ar:"رينغيت ماليزي",symbol:"RM"},PKR:{en:"Pakistani Rupee",ar:"روبية باكستانية",symbol:"Rs."},SEK:{en:"Swedish Krona",ar:"كرونة سويدية",symbol:"kr"},SGD:{en:"Singapore Dollar",ar:"دولار سنغافوري",symbol:"$"},TRY:{en:"Turkish Lira",ar:"ليرة تركية",symbol:"₺"},IQD:{en:"Iraqi Dinar",ar:"دينار عراقي",symbol:"د.ع"},LBP:{en:"Lebanese Pound",ar:"ليرة لبنانية",symbol:"ل.ل"},MRO:{en:"Mauritanian Ouguiya",ar:"أوقية موريتانية",symbol:"UM"},SDG:{en:"Sudanese Pound",ar:"جنيه سوداني",symbol:"SDG"},SYP:{en:"Syrian Pound",ar:"ليرة سورية",symbol:"ل.س"},TND:{en:"Tunisian Dinar",ar:"دينار تونسي",symbol:"د.ت"},JOD:{en:"Jordanian Dinar",ar:"دينار أردني",symbol:"JOD"},DZD:{en:"Algerian Dinar",ar:"دينار جزائري",symbol:"دج"},MAD:{en:"Moroccan Dirham",ar:"درهم مغربي",symbol:"د.م."},LYD:{en:"Libyan Dinar",ar:"دينار ليبي",symbol:"LD"},YER:{en:"Yemeni Riyal",ar:"ريال يمني",symbol:"ر.ي"},ILS:{en:"New Shekel",ar:"شيكل جديد",symbol:"₪"}},this.arabicCurrencies=["SAR","AED","KWD","BHD","QAR","OMR","EGP","IQD","LBP","SYP","TND","DZD","MAD","YER"],this.translationLoaded=!1,this.languages=[],this.currencies=[],this.hasError=!1,this.showTrigger=!1,this.languageSlot=this.host.querySelector('[slot="language"]')?.innerHTML||'<label class="s-localization-modal-label" for="lang-{code}"><span>{name}</span></label>',this.currencySlot=this.host.querySelector('[slot="currency"]')?.innerHTML||'<label class="s-localization-modal-label" for="currency-{code}"><span>{name}</span><small class="s-localization-modal-currency">{symbol}</small></label>'}connectedCallback(){this.isAttached=!0,this.hasLoaded&&this.bindOpenListeners(),this.langUnsubscribe=salla.lang.subscribe((()=>{this.translationLoaded=!0,e(this)}))}disconnectedCallback(){this.isAttached=!1,Salla.event.off("localization::open",this.localizationOpenListener),Salla.event.off("currency::open",this.currencyOpenListener),Salla.event.off("language::open",this.languageOpenListener),this.langUnsubscribe?.()}bindOpenListeners(){this.isAttached&&(Salla.event.on("localization::open",this.localizationOpenListener),Salla.event.on("currency::open",this.currencyOpenListener),Salla.event.on("language::open",this.languageOpenListener))}async componentWillLoad(){await Salla.onReady(),await Salla.lang.onLoaded(),this.hasLoaded=!0,this.bindOpenListeners(),this.language||(this.language=Salla.config.get("user.language_code")),this.currency||(this.currency=Salla.config.get("user.currency_code")),Salla.api.withoutNotifier((()=>this.getCurrencies())).catch((()=>null))}openUnlessNative(){Salla.config.isMobileApp()||this.open()}async open(){return this.modal.open(),await Salla.api.withoutNotifier((()=>this.getLanguages())).then((()=>this.getCurrencies())).then((()=>{this.languages.length<2&&this.currencies.length<2&&this.modal.close()})).catch((a=>{console.log(a),this.hasError=!0,this.errorMessage=a.response?.data?.error?.message||a.response?.data})).finally((()=>this.modal.stopLoading()))}async close(){return this.modal.close()}getCurrency(a){const e=a||this.currency;if(this.currenciesList[e])return this.currenciesList[e];const i=this.currencies.find((a=>a.code===e));if(i){const a=this.escapeHtml(String(i.name||e));return{en:a,ar:a,symbol:this.escapeHtml(String((i.symbol||"").trim()||e))}}return{en:"Saudi Riyal",ar:"ريال سعودي",symbol:"ر.س"}}getLanguageName(){return this.languageNames[this.language]||this.language||""}getCurrencySymbol(a){return"SAR"===(a=a||this.currency)?'<i class="sicon-sar"></i>':"ar"!==this.language&&this.arabicCurrencies.includes(a)?a:this.getCurrency(a).symbol}getCurrencyName(a){return"ar"===this.language?this.getCurrency(a).ar:this.getCurrency(a).en}escapeHtml(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}async getLanguages(){return this.languages.length>1?null:await Salla.config.languages().then((a=>this.languages=a))}async getCurrencies(){return this.currencies.length>1?null:await Salla.config.currencies().then((a=>this.currencies=Object.values(a||{})))}onChangeCurrency(a){this.currency=a.target.value}onChangeLanguage(a){this.language=a.target.value}async submit(){let a;this.btn.load().then((()=>{if(this.currency){if(this.currency!==Salla.config.get("user.currency_code","SAR"))return a=window.location.href,Salla.currency.api.change(this.currency)}else Salla.log("There is no currency!")})).then((()=>{this.language!==Salla.config.get("user.language_code","ar")&&(a=Salla.helpers.addParamToUrl("lang",this.language))})).then((()=>{Salla.cookie.set("s-lang",this.language),Salla.cookie.set("s-curr",this.currency)})).then((()=>this.btn.stop())).then((()=>this.close())).then((()=>{a&&(window.location.href=a.replace(`/${Salla.config.get("user.language_code")}/`,`/${this.language}/`))}))}render(){return[this.showTrigger?i("button",{type:"button",onClick:()=>this.open(),class:"s-localization-modal-trigger-btn"},i("span",null,this.getLanguageName()),i("span",{class:"s-localization-modal-trigger-separator"},"|")," ",i("span",{innerHTML:this.getCurrencySymbol()})):"",i("salla-modal",{key:"f9d068ad678442956baf42eb13d344b302b3eb61",isLoading:!0,class:"s-hidden",ref:a=>this.modal=a,width:"xs"},i("div",{key:"32d8724d52bfe912f1df5fe30c115fb7089d3ee3",slot:"loading"},i("div",{key:"e1db00221c8736e8d29aa3ff6a2f701468e453e9",class:"s-localization-modal-skeleton"},i("salla-skeleton",{key:"420cafb13ba187b6e13565b97377083c3878d7e2",width:"25%",height:"15px"}),i("div",{key:"3012668293ce2edd792f76a180d3a3f0f3a4f19b",class:"s-localization-modal-skeleton-content"},[...Array(4)].map((()=>i("div",{class:"s-localization-modal-skeleton-item"},i("div",{class:"s-localization-modal-skeleton-item-flex"},i("salla-skeleton",{type:"circle",height:"16px",width:"16px"}),i("salla-skeleton",{height:"10px",width:"100px"})),i("salla-skeleton",{height:"15px",width:"20px"}))))),i("salla-skeleton",{key:"de569459de27aa8d75f1ba06ad44ca1746753f08",width:"25%",height:"15px"}),i("div",{key:"a2c912b32e31dbfc571c2dabb82414fa1be7f7f4",class:"s-localization-modal-skeleton-content"},[...Array(4)].map((()=>i("div",{class:"s-localization-modal-skeleton-item"},i("div",{class:"s-localization-modal-skeleton-item-flex"},i("salla-skeleton",{type:"circle",height:"16px",width:"16px"}),i("salla-skeleton",{height:"10px",width:"100px"})),i("salla-skeleton",{height:"15px",width:"20px"}))))),i("salla-skeleton",{key:"ccf4ee9d98af55d3369e15c5a557f0ce5fcbb61a",height:"40px",width:"100%"}))),this.hasError?i("salla-placeholder",{alignment:"center"},i("span",{slot:"description"},this.errorMessage)):i("div",{class:"s-localization-modal-inner"},this.languages.length>1?i("div",{class:"s-localization-modal-section"},i("label",{class:"s-localization-modal-title"},Salla.lang.get("common.titles.language")),i("div",{class:"s-localization-modal-section-inner"},this.languages.length<6?this.languages.map((a=>i("div",{class:"s-localization-modal-item"},i("input",{class:"s-localization-modal-input",type:"radio",checked:this.language==a.iso_code,onChange:()=>this.language=a.iso_code,name:"language",id:"lang-"+a.code.toLowerCase(),value:a.code}),i("div",{class:"s-localization-modal-label-slot",id:"language-slot",innerHTML:this.languageSlot.replace(/\{name\}/g,a.name).replace(/\{code\}/g,a.code).replace(/\{country_code\}/g,a.country_code)})))):i("select",{class:"s-localization-modal-select",name:"language",onChange:a=>this.onChangeLanguage(a)},this.languages.map((a=>i("option",{value:a.code,selected:this.language==a.code},a.name)))))):"",this.currencies.length>1?i("div",{class:"s-localization-modal-section"},i("label",{class:"s-localization-modal-title"},Salla.lang.get("common.titles.currency")),i("div",{class:"s-localization-modal-section-inner"},this.currencies.length<6?this.currencies.map((a=>i("div",{class:"s-localization-modal-item"},i("input",{class:"s-localization-modal-input",type:"radio",name:"currency",checked:this.currency==a.code,onChange:()=>this.currency=a.code,id:"currency-"+a.code,value:a.code}),i("div",{class:"s-localization-modal-label-slot",id:"currency-slot",innerHTML:this.currencySlot.replace(/\{name\}/g,this.getCurrencyName(a.code)).replace(/\{code\}/g,a.code).replace(/\{symbol\}/g,this.getCurrencySymbol(a.code)).replace(/\{country_code\}/g,a.country_code)})))):i("select",{class:"s-localization-modal-select",name:"currency",onChange:a=>this.onChangeCurrency(a)},this.currencies.map((a=>i("option",{value:a.code,selected:this.currency==a.code},a.name)))))):"",i("salla-button",{width:"wide",ref:a=>this.btn=a,onClick:()=>this.submit()},Salla.lang.get("common.elements.ok"))))]}componentDidRender(){this.host.querySelectorAll("#currency-slot").forEach((a=>a.replaceWith(a.firstChild))),this.host.querySelectorAll("#language-slot").forEach((a=>a.replaceWith(a.firstChild)))}get host(){return t(this)}};l.style='/*!twlt*/.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-localization-modal-trigger-btn{display:inline-flex;width:100%;flex-grow:0;flex-basis:0px;align-items:center;justify-content:center;white-space:nowrap;border-radius:9999px;background-color:rgb(229 231 235 / 0.5);padding-left:0.875rem;padding-right:0.875rem;padding-top:0.5rem;padding-bottom:0.5rem;font-size:0.875rem;line-height:1.25rem;font-weight:500;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:150ms}.s-localization-modal-trigger-btn:hover{background-color:rgb(229 231 235 / 0.7)}.s-localization-modal-trigger-separator{margin-left:0.375rem;margin-right:0.375rem}.s-localization-modal-title{font-size:1rem;line-height:1.5rem;font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-localization-modal-section{margin-bottom:2rem}.s-localization-modal-label-slot{flex-grow:1}.s-localization-modal-inner{width:100%}.s-localization-modal-section-inner{margin-top:1rem}.s-localization-modal-section-inner>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.s-localization-modal-item{display:flex;align-items:center}.s-localization-modal-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-localization-modal-input:focus{--tw-ring-color:var(--color-primary)}.s-localization-modal-label{display:flex;flex-grow:1;cursor:pointer;align-items:center;justify-content:space-between;font-weight:500;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-localization-modal-label:where([dir="ltr"],[dir="ltr"] *){margin-left:0.75rem}.s-localization-modal-label:where([dir="rtl"],[dir="rtl"] *){margin-right:0.75rem}.s-localization-modal-flag{border-radius:0.125rem}.s-localization-modal-currency{--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-localization-modal-select{height:2.5rem;width:100%;appearance:none;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));background-position:right;background-repeat:no-repeat;padding-left:1rem;padding-right:1rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / 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-localization-modal-select:focus{border-color:var(--color-primary)}.s-localization-modal-select:where([dir="rtl"],[dir="rtl"] *){background-position:left}.s-localization-modal-skeleton-content{margin-top:2rem;margin-bottom:2rem;display:flex;flex-direction:column}.s-localization-modal-skeleton-content>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.s-localization-modal-skeleton-item{display:flex;align-items:center;justify-content:space-between}.s-localization-modal-skeleton-item-flex{display:flex;align-items:center}.s-localization-modal-skeleton-item-flex salla-skeleton:nth-child(1){margin-right:0.75rem}.s-localization-modal-skeleton-item-flex salla-skeleton:nth-child(1):where([dir="rtl"],[dir="rtl"] *){margin-right:0px;margin-left:0.75rem}';export{l as salla_localization_modal}
4
+ import{r as a,f as e,h as i,a as t}from"./p-g-_4am8C.js";const l=class{constructor(e){a(this,e),this.hasLoaded=!1,this.isAttached=!1,this.localizationOpenListener=()=>this.open(),this.currencyOpenListener=()=>this.openUnlessNative(),this.languageOpenListener=()=>this.openUnlessNative(),this.languageNames={ar:"العربية",en:"English",sq:"shqip",hy:"հայերէն",bg:"български",zh:"汉语",hr:"hrvatski",cs:"čeština",da:"dansk",nl:"dutch",et:"eesti keel",fi:"suomen kieli",fr:"Français",de:"Deutsch",el:"Ελληνικά",hi:"हिन्दी",hu:"magyar",ind:"bahasa Indonesia",ga:"Gaeilge",it:"Italiano",ja:"日本語",ko:"한국어",lv:"latviešu",mt:"Maltese",fa:"فارسی",pl:"Polish",pt:"português",ro:"română",ru:"русский",sl:"slovenščina",es:"Español",sv:"svenska",tl:"Tagalog (Filipino)",tr:"Türkçe",uk:"украї́нська",ur:"اُردُو",ms:"Bahasa Malaysia"},this.currenciesList={SAR:{en:"Saudi Riyal",ar:"ريال سعودي",symbol:"ر.س"},USD:{en:"US Dollar",ar:"دولار أمريكي",symbol:"$"},EUR:{en:"Euro",ar:"يورو",symbol:"€"},AED:{en:"UAE Dirham",ar:"درهم اماراتي",symbol:"د.إ"},KWD:{en:"Kuwaiti Dinar",ar:"دينار كويتي",symbol:"د.ك"},BHD:{en:"Bahraini Dinar",ar:"دينار بحريني",symbol:"د.ب"},QAR:{en:"Qatari Riyal",ar:"ريال قطري",symbol:"ر.ق"},OMR:{en:"Omani Rial",ar:"ريال عماني",symbol:"ر.ع"},AUD:{en:"Australian Dollar",ar:"دولار استرالي",symbol:"$"},CAD:{en:"Canadian Dollar",ar:"دولار كندي",symbol:"$"},CNY:{en:"Renminbi",ar:"رنمينبي",symbol:"¥"},EGP:{en:"Egyptian Pound",ar:"جنيه مصري",symbol:"ج.م"},GBP:{en:"Pound Sterling",ar:"جنيه استرليني",symbol:"£"},IDR:{en:"Indonesian Rupiah",ar:"روبية إندونيسية",symbol:"Rp"},INR:{en:"Indian Rupee",ar:"روبية هندية",symbol:"₹"},JPY:{en:"Japanese Yen",ar:"ين ياباني",symbol:"¥"},MYR:{en:"Malaysian Ringgit",ar:"رينغيت ماليزي",symbol:"RM"},PKR:{en:"Pakistani Rupee",ar:"روبية باكستانية",symbol:"Rs."},SEK:{en:"Swedish Krona",ar:"كرونة سويدية",symbol:"kr"},SGD:{en:"Singapore Dollar",ar:"دولار سنغافوري",symbol:"$"},TRY:{en:"Turkish Lira",ar:"ليرة تركية",symbol:"₺"},IQD:{en:"Iraqi Dinar",ar:"دينار عراقي",symbol:"د.ع"},LBP:{en:"Lebanese Pound",ar:"ليرة لبنانية",symbol:"ل.ل"},MRO:{en:"Mauritanian Ouguiya",ar:"أوقية موريتانية",symbol:"UM"},SDG:{en:"Sudanese Pound",ar:"جنيه سوداني",symbol:"SDG"},SYP:{en:"Syrian Pound",ar:"ليرة سورية",symbol:"ل.س"},TND:{en:"Tunisian Dinar",ar:"دينار تونسي",symbol:"د.ت"},JOD:{en:"Jordanian Dinar",ar:"دينار أردني",symbol:"JOD"},DZD:{en:"Algerian Dinar",ar:"دينار جزائري",symbol:"دج"},MAD:{en:"Moroccan Dirham",ar:"درهم مغربي",symbol:"د.م."},LYD:{en:"Libyan Dinar",ar:"دينار ليبي",symbol:"LD"},YER:{en:"Yemeni Riyal",ar:"ريال يمني",symbol:"ر.ي"},ILS:{en:"New Shekel",ar:"شيكل جديد",symbol:"₪"}},this.arabicCurrencies=["SAR","AED","KWD","BHD","QAR","OMR","EGP","IQD","LBP","SYP","TND","DZD","MAD","YER"],this.translationLoaded=!1,this.languages=[],this.currencies=[],this.hasError=!1,this.showTrigger=!1,this.languageSlot=this.host.querySelector('[slot="language"]')?.innerHTML||'<label class="s-localization-modal-label" for="lang-{code}"><span>{name}</span></label>',this.currencySlot=this.host.querySelector('[slot="currency"]')?.innerHTML||'<label class="s-localization-modal-label" for="currency-{code}"><span>{name}</span><small class="s-localization-modal-currency">{symbol}</small></label>'}connectedCallback(){this.isAttached=!0,this.hasLoaded&&this.bindOpenListeners(),this.langUnsubscribe=salla.lang.subscribe((()=>{this.translationLoaded=!0,e(this)}))}disconnectedCallback(){this.isAttached=!1,Salla.event.off("localization::open",this.localizationOpenListener),Salla.event.off("currency::open",this.currencyOpenListener),Salla.event.off("language::open",this.languageOpenListener),this.langUnsubscribe?.()}bindOpenListeners(){this.isAttached&&(Salla.event.on("localization::open",this.localizationOpenListener),Salla.event.on("currency::open",this.currencyOpenListener),Salla.event.on("language::open",this.languageOpenListener))}async componentWillLoad(){await Salla.onReady(),await Salla.lang.onLoaded(),this.hasLoaded=!0,this.bindOpenListeners(),this.language||(this.language=Salla.config.get("user.language_code")),this.currency||(this.currency=Salla.config.get("user.currency_code")),Salla.api.withoutNotifier((()=>this.getCurrencies())).catch((()=>null))}openUnlessNative(){Salla.config.isMobileApp()||this.open()}async open(){return this.modal.open(),await Salla.api.withoutNotifier((()=>this.getLanguages())).then((()=>this.getCurrencies())).then((()=>{this.languages.length<2&&this.currencies.length<2&&this.modal.close()})).catch((a=>{console.log(a),this.hasError=!0,this.errorMessage=a.response?.data?.error?.message||a.response?.data})).finally((()=>this.modal.stopLoading()))}async close(){return this.modal.close()}getCurrency(a){const e=a||this.currency;if(this.currenciesList[e])return this.currenciesList[e];const i=this.currencies.find((a=>a.code===e));if(i){const a=this.escapeHtml(String(i.name||e));return{en:a,ar:a,symbol:this.escapeHtml(String((i.symbol||"").trim()||e))}}return{en:"Saudi Riyal",ar:"ريال سعودي",symbol:"ر.س"}}getLanguageName(){return this.languageNames[this.language]||this.language||""}getCurrencySymbol(a){return"SAR"===(a=a||this.currency)?'<i class="sicon-sar"></i>':"ar"!==this.language&&this.arabicCurrencies.includes(a)?a:this.getCurrency(a).symbol}getCurrencyName(a){return"ar"===this.language?this.getCurrency(a).ar:this.getCurrency(a).en}escapeHtml(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}async getLanguages(){return this.languages.length>1?null:await Salla.config.languages().then((a=>this.languages=a))}async getCurrencies(){return this.currencies.length>1?null:await Salla.config.currencies().then((a=>this.currencies=Object.values(a||{})))}onChangeCurrency(a){this.currency=a.target.value}onChangeLanguage(a){this.language=a.target.value}async submit(){let a;this.btn.load().then((()=>{if(this.currency){if(this.currency!==Salla.config.get("user.currency_code","SAR"))return a=window.location.href,Salla.currency.api.change(this.currency)}else Salla.log("There is no currency!")})).then((()=>{this.language!==Salla.config.get("user.language_code","ar")&&(a=Salla.helpers.addParamToUrl("lang",this.language))})).then((()=>{Salla.cookie.set("s-lang",this.language),Salla.cookie.set("s-curr",this.currency)})).then((()=>this.btn.stop())).then((()=>this.close())).then((()=>{a&&(window.location.href=a.replace(`/${Salla.config.get("user.language_code")}/`,`/${this.language}/`))}))}render(){return[this.showTrigger?i("button",{type:"button",onClick:()=>this.open(),class:"s-localization-modal-trigger-btn"},i("span",null,this.getLanguageName()),i("span",{class:"s-localization-modal-trigger-separator"},"|")," ",i("span",{innerHTML:this.getCurrencySymbol()})):"",i("salla-modal",{key:"f9d068ad678442956baf42eb13d344b302b3eb61",isLoading:!0,class:"s-hidden",ref:a=>this.modal=a,width:"xs"},i("div",{key:"32d8724d52bfe912f1df5fe30c115fb7089d3ee3",slot:"loading"},i("div",{key:"e1db00221c8736e8d29aa3ff6a2f701468e453e9",class:"s-localization-modal-skeleton"},i("salla-skeleton",{key:"420cafb13ba187b6e13565b97377083c3878d7e2",width:"25%",height:"15px"}),i("div",{key:"3012668293ce2edd792f76a180d3a3f0f3a4f19b",class:"s-localization-modal-skeleton-content"},[...Array(4)].map((()=>i("div",{class:"s-localization-modal-skeleton-item"},i("div",{class:"s-localization-modal-skeleton-item-flex"},i("salla-skeleton",{type:"circle",height:"16px",width:"16px"}),i("salla-skeleton",{height:"10px",width:"100px"})),i("salla-skeleton",{height:"15px",width:"20px"}))))),i("salla-skeleton",{key:"de569459de27aa8d75f1ba06ad44ca1746753f08",width:"25%",height:"15px"}),i("div",{key:"a2c912b32e31dbfc571c2dabb82414fa1be7f7f4",class:"s-localization-modal-skeleton-content"},[...Array(4)].map((()=>i("div",{class:"s-localization-modal-skeleton-item"},i("div",{class:"s-localization-modal-skeleton-item-flex"},i("salla-skeleton",{type:"circle",height:"16px",width:"16px"}),i("salla-skeleton",{height:"10px",width:"100px"})),i("salla-skeleton",{height:"15px",width:"20px"}))))),i("salla-skeleton",{key:"ccf4ee9d98af55d3369e15c5a557f0ce5fcbb61a",height:"40px",width:"100%"}))),this.hasError?i("salla-placeholder",{alignment:"center"},i("span",{slot:"description"},this.errorMessage)):i("div",{class:"s-localization-modal-inner"},this.languages.length>1?i("div",{class:"s-localization-modal-section"},i("label",{class:"s-localization-modal-title"},Salla.lang.get("common.titles.language")),i("div",{class:"s-localization-modal-section-inner"},this.languages.length<6?this.languages.map((a=>i("div",{class:"s-localization-modal-item"},i("input",{class:"s-localization-modal-input",type:"radio",checked:this.language==a.iso_code,onChange:()=>this.language=a.iso_code,name:"language",id:"lang-"+a.code.toLowerCase(),value:a.code}),i("div",{class:"s-localization-modal-label-slot",id:"language-slot",innerHTML:this.languageSlot.replace(/\{name\}/g,a.name).replace(/\{code\}/g,a.code).replace(/\{country_code\}/g,a.country_code)})))):i("select",{class:"s-localization-modal-select",name:"language",onChange:a=>this.onChangeLanguage(a)},this.languages.map((a=>i("option",{value:a.code,selected:this.language==a.code},a.name)))))):"",this.currencies.length>1?i("div",{class:"s-localization-modal-section"},i("label",{class:"s-localization-modal-title"},Salla.lang.get("common.titles.currency")),i("div",{class:"s-localization-modal-section-inner"},this.currencies.length<6?this.currencies.map((a=>i("div",{class:"s-localization-modal-item"},i("input",{class:"s-localization-modal-input",type:"radio",name:"currency",checked:this.currency==a.code,onChange:()=>this.currency=a.code,id:"currency-"+a.code,value:a.code}),i("div",{class:"s-localization-modal-label-slot",id:"currency-slot",innerHTML:this.currencySlot.replace(/\{name\}/g,this.getCurrencyName(a.code)).replace(/\{code\}/g,a.code).replace(/\{symbol\}/g,this.getCurrencySymbol(a.code)).replace(/\{country_code\}/g,a.country_code)})))):i("select",{class:"s-localization-modal-select",name:"currency",onChange:a=>this.onChangeCurrency(a)},this.currencies.map((a=>i("option",{value:a.code,selected:this.currency==a.code},a.name)))))):"",i("salla-button",{width:"wide",ref:a=>this.btn=a,onClick:()=>this.submit()},Salla.lang.get("common.elements.ok"))))]}componentDidRender(){this.host.querySelectorAll("#currency-slot").forEach((a=>a.replaceWith(a.firstChild))),this.host.querySelectorAll("#language-slot").forEach((a=>a.replaceWith(a.firstChild)))}get host(){return t(this)}};l.style='/*!twlt*/.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-localization-modal-trigger-btn{display:inline-flex;width:100%;flex-grow:0;flex-basis:0px;align-items:center;justify-content:center;white-space:nowrap;border-radius:9999px;background-color:rgb(229 231 235 / 0.5);padding-left:0.875rem;padding-right:0.875rem;padding-top:0.5rem;padding-bottom:0.5rem;font-size:0.875rem;line-height:1.25rem;font-weight:500;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:150ms}.s-localization-modal-trigger-btn:hover{background-color:rgb(229 231 235 / 0.7)}.s-localization-modal-trigger-separator{margin-left:0.375rem;margin-right:0.375rem}.s-localization-modal-title{font-size:1rem;line-height:1.5rem;font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-localization-modal-section{margin-bottom:2rem}.s-localization-modal-label-slot{flex-grow:1}.s-localization-modal-inner{width:100%}.s-localization-modal-section-inner{margin-top:1rem}.s-localization-modal-section-inner>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.s-localization-modal-item{display:flex;align-items:center}.s-localization-modal-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-localization-modal-input:focus{--tw-ring-color:var(--color-primary)}.s-localization-modal-label{display:flex;flex-grow:1;cursor:pointer;align-items:center;justify-content:space-between;font-weight:500;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-localization-modal-label:where([dir="ltr"],[dir="ltr"] *){margin-left:0.75rem}.s-localization-modal-label:where([dir="rtl"],[dir="rtl"] *){margin-right:0.75rem}.s-localization-modal-flag{border-radius:0.125rem}.s-localization-modal-currency{--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-localization-modal-select{height:2.5rem;width:100%;appearance:none;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));background-position:right;background-repeat:no-repeat;padding-left:1rem;padding-right:1rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / 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-localization-modal-select:focus{border-color:var(--color-primary)}.s-localization-modal-select:where([dir="rtl"],[dir="rtl"] *){background-position:left}.s-localization-modal-skeleton-content{margin-top:2rem;margin-bottom:2rem;display:flex;flex-direction:column}.s-localization-modal-skeleton-content>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.s-localization-modal-skeleton-item{display:flex;align-items:center;justify-content:space-between}.s-localization-modal-skeleton-item-flex{display:flex;align-items:center}.s-localization-modal-skeleton-item-flex salla-skeleton:nth-child(1){margin-right:0.75rem}.s-localization-modal-skeleton-item-flex salla-skeleton:nth-child(1):where([dir="rtl"],[dir="rtl"] *){margin-right:0px;margin-left:0.75rem}';export{l as salla_localization_modal}