@salla.sa/twilight-components 2.14.523 → 2.14.524

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 (337) hide show
  1. package/dist/cjs/{filepond-DCHVhc44.js → filepond-BVaAyFoF.js} +1 -1
  2. package/dist/cjs/{filepond-plugin-file-poster-CfA-n2Oh.js → filepond-plugin-file-poster-D_7P3fIq.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-validate-size-DZQkwEKK.js → filepond-plugin-file-validate-size-wpUbEEJQ.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-type-Dl8je2Fu.js → filepond-plugin-file-validate-type-DnsofxYi.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-image-edit-BzYslA6t.js → filepond-plugin-image-edit-BN8NNj8r.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-exif-orientation-D856YsXh.js → filepond-plugin-image-exif-orientation-Bh2lasm5.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-preview-CYa8C4oD.js → filepond-plugin-image-preview-CEuvK6zb.js} +1 -1
  8. package/dist/cjs/{functions-DG_jVKBR.js → functions-BsqbMNo6.js} +1 -1
  9. package/dist/cjs/{index-EWm59_5l.js → index-B2m0lkUU.js} +6 -6
  10. package/dist/cjs/{index-D-YSscuC.js → index-D5DmfeX9.js} +1 -1
  11. package/dist/cjs/loader.cjs.js +2 -2
  12. package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
  13. package/dist/cjs/salla-accordion_6.cjs.entry.js +1 -1
  14. package/dist/cjs/salla-add-product-button_5.cjs.entry.js +1 -1
  15. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  16. package/dist/cjs/salla-alert_2.cjs.entry.js +1 -1
  17. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  18. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  19. package/dist/cjs/salla-badge.cjs.entry.js +1 -1
  20. package/dist/cjs/salla-basket-gap.cjs.entry.js +1 -1
  21. package/dist/cjs/salla-booking-field_7.cjs.entry.js +10 -10
  22. package/dist/cjs/salla-bullet-delivery_2.cjs.entry.js +1 -1
  23. package/dist/cjs/salla-cart-coupons.cjs.entry.js +1 -1
  24. package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-cart-summary-card.cjs.entry.js +1 -1
  26. package/dist/cjs/salla-cashback-banner.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-comment-factors.cjs.entry.js +1 -1
  28. package/dist/cjs/salla-comment-form_8.cjs.entry.js +1 -1
  29. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  31. package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-count-down_2.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-delivery-promise.cjs.entry.js +1 -1
  35. package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
  36. package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-filters.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
  39. package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
  40. package/dist/cjs/salla-hook.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
  44. package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
  45. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  46. package/dist/cjs/salla-loyalty-banner.cjs.entry.js +2 -2
  47. package/dist/cjs/salla-loyalty-exchange-product-card_5.cjs.entry.js +3 -3
  48. package/dist/cjs/salla-loyalty-hero_2.cjs.entry.js +2 -2
  49. package/dist/cjs/salla-loyalty-panel.cjs.entry.js +3 -3
  50. package/dist/cjs/salla-loyalty-points-banner.cjs.entry.js +1 -1
  51. package/dist/cjs/salla-loyalty-points-history.cjs.entry.js +1 -1
  52. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  53. package/dist/cjs/salla-loyalty-program.cjs.entry.js +3 -3
  54. package/dist/cjs/salla-loyalty-reward.cjs.entry.js +2 -2
  55. package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
  56. package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
  57. package/dist/cjs/salla-map_2.cjs.entry.js +1 -1
  58. package/dist/cjs/salla-menu.cjs.entry.js +1 -1
  59. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  60. package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
  61. package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
  62. package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
  63. package/dist/cjs/salla-next-order-coupon.cjs.entry.js +1 -1
  64. package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
  65. package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
  66. package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
  67. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  68. package/dist/cjs/salla-order-branch.cjs.entry.js +1 -1
  69. package/dist/cjs/salla-order-cancel.cjs.entry.js +1 -1
  70. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  71. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  72. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  73. package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
  74. package/dist/cjs/salla-order-edit-product-card.cjs.entry.js +1 -1
  75. package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
  76. package/dist/cjs/salla-order-shipments.cjs.entry.js +41 -4
  77. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  78. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  79. package/dist/cjs/salla-orders.cjs.entry.js +1 -1
  80. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  81. package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
  82. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  83. package/dist/cjs/salla-product-card-embed.cjs.entry.js +1 -1
  84. package/dist/cjs/salla-product-card_2.cjs.entry.js +1 -1
  85. package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
  86. package/dist/cjs/salla-products-list.cjs.entry.js +1 -1
  87. package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
  88. package/dist/cjs/salla-rating-modal-v2.cjs.entry.js +1 -1
  89. package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
  90. package/dist/cjs/salla-review-factors-tags.cjs.entry.js +1 -1
  91. package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
  92. package/dist/cjs/salla-search.cjs.entry.js +1 -1
  93. package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
  94. package/dist/cjs/salla-slider.cjs.entry.js +1 -1
  95. package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
  96. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  97. package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
  98. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  99. package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
  100. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  101. package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
  102. package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
  103. package/dist/cjs/salla-user-settings.cjs.entry.js +1 -1
  104. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  105. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  106. package/dist/cjs/salla-wishlist-actions.cjs.entry.js +1 -1
  107. package/dist/cjs/{tracked-promise-C2tbWLf_.js → tracked-promise-DV7LEYsU.js} +1 -1
  108. package/dist/cjs/twilight.cjs.js +2 -2
  109. package/dist/cjs/{vanilla-picker-BXezTQQL.js → vanilla-picker-CXvH2EWT.js} +1 -1
  110. package/dist/collection/Helpers/latest-request.js +31 -0
  111. package/dist/collection/components/salla-order-shipments/salla-order-shipments.js +12 -3
  112. package/dist/components/index.js +2 -2
  113. package/dist/components/salla-order-shipments.js +40 -3
  114. package/dist/esm/{filepond-DQ6pHM8K.js → filepond-DTzVnm2p.js} +1 -1
  115. package/dist/esm/{filepond-plugin-file-poster-Cin3Drv6.js → filepond-plugin-file-poster-Bgus9Ofh.js} +1 -1
  116. package/dist/esm/{filepond-plugin-file-validate-size-Bo-SgRcF.js → filepond-plugin-file-validate-size-B8PRvgIP.js} +1 -1
  117. package/dist/esm/{filepond-plugin-file-validate-type-DvBZJiZ0.js → filepond-plugin-file-validate-type-CAs60OfK.js} +1 -1
  118. package/dist/esm/{filepond-plugin-image-edit-DTVE32mN.js → filepond-plugin-image-edit-5pQX-bqs.js} +1 -1
  119. package/dist/esm/{filepond-plugin-image-exif-orientation-W7UUFbyD.js → filepond-plugin-image-exif-orientation-CQmP0y_L.js} +1 -1
  120. package/dist/esm/{filepond-plugin-image-preview-DGuRiudm.js → filepond-plugin-image-preview-DdIiCGg1.js} +1 -1
  121. package/dist/esm/{functions-D7FvvD3w.js → functions-DpljrYCU.js} +1 -1
  122. package/dist/esm/{index-Bg8UYNC5.js → index-DPAGXd41.js} +1 -1
  123. package/dist/esm/{index-BM5d07q2.js → index-Dm54yhRt.js} +6 -6
  124. package/dist/esm/loader.js +3 -3
  125. package/dist/esm/salla-accordion-body_2.entry.js +1 -1
  126. package/dist/esm/salla-accordion_6.entry.js +1 -1
  127. package/dist/esm/salla-add-product-button_5.entry.js +1 -1
  128. package/dist/esm/salla-advertisement.entry.js +1 -1
  129. package/dist/esm/salla-alert_2.entry.js +1 -1
  130. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  131. package/dist/esm/salla-apps-icons.entry.js +1 -1
  132. package/dist/esm/salla-badge.entry.js +1 -1
  133. package/dist/esm/salla-basket-gap.entry.js +1 -1
  134. package/dist/esm/salla-booking-field_7.entry.js +10 -10
  135. package/dist/esm/salla-bullet-delivery_2.entry.js +1 -1
  136. package/dist/esm/salla-cart-coupons.entry.js +1 -1
  137. package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
  138. package/dist/esm/salla-cart-summary-card.entry.js +1 -1
  139. package/dist/esm/salla-cashback-banner.entry.js +1 -1
  140. package/dist/esm/salla-comment-factors.entry.js +1 -1
  141. package/dist/esm/salla-comment-form_8.entry.js +1 -1
  142. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  143. package/dist/esm/salla-contacts.entry.js +1 -1
  144. package/dist/esm/salla-cookies-bar.entry.js +1 -1
  145. package/dist/esm/salla-count-down_2.entry.js +1 -1
  146. package/dist/esm/salla-custom-fields.entry.js +1 -1
  147. package/dist/esm/salla-delivery-promise.entry.js +1 -1
  148. package/dist/esm/salla-edit-order-button.entry.js +1 -1
  149. package/dist/esm/salla-filters-widget.entry.js +1 -1
  150. package/dist/esm/salla-filters.entry.js +1 -1
  151. package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
  152. package/dist/esm/salla-gifting.entry.js +1 -1
  153. package/dist/esm/salla-hook.entry.js +1 -1
  154. package/dist/esm/salla-infinite-scroll.entry.js +1 -1
  155. package/dist/esm/salla-installment.entry.js +1 -1
  156. package/dist/esm/salla-list-tile.entry.js +1 -1
  157. package/dist/esm/salla-localization-modal.entry.js +1 -1
  158. package/dist/esm/salla-login-modal.entry.js +1 -1
  159. package/dist/esm/salla-loyalty-banner.entry.js +2 -2
  160. package/dist/esm/salla-loyalty-exchange-product-card_5.entry.js +3 -3
  161. package/dist/esm/salla-loyalty-hero_2.entry.js +2 -2
  162. package/dist/esm/salla-loyalty-panel.entry.js +3 -3
  163. package/dist/esm/salla-loyalty-points-banner.entry.js +1 -1
  164. package/dist/esm/salla-loyalty-points-history.entry.js +1 -1
  165. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  166. package/dist/esm/salla-loyalty-program.entry.js +3 -3
  167. package/dist/esm/salla-loyalty-reward.entry.js +2 -2
  168. package/dist/esm/salla-loyalty.entry.js +1 -1
  169. package/dist/esm/salla-maintenance-alert.entry.js +1 -1
  170. package/dist/esm/salla-map_2.entry.js +1 -1
  171. package/dist/esm/salla-menu.entry.js +1 -1
  172. package/dist/esm/salla-metadata.entry.js +1 -1
  173. package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
  174. package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
  175. package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
  176. package/dist/esm/salla-next-order-coupon.entry.js +1 -1
  177. package/dist/esm/salla-notification-item.entry.js +1 -1
  178. package/dist/esm/salla-notifications.entry.js +1 -1
  179. package/dist/esm/salla-offer-modal.entry.js +1 -1
  180. package/dist/esm/salla-offer.entry.js +1 -1
  181. package/dist/esm/salla-order-branch.entry.js +1 -1
  182. package/dist/esm/salla-order-cancel.entry.js +1 -1
  183. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  184. package/dist/esm/salla-order-details-options.entry.js +1 -1
  185. package/dist/esm/salla-order-details.entry.js +1 -1
  186. package/dist/esm/salla-order-edit-item.entry.js +1 -1
  187. package/dist/esm/salla-order-edit-product-card.entry.js +1 -1
  188. package/dist/esm/salla-order-edit.entry.js +1 -1
  189. package/dist/esm/salla-order-shipments.entry.js +41 -4
  190. package/dist/esm/salla-order-summary.entry.js +1 -1
  191. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  192. package/dist/esm/salla-orders.entry.js +1 -1
  193. package/dist/esm/salla-payments.entry.js +1 -1
  194. package/dist/esm/salla-placeholder.entry.js +1 -1
  195. package/dist/esm/salla-price-range.entry.js +1 -1
  196. package/dist/esm/salla-product-card-embed.entry.js +1 -1
  197. package/dist/esm/salla-product-card_2.entry.js +1 -1
  198. package/dist/esm/salla-product-size-guide.entry.js +1 -1
  199. package/dist/esm/salla-products-list.entry.js +1 -1
  200. package/dist/esm/salla-quick-order.entry.js +1 -1
  201. package/dist/esm/salla-rating-modal-v2.entry.js +1 -1
  202. package/dist/esm/salla-rating-modal.entry.js +1 -1
  203. package/dist/esm/salla-review-factors-tags.entry.js +1 -1
  204. package/dist/esm/salla-scopes.entry.js +1 -1
  205. package/dist/esm/salla-search.entry.js +1 -1
  206. package/dist/esm/salla-skeleton.entry.js +1 -1
  207. package/dist/esm/salla-slider.entry.js +1 -1
  208. package/dist/esm/salla-social-share.entry.js +1 -1
  209. package/dist/esm/salla-social.entry.js +1 -1
  210. package/dist/esm/salla-tab-content_3.entry.js +1 -1
  211. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  212. package/dist/esm/salla-tooltip.entry.js +1 -1
  213. package/dist/esm/salla-trust-badges.entry.js +1 -1
  214. package/dist/esm/salla-user-menu.entry.js +1 -1
  215. package/dist/esm/salla-user-profile.entry.js +1 -1
  216. package/dist/esm/salla-user-settings.entry.js +1 -1
  217. package/dist/esm/salla-verify.entry.js +1 -1
  218. package/dist/esm/salla-wallet.entry.js +1 -1
  219. package/dist/esm/salla-wishlist-actions.entry.js +1 -1
  220. package/dist/esm/{tracked-promise-C6Ob-qmO.js → tracked-promise-B8yCrzxY.js} +1 -1
  221. package/dist/esm/twilight.js +3 -3
  222. package/dist/esm/{vanilla-picker-DgInak8N.js → vanilla-picker-DFISd8Ab.js} +1 -1
  223. package/dist/twilight/{p-7b0fd2d3.entry.js → p-00d22240.entry.js} +1 -1
  224. package/dist/twilight/{p-8bcbf94b.entry.js → p-01277c1f.entry.js} +1 -1
  225. package/dist/twilight/{p-29396bf6.entry.js → p-042fe473.entry.js} +1 -1
  226. package/dist/twilight/{p-1eb9b42d.entry.js → p-066b78d8.entry.js} +1 -1
  227. package/dist/twilight/{p-d5d107ea.entry.js → p-074f8d80.entry.js} +1 -1
  228. package/dist/twilight/{p-7741fc5c.entry.js → p-083bc1c5.entry.js} +1 -1
  229. package/dist/twilight/{p-2562e44b.entry.js → p-08c61694.entry.js} +1 -1
  230. package/dist/twilight/{p-55d1c6c9.entry.js → p-0b74b865.entry.js} +1 -1
  231. package/dist/twilight/{p-abc35ead.entry.js → p-0e24390e.entry.js} +1 -1
  232. package/dist/twilight/{p-c16c5ef5.entry.js → p-18dc5f4f.entry.js} +1 -1
  233. package/dist/twilight/{p-a560ee5f.entry.js → p-1ca4cb0a.entry.js} +1 -1
  234. package/dist/twilight/{p-2ac41a04.entry.js → p-1daa6531.entry.js} +1 -1
  235. package/dist/twilight/{p-8db3e0c5.entry.js → p-24901c56.entry.js} +1 -1
  236. package/dist/twilight/{p-1062425d.entry.js → p-2798756b.entry.js} +1 -1
  237. package/dist/twilight/{p-e45ead59.entry.js → p-282d3b67.entry.js} +1 -1
  238. package/dist/twilight/{p-af6f8519.entry.js → p-2b52c465.entry.js} +1 -1
  239. package/dist/twilight/{p-e99c1765.entry.js → p-2ca2dc2a.entry.js} +1 -1
  240. package/dist/twilight/{p-1de72efd.entry.js → p-2db47792.entry.js} +1 -1
  241. package/dist/twilight/{p-abf4c948.entry.js → p-2dbea343.entry.js} +1 -1
  242. package/dist/twilight/{p-6dcd7b46.entry.js → p-2e9f26cf.entry.js} +1 -1
  243. package/dist/twilight/{p-a3aef8bb.entry.js → p-31d66e74.entry.js} +1 -1
  244. package/dist/twilight/{p-9b28408b.entry.js → p-32f66a87.entry.js} +1 -1
  245. package/dist/twilight/{p-b8e31d81.entry.js → p-34bb17c9.entry.js} +1 -1
  246. package/dist/twilight/{p-DnmPgY_G.js → p-3Tx29o41.js} +1 -1
  247. package/dist/twilight/{p-ac6abf15.entry.js → p-4364da4b.entry.js} +1 -1
  248. package/dist/twilight/{p-bfc96cf2.entry.js → p-4467ceb0.entry.js} +1 -1
  249. package/dist/twilight/{p-b2a4ebbb.entry.js → p-44ce2c67.entry.js} +1 -1
  250. package/dist/twilight/{p-3e3b4ace.entry.js → p-453ac18c.entry.js} +1 -1
  251. package/dist/twilight/{p-d1b29d76.entry.js → p-4c3b7f11.entry.js} +1 -1
  252. package/dist/twilight/{p-bad00f10.entry.js → p-4f5916dd.entry.js} +1 -1
  253. package/dist/twilight/{p-45f5fa27.entry.js → p-5acbcd72.entry.js} +1 -1
  254. package/dist/twilight/{p-0a1790b8.entry.js → p-6417da90.entry.js} +1 -1
  255. package/dist/twilight/{p-a43ce575.entry.js → p-6aa57467.entry.js} +1 -1
  256. package/dist/twilight/{p-23dc064a.entry.js → p-6c0de09b.entry.js} +1 -1
  257. package/dist/twilight/{p-65dd99ed.entry.js → p-6d989923.entry.js} +1 -1
  258. package/dist/twilight/{p-45729b8e.entry.js → p-6f20f79a.entry.js} +1 -1
  259. package/dist/twilight/{p-ce653f7c.entry.js → p-6fe98a4d.entry.js} +1 -1
  260. package/dist/twilight/{p-1966d0ca.entry.js → p-70e2d99d.entry.js} +1 -1
  261. package/dist/twilight/{p-ee69544b.entry.js → p-71aeefcf.entry.js} +1 -1
  262. package/dist/twilight/{p-66312912.entry.js → p-7622f77e.entry.js} +1 -1
  263. package/dist/twilight/{p-70d1e905.entry.js → p-764b05c3.entry.js} +1 -1
  264. package/dist/twilight/{p-ace9d8f0.entry.js → p-811d6f89.entry.js} +1 -1
  265. package/dist/twilight/{p-aba9e8c2.entry.js → p-82e55dfd.entry.js} +1 -1
  266. package/dist/twilight/{p-bc0558d2.entry.js → p-8493acd8.entry.js} +1 -1
  267. package/dist/twilight/{p-afe7c1ba.entry.js → p-85ffcb0d.entry.js} +1 -1
  268. package/dist/twilight/{p-6f0215ec.entry.js → p-865393ae.entry.js} +1 -1
  269. package/dist/twilight/{p-42fc5f2f.entry.js → p-879904a5.entry.js} +1 -1
  270. package/dist/twilight/p-8a789d76.entry.js +4 -0
  271. package/dist/twilight/{p-9fdbb0fe.entry.js → p-8d2a1e57.entry.js} +1 -1
  272. package/dist/twilight/{p-42551c8c.entry.js → p-8e05dbd7.entry.js} +1 -1
  273. package/dist/twilight/{p-e060ee6b.entry.js → p-90929ee0.entry.js} +1 -1
  274. package/dist/twilight/{p-afe2670a.entry.js → p-92cf1e0d.entry.js} +1 -1
  275. package/dist/twilight/{p-719cd9a6.entry.js → p-96d471a9.entry.js} +1 -1
  276. package/dist/twilight/{p-7dd8a87f.entry.js → p-9f88fd32.entry.js} +1 -1
  277. package/dist/twilight/{p-CHQutKQ7.js → p-BdU8gNuL.js} +1 -1
  278. package/dist/twilight/{p-kYkXTeTb.js → p-Bmtik9Kw.js} +1 -1
  279. package/dist/twilight/{p-Cvx2P5Pg.js → p-Bsy6Ioog.js} +1 -1
  280. package/dist/twilight/{p-Cc9owUMd.js → p-CK_JEpA3.js} +1 -1
  281. package/dist/twilight/{p-JQryHMzJ.js → p-CQ_QHwLy.js} +1 -1
  282. package/dist/twilight/{p-lri6csDE.js → p-C_YmM4Ke.js} +1 -1
  283. package/dist/twilight/{p-BbNEoGml.js → p-CfrlyZxh.js} +1 -1
  284. package/dist/twilight/{p-DaCdMnag.js → p-D6U543Hv.js} +1 -1
  285. package/dist/twilight/{p-CyUI27N5.js → p-DOQPe4jW.js} +1 -1
  286. package/dist/twilight/{p-BM5d07q2.js → p-Dm54yhRt.js} +1 -1
  287. package/dist/twilight/{p-e-mxvhkF.js → p-N0-g_Ku2.js} +2 -2
  288. package/dist/twilight/{p-26cac2a2.entry.js → p-a26fb2b5.entry.js} +1 -1
  289. package/dist/twilight/p-a307c408.entry.js +4 -0
  290. package/dist/twilight/{p-e9259ff2.entry.js → p-a5070e48.entry.js} +1 -1
  291. package/dist/twilight/{p-e0a0653e.entry.js → p-a7643570.entry.js} +1 -1
  292. package/dist/twilight/{p-9c1e5214.entry.js → p-acfc17d6.entry.js} +1 -1
  293. package/dist/twilight/{p-1865bb17.entry.js → p-b089053b.entry.js} +1 -1
  294. package/dist/twilight/{p-3f1b74c4.entry.js → p-b53f24e0.entry.js} +1 -1
  295. package/dist/twilight/{p-ff5fc7fa.entry.js → p-b775c3a7.entry.js} +1 -1
  296. package/dist/twilight/{p-d23989f3.entry.js → p-b9228f9e.entry.js} +1 -1
  297. package/dist/twilight/{p-80bdb370.entry.js → p-bbad7f4d.entry.js} +1 -1
  298. package/dist/twilight/{p-a4d7223f.entry.js → p-bc633deb.entry.js} +1 -1
  299. package/dist/twilight/{p-5c5f6ad3.entry.js → p-bd31410b.entry.js} +1 -1
  300. package/dist/twilight/{p-9fb0a8ad.entry.js → p-be71261f.entry.js} +1 -1
  301. package/dist/twilight/{p-b3f60292.entry.js → p-bf7b92c5.entry.js} +1 -1
  302. package/dist/twilight/p-c38bfc00.entry.js +4 -0
  303. package/dist/twilight/{p-5ce9e4e4.entry.js → p-c55ed08e.entry.js} +1 -1
  304. package/dist/twilight/{p-30089930.entry.js → p-c88af64d.entry.js} +1 -1
  305. package/dist/twilight/{p-8b16e8b8.entry.js → p-cd0f27b8.entry.js} +1 -1
  306. package/dist/twilight/{p-82384661.entry.js → p-ce888cc2.entry.js} +1 -1
  307. package/dist/twilight/{p-04756108.entry.js → p-d171016f.entry.js} +1 -1
  308. package/dist/twilight/{p-b827f3d2.entry.js → p-d34ee17e.entry.js} +1 -1
  309. package/dist/twilight/{p-5aa658d1.entry.js → p-d5262ac3.entry.js} +1 -1
  310. package/dist/twilight/{p-b5203de2.entry.js → p-d594a28c.entry.js} +1 -1
  311. package/dist/twilight/{p-90ea6647.entry.js → p-d6146737.entry.js} +1 -1
  312. package/dist/twilight/{p-beb0a808.entry.js → p-d8909798.entry.js} +1 -1
  313. package/dist/twilight/{p-3c5c8040.entry.js → p-d8d26e4b.entry.js} +1 -1
  314. package/dist/twilight/{p-9e1645b7.entry.js → p-d9a53204.entry.js} +1 -1
  315. package/dist/twilight/{p-dec7ad63.entry.js → p-df1badad.entry.js} +1 -1
  316. package/dist/twilight/{p-fdfa010d.entry.js → p-e14dc1a9.entry.js} +1 -1
  317. package/dist/twilight/{p-78ed3c14.entry.js → p-e4c40a79.entry.js} +1 -1
  318. package/dist/twilight/{p-7cdfa2ed.entry.js → p-e6255c72.entry.js} +1 -1
  319. package/dist/twilight/{p-c82feb7c.entry.js → p-e775748f.entry.js} +1 -1
  320. package/dist/twilight/{p-01f81bed.entry.js → p-e8cc3acd.entry.js} +1 -1
  321. package/dist/twilight/{p-f443ae10.entry.js → p-eb1e775a.entry.js} +1 -1
  322. package/dist/twilight/{p-c98be632.entry.js → p-edae5524.entry.js} +1 -1
  323. package/dist/twilight/{p-698f2e97.entry.js → p-f1639848.entry.js} +1 -1
  324. package/dist/twilight/{p-62ff80dc.entry.js → p-f351fca5.entry.js} +1 -1
  325. package/dist/twilight/{p-0e4332c5.entry.js → p-f6b097ee.entry.js} +1 -1
  326. package/dist/twilight/{p-2aa80a12.entry.js → p-f9f3639d.entry.js} +1 -1
  327. package/dist/twilight/{p-a6a1affc.entry.js → p-fcc76e96.entry.js} +1 -1
  328. package/dist/twilight/{p-66714663.entry.js → p-fcfd176b.entry.js} +1 -1
  329. package/dist/twilight/{p-f72a852a.entry.js → p-ff58cb8e.entry.js} +1 -1
  330. package/dist/twilight/twilight.esm.js +1 -1
  331. package/dist/types/Helpers/latest-request.d.ts +18 -0
  332. package/dist/types/components/salla-order-shipments/interfaces.d.ts +6 -0
  333. package/dist/types/components/salla-order-shipments/salla-order-shipments.d.ts +2 -0
  334. package/package.json +5 -5
  335. package/dist/twilight/p-3fb2daff.entry.js +0 -4
  336. package/dist/twilight/p-d97d37ec.entry.js +0 -4
  337. package/dist/twilight/p-e2e84b7e.entry.js +0 -4
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,c as s,h as i,H as a,a as e,e as o}from"./p-BM5d07q2.js";import{P as n}from"./p-DY4LZmNP.js";import{H as l}from"./p-XnA1YTjA.js";import{a as r}from"./p-CL7OPpYS.js";import{B as c}from"./p-D3mWkc-3.js";import{D as d}from"./p-CoQJOPRz.js";import{S as h}from"./p-BZp0rKEO.js";import{C as p}from"./p-C6jIkM-X.js";import"./p-CgtvEd63.js";class u{constructor(t,s){this.host=t,this.productId=s,this.collected=!1,this.livePrice=0}static attach(t,s){const i=t.querySelector("salla-mini-checkout-widget");if(!i)return!1;const a=new u(t,String(s));return salla.product?.event?.onPriceUpdated?.((t=>{a.livePrice=Number(t?.data?.price)||a.livePrice})),i.addEventListener("click",(t=>a.handleWidgetClick(t,i)),!0),!0}getSelectedQuantity(){try{const t=document.querySelector("form.product-form"),s=t?.getElementSallaData?.(),i=Number(s instanceof FormData?s.get("quantity"):s?.quantity);if(Number.isFinite(i)&&i>0)return i}catch{}return Number(this.host.getAttribute("quantity"))||1}async handleWidgetClick(t,s){if(this.collected)return void(this.collected=!1);if(t.preventDefault(),t.stopImmediatePropagation(),!await this.validatePdpOptions())return;if(salla.config.isGuest())return void salla.api.auth.requireLoginThen("salla-add-product-button::oo.after-login",(()=>this.handleWidgetClick(t,s)));let i;s.classList.add("s-add-product-button-busy");try{i=await salla.api.withoutNotifier((()=>salla.product.api.getOrderOptions([{id:this.productId,quantity:this.getSelectedQuantity()}])))}catch(t){return salla?.logger?.warn?.("order-options: fetch failed",t),s.classList.remove("s-add-product-button-busy"),void this.resumeWidget(s)}s.classList.remove("s-add-product-button-busy");const a=i?.data?.order_options||[];if(!a.length)return void this.resumeWidget(s);const e=this.livePrice>0?this.livePrice:Number(i?.data?.products?.[0]?.price?.amount)||0,o=this.ensureModal();try{const t=await o.open({orderOptions:a,basePrice:e});this.injectIntoMini(t?.orderOptions||[]),this.resumeWidget(s)}catch{}}async validatePdpOptions(){const t=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);return!t||("function"==typeof t.validateAndScroll?await t.validateAndScroll():"function"!=typeof t.reportValidity||await t.reportValidity())}injectIntoMini(t){if(!t.length)return;const s=this.productId,i=a=>{if(String(a?.id)===String(s))try{a?.payload?.set?.("order_options",t)}finally{salla.event.off("cart::before.add.item",i)}};salla.event.on("cart::before.add.item",i)}ensureModal(){let t=document.querySelector("salla-order-options-modal");return t||(t=document.createElement("salla-order-options-modal"),document.body.appendChild(t)),t}resumeWidget(t){this.collected=!0;const s=t.shadowRoot?.querySelector?.(".s-fast-checkout-button");s?s.click():"function"==typeof t.click&&t.click()}}const m=class{constructor(i){t(this,i),this.success=s(this,"success"),this.failed=s(this,"failed"),this.hostAttributes={},this.hasPreOrder=!1,this.productStatus="sale",this.productType="product",this.selectedOptions=[],this.buyNowText=salla.lang.get("pages.products.buy_now"),this.isDesktopViewport="undefined"==typeof window||window.matchMedia("(min-width: 768px)").matches,this.viewportMediaQuery=null,this.orderOptionsGateAttached=!1,this.onViewportChange=t=>{this.isDesktopViewport=t.matches,this.btn?.setText(t.matches&&this.passedLabel?this.passedLabel:this.getLabel())},salla.lang.onLoaded((()=>{this.buyNowText=salla.lang.get("pages.products.buy_now")}))}getLabel(){return"sale"===this.productStatus&&this.supportStickyBar&&!this.isDesktopViewport&&this.showQuickBuy&&this.isApplePayActive?n:this.hasPreOrder?salla.lang.get("pages.products.pre_order_now"):"sale"===this.productStatus&&"booking"===this.productType?salla.lang.get("pages.cart.book_now"):"sale"===this.productStatus?salla.lang.get("pages.cart.add_to_cart"):"donating"!==this.productType?salla.lang.get("pages.products.out_of_stock"):salla.lang.get("pages.products.donation_exceed")}addProductToCart(t){if("booking"===this.productType)return t.preventDefault(),this.addBookingProduct();if("submit"===this.hostAttributes.type)return!1;t.preventDefault(),this.btn?.disable();const s=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);return s&&"function"==typeof s.validateAndScroll?s.validateAndScroll().then((async t=>{const s={isValid:t,component:this};if(await salla.hooks.call("salla-add-product-button","validate",s),s.isValid)return this._proceedAddToCart();this.btn?.enable()})).catch((()=>{this.btn?.enable()})):this._proceedAddToCart()}async _proceedAddToCart(){const t=this.host.closest("salla-products-list, salla-products-slider")??this.host.closest("salla-product-card, custom-salla-product-card"),s=Object.entries({id:this.productId,donation_amount:this.donatingAmount,quantity:this.quantity,endpoint:"quickAdd",source:l.getProductsSource(t?.getAttribute("source"))}).reduce(((t,[s,i])=>i?(t[s]=i,t):t),{});return salla.cart.addItem(s).then((async t=>(this.selectedOptions=[],this.btn?.enable(),this.success.emit(t),t))).catch((t=>{this.failed.emit(t),this.btn?.enable()}))}addBookingProduct(){return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("booking::add",this.productId),void salla.event.dispatch("login::open")):salla.booking.add(this.productId).then((t=>this.success.emit(t))).catch((t=>this.failed.emit(t)))}getBtnAttributes(){for(let t=0;t<this.host.attributes.length;t++)["id","class"].includes(this.host.attributes[t].name)||(this.hostAttributes[this.host.attributes[t].name]=this.host.attributes[t].value);return this.hostAttributes}get notifyChannels(){return this.channels||salla.api.product.getAvailabilityChannels?.()||l.availabilityChannels()}getQuickBuyBtnAttributes(){return{...this.getBtnAttributes(),type:this.supportStickyBar&&!this.isDesktopViewport?"plain":"donating"==this.productType?"donate":"buy"}}miniCheckoutWidget(){let t=salla.config.get("store.id");if(t)return i("salla-mini-checkout-widget",{language:salla.lang.locale,"store-id":t,config:{user:salla.config.get("user"),failure_url:window.location.href},products:[this.productId],api:salla.config.get("store.api"),outline:!0,"form-selector":"form.product-form",class:"s-add-product-button-mini-checkout"},i("div",{slot:"widget-label",class:"s-add-product-button-mini-checkout-content"},i("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>full-wallet</title>\n<path d="M29 12h-26c-0.668-0.008-1.284-0.226-1.787-0.59l0.009 0.006c-0.744-0.552-1.222-1.428-1.222-2.416 0-1.657 1.343-3 2.999-3h6c0.552 0 1 0.448 1 1s-0.448 1-1 1v0h-6c-0.552 0-1 0.448-1 1 0 0.326 0.156 0.616 0.397 0.798l0.002 0.002c0.167 0.12 0.374 0.194 0.599 0.2l0.001 0h26c0.552 0 1 0.448 1 1s-0.448 1-1 1v0zM27 12c-0.552 0-1-0.448-1-1v0-3h-3c-0.552 0-1-0.448-1-1s0.448-1 1-1v0h4c0.552 0 1 0.448 1 1v0 4c0 0.552-0.448 1-1 1v0zM29 30h-26c-1.657 0-3-1.343-3-3v0-18c0-0.552 0.448-1 1-1s1 0.448 1 1v0 18c0 0.552 0.448 1 1 1v0h25v-5c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM29 18c-0.552 0-1-0.448-1-1v0-6c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM31 24h-7c-2.209 0-4-1.791-4-4s1.791-4 4-4v0h7c0.552 0 1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM24 18c-1.105 0-2 0.895-2 2s0.895 2 2 2v0h6v-4zM25 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-2.306 1.152c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 3.2-1.6c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1v0zM21 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-15.104 7.552c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 16-8c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1-0.001 0-0.001 0-0.002 0h0z"></path>\n</svg>\n'}),this.buyNowText))}componentWillLoad(){return salla.onReady().then((()=>{if(document.documentElement.classList.add("hydrated"),this.showQuickBuy=this.quickBuy&&salla.config.get("store.settings.buy_now")&&"sale"==this.productStatus&&"booking"!==this.productType,this.isApplePayActive=window.ApplePaySession?.canMakePayments()&&salla.config.get("store.settings.payments")?.includes("apple_pay")&&salla.config.get("store.settings.is_salla_gateway",!1),this.passedLabel=this.host.innerHTML.replace("\x3c!----\x3e","").trim(),this.passedLabel&&this.isDesktopViewport)return this.btn?.setText(this.passedLabel);"submit"===this.host.getAttribute("type")&&this.supportStickyBar&&(this.viewportMediaQuery=window.matchMedia("(min-width: 768px)"),this.viewportMediaQuery.addEventListener("change",this.onViewportChange))}))}render(){return this.host.closest(".swiper-slide")?.classList.contains("swiper-slide-duplicate")?"":this.hasSubscribedOptions?i(a,null,i("salla-product-availability",{...this.getBtnAttributes(),"is-subscribed":!0},i("span",{class:"s-hidden"},i("slot",null)))):"out-and-notify"===this.productStatus&&this.notifyChannels||this.hasOutOfStockOption?i(a,null,i("salla-product-availability",{...this.getBtnAttributes()},i("span",{class:"s-hidden"},i("slot",null)))):i(a,{class:{"s-add-product-button-with-quick-buy":this.showQuickBuy,"s-add-product-button-with-sticky-bar":this.supportStickyBar,"s-add-product-button-with-apple-pay":this.showQuickBuy&&this.isApplePayActive}},i("div",{class:{"s-add-product-button-main":this.showQuickBuy,"w-full":!document.getElementById("fast-checkout-js")||["financial_support","donating"].includes(this.productType)}},i("salla-button",{color:"sale"===this.productStatus?"primary":"light",type:"button",fill:"sale"===this.productStatus?"solid":"outline",ref:t=>this.btn=t,onClick:t=>this.addProductToCart(t),disabled:"sale"!==this.productStatus,...this.getBtnAttributes(),"loader-position":"center"},i("slot",null)),this.showQuickBuy&&document.getElementById("fast-checkout-js")&&!["financial_support","donating"].includes(this.productType)?this.miniCheckoutWidget():""),this.showQuickBuy&&this.isApplePayActive?i("salla-quick-buy",{...this.getQuickBuyBtnAttributes()}):"")}async componentDidLoad(){await Salla.hooks.registerComponent("salla-add-product-button",this),this.notifyOptionsAvailability&&salla.event.on("product-options::change",(async t=>{if(!["thumbnail","color","single-option"].includes(t.option.type))return;this.hasSubscribedOptions=!1,this.selectedOptions=await(document.querySelector(`salla-product-options[product-id="${this.productId}"]`)?.getSelectedOptions()),this.hasOutOfStockOption=await(document.querySelector(`salla-product-options[product-id="${this.productId}"]`)?.hasOutOfStockOption());let s=salla.storage.get(`product-${this.productId}-subscribed-options`);if((s||this.subscribedOptions)&&this.hasOutOfStockOption)if(salla.config.isGuest()){const t=s?s.map((t=>t.split(",").map((t=>parseInt(t))))):[];this.hasSubscribedOptions=t.length>0&&t.some((t=>t.every((t=>this.selectedOptions.some((s=>s.id===t))))))}else this.hasSubscribedOptions=!(!this.subscribedOptions||"null"===this.subscribedOptions||"[]"===this.subscribedOptions)&&JSON.parse(this.subscribedOptions).some((t=>t.every((t=>this.selectedOptions.some((s=>s.id===t))))))}))}componentDidRender(){!this.orderOptionsGateAttached&&this.productId&&salla.config.get("store.settings.order_options.mandatory",!1)&&u.attach(this.host,this.productId)&&(this.orderOptionsGateAttached=!0),!this.passedLabel||this.supportStickyBar&&!this.isDesktopViewport?(this.btn?.setText(this.getLabel()),salla.lang.onLoaded((()=>this.btn?.setText(this.getLabel())))):this.btn?.setText(this.passedLabel)}disconnectedCallback(){this.viewportMediaQuery?.removeEventListener("change",this.onViewportChange)}get host(){return e(this)}};m.style=":host{display:block}salla-add-product-button[width=wide]{width:100%}";const y=class{constructor(s){t(this,s),this.limit=3,this.recommendations=[],this.selectedIds=new Set,this.isLoading=!0,this.canRender=!0,this.isAdding=!1,this.title=salla.lang.get("pages.products.bought_together_title"),this.subtitle=salla.lang.get("pages.products.bought_together_subtitle"),this.buyTogetherFor=salla.lang.get("pages.products.buy_together_for"),this.resolvedProductId=0,this.listViewTracked=!1,salla.lang.onLoaded((()=>{this.title=salla.lang.get("pages.products.bought_together_title"),this.subtitle=salla.lang.get("pages.products.bought_together_subtitle"),this.buyTogetherFor=salla.lang.get("pages.products.buy_together_for")}))}componentWillLoad(){salla.onReady().then((()=>{if(!salla.config.get("store.settings.product.bought_together"))return void(this.canRender=!1);const t=salla.config.get("page.id");if(t)return this.resolvedProductId=t,r(String(t));this.canRender=!1})).then((t=>{if(!t?.length)return void(this.canRender=!1);const s=[String(this.resolvedProductId),...t.slice(0,this.limit)];return salla.product.fetch({source:"selected",source_value:s})})).then((t=>{if(!t)return;const s=t?.data??[];if(!s.length)return void(this.canRender=!1);const i=s.find((t=>String(t.id)===String(this.resolvedProductId))),a=s.filter((t=>String(t.id)!==String(this.resolvedProductId)));a.length?(this.recommendations=i?[i,...a]:a,this.selectedIds=new Set(this.recommendations.map((t=>t.id)))):this.canRender=!1})).catch((()=>{this.canRender=!1})).finally((()=>{this.isLoading=!1}))}componentDidRender(){!this.recommendations.length||this.listViewTracked||this.intersectionObserver||(this.intersectionObserver=new IntersectionObserver((t=>{t.some((t=>t.isIntersecting))&&(this.listViewTracked=!0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.emitListViewed())}),{threshold:.1}),this.intersectionObserver.observe(this.el))}disconnectedCallback(){this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0}emitListViewed(){const t=this.recommendations.filter((t=>!this.isMainProduct(t.id)));salla.event.emit("salla-bought-together::list.viewed",{products:t})}isMainProduct(t){return String(t)===String(this.resolvedProductId)}recommendedPosition(t){const s=this.recommendations.filter((t=>!this.isMainProduct(t.id))).findIndex((s=>String(s.id)===String(t)));return-1===s?-1:s+1}emitProductClicked(t,s){salla.event.emit("salla-bought-together::product.clicked",[{product:t,position:s}])}toggleProduct(t){const s=new Set(this.selectedIds);s.has(t)?s.delete(t):s.add(t),this.selectedIds=s}get totalPrice(){const t=this.recommendations.filter((t=>this.selectedIds.has(t.id))).reduce(((t,s)=>t+(s.price??0)),0),s=salla.config.get("store.currency.decimals")??2,i=Math.pow(10,s);return salla.money(Math.round(t*i)/i)}async addSelectedToCart(){if(this.isAdding||!this.selectedIds.size)return;this.isAdding=!0;let t=!1;try{for(const s of Array.from(this.selectedIds))try{salla.cart?.api&&(salla.cart.api.addToCartSource="pdp_fbt");const t=await salla.cart.addItem({id:s,endpoint:"quickAdd",source:"pdp_fbt"}),i=this.recommendations.find((t=>t.id===s));if(i){const a=this.isMainProduct(s)?0:this.recommendedPosition(s),e=t?.data?.items?.find((t=>String(t.product_id)===String(i.id)))??t?.data?.items?.slice(-1)[0];salla.event.emit("salla-bought-together::product.added",[{product:i,position:a,cartItem:e,cartId:t?.data?.id}])}}catch(s){salla.log(s),t=!0}t&&salla.error(salla.lang.get("common.messages.error"))}finally{this.isAdding=!1}}getSkeletonView(){return i(a,{class:"s-bought-together-entry"},i("div",{class:"s-bought-together-skeleton"},i("div",{class:"s-bought-together-skeleton-header"},i("salla-skeleton",{height:"16px",width:"35%"}),i("salla-skeleton",{height:"10px",width:"60%"})),Array(4).fill(null).map(((t,s)=>i("div",{key:s,class:"s-bought-together-skeleton-item"},i("salla-skeleton",{height:"22px",width:"22px"}),i("salla-skeleton",{height:"48px",width:"48px"}),i("div",{class:"s-bought-together-skeleton-info"},i("salla-skeleton",{height:"12px",width:"55%",style:{marginBottom:"3px"}}),i("salla-skeleton",{height:"10px",width:"25%"}))))),i("salla-skeleton",{height:"44px",width:"100%"})))}render(){return this.canRender?this.isLoading?this.getSkeletonView():this.recommendations.length?i(a,{class:"s-bought-together-entry"},i("div",{class:"s-bought-together-header"},i("h3",{class:"s-bought-together-title"},this.title),i("p",{class:"s-bought-together-subtitle"},this.subtitle)),i("div",{class:"s-bought-together-list"},this.recommendations.map((t=>i("div",{key:t.id,class:"s-bought-together-item"+(this.selectedIds.has(t.id)?"":" s-bought-together-item--unchecked")},i("label",{class:"s-bought-together-checkbox-label"},i("input",{type:"checkbox",class:"s-bought-together-checkbox",checked:this.selectedIds.has(t.id),onChange:()=>this.toggleProduct(t.id)}),i("span",{class:"s-bought-together-checkmark"})),i("a",{class:"s-bought-together-item-link",href:t.url,onClick:()=>!this.isMainProduct(t.id)&&this.emitProductClicked(t,this.recommendedPosition(t.id))},i("img",{class:"s-bought-together-item-img",src:t.image?.url||salla.url.cdn("images/s-empty.png"),alt:t.image?.alt||t.name,loading:"lazy",decoding:"async",onError:t=>{t.currentTarget.onerror=null,t.currentTarget.src=salla.url.cdn("images/s-empty.png")}}),i("span",{class:"s-bought-together-item-name"},t.name)),i("span",{class:"s-bought-together-item-price",innerHTML:null!=t.price?salla.money(t.price):""}))))),i("salla-button",{class:"s-bought-together-btn",disabled:!this.selectedIds.size||this.isAdding,loading:this.isAdding,onClick:()=>this.addSelectedToCart()},i("span",{innerHTML:`${this.buyTogetherFor} ${this.totalPrice}`}))):null:null}get el(){return e(this)}};y.style=':host{display:block}.s-bought-together-checkbox:checked~.s-bought-together-checkmark{background-color:var(--color-primary, #2ECC71);border-color:var(--color-primary, #2ECC71)}.s-bought-together-checkbox:checked~.s-bought-together-checkmark::after{content:"";display:block;width:5px;height:9px;border:solid #fff;border-width:0 2px 2px 0;transform:rotate(45deg);margin-top:-2px}';const g=class{constructor(s){t(this,s),this.isUser=salla.config.isUser(),this.translationLoaded=!1,this.notifyOptionsAvailability=!1,this.isSubscribed=!1,this.handleSubmitOptions=async()=>{let t={id:this.productId};if(!this.notifyOptionsAvailability)return t;let s=document.querySelector(`salla-product-options[product-id="${this.productId}"]`),i=Object.values(await(s?.getSelectedOptionsData())||{});if(i.length&&!await(s?.reportValidity())){let t=salla.lang.get("common.messages.required_fields");throw salla.error(t),t}return t.options=[],i.forEach((s=>{s&&!isNaN(s)&&t.options.push(Number(s))})),t},this.typing=t=>{const s=t.target.nextElementSibling;t.target.classList.remove("s-has-error"),s?.classList.contains("s-product-availability-error-msg")&&(s.innerText=""),13===t.keyCode&&this.submit()},salla.lang.onLoaded((()=>{this.translationLoaded=!0,this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.modal?.setTitle(this.title_)})),this.productId||(this.productId=salla.config.get("page.id")),this.isUser||(this.channelsWatcher(this.channels),this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.host.removeAttribute("title"))}channelsWatcher(t){let s=t||salla.api.product.getAvailabilityChannels?.()||l.availabilityChannels();this.channels_=s?s.split(","):[]}get isSubscribedToProduct(){return this.isSubscribed||!this.notifyOptionsAvailability&&(!!salla.api.product.isSubscribedToAvailability?.(this.productId)||!!salla.storage.get(`product-${this.productId}-subscribed`))}openModel(){this.handleSubmitOptions().then((t=>t?this.modal.open():null))}async submit(){let t=await this.handleSubmitOptions();if(this.isUser)return salla.api.product.availabilitySubscribe(t).then((()=>this.isSubscribed=!0));if(this.channels_.includes("sms")||this.channels_.includes("whatsapp")){let{phone:s,countryCode:i}=await this.mobileInput.getValues();t.country_code=i,t.phone=s}return this.channels_.includes("email")&&""!==this.email.value&&(t.email=this.email.value),await this.validateform(),this.btn.load().then((()=>this.btn.disable())).then((()=>salla.api.product.availabilitySubscribe(t))).then((()=>{if(this.notifyOptionsAvailability){if(t.options.length){let s=salla.storage.get(`product-${this.productId}-subscribed-options`)||[],i=t.options.join(",");s.includes(i)?salla.log("already subscribed to this options"):(s.push(i),salla.storage.set(`product-${this.productId}-subscribed-options`,s),this.isSubscribed=!0)}}else this.isSubscribed=!0})).then((()=>this.btn.stop())).then((()=>this.modal.close())).catch((()=>this.btn.stop()&&this.btn.enable()))}async validateform(){try{if(this.channels_.includes("email")){const t=l.isValidEmail(this.email.value);if(t)return;!t&&this.validateField(this.email,salla.lang.get("common.elements.email_is_valid"))}if((this.channels_.includes("sms")||this.channels_.includes("whatsapp"))&&await this.mobileInput.isValid())return}catch(t){throw"Please insert required fields"}}validateField(t,s){t.classList.add("s-has-error"),t.nextElementSibling.innerText="* "+s}render(){return i(a,{key:"ccb098126e7809a6386ff38c74dfa0f00f64deeb",class:"s-product-availability-wrap"},this.isSubscribedToProduct?i("div",{class:"s-product-availability-subscribed"},i("span",{innerHTML:c,class:"s-product-availability-subs-icon"}),salla.lang.get("pages.products.notify_availability_success")):i("salla-button",{width:"wide",onClick:()=>this.isUser?this.submit():this.openModel()},salla.lang.get("pages.products.notify_availability")),this.isUser||this.isSubscribedToProduct?"":this.renderModal())}renderModal(){return i("salla-modal",{ref:t=>this.modal=t,"modal-title":this.title_,subTitle:salla.lang.get("pages.products.notify_availability_subtitle"),width:"sm"},i("span",{slot:"icon",class:"s-product-availability-header-icon",innerHTML:c}),i("div",{class:"s-product-availability-body"},this.channels_.includes("email")?[i("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.email")),i("input",{class:"s-product-availability-input",onKeyDown:t=>this.typing(t),placeholder:salla.lang.get("common.elements.email_placeholder")||"your@email.com",ref:t=>this.email=t,type:"email"}),i("span",{class:"s-product-availability-error-msg"})]:"",this.channels_.includes("sms")||this.channels_.includes("whatsapp")?[i("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.mobile")),i("salla-tel-input",{ref:t=>this.mobileInput=t,onKeyDown:t=>this.typing(t)})]:""),i("div",{slot:"footer",class:"s-product-availability-footer"},i("salla-button",{class:"modal-cancel-btn",width:"wide",color:"light",fill:"outline",onClick:()=>this.modal.close()},salla.lang.get("common.elements.cancel")),i("salla-button",{class:"submit-btn","loader-position":"center",width:"wide",ref:t=>this.btn=t,onClick:()=>this.submit()},salla.lang.get("common.elements.submit"))))}get host(){return e(this)}static get watchers(){return{channels:["channelsWatcher"]}}};var f,b,w;g.style="",function(t){t[t.INIT=1]="INIT",t[t.IDLE=2]="IDLE",t[t.PROCESSING_QUEUED=9]="PROCESSING_QUEUED",t[t.PROCESSING=3]="PROCESSING",t[t.PROCESSING_COMPLETE=5]="PROCESSING_COMPLETE",t[t.PROCESSING_ERROR=6]="PROCESSING_ERROR",t[t.PROCESSING_REVERT_ERROR=10]="PROCESSING_REVERT_ERROR",t[t.LOADING=7]="LOADING",t[t.LOAD_ERROR=8]="LOAD_ERROR"}(f||(f={})),function(t){t[t.EMPTY=0]="EMPTY",t[t.IDLE=1]="IDLE",t[t.ERROR=2]="ERROR",t[t.BUSY=3]="BUSY",t[t.READY=4]="READY"}(b||(b={})),function(t){t[t.INPUT=1]="INPUT",t[t.LIMBO=2]="LIMBO",t[t.LOCAL=3]="LOCAL"}(w||(w={}));const v=class{constructor(a){if(t(this,a),this.changed=s(this,"changed"),this.fileTypes={pdf:"application/pdf",png:"image/png",jpg:"image/jpeg",word:"application/doc,application/ms-doc,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",exl:"application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",txt:"text/plain"},this.outOfStockText="",this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.selectDonationAmount=salla.lang.getWithDefault("pages.products.select_donation_amount","تحديد مبلغ التبرع"),this.selectAmount=salla.lang.getWithDefault("pages.products.select_amount","اختر المبلغ"),this.isCustomDonation=!1,this.selectedOptions=[],this.canDisabled=!1,this.disableCardValue=!0,this.availableDigitalCardValues=[],this.userInitiatedValidation=!1,this.isCartMode=!1,this.availabilityMap={},this.productAvailable=!1,this.outSkus=[],this.ignoreDefaultCardValue=!1,this.productId=salla.config.get("page.id"),this.noPadding=!1,this.handleDonationOptions=(t,s,i)=>{if("custom"===s&&"input"===i){const s=t.target;return salla.helpers.inputDigitsOnly(s),salla.event.emit("product-options::donation-changed",{id:this.productId,price:s.value}),void s.dispatchEvent(new window.Event("change",{bubbles:!0}))}const a="option"===i?String(t.target?.value??""):"";if("option"===i&&"custom"===s&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()),this.isCustomDonation="custom"===a,this.donationInput){if("custom"===a?(this.donationInput.value="",this.donationInput.focus()):this.donationInput.value=a,"custom"===s)return;salla.event.emit("product-options::donation-changed",{id:this.productId,price:a})}},this.hideLabel=t=>!(t.type!==d.DONATION||!t.donation||t.donation.can_donate),this.getExpireDonationMessage=t=>{if(!t.donation)return;const s=t.donation.target_amount<=t.donation.collected_amount;return i("div",{class:{"s-product-options-donation-message":!0,"s-product-options-donation-completed":s,"s-product-options-donation-expired":!s}},i("p",null,t.donation.target_message),i("span",{innerHTML:s?salla.money(t.donation.target_amount):""}))},salla.lang.onLoaded((()=>{this.outOfStockText=salla.lang.get("pages.products.out_of_stock"),this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.selectDonationAmount=salla.lang.getWithDefault("pages.products.select_donation_amount","تحديد مبلغ التبرع"),this.selectAmount=salla.lang.getWithDefault("pages.products.select_amount","اختر المبلغ")})),this.options)try{return void this.setOptionsData(Array.isArray(this.options)?this.options:JSON.parse(this.options))}catch(t){salla.log("Bad json passed via options prop")}Array.isArray(this.optionsData)||(salla.log("Options is not an array[] ---\x3e ",this.optionsData),this.setOptionsData([])),this.productId&&!salla.url.is_page("cart")&&salla.api.product.getDetails(this.productId,["options"]).then((t=>{this.productAvailable=!t.data.is_out_of_stock,this.setOptionsData(t.data.options)}))}async setOptionsData(t){this.optionsData=t,this.outSkus=[],this.optionsData[0]?.details?.forEach((t=>{Object.entries(t.skus_availability||{}).filter((([,t])=>!t)).forEach((([t])=>this.outSkus.push(Number(t))))})),this.fillSelectedOptions(),this.computeAvailability()}async getOptionsData(){return this.optionsData}async getSelectedOptionsData(){const t={},s=this.host.getElementSallaData(),i=void 0!==this.bundleContext?this.bundleContext:null;return s.forEach(((s,a)=>{if(i){if(a.startsWith("bundle[")&&a.includes("[options][")){const i=a.split("[options][")[1].replace("]","");t[i]=s}}else a.startsWith("options[")&&(t[a.replace("options[","").replace("]","")]=s)})),t}async reportValidity(){const t=this.host.querySelectorAll("[required]");let s=!0;for(let i=0;i<t.length;i++){const a=t[i];a.disabled||a.closest(".hidden")||"reportValidity"in a&&!a.reportValidity()&&(s=!1)}return s}async hasOutOfStockOption(){return this.selectedOptions.some((t=>t.is_out))||this.selectedSkus?.length&&this.selectedSkus?.every((t=>this.outSkus.includes(t)))}async getSelectedOptions(){return this.selectedOptions}async getOption(t){return this.optionsData.find((s=>s.id===t))}invalidHandler(t,s){const i=t.target.closest(".s-product-options-option");i.classList.contains("s-product-options-option-error")||i.classList.add("s-product-options-option-error"),!this.userInitiatedValidation&&!salla.helpers.isIOSDevice()||salla.url.is_page("cart")||this.host.querySelector(".s-product-options-option-error")===i&&this.scrollToElement(i)}scrollToElement(t){t&&t.scrollIntoView({behavior:"smooth",block:"center"})}changedHandler(t,s,i=!0){const a={event:t,option:s,detail:null,productId:this.productId};if(s.details){const i=s.details.find((s=>Number(s.id)===Number(t.target.value)));a.detail=i}"country"===s.type&&this.handleCountryOptionChange(t,a.detail);const e=t.target.closest(".s-product-options-option");(t.target.value||(s.type===d.FILE||s.type===d.IMAGE)&&"added"===t.type||s.type===d.MAP&&"selected"===t.type&&t.target.lat&&t.target.lng)&&setTimeout((()=>{e.classList.remove("s-product-options-option-error")}),200),s.type===d.DONATION&&salla.event.emit("product-options::donation-changed",{id:this.productId,price:t.target.value}),this.setSelectedSkus(),this.handleRequiredMultipleOptions(s);const o=this.selectedOptions.findIndex((t=>t.option_id===a.option.id));if(a.option.type===d.MULTIPLE_OPTIONS){const t=this.selectedOptions.findIndex((t=>t.option_id===a.option.id&&t?.id===a.detail?.id));t>-1?this.selectedOptions.splice(t,1):this.selectedOptions.push({...a.detail,option_id:a.option.id})}else a.detail&&0!==Object.keys(a.detail).length?o>-1?this.selectedOptions[o]={...a.detail,option_id:a.option.id}:this.selectedOptions.push({...a.detail,option_id:a.option.id}):o>-1&&this.selectedOptions.splice(o,1);this.optionsData=this.optionsData.map((t=>t.id===a.option.id?{...t,details:t.details.map((t=>({...t,is_selected:a.option.type===d.MULTIPLE_OPTIONS?this.selectedOptions.some((s=>s.id===t.id)):Number(t.id)===Number(a.detail?.id),value:a.detail?.value})))}:t)),this.pruneInvisibleConditionalSelections(),this.setSelectedSkus(),requestAnimationFrame((()=>{this.optionsData?.filter((t=>t.type===d.MULTIPLE_OPTIONS&&t.required)).forEach((t=>this.handleRequiredMultipleOptions(t)))})),i&&(this.changed.emit(a),salla.event.emit("product-options::change",a))}setSelectedSkus(){this.selectedSkus=this.selectedOptions.map((t=>Object.keys(t.skus_availability||{}))).reduce(((t,s)=>t.filter((t=>s.includes(t)))),[]).map((t=>Number(t))),this.computeAvailability()}handleRequiredMultipleOptions(t){if(t.type!==d.MULTIPLE_OPTIONS||!t.required)return;const s=this.host.querySelector(`[data-option-id="${t.id}"]`);if(!s)return;const i=s.querySelectorAll("input:checked").length;s.querySelectorAll("input").forEach((t=>t.toggleAttribute("required",!i)))}pruneInvisibleConditionalSelections(){const t=Math.max(1,this.optionsData.length);for(let s=0;s<t;s++){let t=!1;for(const s of this.optionsData){const i=s.visibility_condition;if(!i)continue;const a=this.selectedOptions.filter((t=>t.option_id===i.option)).map((t=>String(t.id))).includes(String(i.value));("="===i.operator?a:!a)||this.clearStaleOption(s.id)&&(t=!0)}if(!t)break}}clearStaleOption(t){const s=this.optionsData.find((s=>s.id===t));if(!s)return!1;const i=this.selectedOptions.length;this.selectedOptions=this.selectedOptions.filter((s=>s.option_id!==t));const a=this.selectedOptions.length!==i,e=null!=s.value&&String(s.value).length>0,o=s.details?.some((t=>t.is_selected))??!1;return!!(a||e||o)&&(this.optionsData=this.optionsData.map((s=>s.id!==t?s:{...s,value:void 0,details:s.details?.map((t=>({...t,is_selected:!1})))??s.details})),!0)}getLatLng(t,s){return t?t.split(",")["lat"===s?0:1]:""}getDisplayForType(t){return this[`${t.type}Option`]?this[`${t.type}Option`](t):t.type===d.COLOR_PICKER?this.colorPickerOption(t):t.type===d.MULTIPLE_OPTIONS?this.multipleOptions(t):t.type===d.SINGLE_OPTION?this.singleOption(t):t.type===d.RADIO?this.radioOption(t):t.type===d.DIGITAL_CARD_VALUE?this.digitalCardValuesOption(t):t.type===d.COUNTRY?this.countryOption(t):t.type===d.BOOKING&&salla.url.is_page("cart")?i("salla-booking-field",{onInvalidInput:s=>this.invalidHandler(s,t),option:t,productId:t.value}):(salla.log(`Couldn't find options type(${t.type})😢`),"")}getOptionShownWhen(t){return t.visibility_condition?{"data-show-when":`options[${t.visibility_condition.option}] ${t.visibility_condition.operator} ${t.visibility_condition.value}`}:{}}getAvailableDigitalCardSKUs(t){const s=this.optionsData.find((({type:t})=>"digital-code-value"===t));if(!s)throw new Error("product-options:: No digital card options found");const i=Object.keys(t.skus_availability).filter((s=>!1===t.skus_availability[s]));this.availableDigitalCardValues=s.details.filter((t=>!Object.keys(t.skus_availability).filter((t=>i.includes(t))).length))}handleCountryOptionChange(t,s){t.stopImmediatePropagation(),this.ignoreDefaultCardValue=!0;const i=this.host.querySelector("input[data-code-value]:checked");if(i&&(i.checked=!1),!this.optionsData.find((({type:t})=>"digital-code-value"===t)))throw new Error("product-options:: No digital card options found");this.getAvailableDigitalCardSKUs(s)}getSelectedDigitalCardOptions(t){const s=t.details.find((t=>t.is_selected)),i=t.details.find((t=>!!t.is_default))||t.details[0];if(["digital-code-value","country"].includes(t.type))return s||i}async componentWillLoad(){if(salla.url.is_page("cart")&&(this.disableCardValue=!1,this.fillSelectedOptions()),this.config)try{this.optionConfig="string"==typeof this.config?JSON.parse(this.config):this.config}catch(t){console.error("Failed to parse JSON in config prop:",t)}if(this.optionsData.filter((({type:t})=>["country","digital-card-value"].includes(t))).length>0&&salla.url.is_page("cart")){const t=this.optionsData.find((t=>"country"===t.type)),s=t&&this.getSelectedDigitalCardOptions(t);s&&this.getAvailableDigitalCardSKUs(s)}return this.outOfStockText=salla.lang.get("pages.products.out_of_stock"),this.computeAvailability(),await salla.onReady(),this.canDisabled=!salla.config.get("store.settings.product.notify_options_availability")||salla.url.is_page("cart"),this.pasteHandler=this.handlePaste.bind(this),document.addEventListener("paste",this.pasteHandler),!salla.storage.get("cart.id")&&this.optionsData.some((t=>["file","image"].includes(t.type)))?salla.api.cart.getCurrentCartId(!1,"salla-product-options"):null}disconnectedCallback(){this.pasteHandler&&document.removeEventListener("paste",this.pasteHandler)}handlePaste(t){const s=t.target;if(!(Salla.helpers.isAppleDevice()&&(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement)&&s.classList.contains("s-form-control")&&this.host.contains(s)))return;t.preventDefault();const i=t.clipboardData?.getData("text")||"",a=s.selectionStart,e=s.selectionEnd,o=s.value.slice(0,a)+i+s.value.slice(e);s.value=o,s.setSelectionRange(a+i.length,a+i.length);try{s.dispatchEvent(new window.Event("change",{bubbles:!0}))}catch(t){Salla.log("Error on change")}}hideDigitalCardsOptions(t){return this.disableCardValue&&t.type===d.DIGITAL_CARD_VALUE&&!salla.url.is_page("cart")}render(){if(0!==this.optionsData?.length)return i(a,{class:{"s-product-options-wrapper":!0,"s-product-options-no-padding":this.noPadding}},i("salla-conditional-fields",null,this.optionsData.map((t=>i("div",{key:t.id,class:"s-product-options-option-container"+(t.visibility_condition||this.hideDigitalCardsOptions(t)?" hidden":""),"data-option-id":t.id,...this.getOptionShownWhen(t)},"splitter"===t.name?this.splitterOption():i("div",{class:{"s-product-options-option":!0,"s-product-options-option-booking":t.type===d.BOOKING&&salla.url.is_page("cart")},"data-option-type":t.type,"data-option-required":`${t.required}`},i("label",{htmlFor:this.generateInputId(t.id),class:"s-product-options-option-label "+(this.hideLabel(t)?"s-product-options-option-label-hidden":"")},i("b",null,t.name,t.required&&i("span",null," * ")," "),i("small",null,t.placeholder)),i("div",{class:"s-product-options-option-content "+(this.hideLabel(t)||t.type===d.BOOKING&&salla.url.is_page("cart")?"s-product-options-option-content-full-width":"")},this.getDisplayForType(t))))))))}generateUniqueKey(t){const s=this.bundleContext;let i=this.uniqueKey?`${t}-${this.uniqueKey}`:t;if(s)try{const t="string"==typeof s?JSON.parse(s):s,{sectionId:a,productId:e}=t;i=`${i}-bundle-${a}-${e}`}catch(t){}return i}generateInputId(t){return this.generateUniqueKey(`option-${t}`)}generateInputName(t){const s=this.bundleContext,i=t.toString();if(s)try{const t="string"==typeof s?JSON.parse(s):s,{sectionId:a,productId:e}=t;return`bundle[${a}][${e}][options][${i}]`}catch(t){return`options[${i}]`}return`options[${i}]`}fillSelectedOptions(){this.selectedOptions=this.optionsData.reduce(((t,s)=>{const i=(s.details??[]).filter((t=>t.is_selected)).map((t=>({...t,option_id:s.id})));return t.concat(i)}),[])}async seedSelectedOptions(){this.fillSelectedOptions(),requestAnimationFrame((()=>{this.optionsData?.filter((t=>t.type===d.MULTIPLE_OPTIONS&&t.required)).forEach((t=>this.handleRequiredMultipleOptions(t)))}))}async componentDidLoad(){if(!this.optionsData?.length)return;await Salla.hooks.registerComponent("salla-product-options",this);const t=this.optionsData.find((t=>t.type===d.DONATION))?.details?.find((t=>t.is_selected));if(t&&setTimeout((()=>{salla.event.emit("product-options::donation-changed",{id:this.productId,price:t.additional_price})}),1e3),!salla.url.is_page("cart")&&!this.isCartMode){const t=[d.SINGLE_OPTION,d.MULTIPLE_OPTIONS,d.COLOR,d.THUMBNAIL,d.DONATION,d.DIGITAL_CARD_VALUE,d.COUNTRY];this.optionsData.some((s=>t.includes(s.type)&&s.details?.some((t=>t.is_selected))))&&requestAnimationFrame((()=>{try{const t=this.host.closest("form");if(!t)return;const s=new FormData(t),i=s.get("id")||s.get("product_id");if(i&&String(i)!==String(this.productId))return;salla.product.getPrice(s)}catch(t){salla.log("Error updating price for pre-selected options:",t)}}))}}async enterCartMode(){this.isCartMode=!0,this.disableCardValue=!1,this.canDisabled=!0,this.fillSelectedOptions(),this.computeAvailability()}async enableUserInitiatedValidation(){this.userInitiatedValidation=!0}async validateAndScroll(){return await this.enableUserInitiatedValidation(),this.reportValidity()}donationOption(t,s){return i("div",{class:"s-product-options-donation-wrapper"},t.donation?.can_donate?[t.donation?i("div",{key:t.id,class:"s-product-options-donation-progress"},i("salla-progress-bar",{donation:t.donation})):"",t.details.length?[i("h4",{key:t.id},this.selectAmount),i("div",{key:t.id,class:"s-product-options-donation-options"},t.details.map(((s,a)=>i("div",{key:t.id,class:"s-product-options-donation-options-item"},i("input",{id:this.generateUniqueKey(`donation-option-${a}`),type:"radio",name:"donating_option",checked:s.is_selected,value:s.additional_price,onChange:i=>this.handleDonationOptions(i,s,"option",t)}),i("label",{htmlFor:this.generateUniqueKey(`donation-option-${a}`)},i("span",{innerHTML:salla.money(s.name)}))))),t.donation?.custom_amount_enabled?i("div",{class:"s-product-options-donation-options-item"},i("input",{id:this.generateUniqueKey("donation-option-custom"),type:"radio",name:"donating_option",value:"custom",onChange:s=>this.handleDonationOptions(s,"custom","option",t)}),i("label",{htmlFor:this.generateUniqueKey("donation-option-custom")},i("span",null," ",this.selectDonationAmount," "))):"")]:"",i("div",{key:t.id,class:{"s-product-options-donation-input-group":!0,shown:!t.details.length||t.details.length&&this.isCustomDonation}},i("input",{type:"text",id:"donating-amount",name:"donation_amount",class:"s-form-control",ref:t=>{this.donationInput=t},value:t.details.length&&t.details.some((t=>t.is_selected))?t.details.find((t=>t.is_selected)).additional_price:t.value,placeholder:t.placeholder,onInput:s=>this.handleDonationOptions(s,"custom","input",t),onBlur:s=>this.changedHandler(s,t),onInvalid:s=>this.invalidHandler(s,t)}),i("span",{class:"s-product-options-donation-amount-currency"},salla.config.currency(salla.config.get("user.currency_code")).symbol))]:this.getExpireDonationMessage(t))}fileUploader(t,s=null){return i("salla-file-upload",{...s||{},"payload-name":"file",value:t.value,"instant-upload":!0,name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,height:"120px",onAdded:s=>{this.changedHandler(s,t,!(s.detail?.file?.origin===w.LOCAL))},url:salla.cart.api.getUploadImageEndpoint(),"form-data":{cart_item_id:this.productId,product_id:this.productId},onInvalidInput:s=>this.invalidHandler(s,t),class:{"s-product-options-image-input":!0,required:t.required}},i("div",{class:"s-product-options-filepond-placeholder"},i("span",{class:"s-product-options-filepond-placeholder-icon",innerHTML:s.accept?.split(",").every((t=>t.includes("image")))?p:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>file-upload</title>\n<path d="M21.333 24c0.341 0 0.683-0.131 0.943-0.391 0.521-0.521 0.521-1.364 0-1.885l-5.333-5.333c-0.123-0.123-0.271-0.22-0.433-0.288-0.327-0.135-0.693-0.135-1.019 0-0.163 0.068-0.311 0.165-0.433 0.288l-5.333 5.333c-0.521 0.521-0.521 1.364 0 1.885s1.364 0.521 1.885 0l3.057-3.057v10.115c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-10.115l3.057 3.057c0.26 0.26 0.601 0.391 0.943 0.391zM28.943 9.724l-9.333-9.333c-0.249-0.251-0.589-0.391-0.943-0.391h-12c-2.205 0-4 1.795-4 4v24c0 2.205 1.795 4 4 4h4c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333h-4c-0.735 0-1.333-0.599-1.333-1.333v-24c0-0.735 0.599-1.333 1.333-1.333h11.448l8.552 8.552v16.781c0 0.735-0.599 1.333-1.333 1.333h-4c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h4c2.205 0 4-1.795 4-4v-17.333c0-0.353-0.14-0.693-0.391-0.943z"></path>\n</svg>\n'}),i("p",{class:"s-product-options-filepond-placeholder-text"},salla.lang.get("common.uploader.drag_and_drop")),i("span",{class:"filepond--label-action"},salla.lang.get("common.uploader.browse"))))}imageOption(t){return this.fileUploader(t,{accept:"image/png,image/jpeg,image/jpg,image/gif"})}fileOption(t){const s=t.details.map((t=>this.fileTypes[t.name])).filter(Boolean);return s?.length?this.fileUploader(t,{accept:s.join(",")}):"File types not selected."}numberOption(t){return i("input",{type:"text",value:t.value,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onBlur:s=>this.changedHandler(s,t),onInvalid:s=>this.invalidHandler(s,t),onInput:t=>salla.helpers.inputDigitsOnly(t.target)})}splitterOption(){return i("div",{class:"s-product-options-splitter"})}textOption(t){return i("div",{class:"s-product-options-text"},i("input",{type:"text",value:t.value,maxLength:t?.length,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)}))}textareaOption(t){return i("div",{class:"s-product-options-textarea"},i("div",{class:"mt-1"},i("textarea",{rows:4,value:t.value,maxLength:t?.length,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)})))}mapOption(t){return i("salla-map",{zoom:15,lat:this.getLatLng(t.value,"lat"),lng:this.getLatLng(t.value,"lng"),name:this.generateInputName(t.id),searchable:!0,required:t.required,onInvalidInput:s=>this.invalidHandler(s,t),onSelected:s=>this.changedHandler(s,t)})}colorPickerOption(t){return i("salla-color-picker",{onSubmitted:s=>this.changedHandler(s,t),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,onInvalidInput:s=>this.invalidHandler(s,t),color:t.value})}timeOption(t){return i("salla-datetime-picker",{noCalendar:!0,enableTime:!0,dateFormat:"h:i K",value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,name:this.generateInputName(t.id),class:"s-product-options-time-element",onInvalidInput:s=>this.invalidHandler(s,t),onPicked:s=>this.changedHandler(s,t)})}dateOption(t){return i("div",{class:"s-product-options-date-element"},i("salla-datetime-picker",{value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,minDate:new Date,name:this.generateInputName(t.id),onInvalidInput:s=>this.invalidHandler(s,t),onPicked:s=>this.changedHandler(s,t)}))}datetimeOption(t){return i("div",{class:"s-product-options-datetime-element"},i("salla-datetime-picker",{enableTime:!0,value:t.value,dateFormat:"Y-m-d G:i:K",placeholder:t.name,required:!t.visibility_condition&&t.required,name:this.generateInputName(t.id),maxDate:t.to_date_time,minDate:t.from_date_time,onInvalidInput:s=>this.invalidHandler(s,t),onPicked:s=>this.changedHandler(s,t)}))}getOptionDetailName(t,s=!0,i,a){let e;if(i&&i===d.COLOR&&(e=t.name+(s&&this.isOptionDetailOut(t)&&!salla.url.is_page("cart")&&!this.hideOutLabel?` <br/> <p> ${this.outOfStockText} </p>`:"")+(t.additional_price?` <p> (${salla.money(t.additional_price,!1)}) </p>`:"")),!e){const i=(s&&this.isOptionDetailOut(t)&&!salla.url.is_page("cart")&&!this.hideOutLabel?` - ${this.outOfStockText}`:"")+(t.additional_price?` (${salla.money(t.additional_price,!1)})`:"");if("price"===a){const s=salla.helpers.digitsOnly(t.name),a=Number(s);return s&&Number.isFinite(a)?salla.money(a,!0)+i:i}e=t.name+i}return e.replace("<i class=sicon-sar></i>",salla.config.currency()?.symbol||"ر.س")}computeAvailability(){this.availabilityMap=function(t,s,i=!0){const a={};if(!t?.length)return a;const e=t.filter((t=>t.details?.some((t=>t.skus_availability&&Object.keys(t.skus_availability).length>0)))),o=e.length<=1,n=new Set(t.filter((t=>!1===t.is_advance)).map((t=>t.id)));if(0===e.length){for(const s of t)for(const t of s.details)a[t.id]=t.is_out?"out_of_stock":"available";return a}const l=e.some((t=>t.details?.some((t=>t.skus_availability&&Object.values(t.skus_availability).some(Boolean))))),r=i&&!l;for(const t of e){const i=s.filter((s=>s.option_id!==t.id));for(const s of t.details){const t=s.skus_availability;if(!t||!Object.keys(t).length){a[s.id]=s.is_out?"out_of_stock":"available";continue}const e=Object.keys(t).map(Number),l=e.some((s=>t[s]));if(o||0===i.length){a[s.id]=!l&&r||l?"available":"out_of_stock";continue}let c=e;for(const t of i){if(n.has(t.option_id))continue;const s=new Set(Object.keys(t.skus_availability||{}).map(Number));c=c.filter((t=>s.has(t)))}if(!c.length){a[s.id]=r?"available":"impossible";continue}const d=c.some((s=>t[s]));a[s.id]=!d&&r||d?"available":"out_of_stock"}}return a}(this.optionsData||[],this.selectedOptions||[],this.productAvailable)}isOptionDetailOut(t){const s=this.availabilityMap[t.id];return void 0!==s?"available"!==s:!!t.is_out}renderInput(t,s,a,e,o,n){const l=this.generateUniqueKey(`${t}-${a.id}-${s.id}`),r=this.isOptionDetailOut(s),c=this.getOptionDetailName(s,!0,a.type,a.format),d={"s-product-options-grid-mode-span":n,"s-product-options-disabled":this.canDisabled&&r};return i("label",{class:{"s-product-options-disabled":this.canDisabled&&r,"s-product-options-option-stock-out":r}},i("input",{id:l,type:t,name:o,value:s.id,disabled:this.canDisabled&&r,required:e,checked:s.is_selected,onInvalid:t=>this.invalidHandler(t,a),onChange:t=>this.changedHandler(t,a)}),"price"===a.format?i("div",{class:d,innerHTML:c}):i("div",{class:d},c))}renderOptionDetails(t,s,i,a=!1){const e=this.generateInputName(s.id),o="radio"===t?e:`${e}[]`;return s?.details.map((e=>this.renderInput(t,e,s,i,o,a)))}renderSelect(t){return i("div",null,i("select",{id:this.generateInputId(t.id),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,class:"s-form-control",onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)},i("option",{value:""},t.placeholder),t?.details.map((t=>i("option",{key:t.id,value:t.id,disabled:this.canDisabled&&this.isOptionDetailOut(t),selected:t.is_selected},this.getOptionDetailName(t))))))}renderButtonStyle(t,s,a){return i("div",{class:"s-product-options-grid-mode"},this.renderOptionDetails(t,s,a,!0))}singleOption(t){return"button"===this.optionConfig?.["single-option"]?.type||t.type===d.SINGLE_OPTION&&"price"===t.format?this.renderButtonStyle("radio",t,!t.visibility_condition&&t.required):this.renderSelect(t)}multipleOptions(t){const s="button"===this.optionConfig?.["multiple-option"]?.type,a=t.required&&!t.details.some((t=>t.is_selected))&&!t.visibility_condition;return s?this.renderButtonStyle("checkbox",t,a):i("div",{class:{"s-product-options-multiple-options-wrapper":!0,required:t.required}},this.renderOptionDetails("checkbox",t,a))}radioOption(t){return this.singleOption(t)}colorOption(t){return i("fieldset",{class:"s-product-options-colors-wrapper"},t?.details.map((s=>{const a=this.isOptionDetailOut(s);return i("div",{class:{"s-product-options-colors-item":!0,"s-product-options-option-stock-out":a},key:s.id},i("input",{type:"radio",value:s.id,required:!t.visibility_condition&&t.required,checked:s.is_selected,name:this.generateInputName(t.id),disabled:this.canDisabled&&a,id:this.generateUniqueKey(`color-${this.productId}-${t.id}-${s.id}`),onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t),"data-img-id":s.option_value}),i("label",{htmlFor:this.generateUniqueKey(`color-${this.productId}-${t.id}-${s.id}`),"data-img-id":s.option_value},i("span",{style:{backgroundColor:s.color}}),i("div",{innerHTML:this.getOptionDetailName(s,!0,t.type)})))})))}thumbnailOption(t){return i("div",{class:"s-product-options-thumbnails-wrapper"},t.details.map((s=>{const a=this.isOptionDetailOut(s);return i("div",{key:s.id,class:{"s-product-options-option-stock-out":a}},i("input",{type:"radio",value:s.id,"data-itemid":s.id,required:!t.visibility_condition&&t.required,checked:s.is_selected,name:this.generateInputName(t.id),"data-img-id":s.option_value,disabled:this.canDisabled&&a,id:this.generateUniqueKey(`option_${this.productId}-${t.id}_${s.id}`),onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)}),i("label",{htmlFor:this.generateUniqueKey(`option_${this.productId}-${t.id}_${s.id}`),"data-img-id":s.option_value,class:"go-to-slide"},i("img",{"data-src":s.image,src:s.image,title:s.name,alt:s.name}),i("span",{innerHTML:h,class:"s-product-options-thumbnails-icon"}),a?[i("small",{key:`badge-${s.id}`,class:"s-product-options-thumbnails-stock-badge"},this.outOfStockText),this.canDisabled?i("div",{key:`overlay-${s.id}`,class:"s-product-options-thumbnails-badge-overlay"}):""]:""),i("p",null,this.getOptionDetailName(s,!1)," "))})))}digitalCardValuesOption(t){return i("div",{class:"s-product-options-digital-card-wrapper"},this.availableDigitalCardValues.length>0?this.availableDigitalCardValues.map((s=>{const a=String(s.id);return i("label",{htmlFor:this.generateUniqueKey(a.toString()),key:a,class:"s-product-options-digital-card-option"},i("input",{type:"radio","data-code-value":!0,class:"s-form-control s-product-options-digital-card-input",value:s.id,name:this.generateInputName(t.id),id:this.generateUniqueKey(a.toString()),required:!t.visibility_condition&&t.required,onInvalid:s=>this.invalidHandler(s,t),...this.ignoreDefaultCardValue?{}:{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===s.id}}),i("span",null,s.name," ",salla.config?.currency()?.symbol))})):i("div",{class:"s-product-options-digital-card-out-of-stock"}))}countryOption(t){return i("div",{class:"s-product-options-digital-card-wrapper"},t.details.map((s=>{const a=this.isOptionDetailOut(s);return i("label",{htmlFor:this.generateUniqueKey(s.id.toString()),key:s.id,class:{"s-product-options-digital-card-option":!0,"s-product-options-digital-card-option-stock-out":a,"s-product-options-option-stock-out":a}},i("input",{id:this.generateUniqueKey(s.id.toString()),type:"radio",class:"s-form-control s-product-options-digital-card-input",value:s.id,name:this.generateInputName(t.id),disabled:this.canDisabled&&a,required:!t.visibility_condition&&t.required,onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t),onClick:()=>{this.disableCardValue=!1},...salla.url.is_page("cart")?{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===s.id}:{}}),i("img",{loading:"lazy",alt:s.code,height:24,width:24,class:"s-product-options-country-flag",src:`https://cdn.assets.salla.network/prod/admin/cp/assets/flags/1x1/${String(s.code).toLocaleLowerCase()}.svg`,onError:t=>{t.currentTarget.onerror=null,t.currentTarget.src=salla.url.cdn("images/globe.svg")}}),i("span",null,s.name))})))}get host(){return e(this)}};function k(){o.defaults.headers.common.currency=salla?.config?.get?.("user.currency_code")}v.style="";var _={request:(t,s,i,a=null,e=null)=>(k(),o.request({url:s,data:i,method:t.toLowerCase(),responseType:"json"}).then(a).catch(e)),get:(t,s=null,i=null,a)=>(k(),o.get(t,{params:a}).then(s).catch(i)),post(t,s,i=null,a=null){return this.request("post",t,s,i,a)},put(t,s,i=null,a=null){return this.request("put",t,s,i,a)},delete(t,s,i=null,a=null){return this.request("delete",t,s,i,a)},requestWithSupportAjax(t,s,i="post"){return new Promise(((a,e)=>{if(!window?.isLegacyTheme)return this.request(i,t,s,(({data:t})=>a(t)),(({response:t})=>e(t)));k(),$.ajax({url:t,method:i.toUpperCase(),data:s,headers:{currency:o.defaults.headers.common.currency},async:!1,success:function({data:t}){return a(t)},error:function({response:t}){return e(t)}})}))}},S={options:[],header:"undefined"!=typeof navigator&&"undefined"!=typeof window?[navigator.platform,navigator.userAgent,navigator.appVersion,navigator.vendor,window.opera]:[],dataos:[{name:"Windows Phone",value:"Windows Phone",version:"OS"},{name:"Windows",value:"Win",version:"NT"},{name:"iPhone",value:"iPhone",version:"OS"},{name:"iPad",value:"iPad",version:"OS"},{name:"Kindle",value:"Silk",version:"Silk"},{name:"Android",value:"Android",version:"Android"},{name:"PlayBook",value:"PlayBook",version:"OS"},{name:"BlackBerry",value:"BlackBerry",version:"/"},{name:"Macintosh",value:"Mac",version:"OS X"},{name:"Linux",value:"Linux",version:"rv"},{name:"Palm",value:"Palm",version:"PalmOS"}],databrowser:[{name:"Chrome",value:"Chrome",version:"Chrome"},{name:"Firefox",value:"Firefox",version:"Firefox"},{name:"Safari",value:"Safari",version:"Version"},{name:"Internet Explorer",value:"MSIE",version:"MSIE"},{name:"Opera",value:"Opera",version:"Opera"},{name:"BlackBerry",value:"CLDC",version:"CLDC"},{name:"Mozilla",value:"Mozilla",version:"Mozilla"}],init:function(){var t=this.header.join(" ");return{os:this.matchItem(t,this.dataos),browser:this.matchItem(t,this.databrowser)}},matchItem:function(t,s){var i,a,e,o=0,n=0;for(o=0;o<s.length;o+=1)if(new RegExp(s[o].value,"i").test(t)){if(i=new RegExp(s[o].version+"[- /:;]([\\d._]+)","i"),e="",(a=t.match(i))&&a[1]&&(a=a[1]),a)for(a=a.split(/[._]+/),n=0;n<a.length;n+=1)e+=0===n?a[n]+".":a[n];else e="0";return{name:s[o].name,version:parseFloat(e)}}return{name:"unknown",version:0}}};async function C(t,s,i=!1){if(salla.logger.log("🍏 Pay: mutateShippingContact called",s,i),t.detail.requiredShippingContactFields&&0!=t.detail.requiredShippingContactFields.length)if(i){if(salla.config.isGuest()&&salla.config.get("store.features").includes("guest-checkout")){if(!(s.emailAddress&&s.givenName&&s.familyName&&s.phoneNumber)){salla.logger.warn("🍏 Pay: Guest contact fields are required",s);const i=[];return s.emailAddress||i.push(new window.ApplePayError("shippingContactInvalid","emailAddress","Email address is required")),s.phoneNumber||i.push(new window.ApplePayError("shippingContactInvalid","phoneNumber","Phone number is required")),s.givenName&&s.familyName||i.push(new window.ApplePayError("shippingContactInvalid","name","Name is required")),void t.session.completePayment({status:t.session.STATUS_INVALID_SHIPPING_CONTACT,errors:i})}await async function(t,s){return salla.logger.log("🍏 Pay: Updating guest contact",s),new Promise(((i,a)=>{_.post(t.detail.guestContactSelected.url.replace("{id}",t.id),{email:s.emailAddress||null,first_name:s.givenName||null,last_name:s.familyName||null,phone_number:s.phoneNumber||null,country_code:s.countryCode||null},(async({data:s})=>{"function"==typeof t.detail.guestContactSelected?.onSuccess&&t.detail.guestContactSelected.onSuccess(s),i(s)}),(({response:s})=>{salla.logger.warn("🍏 Pay: Failed to update guest contact via api",s),"function"==typeof t.detail.guestContactSelected?.onFailed&&t.detail.guestContactSelected.onFailed(s),a({response:s})}))}))}(t,s)}}else if(t.detail.requiredShippingContactFields.includes("postalAddress"))return _.post(t.detail.shippingContactSelected.url.replace("{id}",t.id),{country:s.country,city:s.locality,local:s.subLocality||s.administrativeArea||s.locality,description:s.subAdministrativeArea,street:s.addressLines?.join(", ")||s.administrativeArea,country_code:s.countryCode,postal_code:s.postalCode},(async({data:s})=>{if("function"==typeof t.detail.shippingContactSelected.onSuccess&&t.detail.shippingContactSelected.onSuccess(s),t.address_id=s.data.address_id,t.shipping_methods=s.data.shipping_methods,!t.shipping_methods||t.shipping_methods&&!t.shipping_methods.length)return salla.logger.warn("🍏 Pay: We dont found any supported methods",s),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]});try{await t.selectApplePayShippingMethod(t.shipping_methods[0])}catch(s){return salla.logger.warn("Failed set the shipping details to api",s),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}try{await t.recalculateTotal()}catch(s){return salla.logger.warn("🍏 Pay: Failed recalculate total",s),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}const i={newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),newShippingMethods:t.mappingShippingMethods(t.shipping_methods)};salla.logger.log("🍏 Pay: completeShippingContactSelection",i),t.session.completeShippingContactSelection(i)}),(({response:s})=>{salla.logger.warn("🍏 Pay: Failed add address via api",s),"function"==typeof t.detail.shippingContactSelected.onFailed&&t.detail.shippingContactSelected.onFailed(s);let i=s?.data?.error?.fields,a=function(t){return Object.entries(t).filter((([t,s])=>s&&s.length>0)).map((([t,s])=>new window.ApplePayError("shippingContactInvalid",t,s[0])))}({countryCode:i?.country_code&&i.country_code.length>0?i.country_code[0]:null,locality:i?.city&&i.city.length>0?i.city[0]:null,country:i?.country&&i.country.length>0?i.country[0]:null});0===a.length&&s?.data?.error?.message&&a.push(new window.ApplePayError("shippingContactInvalid","locality",s?.data?.error?.message)),t.session.completeShippingContactSelection({newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:a})}))}"undefined"!=typeof window&&(window.Salla=window.Salla||{},window.Salla.Payments=window.Salla.Payments||{});const P="undefined"!=typeof window?{session:null,detail:null,address_id:null,shipping_methods:[],total:void 0,request:void 0,id:void 0,countryCode:null,totals:[],shippingCompany:null,init:function(){document.removeEventListener("payments::apple-pay.start-transaction",P.startSession),Salla.event.addEventListener("payments::apple-pay.start-transaction",P.startSession)},initDefault:function(){P.detail.onError||(P.detail.onError=function(t){salla.notify.error(t)}),P.detail.authorized.onFailed||(P.detail.authorized.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse(t),P.onCancel({},t.data.error.message)}),P.detail.validateMerchant.onFailed||(P.detail.validateMerchant.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse({response:t}),P.onCancel({},t.data.error.message)}),P.detail.authorized.onSuccess||(P.detail.authorized.onSuccess=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleAfterResponseActions(t)})},prepareLineItems:function(){return P.detail?.items?.length||(P.detail.items=[{label:salla.lang.get("pages.cart.items_total"),amount:parseFloat(P.detail.amount).toString()}]),P.detail.items},prepareTotal:function(){return{label:window.location.hostname||"Salla",amount:parseFloat(P.detail.amount).toString()}},isPhysical:()=>P.detail?.requiredShippingContactFields?.includes("postalAddress"),startSession:async function(t){P.detail=t.detail||t,salla.log("🍏 Pay: payments::apple-pay.start-transaction",P.detail),P.initDefault();let s,i=P.getApplePaySessionVersion(),a=P.detail.supportedNetworks,e=Array.isArray(a)?[...a]:Object.values(a||{});e.length||(e=["masterCard","visa"]),5!==i||e.includes("mada")||e.push("mada"),P.request={countryCode:P.detail.countryCode||"SA",supportsCouponCode:!0,couponCode:"",currencyCode:P.detail.currency||"SAR",requiredShippingContactFields:P.detail.requiredShippingContactFields?P.detail.requiredShippingContactFields:[],merchantCapabilities:["supports3DS"],supportedNetworks:e,supportedCountries:P.detail.supportedCountries||["SA"],total:P.prepareTotal(),shippingContact:P.detail.shippingContact?P.detail.shippingContact:{},shippingMethods:P.detail.shippingMethods&&P.detail.shippingMethods.length?P.mappingShippingMethods(t.detail.shippingMethods):[],lineItems:P.prepareLineItems()},salla.log("🍏 Pay: init ",P.request),P.session=new ApplePaySession(i,P.request),P.session.onshippingcontactselected=P.onShippingContactSelected,P.session.onshippingmethodselected=P.onShippingMethodSelected,P.session.onvalidatemerchant=P.onValidateMerchant,P.session.onpaymentauthorized=P.onPaymentAuthorized,P.session.oncancel=P.onCancel,P.session.oncouponcodechanged=P.onCouponCodeChanged,P.session.onpaymentmethodselected=P.onPaymentMethodSelected,"function"==typeof P.detail.onStartedSession&&(s=P.detail.onStartedSession(P.session)),s||P.session.begin()},onPaymentMethodSelected:async t=>{if(salla.logger.log("🍏 Pay: onPaymentMethodSelected",t),P.isPhysical())salla.logger.log("🍏 Pay: completePaymentMethodSelection",{newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()}),P.session.completePaymentMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()});else try{await P.recalculateTotal();const t={newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()};salla.logger.log("🍏 Pay: completePaymentMethodSelection",t),P.session.completePaymentMethodSelection(t)}catch(t){salla.logger.warn("🍏 Pay: Failed recalculate total",t),P.session.completePaymentMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems(),status:P.session.STATUS_FAILURE,errors:[new window.ApplePayError("unknown",void 0,t?.response?.data?.error?.message||t?.response?.data?.error?.code||"Failed to recalculate total")]})}},onCouponCodeChanged:t=>(Salla.event.dispatch("payments::apple-pay.coupon.change",t),_.post(P.detail.onCouponCodeChanged.url.replace("{id}",P.id),{coupon:t.couponCode,payment_method:"apple_pay"},(async({data:t})=>{"function"==typeof P.detail.onCouponCodeChanged.onSuccess&&P.detail.onCouponCodeChanged.onSuccess(t),salla.log("🍏 Pay: Coupon applied success"),await P.recalculateTotal(),P.session.completeCouponCodeChange({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()})}),(async t=>{let s=t?.response;Salla.event.dispatch("payments::apple-pay.coupon.failed",s),"function"==typeof P.detail.onCouponCodeChanged.onFailed&&P.detail.onCouponCodeChanged.onFailed(s),await P.recalculateTotal(),P.session.completeCouponCodeChange({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems(),errors:[new window.ApplePayError("couponCodeInvalid")]})}))),onCancel:(t={},s=null)=>{P.detail.onError(s||salla.lang.get("pages.checkout.payment_failed")),Salla.event.createAndDispatch("payments::apple-pay.canceled",t)},onPaymentAuthorized:async t=>{salla.logger.log("🍏 Pay: onPaymentAuthorized",t.payment);try{await C(P,t.payment.shippingContact,!0)}catch(t){salla.logger.error("🍏 Pay: Failed to update guest contact details",t);const s=t?.response||t,i=s?.data?.error?.fields||{},a=[];return i?.email&&i.email.length>0&&a.push(new window.ApplePayError("shippingContactInvalid","emailAddress",i.email[0])),i?.phone&&i.phone.length>0&&a.push(new window.ApplePayError("shippingContactInvalid","phoneNumber",i.phone[0])),i?.first_name&&i.first_name.length>0?a.push(new window.ApplePayError("shippingContactInvalid","name",i.first_name[0])):i?.last_name&&i.last_name.length>0&&a.push(new window.ApplePayError("shippingContactInvalid","name",i.last_name[0])),0===a.length&&a.push(new window.ApplePayError("shippingContactInvalid","name",s?.data?.error?.message||s?.data?.error?.code||"Invalid shipping contact details")),Salla.event.dispatch("payments::apple-pay.authorized.failed",s),"function"==typeof P.detail.authorized.onFailed&&P.detail.authorized.onFailed(s),void P.session.completePayment({status:ApplePaySession.STATUS_INVALID_SHIPPING_CONTACT,errors:a})}Salla.event.dispatch("payments::apple-pay.authorized.init",t),_.post(P.detail.authorized.url.replace("{id}",P.id),{payment_method:"apple_pay",applepay_token:JSON.stringify(t.payment)},(({data:t})=>{Salla.event.dispatch("payments::apple-pay.authorized.success",t),"function"==typeof P.detail.authorized.onSuccess&&P.detail.authorized.onSuccess(t),P.session.completePayment(ApplePaySession.STATUS_SUCCESS)}),(t=>{let s=t?.response;Salla.event.dispatch("payments::apple-pay.authorized.failed",s),"function"==typeof P.detail.authorized.onFailed&&P.detail.authorized.onFailed(s),P.session.completePayment({status:ApplePaySession.STATUS_FAILURE,errors:[new window.ApplePayError("unknown",void 0,s?.data?.error?.message||s?.data?.error?.code||"Failed to parse authorized response")]})}))},onValidateMerchant:async t=>{try{Salla.event.dispatch("payments::apple-pay.validate-merchant.init",t);const{data:s}=await _.post(P.detail.validateMerchant.url.replace("{id}",P.id),{validation_url:t.validationURL});Salla.event.dispatch("payments::apple-pay.validate-merchant.success",s);const i=t=>{P.session.completeMerchantValidation(t)};if("function"==typeof P.detail.validateMerchant.onSuccess){const t=await P.detail.validateMerchant.onSuccess(s);if(t?.redirect)return window.location=t.redirect,P.abortValidateMerchant(t)}i(s.data)}catch(t){console.error(t),P.abortValidateMerchant(t?.response)}},abortValidateMerchant:(t=null)=>{P.abortSession(),Salla.event.dispatch("payments::apple-pay.validate-merchant.failed",t),"function"==typeof P.detail.validateMerchant.onFailed&&P.detail.validateMerchant.onFailed(t)},onShippingContactSelected:async t=>{salla.logger.log("🍏 Pay: onShippingContactSelected",t.shippingContact),await C(P,t.shippingContact)},onShippingMethodSelected:async t=>{let s=t.shippingMethod.identifier.split(","),i={ship_id:s[0],private_ship_id:void 0===s[1]?null:s[1],type:void 0===s[2]?null:s[2],route_id:void 0===s[3]?null:s[3]};if(salla.logger.log("🍏 Pay: onShippingMethodSelected",{event:t,previous:P.shippingCompany,current:i}),P.shouldUpdateShippingCompany(i))try{await P.selectApplePayShippingMethod(i),await P.recalculateTotal()}catch(t){return salla.logger.warn("🍏 Pay: Failed set the shipping details to api",t),void P.session.completeShippingMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems(),status:P.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}salla.logger.log("🍏 Pay: completeShippingMethodSelection",{newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()}),P.session.completeShippingMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()})},abortSession:()=>{P.session&&P.session.abort()},shouldUpdateShippingCompany:t=>P.shippingCompany?.ship_id!=t?.ship_id||P.shippingCompany?.private_ship_id!=t?.private_ship_id,getApplePaySessionVersion:()=>{if("sallapp"===(navigator.userAgent||navigator.vendor||window.opera))return 5;let t=S.init(),s=parseFloat(t.os.version);if("Macintosh"===t.os.name){if(s<10.142)return 1}else if(s<12.11)return 1;return 5},recalculateTotal:()=>(salla.logger.log("🍏 Pay: recalculate total"),_.get(P.detail.recalculateTotal.url.replace("{id}",P.id),(({data:t})=>{salla.logger.log("🍏 Pay: recalculate total success",t);let s=t.data.initial_data?.cart||t.data.cart,i=t.data.initial_data?.payments||t.data.payments;salla.logger.log("🍏 Pay: recalculate total success",{cart:s,payments:i}),null!=i?.gateways?.applePay?.amount?(P.detail.amount=i.gateways.applePay.amount,P.detail.currency=i.gateways.applePay.currency??P.detail.currency):P.detail.amount=i?.gateways?.applePay?.supportedMultiCurrency?s.total_in_customer_currency:s.total,P.detail.items=(s.totals||s.items).map((t=>({label:t.title,amount:"مجاني"===t.amount||"Free"===t.amount?0:t.amount.toString().replace("+","")}))),P.detail.items.pop(),P.totals=P.detail.items}),(t=>(salla.logger.warn("🍏 Pay: recalculate total failed",t),t?.response?.data?.message)))),selectApplePayShippingMethod:t=>{salla.logger.log("🍏 Pay: select shipping method ",t),P.shippingCompany=t;const s={address_id:P.address_id,company_id:t.ship_id,private_company_id:t.private_ship_id,type:t.type||void 0,route_id:t.route_id||void 0,payment_method:"apple_pay"};return _.post(P.detail.shippingMethodSelected.url.replace("{id}",P.id),s,(({data:t})=>("function"==typeof P.detail.shippingMethodSelected.onSuccess&&P.detail.shippingMethodSelected.onSuccess(t),!0)),(t=>{salla.logger.warn("🍏 Pay: Set shipping method failed",t),"function"==typeof P.detail.shippingMethodSelected.onFailed&&P.detail.shippingMethodSelected.onFailed(t);let s=t?.response?.data?.error;return s?.data?.fields?.address_id?s?.data?.fields?.address_id[0]:s?.data?.message}))},mappingShippingMethods:t=>t.map((t=>({label:t.shipping_title,amount:t.enable_free_shipping?0:t.ship_cost,detail:"",identifier:t.ship_id.toString()+(t.private_ship_id?","+t.private_ship_id.toString():"")+(t.type?","+t.type:"")+(t.route_id?","+t.route_id:"")})))}:{};"undefined"!=typeof window&&(window.SallaApplePay=P),"undefined"!=typeof window&&window.ApplePaySession?.canMakePayments()?P.init():"undefined"!=typeof document&&document.querySelectorAll("data-show-if-apple-pay-supported").forEach((t=>t.style.display="none"));const O=class{constructor(i){t(this,i),this.validationFailed=s(this,"validationFailed"),this.requireLogin=s(this,"requireLogin"),this.type="buy",this.productType="product",this.options={},this.collectedOrderOptions=[],this.optionsResolved=!1,this.applePayAmount=0,this.pendingApplePaySession=null,this.quickBuy=salla.lang.get("pages.products.buy_now"),this.handleApplePaySessionStarted=t=>!!salla.config.get("store.settings.order_options.mandatory",!1)&&!this.optionsResolved&&(this.optionsResolved=!0,this.pendingApplePaySession=t,async function(t){let s;try{s=await salla.api.withoutNotifier((()=>salla.product.api.getOrderOptions([{id:t.productId,quantity:t.quantity}])))}catch(s){return salla?.logger?.warn?.("order-options: fetch failed",s),void t.beginPendingSession()}const i=s?.data?.order_options||[];if(!i.length)return void t.beginPendingSession();t.discardPendingSession();const a=Number(t.amount)>0?Number(t.amount):Number(s?.data?.products?.[0]?.price?.amount)||0,e=function(){let t=document.querySelector("salla-order-options-modal");return t||(t=document.createElement("salla-order-options-modal"),document.body.appendChild(t)),t}();try{await e.open({orderOptions:i,basePrice:a,paymentMode:"apple-pay",onSubmit:t.onSubmit})}catch{}}({productId:this.productId,amount:Number(this.amount),quantity:this.getSelectedQuantity(),beginPendingSession:()=>{this.pendingApplePaySession?.begin(),this.pendingApplePaySession=null},discardPendingSession:()=>{this.pendingApplePaySession=null},onSubmit:(t,s)=>{this.collectedOrderOptions=t,this.applePayAmount=s,this.settlePayment()}}),!0),salla.lang.onLoaded((()=>{this.quickBuy=salla.lang.get("pages.products.buy_now")}))}quickBuyHandler(){if(salla.config.isGuest()&&!this.isGuestCheckout())return this.requireLogin.emit({productId:this.productId}),void salla.api.auth.requireLoginThen("salla-quick-buy::user.logged-in",(()=>this.quickBuyHandler()));this.validatePdpOptionsSync()&&(this.optionsResolved=!1,this.collectedOrderOptions=[],this.applePayAmount=0,this.settlePayment())}validatePdpOptionsSync(){return!!function(t){const s=document.querySelector(`salla-product-options[product-id="${t}"]`);if(!s)return!0;const i=s.querySelectorAll("[required]");let a=!0;return i.forEach((t=>{t.disabled||t.closest(".hidden")||"reportValidity"in t&&!t.reportValidity()&&(a=!1)})),a}(this.productId)||(this.validationFailed.emit({productId:this.productId}),salla.error(salla.lang.get("common.messages.required_fields")),!1)}getSelectedQuantity(){try{const t=this.host.getElementSallaData?.(),s=Number(t instanceof FormData?t.get("quantity"):t?.quantity);return Number.isFinite(s)&&s>0?s:1}catch{return 1}}async settlePayment(){let t=this.host.getElementSallaData();if(function(t,s){s.length&&(t&&"function"==typeof t.append?s.forEach(((s,i)=>{t.append(`order_options[${i}][id]`,String(s.id)),t.append(`order_options[${i}][value]`,String(s.value))})):t&&"object"==typeof t&&(t.order_options=s))}(t,this.collectedOrderOptions),!this.isApplePayActive)return salla.api.request("checkout/quick-purchase/"+this.productId,t,"post").then((t=>(t.data.redirect&&(window.location.href=t.data.redirect),t)));t.is_applepay=!0,"append"in t&&t.append("is_applepay",!0),salla.event.dispatch("payments::apple-pay.start-transaction",{amount:this.applePayAmount>0?this.applePayAmount:this.amount,currency:this.currency||salla.config.get("store.settings.buy_now.currency")||"SAR",requiredShippingContactFields:this.getRequiredShippingContactFields(),shippingMethods:this.isRequireShipping?[]:void 0,supportedNetworks:this.isLegacyBuyNowBE()?salla.config.get("store.settings.buy_now.networks"):Array.isArray(this.supportedNetworks)&&this.supportedNetworks.length?this.supportedNetworks:salla.config.get("store.settings.buy_now.supportedNetworks"),supportedCountries:this.isLegacyBuyNowBE()?salla.config.get("store.settings.buy_now.countries"):Array.isArray(this.supportedCountries)&&this.supportedCountries.length?this.supportedCountries:salla.config.get("store.settings.buy_now.supportedCountries"),countryCode:salla.config.get("store.store_country")||"SA",onStartedSession:this.handleApplePaySessionStarted,validateMerchant:{url:this.validateHost?`${this.validateHost}/checkout/applepay/validate`:salla.url.get("checkout/applepay/validate"),onSuccess:s=>this.applePayOnly&&!this.productId?this.cartId?(window.SallaApplePay.id=this.cartId,salla.log("🍏 Pay: create checkout success: with id #"+this.cartId),Promise.resolve(s)):(salla.logger.warn("🍏 Pay: trying to create applePay transaction without cartId/ProductId !"),Promise.resolve(s)):salla.api.request("checkout/quick-purchase/"+this.productId,"object"==typeof t?t:void 0,"post",{}).then((t=>t?.data?.redirect?(salla.log("🍏 Pay: create checkout success: redirect exits, go to checkout page"),window.location.href=t.data.redirect.url,t):t?.data?.id?(window.SallaApplePay.id=t.data.id,void salla.log("🍏 Pay: create checkout success: with id #"+window.SallaApplePay.id)):(salla.logger.warn("🍏 Pay: create checkout success: No id, or redirect"),t)))},authorized:{url:salla.url.get("checkout/{id}/payments/submit"),onFailed:t=>{window.SallaApplePay.onCancel({},t?.data?.error?.message||t?.data?.error?.code||salla.lang.get("pages.checkout.payment_failed"))},onSuccess:t=>{window.location.href=t.redirect.url,salla.log("🍏 Pay: authorized Success:: redirect to thank you page, order placed")}},shippingMethodSelected:this.isRequireShipping?{url:salla.url.get("checkout/{id}/shipping/details")}:void 0,shippingContactSelected:this.isRequireShipping?{url:salla.url.get("checkout/{id}/address/add")}:void 0,guestContactSelected:this.isGuestCheckout()?{url:salla.url.get("checkout/{id}/customer")}:void 0,onCouponCodeChanged:{url:salla.url.get("checkout/{id}/coupons")},recalculateTotal:{url:salla.url.get("checkout/{id}/payments/recalculate?payment_method=apple_pay")},onError:function(t){salla.log(t),salla.notify.error(t)}})}isGuestCheckout(){return salla.config.isGuest()&&salla.config.get("store.features").includes("guest-checkout")&&this.isPhysicalProduct()}getRequiredShippingContactFields(){let t=[];return this.isRequireShipping&&t.push("postalAddress"),this.isGuestCheckout()&&t.push("email","phone","name"),t}isLegacyBuyNowBE(){return null!=salla?.config?.get?.("store.settings.buy_now.multi_currency")}applyBaseCurrencyPrice(t){if(this.isLegacyBuyNowBE())return void(null!=t?.price&&(this.amount=t.price));const s=t?.base_currency_price;null!=s?.amount?(this.amount=s.amount,s?.currency&&(this.currency=s.currency)):null!=t?.price&&(this.amount=t.price,this.currency=salla.config.get("user.currency_code")||this.currency||"SAR")}componentWillLoad(){console.log("🍏 Pay: Quick Buy Component Loaded");const t="undefined"!=typeof window&&!!window.ApplePaySession?.canMakePayments?.(),s=salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??!0,i=salla?.config?.get?.("store.settings.is_salla_gateway",!1)??!0;this.isApplePayActive=t&&s&&i;const a=async()=>{if(this.isLegacyBuyNowBE()&&!this.currency&&salla?.config?.get&&(this.currency=salla.config.get("store.settings.buy_now.multi_currency")?salla.config.get("user.currency_code"):salla.config.get("store.settings.buy_now.currency")||"SAR"),!this.productId&&salla?.config?.get&&salla.url?.is_page&&(this.productId=salla.config.get("page.id")),this.applePayOnly||this.productId){if(this.amount&&this.isRequireShipping||!this.productId||!salla?.product?.getDetails||await salla.product.getDetails(this.productId,[]).then((t=>{this.applyBaseCurrencyPrice(t?.data),this.isRequireShipping=t?.data?.is_require_shipping||!1})).catch((t=>{salla?.logger?.warn?.("🍏 Pay: Failed load the quick buy, get the product details failed: ",t)})),"donate"===this.type&&salla?.event?.on?salla.event.on("product-options::donation-changed",(t=>{String(t.id)===String(this.productId)&&this.applyBaseCurrencyPrice(t)})):salla?.url?.is_page?.("product.single")&&salla?.product?.event?.onPriceUpdated&&salla.product.event.onPriceUpdated((t=>{this.applyBaseCurrencyPrice(t?.data)})),this.isApplePayActive=(salla?.helpers?.hasApplePay?.()??t)&&(salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??s)&&(salla?.config?.get?.("store.settings.is_salla_gateway",!1)??i),!document.getElementById("apple-pay-sdk")&&this.isApplePayActive){const t=document.createElement("script");t.src="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",t.setAttribute("id","apple-pay-sdk"),t.async=!0,document.body.appendChild(t)}}else salla?.logger?.warn?.("🍏 Pay: Failed load the quick buy, the product id is missing")};return new Promise((t=>{"function"==typeof salla?.onReady?salla.onReady((()=>a().then((()=>t(!0))))):a().then((()=>t(!0)))}))}render(){return i(a,{key:"c2ba63eb4fad49f80977d6f1adc836f655524933"},this.quickBuyButton())}quickBuyButton(){return i("apple-pay-button",{locale:salla?.config?.get?.("user.language_code")||"ar",onClick:()=>this.quickBuyHandler(),"data-quick-purchase":"applepay",class:"s-quick-buy-apple-pay","data-is-applepay":"1",buttonstyle:"black",type:this.type})}isPhysicalProduct(){return"product"===this.productType||"group_products"===this.productType||"food"===this.productType}get host(){return e(this)}};O.style=".s-quick-buy-button .s-button-text{display:flex}apple-pay-button{--apple-pay-button-width:100%;--apple-pay-button-height:40px;--apple-pay-button-border-radius:.75rem;--apple-pay-button-box-sizing:content-box}";export{m as salla_add_product_button,y as salla_bought_together,g as salla_product_availability,v as salla_product_options,O as salla_quick_buy}
4
+ import{r as t,c as s,h as i,H as a,a as e,e as o}from"./p-Dm54yhRt.js";import{P as n}from"./p-DY4LZmNP.js";import{H as l}from"./p-XnA1YTjA.js";import{a as r}from"./p-CL7OPpYS.js";import{B as c}from"./p-D3mWkc-3.js";import{D as d}from"./p-CoQJOPRz.js";import{S as h}from"./p-BZp0rKEO.js";import{C as p}from"./p-C6jIkM-X.js";import"./p-CgtvEd63.js";class u{constructor(t,s){this.host=t,this.productId=s,this.collected=!1,this.livePrice=0}static attach(t,s){const i=t.querySelector("salla-mini-checkout-widget");if(!i)return!1;const a=new u(t,String(s));return salla.product?.event?.onPriceUpdated?.((t=>{a.livePrice=Number(t?.data?.price)||a.livePrice})),i.addEventListener("click",(t=>a.handleWidgetClick(t,i)),!0),!0}getSelectedQuantity(){try{const t=document.querySelector("form.product-form"),s=t?.getElementSallaData?.(),i=Number(s instanceof FormData?s.get("quantity"):s?.quantity);if(Number.isFinite(i)&&i>0)return i}catch{}return Number(this.host.getAttribute("quantity"))||1}async handleWidgetClick(t,s){if(this.collected)return void(this.collected=!1);if(t.preventDefault(),t.stopImmediatePropagation(),!await this.validatePdpOptions())return;if(salla.config.isGuest())return void salla.api.auth.requireLoginThen("salla-add-product-button::oo.after-login",(()=>this.handleWidgetClick(t,s)));let i;s.classList.add("s-add-product-button-busy");try{i=await salla.api.withoutNotifier((()=>salla.product.api.getOrderOptions([{id:this.productId,quantity:this.getSelectedQuantity()}])))}catch(t){return salla?.logger?.warn?.("order-options: fetch failed",t),s.classList.remove("s-add-product-button-busy"),void this.resumeWidget(s)}s.classList.remove("s-add-product-button-busy");const a=i?.data?.order_options||[];if(!a.length)return void this.resumeWidget(s);const e=this.livePrice>0?this.livePrice:Number(i?.data?.products?.[0]?.price?.amount)||0,o=this.ensureModal();try{const t=await o.open({orderOptions:a,basePrice:e});this.injectIntoMini(t?.orderOptions||[]),this.resumeWidget(s)}catch{}}async validatePdpOptions(){const t=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);return!t||("function"==typeof t.validateAndScroll?await t.validateAndScroll():"function"!=typeof t.reportValidity||await t.reportValidity())}injectIntoMini(t){if(!t.length)return;const s=this.productId,i=a=>{if(String(a?.id)===String(s))try{a?.payload?.set?.("order_options",t)}finally{salla.event.off("cart::before.add.item",i)}};salla.event.on("cart::before.add.item",i)}ensureModal(){let t=document.querySelector("salla-order-options-modal");return t||(t=document.createElement("salla-order-options-modal"),document.body.appendChild(t)),t}resumeWidget(t){this.collected=!0;const s=t.shadowRoot?.querySelector?.(".s-fast-checkout-button");s?s.click():"function"==typeof t.click&&t.click()}}const m=class{constructor(i){t(this,i),this.success=s(this,"success"),this.failed=s(this,"failed"),this.hostAttributes={},this.hasPreOrder=!1,this.productStatus="sale",this.productType="product",this.selectedOptions=[],this.buyNowText=salla.lang.get("pages.products.buy_now"),this.isDesktopViewport="undefined"==typeof window||window.matchMedia("(min-width: 768px)").matches,this.viewportMediaQuery=null,this.orderOptionsGateAttached=!1,this.onViewportChange=t=>{this.isDesktopViewport=t.matches,this.btn?.setText(t.matches&&this.passedLabel?this.passedLabel:this.getLabel())},salla.lang.onLoaded((()=>{this.buyNowText=salla.lang.get("pages.products.buy_now")}))}getLabel(){return"sale"===this.productStatus&&this.supportStickyBar&&!this.isDesktopViewport&&this.showQuickBuy&&this.isApplePayActive?n:this.hasPreOrder?salla.lang.get("pages.products.pre_order_now"):"sale"===this.productStatus&&"booking"===this.productType?salla.lang.get("pages.cart.book_now"):"sale"===this.productStatus?salla.lang.get("pages.cart.add_to_cart"):"donating"!==this.productType?salla.lang.get("pages.products.out_of_stock"):salla.lang.get("pages.products.donation_exceed")}addProductToCart(t){if("booking"===this.productType)return t.preventDefault(),this.addBookingProduct();if("submit"===this.hostAttributes.type)return!1;t.preventDefault(),this.btn?.disable();const s=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);return s&&"function"==typeof s.validateAndScroll?s.validateAndScroll().then((async t=>{const s={isValid:t,component:this};if(await salla.hooks.call("salla-add-product-button","validate",s),s.isValid)return this._proceedAddToCart();this.btn?.enable()})).catch((()=>{this.btn?.enable()})):this._proceedAddToCart()}async _proceedAddToCart(){const t=this.host.closest("salla-products-list, salla-products-slider")??this.host.closest("salla-product-card, custom-salla-product-card"),s=Object.entries({id:this.productId,donation_amount:this.donatingAmount,quantity:this.quantity,endpoint:"quickAdd",source:l.getProductsSource(t?.getAttribute("source"))}).reduce(((t,[s,i])=>i?(t[s]=i,t):t),{});return salla.cart.addItem(s).then((async t=>(this.selectedOptions=[],this.btn?.enable(),this.success.emit(t),t))).catch((t=>{this.failed.emit(t),this.btn?.enable()}))}addBookingProduct(){return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("booking::add",this.productId),void salla.event.dispatch("login::open")):salla.booking.add(this.productId).then((t=>this.success.emit(t))).catch((t=>this.failed.emit(t)))}getBtnAttributes(){for(let t=0;t<this.host.attributes.length;t++)["id","class"].includes(this.host.attributes[t].name)||(this.hostAttributes[this.host.attributes[t].name]=this.host.attributes[t].value);return this.hostAttributes}get notifyChannels(){return this.channels||salla.api.product.getAvailabilityChannels?.()||l.availabilityChannels()}getQuickBuyBtnAttributes(){return{...this.getBtnAttributes(),type:this.supportStickyBar&&!this.isDesktopViewport?"plain":"donating"==this.productType?"donate":"buy"}}miniCheckoutWidget(){let t=salla.config.get("store.id");if(t)return i("salla-mini-checkout-widget",{language:salla.lang.locale,"store-id":t,config:{user:salla.config.get("user"),failure_url:window.location.href},products:[this.productId],api:salla.config.get("store.api"),outline:!0,"form-selector":"form.product-form",class:"s-add-product-button-mini-checkout"},i("div",{slot:"widget-label",class:"s-add-product-button-mini-checkout-content"},i("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>full-wallet</title>\n<path d="M29 12h-26c-0.668-0.008-1.284-0.226-1.787-0.59l0.009 0.006c-0.744-0.552-1.222-1.428-1.222-2.416 0-1.657 1.343-3 2.999-3h6c0.552 0 1 0.448 1 1s-0.448 1-1 1v0h-6c-0.552 0-1 0.448-1 1 0 0.326 0.156 0.616 0.397 0.798l0.002 0.002c0.167 0.12 0.374 0.194 0.599 0.2l0.001 0h26c0.552 0 1 0.448 1 1s-0.448 1-1 1v0zM27 12c-0.552 0-1-0.448-1-1v0-3h-3c-0.552 0-1-0.448-1-1s0.448-1 1-1v0h4c0.552 0 1 0.448 1 1v0 4c0 0.552-0.448 1-1 1v0zM29 30h-26c-1.657 0-3-1.343-3-3v0-18c0-0.552 0.448-1 1-1s1 0.448 1 1v0 18c0 0.552 0.448 1 1 1v0h25v-5c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM29 18c-0.552 0-1-0.448-1-1v0-6c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM31 24h-7c-2.209 0-4-1.791-4-4s1.791-4 4-4v0h7c0.552 0 1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM24 18c-1.105 0-2 0.895-2 2s0.895 2 2 2v0h6v-4zM25 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-2.306 1.152c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 3.2-1.6c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1v0zM21 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-15.104 7.552c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 16-8c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1-0.001 0-0.001 0-0.002 0h0z"></path>\n</svg>\n'}),this.buyNowText))}componentWillLoad(){return salla.onReady().then((()=>{if(document.documentElement.classList.add("hydrated"),this.showQuickBuy=this.quickBuy&&salla.config.get("store.settings.buy_now")&&"sale"==this.productStatus&&"booking"!==this.productType,this.isApplePayActive=window.ApplePaySession?.canMakePayments()&&salla.config.get("store.settings.payments")?.includes("apple_pay")&&salla.config.get("store.settings.is_salla_gateway",!1),this.passedLabel=this.host.innerHTML.replace("\x3c!----\x3e","").trim(),this.passedLabel&&this.isDesktopViewport)return this.btn?.setText(this.passedLabel);"submit"===this.host.getAttribute("type")&&this.supportStickyBar&&(this.viewportMediaQuery=window.matchMedia("(min-width: 768px)"),this.viewportMediaQuery.addEventListener("change",this.onViewportChange))}))}render(){return this.host.closest(".swiper-slide")?.classList.contains("swiper-slide-duplicate")?"":this.hasSubscribedOptions?i(a,null,i("salla-product-availability",{...this.getBtnAttributes(),"is-subscribed":!0},i("span",{class:"s-hidden"},i("slot",null)))):"out-and-notify"===this.productStatus&&this.notifyChannels||this.hasOutOfStockOption?i(a,null,i("salla-product-availability",{...this.getBtnAttributes()},i("span",{class:"s-hidden"},i("slot",null)))):i(a,{class:{"s-add-product-button-with-quick-buy":this.showQuickBuy,"s-add-product-button-with-sticky-bar":this.supportStickyBar,"s-add-product-button-with-apple-pay":this.showQuickBuy&&this.isApplePayActive}},i("div",{class:{"s-add-product-button-main":this.showQuickBuy,"w-full":!document.getElementById("fast-checkout-js")||["financial_support","donating"].includes(this.productType)}},i("salla-button",{color:"sale"===this.productStatus?"primary":"light",type:"button",fill:"sale"===this.productStatus?"solid":"outline",ref:t=>this.btn=t,onClick:t=>this.addProductToCart(t),disabled:"sale"!==this.productStatus,...this.getBtnAttributes(),"loader-position":"center"},i("slot",null)),this.showQuickBuy&&document.getElementById("fast-checkout-js")&&!["financial_support","donating"].includes(this.productType)?this.miniCheckoutWidget():""),this.showQuickBuy&&this.isApplePayActive?i("salla-quick-buy",{...this.getQuickBuyBtnAttributes()}):"")}async componentDidLoad(){await Salla.hooks.registerComponent("salla-add-product-button",this),this.notifyOptionsAvailability&&salla.event.on("product-options::change",(async t=>{if(!["thumbnail","color","single-option"].includes(t.option.type))return;this.hasSubscribedOptions=!1,this.selectedOptions=await(document.querySelector(`salla-product-options[product-id="${this.productId}"]`)?.getSelectedOptions()),this.hasOutOfStockOption=await(document.querySelector(`salla-product-options[product-id="${this.productId}"]`)?.hasOutOfStockOption());let s=salla.storage.get(`product-${this.productId}-subscribed-options`);if((s||this.subscribedOptions)&&this.hasOutOfStockOption)if(salla.config.isGuest()){const t=s?s.map((t=>t.split(",").map((t=>parseInt(t))))):[];this.hasSubscribedOptions=t.length>0&&t.some((t=>t.every((t=>this.selectedOptions.some((s=>s.id===t))))))}else this.hasSubscribedOptions=!(!this.subscribedOptions||"null"===this.subscribedOptions||"[]"===this.subscribedOptions)&&JSON.parse(this.subscribedOptions).some((t=>t.every((t=>this.selectedOptions.some((s=>s.id===t))))))}))}componentDidRender(){!this.orderOptionsGateAttached&&this.productId&&salla.config.get("store.settings.order_options.mandatory",!1)&&u.attach(this.host,this.productId)&&(this.orderOptionsGateAttached=!0),!this.passedLabel||this.supportStickyBar&&!this.isDesktopViewport?(this.btn?.setText(this.getLabel()),salla.lang.onLoaded((()=>this.btn?.setText(this.getLabel())))):this.btn?.setText(this.passedLabel)}disconnectedCallback(){this.viewportMediaQuery?.removeEventListener("change",this.onViewportChange)}get host(){return e(this)}};m.style=":host{display:block}salla-add-product-button[width=wide]{width:100%}";const y=class{constructor(s){t(this,s),this.limit=3,this.recommendations=[],this.selectedIds=new Set,this.isLoading=!0,this.canRender=!0,this.isAdding=!1,this.title=salla.lang.get("pages.products.bought_together_title"),this.subtitle=salla.lang.get("pages.products.bought_together_subtitle"),this.buyTogetherFor=salla.lang.get("pages.products.buy_together_for"),this.resolvedProductId=0,this.listViewTracked=!1,salla.lang.onLoaded((()=>{this.title=salla.lang.get("pages.products.bought_together_title"),this.subtitle=salla.lang.get("pages.products.bought_together_subtitle"),this.buyTogetherFor=salla.lang.get("pages.products.buy_together_for")}))}componentWillLoad(){salla.onReady().then((()=>{if(!salla.config.get("store.settings.product.bought_together"))return void(this.canRender=!1);const t=salla.config.get("page.id");if(t)return this.resolvedProductId=t,r(String(t));this.canRender=!1})).then((t=>{if(!t?.length)return void(this.canRender=!1);const s=[String(this.resolvedProductId),...t.slice(0,this.limit)];return salla.product.fetch({source:"selected",source_value:s})})).then((t=>{if(!t)return;const s=t?.data??[];if(!s.length)return void(this.canRender=!1);const i=s.find((t=>String(t.id)===String(this.resolvedProductId))),a=s.filter((t=>String(t.id)!==String(this.resolvedProductId)));a.length?(this.recommendations=i?[i,...a]:a,this.selectedIds=new Set(this.recommendations.map((t=>t.id)))):this.canRender=!1})).catch((()=>{this.canRender=!1})).finally((()=>{this.isLoading=!1}))}componentDidRender(){!this.recommendations.length||this.listViewTracked||this.intersectionObserver||(this.intersectionObserver=new IntersectionObserver((t=>{t.some((t=>t.isIntersecting))&&(this.listViewTracked=!0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.emitListViewed())}),{threshold:.1}),this.intersectionObserver.observe(this.el))}disconnectedCallback(){this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0}emitListViewed(){const t=this.recommendations.filter((t=>!this.isMainProduct(t.id)));salla.event.emit("salla-bought-together::list.viewed",{products:t})}isMainProduct(t){return String(t)===String(this.resolvedProductId)}recommendedPosition(t){const s=this.recommendations.filter((t=>!this.isMainProduct(t.id))).findIndex((s=>String(s.id)===String(t)));return-1===s?-1:s+1}emitProductClicked(t,s){salla.event.emit("salla-bought-together::product.clicked",[{product:t,position:s}])}toggleProduct(t){const s=new Set(this.selectedIds);s.has(t)?s.delete(t):s.add(t),this.selectedIds=s}get totalPrice(){const t=this.recommendations.filter((t=>this.selectedIds.has(t.id))).reduce(((t,s)=>t+(s.price??0)),0),s=salla.config.get("store.currency.decimals")??2,i=Math.pow(10,s);return salla.money(Math.round(t*i)/i)}async addSelectedToCart(){if(this.isAdding||!this.selectedIds.size)return;this.isAdding=!0;let t=!1;try{for(const s of Array.from(this.selectedIds))try{salla.cart?.api&&(salla.cart.api.addToCartSource="pdp_fbt");const t=await salla.cart.addItem({id:s,endpoint:"quickAdd",source:"pdp_fbt"}),i=this.recommendations.find((t=>t.id===s));if(i){const a=this.isMainProduct(s)?0:this.recommendedPosition(s),e=t?.data?.items?.find((t=>String(t.product_id)===String(i.id)))??t?.data?.items?.slice(-1)[0];salla.event.emit("salla-bought-together::product.added",[{product:i,position:a,cartItem:e,cartId:t?.data?.id}])}}catch(s){salla.log(s),t=!0}t&&salla.error(salla.lang.get("common.messages.error"))}finally{this.isAdding=!1}}getSkeletonView(){return i(a,{class:"s-bought-together-entry"},i("div",{class:"s-bought-together-skeleton"},i("div",{class:"s-bought-together-skeleton-header"},i("salla-skeleton",{height:"16px",width:"35%"}),i("salla-skeleton",{height:"10px",width:"60%"})),Array(4).fill(null).map(((t,s)=>i("div",{key:s,class:"s-bought-together-skeleton-item"},i("salla-skeleton",{height:"22px",width:"22px"}),i("salla-skeleton",{height:"48px",width:"48px"}),i("div",{class:"s-bought-together-skeleton-info"},i("salla-skeleton",{height:"12px",width:"55%",style:{marginBottom:"3px"}}),i("salla-skeleton",{height:"10px",width:"25%"}))))),i("salla-skeleton",{height:"44px",width:"100%"})))}render(){return this.canRender?this.isLoading?this.getSkeletonView():this.recommendations.length?i(a,{class:"s-bought-together-entry"},i("div",{class:"s-bought-together-header"},i("h3",{class:"s-bought-together-title"},this.title),i("p",{class:"s-bought-together-subtitle"},this.subtitle)),i("div",{class:"s-bought-together-list"},this.recommendations.map((t=>i("div",{key:t.id,class:"s-bought-together-item"+(this.selectedIds.has(t.id)?"":" s-bought-together-item--unchecked")},i("label",{class:"s-bought-together-checkbox-label"},i("input",{type:"checkbox",class:"s-bought-together-checkbox",checked:this.selectedIds.has(t.id),onChange:()=>this.toggleProduct(t.id)}),i("span",{class:"s-bought-together-checkmark"})),i("a",{class:"s-bought-together-item-link",href:t.url,onClick:()=>!this.isMainProduct(t.id)&&this.emitProductClicked(t,this.recommendedPosition(t.id))},i("img",{class:"s-bought-together-item-img",src:t.image?.url||salla.url.cdn("images/s-empty.png"),alt:t.image?.alt||t.name,loading:"lazy",decoding:"async",onError:t=>{t.currentTarget.onerror=null,t.currentTarget.src=salla.url.cdn("images/s-empty.png")}}),i("span",{class:"s-bought-together-item-name"},t.name)),i("span",{class:"s-bought-together-item-price",innerHTML:null!=t.price?salla.money(t.price):""}))))),i("salla-button",{class:"s-bought-together-btn",disabled:!this.selectedIds.size||this.isAdding,loading:this.isAdding,onClick:()=>this.addSelectedToCart()},i("span",{innerHTML:`${this.buyTogetherFor} ${this.totalPrice}`}))):null:null}get el(){return e(this)}};y.style=':host{display:block}.s-bought-together-checkbox:checked~.s-bought-together-checkmark{background-color:var(--color-primary, #2ECC71);border-color:var(--color-primary, #2ECC71)}.s-bought-together-checkbox:checked~.s-bought-together-checkmark::after{content:"";display:block;width:5px;height:9px;border:solid #fff;border-width:0 2px 2px 0;transform:rotate(45deg);margin-top:-2px}';const g=class{constructor(s){t(this,s),this.isUser=salla.config.isUser(),this.translationLoaded=!1,this.notifyOptionsAvailability=!1,this.isSubscribed=!1,this.handleSubmitOptions=async()=>{let t={id:this.productId};if(!this.notifyOptionsAvailability)return t;let s=document.querySelector(`salla-product-options[product-id="${this.productId}"]`),i=Object.values(await(s?.getSelectedOptionsData())||{});if(i.length&&!await(s?.reportValidity())){let t=salla.lang.get("common.messages.required_fields");throw salla.error(t),t}return t.options=[],i.forEach((s=>{s&&!isNaN(s)&&t.options.push(Number(s))})),t},this.typing=t=>{const s=t.target.nextElementSibling;t.target.classList.remove("s-has-error"),s?.classList.contains("s-product-availability-error-msg")&&(s.innerText=""),13===t.keyCode&&this.submit()},salla.lang.onLoaded((()=>{this.translationLoaded=!0,this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.modal?.setTitle(this.title_)})),this.productId||(this.productId=salla.config.get("page.id")),this.isUser||(this.channelsWatcher(this.channels),this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.host.removeAttribute("title"))}channelsWatcher(t){let s=t||salla.api.product.getAvailabilityChannels?.()||l.availabilityChannels();this.channels_=s?s.split(","):[]}get isSubscribedToProduct(){return this.isSubscribed||!this.notifyOptionsAvailability&&(!!salla.api.product.isSubscribedToAvailability?.(this.productId)||!!salla.storage.get(`product-${this.productId}-subscribed`))}openModel(){this.handleSubmitOptions().then((t=>t?this.modal.open():null))}async submit(){let t=await this.handleSubmitOptions();if(this.isUser)return salla.api.product.availabilitySubscribe(t).then((()=>this.isSubscribed=!0));if(this.channels_.includes("sms")||this.channels_.includes("whatsapp")){let{phone:s,countryCode:i}=await this.mobileInput.getValues();t.country_code=i,t.phone=s}return this.channels_.includes("email")&&""!==this.email.value&&(t.email=this.email.value),await this.validateform(),this.btn.load().then((()=>this.btn.disable())).then((()=>salla.api.product.availabilitySubscribe(t))).then((()=>{if(this.notifyOptionsAvailability){if(t.options.length){let s=salla.storage.get(`product-${this.productId}-subscribed-options`)||[],i=t.options.join(",");s.includes(i)?salla.log("already subscribed to this options"):(s.push(i),salla.storage.set(`product-${this.productId}-subscribed-options`,s),this.isSubscribed=!0)}}else this.isSubscribed=!0})).then((()=>this.btn.stop())).then((()=>this.modal.close())).catch((()=>this.btn.stop()&&this.btn.enable()))}async validateform(){try{if(this.channels_.includes("email")){const t=l.isValidEmail(this.email.value);if(t)return;!t&&this.validateField(this.email,salla.lang.get("common.elements.email_is_valid"))}if((this.channels_.includes("sms")||this.channels_.includes("whatsapp"))&&await this.mobileInput.isValid())return}catch(t){throw"Please insert required fields"}}validateField(t,s){t.classList.add("s-has-error"),t.nextElementSibling.innerText="* "+s}render(){return i(a,{key:"ccb098126e7809a6386ff38c74dfa0f00f64deeb",class:"s-product-availability-wrap"},this.isSubscribedToProduct?i("div",{class:"s-product-availability-subscribed"},i("span",{innerHTML:c,class:"s-product-availability-subs-icon"}),salla.lang.get("pages.products.notify_availability_success")):i("salla-button",{width:"wide",onClick:()=>this.isUser?this.submit():this.openModel()},salla.lang.get("pages.products.notify_availability")),this.isUser||this.isSubscribedToProduct?"":this.renderModal())}renderModal(){return i("salla-modal",{ref:t=>this.modal=t,"modal-title":this.title_,subTitle:salla.lang.get("pages.products.notify_availability_subtitle"),width:"sm"},i("span",{slot:"icon",class:"s-product-availability-header-icon",innerHTML:c}),i("div",{class:"s-product-availability-body"},this.channels_.includes("email")?[i("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.email")),i("input",{class:"s-product-availability-input",onKeyDown:t=>this.typing(t),placeholder:salla.lang.get("common.elements.email_placeholder")||"your@email.com",ref:t=>this.email=t,type:"email"}),i("span",{class:"s-product-availability-error-msg"})]:"",this.channels_.includes("sms")||this.channels_.includes("whatsapp")?[i("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.mobile")),i("salla-tel-input",{ref:t=>this.mobileInput=t,onKeyDown:t=>this.typing(t)})]:""),i("div",{slot:"footer",class:"s-product-availability-footer"},i("salla-button",{class:"modal-cancel-btn",width:"wide",color:"light",fill:"outline",onClick:()=>this.modal.close()},salla.lang.get("common.elements.cancel")),i("salla-button",{class:"submit-btn","loader-position":"center",width:"wide",ref:t=>this.btn=t,onClick:()=>this.submit()},salla.lang.get("common.elements.submit"))))}get host(){return e(this)}static get watchers(){return{channels:["channelsWatcher"]}}};var f,b,w;g.style="",function(t){t[t.INIT=1]="INIT",t[t.IDLE=2]="IDLE",t[t.PROCESSING_QUEUED=9]="PROCESSING_QUEUED",t[t.PROCESSING=3]="PROCESSING",t[t.PROCESSING_COMPLETE=5]="PROCESSING_COMPLETE",t[t.PROCESSING_ERROR=6]="PROCESSING_ERROR",t[t.PROCESSING_REVERT_ERROR=10]="PROCESSING_REVERT_ERROR",t[t.LOADING=7]="LOADING",t[t.LOAD_ERROR=8]="LOAD_ERROR"}(f||(f={})),function(t){t[t.EMPTY=0]="EMPTY",t[t.IDLE=1]="IDLE",t[t.ERROR=2]="ERROR",t[t.BUSY=3]="BUSY",t[t.READY=4]="READY"}(b||(b={})),function(t){t[t.INPUT=1]="INPUT",t[t.LIMBO=2]="LIMBO",t[t.LOCAL=3]="LOCAL"}(w||(w={}));const v=class{constructor(a){if(t(this,a),this.changed=s(this,"changed"),this.fileTypes={pdf:"application/pdf",png:"image/png",jpg:"image/jpeg",word:"application/doc,application/ms-doc,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",exl:"application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",txt:"text/plain"},this.outOfStockText="",this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.selectDonationAmount=salla.lang.getWithDefault("pages.products.select_donation_amount","تحديد مبلغ التبرع"),this.selectAmount=salla.lang.getWithDefault("pages.products.select_amount","اختر المبلغ"),this.isCustomDonation=!1,this.selectedOptions=[],this.canDisabled=!1,this.disableCardValue=!0,this.availableDigitalCardValues=[],this.userInitiatedValidation=!1,this.isCartMode=!1,this.availabilityMap={},this.productAvailable=!1,this.outSkus=[],this.ignoreDefaultCardValue=!1,this.productId=salla.config.get("page.id"),this.noPadding=!1,this.handleDonationOptions=(t,s,i)=>{if("custom"===s&&"input"===i){const s=t.target;return salla.helpers.inputDigitsOnly(s),salla.event.emit("product-options::donation-changed",{id:this.productId,price:s.value}),void s.dispatchEvent(new window.Event("change",{bubbles:!0}))}const a="option"===i?String(t.target?.value??""):"";if("option"===i&&"custom"===s&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()),this.isCustomDonation="custom"===a,this.donationInput){if("custom"===a?(this.donationInput.value="",this.donationInput.focus()):this.donationInput.value=a,"custom"===s)return;salla.event.emit("product-options::donation-changed",{id:this.productId,price:a})}},this.hideLabel=t=>!(t.type!==d.DONATION||!t.donation||t.donation.can_donate),this.getExpireDonationMessage=t=>{if(!t.donation)return;const s=t.donation.target_amount<=t.donation.collected_amount;return i("div",{class:{"s-product-options-donation-message":!0,"s-product-options-donation-completed":s,"s-product-options-donation-expired":!s}},i("p",null,t.donation.target_message),i("span",{innerHTML:s?salla.money(t.donation.target_amount):""}))},salla.lang.onLoaded((()=>{this.outOfStockText=salla.lang.get("pages.products.out_of_stock"),this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.selectDonationAmount=salla.lang.getWithDefault("pages.products.select_donation_amount","تحديد مبلغ التبرع"),this.selectAmount=salla.lang.getWithDefault("pages.products.select_amount","اختر المبلغ")})),this.options)try{return void this.setOptionsData(Array.isArray(this.options)?this.options:JSON.parse(this.options))}catch(t){salla.log("Bad json passed via options prop")}Array.isArray(this.optionsData)||(salla.log("Options is not an array[] ---\x3e ",this.optionsData),this.setOptionsData([])),this.productId&&!salla.url.is_page("cart")&&salla.api.product.getDetails(this.productId,["options"]).then((t=>{this.productAvailable=!t.data.is_out_of_stock,this.setOptionsData(t.data.options)}))}async setOptionsData(t){this.optionsData=t,this.outSkus=[],this.optionsData[0]?.details?.forEach((t=>{Object.entries(t.skus_availability||{}).filter((([,t])=>!t)).forEach((([t])=>this.outSkus.push(Number(t))))})),this.fillSelectedOptions(),this.computeAvailability()}async getOptionsData(){return this.optionsData}async getSelectedOptionsData(){const t={},s=this.host.getElementSallaData(),i=void 0!==this.bundleContext?this.bundleContext:null;return s.forEach(((s,a)=>{if(i){if(a.startsWith("bundle[")&&a.includes("[options][")){const i=a.split("[options][")[1].replace("]","");t[i]=s}}else a.startsWith("options[")&&(t[a.replace("options[","").replace("]","")]=s)})),t}async reportValidity(){const t=this.host.querySelectorAll("[required]");let s=!0;for(let i=0;i<t.length;i++){const a=t[i];a.disabled||a.closest(".hidden")||"reportValidity"in a&&!a.reportValidity()&&(s=!1)}return s}async hasOutOfStockOption(){return this.selectedOptions.some((t=>t.is_out))||this.selectedSkus?.length&&this.selectedSkus?.every((t=>this.outSkus.includes(t)))}async getSelectedOptions(){return this.selectedOptions}async getOption(t){return this.optionsData.find((s=>s.id===t))}invalidHandler(t,s){const i=t.target.closest(".s-product-options-option");i.classList.contains("s-product-options-option-error")||i.classList.add("s-product-options-option-error"),!this.userInitiatedValidation&&!salla.helpers.isIOSDevice()||salla.url.is_page("cart")||this.host.querySelector(".s-product-options-option-error")===i&&this.scrollToElement(i)}scrollToElement(t){t&&t.scrollIntoView({behavior:"smooth",block:"center"})}changedHandler(t,s,i=!0){const a={event:t,option:s,detail:null,productId:this.productId};if(s.details){const i=s.details.find((s=>Number(s.id)===Number(t.target.value)));a.detail=i}"country"===s.type&&this.handleCountryOptionChange(t,a.detail);const e=t.target.closest(".s-product-options-option");(t.target.value||(s.type===d.FILE||s.type===d.IMAGE)&&"added"===t.type||s.type===d.MAP&&"selected"===t.type&&t.target.lat&&t.target.lng)&&setTimeout((()=>{e.classList.remove("s-product-options-option-error")}),200),s.type===d.DONATION&&salla.event.emit("product-options::donation-changed",{id:this.productId,price:t.target.value}),this.setSelectedSkus(),this.handleRequiredMultipleOptions(s);const o=this.selectedOptions.findIndex((t=>t.option_id===a.option.id));if(a.option.type===d.MULTIPLE_OPTIONS){const t=this.selectedOptions.findIndex((t=>t.option_id===a.option.id&&t?.id===a.detail?.id));t>-1?this.selectedOptions.splice(t,1):this.selectedOptions.push({...a.detail,option_id:a.option.id})}else a.detail&&0!==Object.keys(a.detail).length?o>-1?this.selectedOptions[o]={...a.detail,option_id:a.option.id}:this.selectedOptions.push({...a.detail,option_id:a.option.id}):o>-1&&this.selectedOptions.splice(o,1);this.optionsData=this.optionsData.map((t=>t.id===a.option.id?{...t,details:t.details.map((t=>({...t,is_selected:a.option.type===d.MULTIPLE_OPTIONS?this.selectedOptions.some((s=>s.id===t.id)):Number(t.id)===Number(a.detail?.id),value:a.detail?.value})))}:t)),this.pruneInvisibleConditionalSelections(),this.setSelectedSkus(),requestAnimationFrame((()=>{this.optionsData?.filter((t=>t.type===d.MULTIPLE_OPTIONS&&t.required)).forEach((t=>this.handleRequiredMultipleOptions(t)))})),i&&(this.changed.emit(a),salla.event.emit("product-options::change",a))}setSelectedSkus(){this.selectedSkus=this.selectedOptions.map((t=>Object.keys(t.skus_availability||{}))).reduce(((t,s)=>t.filter((t=>s.includes(t)))),[]).map((t=>Number(t))),this.computeAvailability()}handleRequiredMultipleOptions(t){if(t.type!==d.MULTIPLE_OPTIONS||!t.required)return;const s=this.host.querySelector(`[data-option-id="${t.id}"]`);if(!s)return;const i=s.querySelectorAll("input:checked").length;s.querySelectorAll("input").forEach((t=>t.toggleAttribute("required",!i)))}pruneInvisibleConditionalSelections(){const t=Math.max(1,this.optionsData.length);for(let s=0;s<t;s++){let t=!1;for(const s of this.optionsData){const i=s.visibility_condition;if(!i)continue;const a=this.selectedOptions.filter((t=>t.option_id===i.option)).map((t=>String(t.id))).includes(String(i.value));("="===i.operator?a:!a)||this.clearStaleOption(s.id)&&(t=!0)}if(!t)break}}clearStaleOption(t){const s=this.optionsData.find((s=>s.id===t));if(!s)return!1;const i=this.selectedOptions.length;this.selectedOptions=this.selectedOptions.filter((s=>s.option_id!==t));const a=this.selectedOptions.length!==i,e=null!=s.value&&String(s.value).length>0,o=s.details?.some((t=>t.is_selected))??!1;return!!(a||e||o)&&(this.optionsData=this.optionsData.map((s=>s.id!==t?s:{...s,value:void 0,details:s.details?.map((t=>({...t,is_selected:!1})))??s.details})),!0)}getLatLng(t,s){return t?t.split(",")["lat"===s?0:1]:""}getDisplayForType(t){return this[`${t.type}Option`]?this[`${t.type}Option`](t):t.type===d.COLOR_PICKER?this.colorPickerOption(t):t.type===d.MULTIPLE_OPTIONS?this.multipleOptions(t):t.type===d.SINGLE_OPTION?this.singleOption(t):t.type===d.RADIO?this.radioOption(t):t.type===d.DIGITAL_CARD_VALUE?this.digitalCardValuesOption(t):t.type===d.COUNTRY?this.countryOption(t):t.type===d.BOOKING&&salla.url.is_page("cart")?i("salla-booking-field",{onInvalidInput:s=>this.invalidHandler(s,t),option:t,productId:t.value}):(salla.log(`Couldn't find options type(${t.type})😢`),"")}getOptionShownWhen(t){return t.visibility_condition?{"data-show-when":`options[${t.visibility_condition.option}] ${t.visibility_condition.operator} ${t.visibility_condition.value}`}:{}}getAvailableDigitalCardSKUs(t){const s=this.optionsData.find((({type:t})=>"digital-code-value"===t));if(!s)throw new Error("product-options:: No digital card options found");const i=Object.keys(t.skus_availability).filter((s=>!1===t.skus_availability[s]));this.availableDigitalCardValues=s.details.filter((t=>!Object.keys(t.skus_availability).filter((t=>i.includes(t))).length))}handleCountryOptionChange(t,s){t.stopImmediatePropagation(),this.ignoreDefaultCardValue=!0;const i=this.host.querySelector("input[data-code-value]:checked");if(i&&(i.checked=!1),!this.optionsData.find((({type:t})=>"digital-code-value"===t)))throw new Error("product-options:: No digital card options found");this.getAvailableDigitalCardSKUs(s)}getSelectedDigitalCardOptions(t){const s=t.details.find((t=>t.is_selected)),i=t.details.find((t=>!!t.is_default))||t.details[0];if(["digital-code-value","country"].includes(t.type))return s||i}async componentWillLoad(){if(salla.url.is_page("cart")&&(this.disableCardValue=!1,this.fillSelectedOptions()),this.config)try{this.optionConfig="string"==typeof this.config?JSON.parse(this.config):this.config}catch(t){console.error("Failed to parse JSON in config prop:",t)}if(this.optionsData.filter((({type:t})=>["country","digital-card-value"].includes(t))).length>0&&salla.url.is_page("cart")){const t=this.optionsData.find((t=>"country"===t.type)),s=t&&this.getSelectedDigitalCardOptions(t);s&&this.getAvailableDigitalCardSKUs(s)}return this.outOfStockText=salla.lang.get("pages.products.out_of_stock"),this.computeAvailability(),await salla.onReady(),this.canDisabled=!salla.config.get("store.settings.product.notify_options_availability")||salla.url.is_page("cart"),this.pasteHandler=this.handlePaste.bind(this),document.addEventListener("paste",this.pasteHandler),!salla.storage.get("cart.id")&&this.optionsData.some((t=>["file","image"].includes(t.type)))?salla.api.cart.getCurrentCartId(!1,"salla-product-options"):null}disconnectedCallback(){this.pasteHandler&&document.removeEventListener("paste",this.pasteHandler)}handlePaste(t){const s=t.target;if(!(Salla.helpers.isAppleDevice()&&(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement)&&s.classList.contains("s-form-control")&&this.host.contains(s)))return;t.preventDefault();const i=t.clipboardData?.getData("text")||"",a=s.selectionStart,e=s.selectionEnd,o=s.value.slice(0,a)+i+s.value.slice(e);s.value=o,s.setSelectionRange(a+i.length,a+i.length);try{s.dispatchEvent(new window.Event("change",{bubbles:!0}))}catch(t){Salla.log("Error on change")}}hideDigitalCardsOptions(t){return this.disableCardValue&&t.type===d.DIGITAL_CARD_VALUE&&!salla.url.is_page("cart")}render(){if(0!==this.optionsData?.length)return i(a,{class:{"s-product-options-wrapper":!0,"s-product-options-no-padding":this.noPadding}},i("salla-conditional-fields",null,this.optionsData.map((t=>i("div",{key:t.id,class:"s-product-options-option-container"+(t.visibility_condition||this.hideDigitalCardsOptions(t)?" hidden":""),"data-option-id":t.id,...this.getOptionShownWhen(t)},"splitter"===t.name?this.splitterOption():i("div",{class:{"s-product-options-option":!0,"s-product-options-option-booking":t.type===d.BOOKING&&salla.url.is_page("cart")},"data-option-type":t.type,"data-option-required":`${t.required}`},i("label",{htmlFor:this.generateInputId(t.id),class:"s-product-options-option-label "+(this.hideLabel(t)?"s-product-options-option-label-hidden":"")},i("b",null,t.name,t.required&&i("span",null," * ")," "),i("small",null,t.placeholder)),i("div",{class:"s-product-options-option-content "+(this.hideLabel(t)||t.type===d.BOOKING&&salla.url.is_page("cart")?"s-product-options-option-content-full-width":"")},this.getDisplayForType(t))))))))}generateUniqueKey(t){const s=this.bundleContext;let i=this.uniqueKey?`${t}-${this.uniqueKey}`:t;if(s)try{const t="string"==typeof s?JSON.parse(s):s,{sectionId:a,productId:e}=t;i=`${i}-bundle-${a}-${e}`}catch(t){}return i}generateInputId(t){return this.generateUniqueKey(`option-${t}`)}generateInputName(t){const s=this.bundleContext,i=t.toString();if(s)try{const t="string"==typeof s?JSON.parse(s):s,{sectionId:a,productId:e}=t;return`bundle[${a}][${e}][options][${i}]`}catch(t){return`options[${i}]`}return`options[${i}]`}fillSelectedOptions(){this.selectedOptions=this.optionsData.reduce(((t,s)=>{const i=(s.details??[]).filter((t=>t.is_selected)).map((t=>({...t,option_id:s.id})));return t.concat(i)}),[])}async seedSelectedOptions(){this.fillSelectedOptions(),requestAnimationFrame((()=>{this.optionsData?.filter((t=>t.type===d.MULTIPLE_OPTIONS&&t.required)).forEach((t=>this.handleRequiredMultipleOptions(t)))}))}async componentDidLoad(){if(!this.optionsData?.length)return;await Salla.hooks.registerComponent("salla-product-options",this);const t=this.optionsData.find((t=>t.type===d.DONATION))?.details?.find((t=>t.is_selected));if(t&&setTimeout((()=>{salla.event.emit("product-options::donation-changed",{id:this.productId,price:t.additional_price})}),1e3),!salla.url.is_page("cart")&&!this.isCartMode){const t=[d.SINGLE_OPTION,d.MULTIPLE_OPTIONS,d.COLOR,d.THUMBNAIL,d.DONATION,d.DIGITAL_CARD_VALUE,d.COUNTRY];this.optionsData.some((s=>t.includes(s.type)&&s.details?.some((t=>t.is_selected))))&&requestAnimationFrame((()=>{try{const t=this.host.closest("form");if(!t)return;const s=new FormData(t),i=s.get("id")||s.get("product_id");if(i&&String(i)!==String(this.productId))return;salla.product.getPrice(s)}catch(t){salla.log("Error updating price for pre-selected options:",t)}}))}}async enterCartMode(){this.isCartMode=!0,this.disableCardValue=!1,this.canDisabled=!0,this.fillSelectedOptions(),this.computeAvailability()}async enableUserInitiatedValidation(){this.userInitiatedValidation=!0}async validateAndScroll(){return await this.enableUserInitiatedValidation(),this.reportValidity()}donationOption(t,s){return i("div",{class:"s-product-options-donation-wrapper"},t.donation?.can_donate?[t.donation?i("div",{key:t.id,class:"s-product-options-donation-progress"},i("salla-progress-bar",{donation:t.donation})):"",t.details.length?[i("h4",{key:t.id},this.selectAmount),i("div",{key:t.id,class:"s-product-options-donation-options"},t.details.map(((s,a)=>i("div",{key:t.id,class:"s-product-options-donation-options-item"},i("input",{id:this.generateUniqueKey(`donation-option-${a}`),type:"radio",name:"donating_option",checked:s.is_selected,value:s.additional_price,onChange:i=>this.handleDonationOptions(i,s,"option",t)}),i("label",{htmlFor:this.generateUniqueKey(`donation-option-${a}`)},i("span",{innerHTML:salla.money(s.name)}))))),t.donation?.custom_amount_enabled?i("div",{class:"s-product-options-donation-options-item"},i("input",{id:this.generateUniqueKey("donation-option-custom"),type:"radio",name:"donating_option",value:"custom",onChange:s=>this.handleDonationOptions(s,"custom","option",t)}),i("label",{htmlFor:this.generateUniqueKey("donation-option-custom")},i("span",null," ",this.selectDonationAmount," "))):"")]:"",i("div",{key:t.id,class:{"s-product-options-donation-input-group":!0,shown:!t.details.length||t.details.length&&this.isCustomDonation}},i("input",{type:"text",id:"donating-amount",name:"donation_amount",class:"s-form-control",ref:t=>{this.donationInput=t},value:t.details.length&&t.details.some((t=>t.is_selected))?t.details.find((t=>t.is_selected)).additional_price:t.value,placeholder:t.placeholder,onInput:s=>this.handleDonationOptions(s,"custom","input",t),onBlur:s=>this.changedHandler(s,t),onInvalid:s=>this.invalidHandler(s,t)}),i("span",{class:"s-product-options-donation-amount-currency"},salla.config.currency(salla.config.get("user.currency_code")).symbol))]:this.getExpireDonationMessage(t))}fileUploader(t,s=null){return i("salla-file-upload",{...s||{},"payload-name":"file",value:t.value,"instant-upload":!0,name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,height:"120px",onAdded:s=>{this.changedHandler(s,t,!(s.detail?.file?.origin===w.LOCAL))},url:salla.cart.api.getUploadImageEndpoint(),"form-data":{cart_item_id:this.productId,product_id:this.productId},onInvalidInput:s=>this.invalidHandler(s,t),class:{"s-product-options-image-input":!0,required:t.required}},i("div",{class:"s-product-options-filepond-placeholder"},i("span",{class:"s-product-options-filepond-placeholder-icon",innerHTML:s.accept?.split(",").every((t=>t.includes("image")))?p:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>file-upload</title>\n<path d="M21.333 24c0.341 0 0.683-0.131 0.943-0.391 0.521-0.521 0.521-1.364 0-1.885l-5.333-5.333c-0.123-0.123-0.271-0.22-0.433-0.288-0.327-0.135-0.693-0.135-1.019 0-0.163 0.068-0.311 0.165-0.433 0.288l-5.333 5.333c-0.521 0.521-0.521 1.364 0 1.885s1.364 0.521 1.885 0l3.057-3.057v10.115c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-10.115l3.057 3.057c0.26 0.26 0.601 0.391 0.943 0.391zM28.943 9.724l-9.333-9.333c-0.249-0.251-0.589-0.391-0.943-0.391h-12c-2.205 0-4 1.795-4 4v24c0 2.205 1.795 4 4 4h4c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333h-4c-0.735 0-1.333-0.599-1.333-1.333v-24c0-0.735 0.599-1.333 1.333-1.333h11.448l8.552 8.552v16.781c0 0.735-0.599 1.333-1.333 1.333h-4c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h4c2.205 0 4-1.795 4-4v-17.333c0-0.353-0.14-0.693-0.391-0.943z"></path>\n</svg>\n'}),i("p",{class:"s-product-options-filepond-placeholder-text"},salla.lang.get("common.uploader.drag_and_drop")),i("span",{class:"filepond--label-action"},salla.lang.get("common.uploader.browse"))))}imageOption(t){return this.fileUploader(t,{accept:"image/png,image/jpeg,image/jpg,image/gif"})}fileOption(t){const s=t.details.map((t=>this.fileTypes[t.name])).filter(Boolean);return s?.length?this.fileUploader(t,{accept:s.join(",")}):"File types not selected."}numberOption(t){return i("input",{type:"text",value:t.value,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onBlur:s=>this.changedHandler(s,t),onInvalid:s=>this.invalidHandler(s,t),onInput:t=>salla.helpers.inputDigitsOnly(t.target)})}splitterOption(){return i("div",{class:"s-product-options-splitter"})}textOption(t){return i("div",{class:"s-product-options-text"},i("input",{type:"text",value:t.value,maxLength:t?.length,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)}))}textareaOption(t){return i("div",{class:"s-product-options-textarea"},i("div",{class:"mt-1"},i("textarea",{rows:4,value:t.value,maxLength:t?.length,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)})))}mapOption(t){return i("salla-map",{zoom:15,lat:this.getLatLng(t.value,"lat"),lng:this.getLatLng(t.value,"lng"),name:this.generateInputName(t.id),searchable:!0,required:t.required,onInvalidInput:s=>this.invalidHandler(s,t),onSelected:s=>this.changedHandler(s,t)})}colorPickerOption(t){return i("salla-color-picker",{onSubmitted:s=>this.changedHandler(s,t),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,onInvalidInput:s=>this.invalidHandler(s,t),color:t.value})}timeOption(t){return i("salla-datetime-picker",{noCalendar:!0,enableTime:!0,dateFormat:"h:i K",value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,name:this.generateInputName(t.id),class:"s-product-options-time-element",onInvalidInput:s=>this.invalidHandler(s,t),onPicked:s=>this.changedHandler(s,t)})}dateOption(t){return i("div",{class:"s-product-options-date-element"},i("salla-datetime-picker",{value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,minDate:new Date,name:this.generateInputName(t.id),onInvalidInput:s=>this.invalidHandler(s,t),onPicked:s=>this.changedHandler(s,t)}))}datetimeOption(t){return i("div",{class:"s-product-options-datetime-element"},i("salla-datetime-picker",{enableTime:!0,value:t.value,dateFormat:"Y-m-d G:i:K",placeholder:t.name,required:!t.visibility_condition&&t.required,name:this.generateInputName(t.id),maxDate:t.to_date_time,minDate:t.from_date_time,onInvalidInput:s=>this.invalidHandler(s,t),onPicked:s=>this.changedHandler(s,t)}))}getOptionDetailName(t,s=!0,i,a){let e;if(i&&i===d.COLOR&&(e=t.name+(s&&this.isOptionDetailOut(t)&&!salla.url.is_page("cart")&&!this.hideOutLabel?` <br/> <p> ${this.outOfStockText} </p>`:"")+(t.additional_price?` <p> (${salla.money(t.additional_price,!1)}) </p>`:"")),!e){const i=(s&&this.isOptionDetailOut(t)&&!salla.url.is_page("cart")&&!this.hideOutLabel?` - ${this.outOfStockText}`:"")+(t.additional_price?` (${salla.money(t.additional_price,!1)})`:"");if("price"===a){const s=salla.helpers.digitsOnly(t.name),a=Number(s);return s&&Number.isFinite(a)?salla.money(a,!0)+i:i}e=t.name+i}return e.replace("<i class=sicon-sar></i>",salla.config.currency()?.symbol||"ر.س")}computeAvailability(){this.availabilityMap=function(t,s,i=!0){const a={};if(!t?.length)return a;const e=t.filter((t=>t.details?.some((t=>t.skus_availability&&Object.keys(t.skus_availability).length>0)))),o=e.length<=1,n=new Set(t.filter((t=>!1===t.is_advance)).map((t=>t.id)));if(0===e.length){for(const s of t)for(const t of s.details)a[t.id]=t.is_out?"out_of_stock":"available";return a}const l=e.some((t=>t.details?.some((t=>t.skus_availability&&Object.values(t.skus_availability).some(Boolean))))),r=i&&!l;for(const t of e){const i=s.filter((s=>s.option_id!==t.id));for(const s of t.details){const t=s.skus_availability;if(!t||!Object.keys(t).length){a[s.id]=s.is_out?"out_of_stock":"available";continue}const e=Object.keys(t).map(Number),l=e.some((s=>t[s]));if(o||0===i.length){a[s.id]=!l&&r||l?"available":"out_of_stock";continue}let c=e;for(const t of i){if(n.has(t.option_id))continue;const s=new Set(Object.keys(t.skus_availability||{}).map(Number));c=c.filter((t=>s.has(t)))}if(!c.length){a[s.id]=r?"available":"impossible";continue}const d=c.some((s=>t[s]));a[s.id]=!d&&r||d?"available":"out_of_stock"}}return a}(this.optionsData||[],this.selectedOptions||[],this.productAvailable)}isOptionDetailOut(t){const s=this.availabilityMap[t.id];return void 0!==s?"available"!==s:!!t.is_out}renderInput(t,s,a,e,o,n){const l=this.generateUniqueKey(`${t}-${a.id}-${s.id}`),r=this.isOptionDetailOut(s),c=this.getOptionDetailName(s,!0,a.type,a.format),d={"s-product-options-grid-mode-span":n,"s-product-options-disabled":this.canDisabled&&r};return i("label",{class:{"s-product-options-disabled":this.canDisabled&&r,"s-product-options-option-stock-out":r}},i("input",{id:l,type:t,name:o,value:s.id,disabled:this.canDisabled&&r,required:e,checked:s.is_selected,onInvalid:t=>this.invalidHandler(t,a),onChange:t=>this.changedHandler(t,a)}),"price"===a.format?i("div",{class:d,innerHTML:c}):i("div",{class:d},c))}renderOptionDetails(t,s,i,a=!1){const e=this.generateInputName(s.id),o="radio"===t?e:`${e}[]`;return s?.details.map((e=>this.renderInput(t,e,s,i,o,a)))}renderSelect(t){return i("div",null,i("select",{id:this.generateInputId(t.id),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,class:"s-form-control",onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)},i("option",{value:""},t.placeholder),t?.details.map((t=>i("option",{key:t.id,value:t.id,disabled:this.canDisabled&&this.isOptionDetailOut(t),selected:t.is_selected},this.getOptionDetailName(t))))))}renderButtonStyle(t,s,a){return i("div",{class:"s-product-options-grid-mode"},this.renderOptionDetails(t,s,a,!0))}singleOption(t){return"button"===this.optionConfig?.["single-option"]?.type||t.type===d.SINGLE_OPTION&&"price"===t.format?this.renderButtonStyle("radio",t,!t.visibility_condition&&t.required):this.renderSelect(t)}multipleOptions(t){const s="button"===this.optionConfig?.["multiple-option"]?.type,a=t.required&&!t.details.some((t=>t.is_selected))&&!t.visibility_condition;return s?this.renderButtonStyle("checkbox",t,a):i("div",{class:{"s-product-options-multiple-options-wrapper":!0,required:t.required}},this.renderOptionDetails("checkbox",t,a))}radioOption(t){return this.singleOption(t)}colorOption(t){return i("fieldset",{class:"s-product-options-colors-wrapper"},t?.details.map((s=>{const a=this.isOptionDetailOut(s);return i("div",{class:{"s-product-options-colors-item":!0,"s-product-options-option-stock-out":a},key:s.id},i("input",{type:"radio",value:s.id,required:!t.visibility_condition&&t.required,checked:s.is_selected,name:this.generateInputName(t.id),disabled:this.canDisabled&&a,id:this.generateUniqueKey(`color-${this.productId}-${t.id}-${s.id}`),onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t),"data-img-id":s.option_value}),i("label",{htmlFor:this.generateUniqueKey(`color-${this.productId}-${t.id}-${s.id}`),"data-img-id":s.option_value},i("span",{style:{backgroundColor:s.color}}),i("div",{innerHTML:this.getOptionDetailName(s,!0,t.type)})))})))}thumbnailOption(t){return i("div",{class:"s-product-options-thumbnails-wrapper"},t.details.map((s=>{const a=this.isOptionDetailOut(s);return i("div",{key:s.id,class:{"s-product-options-option-stock-out":a}},i("input",{type:"radio",value:s.id,"data-itemid":s.id,required:!t.visibility_condition&&t.required,checked:s.is_selected,name:this.generateInputName(t.id),"data-img-id":s.option_value,disabled:this.canDisabled&&a,id:this.generateUniqueKey(`option_${this.productId}-${t.id}_${s.id}`),onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)}),i("label",{htmlFor:this.generateUniqueKey(`option_${this.productId}-${t.id}_${s.id}`),"data-img-id":s.option_value,class:"go-to-slide"},i("img",{"data-src":s.image,src:s.image,title:s.name,alt:s.name}),i("span",{innerHTML:h,class:"s-product-options-thumbnails-icon"}),a?[i("small",{key:`badge-${s.id}`,class:"s-product-options-thumbnails-stock-badge"},this.outOfStockText),this.canDisabled?i("div",{key:`overlay-${s.id}`,class:"s-product-options-thumbnails-badge-overlay"}):""]:""),i("p",null,this.getOptionDetailName(s,!1)," "))})))}digitalCardValuesOption(t){return i("div",{class:"s-product-options-digital-card-wrapper"},this.availableDigitalCardValues.length>0?this.availableDigitalCardValues.map((s=>{const a=String(s.id);return i("label",{htmlFor:this.generateUniqueKey(a.toString()),key:a,class:"s-product-options-digital-card-option"},i("input",{type:"radio","data-code-value":!0,class:"s-form-control s-product-options-digital-card-input",value:s.id,name:this.generateInputName(t.id),id:this.generateUniqueKey(a.toString()),required:!t.visibility_condition&&t.required,onInvalid:s=>this.invalidHandler(s,t),...this.ignoreDefaultCardValue?{}:{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===s.id}}),i("span",null,s.name," ",salla.config?.currency()?.symbol))})):i("div",{class:"s-product-options-digital-card-out-of-stock"}))}countryOption(t){return i("div",{class:"s-product-options-digital-card-wrapper"},t.details.map((s=>{const a=this.isOptionDetailOut(s);return i("label",{htmlFor:this.generateUniqueKey(s.id.toString()),key:s.id,class:{"s-product-options-digital-card-option":!0,"s-product-options-digital-card-option-stock-out":a,"s-product-options-option-stock-out":a}},i("input",{id:this.generateUniqueKey(s.id.toString()),type:"radio",class:"s-form-control s-product-options-digital-card-input",value:s.id,name:this.generateInputName(t.id),disabled:this.canDisabled&&a,required:!t.visibility_condition&&t.required,onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t),onClick:()=>{this.disableCardValue=!1},...salla.url.is_page("cart")?{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===s.id}:{}}),i("img",{loading:"lazy",alt:s.code,height:24,width:24,class:"s-product-options-country-flag",src:`https://cdn.assets.salla.network/prod/admin/cp/assets/flags/1x1/${String(s.code).toLocaleLowerCase()}.svg`,onError:t=>{t.currentTarget.onerror=null,t.currentTarget.src=salla.url.cdn("images/globe.svg")}}),i("span",null,s.name))})))}get host(){return e(this)}};function k(){o.defaults.headers.common.currency=salla?.config?.get?.("user.currency_code")}v.style="";var _={request:(t,s,i,a=null,e=null)=>(k(),o.request({url:s,data:i,method:t.toLowerCase(),responseType:"json"}).then(a).catch(e)),get:(t,s=null,i=null,a)=>(k(),o.get(t,{params:a}).then(s).catch(i)),post(t,s,i=null,a=null){return this.request("post",t,s,i,a)},put(t,s,i=null,a=null){return this.request("put",t,s,i,a)},delete(t,s,i=null,a=null){return this.request("delete",t,s,i,a)},requestWithSupportAjax(t,s,i="post"){return new Promise(((a,e)=>{if(!window?.isLegacyTheme)return this.request(i,t,s,(({data:t})=>a(t)),(({response:t})=>e(t)));k(),$.ajax({url:t,method:i.toUpperCase(),data:s,headers:{currency:o.defaults.headers.common.currency},async:!1,success:function({data:t}){return a(t)},error:function({response:t}){return e(t)}})}))}},S={options:[],header:"undefined"!=typeof navigator&&"undefined"!=typeof window?[navigator.platform,navigator.userAgent,navigator.appVersion,navigator.vendor,window.opera]:[],dataos:[{name:"Windows Phone",value:"Windows Phone",version:"OS"},{name:"Windows",value:"Win",version:"NT"},{name:"iPhone",value:"iPhone",version:"OS"},{name:"iPad",value:"iPad",version:"OS"},{name:"Kindle",value:"Silk",version:"Silk"},{name:"Android",value:"Android",version:"Android"},{name:"PlayBook",value:"PlayBook",version:"OS"},{name:"BlackBerry",value:"BlackBerry",version:"/"},{name:"Macintosh",value:"Mac",version:"OS X"},{name:"Linux",value:"Linux",version:"rv"},{name:"Palm",value:"Palm",version:"PalmOS"}],databrowser:[{name:"Chrome",value:"Chrome",version:"Chrome"},{name:"Firefox",value:"Firefox",version:"Firefox"},{name:"Safari",value:"Safari",version:"Version"},{name:"Internet Explorer",value:"MSIE",version:"MSIE"},{name:"Opera",value:"Opera",version:"Opera"},{name:"BlackBerry",value:"CLDC",version:"CLDC"},{name:"Mozilla",value:"Mozilla",version:"Mozilla"}],init:function(){var t=this.header.join(" ");return{os:this.matchItem(t,this.dataos),browser:this.matchItem(t,this.databrowser)}},matchItem:function(t,s){var i,a,e,o=0,n=0;for(o=0;o<s.length;o+=1)if(new RegExp(s[o].value,"i").test(t)){if(i=new RegExp(s[o].version+"[- /:;]([\\d._]+)","i"),e="",(a=t.match(i))&&a[1]&&(a=a[1]),a)for(a=a.split(/[._]+/),n=0;n<a.length;n+=1)e+=0===n?a[n]+".":a[n];else e="0";return{name:s[o].name,version:parseFloat(e)}}return{name:"unknown",version:0}}};async function C(t,s,i=!1){if(salla.logger.log("🍏 Pay: mutateShippingContact called",s,i),t.detail.requiredShippingContactFields&&0!=t.detail.requiredShippingContactFields.length)if(i){if(salla.config.isGuest()&&salla.config.get("store.features").includes("guest-checkout")){if(!(s.emailAddress&&s.givenName&&s.familyName&&s.phoneNumber)){salla.logger.warn("🍏 Pay: Guest contact fields are required",s);const i=[];return s.emailAddress||i.push(new window.ApplePayError("shippingContactInvalid","emailAddress","Email address is required")),s.phoneNumber||i.push(new window.ApplePayError("shippingContactInvalid","phoneNumber","Phone number is required")),s.givenName&&s.familyName||i.push(new window.ApplePayError("shippingContactInvalid","name","Name is required")),void t.session.completePayment({status:t.session.STATUS_INVALID_SHIPPING_CONTACT,errors:i})}await async function(t,s){return salla.logger.log("🍏 Pay: Updating guest contact",s),new Promise(((i,a)=>{_.post(t.detail.guestContactSelected.url.replace("{id}",t.id),{email:s.emailAddress||null,first_name:s.givenName||null,last_name:s.familyName||null,phone_number:s.phoneNumber||null,country_code:s.countryCode||null},(async({data:s})=>{"function"==typeof t.detail.guestContactSelected?.onSuccess&&t.detail.guestContactSelected.onSuccess(s),i(s)}),(({response:s})=>{salla.logger.warn("🍏 Pay: Failed to update guest contact via api",s),"function"==typeof t.detail.guestContactSelected?.onFailed&&t.detail.guestContactSelected.onFailed(s),a({response:s})}))}))}(t,s)}}else if(t.detail.requiredShippingContactFields.includes("postalAddress"))return _.post(t.detail.shippingContactSelected.url.replace("{id}",t.id),{country:s.country,city:s.locality,local:s.subLocality||s.administrativeArea||s.locality,description:s.subAdministrativeArea,street:s.addressLines?.join(", ")||s.administrativeArea,country_code:s.countryCode,postal_code:s.postalCode},(async({data:s})=>{if("function"==typeof t.detail.shippingContactSelected.onSuccess&&t.detail.shippingContactSelected.onSuccess(s),t.address_id=s.data.address_id,t.shipping_methods=s.data.shipping_methods,!t.shipping_methods||t.shipping_methods&&!t.shipping_methods.length)return salla.logger.warn("🍏 Pay: We dont found any supported methods",s),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]});try{await t.selectApplePayShippingMethod(t.shipping_methods[0])}catch(s){return salla.logger.warn("Failed set the shipping details to api",s),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}try{await t.recalculateTotal()}catch(s){return salla.logger.warn("🍏 Pay: Failed recalculate total",s),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}const i={newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),newShippingMethods:t.mappingShippingMethods(t.shipping_methods)};salla.logger.log("🍏 Pay: completeShippingContactSelection",i),t.session.completeShippingContactSelection(i)}),(({response:s})=>{salla.logger.warn("🍏 Pay: Failed add address via api",s),"function"==typeof t.detail.shippingContactSelected.onFailed&&t.detail.shippingContactSelected.onFailed(s);let i=s?.data?.error?.fields,a=function(t){return Object.entries(t).filter((([t,s])=>s&&s.length>0)).map((([t,s])=>new window.ApplePayError("shippingContactInvalid",t,s[0])))}({countryCode:i?.country_code&&i.country_code.length>0?i.country_code[0]:null,locality:i?.city&&i.city.length>0?i.city[0]:null,country:i?.country&&i.country.length>0?i.country[0]:null});0===a.length&&s?.data?.error?.message&&a.push(new window.ApplePayError("shippingContactInvalid","locality",s?.data?.error?.message)),t.session.completeShippingContactSelection({newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:a})}))}"undefined"!=typeof window&&(window.Salla=window.Salla||{},window.Salla.Payments=window.Salla.Payments||{});const P="undefined"!=typeof window?{session:null,detail:null,address_id:null,shipping_methods:[],total:void 0,request:void 0,id:void 0,countryCode:null,totals:[],shippingCompany:null,init:function(){document.removeEventListener("payments::apple-pay.start-transaction",P.startSession),Salla.event.addEventListener("payments::apple-pay.start-transaction",P.startSession)},initDefault:function(){P.detail.onError||(P.detail.onError=function(t){salla.notify.error(t)}),P.detail.authorized.onFailed||(P.detail.authorized.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse(t),P.onCancel({},t.data.error.message)}),P.detail.validateMerchant.onFailed||(P.detail.validateMerchant.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse({response:t}),P.onCancel({},t.data.error.message)}),P.detail.authorized.onSuccess||(P.detail.authorized.onSuccess=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleAfterResponseActions(t)})},prepareLineItems:function(){return P.detail?.items?.length||(P.detail.items=[{label:salla.lang.get("pages.cart.items_total"),amount:parseFloat(P.detail.amount).toString()}]),P.detail.items},prepareTotal:function(){return{label:window.location.hostname||"Salla",amount:parseFloat(P.detail.amount).toString()}},isPhysical:()=>P.detail?.requiredShippingContactFields?.includes("postalAddress"),startSession:async function(t){P.detail=t.detail||t,salla.log("🍏 Pay: payments::apple-pay.start-transaction",P.detail),P.initDefault();let s,i=P.getApplePaySessionVersion(),a=P.detail.supportedNetworks,e=Array.isArray(a)?[...a]:Object.values(a||{});e.length||(e=["masterCard","visa"]),5!==i||e.includes("mada")||e.push("mada"),P.request={countryCode:P.detail.countryCode||"SA",supportsCouponCode:!0,couponCode:"",currencyCode:P.detail.currency||"SAR",requiredShippingContactFields:P.detail.requiredShippingContactFields?P.detail.requiredShippingContactFields:[],merchantCapabilities:["supports3DS"],supportedNetworks:e,supportedCountries:P.detail.supportedCountries||["SA"],total:P.prepareTotal(),shippingContact:P.detail.shippingContact?P.detail.shippingContact:{},shippingMethods:P.detail.shippingMethods&&P.detail.shippingMethods.length?P.mappingShippingMethods(t.detail.shippingMethods):[],lineItems:P.prepareLineItems()},salla.log("🍏 Pay: init ",P.request),P.session=new ApplePaySession(i,P.request),P.session.onshippingcontactselected=P.onShippingContactSelected,P.session.onshippingmethodselected=P.onShippingMethodSelected,P.session.onvalidatemerchant=P.onValidateMerchant,P.session.onpaymentauthorized=P.onPaymentAuthorized,P.session.oncancel=P.onCancel,P.session.oncouponcodechanged=P.onCouponCodeChanged,P.session.onpaymentmethodselected=P.onPaymentMethodSelected,"function"==typeof P.detail.onStartedSession&&(s=P.detail.onStartedSession(P.session)),s||P.session.begin()},onPaymentMethodSelected:async t=>{if(salla.logger.log("🍏 Pay: onPaymentMethodSelected",t),P.isPhysical())salla.logger.log("🍏 Pay: completePaymentMethodSelection",{newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()}),P.session.completePaymentMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()});else try{await P.recalculateTotal();const t={newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()};salla.logger.log("🍏 Pay: completePaymentMethodSelection",t),P.session.completePaymentMethodSelection(t)}catch(t){salla.logger.warn("🍏 Pay: Failed recalculate total",t),P.session.completePaymentMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems(),status:P.session.STATUS_FAILURE,errors:[new window.ApplePayError("unknown",void 0,t?.response?.data?.error?.message||t?.response?.data?.error?.code||"Failed to recalculate total")]})}},onCouponCodeChanged:t=>(Salla.event.dispatch("payments::apple-pay.coupon.change",t),_.post(P.detail.onCouponCodeChanged.url.replace("{id}",P.id),{coupon:t.couponCode,payment_method:"apple_pay"},(async({data:t})=>{"function"==typeof P.detail.onCouponCodeChanged.onSuccess&&P.detail.onCouponCodeChanged.onSuccess(t),salla.log("🍏 Pay: Coupon applied success"),await P.recalculateTotal(),P.session.completeCouponCodeChange({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()})}),(async t=>{let s=t?.response;Salla.event.dispatch("payments::apple-pay.coupon.failed",s),"function"==typeof P.detail.onCouponCodeChanged.onFailed&&P.detail.onCouponCodeChanged.onFailed(s),await P.recalculateTotal(),P.session.completeCouponCodeChange({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems(),errors:[new window.ApplePayError("couponCodeInvalid")]})}))),onCancel:(t={},s=null)=>{P.detail.onError(s||salla.lang.get("pages.checkout.payment_failed")),Salla.event.createAndDispatch("payments::apple-pay.canceled",t)},onPaymentAuthorized:async t=>{salla.logger.log("🍏 Pay: onPaymentAuthorized",t.payment);try{await C(P,t.payment.shippingContact,!0)}catch(t){salla.logger.error("🍏 Pay: Failed to update guest contact details",t);const s=t?.response||t,i=s?.data?.error?.fields||{},a=[];return i?.email&&i.email.length>0&&a.push(new window.ApplePayError("shippingContactInvalid","emailAddress",i.email[0])),i?.phone&&i.phone.length>0&&a.push(new window.ApplePayError("shippingContactInvalid","phoneNumber",i.phone[0])),i?.first_name&&i.first_name.length>0?a.push(new window.ApplePayError("shippingContactInvalid","name",i.first_name[0])):i?.last_name&&i.last_name.length>0&&a.push(new window.ApplePayError("shippingContactInvalid","name",i.last_name[0])),0===a.length&&a.push(new window.ApplePayError("shippingContactInvalid","name",s?.data?.error?.message||s?.data?.error?.code||"Invalid shipping contact details")),Salla.event.dispatch("payments::apple-pay.authorized.failed",s),"function"==typeof P.detail.authorized.onFailed&&P.detail.authorized.onFailed(s),void P.session.completePayment({status:ApplePaySession.STATUS_INVALID_SHIPPING_CONTACT,errors:a})}Salla.event.dispatch("payments::apple-pay.authorized.init",t),_.post(P.detail.authorized.url.replace("{id}",P.id),{payment_method:"apple_pay",applepay_token:JSON.stringify(t.payment)},(({data:t})=>{Salla.event.dispatch("payments::apple-pay.authorized.success",t),"function"==typeof P.detail.authorized.onSuccess&&P.detail.authorized.onSuccess(t),P.session.completePayment(ApplePaySession.STATUS_SUCCESS)}),(t=>{let s=t?.response;Salla.event.dispatch("payments::apple-pay.authorized.failed",s),"function"==typeof P.detail.authorized.onFailed&&P.detail.authorized.onFailed(s),P.session.completePayment({status:ApplePaySession.STATUS_FAILURE,errors:[new window.ApplePayError("unknown",void 0,s?.data?.error?.message||s?.data?.error?.code||"Failed to parse authorized response")]})}))},onValidateMerchant:async t=>{try{Salla.event.dispatch("payments::apple-pay.validate-merchant.init",t);const{data:s}=await _.post(P.detail.validateMerchant.url.replace("{id}",P.id),{validation_url:t.validationURL});Salla.event.dispatch("payments::apple-pay.validate-merchant.success",s);const i=t=>{P.session.completeMerchantValidation(t)};if("function"==typeof P.detail.validateMerchant.onSuccess){const t=await P.detail.validateMerchant.onSuccess(s);if(t?.redirect)return window.location=t.redirect,P.abortValidateMerchant(t)}i(s.data)}catch(t){console.error(t),P.abortValidateMerchant(t?.response)}},abortValidateMerchant:(t=null)=>{P.abortSession(),Salla.event.dispatch("payments::apple-pay.validate-merchant.failed",t),"function"==typeof P.detail.validateMerchant.onFailed&&P.detail.validateMerchant.onFailed(t)},onShippingContactSelected:async t=>{salla.logger.log("🍏 Pay: onShippingContactSelected",t.shippingContact),await C(P,t.shippingContact)},onShippingMethodSelected:async t=>{let s=t.shippingMethod.identifier.split(","),i={ship_id:s[0],private_ship_id:void 0===s[1]?null:s[1],type:void 0===s[2]?null:s[2],route_id:void 0===s[3]?null:s[3]};if(salla.logger.log("🍏 Pay: onShippingMethodSelected",{event:t,previous:P.shippingCompany,current:i}),P.shouldUpdateShippingCompany(i))try{await P.selectApplePayShippingMethod(i),await P.recalculateTotal()}catch(t){return salla.logger.warn("🍏 Pay: Failed set the shipping details to api",t),void P.session.completeShippingMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems(),status:P.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}salla.logger.log("🍏 Pay: completeShippingMethodSelection",{newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()}),P.session.completeShippingMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()})},abortSession:()=>{P.session&&P.session.abort()},shouldUpdateShippingCompany:t=>P.shippingCompany?.ship_id!=t?.ship_id||P.shippingCompany?.private_ship_id!=t?.private_ship_id,getApplePaySessionVersion:()=>{if("sallapp"===(navigator.userAgent||navigator.vendor||window.opera))return 5;let t=S.init(),s=parseFloat(t.os.version);if("Macintosh"===t.os.name){if(s<10.142)return 1}else if(s<12.11)return 1;return 5},recalculateTotal:()=>(salla.logger.log("🍏 Pay: recalculate total"),_.get(P.detail.recalculateTotal.url.replace("{id}",P.id),(({data:t})=>{salla.logger.log("🍏 Pay: recalculate total success",t);let s=t.data.initial_data?.cart||t.data.cart,i=t.data.initial_data?.payments||t.data.payments;salla.logger.log("🍏 Pay: recalculate total success",{cart:s,payments:i}),null!=i?.gateways?.applePay?.amount?(P.detail.amount=i.gateways.applePay.amount,P.detail.currency=i.gateways.applePay.currency??P.detail.currency):P.detail.amount=i?.gateways?.applePay?.supportedMultiCurrency?s.total_in_customer_currency:s.total,P.detail.items=(s.totals||s.items).map((t=>({label:t.title,amount:"مجاني"===t.amount||"Free"===t.amount?0:t.amount.toString().replace("+","")}))),P.detail.items.pop(),P.totals=P.detail.items}),(t=>(salla.logger.warn("🍏 Pay: recalculate total failed",t),t?.response?.data?.message)))),selectApplePayShippingMethod:t=>{salla.logger.log("🍏 Pay: select shipping method ",t),P.shippingCompany=t;const s={address_id:P.address_id,company_id:t.ship_id,private_company_id:t.private_ship_id,type:t.type||void 0,route_id:t.route_id||void 0,payment_method:"apple_pay"};return _.post(P.detail.shippingMethodSelected.url.replace("{id}",P.id),s,(({data:t})=>("function"==typeof P.detail.shippingMethodSelected.onSuccess&&P.detail.shippingMethodSelected.onSuccess(t),!0)),(t=>{salla.logger.warn("🍏 Pay: Set shipping method failed",t),"function"==typeof P.detail.shippingMethodSelected.onFailed&&P.detail.shippingMethodSelected.onFailed(t);let s=t?.response?.data?.error;return s?.data?.fields?.address_id?s?.data?.fields?.address_id[0]:s?.data?.message}))},mappingShippingMethods:t=>t.map((t=>({label:t.shipping_title,amount:t.enable_free_shipping?0:t.ship_cost,detail:"",identifier:t.ship_id.toString()+(t.private_ship_id?","+t.private_ship_id.toString():"")+(t.type?","+t.type:"")+(t.route_id?","+t.route_id:"")})))}:{};"undefined"!=typeof window&&(window.SallaApplePay=P),"undefined"!=typeof window&&window.ApplePaySession?.canMakePayments()?P.init():"undefined"!=typeof document&&document.querySelectorAll("data-show-if-apple-pay-supported").forEach((t=>t.style.display="none"));const O=class{constructor(i){t(this,i),this.validationFailed=s(this,"validationFailed"),this.requireLogin=s(this,"requireLogin"),this.type="buy",this.productType="product",this.options={},this.collectedOrderOptions=[],this.optionsResolved=!1,this.applePayAmount=0,this.pendingApplePaySession=null,this.quickBuy=salla.lang.get("pages.products.buy_now"),this.handleApplePaySessionStarted=t=>!!salla.config.get("store.settings.order_options.mandatory",!1)&&!this.optionsResolved&&(this.optionsResolved=!0,this.pendingApplePaySession=t,async function(t){let s;try{s=await salla.api.withoutNotifier((()=>salla.product.api.getOrderOptions([{id:t.productId,quantity:t.quantity}])))}catch(s){return salla?.logger?.warn?.("order-options: fetch failed",s),void t.beginPendingSession()}const i=s?.data?.order_options||[];if(!i.length)return void t.beginPendingSession();t.discardPendingSession();const a=Number(t.amount)>0?Number(t.amount):Number(s?.data?.products?.[0]?.price?.amount)||0,e=function(){let t=document.querySelector("salla-order-options-modal");return t||(t=document.createElement("salla-order-options-modal"),document.body.appendChild(t)),t}();try{await e.open({orderOptions:i,basePrice:a,paymentMode:"apple-pay",onSubmit:t.onSubmit})}catch{}}({productId:this.productId,amount:Number(this.amount),quantity:this.getSelectedQuantity(),beginPendingSession:()=>{this.pendingApplePaySession?.begin(),this.pendingApplePaySession=null},discardPendingSession:()=>{this.pendingApplePaySession=null},onSubmit:(t,s)=>{this.collectedOrderOptions=t,this.applePayAmount=s,this.settlePayment()}}),!0),salla.lang.onLoaded((()=>{this.quickBuy=salla.lang.get("pages.products.buy_now")}))}quickBuyHandler(){if(salla.config.isGuest()&&!this.isGuestCheckout())return this.requireLogin.emit({productId:this.productId}),void salla.api.auth.requireLoginThen("salla-quick-buy::user.logged-in",(()=>this.quickBuyHandler()));this.validatePdpOptionsSync()&&(this.optionsResolved=!1,this.collectedOrderOptions=[],this.applePayAmount=0,this.settlePayment())}validatePdpOptionsSync(){return!!function(t){const s=document.querySelector(`salla-product-options[product-id="${t}"]`);if(!s)return!0;const i=s.querySelectorAll("[required]");let a=!0;return i.forEach((t=>{t.disabled||t.closest(".hidden")||"reportValidity"in t&&!t.reportValidity()&&(a=!1)})),a}(this.productId)||(this.validationFailed.emit({productId:this.productId}),salla.error(salla.lang.get("common.messages.required_fields")),!1)}getSelectedQuantity(){try{const t=this.host.getElementSallaData?.(),s=Number(t instanceof FormData?t.get("quantity"):t?.quantity);return Number.isFinite(s)&&s>0?s:1}catch{return 1}}async settlePayment(){let t=this.host.getElementSallaData();if(function(t,s){s.length&&(t&&"function"==typeof t.append?s.forEach(((s,i)=>{t.append(`order_options[${i}][id]`,String(s.id)),t.append(`order_options[${i}][value]`,String(s.value))})):t&&"object"==typeof t&&(t.order_options=s))}(t,this.collectedOrderOptions),!this.isApplePayActive)return salla.api.request("checkout/quick-purchase/"+this.productId,t,"post").then((t=>(t.data.redirect&&(window.location.href=t.data.redirect),t)));t.is_applepay=!0,"append"in t&&t.append("is_applepay",!0),salla.event.dispatch("payments::apple-pay.start-transaction",{amount:this.applePayAmount>0?this.applePayAmount:this.amount,currency:this.currency||salla.config.get("store.settings.buy_now.currency")||"SAR",requiredShippingContactFields:this.getRequiredShippingContactFields(),shippingMethods:this.isRequireShipping?[]:void 0,supportedNetworks:this.isLegacyBuyNowBE()?salla.config.get("store.settings.buy_now.networks"):Array.isArray(this.supportedNetworks)&&this.supportedNetworks.length?this.supportedNetworks:salla.config.get("store.settings.buy_now.supportedNetworks"),supportedCountries:this.isLegacyBuyNowBE()?salla.config.get("store.settings.buy_now.countries"):Array.isArray(this.supportedCountries)&&this.supportedCountries.length?this.supportedCountries:salla.config.get("store.settings.buy_now.supportedCountries"),countryCode:salla.config.get("store.store_country")||"SA",onStartedSession:this.handleApplePaySessionStarted,validateMerchant:{url:this.validateHost?`${this.validateHost}/checkout/applepay/validate`:salla.url.get("checkout/applepay/validate"),onSuccess:s=>this.applePayOnly&&!this.productId?this.cartId?(window.SallaApplePay.id=this.cartId,salla.log("🍏 Pay: create checkout success: with id #"+this.cartId),Promise.resolve(s)):(salla.logger.warn("🍏 Pay: trying to create applePay transaction without cartId/ProductId !"),Promise.resolve(s)):salla.api.request("checkout/quick-purchase/"+this.productId,"object"==typeof t?t:void 0,"post",{}).then((t=>t?.data?.redirect?(salla.log("🍏 Pay: create checkout success: redirect exits, go to checkout page"),window.location.href=t.data.redirect.url,t):t?.data?.id?(window.SallaApplePay.id=t.data.id,void salla.log("🍏 Pay: create checkout success: with id #"+window.SallaApplePay.id)):(salla.logger.warn("🍏 Pay: create checkout success: No id, or redirect"),t)))},authorized:{url:salla.url.get("checkout/{id}/payments/submit"),onFailed:t=>{window.SallaApplePay.onCancel({},t?.data?.error?.message||t?.data?.error?.code||salla.lang.get("pages.checkout.payment_failed"))},onSuccess:t=>{window.location.href=t.redirect.url,salla.log("🍏 Pay: authorized Success:: redirect to thank you page, order placed")}},shippingMethodSelected:this.isRequireShipping?{url:salla.url.get("checkout/{id}/shipping/details")}:void 0,shippingContactSelected:this.isRequireShipping?{url:salla.url.get("checkout/{id}/address/add")}:void 0,guestContactSelected:this.isGuestCheckout()?{url:salla.url.get("checkout/{id}/customer")}:void 0,onCouponCodeChanged:{url:salla.url.get("checkout/{id}/coupons")},recalculateTotal:{url:salla.url.get("checkout/{id}/payments/recalculate?payment_method=apple_pay")},onError:function(t){salla.log(t),salla.notify.error(t)}})}isGuestCheckout(){return salla.config.isGuest()&&salla.config.get("store.features").includes("guest-checkout")&&this.isPhysicalProduct()}getRequiredShippingContactFields(){let t=[];return this.isRequireShipping&&t.push("postalAddress"),this.isGuestCheckout()&&t.push("email","phone","name"),t}isLegacyBuyNowBE(){return null!=salla?.config?.get?.("store.settings.buy_now.multi_currency")}applyBaseCurrencyPrice(t){if(this.isLegacyBuyNowBE())return void(null!=t?.price&&(this.amount=t.price));const s=t?.base_currency_price;null!=s?.amount?(this.amount=s.amount,s?.currency&&(this.currency=s.currency)):null!=t?.price&&(this.amount=t.price,this.currency=salla.config.get("user.currency_code")||this.currency||"SAR")}componentWillLoad(){console.log("🍏 Pay: Quick Buy Component Loaded");const t="undefined"!=typeof window&&!!window.ApplePaySession?.canMakePayments?.(),s=salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??!0,i=salla?.config?.get?.("store.settings.is_salla_gateway",!1)??!0;this.isApplePayActive=t&&s&&i;const a=async()=>{if(this.isLegacyBuyNowBE()&&!this.currency&&salla?.config?.get&&(this.currency=salla.config.get("store.settings.buy_now.multi_currency")?salla.config.get("user.currency_code"):salla.config.get("store.settings.buy_now.currency")||"SAR"),!this.productId&&salla?.config?.get&&salla.url?.is_page&&(this.productId=salla.config.get("page.id")),this.applePayOnly||this.productId){if(this.amount&&this.isRequireShipping||!this.productId||!salla?.product?.getDetails||await salla.product.getDetails(this.productId,[]).then((t=>{this.applyBaseCurrencyPrice(t?.data),this.isRequireShipping=t?.data?.is_require_shipping||!1})).catch((t=>{salla?.logger?.warn?.("🍏 Pay: Failed load the quick buy, get the product details failed: ",t)})),"donate"===this.type&&salla?.event?.on?salla.event.on("product-options::donation-changed",(t=>{String(t.id)===String(this.productId)&&this.applyBaseCurrencyPrice(t)})):salla?.url?.is_page?.("product.single")&&salla?.product?.event?.onPriceUpdated&&salla.product.event.onPriceUpdated((t=>{this.applyBaseCurrencyPrice(t?.data)})),this.isApplePayActive=(salla?.helpers?.hasApplePay?.()??t)&&(salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??s)&&(salla?.config?.get?.("store.settings.is_salla_gateway",!1)??i),!document.getElementById("apple-pay-sdk")&&this.isApplePayActive){const t=document.createElement("script");t.src="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",t.setAttribute("id","apple-pay-sdk"),t.async=!0,document.body.appendChild(t)}}else salla?.logger?.warn?.("🍏 Pay: Failed load the quick buy, the product id is missing")};return new Promise((t=>{"function"==typeof salla?.onReady?salla.onReady((()=>a().then((()=>t(!0))))):a().then((()=>t(!0)))}))}render(){return i(a,{key:"c2ba63eb4fad49f80977d6f1adc836f655524933"},this.quickBuyButton())}quickBuyButton(){return i("apple-pay-button",{locale:salla?.config?.get?.("user.language_code")||"ar",onClick:()=>this.quickBuyHandler(),"data-quick-purchase":"applepay",class:"s-quick-buy-apple-pay","data-is-applepay":"1",buttonstyle:"black",type:this.type})}isPhysicalProduct(){return"product"===this.productType||"group_products"===this.productType||"food"===this.productType}get host(){return e(this)}};O.style=".s-quick-buy-button .s-button-text{display:flex}apple-pay-button{--apple-pay-button-width:100%;--apple-pay-button-height:40px;--apple-pay-button-border-radius:.75rem;--apple-pay-button-box-sizing:content-box}";export{m as salla_add_product_button,y as salla_bought_together,g as salla_product_availability,v as salla_product_options,O as salla_quick_buy}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as t,H as o}from"./p-BM5d07q2.js";const e=class{constructor(t){s(this,t),this.bordered=!0,this.placeholderImage="images/placeholder.png",this.optionsData=[]}componentWillLoad(){this.parseOptionsData()}componentWillUpdate(){this.parseOptionsData()}parseOptionsData(){if(this.options)if("string"==typeof this.options)try{this.optionsData=JSON.parse(this.options)}catch(s){this.optionsData=[]}else this.optionsData=Array.isArray(this.options)?this.options:[];else this.optionsData=[]}renderOptionValue(s){return s.is_image?t("div",{class:"s-order-details-option-image-container"},t("a",{href:s.value,target:"_blank"},t("img",{class:"s-order-details-option-image",src:s.value||this.placeholderImage,alt:s.name}))):s.color?t("span",{title:s.value,class:"s-order-details-option-color-swatch",style:{backgroundColor:s.color}}):s.is_file?t("a",{href:s.value,target:"_blank",class:"s-order-details-option-file-link"},salla.lang.get("common.elements.attachments")):s.is_color_picker?t("div",{class:"s-order-details-option-color-picker"},t("div",{class:"s-order-details-option-color-picker-content"},t("span",{class:"s-order-details-option-color-picker-text"},s.value),t("span",{class:"s-order-details-option-color-picker-swatch",style:{backgroundColor:s.value,width:"1rem"}})),t("salla-button",{onClick:t=>this.copyToClipboard(t,s.value),shape:"link",class:"s-order-details-option-color-picker-button"},t("span",{class:"s-order-details-option-color-copy-icon",innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>swap-fill</title>\n<path d="M28 10.667h-2.667c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333h2.667c0.735 0 1.333 0.597 1.333 1.333v13.333c0 0.736-0.599 1.333-1.333 1.333h-13.333c-0.735 0-1.333-0.597-1.333-1.333v-2.667c0-0.737-0.597-1.333-1.333-1.333s-1.333 0.596-1.333 1.333v2.667c0 2.205 1.795 4 4 4h13.333c2.205 0 4-1.795 4-4v-13.333c0-2.205-1.795-4-4-4zM21.333 17.333v-13.333c0-2.205-1.795-4-4-4h-13.333c-2.205 0-4 1.795-4 4v13.333c0 2.205 1.795 4 4 4h13.333c2.205 0 4-1.795 4-4zM2.667 17.333v-13.333c0-0.736 0.599-1.333 1.333-1.333h13.333c0.735 0 1.333 0.597 1.333 1.333v13.333c0 0.736-0.599 1.333-1.333 1.333h-13.333c-0.735 0-1.333-0.597-1.333-1.333z"></path>\n</svg>\n'}))):s.is_map&&s.latitude&&s.longitude?t("salla-map",{id:`location_map_${s.id}`,class:`map_${s.id}`,zoom:15,readonly:!0,lat:s.latitude,lng:s.longitude},t("div",{slot:"button"},t("button",{type:"button",class:"s-order-details-option-map-button",onClick:()=>this.openMap(s.id)},salla.lang.get("common.elements.show_location")))):t("span",{class:"s-order-details-option-default-text"},s.display_value||s.value)}copyToClipboard(s,t){s.preventDefault(),navigator.clipboard&&navigator.clipboard.writeText(t)}openMap(s){const t=document.querySelector(`salla-map.map_${s}`);t&&t.open&&t.open()}render(){if(!this.optionsData.length)return null;const s=this.bordered?"s-order-details-options-container":"s-order-details-options-container-borderless";return t(o,{class:"s-order-details-options-wrapper"},t("h2",{class:"s-order-details-options-title"},salla.lang.get("pages.cart.item_options")),t("div",{class:s},t("dl",{class:"s-order-details-options-list"},this.optionsData.map((s=>t("div",{key:s.id,class:"s-order-details-options-item"},t("dt",{class:"s-order-details-options-item-name"},s.name,":"),t("dd",{class:s.is_image?"s-order-details-options-item-value-image":"s-order-details-options-item-value-text"},this.renderOptionValue(s))))))))}};e.style="";export{e as salla_order_details_options}
4
+ import{r as s,h as t,H as o}from"./p-Dm54yhRt.js";const e=class{constructor(t){s(this,t),this.bordered=!0,this.placeholderImage="images/placeholder.png",this.optionsData=[]}componentWillLoad(){this.parseOptionsData()}componentWillUpdate(){this.parseOptionsData()}parseOptionsData(){if(this.options)if("string"==typeof this.options)try{this.optionsData=JSON.parse(this.options)}catch(s){this.optionsData=[]}else this.optionsData=Array.isArray(this.options)?this.options:[];else this.optionsData=[]}renderOptionValue(s){return s.is_image?t("div",{class:"s-order-details-option-image-container"},t("a",{href:s.value,target:"_blank"},t("img",{class:"s-order-details-option-image",src:s.value||this.placeholderImage,alt:s.name}))):s.color?t("span",{title:s.value,class:"s-order-details-option-color-swatch",style:{backgroundColor:s.color}}):s.is_file?t("a",{href:s.value,target:"_blank",class:"s-order-details-option-file-link"},salla.lang.get("common.elements.attachments")):s.is_color_picker?t("div",{class:"s-order-details-option-color-picker"},t("div",{class:"s-order-details-option-color-picker-content"},t("span",{class:"s-order-details-option-color-picker-text"},s.value),t("span",{class:"s-order-details-option-color-picker-swatch",style:{backgroundColor:s.value,width:"1rem"}})),t("salla-button",{onClick:t=>this.copyToClipboard(t,s.value),shape:"link",class:"s-order-details-option-color-picker-button"},t("span",{class:"s-order-details-option-color-copy-icon",innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>swap-fill</title>\n<path d="M28 10.667h-2.667c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333h2.667c0.735 0 1.333 0.597 1.333 1.333v13.333c0 0.736-0.599 1.333-1.333 1.333h-13.333c-0.735 0-1.333-0.597-1.333-1.333v-2.667c0-0.737-0.597-1.333-1.333-1.333s-1.333 0.596-1.333 1.333v2.667c0 2.205 1.795 4 4 4h13.333c2.205 0 4-1.795 4-4v-13.333c0-2.205-1.795-4-4-4zM21.333 17.333v-13.333c0-2.205-1.795-4-4-4h-13.333c-2.205 0-4 1.795-4 4v13.333c0 2.205 1.795 4 4 4h13.333c2.205 0 4-1.795 4-4zM2.667 17.333v-13.333c0-0.736 0.599-1.333 1.333-1.333h13.333c0.735 0 1.333 0.597 1.333 1.333v13.333c0 0.736-0.599 1.333-1.333 1.333h-13.333c-0.735 0-1.333-0.597-1.333-1.333z"></path>\n</svg>\n'}))):s.is_map&&s.latitude&&s.longitude?t("salla-map",{id:`location_map_${s.id}`,class:`map_${s.id}`,zoom:15,readonly:!0,lat:s.latitude,lng:s.longitude},t("div",{slot:"button"},t("button",{type:"button",class:"s-order-details-option-map-button",onClick:()=>this.openMap(s.id)},salla.lang.get("common.elements.show_location")))):t("span",{class:"s-order-details-option-default-text"},s.display_value||s.value)}copyToClipboard(s,t){s.preventDefault(),navigator.clipboard&&navigator.clipboard.writeText(t)}openMap(s){const t=document.querySelector(`salla-map.map_${s}`);t&&t.open&&t.open()}render(){if(!this.optionsData.length)return null;const s=this.bordered?"s-order-details-options-container":"s-order-details-options-container-borderless";return t(o,{class:"s-order-details-options-wrapper"},t("h2",{class:"s-order-details-options-title"},salla.lang.get("pages.cart.item_options")),t("div",{class:s},t("dl",{class:"s-order-details-options-list"},this.optionsData.map((s=>t("div",{key:s.id,class:"s-order-details-options-item"},t("dt",{class:"s-order-details-options-item-name"},s.name,":"),t("dd",{class:s.is_image?"s-order-details-options-item-value-image":"s-order-details-options-item-value-text"},this.renderOptionValue(s))))))))}};e.style="";export{e as salla_order_details_options}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{f as t}from"./p-BM5d07q2.js";function r(r,s={}){return s=Object.assign({initialData:void 0,initialStatus:"idle"},s),(i,e)=>{const o=Object.assign((function(...s){const i=r=>{Object.assign(this[e],r),t(this)};return i({status:"pending",error:void 0}),r.call(this,...s).then((t=>(i({status:"success",data:t,error:void 0}),t)),(t=>(i({status:"error",error:t}),Promise.reject(t))))}),{status:s.initialStatus,data:s.initialData,error:void 0});Object.defineProperty(i,e,{value:o})}}export{r as T}
4
+ import{f as t}from"./p-Dm54yhRt.js";function r(r,s={}){return s=Object.assign({initialData:void 0,initialStatus:"idle"},s),(i,e)=>{const o=Object.assign((function(...s){const i=r=>{Object.assign(this[e],r),t(this)};return i({status:"pending",error:void 0}),r.call(this,...s).then((t=>(i({status:"success",data:t,error:void 0}),t)),(t=>(i({status:"error",error:t}),Promise.reject(t))))}),{status:s.initialStatus,data:s.initialData,error:void 0});Object.defineProperty(i,e,{value:o})}}export{r as T}
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{d as t}from"./p-BM5d07q2.js";function n(t,n){return n.forEach((function(n){n&&"string"!=typeof n&&!Array.isArray(n)&&Object.keys(n).forEach((function(e){if("default"!==e&&!(e in t)){var r=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,r.get?r:{enumerable:!0,get:function(){return n[e]}})}}))})),Object.freeze(t)}var e,r={exports:{}},i=(e||(e=1,r.exports=function(){var t={type:"spring",stiffness:.5,damping:.45,mass:10},n=function(t){return-.5*(Math.cos(Math.PI*t)-1)},e=function(t){var n=Math.min(10/t.width,10/t.height),e=document.createElement("canvas"),i=e.getContext("2d"),o=e.width=Math.ceil(t.width*n),a=e.height=Math.ceil(t.height*n);i.drawImage(t,0,0,o,a);var _=null;try{_=i.getImageData(0,0,o,a).data}catch(t){return null}for(var E=_.length,u=0,I=0,c=0,T=0;T<E;T+=4)u+=_[T]*_[T],I+=_[T+1]*_[T+1],c+=_[T+2]*_[T+2];return{r:u=r(u,E),g:I=r(I,E),b:c=r(c,E)}},r=function(t,n){return Math.floor(Math.sqrt(t/(n/4)))},i=function(t,e,r,i,o){t.width=e,t.height=r;var a=t.getContext("2d"),_=.5*e,E=a.createRadialGradient(_,r+110,r-100,_,r+110,r+100);(function(t,e){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:10,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,_=1-a,E=e.join(","),u=0;u<=o;u++){var I=u/o;t.addColorStop(a+_*I,"rgba(".concat(E,", ").concat(i(I)*r,")"))}})(E,i,o,void 0,8,.4),a.save(),a.translate(-250,0),a.scale(2,1),a.fillStyle=E,a.fillRect(0,0,e,r),a.restore()},o="undefined"!=typeof navigator,a="undefined"!=typeof document,_=500,E=200,u=o&&a&&document.createElement("canvas"),I=o&&a&&document.createElement("canvas"),c=o&&a&&document.createElement("canvas"),T=[40,40,40],f=[196,78,71],l=[54,151,99];o&&a&&(i(u,_,E,T,.85),i(I,_,E,f,1),i(c,_,E,l,1));var s=function(n){var r=n.utils.createView({name:"file-poster-overlay",tag:"canvas",ignoreRect:!0,create:function(t){var n,e;(e=t.root.element).width=(n=t.props.template).width,e.height=n.height,e.getContext("2d").drawImage(n,0,0)},mixins:{styles:["opacity"],animations:{opacity:{type:"spring",mass:25}}}}),o=function(t){var n=t.root;n.ref.overlayShadow.opacity=1,n.ref.overlayError.opacity=0,n.ref.overlaySuccess.opacity=0},a=function(t){var n=t.root;n.ref.overlayShadow.opacity=.25,n.ref.overlayError.opacity=1};return n.utils.createView({name:"file-poster-wrapper",create:function(e){var o=e.root,a=e.props,s=o.query("GET_FILE_POSTER_ITEM_OVERLAY_SHADOW_COLOR"),O=o.query("GET_FILE_POSTER_ITEM_OVERLAY_ERROR_COLOR"),R=o.query("GET_FILE_POSTER_ITEM_OVERLAY_SUCCESS_COLOR");s&&s!==T&&i(u,_,E,T=s,.85),O&&O!==f&&i(I,_,E,f=O,1),R&&R!==l&&i(c,_,E,l=R,1);var v=function(n){return n.utils.createView({name:"file-poster",tag:"div",ignoreRect:!0,create:function(t){var n=t.root;n.ref.image=document.createElement("img"),n.element.appendChild(n.ref.image)},write:n.utils.createRoute({DID_FILE_POSTER_LOAD:function(t){var n=t.root,e=t.props,r=e.id,i=n.query("GET_ITEM",{id:e.id});if(i){var o=i.getMetadata("poster");n.ref.image.src=o,n.dispatch("DID_FILE_POSTER_DRAW",{id:r})}}}),mixins:{styles:["scaleX","scaleY","opacity"],animations:{scaleX:t,scaleY:t,opacity:{type:"tween",duration:750}}}})}(n);o.ref.image=o.appendChildView(o.createChildView(v,{id:a.id,scaleX:1.25,scaleY:1.25,opacity:0})),o.ref.overlayShadow=o.appendChildView(o.createChildView(r,{template:u,opacity:0})),o.ref.overlaySuccess=o.appendChildView(o.createChildView(r,{template:c,opacity:0})),o.ref.overlayError=o.appendChildView(o.createChildView(r,{template:I,opacity:0}))},write:n.utils.createRoute({DID_FILE_POSTER_LOAD:function(t){t.root.ref.overlayShadow.opacity=1},DID_FILE_POSTER_DRAW:function(t){var n=t.root.ref.image;n.scaleX=1,n.scaleY=1,n.opacity=1},DID_FILE_POSTER_CONTAINER_CREATE:function(t){var n,r,i,o=t.root,a=t.props.id,_=o.query("GET_ITEM",a);if(_){var E=_.getMetadata("poster"),u=function(t){var n=o.query("GET_FILE_POSTER_CALCULATE_AVERAGE_IMAGE_COLOR")?e(t):null;_.setMetadata("color",n,!0),o.dispatch("DID_FILE_POSTER_LOAD",{id:a,data:t})};n=E,r=function(t,n){var e,r;o.dispatch("DID_FILE_POSTER_CALCULATE_SIZE",{id:a,width:t,height:n}),(e=E,r=o.query("GET_FILE_POSTER_CROSS_ORIGIN_ATTRIBUTE_VALUE"),new Promise((function(t,n){var i=new Image;"string"==typeof crossOrigin&&(i.crossOrigin=r),i.onload=function(){t(i)},i.onerror=function(t){n(t)},i.src=e}))).then(u)},(i=new Image).onload=function(){var t=i.naturalWidth,n=i.naturalHeight;i=null,r(t,n)},i.src=n}},DID_THROW_ITEM_LOAD_ERROR:a,DID_THROW_ITEM_PROCESSING_ERROR:a,DID_THROW_ITEM_INVALID:a,DID_COMPLETE_ITEM_PROCESSING:function(t){var n=t.root;n.ref.overlayShadow.opacity=.25,n.ref.overlaySuccess.opacity=1},DID_START_ITEM_PROCESSING:o,DID_REVERT_ITEM_PROCESSING:o})})},O=function(t){var n=t.addFilter,e=t.utils,r=e.Type,i=e.createRoute,o=s(t);return n("CREATE_VIEW",(function(t){var n=t.view,e=t.query;if((0,t.is)("file")&&e("GET_ALLOW_FILE_POSTER")){var r=function(t,r){var i=r.id,a=e("GET_ITEM",i);a&&a.getMetadata("poster")&&!a.archived&&t.ref.previousPoster!==a.getMetadata("poster")&&(t.ref.previousPoster=a.getMetadata("poster"),e("GET_FILE_POSTER_FILTER_ITEM")(a)&&(t.ref.filePoster&&n.removeChildView(t.ref.filePoster),t.ref.filePoster=n.appendChildView(n.createChildView(o,{id:i})),t.dispatch("DID_FILE_POSTER_CONTAINER_CREATE",{id:i})))},a=function(t){var n=t.root,e=n.query("GET_FILE_POSTER_HEIGHT");if(e)return e;var r=n.query("GET_FILE_POSTER_MIN_HEIGHT"),i=n.query("GET_FILE_POSTER_MAX_HEIGHT");if(r&&n.ref.imageHeight<r)return r;var o=n.rect.element.width*(n.ref.imageHeight/n.ref.imageWidth);return r&&o<r?r:i&&o>i?i:o};n.registerWriter(i({DID_LOAD_ITEM:function(t){r(t.root,t.props)},DID_FILE_POSTER_CALCULATE_SIZE:function(t){var n=t.root,e=t.action;n.ref.filePoster&&(n.ref.imageWidth=e.width,n.ref.imageHeight=e.height,n.ref.shouldUpdatePanelHeight=!0,n.dispatch("KICK"))},DID_UPDATE_ITEM_METADATA:function(t){var n=t.root,e=t.props;/poster/.test(t.action.change.key)&&r(n,e)}},(function(t){var n=t.root;n.ref.filePoster&&(n.rect.element.hidden||n.ref.shouldUpdatePanelHeight&&(n.dispatch("DID_UPDATE_PANEL_HEIGHT",{id:t.props.id,height:a({root:n})}),n.ref.shouldUpdatePanelHeight=!1))})))}})),{options:{allowFilePoster:[!0,r.BOOLEAN],filePosterHeight:[null,r.INT],filePosterMinHeight:[null,r.INT],filePosterMaxHeight:[null,r.INT],filePosterFilterItem:[function(){return!0},r.FUNCTION],filePosterCalculateAverageImageColor:[!1,r.BOOLEAN],filePosterCrossOriginAttributeValue:["Anonymous",r.STRING],filePosterItemOverlayShadowColor:[null,r.ARRAY],filePosterItemOverlayErrorColor:[null,r.ARRAY],filePosterItemOverlaySuccessColor:[null,r.ARRAY]}}};return"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:O})),O}()),r.exports),o=n({__proto__:null,default:t(i)},[i]);
4
+ import{d as t}from"./p-Dm54yhRt.js";function n(t,n){return n.forEach((function(n){n&&"string"!=typeof n&&!Array.isArray(n)&&Object.keys(n).forEach((function(e){if("default"!==e&&!(e in t)){var r=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,r.get?r:{enumerable:!0,get:function(){return n[e]}})}}))})),Object.freeze(t)}var e,r={exports:{}},i=(e||(e=1,r.exports=function(){var t={type:"spring",stiffness:.5,damping:.45,mass:10},n=function(t){return-.5*(Math.cos(Math.PI*t)-1)},e=function(t){var n=Math.min(10/t.width,10/t.height),e=document.createElement("canvas"),i=e.getContext("2d"),o=e.width=Math.ceil(t.width*n),a=e.height=Math.ceil(t.height*n);i.drawImage(t,0,0,o,a);var _=null;try{_=i.getImageData(0,0,o,a).data}catch(t){return null}for(var E=_.length,u=0,I=0,c=0,T=0;T<E;T+=4)u+=_[T]*_[T],I+=_[T+1]*_[T+1],c+=_[T+2]*_[T+2];return{r:u=r(u,E),g:I=r(I,E),b:c=r(c,E)}},r=function(t,n){return Math.floor(Math.sqrt(t/(n/4)))},i=function(t,e,r,i,o){t.width=e,t.height=r;var a=t.getContext("2d"),_=.5*e,E=a.createRadialGradient(_,r+110,r-100,_,r+110,r+100);(function(t,e){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:10,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,_=1-a,E=e.join(","),u=0;u<=o;u++){var I=u/o;t.addColorStop(a+_*I,"rgba(".concat(E,", ").concat(i(I)*r,")"))}})(E,i,o,void 0,8,.4),a.save(),a.translate(-250,0),a.scale(2,1),a.fillStyle=E,a.fillRect(0,0,e,r),a.restore()},o="undefined"!=typeof navigator,a="undefined"!=typeof document,_=500,E=200,u=o&&a&&document.createElement("canvas"),I=o&&a&&document.createElement("canvas"),c=o&&a&&document.createElement("canvas"),T=[40,40,40],f=[196,78,71],l=[54,151,99];o&&a&&(i(u,_,E,T,.85),i(I,_,E,f,1),i(c,_,E,l,1));var s=function(n){var r=n.utils.createView({name:"file-poster-overlay",tag:"canvas",ignoreRect:!0,create:function(t){var n,e;(e=t.root.element).width=(n=t.props.template).width,e.height=n.height,e.getContext("2d").drawImage(n,0,0)},mixins:{styles:["opacity"],animations:{opacity:{type:"spring",mass:25}}}}),o=function(t){var n=t.root;n.ref.overlayShadow.opacity=1,n.ref.overlayError.opacity=0,n.ref.overlaySuccess.opacity=0},a=function(t){var n=t.root;n.ref.overlayShadow.opacity=.25,n.ref.overlayError.opacity=1};return n.utils.createView({name:"file-poster-wrapper",create:function(e){var o=e.root,a=e.props,s=o.query("GET_FILE_POSTER_ITEM_OVERLAY_SHADOW_COLOR"),O=o.query("GET_FILE_POSTER_ITEM_OVERLAY_ERROR_COLOR"),R=o.query("GET_FILE_POSTER_ITEM_OVERLAY_SUCCESS_COLOR");s&&s!==T&&i(u,_,E,T=s,.85),O&&O!==f&&i(I,_,E,f=O,1),R&&R!==l&&i(c,_,E,l=R,1);var v=function(n){return n.utils.createView({name:"file-poster",tag:"div",ignoreRect:!0,create:function(t){var n=t.root;n.ref.image=document.createElement("img"),n.element.appendChild(n.ref.image)},write:n.utils.createRoute({DID_FILE_POSTER_LOAD:function(t){var n=t.root,e=t.props,r=e.id,i=n.query("GET_ITEM",{id:e.id});if(i){var o=i.getMetadata("poster");n.ref.image.src=o,n.dispatch("DID_FILE_POSTER_DRAW",{id:r})}}}),mixins:{styles:["scaleX","scaleY","opacity"],animations:{scaleX:t,scaleY:t,opacity:{type:"tween",duration:750}}}})}(n);o.ref.image=o.appendChildView(o.createChildView(v,{id:a.id,scaleX:1.25,scaleY:1.25,opacity:0})),o.ref.overlayShadow=o.appendChildView(o.createChildView(r,{template:u,opacity:0})),o.ref.overlaySuccess=o.appendChildView(o.createChildView(r,{template:c,opacity:0})),o.ref.overlayError=o.appendChildView(o.createChildView(r,{template:I,opacity:0}))},write:n.utils.createRoute({DID_FILE_POSTER_LOAD:function(t){t.root.ref.overlayShadow.opacity=1},DID_FILE_POSTER_DRAW:function(t){var n=t.root.ref.image;n.scaleX=1,n.scaleY=1,n.opacity=1},DID_FILE_POSTER_CONTAINER_CREATE:function(t){var n,r,i,o=t.root,a=t.props.id,_=o.query("GET_ITEM",a);if(_){var E=_.getMetadata("poster"),u=function(t){var n=o.query("GET_FILE_POSTER_CALCULATE_AVERAGE_IMAGE_COLOR")?e(t):null;_.setMetadata("color",n,!0),o.dispatch("DID_FILE_POSTER_LOAD",{id:a,data:t})};n=E,r=function(t,n){var e,r;o.dispatch("DID_FILE_POSTER_CALCULATE_SIZE",{id:a,width:t,height:n}),(e=E,r=o.query("GET_FILE_POSTER_CROSS_ORIGIN_ATTRIBUTE_VALUE"),new Promise((function(t,n){var i=new Image;"string"==typeof crossOrigin&&(i.crossOrigin=r),i.onload=function(){t(i)},i.onerror=function(t){n(t)},i.src=e}))).then(u)},(i=new Image).onload=function(){var t=i.naturalWidth,n=i.naturalHeight;i=null,r(t,n)},i.src=n}},DID_THROW_ITEM_LOAD_ERROR:a,DID_THROW_ITEM_PROCESSING_ERROR:a,DID_THROW_ITEM_INVALID:a,DID_COMPLETE_ITEM_PROCESSING:function(t){var n=t.root;n.ref.overlayShadow.opacity=.25,n.ref.overlaySuccess.opacity=1},DID_START_ITEM_PROCESSING:o,DID_REVERT_ITEM_PROCESSING:o})})},O=function(t){var n=t.addFilter,e=t.utils,r=e.Type,i=e.createRoute,o=s(t);return n("CREATE_VIEW",(function(t){var n=t.view,e=t.query;if((0,t.is)("file")&&e("GET_ALLOW_FILE_POSTER")){var r=function(t,r){var i=r.id,a=e("GET_ITEM",i);a&&a.getMetadata("poster")&&!a.archived&&t.ref.previousPoster!==a.getMetadata("poster")&&(t.ref.previousPoster=a.getMetadata("poster"),e("GET_FILE_POSTER_FILTER_ITEM")(a)&&(t.ref.filePoster&&n.removeChildView(t.ref.filePoster),t.ref.filePoster=n.appendChildView(n.createChildView(o,{id:i})),t.dispatch("DID_FILE_POSTER_CONTAINER_CREATE",{id:i})))},a=function(t){var n=t.root,e=n.query("GET_FILE_POSTER_HEIGHT");if(e)return e;var r=n.query("GET_FILE_POSTER_MIN_HEIGHT"),i=n.query("GET_FILE_POSTER_MAX_HEIGHT");if(r&&n.ref.imageHeight<r)return r;var o=n.rect.element.width*(n.ref.imageHeight/n.ref.imageWidth);return r&&o<r?r:i&&o>i?i:o};n.registerWriter(i({DID_LOAD_ITEM:function(t){r(t.root,t.props)},DID_FILE_POSTER_CALCULATE_SIZE:function(t){var n=t.root,e=t.action;n.ref.filePoster&&(n.ref.imageWidth=e.width,n.ref.imageHeight=e.height,n.ref.shouldUpdatePanelHeight=!0,n.dispatch("KICK"))},DID_UPDATE_ITEM_METADATA:function(t){var n=t.root,e=t.props;/poster/.test(t.action.change.key)&&r(n,e)}},(function(t){var n=t.root;n.ref.filePoster&&(n.rect.element.hidden||n.ref.shouldUpdatePanelHeight&&(n.dispatch("DID_UPDATE_PANEL_HEIGHT",{id:t.props.id,height:a({root:n})}),n.ref.shouldUpdatePanelHeight=!1))})))}})),{options:{allowFilePoster:[!0,r.BOOLEAN],filePosterHeight:[null,r.INT],filePosterMinHeight:[null,r.INT],filePosterMaxHeight:[null,r.INT],filePosterFilterItem:[function(){return!0},r.FUNCTION],filePosterCalculateAverageImageColor:[!1,r.BOOLEAN],filePosterCrossOriginAttributeValue:["Anonymous",r.STRING],filePosterItemOverlayShadowColor:[null,r.ARRAY],filePosterItemOverlayErrorColor:[null,r.ARRAY],filePosterItemOverlaySuccessColor:[null,r.ARRAY]}}};return"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:O})),O}()),r.exports),o=n({__proto__:null,default:t(i)},[i]);
5
5
  /*!
6
6
  * FilePondPluginFilePoster 2.5.2
7
7
  * Licensed under MIT, https://opensource.org/licenses/MIT/
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{d as e}from"./p-BM5d07q2.js";function E(e,E){return E.forEach((function(E){E&&"string"!=typeof E&&!Array.isArray(E)&&Object.keys(E).forEach((function(i){if("default"!==i&&!(i in e)){var _=Object.getOwnPropertyDescriptor(E,i);Object.defineProperty(e,i,_.get?_:{enumerable:!0,get:function(){return E[i]}})}}))})),Object.freeze(e)}var i,_,l={exports:{}},n=i?l.exports:(i=1,l.exports=(_=function(e){var E=e.addFilter,i=e.utils,_=i.Type,l=i.replaceInString,n=i.toNaturalFileSize;return E("ALLOW_HOPPER_ITEM",(function(e,E){var i=E.query;if(!i("GET_ALLOW_FILE_SIZE_VALIDATION"))return!0;var _=i("GET_MAX_FILE_SIZE");if(null!==_&&e.size>_)return!1;var l=i("GET_MIN_FILE_SIZE");return!(null!==l&&e.size<l)})),E("LOAD_FILE",(function(e,E){var i=E.query;return new Promise((function(E,_){if(!i("GET_ALLOW_FILE_SIZE_VALIDATION"))return E(e);var t=i("GET_FILE_VALIDATE_SIZE_FILTER");if(t&&!t(e))return E(e);var I=i("GET_MAX_FILE_SIZE");if(null!==I&&e.size>I)_({status:{main:i("GET_LABEL_MAX_FILE_SIZE_EXCEEDED"),sub:l(i("GET_LABEL_MAX_FILE_SIZE"),{filesize:n(I,".",i("GET_FILE_SIZE_BASE"),i("GET_FILE_SIZE_LABELS",i))})}});else{var L=i("GET_MIN_FILE_SIZE");if(null!==L&&e.size<L)_({status:{main:i("GET_LABEL_MIN_FILE_SIZE_EXCEEDED"),sub:l(i("GET_LABEL_MIN_FILE_SIZE"),{filesize:n(L,".",i("GET_FILE_SIZE_BASE"),i("GET_FILE_SIZE_LABELS",i))})}});else{var a=i("GET_MAX_TOTAL_FILE_SIZE");if(null!==a&&i("GET_ACTIVE_ITEMS").reduce((function(e,E){return e+E.fileSize}),0)>a)return void _({status:{main:i("GET_LABEL_MAX_TOTAL_FILE_SIZE_EXCEEDED"),sub:l(i("GET_LABEL_MAX_TOTAL_FILE_SIZE"),{filesize:n(a,".",i("GET_FILE_SIZE_BASE"),i("GET_FILE_SIZE_LABELS",i))})}});E(e)}}}))})),{options:{allowFileSizeValidation:[!0,_.BOOLEAN],maxFileSize:[null,_.INT],minFileSize:[null,_.INT],maxTotalFileSize:[null,_.INT],fileValidateSizeFilter:[null,_.FUNCTION],labelMinFileSizeExceeded:["File is too small",_.STRING],labelMinFileSize:["Minimum file size is {filesize}",_.STRING],labelMaxFileSizeExceeded:["File is too large",_.STRING],labelMaxFileSize:["Maximum file size is {filesize}",_.STRING],labelMaxTotalFileSizeExceeded:["Maximum total size exceeded",_.STRING],labelMaxTotalFileSize:["Maximum total file size is {filesize}",_.STRING]}}},"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:_})),_)),t=E({__proto__:null,default:e(n)},[n]);
4
+ import{d as e}from"./p-Dm54yhRt.js";function E(e,E){return E.forEach((function(E){E&&"string"!=typeof E&&!Array.isArray(E)&&Object.keys(E).forEach((function(i){if("default"!==i&&!(i in e)){var _=Object.getOwnPropertyDescriptor(E,i);Object.defineProperty(e,i,_.get?_:{enumerable:!0,get:function(){return E[i]}})}}))})),Object.freeze(e)}var i,_,l={exports:{}},n=i?l.exports:(i=1,l.exports=(_=function(e){var E=e.addFilter,i=e.utils,_=i.Type,l=i.replaceInString,n=i.toNaturalFileSize;return E("ALLOW_HOPPER_ITEM",(function(e,E){var i=E.query;if(!i("GET_ALLOW_FILE_SIZE_VALIDATION"))return!0;var _=i("GET_MAX_FILE_SIZE");if(null!==_&&e.size>_)return!1;var l=i("GET_MIN_FILE_SIZE");return!(null!==l&&e.size<l)})),E("LOAD_FILE",(function(e,E){var i=E.query;return new Promise((function(E,_){if(!i("GET_ALLOW_FILE_SIZE_VALIDATION"))return E(e);var t=i("GET_FILE_VALIDATE_SIZE_FILTER");if(t&&!t(e))return E(e);var I=i("GET_MAX_FILE_SIZE");if(null!==I&&e.size>I)_({status:{main:i("GET_LABEL_MAX_FILE_SIZE_EXCEEDED"),sub:l(i("GET_LABEL_MAX_FILE_SIZE"),{filesize:n(I,".",i("GET_FILE_SIZE_BASE"),i("GET_FILE_SIZE_LABELS",i))})}});else{var L=i("GET_MIN_FILE_SIZE");if(null!==L&&e.size<L)_({status:{main:i("GET_LABEL_MIN_FILE_SIZE_EXCEEDED"),sub:l(i("GET_LABEL_MIN_FILE_SIZE"),{filesize:n(L,".",i("GET_FILE_SIZE_BASE"),i("GET_FILE_SIZE_LABELS",i))})}});else{var a=i("GET_MAX_TOTAL_FILE_SIZE");if(null!==a&&i("GET_ACTIVE_ITEMS").reduce((function(e,E){return e+E.fileSize}),0)>a)return void _({status:{main:i("GET_LABEL_MAX_TOTAL_FILE_SIZE_EXCEEDED"),sub:l(i("GET_LABEL_MAX_TOTAL_FILE_SIZE"),{filesize:n(a,".",i("GET_FILE_SIZE_BASE"),i("GET_FILE_SIZE_LABELS",i))})}});E(e)}}}))})),{options:{allowFileSizeValidation:[!0,_.BOOLEAN],maxFileSize:[null,_.INT],minFileSize:[null,_.INT],maxTotalFileSize:[null,_.INT],fileValidateSizeFilter:[null,_.FUNCTION],labelMinFileSizeExceeded:["File is too small",_.STRING],labelMinFileSize:["Minimum file size is {filesize}",_.STRING],labelMaxFileSizeExceeded:["File is too large",_.STRING],labelMaxFileSize:["Maximum file size is {filesize}",_.STRING],labelMaxTotalFileSizeExceeded:["Maximum total size exceeded",_.STRING],labelMaxTotalFileSize:["Maximum total file size is {filesize}",_.STRING]}}},"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:_})),_)),t=E({__proto__:null,default:e(n)},[n]);
5
5
  /*!
6
6
  * FilePondPluginFileValidateSize 2.2.8
7
7
  * Licensed under MIT, https://opensource.org/licenses/MIT/
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{h as a}from"./p-BM5d07q2.js";function l(a,l=(window.matchMedia("(min-width: 768px)").matches?3:2)){return a<l?a:a-a%l}function t(a=null){for(const a of document.querySelectorAll("salla-modal"))a.close();a&&requestAnimationFrame(a)}function o(a){const l=(a.prizes||[]).map((a=>({...a,items:(a.items||[]).map((l=>({...l,group_title:a.title,group_type:a.type})))}))),t={type:"all",title:salla.lang.get("pages.loyalty_program.all"),items:l.reduce(((a,l)=>a.concat(l.items)),[])};return l.unshift(t),{...a,prizes:l,prizes_count:t.items.length,points:a.points??[]}}function r(a){return[a.name.replace(/\s/g,"-"),`brand-${a.id}`].join("/")}function n(a){for(const l of a.conditions)if(l.key.endsWith("_FOR_UNIT")||l.key.endsWith("_FOR_UNIT_BY_CATEGORIES"))return!0}function s(a){for(const l of a.conditions)if(l.key.endsWith("_BY_CATEGORIES")&&a.conditions.length>1)return!0}function p(a){return s(a)?a.conditions.sort(((a,l)=>a.points-l.points))[0].points:a.points}function e(l,t=!1,o=!1){return"number"==typeof l?t?a("span",null,o?salla.lang.get("pages.loyalty_program.start_from"):""," 1 ",salla.config.currency().symbol," = ",l," ",salla.lang.get("pages.loyalty_program.point")):a("span",null,o?salla.lang.get("pages.loyalty_program.start_from"):""," ",l," ",salla.lang.get("pages.loyalty_program.point")):n(l)?a("span",null,s(l)?salla.lang.get("pages.loyalty_program.start_from"):""," 1 ",salla.config.currency().symbol," = ",p(l)," ",salla.lang.get("pages.loyalty_program.point")):a("span",null,s(l)?salla.lang.get("pages.loyalty_program.start_from"):""," ",p(l)," ",salla.lang.get("pages.loyalty_program.point"))}export{l as a,r as b,t as c,e as f,n as i,o as n}
4
+ import{h as a}from"./p-Dm54yhRt.js";function l(a,l=(window.matchMedia("(min-width: 768px)").matches?3:2)){return a<l?a:a-a%l}function t(a=null){for(const a of document.querySelectorAll("salla-modal"))a.close();a&&requestAnimationFrame(a)}function o(a){const l=(a.prizes||[]).map((a=>({...a,items:(a.items||[]).map((l=>({...l,group_title:a.title,group_type:a.type})))}))),t={type:"all",title:salla.lang.get("pages.loyalty_program.all"),items:l.reduce(((a,l)=>a.concat(l.items)),[])};return l.unshift(t),{...a,prizes:l,prizes_count:t.items.length,points:a.points??[]}}function r(a){return[a.name.replace(/\s/g,"-"),`brand-${a.id}`].join("/")}function n(a){for(const l of a.conditions)if(l.key.endsWith("_FOR_UNIT")||l.key.endsWith("_FOR_UNIT_BY_CATEGORIES"))return!0}function s(a){for(const l of a.conditions)if(l.key.endsWith("_BY_CATEGORIES")&&a.conditions.length>1)return!0}function p(a){return s(a)?a.conditions.sort(((a,l)=>a.points-l.points))[0].points:a.points}function e(l,t=!1,o=!1){return"number"==typeof l?t?a("span",null,o?salla.lang.get("pages.loyalty_program.start_from"):""," 1 ",salla.config.currency().symbol," = ",l," ",salla.lang.get("pages.loyalty_program.point")):a("span",null,o?salla.lang.get("pages.loyalty_program.start_from"):""," ",l," ",salla.lang.get("pages.loyalty_program.point")):n(l)?a("span",null,s(l)?salla.lang.get("pages.loyalty_program.start_from"):""," 1 ",salla.config.currency().symbol," = ",p(l)," ",salla.lang.get("pages.loyalty_program.point")):a("span",null,s(l)?salla.lang.get("pages.loyalty_program.start_from"):""," ",p(l)," ",salla.lang.get("pages.loyalty_program.point"))}export{l as a,r as b,t as c,e as f,n as i,o as n}