@salla.sa/twilight-components 2.14.366 → 2.14.368

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 (251) hide show
  1. package/dist/cjs/{filepond-iKAI8_Ua.js → filepond-BFZbLcs9.js} +1 -1
  2. package/dist/cjs/{filepond-plugin-file-poster-DBOuyuqE.js → filepond-plugin-file-poster-j5N_wxed.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-validate-size-3OjivJWc.js → filepond-plugin-file-validate-size-C4fE0LiJ.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-type-C4wPNa1h.js → filepond-plugin-file-validate-type-K4KCyB8B.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-image-edit-D06RnDWS.js → filepond-plugin-image-edit-BPQKyMc5.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-exif-orientation-CbwYrnuw.js → filepond-plugin-image-exif-orientation-Bqc0A8tM.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-preview-mOmpKkFJ.js → filepond-plugin-image-preview-CWUeJfUC.js} +1 -1
  8. package/dist/cjs/{index-TmWujwmX.js → index-57tdmUta.js} +1 -1
  9. package/dist/cjs/{index-DL9nqubd.js → index-BbnigMiZ.js} +2 -2
  10. package/dist/cjs/loader.cjs.js +1 -1
  11. package/dist/cjs/salla-accordion-body_3.cjs.entry.js +1 -1
  12. package/dist/cjs/salla-accordion_6.cjs.entry.js +1 -1
  13. package/dist/cjs/salla-add-product-button_4.cjs.entry.js +5 -3
  14. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  15. package/dist/cjs/salla-alert_2.cjs.entry.js +1 -1
  16. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  17. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  18. package/dist/cjs/salla-booking-field_7.cjs.entry.js +10 -10
  19. package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
  20. package/dist/cjs/salla-comment-form_8.cjs.entry.js +1 -1
  21. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  22. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  23. package/dist/cjs/salla-cookies-bar.cjs.entry.js +2 -2
  24. package/dist/cjs/salla-count-down_2.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
  26. package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-filters.cjs.entry.js +1 -1
  28. package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
  29. package/dist/cjs/salla-hook.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
  31. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  35. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  36. package/dist/cjs/salla-loyalty-program.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
  39. package/dist/cjs/salla-menu.cjs.entry.js +1 -1
  40. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
  44. package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
  45. package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
  46. package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
  47. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  48. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  49. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  50. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  51. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  52. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  53. package/dist/cjs/salla-orders.cjs.entry.js +1 -1
  54. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  55. package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
  56. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  57. package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
  58. package/dist/cjs/salla-products-list.cjs.entry.js +1 -6
  59. package/dist/cjs/salla-products-slider.cjs.entry.js +3 -9
  60. package/dist/cjs/salla-progress-bar.cjs.entry.js +1 -1
  61. package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
  62. package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
  63. package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
  64. package/dist/cjs/salla-search.cjs.entry.js +1 -1
  65. package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
  66. package/dist/cjs/salla-slider.cjs.entry.js +1 -1
  67. package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
  68. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  69. package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
  70. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  71. package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
  72. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  73. package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
  74. package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
  75. package/dist/cjs/salla-user-settings.cjs.entry.js +1 -1
  76. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  77. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  78. package/dist/cjs/twilight.cjs.js +1 -1
  79. package/dist/cjs/{vanilla-picker-DPu_Z0gW.js → vanilla-picker-DVyFh2bj.js} +1 -1
  80. package/dist/collection/components/salla-add-product-button/salla-add-product-button.js +4 -1
  81. package/dist/collection/components/salla-cookies-bar/salla-cookies-bar.js +1 -1
  82. package/dist/collection/components/salla-products-list/salla-products-list.js +0 -5
  83. package/dist/collection/components/salla-products-slider/salla-products-slider.js +2 -8
  84. package/dist/components/index.js +2 -2
  85. package/dist/components/salla-add-product-button2.js +4 -1
  86. package/dist/components/salla-cookies-bar.js +1 -1
  87. package/dist/components/salla-products-list2.js +0 -5
  88. package/dist/components/salla-products-slider2.js +2 -8
  89. package/dist/esm/{filepond-OIAu6i0O.js → filepond-13fnFppb.js} +1 -1
  90. package/dist/esm/{filepond-plugin-file-poster-BMvjO1cc.js → filepond-plugin-file-poster-BpvS4tvR.js} +1 -1
  91. package/dist/esm/{filepond-plugin-file-validate-size-CMCs88HU.js → filepond-plugin-file-validate-size-D5_uYEwO.js} +1 -1
  92. package/dist/esm/{filepond-plugin-file-validate-type-Bjpeuqen.js → filepond-plugin-file-validate-type-BL4ft-S-.js} +1 -1
  93. package/dist/esm/{filepond-plugin-image-edit-Fpoh6xBj.js → filepond-plugin-image-edit-B1N2m-gK.js} +1 -1
  94. package/dist/esm/{filepond-plugin-image-exif-orientation-CPChwYPW.js → filepond-plugin-image-exif-orientation-3XnkO1Od.js} +1 -1
  95. package/dist/esm/{filepond-plugin-image-preview-pLwEytag.js → filepond-plugin-image-preview-B5KuY0qu.js} +1 -1
  96. package/dist/esm/{index-Cs4XvAmW.js → index-Cb4vp5Dk.js} +1 -1
  97. package/dist/esm/{index-CV1rqKQz.js → index-Y6CiunLU.js} +2 -2
  98. package/dist/esm/loader.js +2 -2
  99. package/dist/esm/salla-accordion-body_3.entry.js +1 -1
  100. package/dist/esm/salla-accordion_6.entry.js +1 -1
  101. package/dist/esm/salla-add-product-button_4.entry.js +5 -3
  102. package/dist/esm/salla-advertisement.entry.js +1 -1
  103. package/dist/esm/salla-alert_2.entry.js +1 -1
  104. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  105. package/dist/esm/salla-apps-icons.entry.js +1 -1
  106. package/dist/esm/salla-booking-field_7.entry.js +10 -10
  107. package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
  108. package/dist/esm/salla-comment-form_8.entry.js +1 -1
  109. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  110. package/dist/esm/salla-contacts.entry.js +1 -1
  111. package/dist/esm/salla-cookies-bar.entry.js +2 -2
  112. package/dist/esm/salla-count-down_2.entry.js +1 -1
  113. package/dist/esm/salla-custom-fields.entry.js +1 -1
  114. package/dist/esm/salla-filters-widget.entry.js +1 -1
  115. package/dist/esm/salla-filters.entry.js +1 -1
  116. package/dist/esm/salla-gifting.entry.js +1 -1
  117. package/dist/esm/salla-hook.entry.js +1 -1
  118. package/dist/esm/salla-infinite-scroll.entry.js +1 -1
  119. package/dist/esm/salla-installment.entry.js +1 -1
  120. package/dist/esm/salla-list-tile.entry.js +1 -1
  121. package/dist/esm/salla-localization-modal.entry.js +1 -1
  122. package/dist/esm/salla-login-modal.entry.js +1 -1
  123. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  124. package/dist/esm/salla-loyalty-program.entry.js +1 -1
  125. package/dist/esm/salla-loyalty.entry.js +1 -1
  126. package/dist/esm/salla-maintenance-alert.entry.js +1 -1
  127. package/dist/esm/salla-menu.entry.js +1 -1
  128. package/dist/esm/salla-metadata.entry.js +1 -1
  129. package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
  130. package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
  131. package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
  132. package/dist/esm/salla-notification-item.entry.js +1 -1
  133. package/dist/esm/salla-notifications.entry.js +1 -1
  134. package/dist/esm/salla-offer-modal.entry.js +1 -1
  135. package/dist/esm/salla-offer.entry.js +1 -1
  136. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  137. package/dist/esm/salla-order-details-options.entry.js +1 -1
  138. package/dist/esm/salla-order-details.entry.js +1 -1
  139. package/dist/esm/salla-order-summary.entry.js +1 -1
  140. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  141. package/dist/esm/salla-orders.entry.js +1 -1
  142. package/dist/esm/salla-payments.entry.js +1 -1
  143. package/dist/esm/salla-placeholder.entry.js +1 -1
  144. package/dist/esm/salla-price-range.entry.js +1 -1
  145. package/dist/esm/salla-product-size-guide.entry.js +1 -1
  146. package/dist/esm/salla-products-list.entry.js +1 -6
  147. package/dist/esm/salla-products-slider.entry.js +3 -9
  148. package/dist/esm/salla-progress-bar.entry.js +1 -1
  149. package/dist/esm/salla-quick-order.entry.js +1 -1
  150. package/dist/esm/salla-rating-modal.entry.js +1 -1
  151. package/dist/esm/salla-scopes.entry.js +1 -1
  152. package/dist/esm/salla-search.entry.js +1 -1
  153. package/dist/esm/salla-skeleton.entry.js +1 -1
  154. package/dist/esm/salla-slider.entry.js +1 -1
  155. package/dist/esm/salla-social-share.entry.js +1 -1
  156. package/dist/esm/salla-social.entry.js +1 -1
  157. package/dist/esm/salla-tab-content_3.entry.js +1 -1
  158. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  159. package/dist/esm/salla-tooltip.entry.js +1 -1
  160. package/dist/esm/salla-trust-badges.entry.js +1 -1
  161. package/dist/esm/salla-user-menu.entry.js +1 -1
  162. package/dist/esm/salla-user-profile.entry.js +1 -1
  163. package/dist/esm/salla-user-settings.entry.js +1 -1
  164. package/dist/esm/salla-verify.entry.js +1 -1
  165. package/dist/esm/salla-wallet.entry.js +1 -1
  166. package/dist/esm/twilight.js +2 -2
  167. package/dist/esm/{vanilla-picker-BASTfXcg.js → vanilla-picker-B7piONfC.js} +1 -1
  168. package/dist/twilight/{p-2405c0f7.entry.js → p-00265d7c.entry.js} +1 -1
  169. package/dist/twilight/{p-75ab49a3.entry.js → p-072f71c3.entry.js} +1 -1
  170. package/dist/twilight/{p-1f6ead7d.entry.js → p-0862caad.entry.js} +1 -1
  171. package/dist/twilight/{p-bb0585cc.entry.js → p-0a074662.entry.js} +1 -1
  172. package/dist/twilight/{p-0f1d7449.entry.js → p-0a9a6df5.entry.js} +1 -1
  173. package/dist/twilight/{p-04664fcb.entry.js → p-0d4b87c7.entry.js} +1 -1
  174. package/dist/twilight/{p-3c418ff7.entry.js → p-133743ba.entry.js} +1 -1
  175. package/dist/twilight/p-13ad1a43.entry.js +4 -0
  176. package/dist/twilight/{p-af3d4d0d.entry.js → p-17011d71.entry.js} +1 -1
  177. package/dist/twilight/{p-907b40cd.entry.js → p-1e59d6df.entry.js} +1 -1
  178. package/dist/twilight/{p-2c787ba0.entry.js → p-2038c995.entry.js} +1 -1
  179. package/dist/twilight/{p-5485978c.entry.js → p-25daa921.entry.js} +1 -1
  180. package/dist/twilight/{p-4d35a32b.entry.js → p-274b59eb.entry.js} +1 -1
  181. package/dist/twilight/{p-8c2b148a.entry.js → p-29fd4524.entry.js} +1 -1
  182. package/dist/twilight/{p-965fe2b3.entry.js → p-2a26fb24.entry.js} +1 -1
  183. package/dist/twilight/{p-3f8b06b3.entry.js → p-2f6f0743.entry.js} +1 -1
  184. package/dist/twilight/{p-6f09b53e.entry.js → p-33d68882.entry.js} +1 -1
  185. package/dist/twilight/{p-f1be81ba.entry.js → p-38fcc532.entry.js} +1 -1
  186. package/dist/twilight/{p-215ed586.entry.js → p-3e24955a.entry.js} +1 -1
  187. package/dist/twilight/{p-f8fb3130.entry.js → p-46a1466d.entry.js} +1 -1
  188. package/dist/twilight/{p-e2c6ed54.entry.js → p-4dc533c9.entry.js} +1 -1
  189. package/dist/twilight/{p-db4f5b38.entry.js → p-4f36d6a1.entry.js} +1 -1
  190. package/dist/twilight/{p-6dbcd99e.entry.js → p-5073fed9.entry.js} +1 -1
  191. package/dist/twilight/{p-e0e61f73.entry.js → p-50ec770f.entry.js} +1 -1
  192. package/dist/twilight/{p-6b6e2a52.entry.js → p-51679569.entry.js} +1 -1
  193. package/dist/twilight/{p-233b89ad.entry.js → p-52f4eb31.entry.js} +1 -1
  194. package/dist/twilight/{p-50f5e38d.entry.js → p-540f44e1.entry.js} +1 -1
  195. package/dist/twilight/{p-9797a552.entry.js → p-56b5e580.entry.js} +1 -1
  196. package/dist/twilight/{p-64ac4c0c.entry.js → p-59677d68.entry.js} +1 -1
  197. package/dist/twilight/{p-594d219c.entry.js → p-5ba1da41.entry.js} +1 -1
  198. package/dist/twilight/{p-c0ab0fc6.entry.js → p-5bb6b939.entry.js} +1 -1
  199. package/dist/twilight/{p-c3f515ae.entry.js → p-5fa668d1.entry.js} +1 -1
  200. package/dist/twilight/{p-22b1bd15.entry.js → p-6066a33d.entry.js} +1 -1
  201. package/dist/twilight/{p-0ede455c.entry.js → p-69884c12.entry.js} +1 -1
  202. package/dist/twilight/{p-cf64bb24.entry.js → p-6eb3185b.entry.js} +1 -1
  203. package/dist/twilight/{p-9d937a82.entry.js → p-72c6ea67.entry.js} +1 -1
  204. package/dist/twilight/{p-f1156ab8.entry.js → p-7389553b.entry.js} +1 -1
  205. package/dist/twilight/{p-90eea1a9.entry.js → p-7a197371.entry.js} +1 -1
  206. package/dist/twilight/{p-fc6ddedc.entry.js → p-85229513.entry.js} +1 -1
  207. package/dist/twilight/{p-a5df57f9.entry.js → p-87756e85.entry.js} +1 -1
  208. package/dist/twilight/{p-d64027b9.entry.js → p-8a287dfe.entry.js} +1 -1
  209. package/dist/twilight/{p-f9fcf183.entry.js → p-8cd21001.entry.js} +1 -1
  210. package/dist/twilight/p-9272011d.entry.js +4 -0
  211. package/dist/twilight/{p-ac7f094e.entry.js → p-9b8ab958.entry.js} +1 -1
  212. package/dist/twilight/{p-D5AsuzfF.js → p-BCiXbXPf.js} +1 -1
  213. package/dist/twilight/{p-5mQqqwMU.js → p-BET_97_b.js} +1 -1
  214. package/dist/twilight/{p-f2v0udIe.js → p-Bcx5sYnZ.js} +1 -1
  215. package/dist/twilight/{p-BLbGjdAU.js → p-C0K8EiG4.js} +1 -1
  216. package/dist/twilight/{p-BGB1zYFQ.js → p-DcT7j_au.js} +1 -1
  217. package/dist/twilight/{p-CofhuO2Z.js → p-Dwd0nl0N.js} +1 -1
  218. package/dist/twilight/p-E4Drg2mm.js +9 -0
  219. package/dist/twilight/{p-CV1rqKQz.js → p-Y6CiunLU.js} +1 -1
  220. package/dist/twilight/{p-0c385d73.entry.js → p-a396686e.entry.js} +1 -1
  221. package/dist/twilight/{p-134c9d22.entry.js → p-a5341e29.entry.js} +1 -1
  222. package/dist/twilight/{p-dfc75ce2.entry.js → p-a5ed9268.entry.js} +1 -1
  223. package/dist/twilight/{p-15242c87.entry.js → p-a767c83d.entry.js} +1 -1
  224. package/dist/twilight/{p-a0a6a255.entry.js → p-af6d37b9.entry.js} +1 -1
  225. package/dist/twilight/{p-40ec7a33.entry.js → p-b10a5dc1.entry.js} +1 -1
  226. package/dist/twilight/{p-6aecc925.entry.js → p-b1cd84e9.entry.js} +1 -1
  227. package/dist/twilight/p-b323bd9c.entry.js +4 -0
  228. package/dist/twilight/p-b5aecb9b.entry.js +4 -0
  229. package/dist/twilight/{p-c7719ce9.entry.js → p-ba808f52.entry.js} +1 -1
  230. package/dist/twilight/{p-95db0124.entry.js → p-badcbdcf.entry.js} +1 -1
  231. package/dist/twilight/{p-1aead6d3.entry.js → p-cfa0b892.entry.js} +1 -1
  232. package/dist/twilight/{p-721bb258.entry.js → p-d1fe1003.entry.js} +1 -1
  233. package/dist/twilight/{p-a08f5eae.entry.js → p-da81ede0.entry.js} +1 -1
  234. package/dist/twilight/{p-58f562df.entry.js → p-db9eaba1.entry.js} +1 -1
  235. package/dist/twilight/{p-c90a6440.entry.js → p-e7ceddca.entry.js} +1 -1
  236. package/dist/twilight/{p-e1bf6d23.entry.js → p-ea031fc5.entry.js} +1 -1
  237. package/dist/twilight/{p-585a349f.entry.js → p-ecdc4cd6.entry.js} +1 -1
  238. package/dist/twilight/{p-DbzHZVd1.js → p-edeim4q7.js} +1 -1
  239. package/dist/twilight/{p-3c09b198.entry.js → p-ee25eb47.entry.js} +1 -1
  240. package/dist/twilight/{p-e0ce2c0d.entry.js → p-f1964ad5.entry.js} +1 -1
  241. package/dist/twilight/{p-7bfb9d71.entry.js → p-f49e71c7.entry.js} +1 -1
  242. package/dist/twilight/{p-2dd98664.entry.js → p-f75d4e9b.entry.js} +1 -1
  243. package/dist/twilight/{p-3c6f9112.entry.js → p-fc6cf914.entry.js} +1 -1
  244. package/dist/twilight/{p-CvLPGpFQ.js → p-zW4iqu6h.js} +1 -1
  245. package/dist/twilight/twilight.esm.js +1 -1
  246. package/package.json +5 -5
  247. package/dist/twilight/p-6daa8bd8.entry.js +0 -4
  248. package/dist/twilight/p-7c8c6c47.entry.js +0 -4
  249. package/dist/twilight/p-a386b02a.entry.js +0 -4
  250. package/dist/twilight/p-de42ef8c.entry.js +0 -4
  251. package/dist/twilight/p-tacIS_Xg.js +0 -9
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,c as s,h as i,H as e,a as n}from"./p-CV1rqKQz.js";import{A as o,a as l}from"./p-Vqpj4CWE.js";const d=class{constructor(i){t(this,i),this.optionsSaved=s(this,"optionsSaved"),this.productSelected=s(this,"productSelected"),this.product=null,this.sectionId=null,this.sectionIndex=0,this.productIndex=0,this.selectedOptions={},this.optionsResetTokens={},this.isLoading=!1,this.hasUnsavedChanges=!1,this.validationErrors=[]}generateCacheKey(t,s,i){return`${t||"unknown"}-${s||0}-${i||"unknown"}`}handleProductChange(t){setTimeout((()=>{this.modal&&t&&this.modal.setTitle(t.name||"")}),100),this.validationErrors=[],this.hasUnsavedChanges=!1}async open(){this.modal?(this.isLoading=!0,this.product?.name&&this.modal.setTitle(this.product.name),this.modal.open(),setTimeout((async()=>{this.product?.id&&await this.initializeSelectedOptions(),this.product?.name&&this.modal.setTitle(this.product.name),this.modal.stopLoading(),this.isLoading=!1}),300)):requestAnimationFrame((()=>this.open()))}async close(){this.modal&&this.modal.close()}async refreshOptionsState(){this.selectedOptions={...this.selectedOptions}}componentDidLoad(){this.modalOpenListener=t=>{this.product=t.product,this.sectionId=t.sectionId||null,this.sectionIndex=t.sectionIndex||0,this.productIndex=t.productIndex||0,this.open()},salla.event.on("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener=t=>{t&&t.productId&&this.clearProductOptions(t.productId,t.sectionId,t.productIndex)},salla.event.on("multiple-bundle-product-modal::clear-options",this.clearOptionsListener),this.optionChangeListener=t=>{const s=t.detail||t,{option:i,detail:e}=s,n=i||s.option_id&&this.product?.options?.find((t=>t.id===s.option_id||String(t.id)===String(s.option_id))),o=e||(s.id?s:null);this.product?.id&&n&&this.handleOptionChange(Number(this.product.id),n,o)},salla.event.on("product-options::change",this.optionChangeListener),this.checkboxChangeListener=t=>{const s=t.target;if(s&&"checkbox"===s.type&&s.name&&s.name.includes("bundle[")&&s.name.includes("][id]")){const t=s.name.match(/^bundle\[([^\]]+)\]\[([^\]]+)\]\[id\]$/);if(t&&!s.checked){const[,i,e]=t,n=s.value,o=this.host.closest("form");this.cleanupProductDeselection({sectionId:i,productIndex:parseInt(e,10),productId:n,form:o,uncheckedInput:s})}}},document.addEventListener("change",this.checkboxChangeListener)}disconnectedCallback(){this.checkboxChangeListener&&document.removeEventListener("change",this.checkboxChangeListener),this.optionChangeListener&&salla.event.off("product-options::change",this.optionChangeListener),this.modalOpenListener&&salla.event.off("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener&&salla.event.off("multiple-bundle-product-modal::clear-options",this.clearOptionsListener)}cleanupProductDeselection(t){const{sectionId:s,productIndex:i,productId:e,form:n,uncheckedInput:o}=t;if(this.clearProductOptions(e,s,i),n){const t=`bundle[${s}][${i}]`;Array.from(n.querySelectorAll(`input[name^="${t}"]`)).forEach((s=>{if(s===o)return;const i="hidden"===s.type,n=s.getAttribute("data-product-id")===String(e)&&s.name?.startsWith(t);(i||n)&&s.remove()})),requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});n.dispatchEvent(t)}))}}generateFormInputName(t,s,i){return`bundle[${t}][${s}][options][${i}]`}async initializeSelectedOptions(){if(!this.product?.id)return;const t=this.product.id,s=this.generateCacheKey(this.sectionId,this.productIndex,t),i=document.querySelector(`salla-product-options[product-id="${t}"]`);if(i)try{const t=await i.getSelectedOptions();t&&t.length>0&&(this.selectedOptions={...this.selectedOptions,[s]:t})}catch(t){console.warn("Could not initialize selected options:",t)}}clearProductOptions(t,s,i){const e={...this.selectedOptions};if(null==s||null==i||Number.isNaN(i)){const s=`-${String(t)}`,i=[];Object.keys(e).forEach((t=>{t.endsWith(s)&&(delete e[t],i.push(t))})),i.forEach((t=>this.bumpOptionsResetToken(t)))}else{const n=this.generateCacheKey(s,i,t);delete e[n],this.bumpOptionsResetToken(n)}this.selectedOptions=e,this.validationErrors=[],this.hasUnsavedChanges=!1}bumpOptionsResetToken(t){t&&(this.optionsResetTokens={...this.optionsResetTokens,[t]:(this.optionsResetTokens[t]||0)+1})}async handleOptionChange(t,s,i){const e=this.generateCacheKey(this.sectionId,this.productIndex,t),n=document.querySelector(`salla-product-options[product-id="${t}"]`);let o=[];if(n)try{o=await n.getSelectedOptions()||[]}catch(t){console.warn("Could not get current selections from component:",t)}if(o.length>0)this.selectedOptions={...this.selectedOptions,[e]:o};else if(this.selectedOptions[e]&&this.selectedOptions[e].length>0){const t=[...this.selectedOptions[e]||[]],n=t.findIndex((t=>t.option_id===s.id));n>-1?i&&null!=i.id?t[n]={...i,option_id:s.id}:t.splice(n,1):i&&null!=i.id&&t.push({...i,option_id:s.id}),this.selectedOptions={...this.selectedOptions,[e]:t}}else i&&null!=i.id&&(this.selectedOptions={...this.selectedOptions,[e]:[{...i,option_id:s.id}]});this.hasUnsavedChanges=!0,this.validationErrors=[]}async validateOptions(){if(!this.product?.options)return!0;const t=[],s=this.product.id,i=this.generateCacheKey(this.sectionId,this.productIndex,s),e=document.querySelector(`salla-product-options[product-id="${s}"]`);let n=[];if(e)try{n=await e.getSelectedOptions()||[];const t=this.selectedOptions[i]||[];(t.length>n.length||0===n.length&&t.length>0)&&(n=t)}catch(t){n=this.selectedOptions[i]||[]}else n=this.selectedOptions[i]||[];return 0===n.length&&t.push(salla.lang.get("pages.products.no_options_selected")),this.product.options.forEach((s=>{s.required&&(n.some((t=>t.option_id==s.id))||t.push(salla.lang.get("pages.products.required_option_missing",{option:s.name})))})),this.validationErrors=t,0===t.length}async onSave(t){t.preventDefault();const s=this.product?.id;if(!s)return;const i=this.generateCacheKey(this.sectionId,this.productIndex,s);if(await new Promise((t=>setTimeout(t,100))),await this.validateOptions()){this.isLoading=!0;try{const t=document.querySelector(`salla-product-options[product-id="${s}"]`);let e=await(t?.getSelectedOptions());if((!e||0===e.length)&&this.selectedOptions[i]?.length>0&&(e=this.selectedOptions[i]),!e||0===e.length)return void(this.isLoading=!1);this.selectedOptions={...this.selectedOptions,[i]:e};const n=this.host.closest("form");if(!n)return void(this.isLoading=!1);const o=`bundle[${this.sectionId}][${this.productIndex}]`;Array.from(n.querySelectorAll(`input[name^="${o}"][type="hidden"]`)).forEach((t=>t.remove())),Array.from(n.querySelectorAll(`[data-product-id="${s}"][name^="${o}"]`)).forEach((t=>t.remove()));const l=`bundle[${this.sectionId}][${this.productIndex}][id]`,d=document.getElementById(l);if(d)d.checked=!0;else{const t=document.createElement("input");t.type="hidden",t.name=`bundle[${this.sectionId}][${this.productIndex}][id]`,t.value=String(s),t.dataset.productId=String(s),n.appendChild(t)}e.forEach((t=>{const i=t.option_id,e=document.createElement("input");e.type="hidden",e.name=this.generateFormInputName(this.sectionId,this.productIndex??0,i),e.value=String(t.id),e.dataset.productId=String(s),n.appendChild(e)}));const a=new window.Event("change",{bubbles:!0});n.dispatchEvent(a),this.optionsSaved.emit({productId:Number(s),selectedOptions:e,sectionId:this.sectionId,productIndex:this.productIndex}),this.sectionId&&this.productSelected.emit({productId:Number(s),sectionId:this.sectionId,product:this.product,fromModal:!0}),salla.notify.success(salla.lang.get("pages.products.options_saved")),this.hasUnsavedChanges=!1,this.validationErrors=[],this.modal.close()}catch(t){salla.notify.error(salla.lang.get("pages.products.options_save_error"))}finally{this.isLoading=!1}}else salla.notify.error(this.validationErrors.join(", "))}getOptionsWithSelectedState(){if(!this.product?.options)return[];const t=this.generateCacheKey(this.sectionId,this.productIndex,this.product.id),s=this.selectedOptions[t]||[];return this.product.options.map((t=>({...t,details:t.details.map((t=>{const i=s.some((s=>s.id===t.id));return{...t,is_selected:i}}))})))}render(){const t=this.product?.id,s=this.getOptionsWithSelectedState(),n=this.generateCacheKey(this.sectionId,this.productIndex,t),o=this.optionsResetTokens[n]||0,l=this.isLoading||s.some((t=>t.details.some((t=>t.is_selected&&!0===t.is_out))));return i(e,{key:"28786c060499c9bfbacf025b75f21d0e8a2d6ab1"},i("salla-modal",{key:"6322c0542ca2769f50ed6fc616c6d5c72d456c9c",isLoading:this.isLoading,ref:t=>this.modal=t,width:"md",centered:!1,id:`s-multiple-bundle-product-options-modal-options-${t}`,class:"s-multiple-bundle-product-options-modal-wrapper"},i("div",{key:"812707c4108b5bdefa97e1ff7537998083e2403b",slot:"loading"},i("salla-skeleton",{key:"e82b875495873b66414ee4a75d845823373b4914",height:"100%",width:"100%"})),this.product?.images&&this.product?.images.length>0&&i("salla-slider",{key:"f1f3545637b182257f9107972a819ae9819de137",id:`details-slider-${this.product?.id}`,type:"thumbs",loop:!1,"auto-height":!0,"listen-to-thumbnails-option":!0,showThumbsControls:!1,controlsOuter:!1,showControls:!1,class:"s-multiple-bundle-product-options-modal-slider",verticalThumbs:!0,thumbsConfig:{centeredSlides:!0,centeredSlidesBounds:!0,slidesPerView:Math.min(5,Math.max(1,this.product?.images.length)),watchOverflow:!0,watchSlidesProgress:!0,direction:"vertical",spaceBetween:10}},i("div",{key:"97b50195903a01376e057bc99ddb353fd3dfdb2b",slot:"items"},this.product?.images&&this.product?.images.map(((t,s)=>i("div",{key:s,class:"swiper-slide"},i("img",{src:t.url,alt:t.alt||`${this.product?.name} - Image ${s+1}`,loading:"lazy",onError:t=>{t.target.style.display="none"}}))))),this.product?.images&&this.product?.images.length>1&&i("div",{key:"ff943c9c8f175ff1c0374a13153b33889c468dda",slot:"thumbs"},this.product?.images&&this.product?.images.map(((t,s)=>i("div",{key:s,"data-caption":`${this.product?.name} - Image ${s+1}`},i("img",{src:t.url,loading:"eager",class:"s-multiple-bundle-product-options-modal-slider-thumb",title:`${this.product?.name} - ${s+1}`,alt:t.alt||`${this.product?.name} - ${s+1}`,onError:t=>{t.target.style.display="none"}})))))),i("salla-product-options",{options:JSON.stringify(s),key:`${n}-reset-${o}`,"product-id":t,"unique-key":`${n}-reset-${o}`}),i("div",{key:"7555836d26018f6405bc54a1cd735b4030d4bdf1",slot:"footer"},i("div",{key:"a7ee5f19a4c11a1c61e4dc026fa8673e0ab74c3f",class:"s-multiple-bundle-product-options-modal-footer"},i("salla-button",{key:"1da19964053766f3a1339ea0e77ab7aaa4d8a003",onClick:t=>this.onSave(t),loading:this.isLoading,disabled:l},this.isLoading?salla.lang.get("common.elements.saving"):salla.lang.get("common.elements.save"))))))}get host(){return n(this)}static get watchers(){return{product:["handleProductChange"]}}};d.style=":host{display:block}";const a=class{constructor(i){t(this,i),this.productSelected=s(this,"productSelected"),this.productOptionsSelected=s(this,"productOptionsSelected"),this.selectedProducts={},this.savedOptionsByInstance={},this.handleProductClick=(t,s)=>{const i=this.generateEventName(this.section.id,s),e=document.getElementById(i);if(e){if(e){const i=!e.checked;i||(this.dispatchClearOptionsEvent(t,s),this.clearSavedOptionsState(this.section.id,s)),e.checked=i,requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});e.dispatchEvent(t)}))}this.productSelected.emit({product:t,sectionId:this.section.id})}},this.handleOptionsClick=t=>{this.productOptionsSelected.emit({product:t,sectionId:this.section.id})}}getProductInstanceKey(t,s){return`${t}::${s}`}dispatchClearOptionsEvent(t,s){salla.event.dispatch("multiple-bundle-product-modal::clear-options",{productId:t.id,sectionId:this.section.id,sectionIndex:this.sectionIndex,productIndex:s})}handleOptionsSaved(t){const s=t.detail;if(!s)return;const{sectionId:i,productIndex:e,selectedOptions:n}=s;if(null==i||i!==this.section?.id)return;if(null==e||Number.isNaN(e))return;const o=this.getProductInstanceKey(i,e);if(n?.length)this.savedOptionsByInstance={...this.savedOptionsByInstance,[o]:!0};else if(this.savedOptionsByInstance[o]){const t={...this.savedOptionsByInstance};delete t[o],this.savedOptionsByInstance=t}}clearSavedOptionsState(t,s){const i=this.getProductInstanceKey(t,s);if(!this.savedOptionsByInstance[i])return;const e={...this.savedOptionsByInstance};delete e[i],this.savedOptionsByInstance=e}generateEventName(t,s){return`bundle[${t}][${s}][id]`}render(){return i(e,{key:"a1e7d56d8a50d1c31ba102d3246b0251516e0a73"},i("salla-slider",{key:"8308576a46ec71f557a3d686d59cd0109d5bef0f",type:"carousel",controlsOuter:!1,showControls:!1,id:`accordion-multiple-bundle-product-${this.section.id}`,pagination:!0,class:"s-multiple-bundle-product-wrapper-slider",sliderConfig:{spaceBetween:0}},i("div",{key:"3ea742119ab77f129b8c60bbcc0f8c0f7bd3e97d",slot:"items"},this?.section?.products?.map(((t,s)=>{const e=this.selectedProducts[this.section.id]?.has(t.id)||!1,n=this.savedOptionsByInstance[this.getProductInstanceKey(this.section.id,s)]?salla.lang.getWithDefault("pages.products.edit_selected_options","تعديل الخيارات"):salla.lang.get("pages.products.choose_from_options");let d=salla.config.get("theme.is_rtl",!0)?o:l;return i("div",{class:"s-multiple-bundle-product-slide-one-third "+(0==t.quantity?"s-multiple-bundle-product-slide-one-third-disabled":""),key:t.id},i("div",{class:"s-multiple-bundle-product-card"},i("div",{class:"s-multiple-bundle-product-image-wrapper",onClick:()=>this.handleProductClick(t,s)},i("input",{id:this.generateEventName(this.section.id,s),type:"checkbox",class:"s-multiple-bundle-product-checkbox",checked:e,name:this.generateEventName(this.section.id,s),value:t.id}),i("img",{src:t.image.url||salla.url.cdn("images/s-empty.png"),loading:"lazy",alt:t.image.alt||t.name,class:"s-multiple-bundle-product-image"})),i("div",{class:"s-multiple-bundle-product-content-wrapper"},i("div",{class:"s-multiple-bundle-product-content"},i("div",{class:"s-multiple-bundle-product-details"},i("div",{class:"s-multiple-bundle-product-title-wrapper"},i("h2",{class:"s-multiple-bundle-product-title"},i("a",{href:t?.url||"#",target:"_blank",rel:"noopener noreferrer"},t.name))),i("div",{class:"s-multiple-bundle-product-price-wrapper"},i("span",{class:"s-multiple-bundle-product-price"},i("span",{innerHTML:salla.money(t.price)})),t.sale_price>0&&i("span",{class:"s-multiple-bundle-product-price-discount"},i("span",{innerHTML:salla.money(t.regular_price)})))),t.quantity_in_group>0&&0!==t.quantity&&i("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.pieces"),i("span",null,t.quantity_in_group)),0===t.quantity&&i("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.quantity_in_group_finished"))),t.options?.length>0&&i("button",{class:"s-multiple-bundle-product-button",onClick:()=>this.handleOptionsClick(t),type:"button"},n,i("span",{class:"s-multiple-bundle-product-button-icon",innerHTML:d})))))})))))}get host(){return n(this)}};a.style="";export{d as salla_multiple_bundle_product_options_modal,a as salla_multiple_bundle_product_slider}
4
+ import{r as t,c as s,h as i,H as e,a as n}from"./p-Y6CiunLU.js";import{A as o,a as l}from"./p-Vqpj4CWE.js";const d=class{constructor(i){t(this,i),this.optionsSaved=s(this,"optionsSaved"),this.productSelected=s(this,"productSelected"),this.product=null,this.sectionId=null,this.sectionIndex=0,this.productIndex=0,this.selectedOptions={},this.optionsResetTokens={},this.isLoading=!1,this.hasUnsavedChanges=!1,this.validationErrors=[]}generateCacheKey(t,s,i){return`${t||"unknown"}-${s||0}-${i||"unknown"}`}handleProductChange(t){setTimeout((()=>{this.modal&&t&&this.modal.setTitle(t.name||"")}),100),this.validationErrors=[],this.hasUnsavedChanges=!1}async open(){this.modal?(this.isLoading=!0,this.product?.name&&this.modal.setTitle(this.product.name),this.modal.open(),setTimeout((async()=>{this.product?.id&&await this.initializeSelectedOptions(),this.product?.name&&this.modal.setTitle(this.product.name),this.modal.stopLoading(),this.isLoading=!1}),300)):requestAnimationFrame((()=>this.open()))}async close(){this.modal&&this.modal.close()}async refreshOptionsState(){this.selectedOptions={...this.selectedOptions}}componentDidLoad(){this.modalOpenListener=t=>{this.product=t.product,this.sectionId=t.sectionId||null,this.sectionIndex=t.sectionIndex||0,this.productIndex=t.productIndex||0,this.open()},salla.event.on("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener=t=>{t&&t.productId&&this.clearProductOptions(t.productId,t.sectionId,t.productIndex)},salla.event.on("multiple-bundle-product-modal::clear-options",this.clearOptionsListener),this.optionChangeListener=t=>{const s=t.detail||t,{option:i,detail:e}=s,n=i||s.option_id&&this.product?.options?.find((t=>t.id===s.option_id||String(t.id)===String(s.option_id))),o=e||(s.id?s:null);this.product?.id&&n&&this.handleOptionChange(Number(this.product.id),n,o)},salla.event.on("product-options::change",this.optionChangeListener),this.checkboxChangeListener=t=>{const s=t.target;if(s&&"checkbox"===s.type&&s.name&&s.name.includes("bundle[")&&s.name.includes("][id]")){const t=s.name.match(/^bundle\[([^\]]+)\]\[([^\]]+)\]\[id\]$/);if(t&&!s.checked){const[,i,e]=t,n=s.value,o=this.host.closest("form");this.cleanupProductDeselection({sectionId:i,productIndex:parseInt(e,10),productId:n,form:o,uncheckedInput:s})}}},document.addEventListener("change",this.checkboxChangeListener)}disconnectedCallback(){this.checkboxChangeListener&&document.removeEventListener("change",this.checkboxChangeListener),this.optionChangeListener&&salla.event.off("product-options::change",this.optionChangeListener),this.modalOpenListener&&salla.event.off("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener&&salla.event.off("multiple-bundle-product-modal::clear-options",this.clearOptionsListener)}cleanupProductDeselection(t){const{sectionId:s,productIndex:i,productId:e,form:n,uncheckedInput:o}=t;if(this.clearProductOptions(e,s,i),n){const t=`bundle[${s}][${i}]`;Array.from(n.querySelectorAll(`input[name^="${t}"]`)).forEach((s=>{if(s===o)return;const i="hidden"===s.type,n=s.getAttribute("data-product-id")===String(e)&&s.name?.startsWith(t);(i||n)&&s.remove()})),requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});n.dispatchEvent(t)}))}}generateFormInputName(t,s,i){return`bundle[${t}][${s}][options][${i}]`}async initializeSelectedOptions(){if(!this.product?.id)return;const t=this.product.id,s=this.generateCacheKey(this.sectionId,this.productIndex,t),i=document.querySelector(`salla-product-options[product-id="${t}"]`);if(i)try{const t=await i.getSelectedOptions();t&&t.length>0&&(this.selectedOptions={...this.selectedOptions,[s]:t})}catch(t){console.warn("Could not initialize selected options:",t)}}clearProductOptions(t,s,i){const e={...this.selectedOptions};if(null==s||null==i||Number.isNaN(i)){const s=`-${String(t)}`,i=[];Object.keys(e).forEach((t=>{t.endsWith(s)&&(delete e[t],i.push(t))})),i.forEach((t=>this.bumpOptionsResetToken(t)))}else{const n=this.generateCacheKey(s,i,t);delete e[n],this.bumpOptionsResetToken(n)}this.selectedOptions=e,this.validationErrors=[],this.hasUnsavedChanges=!1}bumpOptionsResetToken(t){t&&(this.optionsResetTokens={...this.optionsResetTokens,[t]:(this.optionsResetTokens[t]||0)+1})}async handleOptionChange(t,s,i){const e=this.generateCacheKey(this.sectionId,this.productIndex,t),n=document.querySelector(`salla-product-options[product-id="${t}"]`);let o=[];if(n)try{o=await n.getSelectedOptions()||[]}catch(t){console.warn("Could not get current selections from component:",t)}if(o.length>0)this.selectedOptions={...this.selectedOptions,[e]:o};else if(this.selectedOptions[e]&&this.selectedOptions[e].length>0){const t=[...this.selectedOptions[e]||[]],n=t.findIndex((t=>t.option_id===s.id));n>-1?i&&null!=i.id?t[n]={...i,option_id:s.id}:t.splice(n,1):i&&null!=i.id&&t.push({...i,option_id:s.id}),this.selectedOptions={...this.selectedOptions,[e]:t}}else i&&null!=i.id&&(this.selectedOptions={...this.selectedOptions,[e]:[{...i,option_id:s.id}]});this.hasUnsavedChanges=!0,this.validationErrors=[]}async validateOptions(){if(!this.product?.options)return!0;const t=[],s=this.product.id,i=this.generateCacheKey(this.sectionId,this.productIndex,s),e=document.querySelector(`salla-product-options[product-id="${s}"]`);let n=[];if(e)try{n=await e.getSelectedOptions()||[];const t=this.selectedOptions[i]||[];(t.length>n.length||0===n.length&&t.length>0)&&(n=t)}catch(t){n=this.selectedOptions[i]||[]}else n=this.selectedOptions[i]||[];return 0===n.length&&t.push(salla.lang.get("pages.products.no_options_selected")),this.product.options.forEach((s=>{s.required&&(n.some((t=>t.option_id==s.id))||t.push(salla.lang.get("pages.products.required_option_missing",{option:s.name})))})),this.validationErrors=t,0===t.length}async onSave(t){t.preventDefault();const s=this.product?.id;if(!s)return;const i=this.generateCacheKey(this.sectionId,this.productIndex,s);if(await new Promise((t=>setTimeout(t,100))),await this.validateOptions()){this.isLoading=!0;try{const t=document.querySelector(`salla-product-options[product-id="${s}"]`);let e=await(t?.getSelectedOptions());if((!e||0===e.length)&&this.selectedOptions[i]?.length>0&&(e=this.selectedOptions[i]),!e||0===e.length)return void(this.isLoading=!1);this.selectedOptions={...this.selectedOptions,[i]:e};const n=this.host.closest("form");if(!n)return void(this.isLoading=!1);const o=`bundle[${this.sectionId}][${this.productIndex}]`;Array.from(n.querySelectorAll(`input[name^="${o}"][type="hidden"]`)).forEach((t=>t.remove())),Array.from(n.querySelectorAll(`[data-product-id="${s}"][name^="${o}"]`)).forEach((t=>t.remove()));const l=`bundle[${this.sectionId}][${this.productIndex}][id]`,d=document.getElementById(l);if(d)d.checked=!0;else{const t=document.createElement("input");t.type="hidden",t.name=`bundle[${this.sectionId}][${this.productIndex}][id]`,t.value=String(s),t.dataset.productId=String(s),n.appendChild(t)}e.forEach((t=>{const i=t.option_id,e=document.createElement("input");e.type="hidden",e.name=this.generateFormInputName(this.sectionId,this.productIndex??0,i),e.value=String(t.id),e.dataset.productId=String(s),n.appendChild(e)}));const a=new window.Event("change",{bubbles:!0});n.dispatchEvent(a),this.optionsSaved.emit({productId:Number(s),selectedOptions:e,sectionId:this.sectionId,productIndex:this.productIndex}),this.sectionId&&this.productSelected.emit({productId:Number(s),sectionId:this.sectionId,product:this.product,fromModal:!0}),salla.notify.success(salla.lang.get("pages.products.options_saved")),this.hasUnsavedChanges=!1,this.validationErrors=[],this.modal.close()}catch(t){salla.notify.error(salla.lang.get("pages.products.options_save_error"))}finally{this.isLoading=!1}}else salla.notify.error(this.validationErrors.join(", "))}getOptionsWithSelectedState(){if(!this.product?.options)return[];const t=this.generateCacheKey(this.sectionId,this.productIndex,this.product.id),s=this.selectedOptions[t]||[];return this.product.options.map((t=>({...t,details:t.details.map((t=>{const i=s.some((s=>s.id===t.id));return{...t,is_selected:i}}))})))}render(){const t=this.product?.id,s=this.getOptionsWithSelectedState(),n=this.generateCacheKey(this.sectionId,this.productIndex,t),o=this.optionsResetTokens[n]||0,l=this.isLoading||s.some((t=>t.details.some((t=>t.is_selected&&!0===t.is_out))));return i(e,{key:"28786c060499c9bfbacf025b75f21d0e8a2d6ab1"},i("salla-modal",{key:"6322c0542ca2769f50ed6fc616c6d5c72d456c9c",isLoading:this.isLoading,ref:t=>this.modal=t,width:"md",centered:!1,id:`s-multiple-bundle-product-options-modal-options-${t}`,class:"s-multiple-bundle-product-options-modal-wrapper"},i("div",{key:"812707c4108b5bdefa97e1ff7537998083e2403b",slot:"loading"},i("salla-skeleton",{key:"e82b875495873b66414ee4a75d845823373b4914",height:"100%",width:"100%"})),this.product?.images&&this.product?.images.length>0&&i("salla-slider",{key:"f1f3545637b182257f9107972a819ae9819de137",id:`details-slider-${this.product?.id}`,type:"thumbs",loop:!1,"auto-height":!0,"listen-to-thumbnails-option":!0,showThumbsControls:!1,controlsOuter:!1,showControls:!1,class:"s-multiple-bundle-product-options-modal-slider",verticalThumbs:!0,thumbsConfig:{centeredSlides:!0,centeredSlidesBounds:!0,slidesPerView:Math.min(5,Math.max(1,this.product?.images.length)),watchOverflow:!0,watchSlidesProgress:!0,direction:"vertical",spaceBetween:10}},i("div",{key:"97b50195903a01376e057bc99ddb353fd3dfdb2b",slot:"items"},this.product?.images&&this.product?.images.map(((t,s)=>i("div",{key:s,class:"swiper-slide"},i("img",{src:t.url,alt:t.alt||`${this.product?.name} - Image ${s+1}`,loading:"lazy",onError:t=>{t.target.style.display="none"}}))))),this.product?.images&&this.product?.images.length>1&&i("div",{key:"ff943c9c8f175ff1c0374a13153b33889c468dda",slot:"thumbs"},this.product?.images&&this.product?.images.map(((t,s)=>i("div",{key:s,"data-caption":`${this.product?.name} - Image ${s+1}`},i("img",{src:t.url,loading:"eager",class:"s-multiple-bundle-product-options-modal-slider-thumb",title:`${this.product?.name} - ${s+1}`,alt:t.alt||`${this.product?.name} - ${s+1}`,onError:t=>{t.target.style.display="none"}})))))),i("salla-product-options",{options:JSON.stringify(s),key:`${n}-reset-${o}`,"product-id":t,"unique-key":`${n}-reset-${o}`}),i("div",{key:"7555836d26018f6405bc54a1cd735b4030d4bdf1",slot:"footer"},i("div",{key:"a7ee5f19a4c11a1c61e4dc026fa8673e0ab74c3f",class:"s-multiple-bundle-product-options-modal-footer"},i("salla-button",{key:"1da19964053766f3a1339ea0e77ab7aaa4d8a003",onClick:t=>this.onSave(t),loading:this.isLoading,disabled:l},this.isLoading?salla.lang.get("common.elements.saving"):salla.lang.get("common.elements.save"))))))}get host(){return n(this)}static get watchers(){return{product:["handleProductChange"]}}};d.style=":host{display:block}";const a=class{constructor(i){t(this,i),this.productSelected=s(this,"productSelected"),this.productOptionsSelected=s(this,"productOptionsSelected"),this.selectedProducts={},this.savedOptionsByInstance={},this.handleProductClick=(t,s)=>{const i=this.generateEventName(this.section.id,s),e=document.getElementById(i);if(e){if(e){const i=!e.checked;i||(this.dispatchClearOptionsEvent(t,s),this.clearSavedOptionsState(this.section.id,s)),e.checked=i,requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});e.dispatchEvent(t)}))}this.productSelected.emit({product:t,sectionId:this.section.id})}},this.handleOptionsClick=t=>{this.productOptionsSelected.emit({product:t,sectionId:this.section.id})}}getProductInstanceKey(t,s){return`${t}::${s}`}dispatchClearOptionsEvent(t,s){salla.event.dispatch("multiple-bundle-product-modal::clear-options",{productId:t.id,sectionId:this.section.id,sectionIndex:this.sectionIndex,productIndex:s})}handleOptionsSaved(t){const s=t.detail;if(!s)return;const{sectionId:i,productIndex:e,selectedOptions:n}=s;if(null==i||i!==this.section?.id)return;if(null==e||Number.isNaN(e))return;const o=this.getProductInstanceKey(i,e);if(n?.length)this.savedOptionsByInstance={...this.savedOptionsByInstance,[o]:!0};else if(this.savedOptionsByInstance[o]){const t={...this.savedOptionsByInstance};delete t[o],this.savedOptionsByInstance=t}}clearSavedOptionsState(t,s){const i=this.getProductInstanceKey(t,s);if(!this.savedOptionsByInstance[i])return;const e={...this.savedOptionsByInstance};delete e[i],this.savedOptionsByInstance=e}generateEventName(t,s){return`bundle[${t}][${s}][id]`}render(){return i(e,{key:"a1e7d56d8a50d1c31ba102d3246b0251516e0a73"},i("salla-slider",{key:"8308576a46ec71f557a3d686d59cd0109d5bef0f",type:"carousel",controlsOuter:!1,showControls:!1,id:`accordion-multiple-bundle-product-${this.section.id}`,pagination:!0,class:"s-multiple-bundle-product-wrapper-slider",sliderConfig:{spaceBetween:0}},i("div",{key:"3ea742119ab77f129b8c60bbcc0f8c0f7bd3e97d",slot:"items"},this?.section?.products?.map(((t,s)=>{const e=this.selectedProducts[this.section.id]?.has(t.id)||!1,n=this.savedOptionsByInstance[this.getProductInstanceKey(this.section.id,s)]?salla.lang.getWithDefault("pages.products.edit_selected_options","تعديل الخيارات"):salla.lang.get("pages.products.choose_from_options");let d=salla.config.get("theme.is_rtl",!0)?o:l;return i("div",{class:"s-multiple-bundle-product-slide-one-third "+(0==t.quantity?"s-multiple-bundle-product-slide-one-third-disabled":""),key:t.id},i("div",{class:"s-multiple-bundle-product-card"},i("div",{class:"s-multiple-bundle-product-image-wrapper",onClick:()=>this.handleProductClick(t,s)},i("input",{id:this.generateEventName(this.section.id,s),type:"checkbox",class:"s-multiple-bundle-product-checkbox",checked:e,name:this.generateEventName(this.section.id,s),value:t.id}),i("img",{src:t.image.url||salla.url.cdn("images/s-empty.png"),loading:"lazy",alt:t.image.alt||t.name,class:"s-multiple-bundle-product-image"})),i("div",{class:"s-multiple-bundle-product-content-wrapper"},i("div",{class:"s-multiple-bundle-product-content"},i("div",{class:"s-multiple-bundle-product-details"},i("div",{class:"s-multiple-bundle-product-title-wrapper"},i("h2",{class:"s-multiple-bundle-product-title"},i("a",{href:t?.url||"#",target:"_blank",rel:"noopener noreferrer"},t.name))),i("div",{class:"s-multiple-bundle-product-price-wrapper"},i("span",{class:"s-multiple-bundle-product-price"},i("span",{innerHTML:salla.money(t.price)})),t.sale_price>0&&i("span",{class:"s-multiple-bundle-product-price-discount"},i("span",{innerHTML:salla.money(t.regular_price)})))),t.quantity_in_group>0&&0!==t.quantity&&i("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.pieces"),i("span",null,t.quantity_in_group)),0===t.quantity&&i("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.quantity_in_group_finished"))),t.options?.length>0&&i("button",{class:"s-multiple-bundle-product-button",onClick:()=>this.handleOptionsClick(t),type:"button"},n,i("span",{class:"s-multiple-bundle-product-button-icon",innerHTML:d})))))})))))}get host(){return n(this)}};a.style="";export{d as salla_multiple_bundle_product_options_modal,a as salla_multiple_bundle_product_slider}
@@ -0,0 +1,4 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import{r as t,c as a,h as s,H as i,a as e,e as l}from"./p-Y6CiunLU.js";import{P as o}from"./p-DY4LZmNP.js";import{H as n}from"./p-CHf8XdiS.js";import{B as p}from"./p-D3mWkc-3.js";import{i as r}from"./p-BsXh13x8.js";import{C as d}from"./p-C6jIkM-X.js";import"./p-CgtvEd63.js";const c=class{constructor(s){t(this,s),this.success=a(this,"success"),this.failed=a(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.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?o: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 a=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);return a&&"function"==typeof a.validateAndScroll?a.validateAndScroll().then((async t=>{const a={isValid:t,component:this};if(await salla.hooks.call("salla-add-product-button","validate",a),a.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"),a=Object.entries({id:this.productId,donation_amount:this.donatingAmount,quantity:this.quantity,endpoint:"quickAdd",source:n.getProductsSource(t?.getAttribute("source"))}).reduce(((t,[a,s])=>s?(t[a]=s,t):t),{});return salla.cart.addItem(a).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}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 s("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"},s("div",{slot:"widget-label",class:"s-add-product-button-mini-checkout-content"},s("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?s(i,null,s("salla-product-availability",{...this.getBtnAttributes(),"is-subscribed":!0},s("span",{class:"s-hidden"},s("slot",null)))):"out-and-notify"===this.productStatus&&this.channels||this.hasOutOfStockOption?s(i,null,s("salla-product-availability",{...this.getBtnAttributes()},s("span",{class:"s-hidden"},s("slot",null)))):s(i,{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}},s("div",{class:{"s-add-product-button-main":this.showQuickBuy,"w-full":!document.getElementById("fast-checkout-js")||["financial_support","donating"].includes(this.productType)}},s("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"},s("slot",null)),this.showQuickBuy&&document.getElementById("fast-checkout-js")&&!["financial_support","donating"].includes(this.productType)?this.miniCheckoutWidget():""),this.showQuickBuy&&this.isApplePayActive?s("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 a=salla.storage.get(`product-${this.productId}-subscribed-options`);if((a||this.subscribedOptions)&&this.hasOutOfStockOption)if(salla.config.isGuest()){const t=a?a.map((t=>t.split(",").map((t=>parseInt(t))))):[];this.hasSubscribedOptions=t.length>0&&t.some((t=>t.every((t=>this.selectedOptions.some((a=>a.id===t))))))}else this.hasSubscribedOptions=!(!this.subscribedOptions||"null"===this.subscribedOptions||"[]"===this.subscribedOptions)&&JSON.parse(this.subscribedOptions).some((t=>t.every((t=>this.selectedOptions.some((a=>a.id===t))))))}))}componentDidRender(){!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)}};c.style=":host{display:block}salla-add-product-button[width=wide]{width:100%}";const h=class{constructor(a){t(this,a),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 a=document.querySelector(`salla-product-options[product-id="${this.productId}"]`),s=Object.values(await(a?.getSelectedOptionsData())||{});if(s.length&&!await(a?.reportValidity())){let t=salla.lang.get("common.messages.required_fields");throw salla.error(t),t}return t.options=[],s.forEach((a=>{a&&!isNaN(a)&&t.options.push(Number(a))})),t},this.typing=t=>{const a=t.target.nextElementSibling;t.target.classList.remove("s-has-error"),a?.classList.contains("s-product-availability-error-msg")&&(a.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"),this.isVisitorSubscribed=this.notifyOptionsAvailability?"":salla.storage.get(`product-${this.productId}-subscribed`))}channelsWatcher(t){this.channels_=t?t.split(","):[]}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")){let{phone:a,countryCode:s}=await this.mobileInput.getValues();t.country_code=s,t.phone=a}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)return salla.storage.set(`product-${this.productId}-subscribed`,!0),void(this.isSubscribed=!0);if(t.options.length){let a=salla.storage.get(`product-${this.productId}-subscribed-options`)||[],s=t.options.join(",");a.includes(s)?salla.log("already subscribed to this options"):(a.push(s),salla.storage.set(`product-${this.productId}-subscribed-options`,a),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=n.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")&&await this.mobileInput.isValid())return}catch(t){throw"Please insert required fields"}}validateField(t,a){t.classList.add("s-has-error"),t.nextElementSibling.innerText="* "+a}render(){return s(i,{key:"e5b3121a6e352338ff666ba419100150e838e0d2",class:"s-product-availability-wrap"},this.isSubscribed||this.isVisitorSubscribed?s("div",{class:"s-product-availability-subscribed"},s("span",{innerHTML:p,class:"s-product-availability-subs-icon"}),salla.lang.get("pages.products.notify_availability_success")):s("salla-button",{width:"wide",onClick:()=>this.isUser?this.submit():this.openModel()},salla.lang.get("pages.products.notify_availability")),this.isUser||this.isSubscribed||this.isVisitorSubscribed?"":this.renderModal())}renderModal(){return s("salla-modal",{ref:t=>this.modal=t,"modal-title":this.title_,subTitle:salla.lang.get("pages.products.notify_availability_subtitle"),width:"sm"},s("span",{slot:"icon",class:"s-product-availability-header-icon",innerHTML:p}),s("div",{class:"s-product-availability-body"},this.channels_.includes("email")?[s("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.email")),s("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"}),s("span",{class:"s-product-availability-error-msg"})]:"",this.channels_.includes("sms")?[s("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.mobile")),s("salla-tel-input",{ref:t=>this.mobileInput=t,onKeyDown:t=>this.typing(t)})]:""),s("div",{slot:"footer",class:"s-product-availability-footer"},s("salla-button",{class:"modal-cancel-btn",width:"wide",color:"light",fill:"outline",onClick:()=>this.modal.close()},salla.lang.get("common.elements.cancel")),s("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 u,y;h.style="",function(t){t.COLOR="color",t.DATE="date",t.DATETIME="datetime",t.DONATION="donation",t.IMAGE="image",t.MULTIPLE_OPTIONS="multiple-options",t.NUMBER="number",t.SINGLE_OPTION="single-option",t.DIGITAL_CARD_VALUE="digital-code-value",t.COUNTRY="country",t.SPLITTER="splitter",t.TEXT="text",t.TEXTAREA="textarea",t.THUMBNAIL="thumbnail",t.TIME="time",t.RADIO="radio",t.CHECKBOX="checkbox",t.MAP="map",t.FILE="file",t.COLOR_PICKER="color_picker",t.BOOKING="booking"}(u||(u={})),function(t){t.Sar="SAR"}(y||(y={}));const m=class{constructor(i){if(t(this,i),this.changed=a(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.outSkus=[],this.ignoreDefaultCardValue=!1,this.productId=salla.config.get("page.id"),this.handleDonationOptions=(t,a,s)=>{if("custom"===a&&"input"===s){const a=t.target;return salla.helpers.inputDigitsOnly(a),salla.event.emit("product-options::donation-changed",{id:this.productId,price:a.value}),void a.dispatchEvent(new window.Event("change",{bubbles:!0}))}const i="option"===s?String(t.target?.value??""):"";if("option"===s&&"custom"===a&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()),this.isCustomDonation="custom"===i,this.donationInput){if("custom"===i?(this.donationInput.value="",this.donationInput.focus()):this.donationInput.value=i,"custom"===a)return;salla.event.emit("product-options::donation-changed",{id:this.productId,price:i})}},this.hideLabel=t=>!(t.type!==u.DONATION||!t.donation||t.donation.can_donate),this.getExpireDonationMessage=t=>{if(!t.donation)return;const a=t.donation.target_amount<=t.donation.collected_amount;return s("div",{class:{"s-product-options-donation-message":!0,"s-product-options-donation-completed":a,"s-product-options-donation-expired":!a}},s("p",null,t.donation.target_message),s("span",{innerHTML:a?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.setOptionsData(t.data.options)))}async setOptionsData(t){this.optionsData=t;const a=this;this.optionsData[0]?.details?.forEach((function(t){Object.entries(t.skus_availability||{}).filter((t=>!t[1])).map((t=>a.outSkus.push(Number(t[0]))))}))}async getSelectedOptionsData(){const t={},a=this.host.getElementSallaData(),s=void 0!==this.bundleContext?this.bundleContext:null;return a.forEach(((a,i)=>{if(s){if(i.startsWith("bundle[")&&i.includes("[options][")){const s=i.split("[options][")[1].replace("]","");t[s]=a}}else i.startsWith("options[")&&(t[i.replace("options[","").replace("]","")]=a)})),t}async reportValidity(){const t=this.host.querySelectorAll("[required]");let a=!0;for(let s=0;s<t.length;s++)"reportValidity"in t[s]&&!t[s].reportValidity()&&(a=!1);return a}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((a=>a.id===t))}invalidHandler(t,a){const s=t.target.closest(".s-product-options-option");s.classList.contains("s-product-options-option-error")||s.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")===s&&this.scrollToElement(s)}scrollToElement(t){t&&t.scrollIntoView({behavior:"smooth",block:"center"})}changedHandler(t,a,s=!0){const i={event:t,option:a,detail:null,productId:this.productId};if(a.details){const s=a.details.find((a=>Number(a.id)===Number(t.target.value)));i.detail=s}"country"===a.type&&this.handleCountryOptionChange(t,i.detail);const e=t.target.closest(".s-product-options-option");(t.target.value||(a.type===u.FILE||a.type===u.IMAGE)&&"added"===t.type||a.type===u.MAP&&"selected"===t.type&&t.target.lat&&t.target.lng)&&setTimeout((()=>{e.classList.remove("s-product-options-option-error")}),200),a.type===u.DONATION&&salla.event.emit("product-options::donation-changed",{id:this.productId,price:t.target.value}),this.setSelectedSkus(),this.handleRequiredMultipleOptions(a);const l=this.selectedOptions.findIndex((t=>t.option_id===i.option.id));if(i.option.type===u.MULTIPLE_OPTIONS){const t=this.selectedOptions.findIndex((t=>t.option_id===i.option.id&&t?.id===i.detail?.id));t>-1?this.selectedOptions.splice(t,1):this.selectedOptions.push({...i.detail,option_id:i.option.id})}else i.detail&&0!==Object.keys(i.detail).length?l>-1?this.selectedOptions[l]={...i.detail,option_id:i.option.id}:this.selectedOptions.push({...i.detail,option_id:i.option.id}):l>-1&&this.selectedOptions.splice(l,1);this.optionsData=this.optionsData.map((t=>t.id===i.option.id?{...t,details:t.details.map((t=>({...t,is_selected:i.option.type===u.MULTIPLE_OPTIONS?this.selectedOptions.some((a=>a.id===t.id)):Number(t.id)===Number(i.detail?.id),value:i.detail?.value})))}:t)),s&&(this.changed.emit(i),salla.event.emit("product-options::change",i))}setSelectedSkus(){this.selectedSkus=this.selectedOptions.map((t=>Object.keys(t.skus_availability||{}))).reduce(((t,a)=>t.filter((t=>a.includes(t)))),[]).map((t=>Number(t)))}handleRequiredMultipleOptions(t){if(t.type!==u.MULTIPLE_OPTIONS||!t.required)return;const a=this.host.querySelector(`[data-option-id="${t.id}"]`),s=a.querySelectorAll("input:checked").length;a.querySelectorAll("input").forEach((t=>t.toggleAttribute("required",!s)))}getLatLng(t,a){return t?t.split(",")["lat"===a?0:1]:""}getDisplayForType(t){return this[`${t.type}Option`]?this[`${t.type}Option`](t):t.type===u.COLOR_PICKER?this.colorPickerOption(t):t.type===u.MULTIPLE_OPTIONS?this.multipleOptions(t):t.type===u.SINGLE_OPTION?this.singleOption(t):t.type===u.RADIO?this.radioOption(t):t.type===u.DIGITAL_CARD_VALUE?this.digitalCardValuesOption(t):t.type===u.COUNTRY?this.countryOption(t):t.type===u.BOOKING&&salla.url.is_page("cart")?s("salla-booking-field",{onInvalidInput:a=>this.invalidHandler(a,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 a=this.optionsData.find((({type:t})=>"digital-code-value"===t));if(!a)throw new Error("product-options:: No digital card options found");const s=Object.keys(t.skus_availability).filter((a=>!1===t.skus_availability[a]));this.availableDigitalCardValues=a.details.filter((t=>!Object.keys(t.skus_availability).filter((t=>s.includes(t))).length))}handleCountryOptionChange(t,a){t.stopImmediatePropagation(),this.ignoreDefaultCardValue=!0;const s=this.host.querySelector("input[data-code-value]:checked");if(s&&(s.checked=!1),!this.optionsData.find((({type:t})=>"digital-code-value"===t)))throw new Error("product-options:: No digital card options found");this.getAvailableDigitalCardSKUs(a)}getSelectedDigitalCardOptions(t){const a=t.details.find((t=>t.is_selected)),s=t.details.find((t=>!!t.is_default))||t.details[0];if(["digital-code-value","country"].includes(t.type))return a||s}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)),a=t&&this.getSelectedDigitalCardOptions(t);a&&this.getAvailableDigitalCardSKUs(a)}return this.outOfStockText=salla.lang.get("pages.products.out_of_stock"),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 a=t.target;if(!(Salla.helpers.isAppleDevice()&&(a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement)&&a.classList.contains("s-form-control")&&this.host.contains(a)))return;t.preventDefault();const s=t.clipboardData?.getData("text")||"",i=a.selectionStart,e=a.selectionEnd,l=a.value.slice(0,i)+s+a.value.slice(e);a.value=l,a.setSelectionRange(i+s.length,i+s.length);try{a.dispatchEvent(new window.Event("change",{bubbles:!0}))}catch(t){Salla.log("Error on change")}}hideDigitalCardsOptions(t){return this.disableCardValue&&t.type===u.DIGITAL_CARD_VALUE&&!salla.url.is_page("cart")}render(){if(0!==this.optionsData?.length)return s(i,{class:"s-product-options-wrapper"},s("salla-conditional-fields",null,this.optionsData.map((t=>s("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():s("div",{class:{"s-product-options-option":!0,"s-product-options-option-booking":t.type===u.BOOKING&&salla.url.is_page("cart")},"data-option-type":t.type,"data-option-required":`${t.required}`},s("label",{htmlFor:this.generateInputId(t.id),class:"s-product-options-option-label "+(this.hideLabel(t)?"s-product-options-option-label-hidden":"")},s("b",null,t.name,t.required&&s("span",null," * ")," "),s("small",null,t.placeholder)),s("div",{class:"s-product-options-option-content "+(this.hideLabel(t)||t.type===u.BOOKING&&salla.url.is_page("cart")?"s-product-options-option-content-full-width":"")},this.getDisplayForType(t))))))))}generateUniqueKey(t){const a=this.bundleContext;let s=this.uniqueKey?`${t}-${this.uniqueKey}`:t;if(a)try{const t="string"==typeof a?JSON.parse(a):a,{sectionId:i,productId:e}=t;s=`${s}-bundle-${i}-${e}`}catch(t){}return s}generateInputId(t){return this.generateUniqueKey(`option-${t}`)}generateInputName(t){const a=this.bundleContext,s=t.toString();if(a)try{const t="string"==typeof a?JSON.parse(a):a,{sectionId:i,productId:e}=t;return`bundle[${i}][${e}][options][${s}]`}catch(t){return`options[${s}]`}return`options[${s}]`}fillSelectedOptions(){this.selectedOptions=this.optionsData.reduce(((t,a)=>{const s=a.details.filter((t=>t.is_selected)).map((t=>({...t,option_id:a.id})));return t.concat(s)}),[])}async componentDidLoad(){if(!this.optionsData?.length)return;await Salla.hooks.registerComponent("salla-product-options",this);const t=this.optionsData.find((t=>t.type===u.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=[u.SINGLE_OPTION,u.MULTIPLE_OPTIONS,u.COLOR,u.THUMBNAIL,u.DONATION,u.DIGITAL_CARD_VALUE,u.COUNTRY];this.optionsData.some((a=>t.includes(a.type)&&a.details?.some((t=>t.is_selected))))&&requestAnimationFrame((()=>{try{const t=this.host.closest("form");if(!t)return;const a=new FormData(t),s=a.get("id")||a.get("product_id");if(s&&String(s)!==String(this.productId))return;salla.product.getPrice(a)}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()}async enableUserInitiatedValidation(){this.userInitiatedValidation=!0}async validateAndScroll(){return await this.enableUserInitiatedValidation(),this.reportValidity()}donationOption(t,a){return s("div",{class:"s-product-options-donation-wrapper"},t.donation?.can_donate?[t.donation?s("div",{key:t.id,class:"s-product-options-donation-progress"},s("salla-progress-bar",{donation:t.donation})):"",t.details.length?[s("h4",{key:t.id},this.selectAmount),s("div",{key:t.id,class:"s-product-options-donation-options"},t.details.map(((a,i)=>s("div",{key:t.id,class:"s-product-options-donation-options-item"},s("input",{id:this.generateUniqueKey(`donation-option-${i}`),type:"radio",name:"donating_option",checked:a.is_selected,value:a.additional_price,onChange:s=>this.handleDonationOptions(s,a,"option",t)}),s("label",{htmlFor:this.generateUniqueKey(`donation-option-${i}`)},s("span",{innerHTML:salla.money(a.name)}))))),t.donation?.custom_amount_enabled?s("div",{class:"s-product-options-donation-options-item"},s("input",{id:this.generateUniqueKey("donation-option-custom"),type:"radio",name:"donating_option",value:"custom",onChange:a=>this.handleDonationOptions(a,"custom","option",t)}),s("label",{htmlFor:this.generateUniqueKey("donation-option-custom")},s("span",null," ",this.selectDonationAmount," "))):"")]:"",s("div",{key:t.id,class:{"s-product-options-donation-input-group":!0,shown:!t.details.length||t.details.length&&this.isCustomDonation}},s("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:a=>this.handleDonationOptions(a,"custom","input",t),onBlur:a=>this.changedHandler(a,t),onInvalid:a=>this.invalidHandler(a,t)}),s("span",{class:"s-product-options-donation-amount-currency"},salla.config.currency(salla.config.get("user.currency_code")).symbol))]:this.getExpireDonationMessage(t))}fileUploader(t,a=null){return s("salla-file-upload",{...a||{},"payload-name":"file",value:t.value,"instant-upload":!0,name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,height:"120px",onAdded:a=>this.changedHandler(a,t),url:salla.cart.api.getUploadImageEndpoint(),"form-data":{cart_item_id:this.productId,product_id:this.productId},onInvalidInput:a=>this.invalidHandler(a,t),class:{"s-product-options-image-input":!0,required:t.required}},s("div",{class:"s-product-options-filepond-placeholder"},s("span",{class:"s-product-options-filepond-placeholder-icon",innerHTML:a.accept?.split(",").every((t=>t.includes("image")))?d:'\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'}),s("p",{class:"s-product-options-filepond-placeholder-text"},salla.lang.get("common.uploader.drag_and_drop")),s("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 a=t.details.map((t=>this.fileTypes[t.name])).filter(Boolean);return a?.length?this.fileUploader(t,{accept:a.join(",")}):"File types not selected."}numberOption(t){return s("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:a=>this.changedHandler(a,t),onInvalid:a=>this.invalidHandler(a,t),onInput:t=>salla.helpers.inputDigitsOnly(t.target)})}splitterOption(){return s("div",{class:"s-product-options-splitter"})}textOption(t){return s("div",{class:"s-product-options-text"},s("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:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t)}))}textareaOption(t){return s("div",{class:"s-product-options-textarea"},s("div",{class:"mt-1"},s("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:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t)})))}mapOption(t){return s("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:a=>this.invalidHandler(a,t),onSelected:a=>this.changedHandler(a,t)})}colorPickerOption(t){return s("salla-color-picker",{onSubmitted:a=>this.changedHandler(a,t),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,onInvalidInput:a=>this.invalidHandler(a,t),color:t.value})}timeOption(t){return s("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:a=>this.invalidHandler(a,t),onPicked:a=>this.changedHandler(a,t)})}dateOption(t){return s("div",{class:"s-product-options-date-element"},s("salla-datetime-picker",{value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,minDate:new Date,name:this.generateInputName(t.id),onInvalidInput:a=>this.invalidHandler(a,t),onPicked:a=>this.changedHandler(a,t)}))}datetimeOption(t){return s("div",{class:"s-product-options-datetime-element"},s("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:a=>this.invalidHandler(a,t),onPicked:a=>this.changedHandler(a,t)}))}getOptionDetailName(t,a=!0,s){let i;return s&&s===u.COLOR&&(i=t.name+(a&&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>`:"")),i||(i=t.name+(a&&this.isOptionDetailOut(t)&&!salla.url.is_page("cart")&&!this.hideOutLabel?` - ${this.outOfStockText}`:"")+(t.additional_price?` (${salla.money(t.additional_price,!1)})`:"")),i.replace("<i class=sicon-sar></i>",salla.config.currency()?.symbol||"ر.س")}isOptionDetailOut(t){if(t.is_out||!t.skus_availability||!this.selectedSkus?.length)return t.is_out;const a=this.selectedOptions.filter((a=>a.id===t.id)).length;if(a&&1===this.selectedOptions.length)return!1;if(a){const a=this.selectedSkus.filter((t=>this.outSkus.includes(t)));return Object.keys(t.skus_availability).some((t=>a.includes(Number(t))))}return this.selectedOptions.some((a=>a.is_out&&a.option_id!==t.option_id))}renderInput(t,a,i,e,l,o){const n=this.generateUniqueKey(`${t}-${i.id}-${a.id}`),p=this.isOptionDetailOut(a);return s("label",{class:{"s-product-options-disabled":p}},s("input",{id:n,type:t,name:l,value:a.id,disabled:p,required:e,checked:a.is_selected,onInvalid:t=>this.invalidHandler(t,i),onChange:t=>this.changedHandler(t,i)}),s("div",{class:{"s-product-options-grid-mode-span":o,"s-product-options-disabled":p}},this.getOptionDetailName(a)))}renderOptionDetails(t,a,s,i=!1){const e=this.generateInputName(a.id),l="radio"===t?e:`${e}[]`;return a?.details.map((e=>this.renderInput(t,e,a,s,l,i)))}renderSelect(t){return s("div",null,s("select",{id:this.generateInputId(t.id),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,class:"s-form-control",onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t)},s("option",{value:""},t.placeholder),t?.details.map((t=>s("option",{key:t.id,value:t.id,disabled:this.canDisabled&&this.isOptionDetailOut(t),selected:t.is_selected},this.getOptionDetailName(t))))))}renderButtonStyle(t,a,i){return s("div",{class:"s-product-options-grid-mode"},this.renderOptionDetails(t,a,i,!0))}singleOption(t){return"button"===this.optionConfig?.["single-option"]?.type?this.renderButtonStyle("radio",t,!t.visibility_condition&&t.required):this.renderSelect(t)}multipleOptions(t){const a="button"===this.optionConfig?.["multiple-option"]?.type,i=t.required&&!t.details.some((t=>t.is_selected))&&!t.visibility_condition;return a?this.renderButtonStyle("checkbox",t,i):s("div",{class:{"s-product-options-multiple-options-wrapper":!0,required:t.required}},this.renderOptionDetails("checkbox",t,i))}radioOption(t){return this.singleOption(t)}colorOption(t){return s("fieldset",{class:"s-product-options-colors-wrapper"},t?.details.map((a=>s("div",{class:"s-product-options-colors-item",key:a.id},s("input",{type:"radio",value:a.id,required:!t.visibility_condition&&t.required,checked:a.is_selected,name:this.generateInputName(t.id),disabled:this.canDisabled&&this.isOptionDetailOut(a),id:this.generateUniqueKey(`color-${this.productId}-${t.id}-${a.id}`),onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t)}),s("label",{htmlFor:this.generateUniqueKey(`color-${this.productId}-${t.id}-${a.id}`)},s("span",{style:{backgroundColor:a.color}}),s("div",{innerHTML:this.getOptionDetailName(a,!0,t.type)}))))))}thumbnailOption(t){return s("div",{class:"s-product-options-thumbnails-wrapper"},t.details.map((a=>s("div",{key:a.id},s("input",{type:"radio",value:a.id,"data-itemid":a.id,required:!t.visibility_condition&&t.required,checked:a.is_selected,name:this.generateInputName(t.id),"data-img-id":a.option_value,disabled:this.canDisabled&&this.isOptionDetailOut(a),id:this.generateUniqueKey(`option_${this.productId}-${t.id}_${a.id}`),onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t)}),s("label",{htmlFor:this.generateUniqueKey(`option_${this.productId}-${t.id}_${a.id}`),"data-img-id":a.option_value,class:"go-to-slide"},s("img",{"data-src":a.image,src:a.image,title:a.name,alt:a.name}),s("span",{innerHTML:r,class:"s-product-options-thumbnails-icon"}),this.isOptionDetailOut(a)?[s("small",{key:a.id,class:"s-product-options-thumbnails-stock-badge"},this.outOfStockText),this.canDisabled?s("div",{key:a.id,class:"s-product-options-thumbnails-badge-overlay"}):""]:""),s("p",null,this.getOptionDetailName(a,!1)," ")))))}digitalCardValuesOption(t){return s("div",{class:"s-product-options-digital-card-wrapper"},this.availableDigitalCardValues.length>0?this.availableDigitalCardValues.map((a=>{const i=String(a.id);return s("label",{htmlFor:this.generateUniqueKey(i.toString()),key:i,class:"s-product-options-digital-card-option"},s("input",{type:"radio","data-code-value":!0,class:"s-form-control s-product-options-digital-card-input",value:a.id,name:this.generateInputName(t.id),id:this.generateUniqueKey(i.toString()),required:!t.visibility_condition&&t.required,onInvalid:a=>this.invalidHandler(a,t),...this.ignoreDefaultCardValue?{}:{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===a.id}}),s("span",null,a.name," ",salla.config?.currency()?.symbol))})):s("div",{class:"s-product-options-digital-card-out-of-stock"}))}countryOption(t){return s("div",{class:"s-product-options-digital-card-wrapper"},t.details.map((a=>s("label",{htmlFor:this.generateUniqueKey(a.id.toString()),key:a.id,class:{"s-product-options-digital-card-option":!0,"s-product-options-digital-card-option-stock-out":a.is_out}},s("input",{id:this.generateUniqueKey(a.id.toString()),type:"radio",class:"s-form-control s-product-options-digital-card-input",value:a.id,name:this.generateInputName(t.id),disabled:a.is_out,required:!t.visibility_condition&&t.required,onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t),onClick:()=>{this.disableCardValue=!1},...salla.url.is_page("cart")?{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===a.id}:{}}),s("img",{loading:"lazy",alt:a.code,height:24,width:24,class:"s-product-options-country-flag",src:`https://cdn.assets.salla.network/prod/admin/cp/assets/flags/1x1/${String(a.code).toLocaleLowerCase()}.svg`,onError:t=>{t.currentTarget.onerror=null,t.currentTarget.src=salla.url.cdn("images/globe.svg")}}),s("span",null,a.name)))))}get host(){return e(this)}};m.style="";var g={request:(t,a,s,i=null,e=null)=>l.request({url:a,data:s,method:t.toLowerCase(),responseType:"json"}).then(i).catch(e),get:(t,a=null,s=null,i)=>l.get(t,{params:i}).then(a).catch(s),post(t,a,s=null,i=null){return this.request("post",t,a,s,i)},put(t,a,s=null,i=null){return this.request("put",t,a,s,i)},delete(t,a,s=null,i=null){return this.request("delete",t,a,s,i)},requestWithSupportAjax(t,a,s="post"){return new Promise(((i,e)=>{if(!window?.isLegacyTheme)return this.request(s,t,a,(({data:t})=>i(t)),(({response:t})=>e(t)));$.ajax({url:t,method:s.toUpperCase(),data:a,async:!1,success:function({data:t}){return i(t)},error:function({response:t}){return e(t)}})}))}},v={options:[],header:[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,a){var s,i,e,l=0,o=0;for(l=0;l<a.length;l+=1)if(new RegExp(a[l].value,"i").test(t)){if(s=new RegExp(a[l].version+"[- /:;]([\\d._]+)","i"),e="",(i=t.match(s))&&i[1]&&(i=i[1]),i)for(i=i.split(/[._]+/),o=0;o<i.length;o+=1)e+=0===o?i[o]+".":i[o];else e="0";return{name:a[l].name,version:parseFloat(e)}}return{name:"unknown",version:0}}};async function w(t,a,s=!1){if(salla.logger.log("🍏 Pay: mutateShippingContact called",a,s),t.detail.requiredShippingContactFields&&0!=t.detail.requiredShippingContactFields.length)if(s){if(salla.config.isGuest()&&salla.config.get("store.features").includes("guest-checkout")){if(!(a.emailAddress&&a.givenName&&a.familyName&&a.phoneNumber)){salla.logger.warn("🍏 Pay: Guest contact fields are required",a);const s=[];return a.emailAddress||s.push(new window.ApplePayError("shippingContactInvalid","emailAddress","Email address is required")),a.phoneNumber||s.push(new window.ApplePayError("shippingContactInvalid","phoneNumber","Phone number is required")),a.givenName&&a.familyName||s.push(new window.ApplePayError("shippingContactInvalid","name","Name is required")),void t.session.completePayment({status:t.session.STATUS_INVALID_SHIPPING_CONTACT,errors:s})}await async function(t,a){return salla.logger.log("🍏 Pay: Updating guest contact",a),new Promise(((s,i)=>{g.post(t.detail.guestContactSelected.url.replace("{id}",t.id),{email:a.emailAddress||null,first_name:a.givenName||null,last_name:a.familyName||null,phone_number:a.phoneNumber||null,country_code:a.countryCode||null},(async({data:a})=>{"function"==typeof t.detail.guestContactSelected?.onSuccess&&t.detail.guestContactSelected.onSuccess(a),s(a)}),(({response:a})=>{salla.logger.warn("🍏 Pay: Failed to update guest contact via api",a),"function"==typeof t.detail.guestContactSelected?.onFailed&&t.detail.guestContactSelected.onFailed(a),i({response:a})}))}))}(t,a)}}else if(t.detail.requiredShippingContactFields.includes("postalAddress"))return g.post(t.detail.shippingContactSelected.url.replace("{id}",t.id),{country:a.country,city:a.locality,local:a.subLocality||a.administrativeArea||a.locality,description:a.subAdministrativeArea,street:a.addressLines?.join(", ")||a.administrativeArea,country_code:a.countryCode,postal_code:a.postalCode},(async({data:a})=>{if("function"==typeof t.detail.shippingContactSelected.onSuccess&&t.detail.shippingContactSelected.onSuccess(a),t.address_id=a.data.address_id,t.shipping_methods=a.data.shipping_methods,!t.shipping_methods||t.shipping_methods&&!t.shipping_methods.length)return salla.logger.warn("🍏 Pay: We dont found any supported methods",a),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(a){return salla.logger.warn("Failed set the shipping details to api",a),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}try{await t.recalculateTotal()}catch(a){return salla.logger.warn("🍏 Pay: Failed recalculate total",a),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}const s={newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),newShippingMethods:t.mappingShippingMethods(t.shipping_methods)};salla.logger.log("🍏 Pay: completeShippingContactSelection",s),t.session.completeShippingContactSelection(s)}),(({response:a})=>{salla.logger.warn("🍏 Pay: Failed add address via api",a),"function"==typeof t.detail.shippingContactSelected.onFailed&&t.detail.shippingContactSelected.onFailed(a);let s=a?.data?.error?.fields,i=function(t){return Object.entries(t).filter((([t,a])=>a&&a.length>0)).map((([t,a])=>new window.ApplePayError("shippingContactInvalid",t,a[0])))}({countryCode:s?.country_code&&s.country_code.length>0?s.country_code[0]:null,locality:s?.city&&s.city.length>0?s.city[0]:null,country:s?.country&&s.country.length>0?s.country[0]:null});0===i.length&&a?.data?.error?.message&&i.push(new window.ApplePayError("shippingContactInvalid","locality",a?.data?.error?.message)),t.session.completeShippingContactSelection({newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:i})}))}window.Salla=window.Salla||{},window.Salla.Payments=window.Salla.Payments||{},window.SallaApplePay={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",SallaApplePay.startSession),Salla.event.addEventListener("payments::apple-pay.start-transaction",SallaApplePay.startSession)},initDefault:function(){SallaApplePay.detail.onError||(SallaApplePay.detail.onError=function(t){salla.notify.error(t)}),SallaApplePay.detail.authorized.onFailed||(SallaApplePay.detail.authorized.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse(t),SallaApplePay.onCancel({},t.data.error.message)}),SallaApplePay.detail.validateMerchant.onFailed||(SallaApplePay.detail.validateMerchant.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse({response:t}),SallaApplePay.onCancel({},t.data.error.message)}),SallaApplePay.detail.authorized.onSuccess||(SallaApplePay.detail.authorized.onSuccess=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleAfterResponseActions(t)})},prepareLineItems:function(){return SallaApplePay.detail?.items?.length||(SallaApplePay.detail.items=[{label:salla.lang.get("pages.cart.items_total"),amount:parseFloat(SallaApplePay.detail.amount).toString()}]),SallaApplePay.detail.items},prepareTotal:function(){return{label:window.location.hostname||"Salla",amount:parseFloat(SallaApplePay.detail.amount).toString()}},isPhysical:()=>SallaApplePay.detail?.requiredShippingContactFields?.includes("postalAddress"),startSession:async function(t){SallaApplePay.detail=t.detail||t,salla.log("🍏 Pay: payments::apple-pay.start-transaction",SallaApplePay.detail),SallaApplePay.initDefault();let a=SallaApplePay.getApplePaySessionVersion(),s=SallaApplePay.detail.supportedNetworks||["masterCard","visa"];5===a&&s.push("mada"),SallaApplePay.request={countryCode:SallaApplePay.detail.countryCode||"SA",supportsCouponCode:!0,couponCode:"",currencyCode:SallaApplePay.detail.currency||"SAR",requiredShippingContactFields:SallaApplePay.detail.requiredShippingContactFields?SallaApplePay.detail.requiredShippingContactFields:[],merchantCapabilities:["supports3DS"],supportedNetworks:s,supportedCountries:SallaApplePay.detail.supportedCountries||["SA"],total:SallaApplePay.prepareTotal(),shippingContact:SallaApplePay.detail.shippingContact?SallaApplePay.detail.shippingContact:{},shippingMethods:SallaApplePay.detail.shippingMethods&&SallaApplePay.detail.shippingMethods.length?SallaApplePay.mappingShippingMethods(t.detail.shippingMethods):[],lineItems:SallaApplePay.prepareLineItems()},salla.log("🍏 Pay: init ",SallaApplePay.request),SallaApplePay.session=new ApplePaySession(a,SallaApplePay.request),SallaApplePay.session.onshippingcontactselected=SallaApplePay.onShippingContactSelected,SallaApplePay.session.onshippingmethodselected=SallaApplePay.onShippingMethodSelected,SallaApplePay.session.onvalidatemerchant=SallaApplePay.onValidateMerchant,SallaApplePay.session.onpaymentauthorized=SallaApplePay.onPaymentAuthorized,SallaApplePay.session.oncancel=SallaApplePay.onCancel,SallaApplePay.session.oncouponcodechanged=SallaApplePay.onCouponCodeChanged,SallaApplePay.session.onpaymentmethodselected=SallaApplePay.onPaymentMethodSelected,SallaApplePay.session.begin()},onPaymentMethodSelected:async t=>{if(salla.logger.log("🍏 Pay: onPaymentMethodSelected",t),SallaApplePay.isPhysical())salla.logger.log("🍏 Pay: completePaymentMethodSelection",{newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()}),SallaApplePay.session.completePaymentMethodSelection({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()});else try{await SallaApplePay.recalculateTotal();const t={newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()};salla.logger.log("🍏 Pay: completePaymentMethodSelection",t),SallaApplePay.session.completePaymentMethodSelection(t)}catch(t){salla.logger.warn("🍏 Pay: Failed recalculate total",t),SallaApplePay.session.completePaymentMethodSelection({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems(),status:SallaApplePay.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),g.post(SallaApplePay.detail.onCouponCodeChanged.url.replace("{id}",SallaApplePay.id),{coupon:t.couponCode,payment_method:"apple_pay"},(async({data:t})=>{"function"==typeof SallaApplePay.detail.onCouponCodeChanged.onSuccess&&SallaApplePay.detail.onCouponCodeChanged.onSuccess(t),salla.log("🍏 Pay: Coupon applied success"),await SallaApplePay.recalculateTotal(),SallaApplePay.session.completeCouponCodeChange({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()})}),(async t=>{let a=t?.response;Salla.event.dispatch("payments::apple-pay.coupon.failed",a),"function"==typeof SallaApplePay.detail.onCouponCodeChanged.onFailed&&SallaApplePay.detail.onCouponCodeChanged.onFailed(a),await SallaApplePay.recalculateTotal(),SallaApplePay.session.completeCouponCodeChange({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems(),errors:[new window.ApplePayError("couponCodeInvalid")]})}))),onCancel:(t={},a=null)=>{SallaApplePay.detail.onError(a||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 w(SallaApplePay,t.payment.shippingContact,!0)}catch(t){salla.logger.error("🍏 Pay: Failed to update guest contact details",t);const a=t?.response||t,s=a?.data?.error?.fields||{},i=[];return s?.email&&s.email.length>0&&i.push(new window.ApplePayError("shippingContactInvalid","emailAddress",s.email[0])),s?.phone&&s.phone.length>0&&i.push(new window.ApplePayError("shippingContactInvalid","phoneNumber",s.phone[0])),s?.first_name&&s.first_name.length>0?i.push(new window.ApplePayError("shippingContactInvalid","name",s.first_name[0])):s?.last_name&&s.last_name.length>0&&i.push(new window.ApplePayError("shippingContactInvalid","name",s.last_name[0])),0===i.length&&i.push(new window.ApplePayError("shippingContactInvalid","name",a?.data?.error?.message||a?.data?.error?.code||"Invalid shipping contact details")),Salla.event.dispatch("payments::apple-pay.authorized.failed",a),"function"==typeof SallaApplePay.detail.authorized.onFailed&&SallaApplePay.detail.authorized.onFailed(a),void SallaApplePay.session.completePayment({status:ApplePaySession.STATUS_INVALID_SHIPPING_CONTACT,errors:i})}Salla.event.dispatch("payments::apple-pay.authorized.init",t),g.post(SallaApplePay.detail.authorized.url.replace("{id}",SallaApplePay.id),{payment_method:"apple_pay",applepay_token:JSON.stringify(t.payment)},(({data:t})=>{Salla.event.dispatch("payments::apple-pay.authorized.success",t),"function"==typeof SallaApplePay.detail.authorized.onSuccess&&SallaApplePay.detail.authorized.onSuccess(t),SallaApplePay.session.completePayment(ApplePaySession.STATUS_SUCCESS)}),(t=>{let a=t?.response;Salla.event.dispatch("payments::apple-pay.authorized.failed",a),"function"==typeof SallaApplePay.detail.authorized.onFailed&&SallaApplePay.detail.authorized.onFailed(a),SallaApplePay.session.completePayment({status:ApplePaySession.STATUS_FAILURE,errors:[new window.ApplePayError("unknown",void 0,a?.data?.error?.message||a?.data?.error?.code||"Failed to parse authorized response")]})}))},onValidateMerchant:async t=>{try{Salla.event.dispatch("payments::apple-pay.validate-merchant.init",t);const{data:a}=await g.post(SallaApplePay.detail.validateMerchant.url.replace("{id}",SallaApplePay.id),{validation_url:t.validationURL});Salla.event.dispatch("payments::apple-pay.validate-merchant.success",a);const s=t=>{SallaApplePay.session.completeMerchantValidation(t)};if("function"==typeof SallaApplePay.detail.validateMerchant.onSuccess){const t=await SallaApplePay.detail.validateMerchant.onSuccess(a);if(t?.redirect)return window.location=t.redirect,SallaApplePay.abortValidateMerchant(t)}s(a.data)}catch(t){console.error(t),SallaApplePay.abortValidateMerchant(t?.response)}},abortValidateMerchant:(t=null)=>{SallaApplePay.abortSession(),Salla.event.dispatch("payments::apple-pay.validate-merchant.failed",t),"function"==typeof SallaApplePay.detail.validateMerchant.onFailed&&SallaApplePay.detail.validateMerchant.onFailed(t)},onShippingContactSelected:async t=>{salla.logger.log("🍏 Pay: onShippingContactSelected",t.shippingContact),await w(SallaApplePay,t.shippingContact)},onShippingMethodSelected:async t=>{let a=t.shippingMethod.identifier.split(","),s={ship_id:a[0],private_ship_id:void 0===a[1]?null:a[1],type:void 0===a[2]?null:a[2],route_id:void 0===a[3]?null:a[3]};if(salla.logger.log("🍏 Pay: onShippingMethodSelected",{event:t,previous:SallaApplePay.shippingCompany,current:s}),SallaApplePay.shouldUpdateShippingCompany(s))try{await SallaApplePay.selectApplePayShippingMethod(s),await SallaApplePay.recalculateTotal()}catch(t){return salla.logger.warn("🍏 Pay: Failed set the shipping details to api",t),void SallaApplePay.session.completeShippingMethodSelection({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems(),status:SallaApplePay.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}salla.logger.log("🍏 Pay: completeShippingMethodSelection",{newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()}),SallaApplePay.session.completeShippingMethodSelection({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()})},abortSession:()=>{SallaApplePay.session&&SallaApplePay.session.abort()},shouldUpdateShippingCompany:t=>SallaApplePay.shippingCompany?.ship_id!=t?.ship_id||SallaApplePay.shippingCompany?.private_ship_id!=t?.private_ship_id,getApplePaySessionVersion:()=>{if("sallapp"===(navigator.userAgent||navigator.vendor||window.opera))return 5;let t=v.init(),a=parseFloat(t.os.version);if("Macintosh"===t.os.name){if(a<10.142)return 1}else if(a<12.11)return 1;return 5},recalculateTotal:()=>(salla.logger.log("🍏 Pay: recalculate total"),g.get(SallaApplePay.detail.recalculateTotal.url.replace("{id}",SallaApplePay.id),(({data:t})=>{salla.logger.log("🍏 Pay: recalculate total success",t);let a=t.data.initial_data?.cart||t.data.cart,s=t.data.initial_data?.payments||t.data.payments;salla.logger.log("🍏 Pay: recalculate total success",{cart:a,payments:s}),SallaApplePay.detail.amount=s?.gateways?.applePay?.supportedMultiCurrency?a.total_in_customer_currency:a.total,SallaApplePay.detail.items=(a.totals||a.items).map((t=>({label:t.title,amount:"مجاني"===t.amount||"Free"===t.amount?0:t.amount.toString().replace("+","")}))),SallaApplePay.detail.items.pop(),SallaApplePay.totals=SallaApplePay.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),SallaApplePay.shippingCompany=t;const a={address_id:SallaApplePay.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 g.post(SallaApplePay.detail.shippingMethodSelected.url.replace("{id}",SallaApplePay.id),a,(({data:t})=>("function"==typeof SallaApplePay.detail.shippingMethodSelected.onSuccess&&SallaApplePay.detail.shippingMethodSelected.onSuccess(t),!0)),(t=>{salla.logger.warn("🍏 Pay: Set shipping method failed",t),"function"==typeof SallaApplePay.detail.shippingMethodSelected.onFailed&&SallaApplePay.detail.shippingMethodSelected.onFailed(t);let a=t?.response?.data?.error;return a?.data?.fields?.address_id?a?.data?.fields?.address_id[0]:a?.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:"")})))},window.ApplePaySession?.canMakePayments()?SallaApplePay.init():document.querySelectorAll("data-show-if-apple-pay-supported").forEach((t=>t.style.display="none"));const S=class{constructor(s){t(this,s),this.validationFailed=a(this,"validationFailed"),this.requireLogin=a(this,"requireLogin"),this.type="buy",this.productType="product",this.options={},this.quickBuy=salla.lang.get("pages.products.buy_now"),salla.lang.onLoaded((()=>{this.quickBuy=salla.lang.get("pages.products.buy_now")}))}async quickBuyHandler(){if(salla.config.isGuest()&&!this.isGuestCheckout()){this.requireLogin.emit({productId:this.productId});let t="salla-quick-buy::user.logged-in";return salla.event.on(t,(()=>this.settlePayment())),salla.api.auth.setAfterLoginEvent(t),salla.auth.event.dispatch("login::open",{withoutReload:!0})}await this.settlePayment()}async settlePayment(){let t=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);if(t&&!await t.reportValidity())return this.validationFailed.emit({productId:this.productId}),salla.error(salla.lang.get("common.messages.required_fields"));let a=this.host.getElementSallaData();if(!this.isApplePayActive)return salla.api.request("checkout/quick-purchase/"+this.productId,a,"post").then((t=>(t.data.redirect&&(window.location.href=t.data.redirect),t)));a.is_applepay=!0,"append"in a&&a.append("is_applepay",!0),salla.event.dispatch("payments::apple-pay.start-transaction",{amount:this.amount,currency:this.currency||"SAR",requiredShippingContactFields:this.getRequiredShippingContactFields(),shippingMethods:this.isRequireShipping?[]:void 0,supportedNetworks:salla.config.get("store.settings.buy_now.networks"),supportedCountries:salla.config.get("store.settings.buy_now.countries"),countryCode:salla.config.get("store.store_country")||"SA",validateMerchant:{url:this.validateHost?`${this.validateHost}/checkout/applepay/validate`:salla.url.get("checkout/applepay/validate"),onSuccess:t=>this.applePayOnly&&!this.productId?this.cartId?(window.SallaApplePay.id=this.cartId,salla.log("🍏 Pay: create checkout success: with id #"+this.cartId),Promise.resolve(t)):(salla.logger.warn("🍏 Pay: trying to create applePay transaction without cartId/ProductId !"),Promise.resolve(t)):salla.api.request("checkout/quick-purchase/"+this.productId,"object"==typeof a?a: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}componentWillLoad(){console.log("🍏 Pay: Quick Buy Component Loaded");const t="undefined"!=typeof window&&!!window.ApplePaySession?.canMakePayments?.(),a=salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??!0,s=salla?.config?.get?.("store.settings.is_salla_gateway",!1)??!0;this.isApplePayActive=t&&a&&s;const i=async()=>{if(!this.currency&&salla?.config?.get&&(this.currency=salla.config.get("store.settings.buy_now.multi_currency")?salla.config.get("user.currency_code"):"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.amount=t.data.price,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.amount=t.price)})):salla?.url?.is_page?.("product.single")&&salla?.product?.event?.onPriceUpdated&&salla.product.event.onPriceUpdated((t=>{this.amount=t.data.price})),this.isApplePayActive=(salla?.helpers?.hasApplePay?.()??t)&&(salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??a)&&(salla?.config?.get?.("store.settings.is_salla_gateway",!1)??s),!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((()=>i().then((()=>t(!0))))):i().then((()=>t(!0)))}))}render(){return s(i,{key:"88125eb8c3bb1e1b016f39ea84ce6234267587a4"},this.quickBuyButton())}quickBuyButton(){return s("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)}};S.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{c as salla_add_product_button,h as salla_product_availability,m as salla_product_options,S 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}from"./p-CV1rqKQz.js";const r=class{constructor(t){s(this,t),this.height="10px";try{if(this.donation){let s="string"==typeof this.donation?JSON.parse(this.donation):this.donation;s.can_donate&&s.target_amount?(s.target_end_date="0000-00-00"==s.target_end_date?null:s.target_end_date,this.value=s.collected_amount,this.target=s.target_amount,this.header=salla.lang.get("pages.products.target"),this.message=s.target_end_date?salla.lang.get("pages.products.donation_target_date")+" "+s.target_end_date:""):this.message=s.target_amount?s.target_message:""}}catch(s){salla.log("Wrong donation json")}salla.lang.onLoaded((()=>{this.header=this.header?.replace("pages.products.target",salla.lang.get("pages.products.target")),this.message=this.message?.replace("pages.products.donation_target_date",salla.lang.get("pages.products.donation_target_date"))})),salla.onReady((()=>{this.color=this.color||salla.config.get("theme.color.primary","#ffd5c4"),this.unit||(this.unit=salla.config.currency().symbol)}))}getPercentage(){return this.value/this.target*100}render(){return this.target||this.message?t("div",{class:"s-progress-bar-container"},this.header?t("div",{class:"s-progress-bar-header"},this.header):"",this.getProgressBar(),this.message?t("span",{class:"s-progress-bar-message"},this.message):""):""}getProgressBar(){return this.target?[this.hideUnits?null:t("div",{class:"s-progress-bar-target-section"},t("span",{innerHTML:`${salla.helpers.number(this.value)} ${this.unit}`}),t("span",{innerHTML:`${salla.helpers.number(this.target)} ${this.unit}`})),t("div",{class:"s-progress-bar-wrapper",style:{height:this.height}},t("div",{class:{"s-progress-bar-progress":!0,"s-progress-bar-progress-stripped":this.stripped},style:{width:`${this.getPercentage()}%`,backgroundColor:this.color}}))]:null}};r.style="";export{r as salla_progress_bar}
4
+ import{r as s,h as t}from"./p-Y6CiunLU.js";const r=class{constructor(t){s(this,t),this.height="10px";try{if(this.donation){let s="string"==typeof this.donation?JSON.parse(this.donation):this.donation;s.can_donate&&s.target_amount?(s.target_end_date="0000-00-00"==s.target_end_date?null:s.target_end_date,this.value=s.collected_amount,this.target=s.target_amount,this.header=salla.lang.get("pages.products.target"),this.message=s.target_end_date?salla.lang.get("pages.products.donation_target_date")+" "+s.target_end_date:""):this.message=s.target_amount?s.target_message:""}}catch(s){salla.log("Wrong donation json")}salla.lang.onLoaded((()=>{this.header=this.header?.replace("pages.products.target",salla.lang.get("pages.products.target")),this.message=this.message?.replace("pages.products.donation_target_date",salla.lang.get("pages.products.donation_target_date"))})),salla.onReady((()=>{this.color=this.color||salla.config.get("theme.color.primary","#ffd5c4"),this.unit||(this.unit=salla.config.currency().symbol)}))}getPercentage(){return this.value/this.target*100}render(){return this.target||this.message?t("div",{class:"s-progress-bar-container"},this.header?t("div",{class:"s-progress-bar-header"},this.header):"",this.getProgressBar(),this.message?t("span",{class:"s-progress-bar-message"},this.message):""):""}getProgressBar(){return this.target?[this.hideUnits?null:t("div",{class:"s-progress-bar-target-section"},t("span",{innerHTML:`${salla.helpers.number(this.value)} ${this.unit}`}),t("span",{innerHTML:`${salla.helpers.number(this.target)} ${this.unit}`})),t("div",{class:"s-progress-bar-wrapper",style:{height:this.height}},t("div",{class:{"s-progress-bar-progress":!0,"s-progress-bar-progress-stripped":this.stripped},style:{width:`${this.getPercentage()}%`,backgroundColor:this.color}}))]:null}};r.style="";export{r as salla_progress_bar}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as e,H as a}from"./p-CV1rqKQz.js";var t='\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>user-off</title>\n<path d="M10.837 19.309c-4.963 1.284-8.171 4.303-8.171 7.691v3.667c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-3.667c0-2.101 2.48-4.155 6.172-5.109 0.713-0.184 1.141-0.912 0.957-1.625-0.184-0.711-0.908-1.137-1.625-0.956zM12.859 3.715c0.933-0.685 2.020-1.048 3.141-1.048 2.941 0 5.333 2.392 5.333 5.333 0 1.121-0.363 2.208-1.048 3.141-0.436 0.593-0.308 1.428 0.284 1.864 0.239 0.175 0.515 0.259 0.788 0.259 0.411 0 0.815-0.188 1.076-0.544 1.025-1.393 1.567-3.025 1.567-4.72 0-4.412-3.588-8-8-8-1.695 0-3.327 0.541-4.721 1.567-0.592 0.435-0.72 1.269-0.284 1.864 0.436 0.593 1.269 0.721 1.864 0.284zM31.609 29.724l-29.333-29.333c-0.521-0.521-1.364-0.521-1.885 0s-0.521 1.364 0 1.885l29.333 29.333c0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391c0.521-0.521 0.521-1.364 0-1.885z"></path>\n</svg>\n';const i=class{constructor(e){s(this,e),this.deactivateAccount=salla.lang.get("pages.profile.deactivate_account"),this.promotionalMsgs=salla.lang.get("pages.profile.promotional_messages"),this.hideMyName=salla.lang.get("pages.profile.hide_my_name"),this.hideMyNameDesc=salla.lang.get("pages.profile.hide_my_name_desc"),this.deactivateDesc=salla.lang.get("pages.profile.deactivate_account_description"),this.promotionalMsgsDesc=salla.lang.get("pages.profile.promotional_messages_description"),this.sorryForLeavingText=salla.lang.get("pages.profile.warning_for_deactivate"),this.warningText=salla.lang.get("pages.profile.sorry_for_leaving"),this.keepAccount=salla.lang.get("pages.profile.keep_account"),this.buttonLoading=!1,this.canHideName=salla.config.get("store.settings.rating.can_customer_hide_name"),salla.onReady((()=>{this.isHiddenName=salla.config.get("user.is_hidden_name"),this.isNotifiable=salla.config.get("user.is_notifiable"),this.canHideName=salla.config.get("store.settings.rating.can_customer_hide_name"),this.isNotifiable&&this.isHiddenName||salla.event.on("profile::info.fetched",(s=>{this.isHiddenName=s.data.is_hidden_name,this.isNotifiable=s.data.is_notifiable}))})),salla.lang.onLoaded((()=>{this.deactivateAccount=salla.lang.get("pages.profile.deactivate_account"),this.promotionalMsgs=salla.lang.get("pages.profile.promotional_messages"),this.hideMyName=salla.lang.get("pages.profile.hide_my_name"),this.hideMyNameDesc=salla.lang.get("pages.profile.hide_my_name_desc"),this.deactivateDesc=salla.lang.get("pages.profile.deactivate_account_description"),this.promotionalMsgsDesc=salla.lang.get("pages.profile.promotional_messages_description"),this.warningText=salla.lang.get("pages.profile.warning_for_deactivate"),this.sorryForLeavingText=salla.lang.get("pages.profile.sorry_for_leaving"),this.keepAccount=salla.lang.get("pages.profile.keep_account")}))}toggleSetting(s,e){salla.profile.updateSettings({name:s,value:e.target.checked})}capitalizeText(s){return s.charAt(0).toUpperCase()+s.slice(1)}openDeactivateModal(){this.confirmationModal.setTitle(this.capitalizeText(this.deactivateAccount)),this.confirmationModal.open()}async deleteAccount(){await salla.profile.delete().finally((()=>this.confirmationModal.close()))}render(){return e(a,{key:"85b2fe2739f6ac3c55939d3cb9c87fc404413e7f",class:"s-user-settings-wrapper"},this.canHideName&&e("div",{key:"e46be8b9cb4898c9b676ee67f0750bb654bda953",class:"s-user-settings-section"},e("salla-list-tile",{key:"48f81d5a9b511c2a8baabab2aab6ad3dcfb98370"},e("div",{key:"9009c4d612aea7e7a6834b90f38d03d8c95bcc84",slot:"icon",class:"s-user-settings-section-icon"},e("span",{key:"03f209e6e1e1adbdb130f9b80aed30f0618dd58c",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>user-cancel</title>\n<path d="M29.885 16l1.724-1.724c0.521-0.521 0.521-1.364 0-1.885s-1.364-0.521-1.885 0l-1.724 1.724-1.724-1.724c-0.521-0.521-1.364-0.521-1.885 0s-0.521 1.364 0 1.885l1.724 1.724-1.724 1.724c-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391l1.724-1.724 1.724 1.724c0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391c0.521-0.521 0.521-1.364 0-1.885zM10.667 16c4.043 0 7.333-3.289 7.333-7.333s-3.291-7.333-7.333-7.333-7.333 3.289-7.333 7.333 3.291 7.333 7.333 7.333zM10.667 4c2.573 0 4.667 2.093 4.667 4.667s-2.093 4.667-4.667 4.667-4.667-2.093-4.667-4.667 2.093-4.667 4.667-4.667zM10.667 18.667c-5.881 0-10.667 3.813-10.667 8.5v2.167c0 0.736 0.596 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.167c0-3.217 3.588-5.833 8-5.833s8 2.616 8 5.833v2.167c0 0.736 0.596 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.167c0-4.687-4.785-8.5-10.667-8.5z"></path>\n</svg>\n'})),e("div",{key:"fb02ca2387806135ac3f074f0a9f30ce4bb325ca",slot:"title",class:"s-user-settings-section-title"},this.capitalizeText(this.hideMyName)),e("div",{key:"1ddbd1144a59745bf26f4650eb5d050a34d42e8f",slot:"subtitle",class:"s-user-settings-section-subtitle"},this.capitalizeText(this.hideMyNameDesc)),e("div",{key:"0ff6163a407a53ff100c8d3235212c167dbb006a",slot:"action",class:"s-user-settings-section-action"},e("label",{key:"03b817a0bea880c9a2e056d4d8f0fb737dc0e5da",class:"s-toggle"},e("input",{key:"fcb56427c6d1ae503abdc768358e9ecfa9139dac",class:"s-toggle-input",checked:this.isHiddenName,onChange:s=>this.toggleSetting("is_hidden_name",s),type:"checkbox"}),e("div",{key:"ff312279ede50b86446d1305217053942d05a603",class:"s-toggle-switcher"}))))),e("div",{key:"08cf0045a6f96ae7046d9a7c640e53a5b2cec7dc",class:"s-user-settings-section"},e("salla-list-tile",{key:"1ccbcd93cf4cef91693603b5b05dbc4f3b85dc65"},e("div",{key:"bf5270f2d2cae798463ab9516c11321e96c461ff",slot:"icon",class:"s-user-settings-section-icon"},e("span",{key:"3bc3927296faa253a8b91710049eca3372fb24aa",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>bullhorn</title>\n<path d="M30.129 0.264c-0.339-0.252-0.776-0.328-1.179-0.208l-24.951 7.485v-0.216c0-0.736-0.597-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v14.667c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-0.112l3.448 1.207-0.595 1.704c-0.321 1.019-0.227 2.103 0.267 3.051s1.327 1.647 2.345 1.968l6.359 2.004c0.399 0.127 0.804 0.187 1.201 0.187 1.699 0 3.277-1.091 3.812-2.785l0.423-1.295 7.633 2.672c0.143 0.049 0.292 0.075 0.44 0.075 0.273 0 0.543-0.084 0.772-0.247 0.352-0.249 0.561-0.655 0.561-1.087v-28c0-0.421-0.199-0.819-0.537-1.069zM18.297 28.4c-0.221 0.701-0.973 1.089-1.673 0.871l-6.357-2.004c-0.34-0.108-0.617-0.34-0.781-0.656s-0.196-0.676-0.101-0.977l0.581-1.665 8.777 3.072zM28 27.453l-24-8.4v-8.728l24-7.2z"></path>\n</svg>\n'})),e("div",{key:"60ddca373590545a7fd03498e4ff7306a23b05a9",slot:"title",class:"s-user-settings-section-title"},this.capitalizeText(this.promotionalMsgs)),e("div",{key:"874e81d5e4727160a85bb3381fdfadcd65e774c0",slot:"subtitle",class:"s-user-settings-section-subtitle"},this.capitalizeText(this.promotionalMsgsDesc)),e("div",{key:"6d2aacf7a72c4d25163913eccbb0a3e94595ec75",slot:"action",class:"s-user-settings-section-action"},e("label",{key:"cf58459624592b34083afe61a0afc29dea03864e",class:"s-toggle"},e("input",{key:"b854ce4ca8224c8200623aad0dea4c659d89dee1",class:"s-toggle-input",checked:this.isNotifiable,onChange:s=>this.toggleSetting("is_notifiable",s),type:"checkbox"}),e("div",{key:"785a5765e36056629a23ca53e48715f91c14ee1f",class:"s-toggle-switcher"}))))),e("div",{key:"9f58724a8d748809b39874efaa861643a78076eb",class:"s-user-settings-section s-user-settings-section-deactivate-user"},e("salla-list-tile",{key:"12a69027f2822b6fa1e8fb641278932fc2206335"},e("div",{key:"679eec74598612167c77443e5f6977991b333fd7",slot:"icon",class:"s-user-settings-section-icon"},e("span",{key:"0263f8f31ad3e4ca60f2bb4bae910c143f2d36a8",innerHTML:t})),e("div",{key:"6c0c17dfbcbb48ae3882b07b58fb0d1245a28cdb",slot:"title",class:"s-user-settings-section-title"},this.capitalizeText(this.deactivateAccount)),e("div",{key:"07389c3b86b3d8e821b8b9c33cf43de1ee6527db",slot:"subtitle",class:"s-user-settings-section-subtitle"},this.capitalizeText(this.deactivateDesc)),e("div",{key:"e98736162d465c0717550eb8231b120acfafc4f6",slot:"action",class:"s-user-settings-section-action"},e("salla-button",{key:"d29c5023b3a35f95c94a06dc87f0e2504b3a6390",fill:"outline",color:"danger",shape:"btn",size:"medium",width:"normal",onClick:()=>this.openDeactivateModal()},this.capitalizeText(this.deactivateAccount))))),e("salla-modal",{key:"6f23ca61fe62de261e7d2f616a4d5bf13fba1577",width:"sm",subTitle:this.capitalizeText(this.sorryForLeavingText),ref:s=>this.confirmationModal=s},e("span",{key:"89073dfc15d4a1349618180c776968012e843556",slot:"icon",class:"s-user-settings-confirmation-icon",innerHTML:t}),e("div",{key:"f464a56ab783c4ddd51cc40e4d4dbf2f4ae21be2",class:"s-user-settings-confirmation"},e("div",{key:"e9921faaf8718ba51937006360b11d409bde4e05",class:"s-user-settings-confirmation-warning"},this.capitalizeText(this.warningText)),e("div",{key:"4a71df323e6fa2b86cb85e77af438a51e9c1c5a9",class:"s-user-settings-confirmation-actions"},e("salla-button",{key:"156249d17bdcc25b7c586af416001ec60e8b0f5b",width:"wide",onClick:()=>this.confirmationModal.close()},this.capitalizeText(this.keepAccount)),e("salla-button",{key:"acbe44c04f77f8ccdcaeb90bfb731de399f88fc7",fill:"outline",loading:this.buttonLoading,width:"wide",onClick:()=>this.deleteAccount()},this.capitalizeText(this.deactivateAccount))))))}};i.style="";export{i as salla_user_settings}
4
+ import{r as s,h as e,H as a}from"./p-Y6CiunLU.js";var t='\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>user-off</title>\n<path d="M10.837 19.309c-4.963 1.284-8.171 4.303-8.171 7.691v3.667c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-3.667c0-2.101 2.48-4.155 6.172-5.109 0.713-0.184 1.141-0.912 0.957-1.625-0.184-0.711-0.908-1.137-1.625-0.956zM12.859 3.715c0.933-0.685 2.020-1.048 3.141-1.048 2.941 0 5.333 2.392 5.333 5.333 0 1.121-0.363 2.208-1.048 3.141-0.436 0.593-0.308 1.428 0.284 1.864 0.239 0.175 0.515 0.259 0.788 0.259 0.411 0 0.815-0.188 1.076-0.544 1.025-1.393 1.567-3.025 1.567-4.72 0-4.412-3.588-8-8-8-1.695 0-3.327 0.541-4.721 1.567-0.592 0.435-0.72 1.269-0.284 1.864 0.436 0.593 1.269 0.721 1.864 0.284zM31.609 29.724l-29.333-29.333c-0.521-0.521-1.364-0.521-1.885 0s-0.521 1.364 0 1.885l29.333 29.333c0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391c0.521-0.521 0.521-1.364 0-1.885z"></path>\n</svg>\n';const i=class{constructor(e){s(this,e),this.deactivateAccount=salla.lang.get("pages.profile.deactivate_account"),this.promotionalMsgs=salla.lang.get("pages.profile.promotional_messages"),this.hideMyName=salla.lang.get("pages.profile.hide_my_name"),this.hideMyNameDesc=salla.lang.get("pages.profile.hide_my_name_desc"),this.deactivateDesc=salla.lang.get("pages.profile.deactivate_account_description"),this.promotionalMsgsDesc=salla.lang.get("pages.profile.promotional_messages_description"),this.sorryForLeavingText=salla.lang.get("pages.profile.warning_for_deactivate"),this.warningText=salla.lang.get("pages.profile.sorry_for_leaving"),this.keepAccount=salla.lang.get("pages.profile.keep_account"),this.buttonLoading=!1,this.canHideName=salla.config.get("store.settings.rating.can_customer_hide_name"),salla.onReady((()=>{this.isHiddenName=salla.config.get("user.is_hidden_name"),this.isNotifiable=salla.config.get("user.is_notifiable"),this.canHideName=salla.config.get("store.settings.rating.can_customer_hide_name"),this.isNotifiable&&this.isHiddenName||salla.event.on("profile::info.fetched",(s=>{this.isHiddenName=s.data.is_hidden_name,this.isNotifiable=s.data.is_notifiable}))})),salla.lang.onLoaded((()=>{this.deactivateAccount=salla.lang.get("pages.profile.deactivate_account"),this.promotionalMsgs=salla.lang.get("pages.profile.promotional_messages"),this.hideMyName=salla.lang.get("pages.profile.hide_my_name"),this.hideMyNameDesc=salla.lang.get("pages.profile.hide_my_name_desc"),this.deactivateDesc=salla.lang.get("pages.profile.deactivate_account_description"),this.promotionalMsgsDesc=salla.lang.get("pages.profile.promotional_messages_description"),this.warningText=salla.lang.get("pages.profile.warning_for_deactivate"),this.sorryForLeavingText=salla.lang.get("pages.profile.sorry_for_leaving"),this.keepAccount=salla.lang.get("pages.profile.keep_account")}))}toggleSetting(s,e){salla.profile.updateSettings({name:s,value:e.target.checked})}capitalizeText(s){return s.charAt(0).toUpperCase()+s.slice(1)}openDeactivateModal(){this.confirmationModal.setTitle(this.capitalizeText(this.deactivateAccount)),this.confirmationModal.open()}async deleteAccount(){await salla.profile.delete().finally((()=>this.confirmationModal.close()))}render(){return e(a,{key:"85b2fe2739f6ac3c55939d3cb9c87fc404413e7f",class:"s-user-settings-wrapper"},this.canHideName&&e("div",{key:"e46be8b9cb4898c9b676ee67f0750bb654bda953",class:"s-user-settings-section"},e("salla-list-tile",{key:"48f81d5a9b511c2a8baabab2aab6ad3dcfb98370"},e("div",{key:"9009c4d612aea7e7a6834b90f38d03d8c95bcc84",slot:"icon",class:"s-user-settings-section-icon"},e("span",{key:"03f209e6e1e1adbdb130f9b80aed30f0618dd58c",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>user-cancel</title>\n<path d="M29.885 16l1.724-1.724c0.521-0.521 0.521-1.364 0-1.885s-1.364-0.521-1.885 0l-1.724 1.724-1.724-1.724c-0.521-0.521-1.364-0.521-1.885 0s-0.521 1.364 0 1.885l1.724 1.724-1.724 1.724c-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391l1.724-1.724 1.724 1.724c0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391c0.521-0.521 0.521-1.364 0-1.885zM10.667 16c4.043 0 7.333-3.289 7.333-7.333s-3.291-7.333-7.333-7.333-7.333 3.289-7.333 7.333 3.291 7.333 7.333 7.333zM10.667 4c2.573 0 4.667 2.093 4.667 4.667s-2.093 4.667-4.667 4.667-4.667-2.093-4.667-4.667 2.093-4.667 4.667-4.667zM10.667 18.667c-5.881 0-10.667 3.813-10.667 8.5v2.167c0 0.736 0.596 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.167c0-3.217 3.588-5.833 8-5.833s8 2.616 8 5.833v2.167c0 0.736 0.596 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.167c0-4.687-4.785-8.5-10.667-8.5z"></path>\n</svg>\n'})),e("div",{key:"fb02ca2387806135ac3f074f0a9f30ce4bb325ca",slot:"title",class:"s-user-settings-section-title"},this.capitalizeText(this.hideMyName)),e("div",{key:"1ddbd1144a59745bf26f4650eb5d050a34d42e8f",slot:"subtitle",class:"s-user-settings-section-subtitle"},this.capitalizeText(this.hideMyNameDesc)),e("div",{key:"0ff6163a407a53ff100c8d3235212c167dbb006a",slot:"action",class:"s-user-settings-section-action"},e("label",{key:"03b817a0bea880c9a2e056d4d8f0fb737dc0e5da",class:"s-toggle"},e("input",{key:"fcb56427c6d1ae503abdc768358e9ecfa9139dac",class:"s-toggle-input",checked:this.isHiddenName,onChange:s=>this.toggleSetting("is_hidden_name",s),type:"checkbox"}),e("div",{key:"ff312279ede50b86446d1305217053942d05a603",class:"s-toggle-switcher"}))))),e("div",{key:"08cf0045a6f96ae7046d9a7c640e53a5b2cec7dc",class:"s-user-settings-section"},e("salla-list-tile",{key:"1ccbcd93cf4cef91693603b5b05dbc4f3b85dc65"},e("div",{key:"bf5270f2d2cae798463ab9516c11321e96c461ff",slot:"icon",class:"s-user-settings-section-icon"},e("span",{key:"3bc3927296faa253a8b91710049eca3372fb24aa",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>bullhorn</title>\n<path d="M30.129 0.264c-0.339-0.252-0.776-0.328-1.179-0.208l-24.951 7.485v-0.216c0-0.736-0.597-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v14.667c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-0.112l3.448 1.207-0.595 1.704c-0.321 1.019-0.227 2.103 0.267 3.051s1.327 1.647 2.345 1.968l6.359 2.004c0.399 0.127 0.804 0.187 1.201 0.187 1.699 0 3.277-1.091 3.812-2.785l0.423-1.295 7.633 2.672c0.143 0.049 0.292 0.075 0.44 0.075 0.273 0 0.543-0.084 0.772-0.247 0.352-0.249 0.561-0.655 0.561-1.087v-28c0-0.421-0.199-0.819-0.537-1.069zM18.297 28.4c-0.221 0.701-0.973 1.089-1.673 0.871l-6.357-2.004c-0.34-0.108-0.617-0.34-0.781-0.656s-0.196-0.676-0.101-0.977l0.581-1.665 8.777 3.072zM28 27.453l-24-8.4v-8.728l24-7.2z"></path>\n</svg>\n'})),e("div",{key:"60ddca373590545a7fd03498e4ff7306a23b05a9",slot:"title",class:"s-user-settings-section-title"},this.capitalizeText(this.promotionalMsgs)),e("div",{key:"874e81d5e4727160a85bb3381fdfadcd65e774c0",slot:"subtitle",class:"s-user-settings-section-subtitle"},this.capitalizeText(this.promotionalMsgsDesc)),e("div",{key:"6d2aacf7a72c4d25163913eccbb0a3e94595ec75",slot:"action",class:"s-user-settings-section-action"},e("label",{key:"cf58459624592b34083afe61a0afc29dea03864e",class:"s-toggle"},e("input",{key:"b854ce4ca8224c8200623aad0dea4c659d89dee1",class:"s-toggle-input",checked:this.isNotifiable,onChange:s=>this.toggleSetting("is_notifiable",s),type:"checkbox"}),e("div",{key:"785a5765e36056629a23ca53e48715f91c14ee1f",class:"s-toggle-switcher"}))))),e("div",{key:"9f58724a8d748809b39874efaa861643a78076eb",class:"s-user-settings-section s-user-settings-section-deactivate-user"},e("salla-list-tile",{key:"12a69027f2822b6fa1e8fb641278932fc2206335"},e("div",{key:"679eec74598612167c77443e5f6977991b333fd7",slot:"icon",class:"s-user-settings-section-icon"},e("span",{key:"0263f8f31ad3e4ca60f2bb4bae910c143f2d36a8",innerHTML:t})),e("div",{key:"6c0c17dfbcbb48ae3882b07b58fb0d1245a28cdb",slot:"title",class:"s-user-settings-section-title"},this.capitalizeText(this.deactivateAccount)),e("div",{key:"07389c3b86b3d8e821b8b9c33cf43de1ee6527db",slot:"subtitle",class:"s-user-settings-section-subtitle"},this.capitalizeText(this.deactivateDesc)),e("div",{key:"e98736162d465c0717550eb8231b120acfafc4f6",slot:"action",class:"s-user-settings-section-action"},e("salla-button",{key:"d29c5023b3a35f95c94a06dc87f0e2504b3a6390",fill:"outline",color:"danger",shape:"btn",size:"medium",width:"normal",onClick:()=>this.openDeactivateModal()},this.capitalizeText(this.deactivateAccount))))),e("salla-modal",{key:"6f23ca61fe62de261e7d2f616a4d5bf13fba1577",width:"sm",subTitle:this.capitalizeText(this.sorryForLeavingText),ref:s=>this.confirmationModal=s},e("span",{key:"89073dfc15d4a1349618180c776968012e843556",slot:"icon",class:"s-user-settings-confirmation-icon",innerHTML:t}),e("div",{key:"f464a56ab783c4ddd51cc40e4d4dbf2f4ae21be2",class:"s-user-settings-confirmation"},e("div",{key:"e9921faaf8718ba51937006360b11d409bde4e05",class:"s-user-settings-confirmation-warning"},this.capitalizeText(this.warningText)),e("div",{key:"4a71df323e6fa2b86cb85e77af438a51e9c1c5a9",class:"s-user-settings-confirmation-actions"},e("salla-button",{key:"156249d17bdcc25b7c586af416001ec60e8b0f5b",width:"wide",onClick:()=>this.confirmationModal.close()},this.capitalizeText(this.keepAccount)),e("salla-button",{key:"acbe44c04f77f8ccdcaeb90bfb731de399f88fc7",fill:"outline",loading:this.buttonLoading,width:"wide",onClick:()=>this.deleteAccount()},this.capitalizeText(this.deactivateAccount))))))}};i.style="";export{i as salla_user_settings}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,h as s,H as i,a}from"./p-CV1rqKQz.js";import{S as e}from"./p-D4oPi1Ov.js";const c=class{constructor(s){t(this,s),this.size="md",this.color="dark",this.digits="auto",this.daysLabel=salla.lang.getWithDefault("pages.checkout.day","يوم"),this.hoursLabel=salla.lang.getWithDefault("pages.checkout.hour","ساعة"),this.minutesLabel=salla.lang.getWithDefault("pages.checkout.minute","دقيقة"),this.secondsLabel=salla.lang.getWithDefault("pages.checkout.second","ثانية"),this.endLabel=salla.lang.getWithDefault("pages.checkout.offer_ended","انتهت مدة العرض"),this.invalidDate=salla.lang.getWithDefault("blocks.buy_as_gift.incorrect_date","الرجاء إدخال الموعد بشكل صحيح"),this.offerEnded=!1,this.days=this.number(0),this.hours=this.number(0),this.minutes=this.number(0),this.seconds=this.number(0),salla.lang.onLoaded((()=>{this.daysLabel=salla.lang.getWithDefault("pages.checkout.day","يوم"),this.hoursLabel=salla.lang.getWithDefault("pages.checkout.hour","ساعة"),this.minutesLabel=salla.lang.getWithDefault("pages.checkout.minute","دقيقة"),this.invalidDate=salla.lang.getWithDefault("blocks.buy_as_gift.incorrect_date","الرجاء إدخال الموعد بشكل صحيح"),this.secondsLabel=salla.lang.getWithDefault("pages.checkout.second","ثانية"),this.endLabel=salla.lang.getWithDefault("pages.checkout.offer_ended","انتهت مدة العرض")})),this.date&&this.isValidDate(this.date)&&this.startCountDown()}async endCountDown(){clearInterval(this.countInterval),this.offerEnded=!0,this.days=this.number(0),this.hours=this.number(0),this.minutes=this.number(0),this.seconds=this.number(0)}componentWillLoad(){if("string"==typeof this.preOrder)try{this.normalizedPreOrder=JSON.parse(this.preOrder)}catch{this.normalizedPreOrder=void 0}else this.normalizedPreOrder=this.preOrder;this.normalizedPreOrder?.end_date&&(this.date=this.normalizedPreOrder.end_date,this.date&&this.isValidDate(this.date)&&this.startCountDown())}isValidDate(t){let s,i=t.includes("-"),a=t.split(" ");return s=i?a[0].replace(/-/g,"/"):a[0],!isNaN(Date.parse(s))}number(t){return salla.helpers.number(t,"en"===this.digits)}startCountDown(){let t=new Date(this.date.replace(/-/g,"/"));(this.endOfDay||1===this.date.split(" ").length)&&t.setHours(23,59,59,999);let s=t.getTime();this.countInterval=setInterval((()=>{let t=(new Date).getTime(),i=s-t;this.days=this.number(Math.floor(i/864e5)),this.hours=this.number(Math.floor(i%864e5/36e5)),this.minutes=this.number(Math.floor(i%36e5/6e4)),this.seconds=this.number(Math.floor(i%6e4/1e3)),i<0&&this.endCountDown()}),1e3)}renderCountDown(){return s("ul",{class:`s-count-down-list ${this.boxed?"s-count-down-boxed":""} ${this.offerEnded?"s-count-down-ended":""} s-count-down-${this.size} s-count-down-${this.color}`},s("li",{class:"s-count-down-item"},s("div",{class:"s-count-down-item-value"},this.seconds),this.labeled&&s("div",{class:"s-count-down-item-label"},this.secondsLabel)),s("li",{class:"s-count-down-item"},s("div",{class:"s-count-down-item-value"},this.minutes),this.labeled&&s("div",{class:"s-count-down-item-label"},this.minutesLabel)),s("li",{class:"s-count-down-item"},s("div",{class:"s-count-down-item-value"},this.hours),this.labeled&&s("div",{class:"s-count-down-item-label"},this.hoursLabel)),s("li",{class:"s-count-down-item"},s("div",{class:"s-count-down-item-value"},this.days),this.labeled&&s("div",{class:"s-count-down-item-label"},this.daysLabel)))}renderInvalidDate(){return s("div",{class:"s-count-down-text-center"},this.invalidDate)}renderOfferEnded(){return s("div",{class:"s-count-down-end-text"},this.endText?this.endText:this.endLabel)}renderPreOrderToBeAvailableOn(){return this.normalizedPreOrder?.availability_date&&this.isValidDate(this.normalizedPreOrder?.availability_date)?s("div",{class:"s-count-down-info-message"},s("i",{class:"sicon-info"}),s("span",null,salla.lang.getWithDefault("pages.products.expected_to_be","متوقَّع توفُّره بتاريخ:")),s("span",null,new Date(this.normalizedPreOrder?.availability_date).toLocaleDateString(salla.lang.locale,{weekday:"long",year:"numeric",month:"long",day:"numeric"}))):null}renderPreOrderCountDown(){return this.normalizedPreOrder?.activate_countdown?s("div",{class:"s-count-down-pre-order-container"},s("p",{class:"text-sm "},salla.lang.getWithDefault("pages.products.pre_order_ends_in","ينتهي الطلب المسبق خلال:")),this.renderCountDown()):null}renderPreOrder(){return s("div",null,"object"==typeof this.normalizedPreOrder&&this.normalizedPreOrder?.availability_date&&this.renderPreOrderToBeAvailableOn(),this.renderPreOrderCountDown())}renderPrefixText(){return this.prefixText?s("span",{class:"s-count-down-prefix-text"},this.prefixText):null}renderButton(){return this.withButton&&this.buttonText?s("salla-button",{color:"primary",size:"medium",href:this.buttonHref},this.buttonIcon?s("i",{class:this.buttonIcon}):null,s("span",null,this.buttonText)):null}renderContent(){return this.date?this.isValidDate(this.date)?this.preOrder?this.renderPreOrder():this.renderCountDown():this.renderInvalidDate():null}render(){return s(i,{key:"11e7cf7cf77bbde82d990107b7ccda8f1fc9ad6f",class:`s-count-down-wrapper ${this.preOrder&&this.isValidDate(this.date)?"s-count-down-pre-order":""} ${this.horizontal?"s-count-down-horizontal":""} ${this.withButton?"s-count-down-with-button":""}`},this.renderPrefixText(),this.renderContent(),this.offerEnded&&this.renderOfferEnded(),this.renderButton())}};c.style="";var o='\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>heart</title>\n<path d="M23.333 2.267c-3.547 0-5.779 1.605-7.333 3.061-1.555-1.456-3.787-3.061-7.333-3.061-5.955 0-8.667 5.045-8.667 9.733 0 8.503 10.147 14.735 15.513 16.841 0.156 0.061 0.321 0.092 0.487 0.092s0.331-0.031 0.487-0.092c5.367-2.107 15.513-8.339 15.513-16.841 0-4.688-2.712-9.733-8.667-9.733zM16 26.161c-5.537-2.309-13.333-7.799-13.333-14.161 0-3.517 1.856-7.067 6-7.067 2.983 0 4.656 1.451 6.384 3.203 0.5 0.508 1.399 0.508 1.899 0 1.728-1.752 3.401-3.203 6.384-3.203 4.144 0 6 3.549 6 7.067 0 6.363-7.796 11.852-13.333 14.161z"></path>\n</svg>\n';const r=class{constructor(s){if(t(this,s),salla.onReady((()=>{this.fitImageHeight=salla.config.get("store.settings.product.fit_type"),salla.wishlist.event.onAdded(((t,s)=>this.toggleFavoriteIcon(!0,s))),salla.wishlist.event.onRemoved(((t,s)=>this.toggleFavoriteIcon(!1,s))),this.placeholder=salla.url.asset(salla.config.get("theme.settings.placeholder"))})),salla.lang.onLoaded((()=>{this.remained=salla.lang.get("pages.products.remained"),this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.startingPrice=salla.lang.get("pages.products.starting_price"),this.addToCart=salla.lang.get("pages.cart.add_to_cart"),this.outOfStock=salla.lang.get("pages.products.out_of_stock")})),this.product)try{this.productData="object"==typeof this.product?this.product:JSON.parse(this.product)}catch(t){salla.log("Bad json passed via product prop")}}initCircleBar(){let t=this.productData.quantity/(this.productData.quantity>100?2*this.productData.quantity:100)*100;this.pie.querySelector(".s-product-card-content-pie-svg-bar").style.strokeDashoffset=100-t}toggleFavoriteIcon(t=!0,s=null){s&&s!==this.productData.id||this.wishlistBtn?.classList.toggle("s-product-card-wishlist-added",t)}formatDate(t){let s=new Date(t);return`${s.getFullYear()}-${s.getMonth()+1}-${s.getDate()}`}getProductBadge(){return this.productData.promotion_title?s("div",{class:"s-product-card-promotion-title"},this.productData.promotion_title):this.showQuantity&&this.productData?.quantity?s("div",{class:"s-product-card-quantity"},this.remained," ",salla.helpers.number(this.productData?.quantity)):this.showQuantity&&this.productData?.is_out_of_stock?s("div",{class:"s-product-card-out-badge"},this.outOfStock):""}getPriceFormat(t){return t&&0!=t?salla.money(t):salla.config.get("store.settings.product.show_price_as_dash")?"-":""}getProductPrice(){return this.productData.is_on_sale?s("div",{class:"s-product-card-sale-price"},s("h4",{innerHTML:this.getPriceFormat(this.productData.sale_price)}),s("span",{innerHTML:this.getPriceFormat(this.productData?.regular_price)})):this.productData.starting_price?s("div",{class:"s-product-card-starting-price"},s("p",null,this.startingPrice),s("h4",{innerHTML:this.getPriceFormat(this.productData?.starting_price)})):s("h4",{class:"s-product-card-price",innerHTML:this.getPriceFormat(this.productData?.price)})}render(){const t={"s-product-card-entry":!0,"s-product-card-vertical":!this.horizontal&&!this.fullImage&&!this.minimal,"s-product-card-horizontal":this.horizontal&&!this.fullImage&&!this.minimal,"s-product-card-fit-height":this.fitImageHeight&&!this.isSpecial&&!this.fullImage&&!this.minimal,"s-product-card-special":this.isSpecial,"s-product-card-full-image":this.fullImage,"s-product-card-minimal":this.minimal,"s-product-card-compact":this.compact,"s-product-card-donation":this.productData?.donation,"s-product-card-shadow":this.shadowOnHover,"s-product-card-out-of-stock":this.productData?.is_out_of_stock},a=this.productData?.url?{href:this.productData.url,title:`Learn more about ${this.productData?.name}`}:{};return s(i,{key:"7184dd5df9a903e8efb13e9d7ebfde785c9de7cb",id:`product-${this.productData?.id}`,class:t},s("div",{key:"d26a9f0757675e3eca8c1c927af5a693fac362aa",class:this.fullImage?"s-product-card-image-full":"s-product-card-image"},s("a",{key:"740236251eb99e95487c6a489638cbccc224a1b7",...a},s("img",{key:"8d253d0e2bacac675a64bc023d71e2c9926f0586",class:`s-product-card-image-${salla.url.is_placeholder(this.productData?.image?.url)?"contain":this.fitImageHeight?this.fitImageHeight:"cover"} lazy`,src:this.placeholder,alt:this.productData?.image?.alt||this.productData?.name,"data-src":this.productData?.image?.url||this.productData?.thumbnail}),this.fullImage||this.minimal?"":this.getProductBadge()),this.fullImage&&s("a",{key:"97b6378012c501176992dc1bf2bcebd0ddb1b1e4",...a,class:"s-product-card-overlay"}),this.horizontal||this.fullImage?"":s("salla-button",{shape:"icon",fill:"none",color:"light","aria-label":"Add or remove to wishlist",ref:t=>this.wishlistBtn=t,class:"s-product-card-wishlist-btn animated",onClick:()=>salla.wishlist.toggle(this.productData.id)},s("span",{innerHTML:o}))),s("div",{key:"b5f92299df71a73388dbb8e12592e8b7f4c99e91",class:"s-product-card-content"},this.isSpecial&&this.productData?.quantity?s("div",{class:"s-product-card-content-pie",ref:t=>this.pie=t},s("span",null,s("b",null,salla.helpers.number(this.productData?.quantity)),this.remained),s("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"-2 -1 36 34",class:"s-product-card-content-pie-svg"},s("circle",{cx:"16",cy:"16",r:"15.9155",class:"s-product-card-content-pie-svg-base"}),s("circle",{cx:"16",cy:"16",r:"15.9155",class:"s-product-card-content-pie-svg-bar"}))):"",s("div",{key:"dc37b35ce1331859a8c8ce009880faddee014ff4",class:{"s-product-card-content-main":!0,"s-product-card-content-extra-padding":this.isSpecial}},s("h3",{key:"54bbe09fe87302771966928902e2a69ec5c966b3",class:"s-product-card-content-title"},s("a",{key:"d9ed3ae0f677099860b3448fb52d11c678cabb88",...a},this.productData?.name)),this.productData?.subtitle&&!this.minimal?s("p",{class:"s-product-card-content-subtitle"},this.productData?.subtitle):""),!this.productData?.donation||this.minimal||this.fullImage?"":[s("salla-progress-bar",{donation:this.productData?.donation}),s("div",{class:"s-product-card-donation-input"},this.productData?.donation?.can_donate?[s("label",{htmlFor:"donation-amount"},this.donationAmount," ",s("span",null,"*")),s("input",{type:"text",onInput:t=>{salla.helpers.inputDigitsOnly(t.target),this.addBtn.donatingAmount=t.target.value},id:"donation-amount",name:"donating_amount",class:"s-form-control",placeholder:this.donationAmount})]:"")],s("div",{key:"d687ec1039228883aeaaa50f93ad419bf437027a",class:{"s-product-card-content-sub":!0,"s-product-card-content-extra-padding":this.isSpecial}},this.getProductPrice(),this.productData?.rating?.stars&&!this.minimal?s("div",{class:"s-product-card-rating"},s("span",{innerHTML:e}),s("span",null,this.productData.rating.stars)):""),this.isSpecial&&this.productData.discount_ends?s("salla-count-down",{date:this.formatDate(this.productData.discount_ends),"end-of-day":!0,boxed:!0,labeled:!0}):"",this.hideAddBtn||this.compact?"":s("div",{class:"s-product-card-content-footer"},s("salla-add-product-button",{fill:"outline",width:"wide",ref:t=>this.addBtn=t,"product-id":this.productData.id,"product-status":this.productData.status,"product-type":this.productData.type},s("slot",{name:"add-to-cart-label"},this.productData.add_to_cart_label)),this.horizontal||this.fullImage?s("salla-button",{shape:"icon",fill:"none",color:"light",ref:t=>this.wishlistBtn=t,"aria-label":"Add or remove to wishlist",class:"s-product-card-wishlist-btn animated",onClick:()=>salla.wishlist.toggle(this.productData.id),"data-id":"{{ product.id }}"},s("span",{class:"text-xl",innerHTML:o})):"")),!this.hideAddBtn&&this.compact?s("div",{class:"s-product-card-content-footer"},s("salla-add-product-button",{ref:t=>this.addBtn=t,"product-id":this.productData.id,"product-status":this.productData.status,"product-type":this.productData.type,class:"s-add-product-button-compact"},s("slot",{name:"add-to-cart-label"},this.productData.add_to_cart_label))):"")}componentDidLoad(){document.lazyLoadInstance?.update(this.host.querySelectorAll(".lazy")),this.productData?.quantity&&this.isSpecial&&this.initCircleBar(),!salla.config.isGuest()&&salla.storage.get("salla::wishlist",[]).includes(this.productData?.id)&&this.toggleFavoriteIcon()}static get assetsDirs(){return["assets"]}get host(){return a(this)}};r.style='.s-product-card-image::before{font-family:"sallaicons";content:"\\ec1f" !important}.s-product-card-content-pie-svg circle{transition:stroke-dashoffset 1s linear;-webkit-transition:stroke-dashoffset 1s linear;-moz-transition:stroke-dashoffset 1s linear;-ms-transition:stroke-dashoffset 1s linear;-o-transition:stroke-dashoffset 1s linear;stroke:#E8EDF2;stroke-width:2px;stroke-linecap:round;fill:none}.s-product-card-content-pie-svg-bar{stroke:var(--color-primary) !important;stroke-dasharray:100 100;stroke-dashoffset:100}';export{c as salla_count_down,r as salla_product_card}
4
+ import{r as t,h as s,H as i,a}from"./p-Y6CiunLU.js";import{S as e}from"./p-D4oPi1Ov.js";const c=class{constructor(s){t(this,s),this.size="md",this.color="dark",this.digits="auto",this.daysLabel=salla.lang.getWithDefault("pages.checkout.day","يوم"),this.hoursLabel=salla.lang.getWithDefault("pages.checkout.hour","ساعة"),this.minutesLabel=salla.lang.getWithDefault("pages.checkout.minute","دقيقة"),this.secondsLabel=salla.lang.getWithDefault("pages.checkout.second","ثانية"),this.endLabel=salla.lang.getWithDefault("pages.checkout.offer_ended","انتهت مدة العرض"),this.invalidDate=salla.lang.getWithDefault("blocks.buy_as_gift.incorrect_date","الرجاء إدخال الموعد بشكل صحيح"),this.offerEnded=!1,this.days=this.number(0),this.hours=this.number(0),this.minutes=this.number(0),this.seconds=this.number(0),salla.lang.onLoaded((()=>{this.daysLabel=salla.lang.getWithDefault("pages.checkout.day","يوم"),this.hoursLabel=salla.lang.getWithDefault("pages.checkout.hour","ساعة"),this.minutesLabel=salla.lang.getWithDefault("pages.checkout.minute","دقيقة"),this.invalidDate=salla.lang.getWithDefault("blocks.buy_as_gift.incorrect_date","الرجاء إدخال الموعد بشكل صحيح"),this.secondsLabel=salla.lang.getWithDefault("pages.checkout.second","ثانية"),this.endLabel=salla.lang.getWithDefault("pages.checkout.offer_ended","انتهت مدة العرض")})),this.date&&this.isValidDate(this.date)&&this.startCountDown()}async endCountDown(){clearInterval(this.countInterval),this.offerEnded=!0,this.days=this.number(0),this.hours=this.number(0),this.minutes=this.number(0),this.seconds=this.number(0)}componentWillLoad(){if("string"==typeof this.preOrder)try{this.normalizedPreOrder=JSON.parse(this.preOrder)}catch{this.normalizedPreOrder=void 0}else this.normalizedPreOrder=this.preOrder;this.normalizedPreOrder?.end_date&&(this.date=this.normalizedPreOrder.end_date,this.date&&this.isValidDate(this.date)&&this.startCountDown())}isValidDate(t){let s,i=t.includes("-"),a=t.split(" ");return s=i?a[0].replace(/-/g,"/"):a[0],!isNaN(Date.parse(s))}number(t){return salla.helpers.number(t,"en"===this.digits)}startCountDown(){let t=new Date(this.date.replace(/-/g,"/"));(this.endOfDay||1===this.date.split(" ").length)&&t.setHours(23,59,59,999);let s=t.getTime();this.countInterval=setInterval((()=>{let t=(new Date).getTime(),i=s-t;this.days=this.number(Math.floor(i/864e5)),this.hours=this.number(Math.floor(i%864e5/36e5)),this.minutes=this.number(Math.floor(i%36e5/6e4)),this.seconds=this.number(Math.floor(i%6e4/1e3)),i<0&&this.endCountDown()}),1e3)}renderCountDown(){return s("ul",{class:`s-count-down-list ${this.boxed?"s-count-down-boxed":""} ${this.offerEnded?"s-count-down-ended":""} s-count-down-${this.size} s-count-down-${this.color}`},s("li",{class:"s-count-down-item"},s("div",{class:"s-count-down-item-value"},this.seconds),this.labeled&&s("div",{class:"s-count-down-item-label"},this.secondsLabel)),s("li",{class:"s-count-down-item"},s("div",{class:"s-count-down-item-value"},this.minutes),this.labeled&&s("div",{class:"s-count-down-item-label"},this.minutesLabel)),s("li",{class:"s-count-down-item"},s("div",{class:"s-count-down-item-value"},this.hours),this.labeled&&s("div",{class:"s-count-down-item-label"},this.hoursLabel)),s("li",{class:"s-count-down-item"},s("div",{class:"s-count-down-item-value"},this.days),this.labeled&&s("div",{class:"s-count-down-item-label"},this.daysLabel)))}renderInvalidDate(){return s("div",{class:"s-count-down-text-center"},this.invalidDate)}renderOfferEnded(){return s("div",{class:"s-count-down-end-text"},this.endText?this.endText:this.endLabel)}renderPreOrderToBeAvailableOn(){return this.normalizedPreOrder?.availability_date&&this.isValidDate(this.normalizedPreOrder?.availability_date)?s("div",{class:"s-count-down-info-message"},s("i",{class:"sicon-info"}),s("span",null,salla.lang.getWithDefault("pages.products.expected_to_be","متوقَّع توفُّره بتاريخ:")),s("span",null,new Date(this.normalizedPreOrder?.availability_date).toLocaleDateString(salla.lang.locale,{weekday:"long",year:"numeric",month:"long",day:"numeric"}))):null}renderPreOrderCountDown(){return this.normalizedPreOrder?.activate_countdown?s("div",{class:"s-count-down-pre-order-container"},s("p",{class:"text-sm "},salla.lang.getWithDefault("pages.products.pre_order_ends_in","ينتهي الطلب المسبق خلال:")),this.renderCountDown()):null}renderPreOrder(){return s("div",null,"object"==typeof this.normalizedPreOrder&&this.normalizedPreOrder?.availability_date&&this.renderPreOrderToBeAvailableOn(),this.renderPreOrderCountDown())}renderPrefixText(){return this.prefixText?s("span",{class:"s-count-down-prefix-text"},this.prefixText):null}renderButton(){return this.withButton&&this.buttonText?s("salla-button",{color:"primary",size:"medium",href:this.buttonHref},this.buttonIcon?s("i",{class:this.buttonIcon}):null,s("span",null,this.buttonText)):null}renderContent(){return this.date?this.isValidDate(this.date)?this.preOrder?this.renderPreOrder():this.renderCountDown():this.renderInvalidDate():null}render(){return s(i,{key:"11e7cf7cf77bbde82d990107b7ccda8f1fc9ad6f",class:`s-count-down-wrapper ${this.preOrder&&this.isValidDate(this.date)?"s-count-down-pre-order":""} ${this.horizontal?"s-count-down-horizontal":""} ${this.withButton?"s-count-down-with-button":""}`},this.renderPrefixText(),this.renderContent(),this.offerEnded&&this.renderOfferEnded(),this.renderButton())}};c.style="";var o='\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>heart</title>\n<path d="M23.333 2.267c-3.547 0-5.779 1.605-7.333 3.061-1.555-1.456-3.787-3.061-7.333-3.061-5.955 0-8.667 5.045-8.667 9.733 0 8.503 10.147 14.735 15.513 16.841 0.156 0.061 0.321 0.092 0.487 0.092s0.331-0.031 0.487-0.092c5.367-2.107 15.513-8.339 15.513-16.841 0-4.688-2.712-9.733-8.667-9.733zM16 26.161c-5.537-2.309-13.333-7.799-13.333-14.161 0-3.517 1.856-7.067 6-7.067 2.983 0 4.656 1.451 6.384 3.203 0.5 0.508 1.399 0.508 1.899 0 1.728-1.752 3.401-3.203 6.384-3.203 4.144 0 6 3.549 6 7.067 0 6.363-7.796 11.852-13.333 14.161z"></path>\n</svg>\n';const r=class{constructor(s){if(t(this,s),salla.onReady((()=>{this.fitImageHeight=salla.config.get("store.settings.product.fit_type"),salla.wishlist.event.onAdded(((t,s)=>this.toggleFavoriteIcon(!0,s))),salla.wishlist.event.onRemoved(((t,s)=>this.toggleFavoriteIcon(!1,s))),this.placeholder=salla.url.asset(salla.config.get("theme.settings.placeholder"))})),salla.lang.onLoaded((()=>{this.remained=salla.lang.get("pages.products.remained"),this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.startingPrice=salla.lang.get("pages.products.starting_price"),this.addToCart=salla.lang.get("pages.cart.add_to_cart"),this.outOfStock=salla.lang.get("pages.products.out_of_stock")})),this.product)try{this.productData="object"==typeof this.product?this.product:JSON.parse(this.product)}catch(t){salla.log("Bad json passed via product prop")}}initCircleBar(){let t=this.productData.quantity/(this.productData.quantity>100?2*this.productData.quantity:100)*100;this.pie.querySelector(".s-product-card-content-pie-svg-bar").style.strokeDashoffset=100-t}toggleFavoriteIcon(t=!0,s=null){s&&s!==this.productData.id||this.wishlistBtn?.classList.toggle("s-product-card-wishlist-added",t)}formatDate(t){let s=new Date(t);return`${s.getFullYear()}-${s.getMonth()+1}-${s.getDate()}`}getProductBadge(){return this.productData.promotion_title?s("div",{class:"s-product-card-promotion-title"},this.productData.promotion_title):this.showQuantity&&this.productData?.quantity?s("div",{class:"s-product-card-quantity"},this.remained," ",salla.helpers.number(this.productData?.quantity)):this.showQuantity&&this.productData?.is_out_of_stock?s("div",{class:"s-product-card-out-badge"},this.outOfStock):""}getPriceFormat(t){return t&&0!=t?salla.money(t):salla.config.get("store.settings.product.show_price_as_dash")?"-":""}getProductPrice(){return this.productData.is_on_sale?s("div",{class:"s-product-card-sale-price"},s("h4",{innerHTML:this.getPriceFormat(this.productData.sale_price)}),s("span",{innerHTML:this.getPriceFormat(this.productData?.regular_price)})):this.productData.starting_price?s("div",{class:"s-product-card-starting-price"},s("p",null,this.startingPrice),s("h4",{innerHTML:this.getPriceFormat(this.productData?.starting_price)})):s("h4",{class:"s-product-card-price",innerHTML:this.getPriceFormat(this.productData?.price)})}render(){const t={"s-product-card-entry":!0,"s-product-card-vertical":!this.horizontal&&!this.fullImage&&!this.minimal,"s-product-card-horizontal":this.horizontal&&!this.fullImage&&!this.minimal,"s-product-card-fit-height":this.fitImageHeight&&!this.isSpecial&&!this.fullImage&&!this.minimal,"s-product-card-special":this.isSpecial,"s-product-card-full-image":this.fullImage,"s-product-card-minimal":this.minimal,"s-product-card-compact":this.compact,"s-product-card-donation":this.productData?.donation,"s-product-card-shadow":this.shadowOnHover,"s-product-card-out-of-stock":this.productData?.is_out_of_stock},a=this.productData?.url?{href:this.productData.url,title:`Learn more about ${this.productData?.name}`}:{};return s(i,{key:"7184dd5df9a903e8efb13e9d7ebfde785c9de7cb",id:`product-${this.productData?.id}`,class:t},s("div",{key:"d26a9f0757675e3eca8c1c927af5a693fac362aa",class:this.fullImage?"s-product-card-image-full":"s-product-card-image"},s("a",{key:"740236251eb99e95487c6a489638cbccc224a1b7",...a},s("img",{key:"8d253d0e2bacac675a64bc023d71e2c9926f0586",class:`s-product-card-image-${salla.url.is_placeholder(this.productData?.image?.url)?"contain":this.fitImageHeight?this.fitImageHeight:"cover"} lazy`,src:this.placeholder,alt:this.productData?.image?.alt||this.productData?.name,"data-src":this.productData?.image?.url||this.productData?.thumbnail}),this.fullImage||this.minimal?"":this.getProductBadge()),this.fullImage&&s("a",{key:"97b6378012c501176992dc1bf2bcebd0ddb1b1e4",...a,class:"s-product-card-overlay"}),this.horizontal||this.fullImage?"":s("salla-button",{shape:"icon",fill:"none",color:"light","aria-label":"Add or remove to wishlist",ref:t=>this.wishlistBtn=t,class:"s-product-card-wishlist-btn animated",onClick:()=>salla.wishlist.toggle(this.productData.id)},s("span",{innerHTML:o}))),s("div",{key:"b5f92299df71a73388dbb8e12592e8b7f4c99e91",class:"s-product-card-content"},this.isSpecial&&this.productData?.quantity?s("div",{class:"s-product-card-content-pie",ref:t=>this.pie=t},s("span",null,s("b",null,salla.helpers.number(this.productData?.quantity)),this.remained),s("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"-2 -1 36 34",class:"s-product-card-content-pie-svg"},s("circle",{cx:"16",cy:"16",r:"15.9155",class:"s-product-card-content-pie-svg-base"}),s("circle",{cx:"16",cy:"16",r:"15.9155",class:"s-product-card-content-pie-svg-bar"}))):"",s("div",{key:"dc37b35ce1331859a8c8ce009880faddee014ff4",class:{"s-product-card-content-main":!0,"s-product-card-content-extra-padding":this.isSpecial}},s("h3",{key:"54bbe09fe87302771966928902e2a69ec5c966b3",class:"s-product-card-content-title"},s("a",{key:"d9ed3ae0f677099860b3448fb52d11c678cabb88",...a},this.productData?.name)),this.productData?.subtitle&&!this.minimal?s("p",{class:"s-product-card-content-subtitle"},this.productData?.subtitle):""),!this.productData?.donation||this.minimal||this.fullImage?"":[s("salla-progress-bar",{donation:this.productData?.donation}),s("div",{class:"s-product-card-donation-input"},this.productData?.donation?.can_donate?[s("label",{htmlFor:"donation-amount"},this.donationAmount," ",s("span",null,"*")),s("input",{type:"text",onInput:t=>{salla.helpers.inputDigitsOnly(t.target),this.addBtn.donatingAmount=t.target.value},id:"donation-amount",name:"donating_amount",class:"s-form-control",placeholder:this.donationAmount})]:"")],s("div",{key:"d687ec1039228883aeaaa50f93ad419bf437027a",class:{"s-product-card-content-sub":!0,"s-product-card-content-extra-padding":this.isSpecial}},this.getProductPrice(),this.productData?.rating?.stars&&!this.minimal?s("div",{class:"s-product-card-rating"},s("span",{innerHTML:e}),s("span",null,this.productData.rating.stars)):""),this.isSpecial&&this.productData.discount_ends?s("salla-count-down",{date:this.formatDate(this.productData.discount_ends),"end-of-day":!0,boxed:!0,labeled:!0}):"",this.hideAddBtn||this.compact?"":s("div",{class:"s-product-card-content-footer"},s("salla-add-product-button",{fill:"outline",width:"wide",ref:t=>this.addBtn=t,"product-id":this.productData.id,"product-status":this.productData.status,"product-type":this.productData.type},s("slot",{name:"add-to-cart-label"},this.productData.add_to_cart_label)),this.horizontal||this.fullImage?s("salla-button",{shape:"icon",fill:"none",color:"light",ref:t=>this.wishlistBtn=t,"aria-label":"Add or remove to wishlist",class:"s-product-card-wishlist-btn animated",onClick:()=>salla.wishlist.toggle(this.productData.id),"data-id":"{{ product.id }}"},s("span",{class:"text-xl",innerHTML:o})):"")),!this.hideAddBtn&&this.compact?s("div",{class:"s-product-card-content-footer"},s("salla-add-product-button",{ref:t=>this.addBtn=t,"product-id":this.productData.id,"product-status":this.productData.status,"product-type":this.productData.type,class:"s-add-product-button-compact"},s("slot",{name:"add-to-cart-label"},this.productData.add_to_cart_label))):"")}componentDidLoad(){document.lazyLoadInstance?.update(this.host.querySelectorAll(".lazy")),this.productData?.quantity&&this.isSpecial&&this.initCircleBar(),!salla.config.isGuest()&&salla.storage.get("salla::wishlist",[]).includes(this.productData?.id)&&this.toggleFavoriteIcon()}static get assetsDirs(){return["assets"]}get host(){return a(this)}};r.style='.s-product-card-image::before{font-family:"sallaicons";content:"\\ec1f" !important}.s-product-card-content-pie-svg circle{transition:stroke-dashoffset 1s linear;-webkit-transition:stroke-dashoffset 1s linear;-moz-transition:stroke-dashoffset 1s linear;-ms-transition:stroke-dashoffset 1s linear;-o-transition:stroke-dashoffset 1s linear;stroke:#E8EDF2;stroke-width:2px;stroke-linecap:round;fill:none}.s-product-card-content-pie-svg-bar{stroke:var(--color-primary) !important;stroke-dasharray:100 100;stroke-dashoffset:100}';export{c as salla_count_down,r as salla_product_card}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as e,a}from"./p-CV1rqKQz.js";import{S as t}from"./p-BscTeWDc.js";import{H as i}from"./p-CHf8XdiS.js";import"./p-CgtvEd63.js";const r=class{constructor(e){s(this,e),this.inputValue="",this.translationLoaded=!1,this.loading=!1,this.typing=!1,this.debounce=setTimeout((()=>""),1e3),this.inline=!1,this.oval=!1,this.height=60,this.maxWords=5,this.showAction=!1,this.productSlot=this.host.querySelector('[slot="product"]')?.innerHTML||this.getDefaultProductSlot(),salla.event.on("search::open",(()=>this.open())),salla.lang.onLoaded((()=>{this.translationLoaded=!0})),salla.event.on("modalClosed",(()=>this.onModalClose()))}async open(){this.inline||await this.modal.open().then((()=>setTimeout((()=>this.searchInput.focus()),300)))}onModalClose(){this.searchInput.value="",this.results=void 0,this.afterSearching(),this.container.classList.remove("s-search-no-results")}handleKeyDown(s){"Enter"===s.key&&this.search_term?.length&&(window.location.href=salla.url.get("search?q="+encodeURI(this.search_term)))}getDefaultProductSlot(){return'<div class="s-search-product-image-container"> <img class="s-search-product-image" src="{image}" alt="{name}"/></div><div class="s-search-product-details"> <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price} <span class="s-search-product-regular-price">{regular_price}</span></div></div>'}debounceSearch(s){this.typing=!0,clearTimeout(this.debounce),this.debounce=setTimeout((()=>{this.typing=!1,this.search_term=s.target.value}),700)}limitWordsAndSearch(s){const e=s.target.value.trim().split(/\s+/);if(e.length>this.maxWords){const s=e.slice(0,this.maxWords).join(" ");this.searchInput.value=s}this.debounceSearch(s)}getQueryParam(s){return new URLSearchParams(window.location.search).get(s)}handleActionClick(){if(this.search_term&&this.search_term.length>2)return this.search(this.search_term)}handleSearch(s){this.inputValue=s,s.length>2?this.search(s):(this.results=void 0,this.afterSearching())}search(s){this.noResults.style.display="none",this.loading=!0,salla.product.fetch({source:"search",source_value:s}).then((e=>{this.results=e,salla.event.emit("Products Searched",s)})).catch((s=>"Query is same as previous one!"!==s?this.results=void 0:null)).finally((()=>this.afterSearching(!1)))}afterSearching(s=!0){this.noResults.style.display=s||this.results?.data.length>0?"none":"block",i.toggleElementClassIf(this.container,"s-search-container-open","s-search-no-results",(()=>this.results?.data.length)),this.loading=!1,salla.product.api.previousQuery="",this.inputValue.length<3&&this.container.classList.remove("s-search-no-results")}render(){const s=e("div",{key:"2e945555af379b5992375336c5b33a1dbb92589b",class:{"s-search-container":!0,"s-search-inline":this.inline},ref:s=>this.container=s},e("div",{key:"28c948e49a1d72a3a79e87477f37cc5f26dd4b3a",class:"s-search-input-wrapper"},e("span",{key:"b053ea1b4e6ed3c4030010dd61923421fcfeb214",class:"s-search-icon-wrap"},e("span",{key:"e1ecd01ab77d0ddd0b7b2010788fe28deaebd2af",class:"s-search-icon",innerHTML:this.loading?'<i class="s-search-spinner-loader"/>':t})),e("input",{key:"bca441ce72aac9bb85f2862413c77fa853e703c6",type:"search",enterkeyhint:"search",autocomplete:"off",class:"s-search-input",placeholder:salla.lang.get("blocks.header.search_placeholder"),onInput:s=>this.limitWordsAndSearch(s),onKeyDown:s=>this.handleKeyDown(s),ref:s=>this.searchInput=s,style:{height:this.height+"px",borderRadius:this.oval?this.height/2+"px":""}}),this.showAction?e("salla-button",{loading:this.loading,class:{"s-search-action":!0,"s-search-action-oval":this.oval},onClick:()=>this.handleActionClick()},!this.loading&&e("span",{innerHTML:t})):null),e("div",{key:"07ed4d8828b8343dd05bacb3a6904ad30eacce7a",class:"s-search-results"},this.results?.data.map((s=>e("a",{href:s.url+"?from=search-bar",class:{"s-search-product":!0,"s-search-product-not-available":!s.is_available},innerHTML:this.productSlot.replace(/\{name\}/g,s.name).replace(/\{price\}/g,s.price?salla.money(s.price):"").replace(/\{regular_price\}/g,s.is_on_sale&&s.regular_price?salla.money(s.regular_price):"").replace(/\{image\}/g,s.image.url)}))),e("p",{key:"7a3420f60f2172f39c44633176a454f9ae06f0ce",ref:s=>this.noResults=s,class:"s-search-no-results-placeholder"},salla.lang.get("common.elements.no_options"))));return this.inline?e("div",{class:"s-search-modal"},s):e("salla-modal",{position:"top",class:"s-search-modal",ref:s=>this.modal=s},s)}componentDidLoad(){this.afterSearching(),this.searchInput.value=this.getQueryParam("q")}get host(){return a(this)}static get watchers(){return{search_term:["handleSearch"]}}};r.style="";export{r as salla_search}
4
+ import{r as s,h as e,a}from"./p-Y6CiunLU.js";import{S as t}from"./p-BscTeWDc.js";import{H as i}from"./p-CHf8XdiS.js";import"./p-CgtvEd63.js";const h=class{constructor(e){s(this,e),this.inputValue="",this.translationLoaded=!1,this.loading=!1,this.typing=!1,this.debounce=setTimeout((()=>""),1e3),this.inline=!1,this.oval=!1,this.height=60,this.maxWords=5,this.showAction=!1,this.productSlot=this.host.querySelector('[slot="product"]')?.innerHTML||this.getDefaultProductSlot(),salla.event.on("search::open",(()=>this.open())),salla.lang.onLoaded((()=>{this.translationLoaded=!0})),salla.event.on("modalClosed",(()=>this.onModalClose()))}async open(){this.inline||await this.modal.open().then((()=>setTimeout((()=>this.searchInput.focus()),300)))}onModalClose(){this.searchInput.value="",this.results=void 0,this.afterSearching(),this.container.classList.remove("s-search-no-results")}handleKeyDown(s){"Enter"===s.key&&this.search_term?.length&&(window.location.href=salla.url.get("search?q="+encodeURI(this.search_term)))}getDefaultProductSlot(){return'<div class="s-search-product-image-container"> <img class="s-search-product-image" src="{image}" alt="{name}"/></div><div class="s-search-product-details"> <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price} <span class="s-search-product-regular-price">{regular_price}</span></div></div>'}debounceSearch(s){this.typing=!0,clearTimeout(this.debounce),this.debounce=setTimeout((()=>{this.typing=!1,this.search_term=s.target.value}),700)}limitWordsAndSearch(s){const e=s.target.value.trim().split(/\s+/);if(e.length>this.maxWords){const s=e.slice(0,this.maxWords).join(" ");this.searchInput.value=s}this.debounceSearch(s)}getQueryParam(s){return new URLSearchParams(window.location.search).get(s)}handleActionClick(){if(this.search_term&&this.search_term.length>2)return this.search(this.search_term)}handleSearch(s){this.inputValue=s,s.length>2?this.search(s):(this.results=void 0,this.afterSearching())}search(s){this.noResults.style.display="none",this.loading=!0,salla.product.fetch({source:"search",source_value:s}).then((e=>{this.results=e,salla.event.emit("Products Searched",s)})).catch((s=>"Query is same as previous one!"!==s?this.results=void 0:null)).finally((()=>this.afterSearching(!1)))}afterSearching(s=!0){this.noResults.style.display=s||this.results?.data.length>0?"none":"block",i.toggleElementClassIf(this.container,"s-search-container-open","s-search-no-results",(()=>this.results?.data.length)),this.loading=!1,salla.product.api.previousQuery="",this.inputValue.length<3&&this.container.classList.remove("s-search-no-results")}render(){const s=e("div",{key:"2e945555af379b5992375336c5b33a1dbb92589b",class:{"s-search-container":!0,"s-search-inline":this.inline},ref:s=>this.container=s},e("div",{key:"28c948e49a1d72a3a79e87477f37cc5f26dd4b3a",class:"s-search-input-wrapper"},e("span",{key:"b053ea1b4e6ed3c4030010dd61923421fcfeb214",class:"s-search-icon-wrap"},e("span",{key:"e1ecd01ab77d0ddd0b7b2010788fe28deaebd2af",class:"s-search-icon",innerHTML:this.loading?'<i class="s-search-spinner-loader"/>':t})),e("input",{key:"bca441ce72aac9bb85f2862413c77fa853e703c6",type:"search",enterkeyhint:"search",autocomplete:"off",class:"s-search-input",placeholder:salla.lang.get("blocks.header.search_placeholder"),onInput:s=>this.limitWordsAndSearch(s),onKeyDown:s=>this.handleKeyDown(s),ref:s=>this.searchInput=s,style:{height:this.height+"px",borderRadius:this.oval?this.height/2+"px":""}}),this.showAction?e("salla-button",{loading:this.loading,class:{"s-search-action":!0,"s-search-action-oval":this.oval},onClick:()=>this.handleActionClick()},!this.loading&&e("span",{innerHTML:t})):null),e("div",{key:"07ed4d8828b8343dd05bacb3a6904ad30eacce7a",class:"s-search-results"},this.results?.data.map((s=>e("a",{href:s.url+"?from=search-bar",class:{"s-search-product":!0,"s-search-product-not-available":!s.is_available},innerHTML:this.productSlot.replace(/\{name\}/g,s.name).replace(/\{price\}/g,s.price?salla.money(s.price):"").replace(/\{regular_price\}/g,s.is_on_sale&&s.regular_price?salla.money(s.regular_price):"").replace(/\{image\}/g,s.image.url)}))),e("p",{key:"7a3420f60f2172f39c44633176a454f9ae06f0ce",ref:s=>this.noResults=s,class:"s-search-no-results-placeholder"},salla.lang.get("common.elements.no_options"))));return this.inline?e("div",{class:"s-search-modal"},s):e("salla-modal",{position:"top",class:"s-search-modal",ref:s=>this.modal=s},s)}componentDidLoad(){this.afterSearching(),this.searchInput.value=this.getQueryParam("q")}get host(){return a(this)}static get watchers(){return{search_term:["handleSearch"]}}};h.style="";export{h as salla_search}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as c,h as l,H as t,a as s}from"./p-CV1rqKQz.js";import{f as e,t as i}from"./p-CO-PeZ27.js";const o=class{constructor(l){c(this,l),this.links=salla.config.get("store.social"),this.iconsList={instagram:'\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>instagram</title>\n<path d="M23 32h-14c-4.971 0-9-4.029-9-9v0-14c0-4.971 4.029-9 9-9v0h14c4.971 0 9 4.029 9 9v0 14c0 4.971-4.029 9-9 9v0zM9 2c-3.866 0-7 3.134-7 7v0 14c0 3.866 3.134 7 7 7v0h14c3.866 0 7-3.134 7-7v0-14c0-3.866-3.134-7-7-7v0zM16 24c-4.418 0-8-3.582-8-8s3.582-8 8-8c4.418 0 8 3.582 8 8v0c0 4.418-3.582 8-8 8v0zM16 10c-3.314 0-6 2.686-6 6s2.686 6 6 6c3.314 0 6-2.686 6-6v0c0-3.314-2.686-6-6-6v0zM25 9c-1.105 0-2-0.895-2-2s0.895-2 2-2c1.105 0 2 0.895 2 2v0c0 1.105-0.895 2-2 2v0zM25 7v0z"></path>\n</svg>\n',twitter:i,facebook:e,youtube:'\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>youtube</title>\n<path d="M16 28c-3.666 0-8.376-0.056-10.29-0.162-0.113 0.010-0.244 0.016-0.376 0.016-1.676 0-3.139-0.91-3.922-2.264l-0.012-0.022c-0.97-1.6-1.4-4.248-1.4-8.558s0.436-6.962 1.412-8.6c0.782-1.36 2.227-2.262 3.883-2.262 0.148 0 0.293 0.007 0.437 0.021l-0.018-0.001c1.872-0.124 6.544-0.168 10.286-0.168s8.4 0.044 10.292 0.168c0.124-0.012 0.267-0.019 0.412-0.019 1.656 0 3.101 0.905 3.866 2.247l0.012 0.022c0.982 1.624 1.418 4.27 1.418 8.582 0 4.338-0.438 6.982-1.422 8.6-0.789 1.364-2.241 2.268-3.904 2.268-0.133 0-0.265-0.006-0.395-0.017l0.017 0.001c-1.926 0.092-6.632 0.148-10.296 0.148zM16 8c-3.712 0-8.334 0.042-10.168 0.164-1.688 0.094-2.14 0.306-2.702 1.268-0.756 1.81-1.195 3.913-1.195 6.119 0 0.51 0.024 1.015 0.069 1.513l-0.005-0.064c-0.042 0.435-0.065 0.941-0.065 1.453 0 2.198 0.438 4.294 1.231 6.205l-0.039-0.107c0.566 0.968 1.022 1.184 2.708 1.296 3.29 0.184 17.022 0.184 20.34 0 1.678-0.11 2.132-0.326 2.684-1.28 0.764-1.803 1.208-3.899 1.208-6.1 0-0.513-0.024-1.020-0.071-1.52l0.005 0.064c0.042-0.436 0.065-0.943 0.065-1.455 0-2.203-0.439-4.303-1.235-6.218l0.040 0.107v-0.016c-0.554-0.958-1-1.17-2.684-1.264-1.862-0.122-6.644-0.164-10.186-0.164zM13 23c-0.552 0-1-0.448-1-1v0-10c0 0 0 0 0 0 0-0.552 0.448-1 1-1 0.196 0 0.38 0.057 0.534 0.154l-0.004-0.002 8 5c0.284 0.18 0.47 0.492 0.47 0.848s-0.186 0.668-0.466 0.846l-0.004 0.002-8 5c-0.15 0.095-0.334 0.152-0.53 0.152 0 0 0 0 0 0v0zM14 13.8v6.4l5.114-3.2z"></path>\n</svg>\n',snapchat:'\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>snapchat</title>\n<path d="M16.186 30h-0.266c-1.843-0.023-3.525-0.693-4.834-1.792l0.012 0.010c-0.476-0.405-1.043-0.72-1.665-0.909l-0.033-0.009c-0.287-0.044-0.617-0.069-0.954-0.069-0.492 0-0.972 0.053-1.434 0.155l0.044-0.008c-0.261 0.061-0.564 0.102-0.875 0.114l-0.009 0c-0.017 0.001-0.036 0.001-0.056 0.001-0.811 0-1.495-0.545-1.705-1.288l-0.003-0.012c-0.076-0.26-0.132-0.506-0.186-0.746-0.961-0.157-1.822-0.412-2.633-0.76l0.073 0.028c-0.667-0.259-1.199-0.745-1.509-1.362l-0.007-0.016c-0.082-0.189-0.135-0.409-0.146-0.64l-0-0.004c-0.002-0.031-0.003-0.067-0.003-0.103 0-0.841 0.614-1.538 1.417-1.668l0.010-0.001c0.822-0.141 1.555-0.438 2.198-0.859l-0.022 0.013c0.611-0.405 1.138-0.872 1.591-1.404l0.009-0.010c0.526-0.595 0.98-1.273 1.337-2.007l0.023-0.053c0.060-0.102 0.107-0.22 0.135-0.346l0.001-0.008c-0.092-0.020-0.73-0.222-0.972-0.298s-0.374-0.12-0.506-0.17c-0.546-0.205-1.016-0.487-1.424-0.839l0.006 0.005c-0.471-0.388-0.768-0.971-0.768-1.624 0-0.126 0.011-0.249 0.032-0.369l-0.002 0.013c0.143-0.644 0.551-1.172 1.1-1.474l0.011-0.006c0.389-0.241 0.861-0.384 1.366-0.384 0.347 0 0.678 0.067 0.982 0.19l-0.018-0.006c0.128 0.060 0.242 0.106 0.344 0.142-0.082-0.573-0.129-1.235-0.129-1.908 0-1.482 0.227-2.91 0.648-4.253l-0.027 0.101c0.512-1.142 1.207-2.114 2.056-2.925l0.004-0.003c0.7-0.664 1.516-1.214 2.413-1.616l0.055-0.022c1.128-0.5 2.444-0.794 3.828-0.8h0.592c1.386 0.007 2.701 0.301 3.893 0.825l-0.063-0.025c0.956 0.42 1.777 0.967 2.485 1.632l-0.005-0.004c0.855 0.815 1.55 1.789 2.039 2.876l0.023 0.058c0.396 1.237 0.625 2.659 0.625 4.135 0 0.658-0.045 1.304-0.133 1.938l0.008-0.073 0.172-0.076c0.303-0.16 0.661-0.253 1.042-0.253 0.374 0 0.728 0.091 1.039 0.251l-0.013-0.006c0.886 0.274 1.528 1.063 1.582 2.008l0 0.006c-0.001 0.602-0.25 1.146-0.65 1.536l-0 0c-0.429 0.408-0.945 0.73-1.516 0.935l-0.030 0.009c-0.144 0.056-0.316 0.112-0.504 0.17-0.367 0.103-0.686 0.235-0.984 0.398l0.024-0.012c0.018 0.030 0.042 0.094 0.086 0.18 0.963 2.174 2.834 3.796 5.118 4.4l0.054 0.012c0.814 0.133 1.427 0.83 1.427 1.671 0 0.036-0.001 0.072-0.003 0.108l0-0.005c-0.012 0.241-0.070 0.465-0.165 0.669l0.005-0.011c-0.319 0.624-0.847 1.103-1.489 1.352l-0.019 0.006c-0.739 0.323-1.6 0.578-2.497 0.724l-0.063 0.008c-0.056 0.264-0.112 0.496-0.186 0.742-0.215 0.747-0.893 1.284-1.696 1.284-0.011 0-0.021-0-0.032-0l0.002 0c-0.328-0.004-0.644-0.042-0.949-0.11l0.031 0.006c-0.404-0.090-0.869-0.142-1.345-0.142-0.353 0-0.7 0.029-1.038 0.083l0.037-0.005c-0.653 0.195-1.218 0.508-1.699 0.917l0.007-0.005c-1.275 1.065-2.916 1.731-4.71 1.788l-0.012 0zM8.444 25.218c0.457 0.001 0.904 0.041 1.339 0.117l-0.047-0.007c0.966 0.232 1.808 0.664 2.516 1.252l-0.010-0.008c0.96 0.829 2.199 1.357 3.56 1.427l0.014 0.001h0.37c1.373-0.070 2.61-0.597 3.576-1.43l-0.008 0.006c0.701-0.583 1.546-1.016 2.474-1.239l0.042-0.009c0.394-0.063 0.849-0.1 1.312-0.1 0.615 0 1.216 0.064 1.795 0.186l-0.057-0.010c0.105 0.023 0.238 0.045 0.372 0.059l0.016 0.001c0.042-0.162 0.076-0.314 0.11-0.47 0.059-0.339 0.156-0.641 0.287-0.924l-0.009 0.023 0.234-0.44 0.492-0.078c0.99-0.119 1.892-0.359 2.738-0.705l-0.070 0.025c0.086-0.040 0.158-0.076 0.216-0.11-2.748-0.86-4.933-2.816-6.081-5.342l-0.025-0.062c-0.184-0.31-0.294-0.684-0.294-1.083 0-0.27 0.050-0.528 0.14-0.765l-0.005 0.015c0.492-0.783 1.284-1.339 2.212-1.507l0.020-0.003c0.14-0.044 0.27-0.084 0.376-0.126 0.327-0.108 0.609-0.272 0.849-0.482l-0.003 0.002c0.074-0.106 0-0.2-0.216-0.284-0.094-0.041-0.203-0.065-0.318-0.066h-0c-0.529 0.242-1.142 0.411-1.786 0.474l-0.024 0.002c-0.313-0-0.612-0.064-0.883-0.18l0.015 0.006-0.628-0.28 0.072-1.272c0.093-0.623 0.146-1.342 0.146-2.074 0-1.269-0.16-2.501-0.46-3.677l0.022 0.103c-0.396-0.896-0.936-1.659-1.598-2.296l-0.002-0.002c-0.541-0.508-1.172-0.928-1.865-1.233l-0.043-0.017c-0.895-0.396-1.939-0.629-3.036-0.634h-0.002l-0.218-1v1h-0.348c-1.105 0.003-2.155 0.237-3.106 0.656l0.050-0.020c-0.733 0.322-1.361 0.742-1.903 1.253l0.003-0.003c-0.663 0.638-1.203 1.398-1.582 2.247l-0.018 0.045c-0.279 1.065-0.44 2.287-0.44 3.547 0 0.704 0.050 1.395 0.147 2.072l-0.009-0.078 0.080 1.372-0.618 0.284c-0.31 0.108-0.666 0.17-1.038 0.17-0.6 0-1.163-0.163-1.645-0.446l0.015 0.008c-0.019-0.001-0.041-0.002-0.064-0.002-0.154 0-0.299 0.039-0.425 0.109l0.005-0.002c-0.063 0.032-0.115 0.078-0.153 0.135l-0.001 0.001c0.258 0.244 0.567 0.435 0.91 0.556l0.018 0.006c0.094 0.036 0.2 0.070 0.32 0.108 0.971 0.167 1.784 0.732 2.282 1.516l0.008 0.014c0.087 0.225 0.137 0.486 0.137 0.758 0 0.403-0.11 0.781-0.303 1.104l0.005-0.010c-0.459 0.983-1.016 1.829-1.677 2.582l0.011-0.012c-0.588 0.687-1.26 1.279-2.004 1.768l-0.036 0.022c-0.689 0.451-1.49 0.805-2.346 1.017l-0.054 0.011c0.060 0.034 0.132 0.072 0.218 0.112 0.776 0.322 1.678 0.561 2.618 0.675l0.050 0.005 0.498 0.078 0.234 0.446c0.116 0.255 0.209 0.553 0.265 0.863l0.003 0.023c0.038 0.164 0.072 0.328 0.118 0.496 0.12-0.014 0.242-0.042 0.378-0.068 0.528-0.12 1.138-0.192 1.762-0.2l0.006-0zM30.244 22.892v0z"></path>\n</svg>\n',tiktok:'\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>tiktok</title>\n<path d="M29.046 7.029c-3.359 0-6.092-2.733-6.092-6.092 0-0.518-0.42-0.938-0.938-0.938h-5.021c-0.518 0-0.938 0.42-0.938 0.938v20.585c0 1.975-1.606 3.581-3.581 3.581s-3.581-1.606-3.581-3.581c0-1.975 1.606-3.581 3.581-3.581 0.518 0 0.938-0.42 0.938-0.938v-5.021c0-0.518-0.42-0.938-0.938-0.938-5.777 0-10.477 4.7-10.477 10.477s4.7 10.477 10.477 10.477c5.777 0 10.477-4.7 10.477-10.477v-9.112c1.866 0.995 3.942 1.514 6.092 1.514 0.518 0 0.938-0.42 0.938-0.938v-5.021c0-0.518-0.42-0.938-0.938-0.938zM28.108 12.011c-2.001-0.166-3.902-0.866-5.544-2.047-0.285-0.206-0.662-0.234-0.975-0.073s-0.51 0.482-0.51 0.834v10.798c0 4.743-3.859 8.602-8.602 8.602s-8.602-3.859-8.602-8.602c0-4.427 3.361-8.083 7.665-8.552v3.176c-2.563 0.446-4.519 2.687-4.519 5.376 0 3.009 2.447 5.456 5.456 5.456s5.456-2.448 5.456-5.456v-19.648h3.201c0.429 3.645 3.329 6.545 6.974 6.974z"></path>\n</svg>\n'},this.socialSlot=this.host.querySelector('[slot="social-item"]')?.innerHTML||'<a href={link} rel="noopener" target="_blank" title={type} aria-label={type}><span class="s-social-icon">{icon}</span></a>',salla.lang.onLoaded((()=>{this.links=salla.config.get("store.social")}))}getLinksArray(){return this.links?Object.entries(this.links).filter((([c,l])=>!!l&&"whatsapp"!==c)).map((([c,l])=>({type:c,value:l}))):[]}componentWillLoad(){return new Promise((c=>salla.onReady(c)))}render(){const c=this.getLinksArray();return l(t,{key:"20f01d2027bf9ac9fa635c2e814bf9778c5abf8c"},l("ul",{key:"016fc5a496d6efd36cf15dc805dd83ee4d6a9845",class:"s-social-list"},c.map((c=>l("li",{class:"s-social-link"},l("div",{id:"social-slot",innerHTML:this.socialSlot.replace(/\{icon\}/g,this.iconsList[c.type]).replace(/\{type\}/g,c.type).replace(/\{link\}/g,c.value.toString())}))))))}componentDidRender(){this.host.querySelectorAll("#social-slot").forEach((c=>c.replaceWith(c.firstChild))),this.host.querySelector('[slot="social-item"]')?.remove()}get host(){return s(this)}};o.style=":host{display:block}";export{o as salla_social}
4
+ import{r as c,h as l,H as t,a as s}from"./p-Y6CiunLU.js";import{f as e,t as i}from"./p-CO-PeZ27.js";const o=class{constructor(l){c(this,l),this.links=salla.config.get("store.social"),this.iconsList={instagram:'\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>instagram</title>\n<path d="M23 32h-14c-4.971 0-9-4.029-9-9v0-14c0-4.971 4.029-9 9-9v0h14c4.971 0 9 4.029 9 9v0 14c0 4.971-4.029 9-9 9v0zM9 2c-3.866 0-7 3.134-7 7v0 14c0 3.866 3.134 7 7 7v0h14c3.866 0 7-3.134 7-7v0-14c0-3.866-3.134-7-7-7v0zM16 24c-4.418 0-8-3.582-8-8s3.582-8 8-8c4.418 0 8 3.582 8 8v0c0 4.418-3.582 8-8 8v0zM16 10c-3.314 0-6 2.686-6 6s2.686 6 6 6c3.314 0 6-2.686 6-6v0c0-3.314-2.686-6-6-6v0zM25 9c-1.105 0-2-0.895-2-2s0.895-2 2-2c1.105 0 2 0.895 2 2v0c0 1.105-0.895 2-2 2v0zM25 7v0z"></path>\n</svg>\n',twitter:i,facebook:e,youtube:'\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>youtube</title>\n<path d="M16 28c-3.666 0-8.376-0.056-10.29-0.162-0.113 0.010-0.244 0.016-0.376 0.016-1.676 0-3.139-0.91-3.922-2.264l-0.012-0.022c-0.97-1.6-1.4-4.248-1.4-8.558s0.436-6.962 1.412-8.6c0.782-1.36 2.227-2.262 3.883-2.262 0.148 0 0.293 0.007 0.437 0.021l-0.018-0.001c1.872-0.124 6.544-0.168 10.286-0.168s8.4 0.044 10.292 0.168c0.124-0.012 0.267-0.019 0.412-0.019 1.656 0 3.101 0.905 3.866 2.247l0.012 0.022c0.982 1.624 1.418 4.27 1.418 8.582 0 4.338-0.438 6.982-1.422 8.6-0.789 1.364-2.241 2.268-3.904 2.268-0.133 0-0.265-0.006-0.395-0.017l0.017 0.001c-1.926 0.092-6.632 0.148-10.296 0.148zM16 8c-3.712 0-8.334 0.042-10.168 0.164-1.688 0.094-2.14 0.306-2.702 1.268-0.756 1.81-1.195 3.913-1.195 6.119 0 0.51 0.024 1.015 0.069 1.513l-0.005-0.064c-0.042 0.435-0.065 0.941-0.065 1.453 0 2.198 0.438 4.294 1.231 6.205l-0.039-0.107c0.566 0.968 1.022 1.184 2.708 1.296 3.29 0.184 17.022 0.184 20.34 0 1.678-0.11 2.132-0.326 2.684-1.28 0.764-1.803 1.208-3.899 1.208-6.1 0-0.513-0.024-1.020-0.071-1.52l0.005 0.064c0.042-0.436 0.065-0.943 0.065-1.455 0-2.203-0.439-4.303-1.235-6.218l0.040 0.107v-0.016c-0.554-0.958-1-1.17-2.684-1.264-1.862-0.122-6.644-0.164-10.186-0.164zM13 23c-0.552 0-1-0.448-1-1v0-10c0 0 0 0 0 0 0-0.552 0.448-1 1-1 0.196 0 0.38 0.057 0.534 0.154l-0.004-0.002 8 5c0.284 0.18 0.47 0.492 0.47 0.848s-0.186 0.668-0.466 0.846l-0.004 0.002-8 5c-0.15 0.095-0.334 0.152-0.53 0.152 0 0 0 0 0 0v0zM14 13.8v6.4l5.114-3.2z"></path>\n</svg>\n',snapchat:'\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>snapchat</title>\n<path d="M16.186 30h-0.266c-1.843-0.023-3.525-0.693-4.834-1.792l0.012 0.010c-0.476-0.405-1.043-0.72-1.665-0.909l-0.033-0.009c-0.287-0.044-0.617-0.069-0.954-0.069-0.492 0-0.972 0.053-1.434 0.155l0.044-0.008c-0.261 0.061-0.564 0.102-0.875 0.114l-0.009 0c-0.017 0.001-0.036 0.001-0.056 0.001-0.811 0-1.495-0.545-1.705-1.288l-0.003-0.012c-0.076-0.26-0.132-0.506-0.186-0.746-0.961-0.157-1.822-0.412-2.633-0.76l0.073 0.028c-0.667-0.259-1.199-0.745-1.509-1.362l-0.007-0.016c-0.082-0.189-0.135-0.409-0.146-0.64l-0-0.004c-0.002-0.031-0.003-0.067-0.003-0.103 0-0.841 0.614-1.538 1.417-1.668l0.010-0.001c0.822-0.141 1.555-0.438 2.198-0.859l-0.022 0.013c0.611-0.405 1.138-0.872 1.591-1.404l0.009-0.010c0.526-0.595 0.98-1.273 1.337-2.007l0.023-0.053c0.060-0.102 0.107-0.22 0.135-0.346l0.001-0.008c-0.092-0.020-0.73-0.222-0.972-0.298s-0.374-0.12-0.506-0.17c-0.546-0.205-1.016-0.487-1.424-0.839l0.006 0.005c-0.471-0.388-0.768-0.971-0.768-1.624 0-0.126 0.011-0.249 0.032-0.369l-0.002 0.013c0.143-0.644 0.551-1.172 1.1-1.474l0.011-0.006c0.389-0.241 0.861-0.384 1.366-0.384 0.347 0 0.678 0.067 0.982 0.19l-0.018-0.006c0.128 0.060 0.242 0.106 0.344 0.142-0.082-0.573-0.129-1.235-0.129-1.908 0-1.482 0.227-2.91 0.648-4.253l-0.027 0.101c0.512-1.142 1.207-2.114 2.056-2.925l0.004-0.003c0.7-0.664 1.516-1.214 2.413-1.616l0.055-0.022c1.128-0.5 2.444-0.794 3.828-0.8h0.592c1.386 0.007 2.701 0.301 3.893 0.825l-0.063-0.025c0.956 0.42 1.777 0.967 2.485 1.632l-0.005-0.004c0.855 0.815 1.55 1.789 2.039 2.876l0.023 0.058c0.396 1.237 0.625 2.659 0.625 4.135 0 0.658-0.045 1.304-0.133 1.938l0.008-0.073 0.172-0.076c0.303-0.16 0.661-0.253 1.042-0.253 0.374 0 0.728 0.091 1.039 0.251l-0.013-0.006c0.886 0.274 1.528 1.063 1.582 2.008l0 0.006c-0.001 0.602-0.25 1.146-0.65 1.536l-0 0c-0.429 0.408-0.945 0.73-1.516 0.935l-0.030 0.009c-0.144 0.056-0.316 0.112-0.504 0.17-0.367 0.103-0.686 0.235-0.984 0.398l0.024-0.012c0.018 0.030 0.042 0.094 0.086 0.18 0.963 2.174 2.834 3.796 5.118 4.4l0.054 0.012c0.814 0.133 1.427 0.83 1.427 1.671 0 0.036-0.001 0.072-0.003 0.108l0-0.005c-0.012 0.241-0.070 0.465-0.165 0.669l0.005-0.011c-0.319 0.624-0.847 1.103-1.489 1.352l-0.019 0.006c-0.739 0.323-1.6 0.578-2.497 0.724l-0.063 0.008c-0.056 0.264-0.112 0.496-0.186 0.742-0.215 0.747-0.893 1.284-1.696 1.284-0.011 0-0.021-0-0.032-0l0.002 0c-0.328-0.004-0.644-0.042-0.949-0.11l0.031 0.006c-0.404-0.090-0.869-0.142-1.345-0.142-0.353 0-0.7 0.029-1.038 0.083l0.037-0.005c-0.653 0.195-1.218 0.508-1.699 0.917l0.007-0.005c-1.275 1.065-2.916 1.731-4.71 1.788l-0.012 0zM8.444 25.218c0.457 0.001 0.904 0.041 1.339 0.117l-0.047-0.007c0.966 0.232 1.808 0.664 2.516 1.252l-0.010-0.008c0.96 0.829 2.199 1.357 3.56 1.427l0.014 0.001h0.37c1.373-0.070 2.61-0.597 3.576-1.43l-0.008 0.006c0.701-0.583 1.546-1.016 2.474-1.239l0.042-0.009c0.394-0.063 0.849-0.1 1.312-0.1 0.615 0 1.216 0.064 1.795 0.186l-0.057-0.010c0.105 0.023 0.238 0.045 0.372 0.059l0.016 0.001c0.042-0.162 0.076-0.314 0.11-0.47 0.059-0.339 0.156-0.641 0.287-0.924l-0.009 0.023 0.234-0.44 0.492-0.078c0.99-0.119 1.892-0.359 2.738-0.705l-0.070 0.025c0.086-0.040 0.158-0.076 0.216-0.11-2.748-0.86-4.933-2.816-6.081-5.342l-0.025-0.062c-0.184-0.31-0.294-0.684-0.294-1.083 0-0.27 0.050-0.528 0.14-0.765l-0.005 0.015c0.492-0.783 1.284-1.339 2.212-1.507l0.020-0.003c0.14-0.044 0.27-0.084 0.376-0.126 0.327-0.108 0.609-0.272 0.849-0.482l-0.003 0.002c0.074-0.106 0-0.2-0.216-0.284-0.094-0.041-0.203-0.065-0.318-0.066h-0c-0.529 0.242-1.142 0.411-1.786 0.474l-0.024 0.002c-0.313-0-0.612-0.064-0.883-0.18l0.015 0.006-0.628-0.28 0.072-1.272c0.093-0.623 0.146-1.342 0.146-2.074 0-1.269-0.16-2.501-0.46-3.677l0.022 0.103c-0.396-0.896-0.936-1.659-1.598-2.296l-0.002-0.002c-0.541-0.508-1.172-0.928-1.865-1.233l-0.043-0.017c-0.895-0.396-1.939-0.629-3.036-0.634h-0.002l-0.218-1v1h-0.348c-1.105 0.003-2.155 0.237-3.106 0.656l0.050-0.020c-0.733 0.322-1.361 0.742-1.903 1.253l0.003-0.003c-0.663 0.638-1.203 1.398-1.582 2.247l-0.018 0.045c-0.279 1.065-0.44 2.287-0.44 3.547 0 0.704 0.050 1.395 0.147 2.072l-0.009-0.078 0.080 1.372-0.618 0.284c-0.31 0.108-0.666 0.17-1.038 0.17-0.6 0-1.163-0.163-1.645-0.446l0.015 0.008c-0.019-0.001-0.041-0.002-0.064-0.002-0.154 0-0.299 0.039-0.425 0.109l0.005-0.002c-0.063 0.032-0.115 0.078-0.153 0.135l-0.001 0.001c0.258 0.244 0.567 0.435 0.91 0.556l0.018 0.006c0.094 0.036 0.2 0.070 0.32 0.108 0.971 0.167 1.784 0.732 2.282 1.516l0.008 0.014c0.087 0.225 0.137 0.486 0.137 0.758 0 0.403-0.11 0.781-0.303 1.104l0.005-0.010c-0.459 0.983-1.016 1.829-1.677 2.582l0.011-0.012c-0.588 0.687-1.26 1.279-2.004 1.768l-0.036 0.022c-0.689 0.451-1.49 0.805-2.346 1.017l-0.054 0.011c0.060 0.034 0.132 0.072 0.218 0.112 0.776 0.322 1.678 0.561 2.618 0.675l0.050 0.005 0.498 0.078 0.234 0.446c0.116 0.255 0.209 0.553 0.265 0.863l0.003 0.023c0.038 0.164 0.072 0.328 0.118 0.496 0.12-0.014 0.242-0.042 0.378-0.068 0.528-0.12 1.138-0.192 1.762-0.2l0.006-0zM30.244 22.892v0z"></path>\n</svg>\n',tiktok:'\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>tiktok</title>\n<path d="M29.046 7.029c-3.359 0-6.092-2.733-6.092-6.092 0-0.518-0.42-0.938-0.938-0.938h-5.021c-0.518 0-0.938 0.42-0.938 0.938v20.585c0 1.975-1.606 3.581-3.581 3.581s-3.581-1.606-3.581-3.581c0-1.975 1.606-3.581 3.581-3.581 0.518 0 0.938-0.42 0.938-0.938v-5.021c0-0.518-0.42-0.938-0.938-0.938-5.777 0-10.477 4.7-10.477 10.477s4.7 10.477 10.477 10.477c5.777 0 10.477-4.7 10.477-10.477v-9.112c1.866 0.995 3.942 1.514 6.092 1.514 0.518 0 0.938-0.42 0.938-0.938v-5.021c0-0.518-0.42-0.938-0.938-0.938zM28.108 12.011c-2.001-0.166-3.902-0.866-5.544-2.047-0.285-0.206-0.662-0.234-0.975-0.073s-0.51 0.482-0.51 0.834v10.798c0 4.743-3.859 8.602-8.602 8.602s-8.602-3.859-8.602-8.602c0-4.427 3.361-8.083 7.665-8.552v3.176c-2.563 0.446-4.519 2.687-4.519 5.376 0 3.009 2.447 5.456 5.456 5.456s5.456-2.448 5.456-5.456v-19.648h3.201c0.429 3.645 3.329 6.545 6.974 6.974z"></path>\n</svg>\n'},this.socialSlot=this.host.querySelector('[slot="social-item"]')?.innerHTML||'<a href={link} rel="noopener" target="_blank" title={type} aria-label={type}><span class="s-social-icon">{icon}</span></a>',salla.lang.onLoaded((()=>{this.links=salla.config.get("store.social")}))}getLinksArray(){return this.links?Object.entries(this.links).filter((([c,l])=>!!l&&"whatsapp"!==c)).map((([c,l])=>({type:c,value:l}))):[]}componentWillLoad(){return new Promise((c=>salla.onReady(c)))}render(){const c=this.getLinksArray();return l(t,{key:"20f01d2027bf9ac9fa635c2e814bf9778c5abf8c"},l("ul",{key:"016fc5a496d6efd36cf15dc805dd83ee4d6a9845",class:"s-social-list"},c.map((c=>l("li",{class:"s-social-link"},l("div",{id:"social-slot",innerHTML:this.socialSlot.replace(/\{icon\}/g,this.iconsList[c.type]).replace(/\{type\}/g,c.type).replace(/\{link\}/g,c.value.toString())}))))))}componentDidRender(){this.host.querySelectorAll("#social-slot").forEach((c=>c.replaceWith(c.firstChild))),this.host.querySelector('[slot="social-item"]')?.remove()}get host(){return s(this)}};o.style=":host{display:block}";export{o as salla_social}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,c as t,h as i,H as e,a as r}from"./p-CV1rqKQz.js";import{M as l}from"./p-DmgxDvXL.js";import{C as a}from"./p-BsLF_HK7.js";const h=class{constructor(i){s(this,i),this.quickOrderSubmited=t(this,"quickOrderSubmited"),this.quickOrderTitle="ليش تنتظر؟",this.subTitle="احصل على المنتج مباشرة الآن",this.payButtonTitle="اطلب المنتج",this.confirmPayButtonTitle="اشتر الآن",this.agreementText=salla.lang.get("pages.checkout.show_full_agreement"),this.isEmailRequired=!1,this.quickOrderStyle="default",this.isAvailable=!1,this.oneClick=!1,this.expanded=!1,this.isTermsRequired=!1,this.countryCode=salla.config.get("user.country_code","SA")||"SA",this.submitSucess=!1,this.placeHolderEmail=salla.lang.get("common.elements.email"),this.emailOptional=salla.lang.get("common.elements.optional"),this.agreementShowText=salla.lang.get("pages.checkout.show_full_agreement"),this.agreementModalHead=salla.lang.get("pages.checkout.full_agreement"),this.userNameLabel=salla.lang.get("pages.products.your_name"),this.termsChecked=!1,salla.onReady((()=>{this.productId=this.productId||salla.config.get("page.id")})),salla.lang.onLoaded((()=>{this.placeHolderEmail=salla.lang.get("common.elements.email"),this.emailOptional=salla.lang.get("common.elements.optional"),this.agreementShowText=salla.lang.get("pages.checkout.show_full_agreement"),this.agreementModalHead=salla.lang.get("pages.checkout.full_agreement"),this.userNameLabel=salla.lang.get("pages.products.your_name")}))}getBtnColor(){return"default"===this.quickOrderStyle?"light":"primary"}getErrorMessage(s,t){return"terms"==t?salla.lang.get("pages.checkout.check_agreement"):salla.lang.get(`common.errors.${s}`,{attribute:"name"==t?this.userNameLabel:this.placeHolderEmail})}handleInvalidInput(s){let t,i=s.target,e=i.validity;e.valueMissing?(t=this.getErrorMessage("field_required",i.name),console.log(this.getErrorMessage("field_required",i.name))):e.typeMismatch&&(t=this.getErrorMessage("invalid_value",i.name)),i.setCustomValidity(t)}async setWrapperHeight(){let s=this.host.querySelector(".s-quick-order-expandable");setTimeout((()=>{s.style.maxHeight=s.style.maxHeight||this.oneClick?null:s.scrollHeight+"px"}),50)}getDarkOrLight(){return"default"===this.quickOrderStyle&&salla.config.get("theme.color.is_dark")?"dark":"light"}getStyleColor(){return{gray:"#f3f3f3",white:"#ffffff",default:salla.config.get("theme.color.primary")}[this.quickOrderStyle]||"#f3f3f3"}async submit(s,t=!1){return s.preventDefault(),t&&!this.oneClick?(this.expanded=!this.expanded,void this.setWrapperHeight()):this.submitBtn.load().then((()=>this.getPayload())).then((s=>salla.api.cart.createQuickOrder(s))).then((()=>{setTimeout((()=>{this.submitBtn.stop(),this.submitSucess=!0,this.quickOrderSubmited.emit()}),200)})).catch((s=>s&&(console.error(s),this.submitBtn.stop())))}async getPayload(){return this.oneClick?{product_ids:[this.productId],agreement:!0}:{product_ids:[this.productId],email:this.emailInput?.value,phone:Number((await(this.phoneInput?.getValues()))?.phone),country_code:(await(this.phoneInput?.getValues()))?.countryCode||this.countryCode,name:this.nameInput?.value,agreement:this.termsChecked}}formatAgreementText(s,t=150){return s?s.length<=t?s:(new DOMParser).parseFromString(s,"text/html").documentElement.innerText.substring(0,t)+"...":""}loadQuickOrderSettings(){let s=salla.config.get("store.settings.quick_order");return s?(this.user=salla.config.get("user")||salla.storage.get("user")||{},this.countryCode=this.user?.country_code||this.countryCode,this.isEmailRequired=!this.user?.email&&this.isEmailRequired,this.oneClick=this.user?.email,this.initComponentData(s),Promise.resolve()):Promise.resolve()}initComponentData(s){this.quickOrderTitle=s.title,this.subTitle=s.sub_title,this.payButtonTitle=s.order_now_button,this.isEmailRequired=s.is_email_required,this.isTermsRequired=s.show_agreement,this.agreementText=s.agreement,this.confirmPayButtonTitle=s.confirm_button,this.thanksMessage=s.thanks_message,this.quickOrderStyle=s.style,this.isAvailable=!0,this.oneClick=this.oneClick&&!this.isTermsRequired}componentWillLoad(){return new Promise((s=>salla.onReady((()=>this.loadQuickOrderSettings().then(s)))))}render(){if(this.isAvailable)return this.submitSucess?i(e,{class:"s-quick-order"},i("div",{class:"s-quick-order-confirm",style:{backgroundColor:salla.config.get("theme.color.primary")+"10",borderColor:salla.config.get("theme.color.primary")+"10",color:salla.config.get("theme.color.primary")}},i("i",{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>party-horn</title>\n<path fill="currentColor" d="M5.333 4.013c0.736 0 1.333-0.596 1.333-1.333v-0.013c0-0.737-0.597-1.327-1.333-1.327s-1.333 0.603-1.333 1.34 0.597 1.333 1.333 1.333zM11.333 10c0.341 0 0.683-0.131 0.943-0.391 1.541-1.54 2.391-3.589 2.391-5.771v-2.505c0-0.737-0.597-1.333-1.333-1.333s-1.333 0.596-1.333 1.333v2.505c0 1.468-0.572 2.848-1.609 3.885-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391zM18.667 9.993c0.319 0 0.639-0.115 0.895-0.345 0.383-0.347 0.684-0.325 1.497-0.22 0.923 0.124 2.319 0.307 3.636-0.887 1.293-1.172 1.303-2.54 1.308-3.539 0.005-0.887 0.043-1.228 0.432-1.581 0.361-0.327 0.621-0.335 1.493-0.216 0.923 0.12 2.317 0.307 3.635-0.884 0.545-0.495 0.587-1.337 0.093-1.883-0.493-0.547-1.336-0.589-1.884-0.093-0.361 0.325-0.621 0.333-1.493 0.216-0.921-0.119-2.317-0.305-3.635 0.884-1.293 1.173-1.303 2.541-1.308 3.54-0.005 0.885-0.043 1.227-0.432 1.58-0.383 0.348-0.683 0.327-1.497 0.22-0.924-0.124-2.32-0.305-3.636 0.887-0.545 0.495-0.587 1.339-0.092 1.884 0.264 0.291 0.625 0.437 0.988 0.437zM18.667 16.013c0.736 0 1.333-0.596 1.333-1.333v-0.013c0-0.737-0.597-1.327-1.333-1.327s-1.333 0.603-1.333 1.34 0.597 1.333 1.333 1.333zM30.667 17.333h-2.505c-2.179 0-4.228 0.849-5.771 2.391-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.603 0.391 0.944 0.391s0.683-0.131 0.943-0.391c1.023-1.023 2.439-1.609 3.884-1.609h2.505c0.736 0 1.333-0.596 1.333-1.333s-0.597-1.333-1.333-1.333zM30.667 10.66c-0.736 0-1.333 0.603-1.333 1.34s0.597 1.333 1.333 1.333 1.333-0.596 1.333-1.333v-0.013c0-0.736-0.597-1.327-1.333-1.327zM29.333 26.66c-0.736 0-1.333 0.603-1.333 1.34s0.597 1.333 1.333 1.333 1.333-0.596 1.333-1.333v-0.013c0-0.736-0.597-1.327-1.333-1.327zM7.456 11.057c-0.327-0.327-0.799-0.46-1.249-0.356-0.449 0.107-0.812 0.439-0.959 0.876l-5.036 15.113c-0.487 1.457-0.113 3.037 0.973 4.125 0.772 0.771 1.792 1.183 2.84 1.183 0.428 0 0.861-0.068 1.284-0.209l15.112-5.037c0.439-0.145 0.769-0.508 0.876-0.959 0.107-0.449-0.028-0.921-0.355-1.249zM4.467 29.259c-0.503 0.163-1.023 0.043-1.395-0.329-0.373-0.373-0.497-0.896-0.329-1.396l4.355-13.065 10.436 10.435z"></path>\n</svg>\n'}),i("span",null,this.thanksMessage))):i(e,{class:`s-quick-order s-quick-order-${this.getDarkOrLight()}`},i("div",{class:`s-quick-order-container s-quick-order-${this.quickOrderStyle}`,style:{backgroundColor:this.getStyleColor()}},i("div",{class:"s-quick-order-button-cont"},i("div",null,i("h3",null,this.quickOrderTitle),i("p",null,this.subTitle)),i("salla-button",{class:this.expanded?"s-quick-order-btn-close":"",onClick:s=>this.submit(s,!0),color:this.getBtnColor()},this.oneClick?this.confirmPayButtonTitle:this.expanded?i("i",{innerHTML:a}):this.confirmPayButtonTitle)),i("form",{onSubmit:s=>this.submit(s),class:"s-quick-order-expandable "+(this.expanded?"s-quick-order-shown":"")},Salla.config.isGuest()&&[i("div",{class:"s-form-group"},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>portrait</title>\n<path d="M24 1.333h-16c-3.676 0-6.667 2.991-6.667 6.667v16c0 3.028 2.041 5.561 4.811 6.371 0.004 0.001 0.008 0.003 0.012 0.004 0.591 0.172 1.2 0.292 1.844 0.292h16c0.644 0 1.253-0.12 1.843-0.292 0.004-0.001 0.008-0.003 0.012-0.004 2.771-0.809 4.812-3.343 4.812-6.371v-16c0-3.676-2.991-6.667-6.667-6.667zM8.012 28c0.121-1.915 3.363-4 7.988-4s7.868 2.085 7.988 4zM28 24c0 1.24-0.579 2.335-1.467 3.069-0.768-3.288-5.112-5.736-10.533-5.736s-9.765 2.448-10.533 5.736c-0.888-0.735-1.467-1.829-1.467-3.069v-16c0-2.205 1.795-4 4-4h16c2.205 0 4 1.795 4 4zM16 6.667c-3.308 0-6 2.692-6 6s2.692 6 6 6 6-2.692 6-6-2.692-6-6-6zM16 16c-1.839 0-3.333-1.495-3.333-3.333s1.495-3.333 3.333-3.333 3.333 1.495 3.333 3.333-1.495 3.333-3.333 3.333z"></path>\n</svg>\n'}),i("input",{type:"text",required:!0,class:"s-form-control s-quick-order-phone-field",name:"name",placeholder:this.userNameLabel,ref:s=>this.nameInput=s})),i("div",{class:"s-quick-order-flex-input"},i("div",{class:"s-form-group"},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>iphone-x</title>\n<path d="M24 0h-16c-2.205 0-4 1.795-4 4v24c0 2.205 1.795 4 4 4h16c2.205 0 4-1.795 4-4v-24c0-2.205-1.795-4-4-4zM25.333 28c0 0.736-0.597 1.333-1.333 1.333h-16c-0.736 0-1.333-0.597-1.333-1.333v-24c0-0.735 0.597-1.333 1.333-1.333h4c0 1.471 1.196 2.667 2.667 2.667h2.667c1.471 0 2.667-1.196 2.667-2.667h4c0.736 0 1.333 0.599 1.333 1.333z"></path>\n</svg>\n'}),i("salla-tel-input",{ref:s=>this.phoneInput=s})),i("div",{class:"s-form-group"},i("span",{innerHTML:l}),i("input",{type:"email",class:"s-form-control s-quick-order-email-field",name:"email",required:this.isEmailRequired,placeholder:this.placeHolderEmail+" "+(this.isEmailRequired?"":this.emailOptional),ref:s=>this.emailInput=s})))],this.isTermsRequired&&i("label",{htmlFor:"terms",class:"s-quick-order-terms"},i("input",{type:"checkbox",required:!0,name:"terms",id:"terms",ref:s=>this.termsInput=s,onChange:()=>this.termsChecked=this.termsInput.checked,class:"s-checkbox"}),i("span",{class:"s-form-label"}," ",i("div",{innerHTML:this.formatAgreementText(this.agreementText,150)},this.agreementText.length>150&&i("salla-button",{shape:"link",onClick:()=>this.agreementModal.open()},this.agreementShowText))," ")),i("salla-button",{type:"submit",color:this.getBtnColor(),width:"wide",ref:s=>this.submitBtn=s},this.payButtonTitle)),i("salla-modal",{"modal-title":this.agreementModalHead,ref:s=>this.agreementModal=s},i("article",{innerHTML:this.agreementText}))))}componentDidLoad(){this.host.querySelectorAll("input").forEach((s=>{s.addEventListener("invalid",(s=>{this.handleInvalidInput(s)})),s.addEventListener("input",(()=>{s.setCustomValidity(""),s.reportValidity()}))}))}get host(){return r(this)}};h.style=".s-quick-order-expandable:not(.s-quick-order-shown){overflow:hidden}";export{h as salla_quick_order}
4
+ import{r as s,c as t,h as i,H as e,a as r}from"./p-Y6CiunLU.js";import{M as l}from"./p-DmgxDvXL.js";import{C as a}from"./p-BsLF_HK7.js";const h=class{constructor(i){s(this,i),this.quickOrderSubmited=t(this,"quickOrderSubmited"),this.quickOrderTitle="ليش تنتظر؟",this.subTitle="احصل على المنتج مباشرة الآن",this.payButtonTitle="اطلب المنتج",this.confirmPayButtonTitle="اشتر الآن",this.agreementText=salla.lang.get("pages.checkout.show_full_agreement"),this.isEmailRequired=!1,this.quickOrderStyle="default",this.isAvailable=!1,this.oneClick=!1,this.expanded=!1,this.isTermsRequired=!1,this.countryCode=salla.config.get("user.country_code","SA")||"SA",this.submitSucess=!1,this.placeHolderEmail=salla.lang.get("common.elements.email"),this.emailOptional=salla.lang.get("common.elements.optional"),this.agreementShowText=salla.lang.get("pages.checkout.show_full_agreement"),this.agreementModalHead=salla.lang.get("pages.checkout.full_agreement"),this.userNameLabel=salla.lang.get("pages.products.your_name"),this.termsChecked=!1,salla.onReady((()=>{this.productId=this.productId||salla.config.get("page.id")})),salla.lang.onLoaded((()=>{this.placeHolderEmail=salla.lang.get("common.elements.email"),this.emailOptional=salla.lang.get("common.elements.optional"),this.agreementShowText=salla.lang.get("pages.checkout.show_full_agreement"),this.agreementModalHead=salla.lang.get("pages.checkout.full_agreement"),this.userNameLabel=salla.lang.get("pages.products.your_name")}))}getBtnColor(){return"default"===this.quickOrderStyle?"light":"primary"}getErrorMessage(s,t){return"terms"==t?salla.lang.get("pages.checkout.check_agreement"):salla.lang.get(`common.errors.${s}`,{attribute:"name"==t?this.userNameLabel:this.placeHolderEmail})}handleInvalidInput(s){let t,i=s.target,e=i.validity;e.valueMissing?(t=this.getErrorMessage("field_required",i.name),console.log(this.getErrorMessage("field_required",i.name))):e.typeMismatch&&(t=this.getErrorMessage("invalid_value",i.name)),i.setCustomValidity(t)}async setWrapperHeight(){let s=this.host.querySelector(".s-quick-order-expandable");setTimeout((()=>{s.style.maxHeight=s.style.maxHeight||this.oneClick?null:s.scrollHeight+"px"}),50)}getDarkOrLight(){return"default"===this.quickOrderStyle&&salla.config.get("theme.color.is_dark")?"dark":"light"}getStyleColor(){return{gray:"#f3f3f3",white:"#ffffff",default:salla.config.get("theme.color.primary")}[this.quickOrderStyle]||"#f3f3f3"}async submit(s,t=!1){return s.preventDefault(),t&&!this.oneClick?(this.expanded=!this.expanded,void this.setWrapperHeight()):this.submitBtn.load().then((()=>this.getPayload())).then((s=>salla.api.cart.createQuickOrder(s))).then((()=>{setTimeout((()=>{this.submitBtn.stop(),this.submitSucess=!0,this.quickOrderSubmited.emit()}),200)})).catch((s=>s&&(console.error(s),this.submitBtn.stop())))}async getPayload(){return this.oneClick?{product_ids:[this.productId],agreement:!0}:{product_ids:[this.productId],email:this.emailInput?.value,phone:Number((await(this.phoneInput?.getValues()))?.phone),country_code:(await(this.phoneInput?.getValues()))?.countryCode||this.countryCode,name:this.nameInput?.value,agreement:this.termsChecked}}formatAgreementText(s,t=150){return s?s.length<=t?s:(new DOMParser).parseFromString(s,"text/html").documentElement.innerText.substring(0,t)+"...":""}loadQuickOrderSettings(){let s=salla.config.get("store.settings.quick_order");return s?(this.user=salla.config.get("user")||salla.storage.get("user")||{},this.countryCode=this.user?.country_code||this.countryCode,this.isEmailRequired=!this.user?.email&&this.isEmailRequired,this.oneClick=this.user?.email,this.initComponentData(s),Promise.resolve()):Promise.resolve()}initComponentData(s){this.quickOrderTitle=s.title,this.subTitle=s.sub_title,this.payButtonTitle=s.order_now_button,this.isEmailRequired=s.is_email_required,this.isTermsRequired=s.show_agreement,this.agreementText=s.agreement,this.confirmPayButtonTitle=s.confirm_button,this.thanksMessage=s.thanks_message,this.quickOrderStyle=s.style,this.isAvailable=!0,this.oneClick=this.oneClick&&!this.isTermsRequired}componentWillLoad(){return new Promise((s=>salla.onReady((()=>this.loadQuickOrderSettings().then(s)))))}render(){if(this.isAvailable)return this.submitSucess?i(e,{class:"s-quick-order"},i("div",{class:"s-quick-order-confirm",style:{backgroundColor:salla.config.get("theme.color.primary")+"10",borderColor:salla.config.get("theme.color.primary")+"10",color:salla.config.get("theme.color.primary")}},i("i",{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>party-horn</title>\n<path fill="currentColor" d="M5.333 4.013c0.736 0 1.333-0.596 1.333-1.333v-0.013c0-0.737-0.597-1.327-1.333-1.327s-1.333 0.603-1.333 1.34 0.597 1.333 1.333 1.333zM11.333 10c0.341 0 0.683-0.131 0.943-0.391 1.541-1.54 2.391-3.589 2.391-5.771v-2.505c0-0.737-0.597-1.333-1.333-1.333s-1.333 0.596-1.333 1.333v2.505c0 1.468-0.572 2.848-1.609 3.885-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391zM18.667 9.993c0.319 0 0.639-0.115 0.895-0.345 0.383-0.347 0.684-0.325 1.497-0.22 0.923 0.124 2.319 0.307 3.636-0.887 1.293-1.172 1.303-2.54 1.308-3.539 0.005-0.887 0.043-1.228 0.432-1.581 0.361-0.327 0.621-0.335 1.493-0.216 0.923 0.12 2.317 0.307 3.635-0.884 0.545-0.495 0.587-1.337 0.093-1.883-0.493-0.547-1.336-0.589-1.884-0.093-0.361 0.325-0.621 0.333-1.493 0.216-0.921-0.119-2.317-0.305-3.635 0.884-1.293 1.173-1.303 2.541-1.308 3.54-0.005 0.885-0.043 1.227-0.432 1.58-0.383 0.348-0.683 0.327-1.497 0.22-0.924-0.124-2.32-0.305-3.636 0.887-0.545 0.495-0.587 1.339-0.092 1.884 0.264 0.291 0.625 0.437 0.988 0.437zM18.667 16.013c0.736 0 1.333-0.596 1.333-1.333v-0.013c0-0.737-0.597-1.327-1.333-1.327s-1.333 0.603-1.333 1.34 0.597 1.333 1.333 1.333zM30.667 17.333h-2.505c-2.179 0-4.228 0.849-5.771 2.391-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.603 0.391 0.944 0.391s0.683-0.131 0.943-0.391c1.023-1.023 2.439-1.609 3.884-1.609h2.505c0.736 0 1.333-0.596 1.333-1.333s-0.597-1.333-1.333-1.333zM30.667 10.66c-0.736 0-1.333 0.603-1.333 1.34s0.597 1.333 1.333 1.333 1.333-0.596 1.333-1.333v-0.013c0-0.736-0.597-1.327-1.333-1.327zM29.333 26.66c-0.736 0-1.333 0.603-1.333 1.34s0.597 1.333 1.333 1.333 1.333-0.596 1.333-1.333v-0.013c0-0.736-0.597-1.327-1.333-1.327zM7.456 11.057c-0.327-0.327-0.799-0.46-1.249-0.356-0.449 0.107-0.812 0.439-0.959 0.876l-5.036 15.113c-0.487 1.457-0.113 3.037 0.973 4.125 0.772 0.771 1.792 1.183 2.84 1.183 0.428 0 0.861-0.068 1.284-0.209l15.112-5.037c0.439-0.145 0.769-0.508 0.876-0.959 0.107-0.449-0.028-0.921-0.355-1.249zM4.467 29.259c-0.503 0.163-1.023 0.043-1.395-0.329-0.373-0.373-0.497-0.896-0.329-1.396l4.355-13.065 10.436 10.435z"></path>\n</svg>\n'}),i("span",null,this.thanksMessage))):i(e,{class:`s-quick-order s-quick-order-${this.getDarkOrLight()}`},i("div",{class:`s-quick-order-container s-quick-order-${this.quickOrderStyle}`,style:{backgroundColor:this.getStyleColor()}},i("div",{class:"s-quick-order-button-cont"},i("div",null,i("h3",null,this.quickOrderTitle),i("p",null,this.subTitle)),i("salla-button",{class:this.expanded?"s-quick-order-btn-close":"",onClick:s=>this.submit(s,!0),color:this.getBtnColor()},this.oneClick?this.confirmPayButtonTitle:this.expanded?i("i",{innerHTML:a}):this.confirmPayButtonTitle)),i("form",{onSubmit:s=>this.submit(s),class:"s-quick-order-expandable "+(this.expanded?"s-quick-order-shown":"")},Salla.config.isGuest()&&[i("div",{class:"s-form-group"},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>portrait</title>\n<path d="M24 1.333h-16c-3.676 0-6.667 2.991-6.667 6.667v16c0 3.028 2.041 5.561 4.811 6.371 0.004 0.001 0.008 0.003 0.012 0.004 0.591 0.172 1.2 0.292 1.844 0.292h16c0.644 0 1.253-0.12 1.843-0.292 0.004-0.001 0.008-0.003 0.012-0.004 2.771-0.809 4.812-3.343 4.812-6.371v-16c0-3.676-2.991-6.667-6.667-6.667zM8.012 28c0.121-1.915 3.363-4 7.988-4s7.868 2.085 7.988 4zM28 24c0 1.24-0.579 2.335-1.467 3.069-0.768-3.288-5.112-5.736-10.533-5.736s-9.765 2.448-10.533 5.736c-0.888-0.735-1.467-1.829-1.467-3.069v-16c0-2.205 1.795-4 4-4h16c2.205 0 4 1.795 4 4zM16 6.667c-3.308 0-6 2.692-6 6s2.692 6 6 6 6-2.692 6-6-2.692-6-6-6zM16 16c-1.839 0-3.333-1.495-3.333-3.333s1.495-3.333 3.333-3.333 3.333 1.495 3.333 3.333-1.495 3.333-3.333 3.333z"></path>\n</svg>\n'}),i("input",{type:"text",required:!0,class:"s-form-control s-quick-order-phone-field",name:"name",placeholder:this.userNameLabel,ref:s=>this.nameInput=s})),i("div",{class:"s-quick-order-flex-input"},i("div",{class:"s-form-group"},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>iphone-x</title>\n<path d="M24 0h-16c-2.205 0-4 1.795-4 4v24c0 2.205 1.795 4 4 4h16c2.205 0 4-1.795 4-4v-24c0-2.205-1.795-4-4-4zM25.333 28c0 0.736-0.597 1.333-1.333 1.333h-16c-0.736 0-1.333-0.597-1.333-1.333v-24c0-0.735 0.597-1.333 1.333-1.333h4c0 1.471 1.196 2.667 2.667 2.667h2.667c1.471 0 2.667-1.196 2.667-2.667h4c0.736 0 1.333 0.599 1.333 1.333z"></path>\n</svg>\n'}),i("salla-tel-input",{ref:s=>this.phoneInput=s})),i("div",{class:"s-form-group"},i("span",{innerHTML:l}),i("input",{type:"email",class:"s-form-control s-quick-order-email-field",name:"email",required:this.isEmailRequired,placeholder:this.placeHolderEmail+" "+(this.isEmailRequired?"":this.emailOptional),ref:s=>this.emailInput=s})))],this.isTermsRequired&&i("label",{htmlFor:"terms",class:"s-quick-order-terms"},i("input",{type:"checkbox",required:!0,name:"terms",id:"terms",ref:s=>this.termsInput=s,onChange:()=>this.termsChecked=this.termsInput.checked,class:"s-checkbox"}),i("span",{class:"s-form-label"}," ",i("div",{innerHTML:this.formatAgreementText(this.agreementText,150)},this.agreementText.length>150&&i("salla-button",{shape:"link",onClick:()=>this.agreementModal.open()},this.agreementShowText))," ")),i("salla-button",{type:"submit",color:this.getBtnColor(),width:"wide",ref:s=>this.submitBtn=s},this.payButtonTitle)),i("salla-modal",{"modal-title":this.agreementModalHead,ref:s=>this.agreementModal=s},i("article",{innerHTML:this.agreementText}))))}componentDidLoad(){this.host.querySelectorAll("input").forEach((s=>{s.addEventListener("invalid",(s=>{this.handleInvalidInput(s)})),s.addEventListener("input",(()=>{s.setCustomValidity(""),s.reportValidity()}))}))}get host(){return r(this)}};h.style=".s-quick-order-expandable:not(.s-quick-order-shown){overflow:hidden}";export{h as salla_quick_order}