@salla.sa/twilight-components 2.14.521 → 2.14.522
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.
- package/dist/cjs/arrow-right-Cd6JoegH.js +13 -0
- package/dist/cjs/{filepond-BxIqz4X5.js → filepond-RbRMljF_.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-CgcL8KEM.js → filepond-plugin-file-poster-uIFauwzO.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-CE5D63gi.js → filepond-plugin-file-validate-size-Cd_r4359.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-CTZlbHeg.js → filepond-plugin-file-validate-type-C5tN0mCB.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-DwwaA0xD.js → filepond-plugin-image-edit-Bj-vUOxV.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-Ds2jzd-0.js → filepond-plugin-image-exif-orientation-DR6IE-Yk.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-zMIkW3BA.js → filepond-plugin-image-preview-HghuKrCb.js} +1 -1
- package/dist/cjs/{functions-kxrglIIV.js → functions-C0u_gA0Z.js} +1 -1
- package/dist/cjs/{index-D9nhi8-6.js → index-BJw_NdHc.js} +10 -10
- package/dist/cjs/{index-BqVQnSPs.js → index-DZPED3mu.js} +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-accordion_6.cjs.entry.js +18 -3
- package/dist/cjs/salla-add-product-button_5.cjs.entry.js +1 -1
- package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
- package/dist/cjs/salla-alert_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
- package/dist/cjs/salla-badge.cjs.entry.js +1 -1
- package/dist/cjs/salla-basket-gap.cjs.entry.js +1 -1
- package/dist/cjs/salla-booking-field_7.cjs.entry.js +10 -10
- package/dist/cjs/salla-bullet-delivery_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-coupons.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-summary-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-cashback-banner.cjs.entry.js +1 -1
- package/dist/cjs/salla-comment-factors.cjs.entry.js +1 -1
- package/dist/cjs/salla-comment-form_8.cjs.entry.js +1 -1
- package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
- package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
- package/dist/cjs/salla-count-down_2.cjs.entry.js +12 -7
- package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
- package/dist/cjs/salla-delivery-promise.cjs.entry.js +1 -1
- package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters.cjs.entry.js +1 -1
- package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
- package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
- package/dist/cjs/salla-hook.cjs.entry.js +1 -1
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
- package/dist/cjs/salla-installment.cjs.entry.js +1 -1
- package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
- package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-banner.cjs.entry.js +2 -2
- package/dist/cjs/salla-loyalty-exchange-product-card_5.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty-hero_2.cjs.entry.js +2 -2
- package/dist/cjs/salla-loyalty-panel.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty-points-banner.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-points-history.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-program.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty-reward.cjs.entry.js +2 -2
- package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
- package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-map_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-menu.cjs.entry.js +1 -1
- package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-next-order-coupon.cjs.entry.js +1 -1
- package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-branch.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-cancel.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit-product-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-shipments.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-orders.cjs.entry.js +1 -1
- package/dist/cjs/salla-payments.cjs.entry.js +1 -1
- package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
- package/dist/cjs/salla-price-range.cjs.entry.js +3 -9
- package/dist/cjs/salla-product-card-embed.cjs.entry.js +1 -1
- package/dist/cjs/salla-product-card_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
- package/dist/cjs/salla-products-list.cjs.entry.js +1 -1
- package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
- package/dist/cjs/salla-rating-modal-v2.cjs.entry.js +1 -1
- package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-review-factors-tags.cjs.entry.js +1 -1
- package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
- package/dist/cjs/salla-search.cjs.entry.js +1 -1
- package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
- package/dist/cjs/salla-slider.cjs.entry.js +1 -1
- package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
- package/dist/cjs/salla-social.cjs.entry.js +1 -1
- package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
- package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
- package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-settings.cjs.entry.js +471 -34
- package/dist/cjs/salla-verify.cjs.entry.js +9 -1
- package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
- package/dist/cjs/salla-wishlist-actions.cjs.entry.js +2 -2
- package/dist/cjs/{tracked-promise-I3cWE57r.js → tracked-promise-84l9D1pi.js} +1 -1
- package/dist/cjs/twilight.cjs.js +2 -2
- package/dist/cjs/{vanilla-picker-BN2v2WSB.js → vanilla-picker-C9ruFpIn.js} +1 -1
- package/dist/collection/components/salla-modal/salla-modal.css +12 -0
- package/dist/collection/components/salla-modal/salla-modal.js +50 -1
- package/dist/collection/components/salla-order-options-modal/salla-order-options-modal.js +11 -6
- package/dist/collection/components/salla-user-settings/salla-user-settings.css +137 -0
- package/dist/collection/components/salla-user-settings/salla-user-settings.js +497 -32
- package/dist/collection/components/salla-verify/salla-verify.js +8 -0
- package/dist/collection/components/salla-wishlist-actions/salla-wishlist-actions.js +1 -1
- package/dist/components/arrow-right.js +11 -0
- package/dist/components/index.js +2 -2
- package/dist/components/salla-login-modal2.js +7 -1
- package/dist/components/salla-loyalty-point2.js +8 -2
- package/dist/components/salla-modal2.js +25 -3
- package/dist/components/salla-order-options-modal2.js +11 -6
- package/dist/components/salla-price-range2.js +1 -7
- package/dist/components/salla-product-size-guide.js +7 -1
- package/dist/components/salla-user-menu.js +7 -1
- package/dist/components/salla-user-settings.js +498 -39
- package/dist/components/salla-verify.js +8 -0
- package/dist/components/salla-wishlist-actions.js +1 -1
- package/dist/esm/arrow-right-B9q7ymSg.js +11 -0
- package/dist/esm/{filepond-DiqSFaKJ.js → filepond-DTXpxLd9.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-CIhvZWr3.js → filepond-plugin-file-poster-QykV8B8G.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-Dh-rJsdI.js → filepond-plugin-file-validate-size-Bj5ENC6_.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-I9XENo4v.js → filepond-plugin-file-validate-type-8CnQZmpk.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-D7HhgEBr.js → filepond-plugin-image-edit-JxnSBv4V.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-CJ6QNX7n.js → filepond-plugin-image-exif-orientation-P7dHkas0.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-ChlwE2Wy.js → filepond-plugin-image-preview-B6byQaCY.js} +1 -1
- package/dist/esm/{functions-DG90cyVT.js → functions-B-HhhobN.js} +1 -1
- package/dist/esm/{index-CceR4m1x.js → index-BszjiU3B.js} +1 -1
- package/dist/esm/{index-BmH_SCLp.js → index-CJNSdTHZ.js} +10 -10
- package/dist/esm/loader.js +3 -3
- package/dist/esm/salla-accordion-body_2.entry.js +1 -1
- package/dist/esm/salla-accordion_6.entry.js +18 -3
- package/dist/esm/salla-add-product-button_5.entry.js +1 -1
- package/dist/esm/salla-advertisement.entry.js +1 -1
- package/dist/esm/salla-alert_2.entry.js +1 -1
- package/dist/esm/salla-app-install-alert.entry.js +1 -1
- package/dist/esm/salla-apps-icons.entry.js +1 -1
- package/dist/esm/salla-badge.entry.js +1 -1
- package/dist/esm/salla-basket-gap.entry.js +1 -1
- package/dist/esm/salla-booking-field_7.entry.js +10 -10
- package/dist/esm/salla-bullet-delivery_2.entry.js +1 -1
- package/dist/esm/salla-cart-coupons.entry.js +1 -1
- package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
- package/dist/esm/salla-cart-summary-card.entry.js +1 -1
- package/dist/esm/salla-cashback-banner.entry.js +1 -1
- package/dist/esm/salla-comment-factors.entry.js +1 -1
- package/dist/esm/salla-comment-form_8.entry.js +1 -1
- package/dist/esm/salla-conditional-offer.entry.js +1 -1
- package/dist/esm/salla-contacts.entry.js +1 -1
- package/dist/esm/salla-cookies-bar.entry.js +1 -1
- package/dist/esm/salla-count-down_2.entry.js +12 -7
- package/dist/esm/salla-custom-fields.entry.js +1 -1
- package/dist/esm/salla-delivery-promise.entry.js +1 -1
- package/dist/esm/salla-edit-order-button.entry.js +1 -1
- package/dist/esm/salla-filters-widget.entry.js +1 -1
- package/dist/esm/salla-filters.entry.js +1 -1
- package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
- package/dist/esm/salla-gifting.entry.js +1 -1
- package/dist/esm/salla-hook.entry.js +1 -1
- package/dist/esm/salla-infinite-scroll.entry.js +1 -1
- package/dist/esm/salla-installment.entry.js +1 -1
- package/dist/esm/salla-list-tile.entry.js +1 -1
- package/dist/esm/salla-localization-modal.entry.js +1 -1
- package/dist/esm/salla-login-modal.entry.js +1 -1
- package/dist/esm/salla-loyalty-banner.entry.js +2 -2
- package/dist/esm/salla-loyalty-exchange-product-card_5.entry.js +3 -3
- package/dist/esm/salla-loyalty-hero_2.entry.js +2 -2
- package/dist/esm/salla-loyalty-panel.entry.js +3 -3
- package/dist/esm/salla-loyalty-points-banner.entry.js +1 -1
- package/dist/esm/salla-loyalty-points-history.entry.js +1 -1
- package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
- package/dist/esm/salla-loyalty-program.entry.js +3 -3
- package/dist/esm/salla-loyalty-reward.entry.js +2 -2
- package/dist/esm/salla-loyalty.entry.js +1 -1
- package/dist/esm/salla-maintenance-alert.entry.js +1 -1
- package/dist/esm/salla-map_2.entry.js +1 -1
- package/dist/esm/salla-menu.entry.js +1 -1
- package/dist/esm/salla-metadata.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-next-order-coupon.entry.js +1 -1
- package/dist/esm/salla-notification-item.entry.js +1 -1
- package/dist/esm/salla-notifications.entry.js +1 -1
- package/dist/esm/salla-offer-modal.entry.js +1 -1
- package/dist/esm/salla-offer.entry.js +1 -1
- package/dist/esm/salla-order-branch.entry.js +1 -1
- package/dist/esm/salla-order-cancel.entry.js +1 -1
- package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-order-details-options.entry.js +1 -1
- package/dist/esm/salla-order-details.entry.js +1 -1
- package/dist/esm/salla-order-edit-item.entry.js +1 -1
- package/dist/esm/salla-order-edit-product-card.entry.js +1 -1
- package/dist/esm/salla-order-edit.entry.js +1 -1
- package/dist/esm/salla-order-shipments.entry.js +1 -1
- package/dist/esm/salla-order-summary.entry.js +1 -1
- package/dist/esm/salla-order-totals-card.entry.js +1 -1
- package/dist/esm/salla-orders.entry.js +1 -1
- package/dist/esm/salla-payments.entry.js +1 -1
- package/dist/esm/salla-placeholder.entry.js +1 -1
- package/dist/esm/salla-price-range.entry.js +2 -8
- package/dist/esm/salla-product-card-embed.entry.js +1 -1
- package/dist/esm/salla-product-card_2.entry.js +1 -1
- package/dist/esm/salla-product-size-guide.entry.js +1 -1
- package/dist/esm/salla-products-list.entry.js +1 -1
- package/dist/esm/salla-quick-order.entry.js +1 -1
- package/dist/esm/salla-rating-modal-v2.entry.js +1 -1
- package/dist/esm/salla-rating-modal.entry.js +1 -1
- package/dist/esm/salla-review-factors-tags.entry.js +1 -1
- package/dist/esm/salla-scopes.entry.js +1 -1
- package/dist/esm/salla-search.entry.js +1 -1
- package/dist/esm/salla-skeleton.entry.js +1 -1
- package/dist/esm/salla-slider.entry.js +1 -1
- package/dist/esm/salla-social-share.entry.js +1 -1
- package/dist/esm/salla-social.entry.js +1 -1
- package/dist/esm/salla-tab-content_3.entry.js +1 -1
- package/dist/esm/salla-tiered-offer.entry.js +1 -1
- package/dist/esm/salla-tooltip.entry.js +1 -1
- package/dist/esm/salla-trust-badges.entry.js +1 -1
- package/dist/esm/salla-user-menu.entry.js +1 -1
- package/dist/esm/salla-user-profile.entry.js +1 -1
- package/dist/esm/salla-user-settings.entry.js +471 -34
- package/dist/esm/salla-verify.entry.js +9 -1
- package/dist/esm/salla-wallet.entry.js +1 -1
- package/dist/esm/salla-wishlist-actions.entry.js +2 -2
- package/dist/esm/{tracked-promise-Ci6ut_FU.js → tracked-promise-BfoqsGRk.js} +1 -1
- package/dist/esm/twilight.js +3 -3
- package/dist/esm/{vanilla-picker-vyxTZ0dX.js → vanilla-picker-BhDt66Uk.js} +1 -1
- package/dist/twilight/{p-b74d7a0c.entry.js → p-0645933f.entry.js} +1 -1
- package/dist/twilight/{p-050f0c6a.entry.js → p-0a1e4dbe.entry.js} +1 -1
- package/dist/twilight/{p-4afedde2.entry.js → p-0c879092.entry.js} +1 -1
- package/dist/twilight/{p-3JgvsDKa.js → p-13LBJtjX.js} +2 -2
- package/dist/twilight/{p-da16958f.entry.js → p-16cf7eaf.entry.js} +1 -1
- package/dist/twilight/{p-4dcb3f48.entry.js → p-186221a2.entry.js} +1 -1
- package/dist/twilight/{p-781d048b.entry.js → p-1eb3897d.entry.js} +1 -1
- package/dist/twilight/{p-0c59cc4f.entry.js → p-211f9589.entry.js} +1 -1
- package/dist/twilight/{p-a54f3e4d.entry.js → p-22424405.entry.js} +1 -1
- package/dist/twilight/{p-2e23d889.entry.js → p-22da1d18.entry.js} +1 -1
- package/dist/twilight/{p-0331b059.entry.js → p-247e6bc1.entry.js} +1 -1
- package/dist/twilight/{p-ae2071d6.entry.js → p-26d4a829.entry.js} +1 -1
- package/dist/twilight/{p-5659163f.entry.js → p-2b411871.entry.js} +1 -1
- package/dist/twilight/{p-772b2587.entry.js → p-2bd6a7ad.entry.js} +1 -1
- package/dist/twilight/{p-dbd42678.entry.js → p-2c9d2ea4.entry.js} +1 -1
- package/dist/twilight/{p-b41da249.entry.js → p-30638d38.entry.js} +1 -1
- package/dist/twilight/{p-2199c255.entry.js → p-33a93add.entry.js} +1 -1
- package/dist/twilight/{p-4b425007.entry.js → p-34968257.entry.js} +1 -1
- package/dist/twilight/{p-c8fa6a7e.entry.js → p-376ca265.entry.js} +1 -1
- package/dist/twilight/{p-5b98f12c.entry.js → p-379956ef.entry.js} +1 -1
- package/dist/twilight/{p-6481d82b.entry.js → p-3b227e0d.entry.js} +1 -1
- package/dist/twilight/{p-aa3de1af.entry.js → p-3cdf1264.entry.js} +1 -1
- package/dist/twilight/{p-7054391f.entry.js → p-3d9d15b0.entry.js} +1 -1
- package/dist/twilight/{p-e9fb7554.entry.js → p-3de8587f.entry.js} +1 -1
- package/dist/twilight/{p-cdd9e371.entry.js → p-3e88938d.entry.js} +1 -1
- package/dist/twilight/{p-88137e81.entry.js → p-40cd342c.entry.js} +1 -1
- package/dist/twilight/{p-25a5a6e1.entry.js → p-42686603.entry.js} +1 -1
- package/dist/twilight/{p-ff2cf3a4.entry.js → p-43437311.entry.js} +1 -1
- package/dist/twilight/{p-097f2555.entry.js → p-46d4d4f1.entry.js} +1 -1
- package/dist/twilight/{p-7dd7b06b.entry.js → p-4947d2c3.entry.js} +1 -1
- package/dist/twilight/{p-5245c9fb.entry.js → p-4d67b437.entry.js} +1 -1
- package/dist/twilight/{p-0043e129.entry.js → p-53e8d007.entry.js} +1 -1
- package/dist/twilight/{p-1fa3928c.entry.js → p-56851c9a.entry.js} +1 -1
- package/dist/twilight/{p-f8b734e1.entry.js → p-58969bd2.entry.js} +1 -1
- package/dist/twilight/{p-eb06c23f.entry.js → p-58a2b477.entry.js} +1 -1
- package/dist/twilight/p-59500502.entry.js +4 -0
- package/dist/twilight/{p-e258f515.entry.js → p-597243e9.entry.js} +1 -1
- package/dist/twilight/{p-28f8858c.entry.js → p-5c7d194c.entry.js} +1 -1
- package/dist/twilight/{p-2cb0a5c2.entry.js → p-5c923f3e.entry.js} +1 -1
- package/dist/twilight/{p-42ab7e46.entry.js → p-5ce7a5f4.entry.js} +1 -1
- package/dist/twilight/{p-314e1a7e.entry.js → p-610cf53f.entry.js} +1 -1
- package/dist/twilight/{p-fbbf8d50.entry.js → p-6246f251.entry.js} +1 -1
- package/dist/twilight/{p-919d1d2f.entry.js → p-63e4468c.entry.js} +1 -1
- package/dist/twilight/{p-9338485b.entry.js → p-69791429.entry.js} +1 -1
- package/dist/twilight/{p-a025825a.entry.js → p-72302934.entry.js} +1 -1
- package/dist/twilight/{p-1afaa214.entry.js → p-74000383.entry.js} +1 -1
- package/dist/twilight/{p-9c738246.entry.js → p-75ca0611.entry.js} +1 -1
- package/dist/twilight/p-75cd81c8.entry.js +4 -0
- package/dist/twilight/{p-54b18586.entry.js → p-782376aa.entry.js} +1 -1
- package/dist/twilight/{p-93b9c55e.entry.js → p-78b64ecf.entry.js} +1 -1
- package/dist/twilight/{p-5a17a1ea.entry.js → p-7ad821d8.entry.js} +1 -1
- package/dist/twilight/{p-3b927d75.entry.js → p-7c9cee72.entry.js} +1 -1
- package/dist/twilight/{p-ad95d915.entry.js → p-8416f053.entry.js} +1 -1
- package/dist/twilight/{p-0bc95bea.entry.js → p-8641e913.entry.js} +1 -1
- package/dist/twilight/{p-bd5baa3a.entry.js → p-87b03980.entry.js} +1 -1
- package/dist/twilight/{p-9e73018d.entry.js → p-87b8805f.entry.js} +1 -1
- package/dist/twilight/{p-22b1d1b5.entry.js → p-88b5f845.entry.js} +1 -1
- package/dist/twilight/{p-c32a7b18.entry.js → p-8d1a1d2f.entry.js} +1 -1
- package/dist/twilight/{p-d4b5c142.entry.js → p-8d8ce19f.entry.js} +1 -1
- package/dist/twilight/{p-8bc95f60.entry.js → p-8e17a662.entry.js} +1 -1
- package/dist/twilight/{p-8dd3312e.entry.js → p-926861b0.entry.js} +1 -1
- package/dist/twilight/{p-29d997c7.entry.js → p-9da90445.entry.js} +1 -1
- package/dist/twilight/{p-D5XsQ4D9.js → p-B5LlhDea.js} +1 -1
- package/dist/twilight/p-B9q7ymSg.js +4 -0
- package/dist/twilight/{p-5h7fTMtR.js → p-BNxL6rtA.js} +1 -1
- package/dist/twilight/{p-Jgd9UbQM.js → p-BQ7LZ-gv.js} +1 -1
- package/dist/twilight/{p-BmH_SCLp.js → p-CJNSdTHZ.js} +1 -1
- package/dist/twilight/{p-1HIaZAiz.js → p-CKo8lUax.js} +1 -1
- package/dist/twilight/{p-CyJQdnNc.js → p-CdiD-2Z3.js} +1 -1
- package/dist/twilight/{p-BFMG8k2g.js → p-ClsWSoli.js} +1 -1
- package/dist/twilight/{p-DcFiC1dv.js → p-D4LxjuhN.js} +1 -1
- package/dist/twilight/{p-Duga6KlO.js → p-DD48ApDW.js} +2 -2
- package/dist/twilight/{p-CVQzCtED.js → p-DNerctfJ.js} +1 -1
- package/dist/twilight/{p-DNxVGDCc.js → p-DsEuHqot.js} +1 -1
- package/dist/twilight/{p-86509218.entry.js → p-a241a76f.entry.js} +1 -1
- package/dist/twilight/{p-719d5824.entry.js → p-a3a666c9.entry.js} +1 -1
- package/dist/twilight/{p-f639f01e.entry.js → p-a59e6aa6.entry.js} +1 -1
- package/dist/twilight/{p-edc7d892.entry.js → p-ab7940b0.entry.js} +1 -1
- package/dist/twilight/{p-f6644651.entry.js → p-ac63d3c2.entry.js} +1 -1
- package/dist/twilight/{p-9eb20b1e.entry.js → p-ad96b0eb.entry.js} +1 -1
- package/dist/twilight/{p-c8e712e4.entry.js → p-b1ecd1bb.entry.js} +1 -1
- package/dist/twilight/{p-c337127b.entry.js → p-b30b0488.entry.js} +1 -1
- package/dist/twilight/{p-c9e00ab5.entry.js → p-b5b0ca7c.entry.js} +1 -1
- package/dist/twilight/{p-849c72c4.entry.js → p-b8815e28.entry.js} +1 -1
- package/dist/twilight/p-b8cfcf08.entry.js +4 -0
- package/dist/twilight/{p-9fbf4a49.entry.js → p-b8d5d785.entry.js} +1 -1
- package/dist/twilight/{p-3977e18c.entry.js → p-bae0376c.entry.js} +1 -1
- package/dist/twilight/{p-6304507a.entry.js → p-bb7f8555.entry.js} +1 -1
- package/dist/twilight/{p-f7e468c7.entry.js → p-bfe4961c.entry.js} +1 -1
- package/dist/twilight/{p-2bdf089c.entry.js → p-c6b90867.entry.js} +1 -1
- package/dist/twilight/{p-761f03b0.entry.js → p-c8632eac.entry.js} +1 -1
- package/dist/twilight/{p-00a79225.entry.js → p-cd5d24ce.entry.js} +1 -1
- package/dist/twilight/{p-22b5b7c5.entry.js → p-cdf7bbdf.entry.js} +1 -1
- package/dist/twilight/{p-8ee28c75.entry.js → p-cf07ebbf.entry.js} +1 -1
- package/dist/twilight/{p-2235f1f2.entry.js → p-d016060c.entry.js} +1 -1
- package/dist/twilight/{p-258ddfbb.entry.js → p-d51142bc.entry.js} +1 -1
- package/dist/twilight/p-d8bf2907.entry.js +4 -0
- package/dist/twilight/{p-456c03b1.entry.js → p-d9739d37.entry.js} +1 -1
- package/dist/twilight/{p-4db788b8.entry.js → p-dfc15c20.entry.js} +1 -1
- package/dist/twilight/p-e81e649c.entry.js +4 -0
- package/dist/twilight/{p-9329c9ae.entry.js → p-e85b1ffb.entry.js} +1 -1
- package/dist/twilight/{p-3aa708ac.entry.js → p-e98fb647.entry.js} +1 -1
- package/dist/twilight/{p-5327d518.entry.js → p-eaa6a288.entry.js} +1 -1
- package/dist/twilight/{p-3b4f6d09.entry.js → p-f2437a5e.entry.js} +1 -1
- package/dist/twilight/{p-a6f1ab9d.entry.js → p-f3d815f9.entry.js} +1 -1
- package/dist/twilight/{p-169ccb83.entry.js → p-f7ca9b12.entry.js} +1 -1
- package/dist/twilight/{p-5aa54ac9.entry.js → p-fa0363af.entry.js} +1 -1
- package/dist/twilight/{p-7d6d2166.entry.js → p-fa560d9b.entry.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-modal/salla-modal.d.ts +10 -0
- package/dist/types/components/salla-order-options-modal/salla-order-options-modal.d.ts +5 -1
- package/dist/types/components/salla-user-settings/salla-user-settings.d.ts +84 -9
- package/dist/types/components.d.ts +15 -0
- package/package.json +5 -5
- package/dist/twilight/p-19173dca.entry.js +0 -4
- package/dist/twilight/p-26f2eea3.entry.js +0 -4
- package/dist/twilight/p-3d4ea448.entry.js +0 -4
- package/dist/twilight/p-6ce962f1.entry.js +0 -4
- package/dist/twilight/p-ec66b2a0.entry.js +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,c as s,h as i,H as a,a as e,e as o}from"./p-BmH_SCLp.js";import{P as n}from"./p-DY4LZmNP.js";import{H as l}from"./p-XnA1YTjA.js";import{a as r}from"./p-CL7OPpYS.js";import{B as c}from"./p-D3mWkc-3.js";import{D as d}from"./p-CoQJOPRz.js";import{S as h}from"./p-BZp0rKEO.js";import{C as p}from"./p-C6jIkM-X.js";import"./p-CgtvEd63.js";class u{constructor(t,s){this.host=t,this.productId=s,this.collected=!1,this.livePrice=0}static attach(t,s){const i=t.querySelector("salla-mini-checkout-widget");if(!i)return!1;const a=new u(t,String(s));return salla.product?.event?.onPriceUpdated?.((t=>{a.livePrice=Number(t?.data?.price)||a.livePrice})),i.addEventListener("click",(t=>a.handleWidgetClick(t,i)),!0),!0}getSelectedQuantity(){try{const t=document.querySelector("form.product-form"),s=t?.getElementSallaData?.(),i=Number(s instanceof FormData?s.get("quantity"):s?.quantity);if(Number.isFinite(i)&&i>0)return i}catch{}return Number(this.host.getAttribute("quantity"))||1}async handleWidgetClick(t,s){if(this.collected)return void(this.collected=!1);if(t.preventDefault(),t.stopImmediatePropagation(),!await this.validatePdpOptions())return;if(salla.config.isGuest())return void salla.api.auth.requireLoginThen("salla-add-product-button::oo.after-login",(()=>this.handleWidgetClick(t,s)));let i;s.classList.add("s-add-product-button-busy");try{i=await salla.api.withoutNotifier((()=>salla.product.api.getOrderOptions([{id:this.productId,quantity:this.getSelectedQuantity()}])))}catch(t){return salla?.logger?.warn?.("order-options: fetch failed",t),s.classList.remove("s-add-product-button-busy"),void this.resumeWidget(s)}s.classList.remove("s-add-product-button-busy");const a=i?.data?.order_options||[];if(!a.length)return void this.resumeWidget(s);const e=this.livePrice>0?this.livePrice:Number(i?.data?.products?.[0]?.price?.amount)||0,o=this.ensureModal();try{const t=await o.open({orderOptions:a,basePrice:e});this.injectIntoMini(t?.orderOptions||[]),this.resumeWidget(s)}catch{}}async validatePdpOptions(){const t=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);return!t||("function"==typeof t.validateAndScroll?await t.validateAndScroll():"function"!=typeof t.reportValidity||await t.reportValidity())}injectIntoMini(t){if(!t.length)return;const s=this.productId,i=a=>{if(String(a?.id)===String(s))try{a?.payload?.set?.("order_options",t)}finally{salla.event.off("cart::before.add.item",i)}};salla.event.on("cart::before.add.item",i)}ensureModal(){let t=document.querySelector("salla-order-options-modal");return t||(t=document.createElement("salla-order-options-modal"),document.body.appendChild(t)),t}resumeWidget(t){this.collected=!0;const s=t.shadowRoot?.querySelector?.(".s-fast-checkout-button");s?s.click():"function"==typeof t.click&&t.click()}}const m=class{constructor(i){t(this,i),this.success=s(this,"success"),this.failed=s(this,"failed"),this.hostAttributes={},this.hasPreOrder=!1,this.productStatus="sale",this.productType="product",this.selectedOptions=[],this.buyNowText=salla.lang.get("pages.products.buy_now"),this.isDesktopViewport="undefined"==typeof window||window.matchMedia("(min-width: 768px)").matches,this.viewportMediaQuery=null,this.orderOptionsGateAttached=!1,this.onViewportChange=t=>{this.isDesktopViewport=t.matches,this.btn?.setText(t.matches&&this.passedLabel?this.passedLabel:this.getLabel())},salla.lang.onLoaded((()=>{this.buyNowText=salla.lang.get("pages.products.buy_now")}))}getLabel(){return"sale"===this.productStatus&&this.supportStickyBar&&!this.isDesktopViewport&&this.showQuickBuy&&this.isApplePayActive?n:this.hasPreOrder?salla.lang.get("pages.products.pre_order_now"):"sale"===this.productStatus&&"booking"===this.productType?salla.lang.get("pages.cart.book_now"):"sale"===this.productStatus?salla.lang.get("pages.cart.add_to_cart"):"donating"!==this.productType?salla.lang.get("pages.products.out_of_stock"):salla.lang.get("pages.products.donation_exceed")}addProductToCart(t){if("booking"===this.productType)return t.preventDefault(),this.addBookingProduct();if("submit"===this.hostAttributes.type)return!1;t.preventDefault(),this.btn?.disable();const s=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);return s&&"function"==typeof s.validateAndScroll?s.validateAndScroll().then((async t=>{const s={isValid:t,component:this};if(await salla.hooks.call("salla-add-product-button","validate",s),s.isValid)return this._proceedAddToCart();this.btn?.enable()})).catch((()=>{this.btn?.enable()})):this._proceedAddToCart()}async _proceedAddToCart(){const t=this.host.closest("salla-products-list, salla-products-slider")??this.host.closest("salla-product-card, custom-salla-product-card"),s=Object.entries({id:this.productId,donation_amount:this.donatingAmount,quantity:this.quantity,endpoint:"quickAdd",source:l.getProductsSource(t?.getAttribute("source"))}).reduce(((t,[s,i])=>i?(t[s]=i,t):t),{});return salla.cart.addItem(s).then((async t=>(this.selectedOptions=[],this.btn?.enable(),this.success.emit(t),t))).catch((t=>{this.failed.emit(t),this.btn?.enable()}))}addBookingProduct(){return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("booking::add",this.productId),void salla.event.dispatch("login::open")):salla.booking.add(this.productId).then((t=>this.success.emit(t))).catch((t=>this.failed.emit(t)))}getBtnAttributes(){for(let t=0;t<this.host.attributes.length;t++)["id","class"].includes(this.host.attributes[t].name)||(this.hostAttributes[this.host.attributes[t].name]=this.host.attributes[t].value);return this.hostAttributes}get notifyChannels(){return this.channels||salla.api.product.getAvailabilityChannels?.()||l.availabilityChannels()}getQuickBuyBtnAttributes(){return{...this.getBtnAttributes(),type:this.supportStickyBar&&!this.isDesktopViewport?"plain":"donating"==this.productType?"donate":"buy"}}miniCheckoutWidget(){let t=salla.config.get("store.id");if(t)return i("salla-mini-checkout-widget",{language:salla.lang.locale,"store-id":t,config:{user:salla.config.get("user"),failure_url:window.location.href},products:[this.productId],api:salla.config.get("store.api"),outline:!0,"form-selector":"form.product-form",class:"s-add-product-button-mini-checkout"},i("div",{slot:"widget-label",class:"s-add-product-button-mini-checkout-content"},i("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>full-wallet</title>\n<path d="M29 12h-26c-0.668-0.008-1.284-0.226-1.787-0.59l0.009 0.006c-0.744-0.552-1.222-1.428-1.222-2.416 0-1.657 1.343-3 2.999-3h6c0.552 0 1 0.448 1 1s-0.448 1-1 1v0h-6c-0.552 0-1 0.448-1 1 0 0.326 0.156 0.616 0.397 0.798l0.002 0.002c0.167 0.12 0.374 0.194 0.599 0.2l0.001 0h26c0.552 0 1 0.448 1 1s-0.448 1-1 1v0zM27 12c-0.552 0-1-0.448-1-1v0-3h-3c-0.552 0-1-0.448-1-1s0.448-1 1-1v0h4c0.552 0 1 0.448 1 1v0 4c0 0.552-0.448 1-1 1v0zM29 30h-26c-1.657 0-3-1.343-3-3v0-18c0-0.552 0.448-1 1-1s1 0.448 1 1v0 18c0 0.552 0.448 1 1 1v0h25v-5c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM29 18c-0.552 0-1-0.448-1-1v0-6c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM31 24h-7c-2.209 0-4-1.791-4-4s1.791-4 4-4v0h7c0.552 0 1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM24 18c-1.105 0-2 0.895-2 2s0.895 2 2 2v0h6v-4zM25 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-2.306 1.152c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 3.2-1.6c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1v0zM21 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-15.104 7.552c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 16-8c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1-0.001 0-0.001 0-0.002 0h0z"></path>\n</svg>\n'}),this.buyNowText))}componentWillLoad(){return salla.onReady().then((()=>{if(document.documentElement.classList.add("hydrated"),this.showQuickBuy=this.quickBuy&&salla.config.get("store.settings.buy_now")&&"sale"==this.productStatus&&"booking"!==this.productType,this.isApplePayActive=window.ApplePaySession?.canMakePayments()&&salla.config.get("store.settings.payments")?.includes("apple_pay")&&salla.config.get("store.settings.is_salla_gateway",!1),this.passedLabel=this.host.innerHTML.replace("\x3c!----\x3e","").trim(),this.passedLabel&&this.isDesktopViewport)return this.btn?.setText(this.passedLabel);"submit"===this.host.getAttribute("type")&&this.supportStickyBar&&(this.viewportMediaQuery=window.matchMedia("(min-width: 768px)"),this.viewportMediaQuery.addEventListener("change",this.onViewportChange))}))}render(){return this.host.closest(".swiper-slide")?.classList.contains("swiper-slide-duplicate")?"":this.hasSubscribedOptions?i(a,null,i("salla-product-availability",{...this.getBtnAttributes(),"is-subscribed":!0},i("span",{class:"s-hidden"},i("slot",null)))):"out-and-notify"===this.productStatus&&this.notifyChannels||this.hasOutOfStockOption?i(a,null,i("salla-product-availability",{...this.getBtnAttributes()},i("span",{class:"s-hidden"},i("slot",null)))):i(a,{class:{"s-add-product-button-with-quick-buy":this.showQuickBuy,"s-add-product-button-with-sticky-bar":this.supportStickyBar,"s-add-product-button-with-apple-pay":this.showQuickBuy&&this.isApplePayActive}},i("div",{class:{"s-add-product-button-main":this.showQuickBuy,"w-full":!document.getElementById("fast-checkout-js")||["financial_support","donating"].includes(this.productType)}},i("salla-button",{color:"sale"===this.productStatus?"primary":"light",type:"button",fill:"sale"===this.productStatus?"solid":"outline",ref:t=>this.btn=t,onClick:t=>this.addProductToCart(t),disabled:"sale"!==this.productStatus,...this.getBtnAttributes(),"loader-position":"center"},i("slot",null)),this.showQuickBuy&&document.getElementById("fast-checkout-js")&&!["financial_support","donating"].includes(this.productType)?this.miniCheckoutWidget():""),this.showQuickBuy&&this.isApplePayActive?i("salla-quick-buy",{...this.getQuickBuyBtnAttributes()}):"")}async componentDidLoad(){await Salla.hooks.registerComponent("salla-add-product-button",this),this.notifyOptionsAvailability&&salla.event.on("product-options::change",(async t=>{if(!["thumbnail","color","single-option"].includes(t.option.type))return;this.hasSubscribedOptions=!1,this.selectedOptions=await(document.querySelector(`salla-product-options[product-id="${this.productId}"]`)?.getSelectedOptions()),this.hasOutOfStockOption=await(document.querySelector(`salla-product-options[product-id="${this.productId}"]`)?.hasOutOfStockOption());let s=salla.storage.get(`product-${this.productId}-subscribed-options`);if((s||this.subscribedOptions)&&this.hasOutOfStockOption)if(salla.config.isGuest()){const t=s?s.map((t=>t.split(",").map((t=>parseInt(t))))):[];this.hasSubscribedOptions=t.length>0&&t.some((t=>t.every((t=>this.selectedOptions.some((s=>s.id===t))))))}else this.hasSubscribedOptions=!(!this.subscribedOptions||"null"===this.subscribedOptions||"[]"===this.subscribedOptions)&&JSON.parse(this.subscribedOptions).some((t=>t.every((t=>this.selectedOptions.some((s=>s.id===t))))))}))}componentDidRender(){!this.orderOptionsGateAttached&&this.productId&&salla.config.get("store.settings.order_options.mandatory",!1)&&u.attach(this.host,this.productId)&&(this.orderOptionsGateAttached=!0),!this.passedLabel||this.supportStickyBar&&!this.isDesktopViewport?(this.btn?.setText(this.getLabel()),salla.lang.onLoaded((()=>this.btn?.setText(this.getLabel())))):this.btn?.setText(this.passedLabel)}disconnectedCallback(){this.viewportMediaQuery?.removeEventListener("change",this.onViewportChange)}get host(){return e(this)}};m.style=":host{display:block}salla-add-product-button[width=wide]{width:100%}";const y=class{constructor(s){t(this,s),this.limit=3,this.recommendations=[],this.selectedIds=new Set,this.isLoading=!0,this.canRender=!0,this.isAdding=!1,this.title=salla.lang.get("pages.products.bought_together_title"),this.subtitle=salla.lang.get("pages.products.bought_together_subtitle"),this.buyTogetherFor=salla.lang.get("pages.products.buy_together_for"),this.resolvedProductId=0,this.listViewTracked=!1,salla.lang.onLoaded((()=>{this.title=salla.lang.get("pages.products.bought_together_title"),this.subtitle=salla.lang.get("pages.products.bought_together_subtitle"),this.buyTogetherFor=salla.lang.get("pages.products.buy_together_for")}))}componentWillLoad(){salla.onReady().then((()=>{if(!salla.config.get("store.settings.product.bought_together"))return void(this.canRender=!1);const t=salla.config.get("page.id");if(t)return this.resolvedProductId=t,r(String(t));this.canRender=!1})).then((t=>{if(!t?.length)return void(this.canRender=!1);const s=[String(this.resolvedProductId),...t.slice(0,this.limit)];return salla.product.fetch({source:"selected",source_value:s})})).then((t=>{if(!t)return;const s=t?.data??[];if(!s.length)return void(this.canRender=!1);const i=s.find((t=>String(t.id)===String(this.resolvedProductId))),a=s.filter((t=>String(t.id)!==String(this.resolvedProductId)));a.length?(this.recommendations=i?[i,...a]:a,this.selectedIds=new Set(this.recommendations.map((t=>t.id)))):this.canRender=!1})).catch((()=>{this.canRender=!1})).finally((()=>{this.isLoading=!1}))}componentDidRender(){!this.recommendations.length||this.listViewTracked||this.intersectionObserver||(this.intersectionObserver=new IntersectionObserver((t=>{t.some((t=>t.isIntersecting))&&(this.listViewTracked=!0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.emitListViewed())}),{threshold:.1}),this.intersectionObserver.observe(this.el))}disconnectedCallback(){this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0}emitListViewed(){const t=this.recommendations.filter((t=>!this.isMainProduct(t.id)));salla.event.emit("salla-bought-together::list.viewed",{products:t})}isMainProduct(t){return String(t)===String(this.resolvedProductId)}recommendedPosition(t){const s=this.recommendations.filter((t=>!this.isMainProduct(t.id))).findIndex((s=>String(s.id)===String(t)));return-1===s?-1:s+1}emitProductClicked(t,s){salla.event.emit("salla-bought-together::product.clicked",[{product:t,position:s}])}toggleProduct(t){const s=new Set(this.selectedIds);s.has(t)?s.delete(t):s.add(t),this.selectedIds=s}get totalPrice(){const t=this.recommendations.filter((t=>this.selectedIds.has(t.id))).reduce(((t,s)=>t+(s.price??0)),0),s=salla.config.get("store.currency.decimals")??2,i=Math.pow(10,s);return salla.money(Math.round(t*i)/i)}async addSelectedToCart(){if(this.isAdding||!this.selectedIds.size)return;this.isAdding=!0;let t=!1;try{for(const s of Array.from(this.selectedIds))try{salla.cart?.api&&(salla.cart.api.addToCartSource="pdp_fbt");const t=await salla.cart.addItem({id:s,endpoint:"quickAdd",source:"pdp_fbt"}),i=this.recommendations.find((t=>t.id===s));if(i){const a=this.isMainProduct(s)?0:this.recommendedPosition(s),e=t?.data?.items?.find((t=>String(t.product_id)===String(i.id)))??t?.data?.items?.slice(-1)[0];salla.event.emit("salla-bought-together::product.added",[{product:i,position:a,cartItem:e,cartId:t?.data?.id}])}}catch(s){salla.log(s),t=!0}t&&salla.error(salla.lang.get("common.messages.error"))}finally{this.isAdding=!1}}getSkeletonView(){return i(a,{class:"s-bought-together-entry"},i("div",{class:"s-bought-together-skeleton"},i("div",{class:"s-bought-together-skeleton-header"},i("salla-skeleton",{height:"16px",width:"35%"}),i("salla-skeleton",{height:"10px",width:"60%"})),Array(4).fill(null).map(((t,s)=>i("div",{key:s,class:"s-bought-together-skeleton-item"},i("salla-skeleton",{height:"22px",width:"22px"}),i("salla-skeleton",{height:"48px",width:"48px"}),i("div",{class:"s-bought-together-skeleton-info"},i("salla-skeleton",{height:"12px",width:"55%",style:{marginBottom:"3px"}}),i("salla-skeleton",{height:"10px",width:"25%"}))))),i("salla-skeleton",{height:"44px",width:"100%"})))}render(){return this.canRender?this.isLoading?this.getSkeletonView():this.recommendations.length?i(a,{class:"s-bought-together-entry"},i("div",{class:"s-bought-together-header"},i("h3",{class:"s-bought-together-title"},this.title),i("p",{class:"s-bought-together-subtitle"},this.subtitle)),i("div",{class:"s-bought-together-list"},this.recommendations.map((t=>i("div",{key:t.id,class:"s-bought-together-item"+(this.selectedIds.has(t.id)?"":" s-bought-together-item--unchecked")},i("label",{class:"s-bought-together-checkbox-label"},i("input",{type:"checkbox",class:"s-bought-together-checkbox",checked:this.selectedIds.has(t.id),onChange:()=>this.toggleProduct(t.id)}),i("span",{class:"s-bought-together-checkmark"})),i("a",{class:"s-bought-together-item-link",href:t.url,onClick:()=>!this.isMainProduct(t.id)&&this.emitProductClicked(t,this.recommendedPosition(t.id))},i("img",{class:"s-bought-together-item-img",src:t.image?.url||salla.url.cdn("images/s-empty.png"),alt:t.image?.alt||t.name,loading:"lazy",decoding:"async",onError:t=>{t.currentTarget.onerror=null,t.currentTarget.src=salla.url.cdn("images/s-empty.png")}}),i("span",{class:"s-bought-together-item-name"},t.name)),i("span",{class:"s-bought-together-item-price",innerHTML:null!=t.price?salla.money(t.price):""}))))),i("salla-button",{class:"s-bought-together-btn",disabled:!this.selectedIds.size||this.isAdding,loading:this.isAdding,onClick:()=>this.addSelectedToCart()},i("span",{innerHTML:`${this.buyTogetherFor} ${this.totalPrice}`}))):null:null}get el(){return e(this)}};y.style=':host{display:block}.s-bought-together-checkbox:checked~.s-bought-together-checkmark{background-color:var(--color-primary, #2ECC71);border-color:var(--color-primary, #2ECC71)}.s-bought-together-checkbox:checked~.s-bought-together-checkmark::after{content:"";display:block;width:5px;height:9px;border:solid #fff;border-width:0 2px 2px 0;transform:rotate(45deg);margin-top:-2px}';const g=class{constructor(s){t(this,s),this.isUser=salla.config.isUser(),this.translationLoaded=!1,this.notifyOptionsAvailability=!1,this.isSubscribed=!1,this.handleSubmitOptions=async()=>{let t={id:this.productId};if(!this.notifyOptionsAvailability)return t;let s=document.querySelector(`salla-product-options[product-id="${this.productId}"]`),i=Object.values(await(s?.getSelectedOptionsData())||{});if(i.length&&!await(s?.reportValidity())){let t=salla.lang.get("common.messages.required_fields");throw salla.error(t),t}return t.options=[],i.forEach((s=>{s&&!isNaN(s)&&t.options.push(Number(s))})),t},this.typing=t=>{const s=t.target.nextElementSibling;t.target.classList.remove("s-has-error"),s?.classList.contains("s-product-availability-error-msg")&&(s.innerText=""),13===t.keyCode&&this.submit()},salla.lang.onLoaded((()=>{this.translationLoaded=!0,this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.modal?.setTitle(this.title_)})),this.productId||(this.productId=salla.config.get("page.id")),this.isUser||(this.channelsWatcher(this.channels),this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.host.removeAttribute("title"))}channelsWatcher(t){let s=t||salla.api.product.getAvailabilityChannels?.()||l.availabilityChannels();this.channels_=s?s.split(","):[]}get isSubscribedToProduct(){return this.isSubscribed||!this.notifyOptionsAvailability&&(!!salla.api.product.isSubscribedToAvailability?.(this.productId)||!!salla.storage.get(`product-${this.productId}-subscribed`))}openModel(){this.handleSubmitOptions().then((t=>t?this.modal.open():null))}async submit(){let t=await this.handleSubmitOptions();if(this.isUser)return salla.api.product.availabilitySubscribe(t).then((()=>this.isSubscribed=!0));if(this.channels_.includes("sms")||this.channels_.includes("whatsapp")){let{phone:s,countryCode:i}=await this.mobileInput.getValues();t.country_code=i,t.phone=s}return this.channels_.includes("email")&&""!==this.email.value&&(t.email=this.email.value),await this.validateform(),this.btn.load().then((()=>this.btn.disable())).then((()=>salla.api.product.availabilitySubscribe(t))).then((()=>{if(this.notifyOptionsAvailability){if(t.options.length){let s=salla.storage.get(`product-${this.productId}-subscribed-options`)||[],i=t.options.join(",");s.includes(i)?salla.log("already subscribed to this options"):(s.push(i),salla.storage.set(`product-${this.productId}-subscribed-options`,s),this.isSubscribed=!0)}}else this.isSubscribed=!0})).then((()=>this.btn.stop())).then((()=>this.modal.close())).catch((()=>this.btn.stop()&&this.btn.enable()))}async validateform(){try{if(this.channels_.includes("email")){const t=l.isValidEmail(this.email.value);if(t)return;!t&&this.validateField(this.email,salla.lang.get("common.elements.email_is_valid"))}if((this.channels_.includes("sms")||this.channels_.includes("whatsapp"))&&await this.mobileInput.isValid())return}catch(t){throw"Please insert required fields"}}validateField(t,s){t.classList.add("s-has-error"),t.nextElementSibling.innerText="* "+s}render(){return i(a,{key:"ccb098126e7809a6386ff38c74dfa0f00f64deeb",class:"s-product-availability-wrap"},this.isSubscribedToProduct?i("div",{class:"s-product-availability-subscribed"},i("span",{innerHTML:c,class:"s-product-availability-subs-icon"}),salla.lang.get("pages.products.notify_availability_success")):i("salla-button",{width:"wide",onClick:()=>this.isUser?this.submit():this.openModel()},salla.lang.get("pages.products.notify_availability")),this.isUser||this.isSubscribedToProduct?"":this.renderModal())}renderModal(){return i("salla-modal",{ref:t=>this.modal=t,"modal-title":this.title_,subTitle:salla.lang.get("pages.products.notify_availability_subtitle"),width:"sm"},i("span",{slot:"icon",class:"s-product-availability-header-icon",innerHTML:c}),i("div",{class:"s-product-availability-body"},this.channels_.includes("email")?[i("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.email")),i("input",{class:"s-product-availability-input",onKeyDown:t=>this.typing(t),placeholder:salla.lang.get("common.elements.email_placeholder")||"your@email.com",ref:t=>this.email=t,type:"email"}),i("span",{class:"s-product-availability-error-msg"})]:"",this.channels_.includes("sms")||this.channels_.includes("whatsapp")?[i("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.mobile")),i("salla-tel-input",{ref:t=>this.mobileInput=t,onKeyDown:t=>this.typing(t)})]:""),i("div",{slot:"footer",class:"s-product-availability-footer"},i("salla-button",{class:"modal-cancel-btn",width:"wide",color:"light",fill:"outline",onClick:()=>this.modal.close()},salla.lang.get("common.elements.cancel")),i("salla-button",{class:"submit-btn","loader-position":"center",width:"wide",ref:t=>this.btn=t,onClick:()=>this.submit()},salla.lang.get("common.elements.submit"))))}get host(){return e(this)}static get watchers(){return{channels:["channelsWatcher"]}}};var f,b,w;g.style="",function(t){t[t.INIT=1]="INIT",t[t.IDLE=2]="IDLE",t[t.PROCESSING_QUEUED=9]="PROCESSING_QUEUED",t[t.PROCESSING=3]="PROCESSING",t[t.PROCESSING_COMPLETE=5]="PROCESSING_COMPLETE",t[t.PROCESSING_ERROR=6]="PROCESSING_ERROR",t[t.PROCESSING_REVERT_ERROR=10]="PROCESSING_REVERT_ERROR",t[t.LOADING=7]="LOADING",t[t.LOAD_ERROR=8]="LOAD_ERROR"}(f||(f={})),function(t){t[t.EMPTY=0]="EMPTY",t[t.IDLE=1]="IDLE",t[t.ERROR=2]="ERROR",t[t.BUSY=3]="BUSY",t[t.READY=4]="READY"}(b||(b={})),function(t){t[t.INPUT=1]="INPUT",t[t.LIMBO=2]="LIMBO",t[t.LOCAL=3]="LOCAL"}(w||(w={}));const v=class{constructor(a){if(t(this,a),this.changed=s(this,"changed"),this.fileTypes={pdf:"application/pdf",png:"image/png",jpg:"image/jpeg",word:"application/doc,application/ms-doc,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",exl:"application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",txt:"text/plain"},this.outOfStockText="",this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.selectDonationAmount=salla.lang.getWithDefault("pages.products.select_donation_amount","تحديد مبلغ التبرع"),this.selectAmount=salla.lang.getWithDefault("pages.products.select_amount","اختر المبلغ"),this.isCustomDonation=!1,this.selectedOptions=[],this.canDisabled=!1,this.disableCardValue=!0,this.availableDigitalCardValues=[],this.userInitiatedValidation=!1,this.isCartMode=!1,this.availabilityMap={},this.productAvailable=!1,this.outSkus=[],this.ignoreDefaultCardValue=!1,this.productId=salla.config.get("page.id"),this.noPadding=!1,this.handleDonationOptions=(t,s,i)=>{if("custom"===s&&"input"===i){const s=t.target;return salla.helpers.inputDigitsOnly(s),salla.event.emit("product-options::donation-changed",{id:this.productId,price:s.value}),void s.dispatchEvent(new window.Event("change",{bubbles:!0}))}const a="option"===i?String(t.target?.value??""):"";if("option"===i&&"custom"===s&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()),this.isCustomDonation="custom"===a,this.donationInput){if("custom"===a?(this.donationInput.value="",this.donationInput.focus()):this.donationInput.value=a,"custom"===s)return;salla.event.emit("product-options::donation-changed",{id:this.productId,price:a})}},this.hideLabel=t=>!(t.type!==d.DONATION||!t.donation||t.donation.can_donate),this.getExpireDonationMessage=t=>{if(!t.donation)return;const s=t.donation.target_amount<=t.donation.collected_amount;return i("div",{class:{"s-product-options-donation-message":!0,"s-product-options-donation-completed":s,"s-product-options-donation-expired":!s}},i("p",null,t.donation.target_message),i("span",{innerHTML:s?salla.money(t.donation.target_amount):""}))},salla.lang.onLoaded((()=>{this.outOfStockText=salla.lang.get("pages.products.out_of_stock"),this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.selectDonationAmount=salla.lang.getWithDefault("pages.products.select_donation_amount","تحديد مبلغ التبرع"),this.selectAmount=salla.lang.getWithDefault("pages.products.select_amount","اختر المبلغ")})),this.options)try{return void this.setOptionsData(Array.isArray(this.options)?this.options:JSON.parse(this.options))}catch(t){salla.log("Bad json passed via options prop")}Array.isArray(this.optionsData)||(salla.log("Options is not an array[] ---\x3e ",this.optionsData),this.setOptionsData([])),this.productId&&!salla.url.is_page("cart")&&salla.api.product.getDetails(this.productId,["options"]).then((t=>{this.productAvailable=!t.data.is_out_of_stock,this.setOptionsData(t.data.options)}))}async setOptionsData(t){this.optionsData=t,this.outSkus=[],this.optionsData[0]?.details?.forEach((t=>{Object.entries(t.skus_availability||{}).filter((([,t])=>!t)).forEach((([t])=>this.outSkus.push(Number(t))))})),this.fillSelectedOptions(),this.computeAvailability()}async getOptionsData(){return this.optionsData}async getSelectedOptionsData(){const t={},s=this.host.getElementSallaData(),i=void 0!==this.bundleContext?this.bundleContext:null;return s.forEach(((s,a)=>{if(i){if(a.startsWith("bundle[")&&a.includes("[options][")){const i=a.split("[options][")[1].replace("]","");t[i]=s}}else a.startsWith("options[")&&(t[a.replace("options[","").replace("]","")]=s)})),t}async reportValidity(){const t=this.host.querySelectorAll("[required]");let s=!0;for(let i=0;i<t.length;i++){const a=t[i];a.disabled||a.closest(".hidden")||"reportValidity"in a&&!a.reportValidity()&&(s=!1)}return s}async hasOutOfStockOption(){return this.selectedOptions.some((t=>t.is_out))||this.selectedSkus?.length&&this.selectedSkus?.every((t=>this.outSkus.includes(t)))}async getSelectedOptions(){return this.selectedOptions}async getOption(t){return this.optionsData.find((s=>s.id===t))}invalidHandler(t,s){const i=t.target.closest(".s-product-options-option");i.classList.contains("s-product-options-option-error")||i.classList.add("s-product-options-option-error"),!this.userInitiatedValidation&&!salla.helpers.isIOSDevice()||salla.url.is_page("cart")||this.host.querySelector(".s-product-options-option-error")===i&&this.scrollToElement(i)}scrollToElement(t){t&&t.scrollIntoView({behavior:"smooth",block:"center"})}changedHandler(t,s,i=!0){const a={event:t,option:s,detail:null,productId:this.productId};if(s.details){const i=s.details.find((s=>Number(s.id)===Number(t.target.value)));a.detail=i}"country"===s.type&&this.handleCountryOptionChange(t,a.detail);const e=t.target.closest(".s-product-options-option");(t.target.value||(s.type===d.FILE||s.type===d.IMAGE)&&"added"===t.type||s.type===d.MAP&&"selected"===t.type&&t.target.lat&&t.target.lng)&&setTimeout((()=>{e.classList.remove("s-product-options-option-error")}),200),s.type===d.DONATION&&salla.event.emit("product-options::donation-changed",{id:this.productId,price:t.target.value}),this.setSelectedSkus(),this.handleRequiredMultipleOptions(s);const o=this.selectedOptions.findIndex((t=>t.option_id===a.option.id));if(a.option.type===d.MULTIPLE_OPTIONS){const t=this.selectedOptions.findIndex((t=>t.option_id===a.option.id&&t?.id===a.detail?.id));t>-1?this.selectedOptions.splice(t,1):this.selectedOptions.push({...a.detail,option_id:a.option.id})}else a.detail&&0!==Object.keys(a.detail).length?o>-1?this.selectedOptions[o]={...a.detail,option_id:a.option.id}:this.selectedOptions.push({...a.detail,option_id:a.option.id}):o>-1&&this.selectedOptions.splice(o,1);this.optionsData=this.optionsData.map((t=>t.id===a.option.id?{...t,details:t.details.map((t=>({...t,is_selected:a.option.type===d.MULTIPLE_OPTIONS?this.selectedOptions.some((s=>s.id===t.id)):Number(t.id)===Number(a.detail?.id),value:a.detail?.value})))}:t)),this.pruneInvisibleConditionalSelections(),this.setSelectedSkus(),requestAnimationFrame((()=>{this.optionsData?.filter((t=>t.type===d.MULTIPLE_OPTIONS&&t.required)).forEach((t=>this.handleRequiredMultipleOptions(t)))})),i&&(this.changed.emit(a),salla.event.emit("product-options::change",a))}setSelectedSkus(){this.selectedSkus=this.selectedOptions.map((t=>Object.keys(t.skus_availability||{}))).reduce(((t,s)=>t.filter((t=>s.includes(t)))),[]).map((t=>Number(t))),this.computeAvailability()}handleRequiredMultipleOptions(t){if(t.type!==d.MULTIPLE_OPTIONS||!t.required)return;const s=this.host.querySelector(`[data-option-id="${t.id}"]`);if(!s)return;const i=s.querySelectorAll("input:checked").length;s.querySelectorAll("input").forEach((t=>t.toggleAttribute("required",!i)))}pruneInvisibleConditionalSelections(){const t=Math.max(1,this.optionsData.length);for(let s=0;s<t;s++){let t=!1;for(const s of this.optionsData){const i=s.visibility_condition;if(!i)continue;const a=this.selectedOptions.filter((t=>t.option_id===i.option)).map((t=>String(t.id))).includes(String(i.value));("="===i.operator?a:!a)||this.clearStaleOption(s.id)&&(t=!0)}if(!t)break}}clearStaleOption(t){const s=this.optionsData.find((s=>s.id===t));if(!s)return!1;const i=this.selectedOptions.length;this.selectedOptions=this.selectedOptions.filter((s=>s.option_id!==t));const a=this.selectedOptions.length!==i,e=null!=s.value&&String(s.value).length>0,o=s.details?.some((t=>t.is_selected))??!1;return!!(a||e||o)&&(this.optionsData=this.optionsData.map((s=>s.id!==t?s:{...s,value:void 0,details:s.details?.map((t=>({...t,is_selected:!1})))??s.details})),!0)}getLatLng(t,s){return t?t.split(",")["lat"===s?0:1]:""}getDisplayForType(t){return this[`${t.type}Option`]?this[`${t.type}Option`](t):t.type===d.COLOR_PICKER?this.colorPickerOption(t):t.type===d.MULTIPLE_OPTIONS?this.multipleOptions(t):t.type===d.SINGLE_OPTION?this.singleOption(t):t.type===d.RADIO?this.radioOption(t):t.type===d.DIGITAL_CARD_VALUE?this.digitalCardValuesOption(t):t.type===d.COUNTRY?this.countryOption(t):t.type===d.BOOKING&&salla.url.is_page("cart")?i("salla-booking-field",{onInvalidInput:s=>this.invalidHandler(s,t),option:t,productId:t.value}):(salla.log(`Couldn't find options type(${t.type})😢`),"")}getOptionShownWhen(t){return t.visibility_condition?{"data-show-when":`options[${t.visibility_condition.option}] ${t.visibility_condition.operator} ${t.visibility_condition.value}`}:{}}getAvailableDigitalCardSKUs(t){const s=this.optionsData.find((({type:t})=>"digital-code-value"===t));if(!s)throw new Error("product-options:: No digital card options found");const i=Object.keys(t.skus_availability).filter((s=>!1===t.skus_availability[s]));this.availableDigitalCardValues=s.details.filter((t=>!Object.keys(t.skus_availability).filter((t=>i.includes(t))).length))}handleCountryOptionChange(t,s){t.stopImmediatePropagation(),this.ignoreDefaultCardValue=!0;const i=this.host.querySelector("input[data-code-value]:checked");if(i&&(i.checked=!1),!this.optionsData.find((({type:t})=>"digital-code-value"===t)))throw new Error("product-options:: No digital card options found");this.getAvailableDigitalCardSKUs(s)}getSelectedDigitalCardOptions(t){const s=t.details.find((t=>t.is_selected)),i=t.details.find((t=>!!t.is_default))||t.details[0];if(["digital-code-value","country"].includes(t.type))return s||i}async componentWillLoad(){if(salla.url.is_page("cart")&&(this.disableCardValue=!1,this.fillSelectedOptions()),this.config)try{this.optionConfig="string"==typeof this.config?JSON.parse(this.config):this.config}catch(t){console.error("Failed to parse JSON in config prop:",t)}if(this.optionsData.filter((({type:t})=>["country","digital-card-value"].includes(t))).length>0&&salla.url.is_page("cart")){const t=this.optionsData.find((t=>"country"===t.type)),s=t&&this.getSelectedDigitalCardOptions(t);s&&this.getAvailableDigitalCardSKUs(s)}return this.outOfStockText=salla.lang.get("pages.products.out_of_stock"),this.computeAvailability(),await salla.onReady(),this.canDisabled=!salla.config.get("store.settings.product.notify_options_availability")||salla.url.is_page("cart"),this.pasteHandler=this.handlePaste.bind(this),document.addEventListener("paste",this.pasteHandler),!salla.storage.get("cart.id")&&this.optionsData.some((t=>["file","image"].includes(t.type)))?salla.api.cart.getCurrentCartId(!1,"salla-product-options"):null}disconnectedCallback(){this.pasteHandler&&document.removeEventListener("paste",this.pasteHandler)}handlePaste(t){const s=t.target;if(!(Salla.helpers.isAppleDevice()&&(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement)&&s.classList.contains("s-form-control")&&this.host.contains(s)))return;t.preventDefault();const i=t.clipboardData?.getData("text")||"",a=s.selectionStart,e=s.selectionEnd,o=s.value.slice(0,a)+i+s.value.slice(e);s.value=o,s.setSelectionRange(a+i.length,a+i.length);try{s.dispatchEvent(new window.Event("change",{bubbles:!0}))}catch(t){Salla.log("Error on change")}}hideDigitalCardsOptions(t){return this.disableCardValue&&t.type===d.DIGITAL_CARD_VALUE&&!salla.url.is_page("cart")}render(){if(0!==this.optionsData?.length)return i(a,{class:{"s-product-options-wrapper":!0,"s-product-options-no-padding":this.noPadding}},i("salla-conditional-fields",null,this.optionsData.map((t=>i("div",{key:t.id,class:"s-product-options-option-container"+(t.visibility_condition||this.hideDigitalCardsOptions(t)?" hidden":""),"data-option-id":t.id,...this.getOptionShownWhen(t)},"splitter"===t.name?this.splitterOption():i("div",{class:{"s-product-options-option":!0,"s-product-options-option-booking":t.type===d.BOOKING&&salla.url.is_page("cart")},"data-option-type":t.type,"data-option-required":`${t.required}`},i("label",{htmlFor:this.generateInputId(t.id),class:"s-product-options-option-label "+(this.hideLabel(t)?"s-product-options-option-label-hidden":"")},i("b",null,t.name,t.required&&i("span",null," * ")," "),i("small",null,t.placeholder)),i("div",{class:"s-product-options-option-content "+(this.hideLabel(t)||t.type===d.BOOKING&&salla.url.is_page("cart")?"s-product-options-option-content-full-width":"")},this.getDisplayForType(t))))))))}generateUniqueKey(t){const s=this.bundleContext;let i=this.uniqueKey?`${t}-${this.uniqueKey}`:t;if(s)try{const t="string"==typeof s?JSON.parse(s):s,{sectionId:a,productId:e}=t;i=`${i}-bundle-${a}-${e}`}catch(t){}return i}generateInputId(t){return this.generateUniqueKey(`option-${t}`)}generateInputName(t){const s=this.bundleContext,i=t.toString();if(s)try{const t="string"==typeof s?JSON.parse(s):s,{sectionId:a,productId:e}=t;return`bundle[${a}][${e}][options][${i}]`}catch(t){return`options[${i}]`}return`options[${i}]`}fillSelectedOptions(){this.selectedOptions=this.optionsData.reduce(((t,s)=>{const i=(s.details??[]).filter((t=>t.is_selected)).map((t=>({...t,option_id:s.id})));return t.concat(i)}),[])}async seedSelectedOptions(){this.fillSelectedOptions(),requestAnimationFrame((()=>{this.optionsData?.filter((t=>t.type===d.MULTIPLE_OPTIONS&&t.required)).forEach((t=>this.handleRequiredMultipleOptions(t)))}))}async componentDidLoad(){if(!this.optionsData?.length)return;await Salla.hooks.registerComponent("salla-product-options",this);const t=this.optionsData.find((t=>t.type===d.DONATION))?.details?.find((t=>t.is_selected));if(t&&setTimeout((()=>{salla.event.emit("product-options::donation-changed",{id:this.productId,price:t.additional_price})}),1e3),!salla.url.is_page("cart")&&!this.isCartMode){const t=[d.SINGLE_OPTION,d.MULTIPLE_OPTIONS,d.COLOR,d.THUMBNAIL,d.DONATION,d.DIGITAL_CARD_VALUE,d.COUNTRY];this.optionsData.some((s=>t.includes(s.type)&&s.details?.some((t=>t.is_selected))))&&requestAnimationFrame((()=>{try{const t=this.host.closest("form");if(!t)return;const s=new FormData(t),i=s.get("id")||s.get("product_id");if(i&&String(i)!==String(this.productId))return;salla.product.getPrice(s)}catch(t){salla.log("Error updating price for pre-selected options:",t)}}))}}async enterCartMode(){this.isCartMode=!0,this.disableCardValue=!1,this.canDisabled=!0,this.fillSelectedOptions(),this.computeAvailability()}async enableUserInitiatedValidation(){this.userInitiatedValidation=!0}async validateAndScroll(){return await this.enableUserInitiatedValidation(),this.reportValidity()}donationOption(t,s){return i("div",{class:"s-product-options-donation-wrapper"},t.donation?.can_donate?[t.donation?i("div",{key:t.id,class:"s-product-options-donation-progress"},i("salla-progress-bar",{donation:t.donation})):"",t.details.length?[i("h4",{key:t.id},this.selectAmount),i("div",{key:t.id,class:"s-product-options-donation-options"},t.details.map(((s,a)=>i("div",{key:t.id,class:"s-product-options-donation-options-item"},i("input",{id:this.generateUniqueKey(`donation-option-${a}`),type:"radio",name:"donating_option",checked:s.is_selected,value:s.additional_price,onChange:i=>this.handleDonationOptions(i,s,"option",t)}),i("label",{htmlFor:this.generateUniqueKey(`donation-option-${a}`)},i("span",{innerHTML:salla.money(s.name)}))))),t.donation?.custom_amount_enabled?i("div",{class:"s-product-options-donation-options-item"},i("input",{id:this.generateUniqueKey("donation-option-custom"),type:"radio",name:"donating_option",value:"custom",onChange:s=>this.handleDonationOptions(s,"custom","option",t)}),i("label",{htmlFor:this.generateUniqueKey("donation-option-custom")},i("span",null," ",this.selectDonationAmount," "))):"")]:"",i("div",{key:t.id,class:{"s-product-options-donation-input-group":!0,shown:!t.details.length||t.details.length&&this.isCustomDonation}},i("input",{type:"text",id:"donating-amount",name:"donation_amount",class:"s-form-control",ref:t=>{this.donationInput=t},value:t.details.length&&t.details.some((t=>t.is_selected))?t.details.find((t=>t.is_selected)).additional_price:t.value,placeholder:t.placeholder,onInput:s=>this.handleDonationOptions(s,"custom","input",t),onBlur:s=>this.changedHandler(s,t),onInvalid:s=>this.invalidHandler(s,t)}),i("span",{class:"s-product-options-donation-amount-currency"},salla.config.currency(salla.config.get("user.currency_code")).symbol))]:this.getExpireDonationMessage(t))}fileUploader(t,s=null){return i("salla-file-upload",{...s||{},"payload-name":"file",value:t.value,"instant-upload":!0,name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,height:"120px",onAdded:s=>{this.changedHandler(s,t,!(s.detail?.file?.origin===w.LOCAL))},url:salla.cart.api.getUploadImageEndpoint(),"form-data":{cart_item_id:this.productId,product_id:this.productId},onInvalidInput:s=>this.invalidHandler(s,t),class:{"s-product-options-image-input":!0,required:t.required}},i("div",{class:"s-product-options-filepond-placeholder"},i("span",{class:"s-product-options-filepond-placeholder-icon",innerHTML:s.accept?.split(",").every((t=>t.includes("image")))?p:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>file-upload</title>\n<path d="M21.333 24c0.341 0 0.683-0.131 0.943-0.391 0.521-0.521 0.521-1.364 0-1.885l-5.333-5.333c-0.123-0.123-0.271-0.22-0.433-0.288-0.327-0.135-0.693-0.135-1.019 0-0.163 0.068-0.311 0.165-0.433 0.288l-5.333 5.333c-0.521 0.521-0.521 1.364 0 1.885s1.364 0.521 1.885 0l3.057-3.057v10.115c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-10.115l3.057 3.057c0.26 0.26 0.601 0.391 0.943 0.391zM28.943 9.724l-9.333-9.333c-0.249-0.251-0.589-0.391-0.943-0.391h-12c-2.205 0-4 1.795-4 4v24c0 2.205 1.795 4 4 4h4c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333h-4c-0.735 0-1.333-0.599-1.333-1.333v-24c0-0.735 0.599-1.333 1.333-1.333h11.448l8.552 8.552v16.781c0 0.735-0.599 1.333-1.333 1.333h-4c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h4c2.205 0 4-1.795 4-4v-17.333c0-0.353-0.14-0.693-0.391-0.943z"></path>\n</svg>\n'}),i("p",{class:"s-product-options-filepond-placeholder-text"},salla.lang.get("common.uploader.drag_and_drop")),i("span",{class:"filepond--label-action"},salla.lang.get("common.uploader.browse"))))}imageOption(t){return this.fileUploader(t,{accept:"image/png,image/jpeg,image/jpg,image/gif"})}fileOption(t){const s=t.details.map((t=>this.fileTypes[t.name])).filter(Boolean);return s?.length?this.fileUploader(t,{accept:s.join(",")}):"File types not selected."}numberOption(t){return i("input",{type:"text",value:t.value,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onBlur:s=>this.changedHandler(s,t),onInvalid:s=>this.invalidHandler(s,t),onInput:t=>salla.helpers.inputDigitsOnly(t.target)})}splitterOption(){return i("div",{class:"s-product-options-splitter"})}textOption(t){return i("div",{class:"s-product-options-text"},i("input",{type:"text",value:t.value,maxLength:t?.length,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)}))}textareaOption(t){return i("div",{class:"s-product-options-textarea"},i("div",{class:"mt-1"},i("textarea",{rows:4,value:t.value,maxLength:t?.length,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)})))}mapOption(t){return i("salla-map",{zoom:15,lat:this.getLatLng(t.value,"lat"),lng:this.getLatLng(t.value,"lng"),name:this.generateInputName(t.id),searchable:!0,required:t.required,onInvalidInput:s=>this.invalidHandler(s,t),onSelected:s=>this.changedHandler(s,t)})}colorPickerOption(t){return i("salla-color-picker",{onSubmitted:s=>this.changedHandler(s,t),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,onInvalidInput:s=>this.invalidHandler(s,t),color:t.value})}timeOption(t){return i("salla-datetime-picker",{noCalendar:!0,enableTime:!0,dateFormat:"h:i K",value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,name:this.generateInputName(t.id),class:"s-product-options-time-element",onInvalidInput:s=>this.invalidHandler(s,t),onPicked:s=>this.changedHandler(s,t)})}dateOption(t){return i("div",{class:"s-product-options-date-element"},i("salla-datetime-picker",{value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,minDate:new Date,name:this.generateInputName(t.id),onInvalidInput:s=>this.invalidHandler(s,t),onPicked:s=>this.changedHandler(s,t)}))}datetimeOption(t){return i("div",{class:"s-product-options-datetime-element"},i("salla-datetime-picker",{enableTime:!0,value:t.value,dateFormat:"Y-m-d G:i:K",placeholder:t.name,required:!t.visibility_condition&&t.required,name:this.generateInputName(t.id),maxDate:t.to_date_time,minDate:t.from_date_time,onInvalidInput:s=>this.invalidHandler(s,t),onPicked:s=>this.changedHandler(s,t)}))}getOptionDetailName(t,s=!0,i,a){let e;if(i&&i===d.COLOR&&(e=t.name+(s&&this.isOptionDetailOut(t)&&!salla.url.is_page("cart")&&!this.hideOutLabel?` <br/> <p> ${this.outOfStockText} </p>`:"")+(t.additional_price?` <p> (${salla.money(t.additional_price,!1)}) </p>`:"")),!e){const i=(s&&this.isOptionDetailOut(t)&&!salla.url.is_page("cart")&&!this.hideOutLabel?` - ${this.outOfStockText}`:"")+(t.additional_price?` (${salla.money(t.additional_price,!1)})`:"");if("price"===a){const s=salla.helpers.digitsOnly(t.name),a=Number(s);return s&&Number.isFinite(a)?salla.money(a,!0)+i:i}e=t.name+i}return e.replace("<i class=sicon-sar></i>",salla.config.currency()?.symbol||"ر.س")}computeAvailability(){this.availabilityMap=function(t,s,i=!0){const a={};if(!t?.length)return a;const e=t.filter((t=>t.details?.some((t=>t.skus_availability&&Object.keys(t.skus_availability).length>0)))),o=e.length<=1,n=new Set(t.filter((t=>!1===t.is_advance)).map((t=>t.id)));if(0===e.length){for(const s of t)for(const t of s.details)a[t.id]=t.is_out?"out_of_stock":"available";return a}const l=e.some((t=>t.details?.some((t=>t.skus_availability&&Object.values(t.skus_availability).some(Boolean))))),r=i&&!l;for(const t of e){const i=s.filter((s=>s.option_id!==t.id));for(const s of t.details){const t=s.skus_availability;if(!t||!Object.keys(t).length){a[s.id]=s.is_out?"out_of_stock":"available";continue}const e=Object.keys(t).map(Number),l=e.some((s=>t[s]));if(o||0===i.length){a[s.id]=!l&&r||l?"available":"out_of_stock";continue}let c=e;for(const t of i){if(n.has(t.option_id))continue;const s=new Set(Object.keys(t.skus_availability||{}).map(Number));c=c.filter((t=>s.has(t)))}if(!c.length){a[s.id]=r?"available":"impossible";continue}const d=c.some((s=>t[s]));a[s.id]=!d&&r||d?"available":"out_of_stock"}}return a}(this.optionsData||[],this.selectedOptions||[],this.productAvailable)}isOptionDetailOut(t){const s=this.availabilityMap[t.id];return void 0!==s?"available"!==s:!!t.is_out}renderInput(t,s,a,e,o,n){const l=this.generateUniqueKey(`${t}-${a.id}-${s.id}`),r=this.isOptionDetailOut(s),c=this.getOptionDetailName(s,!0,a.type,a.format),d={"s-product-options-grid-mode-span":n,"s-product-options-disabled":this.canDisabled&&r};return i("label",{class:{"s-product-options-disabled":this.canDisabled&&r,"s-product-options-option-stock-out":r}},i("input",{id:l,type:t,name:o,value:s.id,disabled:this.canDisabled&&r,required:e,checked:s.is_selected,onInvalid:t=>this.invalidHandler(t,a),onChange:t=>this.changedHandler(t,a)}),"price"===a.format?i("div",{class:d,innerHTML:c}):i("div",{class:d},c))}renderOptionDetails(t,s,i,a=!1){const e=this.generateInputName(s.id),o="radio"===t?e:`${e}[]`;return s?.details.map((e=>this.renderInput(t,e,s,i,o,a)))}renderSelect(t){return i("div",null,i("select",{id:this.generateInputId(t.id),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,class:"s-form-control",onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)},i("option",{value:""},t.placeholder),t?.details.map((t=>i("option",{key:t.id,value:t.id,disabled:this.canDisabled&&this.isOptionDetailOut(t),selected:t.is_selected},this.getOptionDetailName(t))))))}renderButtonStyle(t,s,a){return i("div",{class:"s-product-options-grid-mode"},this.renderOptionDetails(t,s,a,!0))}singleOption(t){return"button"===this.optionConfig?.["single-option"]?.type||t.type===d.SINGLE_OPTION&&"price"===t.format?this.renderButtonStyle("radio",t,!t.visibility_condition&&t.required):this.renderSelect(t)}multipleOptions(t){const s="button"===this.optionConfig?.["multiple-option"]?.type,a=t.required&&!t.details.some((t=>t.is_selected))&&!t.visibility_condition;return s?this.renderButtonStyle("checkbox",t,a):i("div",{class:{"s-product-options-multiple-options-wrapper":!0,required:t.required}},this.renderOptionDetails("checkbox",t,a))}radioOption(t){return this.singleOption(t)}colorOption(t){return i("fieldset",{class:"s-product-options-colors-wrapper"},t?.details.map((s=>{const a=this.isOptionDetailOut(s);return i("div",{class:{"s-product-options-colors-item":!0,"s-product-options-option-stock-out":a},key:s.id},i("input",{type:"radio",value:s.id,required:!t.visibility_condition&&t.required,checked:s.is_selected,name:this.generateInputName(t.id),disabled:this.canDisabled&&a,id:this.generateUniqueKey(`color-${this.productId}-${t.id}-${s.id}`),onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t),"data-img-id":s.option_value}),i("label",{htmlFor:this.generateUniqueKey(`color-${this.productId}-${t.id}-${s.id}`),"data-img-id":s.option_value},i("span",{style:{backgroundColor:s.color}}),i("div",{innerHTML:this.getOptionDetailName(s,!0,t.type)})))})))}thumbnailOption(t){return i("div",{class:"s-product-options-thumbnails-wrapper"},t.details.map((s=>{const a=this.isOptionDetailOut(s);return i("div",{key:s.id,class:{"s-product-options-option-stock-out":a}},i("input",{type:"radio",value:s.id,"data-itemid":s.id,required:!t.visibility_condition&&t.required,checked:s.is_selected,name:this.generateInputName(t.id),"data-img-id":s.option_value,disabled:this.canDisabled&&a,id:this.generateUniqueKey(`option_${this.productId}-${t.id}_${s.id}`),onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)}),i("label",{htmlFor:this.generateUniqueKey(`option_${this.productId}-${t.id}_${s.id}`),"data-img-id":s.option_value,class:"go-to-slide"},i("img",{"data-src":s.image,src:s.image,title:s.name,alt:s.name}),i("span",{innerHTML:h,class:"s-product-options-thumbnails-icon"}),a?[i("small",{key:`badge-${s.id}`,class:"s-product-options-thumbnails-stock-badge"},this.outOfStockText),this.canDisabled?i("div",{key:`overlay-${s.id}`,class:"s-product-options-thumbnails-badge-overlay"}):""]:""),i("p",null,this.getOptionDetailName(s,!1)," "))})))}digitalCardValuesOption(t){return i("div",{class:"s-product-options-digital-card-wrapper"},this.availableDigitalCardValues.length>0?this.availableDigitalCardValues.map((s=>{const a=String(s.id);return i("label",{htmlFor:this.generateUniqueKey(a.toString()),key:a,class:"s-product-options-digital-card-option"},i("input",{type:"radio","data-code-value":!0,class:"s-form-control s-product-options-digital-card-input",value:s.id,name:this.generateInputName(t.id),id:this.generateUniqueKey(a.toString()),required:!t.visibility_condition&&t.required,onInvalid:s=>this.invalidHandler(s,t),...this.ignoreDefaultCardValue?{}:{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===s.id}}),i("span",null,s.name," ",salla.config?.currency()?.symbol))})):i("div",{class:"s-product-options-digital-card-out-of-stock"}))}countryOption(t){return i("div",{class:"s-product-options-digital-card-wrapper"},t.details.map((s=>{const a=this.isOptionDetailOut(s);return i("label",{htmlFor:this.generateUniqueKey(s.id.toString()),key:s.id,class:{"s-product-options-digital-card-option":!0,"s-product-options-digital-card-option-stock-out":a,"s-product-options-option-stock-out":a}},i("input",{id:this.generateUniqueKey(s.id.toString()),type:"radio",class:"s-form-control s-product-options-digital-card-input",value:s.id,name:this.generateInputName(t.id),disabled:this.canDisabled&&a,required:!t.visibility_condition&&t.required,onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t),onClick:()=>{this.disableCardValue=!1},...salla.url.is_page("cart")?{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===s.id}:{}}),i("img",{loading:"lazy",alt:s.code,height:24,width:24,class:"s-product-options-country-flag",src:`https://cdn.assets.salla.network/prod/admin/cp/assets/flags/1x1/${String(s.code).toLocaleLowerCase()}.svg`,onError:t=>{t.currentTarget.onerror=null,t.currentTarget.src=salla.url.cdn("images/globe.svg")}}),i("span",null,s.name))})))}get host(){return e(this)}};function k(){o.defaults.headers.common.currency=salla?.config?.get?.("user.currency_code")}v.style="";var _={request:(t,s,i,a=null,e=null)=>(k(),o.request({url:s,data:i,method:t.toLowerCase(),responseType:"json"}).then(a).catch(e)),get:(t,s=null,i=null,a)=>(k(),o.get(t,{params:a}).then(s).catch(i)),post(t,s,i=null,a=null){return this.request("post",t,s,i,a)},put(t,s,i=null,a=null){return this.request("put",t,s,i,a)},delete(t,s,i=null,a=null){return this.request("delete",t,s,i,a)},requestWithSupportAjax(t,s,i="post"){return new Promise(((a,e)=>{if(!window?.isLegacyTheme)return this.request(i,t,s,(({data:t})=>a(t)),(({response:t})=>e(t)));k(),$.ajax({url:t,method:i.toUpperCase(),data:s,headers:{currency:o.defaults.headers.common.currency},async:!1,success:function({data:t}){return a(t)},error:function({response:t}){return e(t)}})}))}},S={options:[],header:"undefined"!=typeof navigator&&"undefined"!=typeof window?[navigator.platform,navigator.userAgent,navigator.appVersion,navigator.vendor,window.opera]:[],dataos:[{name:"Windows Phone",value:"Windows Phone",version:"OS"},{name:"Windows",value:"Win",version:"NT"},{name:"iPhone",value:"iPhone",version:"OS"},{name:"iPad",value:"iPad",version:"OS"},{name:"Kindle",value:"Silk",version:"Silk"},{name:"Android",value:"Android",version:"Android"},{name:"PlayBook",value:"PlayBook",version:"OS"},{name:"BlackBerry",value:"BlackBerry",version:"/"},{name:"Macintosh",value:"Mac",version:"OS X"},{name:"Linux",value:"Linux",version:"rv"},{name:"Palm",value:"Palm",version:"PalmOS"}],databrowser:[{name:"Chrome",value:"Chrome",version:"Chrome"},{name:"Firefox",value:"Firefox",version:"Firefox"},{name:"Safari",value:"Safari",version:"Version"},{name:"Internet Explorer",value:"MSIE",version:"MSIE"},{name:"Opera",value:"Opera",version:"Opera"},{name:"BlackBerry",value:"CLDC",version:"CLDC"},{name:"Mozilla",value:"Mozilla",version:"Mozilla"}],init:function(){var t=this.header.join(" ");return{os:this.matchItem(t,this.dataos),browser:this.matchItem(t,this.databrowser)}},matchItem:function(t,s){var i,a,e,o=0,n=0;for(o=0;o<s.length;o+=1)if(new RegExp(s[o].value,"i").test(t)){if(i=new RegExp(s[o].version+"[- /:;]([\\d._]+)","i"),e="",(a=t.match(i))&&a[1]&&(a=a[1]),a)for(a=a.split(/[._]+/),n=0;n<a.length;n+=1)e+=0===n?a[n]+".":a[n];else e="0";return{name:s[o].name,version:parseFloat(e)}}return{name:"unknown",version:0}}};async function C(t,s,i=!1){if(salla.logger.log("🍏 Pay: mutateShippingContact called",s,i),t.detail.requiredShippingContactFields&&0!=t.detail.requiredShippingContactFields.length)if(i){if(salla.config.isGuest()&&salla.config.get("store.features").includes("guest-checkout")){if(!(s.emailAddress&&s.givenName&&s.familyName&&s.phoneNumber)){salla.logger.warn("🍏 Pay: Guest contact fields are required",s);const i=[];return s.emailAddress||i.push(new window.ApplePayError("shippingContactInvalid","emailAddress","Email address is required")),s.phoneNumber||i.push(new window.ApplePayError("shippingContactInvalid","phoneNumber","Phone number is required")),s.givenName&&s.familyName||i.push(new window.ApplePayError("shippingContactInvalid","name","Name is required")),void t.session.completePayment({status:t.session.STATUS_INVALID_SHIPPING_CONTACT,errors:i})}await async function(t,s){return salla.logger.log("🍏 Pay: Updating guest contact",s),new Promise(((i,a)=>{_.post(t.detail.guestContactSelected.url.replace("{id}",t.id),{email:s.emailAddress||null,first_name:s.givenName||null,last_name:s.familyName||null,phone_number:s.phoneNumber||null,country_code:s.countryCode||null},(async({data:s})=>{"function"==typeof t.detail.guestContactSelected?.onSuccess&&t.detail.guestContactSelected.onSuccess(s),i(s)}),(({response:s})=>{salla.logger.warn("🍏 Pay: Failed to update guest contact via api",s),"function"==typeof t.detail.guestContactSelected?.onFailed&&t.detail.guestContactSelected.onFailed(s),a({response:s})}))}))}(t,s)}}else if(t.detail.requiredShippingContactFields.includes("postalAddress"))return _.post(t.detail.shippingContactSelected.url.replace("{id}",t.id),{country:s.country,city:s.locality,local:s.subLocality||s.administrativeArea||s.locality,description:s.subAdministrativeArea,street:s.addressLines?.join(", ")||s.administrativeArea,country_code:s.countryCode,postal_code:s.postalCode},(async({data:s})=>{if("function"==typeof t.detail.shippingContactSelected.onSuccess&&t.detail.shippingContactSelected.onSuccess(s),t.address_id=s.data.address_id,t.shipping_methods=s.data.shipping_methods,!t.shipping_methods||t.shipping_methods&&!t.shipping_methods.length)return salla.logger.warn("🍏 Pay: We dont found any supported methods",s),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]});try{await t.selectApplePayShippingMethod(t.shipping_methods[0])}catch(s){return salla.logger.warn("Failed set the shipping details to api",s),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}try{await t.recalculateTotal()}catch(s){return salla.logger.warn("🍏 Pay: Failed recalculate total",s),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}const i={newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),newShippingMethods:t.mappingShippingMethods(t.shipping_methods)};salla.logger.log("🍏 Pay: completeShippingContactSelection",i),t.session.completeShippingContactSelection(i)}),(({response:s})=>{salla.logger.warn("🍏 Pay: Failed add address via api",s),"function"==typeof t.detail.shippingContactSelected.onFailed&&t.detail.shippingContactSelected.onFailed(s);let i=s?.data?.error?.fields,a=function(t){return Object.entries(t).filter((([t,s])=>s&&s.length>0)).map((([t,s])=>new window.ApplePayError("shippingContactInvalid",t,s[0])))}({countryCode:i?.country_code&&i.country_code.length>0?i.country_code[0]:null,locality:i?.city&&i.city.length>0?i.city[0]:null,country:i?.country&&i.country.length>0?i.country[0]:null});0===a.length&&s?.data?.error?.message&&a.push(new window.ApplePayError("shippingContactInvalid","locality",s?.data?.error?.message)),t.session.completeShippingContactSelection({newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:a})}))}"undefined"!=typeof window&&(window.Salla=window.Salla||{},window.Salla.Payments=window.Salla.Payments||{});const P="undefined"!=typeof window?{session:null,detail:null,address_id:null,shipping_methods:[],total:void 0,request:void 0,id:void 0,countryCode:null,totals:[],shippingCompany:null,init:function(){document.removeEventListener("payments::apple-pay.start-transaction",P.startSession),Salla.event.addEventListener("payments::apple-pay.start-transaction",P.startSession)},initDefault:function(){P.detail.onError||(P.detail.onError=function(t){salla.notify.error(t)}),P.detail.authorized.onFailed||(P.detail.authorized.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse(t),P.onCancel({},t.data.error.message)}),P.detail.validateMerchant.onFailed||(P.detail.validateMerchant.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse({response:t}),P.onCancel({},t.data.error.message)}),P.detail.authorized.onSuccess||(P.detail.authorized.onSuccess=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleAfterResponseActions(t)})},prepareLineItems:function(){return P.detail?.items?.length||(P.detail.items=[{label:salla.lang.get("pages.cart.items_total"),amount:parseFloat(P.detail.amount).toString()}]),P.detail.items},prepareTotal:function(){return{label:window.location.hostname||"Salla",amount:parseFloat(P.detail.amount).toString()}},isPhysical:()=>P.detail?.requiredShippingContactFields?.includes("postalAddress"),startSession:async function(t){P.detail=t.detail||t,salla.log("🍏 Pay: payments::apple-pay.start-transaction",P.detail),P.initDefault();let s,i=P.getApplePaySessionVersion(),a=P.detail.supportedNetworks,e=Array.isArray(a)?[...a]:Object.values(a||{});e.length||(e=["masterCard","visa"]),5!==i||e.includes("mada")||e.push("mada"),P.request={countryCode:P.detail.countryCode||"SA",supportsCouponCode:!0,couponCode:"",currencyCode:P.detail.currency||"SAR",requiredShippingContactFields:P.detail.requiredShippingContactFields?P.detail.requiredShippingContactFields:[],merchantCapabilities:["supports3DS"],supportedNetworks:e,supportedCountries:P.detail.supportedCountries||["SA"],total:P.prepareTotal(),shippingContact:P.detail.shippingContact?P.detail.shippingContact:{},shippingMethods:P.detail.shippingMethods&&P.detail.shippingMethods.length?P.mappingShippingMethods(t.detail.shippingMethods):[],lineItems:P.prepareLineItems()},salla.log("🍏 Pay: init ",P.request),P.session=new ApplePaySession(i,P.request),P.session.onshippingcontactselected=P.onShippingContactSelected,P.session.onshippingmethodselected=P.onShippingMethodSelected,P.session.onvalidatemerchant=P.onValidateMerchant,P.session.onpaymentauthorized=P.onPaymentAuthorized,P.session.oncancel=P.onCancel,P.session.oncouponcodechanged=P.onCouponCodeChanged,P.session.onpaymentmethodselected=P.onPaymentMethodSelected,"function"==typeof P.detail.onStartedSession&&(s=P.detail.onStartedSession(P.session)),s||P.session.begin()},onPaymentMethodSelected:async t=>{if(salla.logger.log("🍏 Pay: onPaymentMethodSelected",t),P.isPhysical())salla.logger.log("🍏 Pay: completePaymentMethodSelection",{newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()}),P.session.completePaymentMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()});else try{await P.recalculateTotal();const t={newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()};salla.logger.log("🍏 Pay: completePaymentMethodSelection",t),P.session.completePaymentMethodSelection(t)}catch(t){salla.logger.warn("🍏 Pay: Failed recalculate total",t),P.session.completePaymentMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems(),status:P.session.STATUS_FAILURE,errors:[new window.ApplePayError("unknown",void 0,t?.response?.data?.error?.message||t?.response?.data?.error?.code||"Failed to recalculate total")]})}},onCouponCodeChanged:t=>(Salla.event.dispatch("payments::apple-pay.coupon.change",t),_.post(P.detail.onCouponCodeChanged.url.replace("{id}",P.id),{coupon:t.couponCode,payment_method:"apple_pay"},(async({data:t})=>{"function"==typeof P.detail.onCouponCodeChanged.onSuccess&&P.detail.onCouponCodeChanged.onSuccess(t),salla.log("🍏 Pay: Coupon applied success"),await P.recalculateTotal(),P.session.completeCouponCodeChange({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()})}),(async t=>{let s=t?.response;Salla.event.dispatch("payments::apple-pay.coupon.failed",s),"function"==typeof P.detail.onCouponCodeChanged.onFailed&&P.detail.onCouponCodeChanged.onFailed(s),await P.recalculateTotal(),P.session.completeCouponCodeChange({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems(),errors:[new window.ApplePayError("couponCodeInvalid")]})}))),onCancel:(t={},s=null)=>{P.detail.onError(s||salla.lang.get("pages.checkout.payment_failed")),Salla.event.createAndDispatch("payments::apple-pay.canceled",t)},onPaymentAuthorized:async t=>{salla.logger.log("🍏 Pay: onPaymentAuthorized",t.payment);try{await C(P,t.payment.shippingContact,!0)}catch(t){salla.logger.error("🍏 Pay: Failed to update guest contact details",t);const s=t?.response||t,i=s?.data?.error?.fields||{},a=[];return i?.email&&i.email.length>0&&a.push(new window.ApplePayError("shippingContactInvalid","emailAddress",i.email[0])),i?.phone&&i.phone.length>0&&a.push(new window.ApplePayError("shippingContactInvalid","phoneNumber",i.phone[0])),i?.first_name&&i.first_name.length>0?a.push(new window.ApplePayError("shippingContactInvalid","name",i.first_name[0])):i?.last_name&&i.last_name.length>0&&a.push(new window.ApplePayError("shippingContactInvalid","name",i.last_name[0])),0===a.length&&a.push(new window.ApplePayError("shippingContactInvalid","name",s?.data?.error?.message||s?.data?.error?.code||"Invalid shipping contact details")),Salla.event.dispatch("payments::apple-pay.authorized.failed",s),"function"==typeof P.detail.authorized.onFailed&&P.detail.authorized.onFailed(s),void P.session.completePayment({status:ApplePaySession.STATUS_INVALID_SHIPPING_CONTACT,errors:a})}Salla.event.dispatch("payments::apple-pay.authorized.init",t),_.post(P.detail.authorized.url.replace("{id}",P.id),{payment_method:"apple_pay",applepay_token:JSON.stringify(t.payment)},(({data:t})=>{Salla.event.dispatch("payments::apple-pay.authorized.success",t),"function"==typeof P.detail.authorized.onSuccess&&P.detail.authorized.onSuccess(t),P.session.completePayment(ApplePaySession.STATUS_SUCCESS)}),(t=>{let s=t?.response;Salla.event.dispatch("payments::apple-pay.authorized.failed",s),"function"==typeof P.detail.authorized.onFailed&&P.detail.authorized.onFailed(s),P.session.completePayment({status:ApplePaySession.STATUS_FAILURE,errors:[new window.ApplePayError("unknown",void 0,s?.data?.error?.message||s?.data?.error?.code||"Failed to parse authorized response")]})}))},onValidateMerchant:async t=>{try{Salla.event.dispatch("payments::apple-pay.validate-merchant.init",t);const{data:s}=await _.post(P.detail.validateMerchant.url.replace("{id}",P.id),{validation_url:t.validationURL});Salla.event.dispatch("payments::apple-pay.validate-merchant.success",s);const i=t=>{P.session.completeMerchantValidation(t)};if("function"==typeof P.detail.validateMerchant.onSuccess){const t=await P.detail.validateMerchant.onSuccess(s);if(t?.redirect)return window.location=t.redirect,P.abortValidateMerchant(t)}i(s.data)}catch(t){console.error(t),P.abortValidateMerchant(t?.response)}},abortValidateMerchant:(t=null)=>{P.abortSession(),Salla.event.dispatch("payments::apple-pay.validate-merchant.failed",t),"function"==typeof P.detail.validateMerchant.onFailed&&P.detail.validateMerchant.onFailed(t)},onShippingContactSelected:async t=>{salla.logger.log("🍏 Pay: onShippingContactSelected",t.shippingContact),await C(P,t.shippingContact)},onShippingMethodSelected:async t=>{let s=t.shippingMethod.identifier.split(","),i={ship_id:s[0],private_ship_id:void 0===s[1]?null:s[1],type:void 0===s[2]?null:s[2],route_id:void 0===s[3]?null:s[3]};if(salla.logger.log("🍏 Pay: onShippingMethodSelected",{event:t,previous:P.shippingCompany,current:i}),P.shouldUpdateShippingCompany(i))try{await P.selectApplePayShippingMethod(i),await P.recalculateTotal()}catch(t){return salla.logger.warn("🍏 Pay: Failed set the shipping details to api",t),void P.session.completeShippingMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems(),status:P.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}salla.logger.log("🍏 Pay: completeShippingMethodSelection",{newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()}),P.session.completeShippingMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()})},abortSession:()=>{P.session&&P.session.abort()},shouldUpdateShippingCompany:t=>P.shippingCompany?.ship_id!=t?.ship_id||P.shippingCompany?.private_ship_id!=t?.private_ship_id,getApplePaySessionVersion:()=>{if("sallapp"===(navigator.userAgent||navigator.vendor||window.opera))return 5;let t=S.init(),s=parseFloat(t.os.version);if("Macintosh"===t.os.name){if(s<10.142)return 1}else if(s<12.11)return 1;return 5},recalculateTotal:()=>(salla.logger.log("🍏 Pay: recalculate total"),_.get(P.detail.recalculateTotal.url.replace("{id}",P.id),(({data:t})=>{salla.logger.log("🍏 Pay: recalculate total success",t);let s=t.data.initial_data?.cart||t.data.cart,i=t.data.initial_data?.payments||t.data.payments;salla.logger.log("🍏 Pay: recalculate total success",{cart:s,payments:i}),null!=i?.gateways?.applePay?.amount?(P.detail.amount=i.gateways.applePay.amount,P.detail.currency=i.gateways.applePay.currency??P.detail.currency):P.detail.amount=i?.gateways?.applePay?.supportedMultiCurrency?s.total_in_customer_currency:s.total,P.detail.items=(s.totals||s.items).map((t=>({label:t.title,amount:"مجاني"===t.amount||"Free"===t.amount?0:t.amount.toString().replace("+","")}))),P.detail.items.pop(),P.totals=P.detail.items}),(t=>(salla.logger.warn("🍏 Pay: recalculate total failed",t),t?.response?.data?.message)))),selectApplePayShippingMethod:t=>{salla.logger.log("🍏 Pay: select shipping method ",t),P.shippingCompany=t;const s={address_id:P.address_id,company_id:t.ship_id,private_company_id:t.private_ship_id,type:t.type||void 0,route_id:t.route_id||void 0,payment_method:"apple_pay"};return _.post(P.detail.shippingMethodSelected.url.replace("{id}",P.id),s,(({data:t})=>("function"==typeof P.detail.shippingMethodSelected.onSuccess&&P.detail.shippingMethodSelected.onSuccess(t),!0)),(t=>{salla.logger.warn("🍏 Pay: Set shipping method failed",t),"function"==typeof P.detail.shippingMethodSelected.onFailed&&P.detail.shippingMethodSelected.onFailed(t);let s=t?.response?.data?.error;return s?.data?.fields?.address_id?s?.data?.fields?.address_id[0]:s?.data?.message}))},mappingShippingMethods:t=>t.map((t=>({label:t.shipping_title,amount:t.enable_free_shipping?0:t.ship_cost,detail:"",identifier:t.ship_id.toString()+(t.private_ship_id?","+t.private_ship_id.toString():"")+(t.type?","+t.type:"")+(t.route_id?","+t.route_id:"")})))}:{};"undefined"!=typeof window&&(window.SallaApplePay=P),"undefined"!=typeof window&&window.ApplePaySession?.canMakePayments()?P.init():"undefined"!=typeof document&&document.querySelectorAll("data-show-if-apple-pay-supported").forEach((t=>t.style.display="none"));const O=class{constructor(i){t(this,i),this.validationFailed=s(this,"validationFailed"),this.requireLogin=s(this,"requireLogin"),this.type="buy",this.productType="product",this.options={},this.collectedOrderOptions=[],this.optionsResolved=!1,this.applePayAmount=0,this.pendingApplePaySession=null,this.quickBuy=salla.lang.get("pages.products.buy_now"),this.handleApplePaySessionStarted=t=>!!salla.config.get("store.settings.order_options.mandatory",!1)&&!this.optionsResolved&&(this.optionsResolved=!0,this.pendingApplePaySession=t,async function(t){let s;try{s=await salla.api.withoutNotifier((()=>salla.product.api.getOrderOptions([{id:t.productId,quantity:t.quantity}])))}catch(s){return salla?.logger?.warn?.("order-options: fetch failed",s),void t.beginPendingSession()}const i=s?.data?.order_options||[];if(!i.length)return void t.beginPendingSession();t.discardPendingSession();const a=Number(t.amount)>0?Number(t.amount):Number(s?.data?.products?.[0]?.price?.amount)||0,e=function(){let t=document.querySelector("salla-order-options-modal");return t||(t=document.createElement("salla-order-options-modal"),document.body.appendChild(t)),t}();try{await e.open({orderOptions:i,basePrice:a,paymentMode:"apple-pay",onSubmit:t.onSubmit})}catch{}}({productId:this.productId,amount:Number(this.amount),quantity:this.getSelectedQuantity(),beginPendingSession:()=>{this.pendingApplePaySession?.begin(),this.pendingApplePaySession=null},discardPendingSession:()=>{this.pendingApplePaySession=null},onSubmit:(t,s)=>{this.collectedOrderOptions=t,this.applePayAmount=s,this.settlePayment()}}),!0),salla.lang.onLoaded((()=>{this.quickBuy=salla.lang.get("pages.products.buy_now")}))}quickBuyHandler(){if(salla.config.isGuest()&&!this.isGuestCheckout())return this.requireLogin.emit({productId:this.productId}),void salla.api.auth.requireLoginThen("salla-quick-buy::user.logged-in",(()=>this.quickBuyHandler()));this.validatePdpOptionsSync()&&(this.optionsResolved=!1,this.collectedOrderOptions=[],this.applePayAmount=0,this.settlePayment())}validatePdpOptionsSync(){return!!function(t){const s=document.querySelector(`salla-product-options[product-id="${t}"]`);if(!s)return!0;const i=s.querySelectorAll("[required]");let a=!0;return i.forEach((t=>{t.disabled||t.closest(".hidden")||"reportValidity"in t&&!t.reportValidity()&&(a=!1)})),a}(this.productId)||(this.validationFailed.emit({productId:this.productId}),salla.error(salla.lang.get("common.messages.required_fields")),!1)}getSelectedQuantity(){try{const t=this.host.getElementSallaData?.(),s=Number(t instanceof FormData?t.get("quantity"):t?.quantity);return Number.isFinite(s)&&s>0?s:1}catch{return 1}}async settlePayment(){let t=this.host.getElementSallaData();if(function(t,s){s.length&&(t&&"function"==typeof t.append?s.forEach(((s,i)=>{t.append(`order_options[${i}][id]`,String(s.id)),t.append(`order_options[${i}][value]`,String(s.value))})):t&&"object"==typeof t&&(t.order_options=s))}(t,this.collectedOrderOptions),!this.isApplePayActive)return salla.api.request("checkout/quick-purchase/"+this.productId,t,"post").then((t=>(t.data.redirect&&(window.location.href=t.data.redirect),t)));t.is_applepay=!0,"append"in t&&t.append("is_applepay",!0),salla.event.dispatch("payments::apple-pay.start-transaction",{amount:this.applePayAmount>0?this.applePayAmount:this.amount,currency:this.currency||salla.config.get("store.settings.buy_now.currency")||"SAR",requiredShippingContactFields:this.getRequiredShippingContactFields(),shippingMethods:this.isRequireShipping?[]:void 0,supportedNetworks:this.isLegacyBuyNowBE()?salla.config.get("store.settings.buy_now.networks"):Array.isArray(this.supportedNetworks)&&this.supportedNetworks.length?this.supportedNetworks:salla.config.get("store.settings.buy_now.supportedNetworks"),supportedCountries:this.isLegacyBuyNowBE()?salla.config.get("store.settings.buy_now.countries"):Array.isArray(this.supportedCountries)&&this.supportedCountries.length?this.supportedCountries:salla.config.get("store.settings.buy_now.supportedCountries"),countryCode:salla.config.get("store.store_country")||"SA",onStartedSession:this.handleApplePaySessionStarted,validateMerchant:{url:this.validateHost?`${this.validateHost}/checkout/applepay/validate`:salla.url.get("checkout/applepay/validate"),onSuccess:s=>this.applePayOnly&&!this.productId?this.cartId?(window.SallaApplePay.id=this.cartId,salla.log("🍏 Pay: create checkout success: with id #"+this.cartId),Promise.resolve(s)):(salla.logger.warn("🍏 Pay: trying to create applePay transaction without cartId/ProductId !"),Promise.resolve(s)):salla.api.request("checkout/quick-purchase/"+this.productId,"object"==typeof t?t:void 0,"post",{}).then((t=>t?.data?.redirect?(salla.log("🍏 Pay: create checkout success: redirect exits, go to checkout page"),window.location.href=t.data.redirect.url,t):t?.data?.id?(window.SallaApplePay.id=t.data.id,void salla.log("🍏 Pay: create checkout success: with id #"+window.SallaApplePay.id)):(salla.logger.warn("🍏 Pay: create checkout success: No id, or redirect"),t)))},authorized:{url:salla.url.get("checkout/{id}/payments/submit"),onFailed:t=>{window.SallaApplePay.onCancel({},t?.data?.error?.message||t?.data?.error?.code||salla.lang.get("pages.checkout.payment_failed"))},onSuccess:t=>{window.location.href=t.redirect.url,salla.log("🍏 Pay: authorized Success:: redirect to thank you page, order placed")}},shippingMethodSelected:this.isRequireShipping?{url:salla.url.get("checkout/{id}/shipping/details")}:void 0,shippingContactSelected:this.isRequireShipping?{url:salla.url.get("checkout/{id}/address/add")}:void 0,guestContactSelected:this.isGuestCheckout()?{url:salla.url.get("checkout/{id}/customer")}:void 0,onCouponCodeChanged:{url:salla.url.get("checkout/{id}/coupons")},recalculateTotal:{url:salla.url.get("checkout/{id}/payments/recalculate?payment_method=apple_pay")},onError:function(t){salla.log(t),salla.notify.error(t)}})}isGuestCheckout(){return salla.config.isGuest()&&salla.config.get("store.features").includes("guest-checkout")&&this.isPhysicalProduct()}getRequiredShippingContactFields(){let t=[];return this.isRequireShipping&&t.push("postalAddress"),this.isGuestCheckout()&&t.push("email","phone","name"),t}isLegacyBuyNowBE(){return null!=salla?.config?.get?.("store.settings.buy_now.multi_currency")}applyBaseCurrencyPrice(t){if(this.isLegacyBuyNowBE())return void(null!=t?.price&&(this.amount=t.price));const s=t?.base_currency_price;null!=s?.amount?(this.amount=s.amount,s?.currency&&(this.currency=s.currency)):null!=t?.price&&(this.amount=t.price,this.currency=salla.config.get("user.currency_code")||this.currency||"SAR")}componentWillLoad(){console.log("🍏 Pay: Quick Buy Component Loaded");const t="undefined"!=typeof window&&!!window.ApplePaySession?.canMakePayments?.(),s=salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??!0,i=salla?.config?.get?.("store.settings.is_salla_gateway",!1)??!0;this.isApplePayActive=t&&s&&i;const a=async()=>{if(this.isLegacyBuyNowBE()&&!this.currency&&salla?.config?.get&&(this.currency=salla.config.get("store.settings.buy_now.multi_currency")?salla.config.get("user.currency_code"):salla.config.get("store.settings.buy_now.currency")||"SAR"),!this.productId&&salla?.config?.get&&salla.url?.is_page&&(this.productId=salla.config.get("page.id")),this.applePayOnly||this.productId){if(this.amount&&this.isRequireShipping||!this.productId||!salla?.product?.getDetails||await salla.product.getDetails(this.productId,[]).then((t=>{this.applyBaseCurrencyPrice(t?.data),this.isRequireShipping=t?.data?.is_require_shipping||!1})).catch((t=>{salla?.logger?.warn?.("🍏 Pay: Failed load the quick buy, get the product details failed: ",t)})),"donate"===this.type&&salla?.event?.on?salla.event.on("product-options::donation-changed",(t=>{String(t.id)===String(this.productId)&&this.applyBaseCurrencyPrice(t)})):salla?.url?.is_page?.("product.single")&&salla?.product?.event?.onPriceUpdated&&salla.product.event.onPriceUpdated((t=>{this.applyBaseCurrencyPrice(t?.data)})),this.isApplePayActive=(salla?.helpers?.hasApplePay?.()??t)&&(salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??s)&&(salla?.config?.get?.("store.settings.is_salla_gateway",!1)??i),!document.getElementById("apple-pay-sdk")&&this.isApplePayActive){const t=document.createElement("script");t.src="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",t.setAttribute("id","apple-pay-sdk"),t.async=!0,document.body.appendChild(t)}}else salla?.logger?.warn?.("🍏 Pay: Failed load the quick buy, the product id is missing")};return new Promise((t=>{"function"==typeof salla?.onReady?salla.onReady((()=>a().then((()=>t(!0))))):a().then((()=>t(!0)))}))}render(){return i(a,{key:"c2ba63eb4fad49f80977d6f1adc836f655524933"},this.quickBuyButton())}quickBuyButton(){return i("apple-pay-button",{locale:salla?.config?.get?.("user.language_code")||"ar",onClick:()=>this.quickBuyHandler(),"data-quick-purchase":"applepay",class:"s-quick-buy-apple-pay","data-is-applepay":"1",buttonstyle:"black",type:this.type})}isPhysicalProduct(){return"product"===this.productType||"group_products"===this.productType||"food"===this.productType}get host(){return e(this)}};O.style=".s-quick-buy-button .s-button-text{display:flex}apple-pay-button{--apple-pay-button-width:100%;--apple-pay-button-height:40px;--apple-pay-button-border-radius:.75rem;--apple-pay-button-box-sizing:content-box}";export{m as salla_add_product_button,y as salla_bought_together,g as salla_product_availability,v as salla_product_options,O as salla_quick_buy}
|
|
4
|
+
import{r as t,c as s,h as i,H as a,a as e,e as o}from"./p-CJNSdTHZ.js";import{P as n}from"./p-DY4LZmNP.js";import{H as l}from"./p-XnA1YTjA.js";import{a as r}from"./p-CL7OPpYS.js";import{B as c}from"./p-D3mWkc-3.js";import{D as d}from"./p-CoQJOPRz.js";import{S as h}from"./p-BZp0rKEO.js";import{C as p}from"./p-C6jIkM-X.js";import"./p-CgtvEd63.js";class u{constructor(t,s){this.host=t,this.productId=s,this.collected=!1,this.livePrice=0}static attach(t,s){const i=t.querySelector("salla-mini-checkout-widget");if(!i)return!1;const a=new u(t,String(s));return salla.product?.event?.onPriceUpdated?.((t=>{a.livePrice=Number(t?.data?.price)||a.livePrice})),i.addEventListener("click",(t=>a.handleWidgetClick(t,i)),!0),!0}getSelectedQuantity(){try{const t=document.querySelector("form.product-form"),s=t?.getElementSallaData?.(),i=Number(s instanceof FormData?s.get("quantity"):s?.quantity);if(Number.isFinite(i)&&i>0)return i}catch{}return Number(this.host.getAttribute("quantity"))||1}async handleWidgetClick(t,s){if(this.collected)return void(this.collected=!1);if(t.preventDefault(),t.stopImmediatePropagation(),!await this.validatePdpOptions())return;if(salla.config.isGuest())return void salla.api.auth.requireLoginThen("salla-add-product-button::oo.after-login",(()=>this.handleWidgetClick(t,s)));let i;s.classList.add("s-add-product-button-busy");try{i=await salla.api.withoutNotifier((()=>salla.product.api.getOrderOptions([{id:this.productId,quantity:this.getSelectedQuantity()}])))}catch(t){return salla?.logger?.warn?.("order-options: fetch failed",t),s.classList.remove("s-add-product-button-busy"),void this.resumeWidget(s)}s.classList.remove("s-add-product-button-busy");const a=i?.data?.order_options||[];if(!a.length)return void this.resumeWidget(s);const e=this.livePrice>0?this.livePrice:Number(i?.data?.products?.[0]?.price?.amount)||0,o=this.ensureModal();try{const t=await o.open({orderOptions:a,basePrice:e});this.injectIntoMini(t?.orderOptions||[]),this.resumeWidget(s)}catch{}}async validatePdpOptions(){const t=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);return!t||("function"==typeof t.validateAndScroll?await t.validateAndScroll():"function"!=typeof t.reportValidity||await t.reportValidity())}injectIntoMini(t){if(!t.length)return;const s=this.productId,i=a=>{if(String(a?.id)===String(s))try{a?.payload?.set?.("order_options",t)}finally{salla.event.off("cart::before.add.item",i)}};salla.event.on("cart::before.add.item",i)}ensureModal(){let t=document.querySelector("salla-order-options-modal");return t||(t=document.createElement("salla-order-options-modal"),document.body.appendChild(t)),t}resumeWidget(t){this.collected=!0;const s=t.shadowRoot?.querySelector?.(".s-fast-checkout-button");s?s.click():"function"==typeof t.click&&t.click()}}const m=class{constructor(i){t(this,i),this.success=s(this,"success"),this.failed=s(this,"failed"),this.hostAttributes={},this.hasPreOrder=!1,this.productStatus="sale",this.productType="product",this.selectedOptions=[],this.buyNowText=salla.lang.get("pages.products.buy_now"),this.isDesktopViewport="undefined"==typeof window||window.matchMedia("(min-width: 768px)").matches,this.viewportMediaQuery=null,this.orderOptionsGateAttached=!1,this.onViewportChange=t=>{this.isDesktopViewport=t.matches,this.btn?.setText(t.matches&&this.passedLabel?this.passedLabel:this.getLabel())},salla.lang.onLoaded((()=>{this.buyNowText=salla.lang.get("pages.products.buy_now")}))}getLabel(){return"sale"===this.productStatus&&this.supportStickyBar&&!this.isDesktopViewport&&this.showQuickBuy&&this.isApplePayActive?n:this.hasPreOrder?salla.lang.get("pages.products.pre_order_now"):"sale"===this.productStatus&&"booking"===this.productType?salla.lang.get("pages.cart.book_now"):"sale"===this.productStatus?salla.lang.get("pages.cart.add_to_cart"):"donating"!==this.productType?salla.lang.get("pages.products.out_of_stock"):salla.lang.get("pages.products.donation_exceed")}addProductToCart(t){if("booking"===this.productType)return t.preventDefault(),this.addBookingProduct();if("submit"===this.hostAttributes.type)return!1;t.preventDefault(),this.btn?.disable();const s=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);return s&&"function"==typeof s.validateAndScroll?s.validateAndScroll().then((async t=>{const s={isValid:t,component:this};if(await salla.hooks.call("salla-add-product-button","validate",s),s.isValid)return this._proceedAddToCart();this.btn?.enable()})).catch((()=>{this.btn?.enable()})):this._proceedAddToCart()}async _proceedAddToCart(){const t=this.host.closest("salla-products-list, salla-products-slider")??this.host.closest("salla-product-card, custom-salla-product-card"),s=Object.entries({id:this.productId,donation_amount:this.donatingAmount,quantity:this.quantity,endpoint:"quickAdd",source:l.getProductsSource(t?.getAttribute("source"))}).reduce(((t,[s,i])=>i?(t[s]=i,t):t),{});return salla.cart.addItem(s).then((async t=>(this.selectedOptions=[],this.btn?.enable(),this.success.emit(t),t))).catch((t=>{this.failed.emit(t),this.btn?.enable()}))}addBookingProduct(){return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("booking::add",this.productId),void salla.event.dispatch("login::open")):salla.booking.add(this.productId).then((t=>this.success.emit(t))).catch((t=>this.failed.emit(t)))}getBtnAttributes(){for(let t=0;t<this.host.attributes.length;t++)["id","class"].includes(this.host.attributes[t].name)||(this.hostAttributes[this.host.attributes[t].name]=this.host.attributes[t].value);return this.hostAttributes}get notifyChannels(){return this.channels||salla.api.product.getAvailabilityChannels?.()||l.availabilityChannels()}getQuickBuyBtnAttributes(){return{...this.getBtnAttributes(),type:this.supportStickyBar&&!this.isDesktopViewport?"plain":"donating"==this.productType?"donate":"buy"}}miniCheckoutWidget(){let t=salla.config.get("store.id");if(t)return i("salla-mini-checkout-widget",{language:salla.lang.locale,"store-id":t,config:{user:salla.config.get("user"),failure_url:window.location.href},products:[this.productId],api:salla.config.get("store.api"),outline:!0,"form-selector":"form.product-form",class:"s-add-product-button-mini-checkout"},i("div",{slot:"widget-label",class:"s-add-product-button-mini-checkout-content"},i("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>full-wallet</title>\n<path d="M29 12h-26c-0.668-0.008-1.284-0.226-1.787-0.59l0.009 0.006c-0.744-0.552-1.222-1.428-1.222-2.416 0-1.657 1.343-3 2.999-3h6c0.552 0 1 0.448 1 1s-0.448 1-1 1v0h-6c-0.552 0-1 0.448-1 1 0 0.326 0.156 0.616 0.397 0.798l0.002 0.002c0.167 0.12 0.374 0.194 0.599 0.2l0.001 0h26c0.552 0 1 0.448 1 1s-0.448 1-1 1v0zM27 12c-0.552 0-1-0.448-1-1v0-3h-3c-0.552 0-1-0.448-1-1s0.448-1 1-1v0h4c0.552 0 1 0.448 1 1v0 4c0 0.552-0.448 1-1 1v0zM29 30h-26c-1.657 0-3-1.343-3-3v0-18c0-0.552 0.448-1 1-1s1 0.448 1 1v0 18c0 0.552 0.448 1 1 1v0h25v-5c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM29 18c-0.552 0-1-0.448-1-1v0-6c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM31 24h-7c-2.209 0-4-1.791-4-4s1.791-4 4-4v0h7c0.552 0 1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM24 18c-1.105 0-2 0.895-2 2s0.895 2 2 2v0h6v-4zM25 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-2.306 1.152c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 3.2-1.6c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1v0zM21 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-15.104 7.552c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 16-8c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1-0.001 0-0.001 0-0.002 0h0z"></path>\n</svg>\n'}),this.buyNowText))}componentWillLoad(){return salla.onReady().then((()=>{if(document.documentElement.classList.add("hydrated"),this.showQuickBuy=this.quickBuy&&salla.config.get("store.settings.buy_now")&&"sale"==this.productStatus&&"booking"!==this.productType,this.isApplePayActive=window.ApplePaySession?.canMakePayments()&&salla.config.get("store.settings.payments")?.includes("apple_pay")&&salla.config.get("store.settings.is_salla_gateway",!1),this.passedLabel=this.host.innerHTML.replace("\x3c!----\x3e","").trim(),this.passedLabel&&this.isDesktopViewport)return this.btn?.setText(this.passedLabel);"submit"===this.host.getAttribute("type")&&this.supportStickyBar&&(this.viewportMediaQuery=window.matchMedia("(min-width: 768px)"),this.viewportMediaQuery.addEventListener("change",this.onViewportChange))}))}render(){return this.host.closest(".swiper-slide")?.classList.contains("swiper-slide-duplicate")?"":this.hasSubscribedOptions?i(a,null,i("salla-product-availability",{...this.getBtnAttributes(),"is-subscribed":!0},i("span",{class:"s-hidden"},i("slot",null)))):"out-and-notify"===this.productStatus&&this.notifyChannels||this.hasOutOfStockOption?i(a,null,i("salla-product-availability",{...this.getBtnAttributes()},i("span",{class:"s-hidden"},i("slot",null)))):i(a,{class:{"s-add-product-button-with-quick-buy":this.showQuickBuy,"s-add-product-button-with-sticky-bar":this.supportStickyBar,"s-add-product-button-with-apple-pay":this.showQuickBuy&&this.isApplePayActive}},i("div",{class:{"s-add-product-button-main":this.showQuickBuy,"w-full":!document.getElementById("fast-checkout-js")||["financial_support","donating"].includes(this.productType)}},i("salla-button",{color:"sale"===this.productStatus?"primary":"light",type:"button",fill:"sale"===this.productStatus?"solid":"outline",ref:t=>this.btn=t,onClick:t=>this.addProductToCart(t),disabled:"sale"!==this.productStatus,...this.getBtnAttributes(),"loader-position":"center"},i("slot",null)),this.showQuickBuy&&document.getElementById("fast-checkout-js")&&!["financial_support","donating"].includes(this.productType)?this.miniCheckoutWidget():""),this.showQuickBuy&&this.isApplePayActive?i("salla-quick-buy",{...this.getQuickBuyBtnAttributes()}):"")}async componentDidLoad(){await Salla.hooks.registerComponent("salla-add-product-button",this),this.notifyOptionsAvailability&&salla.event.on("product-options::change",(async t=>{if(!["thumbnail","color","single-option"].includes(t.option.type))return;this.hasSubscribedOptions=!1,this.selectedOptions=await(document.querySelector(`salla-product-options[product-id="${this.productId}"]`)?.getSelectedOptions()),this.hasOutOfStockOption=await(document.querySelector(`salla-product-options[product-id="${this.productId}"]`)?.hasOutOfStockOption());let s=salla.storage.get(`product-${this.productId}-subscribed-options`);if((s||this.subscribedOptions)&&this.hasOutOfStockOption)if(salla.config.isGuest()){const t=s?s.map((t=>t.split(",").map((t=>parseInt(t))))):[];this.hasSubscribedOptions=t.length>0&&t.some((t=>t.every((t=>this.selectedOptions.some((s=>s.id===t))))))}else this.hasSubscribedOptions=!(!this.subscribedOptions||"null"===this.subscribedOptions||"[]"===this.subscribedOptions)&&JSON.parse(this.subscribedOptions).some((t=>t.every((t=>this.selectedOptions.some((s=>s.id===t))))))}))}componentDidRender(){!this.orderOptionsGateAttached&&this.productId&&salla.config.get("store.settings.order_options.mandatory",!1)&&u.attach(this.host,this.productId)&&(this.orderOptionsGateAttached=!0),!this.passedLabel||this.supportStickyBar&&!this.isDesktopViewport?(this.btn?.setText(this.getLabel()),salla.lang.onLoaded((()=>this.btn?.setText(this.getLabel())))):this.btn?.setText(this.passedLabel)}disconnectedCallback(){this.viewportMediaQuery?.removeEventListener("change",this.onViewportChange)}get host(){return e(this)}};m.style=":host{display:block}salla-add-product-button[width=wide]{width:100%}";const y=class{constructor(s){t(this,s),this.limit=3,this.recommendations=[],this.selectedIds=new Set,this.isLoading=!0,this.canRender=!0,this.isAdding=!1,this.title=salla.lang.get("pages.products.bought_together_title"),this.subtitle=salla.lang.get("pages.products.bought_together_subtitle"),this.buyTogetherFor=salla.lang.get("pages.products.buy_together_for"),this.resolvedProductId=0,this.listViewTracked=!1,salla.lang.onLoaded((()=>{this.title=salla.lang.get("pages.products.bought_together_title"),this.subtitle=salla.lang.get("pages.products.bought_together_subtitle"),this.buyTogetherFor=salla.lang.get("pages.products.buy_together_for")}))}componentWillLoad(){salla.onReady().then((()=>{if(!salla.config.get("store.settings.product.bought_together"))return void(this.canRender=!1);const t=salla.config.get("page.id");if(t)return this.resolvedProductId=t,r(String(t));this.canRender=!1})).then((t=>{if(!t?.length)return void(this.canRender=!1);const s=[String(this.resolvedProductId),...t.slice(0,this.limit)];return salla.product.fetch({source:"selected",source_value:s})})).then((t=>{if(!t)return;const s=t?.data??[];if(!s.length)return void(this.canRender=!1);const i=s.find((t=>String(t.id)===String(this.resolvedProductId))),a=s.filter((t=>String(t.id)!==String(this.resolvedProductId)));a.length?(this.recommendations=i?[i,...a]:a,this.selectedIds=new Set(this.recommendations.map((t=>t.id)))):this.canRender=!1})).catch((()=>{this.canRender=!1})).finally((()=>{this.isLoading=!1}))}componentDidRender(){!this.recommendations.length||this.listViewTracked||this.intersectionObserver||(this.intersectionObserver=new IntersectionObserver((t=>{t.some((t=>t.isIntersecting))&&(this.listViewTracked=!0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.emitListViewed())}),{threshold:.1}),this.intersectionObserver.observe(this.el))}disconnectedCallback(){this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0}emitListViewed(){const t=this.recommendations.filter((t=>!this.isMainProduct(t.id)));salla.event.emit("salla-bought-together::list.viewed",{products:t})}isMainProduct(t){return String(t)===String(this.resolvedProductId)}recommendedPosition(t){const s=this.recommendations.filter((t=>!this.isMainProduct(t.id))).findIndex((s=>String(s.id)===String(t)));return-1===s?-1:s+1}emitProductClicked(t,s){salla.event.emit("salla-bought-together::product.clicked",[{product:t,position:s}])}toggleProduct(t){const s=new Set(this.selectedIds);s.has(t)?s.delete(t):s.add(t),this.selectedIds=s}get totalPrice(){const t=this.recommendations.filter((t=>this.selectedIds.has(t.id))).reduce(((t,s)=>t+(s.price??0)),0),s=salla.config.get("store.currency.decimals")??2,i=Math.pow(10,s);return salla.money(Math.round(t*i)/i)}async addSelectedToCart(){if(this.isAdding||!this.selectedIds.size)return;this.isAdding=!0;let t=!1;try{for(const s of Array.from(this.selectedIds))try{salla.cart?.api&&(salla.cart.api.addToCartSource="pdp_fbt");const t=await salla.cart.addItem({id:s,endpoint:"quickAdd",source:"pdp_fbt"}),i=this.recommendations.find((t=>t.id===s));if(i){const a=this.isMainProduct(s)?0:this.recommendedPosition(s),e=t?.data?.items?.find((t=>String(t.product_id)===String(i.id)))??t?.data?.items?.slice(-1)[0];salla.event.emit("salla-bought-together::product.added",[{product:i,position:a,cartItem:e,cartId:t?.data?.id}])}}catch(s){salla.log(s),t=!0}t&&salla.error(salla.lang.get("common.messages.error"))}finally{this.isAdding=!1}}getSkeletonView(){return i(a,{class:"s-bought-together-entry"},i("div",{class:"s-bought-together-skeleton"},i("div",{class:"s-bought-together-skeleton-header"},i("salla-skeleton",{height:"16px",width:"35%"}),i("salla-skeleton",{height:"10px",width:"60%"})),Array(4).fill(null).map(((t,s)=>i("div",{key:s,class:"s-bought-together-skeleton-item"},i("salla-skeleton",{height:"22px",width:"22px"}),i("salla-skeleton",{height:"48px",width:"48px"}),i("div",{class:"s-bought-together-skeleton-info"},i("salla-skeleton",{height:"12px",width:"55%",style:{marginBottom:"3px"}}),i("salla-skeleton",{height:"10px",width:"25%"}))))),i("salla-skeleton",{height:"44px",width:"100%"})))}render(){return this.canRender?this.isLoading?this.getSkeletonView():this.recommendations.length?i(a,{class:"s-bought-together-entry"},i("div",{class:"s-bought-together-header"},i("h3",{class:"s-bought-together-title"},this.title),i("p",{class:"s-bought-together-subtitle"},this.subtitle)),i("div",{class:"s-bought-together-list"},this.recommendations.map((t=>i("div",{key:t.id,class:"s-bought-together-item"+(this.selectedIds.has(t.id)?"":" s-bought-together-item--unchecked")},i("label",{class:"s-bought-together-checkbox-label"},i("input",{type:"checkbox",class:"s-bought-together-checkbox",checked:this.selectedIds.has(t.id),onChange:()=>this.toggleProduct(t.id)}),i("span",{class:"s-bought-together-checkmark"})),i("a",{class:"s-bought-together-item-link",href:t.url,onClick:()=>!this.isMainProduct(t.id)&&this.emitProductClicked(t,this.recommendedPosition(t.id))},i("img",{class:"s-bought-together-item-img",src:t.image?.url||salla.url.cdn("images/s-empty.png"),alt:t.image?.alt||t.name,loading:"lazy",decoding:"async",onError:t=>{t.currentTarget.onerror=null,t.currentTarget.src=salla.url.cdn("images/s-empty.png")}}),i("span",{class:"s-bought-together-item-name"},t.name)),i("span",{class:"s-bought-together-item-price",innerHTML:null!=t.price?salla.money(t.price):""}))))),i("salla-button",{class:"s-bought-together-btn",disabled:!this.selectedIds.size||this.isAdding,loading:this.isAdding,onClick:()=>this.addSelectedToCart()},i("span",{innerHTML:`${this.buyTogetherFor} ${this.totalPrice}`}))):null:null}get el(){return e(this)}};y.style=':host{display:block}.s-bought-together-checkbox:checked~.s-bought-together-checkmark{background-color:var(--color-primary, #2ECC71);border-color:var(--color-primary, #2ECC71)}.s-bought-together-checkbox:checked~.s-bought-together-checkmark::after{content:"";display:block;width:5px;height:9px;border:solid #fff;border-width:0 2px 2px 0;transform:rotate(45deg);margin-top:-2px}';const g=class{constructor(s){t(this,s),this.isUser=salla.config.isUser(),this.translationLoaded=!1,this.notifyOptionsAvailability=!1,this.isSubscribed=!1,this.handleSubmitOptions=async()=>{let t={id:this.productId};if(!this.notifyOptionsAvailability)return t;let s=document.querySelector(`salla-product-options[product-id="${this.productId}"]`),i=Object.values(await(s?.getSelectedOptionsData())||{});if(i.length&&!await(s?.reportValidity())){let t=salla.lang.get("common.messages.required_fields");throw salla.error(t),t}return t.options=[],i.forEach((s=>{s&&!isNaN(s)&&t.options.push(Number(s))})),t},this.typing=t=>{const s=t.target.nextElementSibling;t.target.classList.remove("s-has-error"),s?.classList.contains("s-product-availability-error-msg")&&(s.innerText=""),13===t.keyCode&&this.submit()},salla.lang.onLoaded((()=>{this.translationLoaded=!0,this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.modal?.setTitle(this.title_)})),this.productId||(this.productId=salla.config.get("page.id")),this.isUser||(this.channelsWatcher(this.channels),this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.host.removeAttribute("title"))}channelsWatcher(t){let s=t||salla.api.product.getAvailabilityChannels?.()||l.availabilityChannels();this.channels_=s?s.split(","):[]}get isSubscribedToProduct(){return this.isSubscribed||!this.notifyOptionsAvailability&&(!!salla.api.product.isSubscribedToAvailability?.(this.productId)||!!salla.storage.get(`product-${this.productId}-subscribed`))}openModel(){this.handleSubmitOptions().then((t=>t?this.modal.open():null))}async submit(){let t=await this.handleSubmitOptions();if(this.isUser)return salla.api.product.availabilitySubscribe(t).then((()=>this.isSubscribed=!0));if(this.channels_.includes("sms")||this.channels_.includes("whatsapp")){let{phone:s,countryCode:i}=await this.mobileInput.getValues();t.country_code=i,t.phone=s}return this.channels_.includes("email")&&""!==this.email.value&&(t.email=this.email.value),await this.validateform(),this.btn.load().then((()=>this.btn.disable())).then((()=>salla.api.product.availabilitySubscribe(t))).then((()=>{if(this.notifyOptionsAvailability){if(t.options.length){let s=salla.storage.get(`product-${this.productId}-subscribed-options`)||[],i=t.options.join(",");s.includes(i)?salla.log("already subscribed to this options"):(s.push(i),salla.storage.set(`product-${this.productId}-subscribed-options`,s),this.isSubscribed=!0)}}else this.isSubscribed=!0})).then((()=>this.btn.stop())).then((()=>this.modal.close())).catch((()=>this.btn.stop()&&this.btn.enable()))}async validateform(){try{if(this.channels_.includes("email")){const t=l.isValidEmail(this.email.value);if(t)return;!t&&this.validateField(this.email,salla.lang.get("common.elements.email_is_valid"))}if((this.channels_.includes("sms")||this.channels_.includes("whatsapp"))&&await this.mobileInput.isValid())return}catch(t){throw"Please insert required fields"}}validateField(t,s){t.classList.add("s-has-error"),t.nextElementSibling.innerText="* "+s}render(){return i(a,{key:"ccb098126e7809a6386ff38c74dfa0f00f64deeb",class:"s-product-availability-wrap"},this.isSubscribedToProduct?i("div",{class:"s-product-availability-subscribed"},i("span",{innerHTML:c,class:"s-product-availability-subs-icon"}),salla.lang.get("pages.products.notify_availability_success")):i("salla-button",{width:"wide",onClick:()=>this.isUser?this.submit():this.openModel()},salla.lang.get("pages.products.notify_availability")),this.isUser||this.isSubscribedToProduct?"":this.renderModal())}renderModal(){return i("salla-modal",{ref:t=>this.modal=t,"modal-title":this.title_,subTitle:salla.lang.get("pages.products.notify_availability_subtitle"),width:"sm"},i("span",{slot:"icon",class:"s-product-availability-header-icon",innerHTML:c}),i("div",{class:"s-product-availability-body"},this.channels_.includes("email")?[i("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.email")),i("input",{class:"s-product-availability-input",onKeyDown:t=>this.typing(t),placeholder:salla.lang.get("common.elements.email_placeholder")||"your@email.com",ref:t=>this.email=t,type:"email"}),i("span",{class:"s-product-availability-error-msg"})]:"",this.channels_.includes("sms")||this.channels_.includes("whatsapp")?[i("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.mobile")),i("salla-tel-input",{ref:t=>this.mobileInput=t,onKeyDown:t=>this.typing(t)})]:""),i("div",{slot:"footer",class:"s-product-availability-footer"},i("salla-button",{class:"modal-cancel-btn",width:"wide",color:"light",fill:"outline",onClick:()=>this.modal.close()},salla.lang.get("common.elements.cancel")),i("salla-button",{class:"submit-btn","loader-position":"center",width:"wide",ref:t=>this.btn=t,onClick:()=>this.submit()},salla.lang.get("common.elements.submit"))))}get host(){return e(this)}static get watchers(){return{channels:["channelsWatcher"]}}};var f,b,w;g.style="",function(t){t[t.INIT=1]="INIT",t[t.IDLE=2]="IDLE",t[t.PROCESSING_QUEUED=9]="PROCESSING_QUEUED",t[t.PROCESSING=3]="PROCESSING",t[t.PROCESSING_COMPLETE=5]="PROCESSING_COMPLETE",t[t.PROCESSING_ERROR=6]="PROCESSING_ERROR",t[t.PROCESSING_REVERT_ERROR=10]="PROCESSING_REVERT_ERROR",t[t.LOADING=7]="LOADING",t[t.LOAD_ERROR=8]="LOAD_ERROR"}(f||(f={})),function(t){t[t.EMPTY=0]="EMPTY",t[t.IDLE=1]="IDLE",t[t.ERROR=2]="ERROR",t[t.BUSY=3]="BUSY",t[t.READY=4]="READY"}(b||(b={})),function(t){t[t.INPUT=1]="INPUT",t[t.LIMBO=2]="LIMBO",t[t.LOCAL=3]="LOCAL"}(w||(w={}));const v=class{constructor(a){if(t(this,a),this.changed=s(this,"changed"),this.fileTypes={pdf:"application/pdf",png:"image/png",jpg:"image/jpeg",word:"application/doc,application/ms-doc,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",exl:"application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",txt:"text/plain"},this.outOfStockText="",this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.selectDonationAmount=salla.lang.getWithDefault("pages.products.select_donation_amount","تحديد مبلغ التبرع"),this.selectAmount=salla.lang.getWithDefault("pages.products.select_amount","اختر المبلغ"),this.isCustomDonation=!1,this.selectedOptions=[],this.canDisabled=!1,this.disableCardValue=!0,this.availableDigitalCardValues=[],this.userInitiatedValidation=!1,this.isCartMode=!1,this.availabilityMap={},this.productAvailable=!1,this.outSkus=[],this.ignoreDefaultCardValue=!1,this.productId=salla.config.get("page.id"),this.noPadding=!1,this.handleDonationOptions=(t,s,i)=>{if("custom"===s&&"input"===i){const s=t.target;return salla.helpers.inputDigitsOnly(s),salla.event.emit("product-options::donation-changed",{id:this.productId,price:s.value}),void s.dispatchEvent(new window.Event("change",{bubbles:!0}))}const a="option"===i?String(t.target?.value??""):"";if("option"===i&&"custom"===s&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()),this.isCustomDonation="custom"===a,this.donationInput){if("custom"===a?(this.donationInput.value="",this.donationInput.focus()):this.donationInput.value=a,"custom"===s)return;salla.event.emit("product-options::donation-changed",{id:this.productId,price:a})}},this.hideLabel=t=>!(t.type!==d.DONATION||!t.donation||t.donation.can_donate),this.getExpireDonationMessage=t=>{if(!t.donation)return;const s=t.donation.target_amount<=t.donation.collected_amount;return i("div",{class:{"s-product-options-donation-message":!0,"s-product-options-donation-completed":s,"s-product-options-donation-expired":!s}},i("p",null,t.donation.target_message),i("span",{innerHTML:s?salla.money(t.donation.target_amount):""}))},salla.lang.onLoaded((()=>{this.outOfStockText=salla.lang.get("pages.products.out_of_stock"),this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.selectDonationAmount=salla.lang.getWithDefault("pages.products.select_donation_amount","تحديد مبلغ التبرع"),this.selectAmount=salla.lang.getWithDefault("pages.products.select_amount","اختر المبلغ")})),this.options)try{return void this.setOptionsData(Array.isArray(this.options)?this.options:JSON.parse(this.options))}catch(t){salla.log("Bad json passed via options prop")}Array.isArray(this.optionsData)||(salla.log("Options is not an array[] ---\x3e ",this.optionsData),this.setOptionsData([])),this.productId&&!salla.url.is_page("cart")&&salla.api.product.getDetails(this.productId,["options"]).then((t=>{this.productAvailable=!t.data.is_out_of_stock,this.setOptionsData(t.data.options)}))}async setOptionsData(t){this.optionsData=t,this.outSkus=[],this.optionsData[0]?.details?.forEach((t=>{Object.entries(t.skus_availability||{}).filter((([,t])=>!t)).forEach((([t])=>this.outSkus.push(Number(t))))})),this.fillSelectedOptions(),this.computeAvailability()}async getOptionsData(){return this.optionsData}async getSelectedOptionsData(){const t={},s=this.host.getElementSallaData(),i=void 0!==this.bundleContext?this.bundleContext:null;return s.forEach(((s,a)=>{if(i){if(a.startsWith("bundle[")&&a.includes("[options][")){const i=a.split("[options][")[1].replace("]","");t[i]=s}}else a.startsWith("options[")&&(t[a.replace("options[","").replace("]","")]=s)})),t}async reportValidity(){const t=this.host.querySelectorAll("[required]");let s=!0;for(let i=0;i<t.length;i++){const a=t[i];a.disabled||a.closest(".hidden")||"reportValidity"in a&&!a.reportValidity()&&(s=!1)}return s}async hasOutOfStockOption(){return this.selectedOptions.some((t=>t.is_out))||this.selectedSkus?.length&&this.selectedSkus?.every((t=>this.outSkus.includes(t)))}async getSelectedOptions(){return this.selectedOptions}async getOption(t){return this.optionsData.find((s=>s.id===t))}invalidHandler(t,s){const i=t.target.closest(".s-product-options-option");i.classList.contains("s-product-options-option-error")||i.classList.add("s-product-options-option-error"),!this.userInitiatedValidation&&!salla.helpers.isIOSDevice()||salla.url.is_page("cart")||this.host.querySelector(".s-product-options-option-error")===i&&this.scrollToElement(i)}scrollToElement(t){t&&t.scrollIntoView({behavior:"smooth",block:"center"})}changedHandler(t,s,i=!0){const a={event:t,option:s,detail:null,productId:this.productId};if(s.details){const i=s.details.find((s=>Number(s.id)===Number(t.target.value)));a.detail=i}"country"===s.type&&this.handleCountryOptionChange(t,a.detail);const e=t.target.closest(".s-product-options-option");(t.target.value||(s.type===d.FILE||s.type===d.IMAGE)&&"added"===t.type||s.type===d.MAP&&"selected"===t.type&&t.target.lat&&t.target.lng)&&setTimeout((()=>{e.classList.remove("s-product-options-option-error")}),200),s.type===d.DONATION&&salla.event.emit("product-options::donation-changed",{id:this.productId,price:t.target.value}),this.setSelectedSkus(),this.handleRequiredMultipleOptions(s);const o=this.selectedOptions.findIndex((t=>t.option_id===a.option.id));if(a.option.type===d.MULTIPLE_OPTIONS){const t=this.selectedOptions.findIndex((t=>t.option_id===a.option.id&&t?.id===a.detail?.id));t>-1?this.selectedOptions.splice(t,1):this.selectedOptions.push({...a.detail,option_id:a.option.id})}else a.detail&&0!==Object.keys(a.detail).length?o>-1?this.selectedOptions[o]={...a.detail,option_id:a.option.id}:this.selectedOptions.push({...a.detail,option_id:a.option.id}):o>-1&&this.selectedOptions.splice(o,1);this.optionsData=this.optionsData.map((t=>t.id===a.option.id?{...t,details:t.details.map((t=>({...t,is_selected:a.option.type===d.MULTIPLE_OPTIONS?this.selectedOptions.some((s=>s.id===t.id)):Number(t.id)===Number(a.detail?.id),value:a.detail?.value})))}:t)),this.pruneInvisibleConditionalSelections(),this.setSelectedSkus(),requestAnimationFrame((()=>{this.optionsData?.filter((t=>t.type===d.MULTIPLE_OPTIONS&&t.required)).forEach((t=>this.handleRequiredMultipleOptions(t)))})),i&&(this.changed.emit(a),salla.event.emit("product-options::change",a))}setSelectedSkus(){this.selectedSkus=this.selectedOptions.map((t=>Object.keys(t.skus_availability||{}))).reduce(((t,s)=>t.filter((t=>s.includes(t)))),[]).map((t=>Number(t))),this.computeAvailability()}handleRequiredMultipleOptions(t){if(t.type!==d.MULTIPLE_OPTIONS||!t.required)return;const s=this.host.querySelector(`[data-option-id="${t.id}"]`);if(!s)return;const i=s.querySelectorAll("input:checked").length;s.querySelectorAll("input").forEach((t=>t.toggleAttribute("required",!i)))}pruneInvisibleConditionalSelections(){const t=Math.max(1,this.optionsData.length);for(let s=0;s<t;s++){let t=!1;for(const s of this.optionsData){const i=s.visibility_condition;if(!i)continue;const a=this.selectedOptions.filter((t=>t.option_id===i.option)).map((t=>String(t.id))).includes(String(i.value));("="===i.operator?a:!a)||this.clearStaleOption(s.id)&&(t=!0)}if(!t)break}}clearStaleOption(t){const s=this.optionsData.find((s=>s.id===t));if(!s)return!1;const i=this.selectedOptions.length;this.selectedOptions=this.selectedOptions.filter((s=>s.option_id!==t));const a=this.selectedOptions.length!==i,e=null!=s.value&&String(s.value).length>0,o=s.details?.some((t=>t.is_selected))??!1;return!!(a||e||o)&&(this.optionsData=this.optionsData.map((s=>s.id!==t?s:{...s,value:void 0,details:s.details?.map((t=>({...t,is_selected:!1})))??s.details})),!0)}getLatLng(t,s){return t?t.split(",")["lat"===s?0:1]:""}getDisplayForType(t){return this[`${t.type}Option`]?this[`${t.type}Option`](t):t.type===d.COLOR_PICKER?this.colorPickerOption(t):t.type===d.MULTIPLE_OPTIONS?this.multipleOptions(t):t.type===d.SINGLE_OPTION?this.singleOption(t):t.type===d.RADIO?this.radioOption(t):t.type===d.DIGITAL_CARD_VALUE?this.digitalCardValuesOption(t):t.type===d.COUNTRY?this.countryOption(t):t.type===d.BOOKING&&salla.url.is_page("cart")?i("salla-booking-field",{onInvalidInput:s=>this.invalidHandler(s,t),option:t,productId:t.value}):(salla.log(`Couldn't find options type(${t.type})😢`),"")}getOptionShownWhen(t){return t.visibility_condition?{"data-show-when":`options[${t.visibility_condition.option}] ${t.visibility_condition.operator} ${t.visibility_condition.value}`}:{}}getAvailableDigitalCardSKUs(t){const s=this.optionsData.find((({type:t})=>"digital-code-value"===t));if(!s)throw new Error("product-options:: No digital card options found");const i=Object.keys(t.skus_availability).filter((s=>!1===t.skus_availability[s]));this.availableDigitalCardValues=s.details.filter((t=>!Object.keys(t.skus_availability).filter((t=>i.includes(t))).length))}handleCountryOptionChange(t,s){t.stopImmediatePropagation(),this.ignoreDefaultCardValue=!0;const i=this.host.querySelector("input[data-code-value]:checked");if(i&&(i.checked=!1),!this.optionsData.find((({type:t})=>"digital-code-value"===t)))throw new Error("product-options:: No digital card options found");this.getAvailableDigitalCardSKUs(s)}getSelectedDigitalCardOptions(t){const s=t.details.find((t=>t.is_selected)),i=t.details.find((t=>!!t.is_default))||t.details[0];if(["digital-code-value","country"].includes(t.type))return s||i}async componentWillLoad(){if(salla.url.is_page("cart")&&(this.disableCardValue=!1,this.fillSelectedOptions()),this.config)try{this.optionConfig="string"==typeof this.config?JSON.parse(this.config):this.config}catch(t){console.error("Failed to parse JSON in config prop:",t)}if(this.optionsData.filter((({type:t})=>["country","digital-card-value"].includes(t))).length>0&&salla.url.is_page("cart")){const t=this.optionsData.find((t=>"country"===t.type)),s=t&&this.getSelectedDigitalCardOptions(t);s&&this.getAvailableDigitalCardSKUs(s)}return this.outOfStockText=salla.lang.get("pages.products.out_of_stock"),this.computeAvailability(),await salla.onReady(),this.canDisabled=!salla.config.get("store.settings.product.notify_options_availability")||salla.url.is_page("cart"),this.pasteHandler=this.handlePaste.bind(this),document.addEventListener("paste",this.pasteHandler),!salla.storage.get("cart.id")&&this.optionsData.some((t=>["file","image"].includes(t.type)))?salla.api.cart.getCurrentCartId(!1,"salla-product-options"):null}disconnectedCallback(){this.pasteHandler&&document.removeEventListener("paste",this.pasteHandler)}handlePaste(t){const s=t.target;if(!(Salla.helpers.isAppleDevice()&&(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement)&&s.classList.contains("s-form-control")&&this.host.contains(s)))return;t.preventDefault();const i=t.clipboardData?.getData("text")||"",a=s.selectionStart,e=s.selectionEnd,o=s.value.slice(0,a)+i+s.value.slice(e);s.value=o,s.setSelectionRange(a+i.length,a+i.length);try{s.dispatchEvent(new window.Event("change",{bubbles:!0}))}catch(t){Salla.log("Error on change")}}hideDigitalCardsOptions(t){return this.disableCardValue&&t.type===d.DIGITAL_CARD_VALUE&&!salla.url.is_page("cart")}render(){if(0!==this.optionsData?.length)return i(a,{class:{"s-product-options-wrapper":!0,"s-product-options-no-padding":this.noPadding}},i("salla-conditional-fields",null,this.optionsData.map((t=>i("div",{key:t.id,class:"s-product-options-option-container"+(t.visibility_condition||this.hideDigitalCardsOptions(t)?" hidden":""),"data-option-id":t.id,...this.getOptionShownWhen(t)},"splitter"===t.name?this.splitterOption():i("div",{class:{"s-product-options-option":!0,"s-product-options-option-booking":t.type===d.BOOKING&&salla.url.is_page("cart")},"data-option-type":t.type,"data-option-required":`${t.required}`},i("label",{htmlFor:this.generateInputId(t.id),class:"s-product-options-option-label "+(this.hideLabel(t)?"s-product-options-option-label-hidden":"")},i("b",null,t.name,t.required&&i("span",null," * ")," "),i("small",null,t.placeholder)),i("div",{class:"s-product-options-option-content "+(this.hideLabel(t)||t.type===d.BOOKING&&salla.url.is_page("cart")?"s-product-options-option-content-full-width":"")},this.getDisplayForType(t))))))))}generateUniqueKey(t){const s=this.bundleContext;let i=this.uniqueKey?`${t}-${this.uniqueKey}`:t;if(s)try{const t="string"==typeof s?JSON.parse(s):s,{sectionId:a,productId:e}=t;i=`${i}-bundle-${a}-${e}`}catch(t){}return i}generateInputId(t){return this.generateUniqueKey(`option-${t}`)}generateInputName(t){const s=this.bundleContext,i=t.toString();if(s)try{const t="string"==typeof s?JSON.parse(s):s,{sectionId:a,productId:e}=t;return`bundle[${a}][${e}][options][${i}]`}catch(t){return`options[${i}]`}return`options[${i}]`}fillSelectedOptions(){this.selectedOptions=this.optionsData.reduce(((t,s)=>{const i=(s.details??[]).filter((t=>t.is_selected)).map((t=>({...t,option_id:s.id})));return t.concat(i)}),[])}async seedSelectedOptions(){this.fillSelectedOptions(),requestAnimationFrame((()=>{this.optionsData?.filter((t=>t.type===d.MULTIPLE_OPTIONS&&t.required)).forEach((t=>this.handleRequiredMultipleOptions(t)))}))}async componentDidLoad(){if(!this.optionsData?.length)return;await Salla.hooks.registerComponent("salla-product-options",this);const t=this.optionsData.find((t=>t.type===d.DONATION))?.details?.find((t=>t.is_selected));if(t&&setTimeout((()=>{salla.event.emit("product-options::donation-changed",{id:this.productId,price:t.additional_price})}),1e3),!salla.url.is_page("cart")&&!this.isCartMode){const t=[d.SINGLE_OPTION,d.MULTIPLE_OPTIONS,d.COLOR,d.THUMBNAIL,d.DONATION,d.DIGITAL_CARD_VALUE,d.COUNTRY];this.optionsData.some((s=>t.includes(s.type)&&s.details?.some((t=>t.is_selected))))&&requestAnimationFrame((()=>{try{const t=this.host.closest("form");if(!t)return;const s=new FormData(t),i=s.get("id")||s.get("product_id");if(i&&String(i)!==String(this.productId))return;salla.product.getPrice(s)}catch(t){salla.log("Error updating price for pre-selected options:",t)}}))}}async enterCartMode(){this.isCartMode=!0,this.disableCardValue=!1,this.canDisabled=!0,this.fillSelectedOptions(),this.computeAvailability()}async enableUserInitiatedValidation(){this.userInitiatedValidation=!0}async validateAndScroll(){return await this.enableUserInitiatedValidation(),this.reportValidity()}donationOption(t,s){return i("div",{class:"s-product-options-donation-wrapper"},t.donation?.can_donate?[t.donation?i("div",{key:t.id,class:"s-product-options-donation-progress"},i("salla-progress-bar",{donation:t.donation})):"",t.details.length?[i("h4",{key:t.id},this.selectAmount),i("div",{key:t.id,class:"s-product-options-donation-options"},t.details.map(((s,a)=>i("div",{key:t.id,class:"s-product-options-donation-options-item"},i("input",{id:this.generateUniqueKey(`donation-option-${a}`),type:"radio",name:"donating_option",checked:s.is_selected,value:s.additional_price,onChange:i=>this.handleDonationOptions(i,s,"option",t)}),i("label",{htmlFor:this.generateUniqueKey(`donation-option-${a}`)},i("span",{innerHTML:salla.money(s.name)}))))),t.donation?.custom_amount_enabled?i("div",{class:"s-product-options-donation-options-item"},i("input",{id:this.generateUniqueKey("donation-option-custom"),type:"radio",name:"donating_option",value:"custom",onChange:s=>this.handleDonationOptions(s,"custom","option",t)}),i("label",{htmlFor:this.generateUniqueKey("donation-option-custom")},i("span",null," ",this.selectDonationAmount," "))):"")]:"",i("div",{key:t.id,class:{"s-product-options-donation-input-group":!0,shown:!t.details.length||t.details.length&&this.isCustomDonation}},i("input",{type:"text",id:"donating-amount",name:"donation_amount",class:"s-form-control",ref:t=>{this.donationInput=t},value:t.details.length&&t.details.some((t=>t.is_selected))?t.details.find((t=>t.is_selected)).additional_price:t.value,placeholder:t.placeholder,onInput:s=>this.handleDonationOptions(s,"custom","input",t),onBlur:s=>this.changedHandler(s,t),onInvalid:s=>this.invalidHandler(s,t)}),i("span",{class:"s-product-options-donation-amount-currency"},salla.config.currency(salla.config.get("user.currency_code")).symbol))]:this.getExpireDonationMessage(t))}fileUploader(t,s=null){return i("salla-file-upload",{...s||{},"payload-name":"file",value:t.value,"instant-upload":!0,name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,height:"120px",onAdded:s=>{this.changedHandler(s,t,!(s.detail?.file?.origin===w.LOCAL))},url:salla.cart.api.getUploadImageEndpoint(),"form-data":{cart_item_id:this.productId,product_id:this.productId},onInvalidInput:s=>this.invalidHandler(s,t),class:{"s-product-options-image-input":!0,required:t.required}},i("div",{class:"s-product-options-filepond-placeholder"},i("span",{class:"s-product-options-filepond-placeholder-icon",innerHTML:s.accept?.split(",").every((t=>t.includes("image")))?p:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>file-upload</title>\n<path d="M21.333 24c0.341 0 0.683-0.131 0.943-0.391 0.521-0.521 0.521-1.364 0-1.885l-5.333-5.333c-0.123-0.123-0.271-0.22-0.433-0.288-0.327-0.135-0.693-0.135-1.019 0-0.163 0.068-0.311 0.165-0.433 0.288l-5.333 5.333c-0.521 0.521-0.521 1.364 0 1.885s1.364 0.521 1.885 0l3.057-3.057v10.115c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-10.115l3.057 3.057c0.26 0.26 0.601 0.391 0.943 0.391zM28.943 9.724l-9.333-9.333c-0.249-0.251-0.589-0.391-0.943-0.391h-12c-2.205 0-4 1.795-4 4v24c0 2.205 1.795 4 4 4h4c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333h-4c-0.735 0-1.333-0.599-1.333-1.333v-24c0-0.735 0.599-1.333 1.333-1.333h11.448l8.552 8.552v16.781c0 0.735-0.599 1.333-1.333 1.333h-4c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h4c2.205 0 4-1.795 4-4v-17.333c0-0.353-0.14-0.693-0.391-0.943z"></path>\n</svg>\n'}),i("p",{class:"s-product-options-filepond-placeholder-text"},salla.lang.get("common.uploader.drag_and_drop")),i("span",{class:"filepond--label-action"},salla.lang.get("common.uploader.browse"))))}imageOption(t){return this.fileUploader(t,{accept:"image/png,image/jpeg,image/jpg,image/gif"})}fileOption(t){const s=t.details.map((t=>this.fileTypes[t.name])).filter(Boolean);return s?.length?this.fileUploader(t,{accept:s.join(",")}):"File types not selected."}numberOption(t){return i("input",{type:"text",value:t.value,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onBlur:s=>this.changedHandler(s,t),onInvalid:s=>this.invalidHandler(s,t),onInput:t=>salla.helpers.inputDigitsOnly(t.target)})}splitterOption(){return i("div",{class:"s-product-options-splitter"})}textOption(t){return i("div",{class:"s-product-options-text"},i("input",{type:"text",value:t.value,maxLength:t?.length,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)}))}textareaOption(t){return i("div",{class:"s-product-options-textarea"},i("div",{class:"mt-1"},i("textarea",{rows:4,value:t.value,maxLength:t?.length,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)})))}mapOption(t){return i("salla-map",{zoom:15,lat:this.getLatLng(t.value,"lat"),lng:this.getLatLng(t.value,"lng"),name:this.generateInputName(t.id),searchable:!0,required:t.required,onInvalidInput:s=>this.invalidHandler(s,t),onSelected:s=>this.changedHandler(s,t)})}colorPickerOption(t){return i("salla-color-picker",{onSubmitted:s=>this.changedHandler(s,t),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,onInvalidInput:s=>this.invalidHandler(s,t),color:t.value})}timeOption(t){return i("salla-datetime-picker",{noCalendar:!0,enableTime:!0,dateFormat:"h:i K",value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,name:this.generateInputName(t.id),class:"s-product-options-time-element",onInvalidInput:s=>this.invalidHandler(s,t),onPicked:s=>this.changedHandler(s,t)})}dateOption(t){return i("div",{class:"s-product-options-date-element"},i("salla-datetime-picker",{value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,minDate:new Date,name:this.generateInputName(t.id),onInvalidInput:s=>this.invalidHandler(s,t),onPicked:s=>this.changedHandler(s,t)}))}datetimeOption(t){return i("div",{class:"s-product-options-datetime-element"},i("salla-datetime-picker",{enableTime:!0,value:t.value,dateFormat:"Y-m-d G:i:K",placeholder:t.name,required:!t.visibility_condition&&t.required,name:this.generateInputName(t.id),maxDate:t.to_date_time,minDate:t.from_date_time,onInvalidInput:s=>this.invalidHandler(s,t),onPicked:s=>this.changedHandler(s,t)}))}getOptionDetailName(t,s=!0,i,a){let e;if(i&&i===d.COLOR&&(e=t.name+(s&&this.isOptionDetailOut(t)&&!salla.url.is_page("cart")&&!this.hideOutLabel?` <br/> <p> ${this.outOfStockText} </p>`:"")+(t.additional_price?` <p> (${salla.money(t.additional_price,!1)}) </p>`:"")),!e){const i=(s&&this.isOptionDetailOut(t)&&!salla.url.is_page("cart")&&!this.hideOutLabel?` - ${this.outOfStockText}`:"")+(t.additional_price?` (${salla.money(t.additional_price,!1)})`:"");if("price"===a){const s=salla.helpers.digitsOnly(t.name),a=Number(s);return s&&Number.isFinite(a)?salla.money(a,!0)+i:i}e=t.name+i}return e.replace("<i class=sicon-sar></i>",salla.config.currency()?.symbol||"ر.س")}computeAvailability(){this.availabilityMap=function(t,s,i=!0){const a={};if(!t?.length)return a;const e=t.filter((t=>t.details?.some((t=>t.skus_availability&&Object.keys(t.skus_availability).length>0)))),o=e.length<=1,n=new Set(t.filter((t=>!1===t.is_advance)).map((t=>t.id)));if(0===e.length){for(const s of t)for(const t of s.details)a[t.id]=t.is_out?"out_of_stock":"available";return a}const l=e.some((t=>t.details?.some((t=>t.skus_availability&&Object.values(t.skus_availability).some(Boolean))))),r=i&&!l;for(const t of e){const i=s.filter((s=>s.option_id!==t.id));for(const s of t.details){const t=s.skus_availability;if(!t||!Object.keys(t).length){a[s.id]=s.is_out?"out_of_stock":"available";continue}const e=Object.keys(t).map(Number),l=e.some((s=>t[s]));if(o||0===i.length){a[s.id]=!l&&r||l?"available":"out_of_stock";continue}let c=e;for(const t of i){if(n.has(t.option_id))continue;const s=new Set(Object.keys(t.skus_availability||{}).map(Number));c=c.filter((t=>s.has(t)))}if(!c.length){a[s.id]=r?"available":"impossible";continue}const d=c.some((s=>t[s]));a[s.id]=!d&&r||d?"available":"out_of_stock"}}return a}(this.optionsData||[],this.selectedOptions||[],this.productAvailable)}isOptionDetailOut(t){const s=this.availabilityMap[t.id];return void 0!==s?"available"!==s:!!t.is_out}renderInput(t,s,a,e,o,n){const l=this.generateUniqueKey(`${t}-${a.id}-${s.id}`),r=this.isOptionDetailOut(s),c=this.getOptionDetailName(s,!0,a.type,a.format),d={"s-product-options-grid-mode-span":n,"s-product-options-disabled":this.canDisabled&&r};return i("label",{class:{"s-product-options-disabled":this.canDisabled&&r,"s-product-options-option-stock-out":r}},i("input",{id:l,type:t,name:o,value:s.id,disabled:this.canDisabled&&r,required:e,checked:s.is_selected,onInvalid:t=>this.invalidHandler(t,a),onChange:t=>this.changedHandler(t,a)}),"price"===a.format?i("div",{class:d,innerHTML:c}):i("div",{class:d},c))}renderOptionDetails(t,s,i,a=!1){const e=this.generateInputName(s.id),o="radio"===t?e:`${e}[]`;return s?.details.map((e=>this.renderInput(t,e,s,i,o,a)))}renderSelect(t){return i("div",null,i("select",{id:this.generateInputId(t.id),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,class:"s-form-control",onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)},i("option",{value:""},t.placeholder),t?.details.map((t=>i("option",{key:t.id,value:t.id,disabled:this.canDisabled&&this.isOptionDetailOut(t),selected:t.is_selected},this.getOptionDetailName(t))))))}renderButtonStyle(t,s,a){return i("div",{class:"s-product-options-grid-mode"},this.renderOptionDetails(t,s,a,!0))}singleOption(t){return"button"===this.optionConfig?.["single-option"]?.type||t.type===d.SINGLE_OPTION&&"price"===t.format?this.renderButtonStyle("radio",t,!t.visibility_condition&&t.required):this.renderSelect(t)}multipleOptions(t){const s="button"===this.optionConfig?.["multiple-option"]?.type,a=t.required&&!t.details.some((t=>t.is_selected))&&!t.visibility_condition;return s?this.renderButtonStyle("checkbox",t,a):i("div",{class:{"s-product-options-multiple-options-wrapper":!0,required:t.required}},this.renderOptionDetails("checkbox",t,a))}radioOption(t){return this.singleOption(t)}colorOption(t){return i("fieldset",{class:"s-product-options-colors-wrapper"},t?.details.map((s=>{const a=this.isOptionDetailOut(s);return i("div",{class:{"s-product-options-colors-item":!0,"s-product-options-option-stock-out":a},key:s.id},i("input",{type:"radio",value:s.id,required:!t.visibility_condition&&t.required,checked:s.is_selected,name:this.generateInputName(t.id),disabled:this.canDisabled&&a,id:this.generateUniqueKey(`color-${this.productId}-${t.id}-${s.id}`),onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t),"data-img-id":s.option_value}),i("label",{htmlFor:this.generateUniqueKey(`color-${this.productId}-${t.id}-${s.id}`),"data-img-id":s.option_value},i("span",{style:{backgroundColor:s.color}}),i("div",{innerHTML:this.getOptionDetailName(s,!0,t.type)})))})))}thumbnailOption(t){return i("div",{class:"s-product-options-thumbnails-wrapper"},t.details.map((s=>{const a=this.isOptionDetailOut(s);return i("div",{key:s.id,class:{"s-product-options-option-stock-out":a}},i("input",{type:"radio",value:s.id,"data-itemid":s.id,required:!t.visibility_condition&&t.required,checked:s.is_selected,name:this.generateInputName(t.id),"data-img-id":s.option_value,disabled:this.canDisabled&&a,id:this.generateUniqueKey(`option_${this.productId}-${t.id}_${s.id}`),onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)}),i("label",{htmlFor:this.generateUniqueKey(`option_${this.productId}-${t.id}_${s.id}`),"data-img-id":s.option_value,class:"go-to-slide"},i("img",{"data-src":s.image,src:s.image,title:s.name,alt:s.name}),i("span",{innerHTML:h,class:"s-product-options-thumbnails-icon"}),a?[i("small",{key:`badge-${s.id}`,class:"s-product-options-thumbnails-stock-badge"},this.outOfStockText),this.canDisabled?i("div",{key:`overlay-${s.id}`,class:"s-product-options-thumbnails-badge-overlay"}):""]:""),i("p",null,this.getOptionDetailName(s,!1)," "))})))}digitalCardValuesOption(t){return i("div",{class:"s-product-options-digital-card-wrapper"},this.availableDigitalCardValues.length>0?this.availableDigitalCardValues.map((s=>{const a=String(s.id);return i("label",{htmlFor:this.generateUniqueKey(a.toString()),key:a,class:"s-product-options-digital-card-option"},i("input",{type:"radio","data-code-value":!0,class:"s-form-control s-product-options-digital-card-input",value:s.id,name:this.generateInputName(t.id),id:this.generateUniqueKey(a.toString()),required:!t.visibility_condition&&t.required,onInvalid:s=>this.invalidHandler(s,t),...this.ignoreDefaultCardValue?{}:{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===s.id}}),i("span",null,s.name," ",salla.config?.currency()?.symbol))})):i("div",{class:"s-product-options-digital-card-out-of-stock"}))}countryOption(t){return i("div",{class:"s-product-options-digital-card-wrapper"},t.details.map((s=>{const a=this.isOptionDetailOut(s);return i("label",{htmlFor:this.generateUniqueKey(s.id.toString()),key:s.id,class:{"s-product-options-digital-card-option":!0,"s-product-options-digital-card-option-stock-out":a,"s-product-options-option-stock-out":a}},i("input",{id:this.generateUniqueKey(s.id.toString()),type:"radio",class:"s-form-control s-product-options-digital-card-input",value:s.id,name:this.generateInputName(t.id),disabled:this.canDisabled&&a,required:!t.visibility_condition&&t.required,onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t),onClick:()=>{this.disableCardValue=!1},...salla.url.is_page("cart")?{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===s.id}:{}}),i("img",{loading:"lazy",alt:s.code,height:24,width:24,class:"s-product-options-country-flag",src:`https://cdn.assets.salla.network/prod/admin/cp/assets/flags/1x1/${String(s.code).toLocaleLowerCase()}.svg`,onError:t=>{t.currentTarget.onerror=null,t.currentTarget.src=salla.url.cdn("images/globe.svg")}}),i("span",null,s.name))})))}get host(){return e(this)}};function k(){o.defaults.headers.common.currency=salla?.config?.get?.("user.currency_code")}v.style="";var _={request:(t,s,i,a=null,e=null)=>(k(),o.request({url:s,data:i,method:t.toLowerCase(),responseType:"json"}).then(a).catch(e)),get:(t,s=null,i=null,a)=>(k(),o.get(t,{params:a}).then(s).catch(i)),post(t,s,i=null,a=null){return this.request("post",t,s,i,a)},put(t,s,i=null,a=null){return this.request("put",t,s,i,a)},delete(t,s,i=null,a=null){return this.request("delete",t,s,i,a)},requestWithSupportAjax(t,s,i="post"){return new Promise(((a,e)=>{if(!window?.isLegacyTheme)return this.request(i,t,s,(({data:t})=>a(t)),(({response:t})=>e(t)));k(),$.ajax({url:t,method:i.toUpperCase(),data:s,headers:{currency:o.defaults.headers.common.currency},async:!1,success:function({data:t}){return a(t)},error:function({response:t}){return e(t)}})}))}},S={options:[],header:"undefined"!=typeof navigator&&"undefined"!=typeof window?[navigator.platform,navigator.userAgent,navigator.appVersion,navigator.vendor,window.opera]:[],dataos:[{name:"Windows Phone",value:"Windows Phone",version:"OS"},{name:"Windows",value:"Win",version:"NT"},{name:"iPhone",value:"iPhone",version:"OS"},{name:"iPad",value:"iPad",version:"OS"},{name:"Kindle",value:"Silk",version:"Silk"},{name:"Android",value:"Android",version:"Android"},{name:"PlayBook",value:"PlayBook",version:"OS"},{name:"BlackBerry",value:"BlackBerry",version:"/"},{name:"Macintosh",value:"Mac",version:"OS X"},{name:"Linux",value:"Linux",version:"rv"},{name:"Palm",value:"Palm",version:"PalmOS"}],databrowser:[{name:"Chrome",value:"Chrome",version:"Chrome"},{name:"Firefox",value:"Firefox",version:"Firefox"},{name:"Safari",value:"Safari",version:"Version"},{name:"Internet Explorer",value:"MSIE",version:"MSIE"},{name:"Opera",value:"Opera",version:"Opera"},{name:"BlackBerry",value:"CLDC",version:"CLDC"},{name:"Mozilla",value:"Mozilla",version:"Mozilla"}],init:function(){var t=this.header.join(" ");return{os:this.matchItem(t,this.dataos),browser:this.matchItem(t,this.databrowser)}},matchItem:function(t,s){var i,a,e,o=0,n=0;for(o=0;o<s.length;o+=1)if(new RegExp(s[o].value,"i").test(t)){if(i=new RegExp(s[o].version+"[- /:;]([\\d._]+)","i"),e="",(a=t.match(i))&&a[1]&&(a=a[1]),a)for(a=a.split(/[._]+/),n=0;n<a.length;n+=1)e+=0===n?a[n]+".":a[n];else e="0";return{name:s[o].name,version:parseFloat(e)}}return{name:"unknown",version:0}}};async function C(t,s,i=!1){if(salla.logger.log("🍏 Pay: mutateShippingContact called",s,i),t.detail.requiredShippingContactFields&&0!=t.detail.requiredShippingContactFields.length)if(i){if(salla.config.isGuest()&&salla.config.get("store.features").includes("guest-checkout")){if(!(s.emailAddress&&s.givenName&&s.familyName&&s.phoneNumber)){salla.logger.warn("🍏 Pay: Guest contact fields are required",s);const i=[];return s.emailAddress||i.push(new window.ApplePayError("shippingContactInvalid","emailAddress","Email address is required")),s.phoneNumber||i.push(new window.ApplePayError("shippingContactInvalid","phoneNumber","Phone number is required")),s.givenName&&s.familyName||i.push(new window.ApplePayError("shippingContactInvalid","name","Name is required")),void t.session.completePayment({status:t.session.STATUS_INVALID_SHIPPING_CONTACT,errors:i})}await async function(t,s){return salla.logger.log("🍏 Pay: Updating guest contact",s),new Promise(((i,a)=>{_.post(t.detail.guestContactSelected.url.replace("{id}",t.id),{email:s.emailAddress||null,first_name:s.givenName||null,last_name:s.familyName||null,phone_number:s.phoneNumber||null,country_code:s.countryCode||null},(async({data:s})=>{"function"==typeof t.detail.guestContactSelected?.onSuccess&&t.detail.guestContactSelected.onSuccess(s),i(s)}),(({response:s})=>{salla.logger.warn("🍏 Pay: Failed to update guest contact via api",s),"function"==typeof t.detail.guestContactSelected?.onFailed&&t.detail.guestContactSelected.onFailed(s),a({response:s})}))}))}(t,s)}}else if(t.detail.requiredShippingContactFields.includes("postalAddress"))return _.post(t.detail.shippingContactSelected.url.replace("{id}",t.id),{country:s.country,city:s.locality,local:s.subLocality||s.administrativeArea||s.locality,description:s.subAdministrativeArea,street:s.addressLines?.join(", ")||s.administrativeArea,country_code:s.countryCode,postal_code:s.postalCode},(async({data:s})=>{if("function"==typeof t.detail.shippingContactSelected.onSuccess&&t.detail.shippingContactSelected.onSuccess(s),t.address_id=s.data.address_id,t.shipping_methods=s.data.shipping_methods,!t.shipping_methods||t.shipping_methods&&!t.shipping_methods.length)return salla.logger.warn("🍏 Pay: We dont found any supported methods",s),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]});try{await t.selectApplePayShippingMethod(t.shipping_methods[0])}catch(s){return salla.logger.warn("Failed set the shipping details to api",s),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}try{await t.recalculateTotal()}catch(s){return salla.logger.warn("🍏 Pay: Failed recalculate total",s),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}const i={newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),newShippingMethods:t.mappingShippingMethods(t.shipping_methods)};salla.logger.log("🍏 Pay: completeShippingContactSelection",i),t.session.completeShippingContactSelection(i)}),(({response:s})=>{salla.logger.warn("🍏 Pay: Failed add address via api",s),"function"==typeof t.detail.shippingContactSelected.onFailed&&t.detail.shippingContactSelected.onFailed(s);let i=s?.data?.error?.fields,a=function(t){return Object.entries(t).filter((([t,s])=>s&&s.length>0)).map((([t,s])=>new window.ApplePayError("shippingContactInvalid",t,s[0])))}({countryCode:i?.country_code&&i.country_code.length>0?i.country_code[0]:null,locality:i?.city&&i.city.length>0?i.city[0]:null,country:i?.country&&i.country.length>0?i.country[0]:null});0===a.length&&s?.data?.error?.message&&a.push(new window.ApplePayError("shippingContactInvalid","locality",s?.data?.error?.message)),t.session.completeShippingContactSelection({newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:a})}))}"undefined"!=typeof window&&(window.Salla=window.Salla||{},window.Salla.Payments=window.Salla.Payments||{});const P="undefined"!=typeof window?{session:null,detail:null,address_id:null,shipping_methods:[],total:void 0,request:void 0,id:void 0,countryCode:null,totals:[],shippingCompany:null,init:function(){document.removeEventListener("payments::apple-pay.start-transaction",P.startSession),Salla.event.addEventListener("payments::apple-pay.start-transaction",P.startSession)},initDefault:function(){P.detail.onError||(P.detail.onError=function(t){salla.notify.error(t)}),P.detail.authorized.onFailed||(P.detail.authorized.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse(t),P.onCancel({},t.data.error.message)}),P.detail.validateMerchant.onFailed||(P.detail.validateMerchant.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse({response:t}),P.onCancel({},t.data.error.message)}),P.detail.authorized.onSuccess||(P.detail.authorized.onSuccess=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleAfterResponseActions(t)})},prepareLineItems:function(){return P.detail?.items?.length||(P.detail.items=[{label:salla.lang.get("pages.cart.items_total"),amount:parseFloat(P.detail.amount).toString()}]),P.detail.items},prepareTotal:function(){return{label:window.location.hostname||"Salla",amount:parseFloat(P.detail.amount).toString()}},isPhysical:()=>P.detail?.requiredShippingContactFields?.includes("postalAddress"),startSession:async function(t){P.detail=t.detail||t,salla.log("🍏 Pay: payments::apple-pay.start-transaction",P.detail),P.initDefault();let s,i=P.getApplePaySessionVersion(),a=P.detail.supportedNetworks,e=Array.isArray(a)?[...a]:Object.values(a||{});e.length||(e=["masterCard","visa"]),5!==i||e.includes("mada")||e.push("mada"),P.request={countryCode:P.detail.countryCode||"SA",supportsCouponCode:!0,couponCode:"",currencyCode:P.detail.currency||"SAR",requiredShippingContactFields:P.detail.requiredShippingContactFields?P.detail.requiredShippingContactFields:[],merchantCapabilities:["supports3DS"],supportedNetworks:e,supportedCountries:P.detail.supportedCountries||["SA"],total:P.prepareTotal(),shippingContact:P.detail.shippingContact?P.detail.shippingContact:{},shippingMethods:P.detail.shippingMethods&&P.detail.shippingMethods.length?P.mappingShippingMethods(t.detail.shippingMethods):[],lineItems:P.prepareLineItems()},salla.log("🍏 Pay: init ",P.request),P.session=new ApplePaySession(i,P.request),P.session.onshippingcontactselected=P.onShippingContactSelected,P.session.onshippingmethodselected=P.onShippingMethodSelected,P.session.onvalidatemerchant=P.onValidateMerchant,P.session.onpaymentauthorized=P.onPaymentAuthorized,P.session.oncancel=P.onCancel,P.session.oncouponcodechanged=P.onCouponCodeChanged,P.session.onpaymentmethodselected=P.onPaymentMethodSelected,"function"==typeof P.detail.onStartedSession&&(s=P.detail.onStartedSession(P.session)),s||P.session.begin()},onPaymentMethodSelected:async t=>{if(salla.logger.log("🍏 Pay: onPaymentMethodSelected",t),P.isPhysical())salla.logger.log("🍏 Pay: completePaymentMethodSelection",{newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()}),P.session.completePaymentMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()});else try{await P.recalculateTotal();const t={newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()};salla.logger.log("🍏 Pay: completePaymentMethodSelection",t),P.session.completePaymentMethodSelection(t)}catch(t){salla.logger.warn("🍏 Pay: Failed recalculate total",t),P.session.completePaymentMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems(),status:P.session.STATUS_FAILURE,errors:[new window.ApplePayError("unknown",void 0,t?.response?.data?.error?.message||t?.response?.data?.error?.code||"Failed to recalculate total")]})}},onCouponCodeChanged:t=>(Salla.event.dispatch("payments::apple-pay.coupon.change",t),_.post(P.detail.onCouponCodeChanged.url.replace("{id}",P.id),{coupon:t.couponCode,payment_method:"apple_pay"},(async({data:t})=>{"function"==typeof P.detail.onCouponCodeChanged.onSuccess&&P.detail.onCouponCodeChanged.onSuccess(t),salla.log("🍏 Pay: Coupon applied success"),await P.recalculateTotal(),P.session.completeCouponCodeChange({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()})}),(async t=>{let s=t?.response;Salla.event.dispatch("payments::apple-pay.coupon.failed",s),"function"==typeof P.detail.onCouponCodeChanged.onFailed&&P.detail.onCouponCodeChanged.onFailed(s),await P.recalculateTotal(),P.session.completeCouponCodeChange({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems(),errors:[new window.ApplePayError("couponCodeInvalid")]})}))),onCancel:(t={},s=null)=>{P.detail.onError(s||salla.lang.get("pages.checkout.payment_failed")),Salla.event.createAndDispatch("payments::apple-pay.canceled",t)},onPaymentAuthorized:async t=>{salla.logger.log("🍏 Pay: onPaymentAuthorized",t.payment);try{await C(P,t.payment.shippingContact,!0)}catch(t){salla.logger.error("🍏 Pay: Failed to update guest contact details",t);const s=t?.response||t,i=s?.data?.error?.fields||{},a=[];return i?.email&&i.email.length>0&&a.push(new window.ApplePayError("shippingContactInvalid","emailAddress",i.email[0])),i?.phone&&i.phone.length>0&&a.push(new window.ApplePayError("shippingContactInvalid","phoneNumber",i.phone[0])),i?.first_name&&i.first_name.length>0?a.push(new window.ApplePayError("shippingContactInvalid","name",i.first_name[0])):i?.last_name&&i.last_name.length>0&&a.push(new window.ApplePayError("shippingContactInvalid","name",i.last_name[0])),0===a.length&&a.push(new window.ApplePayError("shippingContactInvalid","name",s?.data?.error?.message||s?.data?.error?.code||"Invalid shipping contact details")),Salla.event.dispatch("payments::apple-pay.authorized.failed",s),"function"==typeof P.detail.authorized.onFailed&&P.detail.authorized.onFailed(s),void P.session.completePayment({status:ApplePaySession.STATUS_INVALID_SHIPPING_CONTACT,errors:a})}Salla.event.dispatch("payments::apple-pay.authorized.init",t),_.post(P.detail.authorized.url.replace("{id}",P.id),{payment_method:"apple_pay",applepay_token:JSON.stringify(t.payment)},(({data:t})=>{Salla.event.dispatch("payments::apple-pay.authorized.success",t),"function"==typeof P.detail.authorized.onSuccess&&P.detail.authorized.onSuccess(t),P.session.completePayment(ApplePaySession.STATUS_SUCCESS)}),(t=>{let s=t?.response;Salla.event.dispatch("payments::apple-pay.authorized.failed",s),"function"==typeof P.detail.authorized.onFailed&&P.detail.authorized.onFailed(s),P.session.completePayment({status:ApplePaySession.STATUS_FAILURE,errors:[new window.ApplePayError("unknown",void 0,s?.data?.error?.message||s?.data?.error?.code||"Failed to parse authorized response")]})}))},onValidateMerchant:async t=>{try{Salla.event.dispatch("payments::apple-pay.validate-merchant.init",t);const{data:s}=await _.post(P.detail.validateMerchant.url.replace("{id}",P.id),{validation_url:t.validationURL});Salla.event.dispatch("payments::apple-pay.validate-merchant.success",s);const i=t=>{P.session.completeMerchantValidation(t)};if("function"==typeof P.detail.validateMerchant.onSuccess){const t=await P.detail.validateMerchant.onSuccess(s);if(t?.redirect)return window.location=t.redirect,P.abortValidateMerchant(t)}i(s.data)}catch(t){console.error(t),P.abortValidateMerchant(t?.response)}},abortValidateMerchant:(t=null)=>{P.abortSession(),Salla.event.dispatch("payments::apple-pay.validate-merchant.failed",t),"function"==typeof P.detail.validateMerchant.onFailed&&P.detail.validateMerchant.onFailed(t)},onShippingContactSelected:async t=>{salla.logger.log("🍏 Pay: onShippingContactSelected",t.shippingContact),await C(P,t.shippingContact)},onShippingMethodSelected:async t=>{let s=t.shippingMethod.identifier.split(","),i={ship_id:s[0],private_ship_id:void 0===s[1]?null:s[1],type:void 0===s[2]?null:s[2],route_id:void 0===s[3]?null:s[3]};if(salla.logger.log("🍏 Pay: onShippingMethodSelected",{event:t,previous:P.shippingCompany,current:i}),P.shouldUpdateShippingCompany(i))try{await P.selectApplePayShippingMethod(i),await P.recalculateTotal()}catch(t){return salla.logger.warn("🍏 Pay: Failed set the shipping details to api",t),void P.session.completeShippingMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems(),status:P.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}salla.logger.log("🍏 Pay: completeShippingMethodSelection",{newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()}),P.session.completeShippingMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()})},abortSession:()=>{P.session&&P.session.abort()},shouldUpdateShippingCompany:t=>P.shippingCompany?.ship_id!=t?.ship_id||P.shippingCompany?.private_ship_id!=t?.private_ship_id,getApplePaySessionVersion:()=>{if("sallapp"===(navigator.userAgent||navigator.vendor||window.opera))return 5;let t=S.init(),s=parseFloat(t.os.version);if("Macintosh"===t.os.name){if(s<10.142)return 1}else if(s<12.11)return 1;return 5},recalculateTotal:()=>(salla.logger.log("🍏 Pay: recalculate total"),_.get(P.detail.recalculateTotal.url.replace("{id}",P.id),(({data:t})=>{salla.logger.log("🍏 Pay: recalculate total success",t);let s=t.data.initial_data?.cart||t.data.cart,i=t.data.initial_data?.payments||t.data.payments;salla.logger.log("🍏 Pay: recalculate total success",{cart:s,payments:i}),null!=i?.gateways?.applePay?.amount?(P.detail.amount=i.gateways.applePay.amount,P.detail.currency=i.gateways.applePay.currency??P.detail.currency):P.detail.amount=i?.gateways?.applePay?.supportedMultiCurrency?s.total_in_customer_currency:s.total,P.detail.items=(s.totals||s.items).map((t=>({label:t.title,amount:"مجاني"===t.amount||"Free"===t.amount?0:t.amount.toString().replace("+","")}))),P.detail.items.pop(),P.totals=P.detail.items}),(t=>(salla.logger.warn("🍏 Pay: recalculate total failed",t),t?.response?.data?.message)))),selectApplePayShippingMethod:t=>{salla.logger.log("🍏 Pay: select shipping method ",t),P.shippingCompany=t;const s={address_id:P.address_id,company_id:t.ship_id,private_company_id:t.private_ship_id,type:t.type||void 0,route_id:t.route_id||void 0,payment_method:"apple_pay"};return _.post(P.detail.shippingMethodSelected.url.replace("{id}",P.id),s,(({data:t})=>("function"==typeof P.detail.shippingMethodSelected.onSuccess&&P.detail.shippingMethodSelected.onSuccess(t),!0)),(t=>{salla.logger.warn("🍏 Pay: Set shipping method failed",t),"function"==typeof P.detail.shippingMethodSelected.onFailed&&P.detail.shippingMethodSelected.onFailed(t);let s=t?.response?.data?.error;return s?.data?.fields?.address_id?s?.data?.fields?.address_id[0]:s?.data?.message}))},mappingShippingMethods:t=>t.map((t=>({label:t.shipping_title,amount:t.enable_free_shipping?0:t.ship_cost,detail:"",identifier:t.ship_id.toString()+(t.private_ship_id?","+t.private_ship_id.toString():"")+(t.type?","+t.type:"")+(t.route_id?","+t.route_id:"")})))}:{};"undefined"!=typeof window&&(window.SallaApplePay=P),"undefined"!=typeof window&&window.ApplePaySession?.canMakePayments()?P.init():"undefined"!=typeof document&&document.querySelectorAll("data-show-if-apple-pay-supported").forEach((t=>t.style.display="none"));const O=class{constructor(i){t(this,i),this.validationFailed=s(this,"validationFailed"),this.requireLogin=s(this,"requireLogin"),this.type="buy",this.productType="product",this.options={},this.collectedOrderOptions=[],this.optionsResolved=!1,this.applePayAmount=0,this.pendingApplePaySession=null,this.quickBuy=salla.lang.get("pages.products.buy_now"),this.handleApplePaySessionStarted=t=>!!salla.config.get("store.settings.order_options.mandatory",!1)&&!this.optionsResolved&&(this.optionsResolved=!0,this.pendingApplePaySession=t,async function(t){let s;try{s=await salla.api.withoutNotifier((()=>salla.product.api.getOrderOptions([{id:t.productId,quantity:t.quantity}])))}catch(s){return salla?.logger?.warn?.("order-options: fetch failed",s),void t.beginPendingSession()}const i=s?.data?.order_options||[];if(!i.length)return void t.beginPendingSession();t.discardPendingSession();const a=Number(t.amount)>0?Number(t.amount):Number(s?.data?.products?.[0]?.price?.amount)||0,e=function(){let t=document.querySelector("salla-order-options-modal");return t||(t=document.createElement("salla-order-options-modal"),document.body.appendChild(t)),t}();try{await e.open({orderOptions:i,basePrice:a,paymentMode:"apple-pay",onSubmit:t.onSubmit})}catch{}}({productId:this.productId,amount:Number(this.amount),quantity:this.getSelectedQuantity(),beginPendingSession:()=>{this.pendingApplePaySession?.begin(),this.pendingApplePaySession=null},discardPendingSession:()=>{this.pendingApplePaySession=null},onSubmit:(t,s)=>{this.collectedOrderOptions=t,this.applePayAmount=s,this.settlePayment()}}),!0),salla.lang.onLoaded((()=>{this.quickBuy=salla.lang.get("pages.products.buy_now")}))}quickBuyHandler(){if(salla.config.isGuest()&&!this.isGuestCheckout())return this.requireLogin.emit({productId:this.productId}),void salla.api.auth.requireLoginThen("salla-quick-buy::user.logged-in",(()=>this.quickBuyHandler()));this.validatePdpOptionsSync()&&(this.optionsResolved=!1,this.collectedOrderOptions=[],this.applePayAmount=0,this.settlePayment())}validatePdpOptionsSync(){return!!function(t){const s=document.querySelector(`salla-product-options[product-id="${t}"]`);if(!s)return!0;const i=s.querySelectorAll("[required]");let a=!0;return i.forEach((t=>{t.disabled||t.closest(".hidden")||"reportValidity"in t&&!t.reportValidity()&&(a=!1)})),a}(this.productId)||(this.validationFailed.emit({productId:this.productId}),salla.error(salla.lang.get("common.messages.required_fields")),!1)}getSelectedQuantity(){try{const t=this.host.getElementSallaData?.(),s=Number(t instanceof FormData?t.get("quantity"):t?.quantity);return Number.isFinite(s)&&s>0?s:1}catch{return 1}}async settlePayment(){let t=this.host.getElementSallaData();if(function(t,s){s.length&&(t&&"function"==typeof t.append?s.forEach(((s,i)=>{t.append(`order_options[${i}][id]`,String(s.id)),t.append(`order_options[${i}][value]`,String(s.value))})):t&&"object"==typeof t&&(t.order_options=s))}(t,this.collectedOrderOptions),!this.isApplePayActive)return salla.api.request("checkout/quick-purchase/"+this.productId,t,"post").then((t=>(t.data.redirect&&(window.location.href=t.data.redirect),t)));t.is_applepay=!0,"append"in t&&t.append("is_applepay",!0),salla.event.dispatch("payments::apple-pay.start-transaction",{amount:this.applePayAmount>0?this.applePayAmount:this.amount,currency:this.currency||salla.config.get("store.settings.buy_now.currency")||"SAR",requiredShippingContactFields:this.getRequiredShippingContactFields(),shippingMethods:this.isRequireShipping?[]:void 0,supportedNetworks:this.isLegacyBuyNowBE()?salla.config.get("store.settings.buy_now.networks"):Array.isArray(this.supportedNetworks)&&this.supportedNetworks.length?this.supportedNetworks:salla.config.get("store.settings.buy_now.supportedNetworks"),supportedCountries:this.isLegacyBuyNowBE()?salla.config.get("store.settings.buy_now.countries"):Array.isArray(this.supportedCountries)&&this.supportedCountries.length?this.supportedCountries:salla.config.get("store.settings.buy_now.supportedCountries"),countryCode:salla.config.get("store.store_country")||"SA",onStartedSession:this.handleApplePaySessionStarted,validateMerchant:{url:this.validateHost?`${this.validateHost}/checkout/applepay/validate`:salla.url.get("checkout/applepay/validate"),onSuccess:s=>this.applePayOnly&&!this.productId?this.cartId?(window.SallaApplePay.id=this.cartId,salla.log("🍏 Pay: create checkout success: with id #"+this.cartId),Promise.resolve(s)):(salla.logger.warn("🍏 Pay: trying to create applePay transaction without cartId/ProductId !"),Promise.resolve(s)):salla.api.request("checkout/quick-purchase/"+this.productId,"object"==typeof t?t:void 0,"post",{}).then((t=>t?.data?.redirect?(salla.log("🍏 Pay: create checkout success: redirect exits, go to checkout page"),window.location.href=t.data.redirect.url,t):t?.data?.id?(window.SallaApplePay.id=t.data.id,void salla.log("🍏 Pay: create checkout success: with id #"+window.SallaApplePay.id)):(salla.logger.warn("🍏 Pay: create checkout success: No id, or redirect"),t)))},authorized:{url:salla.url.get("checkout/{id}/payments/submit"),onFailed:t=>{window.SallaApplePay.onCancel({},t?.data?.error?.message||t?.data?.error?.code||salla.lang.get("pages.checkout.payment_failed"))},onSuccess:t=>{window.location.href=t.redirect.url,salla.log("🍏 Pay: authorized Success:: redirect to thank you page, order placed")}},shippingMethodSelected:this.isRequireShipping?{url:salla.url.get("checkout/{id}/shipping/details")}:void 0,shippingContactSelected:this.isRequireShipping?{url:salla.url.get("checkout/{id}/address/add")}:void 0,guestContactSelected:this.isGuestCheckout()?{url:salla.url.get("checkout/{id}/customer")}:void 0,onCouponCodeChanged:{url:salla.url.get("checkout/{id}/coupons")},recalculateTotal:{url:salla.url.get("checkout/{id}/payments/recalculate?payment_method=apple_pay")},onError:function(t){salla.log(t),salla.notify.error(t)}})}isGuestCheckout(){return salla.config.isGuest()&&salla.config.get("store.features").includes("guest-checkout")&&this.isPhysicalProduct()}getRequiredShippingContactFields(){let t=[];return this.isRequireShipping&&t.push("postalAddress"),this.isGuestCheckout()&&t.push("email","phone","name"),t}isLegacyBuyNowBE(){return null!=salla?.config?.get?.("store.settings.buy_now.multi_currency")}applyBaseCurrencyPrice(t){if(this.isLegacyBuyNowBE())return void(null!=t?.price&&(this.amount=t.price));const s=t?.base_currency_price;null!=s?.amount?(this.amount=s.amount,s?.currency&&(this.currency=s.currency)):null!=t?.price&&(this.amount=t.price,this.currency=salla.config.get("user.currency_code")||this.currency||"SAR")}componentWillLoad(){console.log("🍏 Pay: Quick Buy Component Loaded");const t="undefined"!=typeof window&&!!window.ApplePaySession?.canMakePayments?.(),s=salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??!0,i=salla?.config?.get?.("store.settings.is_salla_gateway",!1)??!0;this.isApplePayActive=t&&s&&i;const a=async()=>{if(this.isLegacyBuyNowBE()&&!this.currency&&salla?.config?.get&&(this.currency=salla.config.get("store.settings.buy_now.multi_currency")?salla.config.get("user.currency_code"):salla.config.get("store.settings.buy_now.currency")||"SAR"),!this.productId&&salla?.config?.get&&salla.url?.is_page&&(this.productId=salla.config.get("page.id")),this.applePayOnly||this.productId){if(this.amount&&this.isRequireShipping||!this.productId||!salla?.product?.getDetails||await salla.product.getDetails(this.productId,[]).then((t=>{this.applyBaseCurrencyPrice(t?.data),this.isRequireShipping=t?.data?.is_require_shipping||!1})).catch((t=>{salla?.logger?.warn?.("🍏 Pay: Failed load the quick buy, get the product details failed: ",t)})),"donate"===this.type&&salla?.event?.on?salla.event.on("product-options::donation-changed",(t=>{String(t.id)===String(this.productId)&&this.applyBaseCurrencyPrice(t)})):salla?.url?.is_page?.("product.single")&&salla?.product?.event?.onPriceUpdated&&salla.product.event.onPriceUpdated((t=>{this.applyBaseCurrencyPrice(t?.data)})),this.isApplePayActive=(salla?.helpers?.hasApplePay?.()??t)&&(salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??s)&&(salla?.config?.get?.("store.settings.is_salla_gateway",!1)??i),!document.getElementById("apple-pay-sdk")&&this.isApplePayActive){const t=document.createElement("script");t.src="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",t.setAttribute("id","apple-pay-sdk"),t.async=!0,document.body.appendChild(t)}}else salla?.logger?.warn?.("🍏 Pay: Failed load the quick buy, the product id is missing")};return new Promise((t=>{"function"==typeof salla?.onReady?salla.onReady((()=>a().then((()=>t(!0))))):a().then((()=>t(!0)))}))}render(){return i(a,{key:"c2ba63eb4fad49f80977d6f1adc836f655524933"},this.quickBuyButton())}quickBuyButton(){return i("apple-pay-button",{locale:salla?.config?.get?.("user.language_code")||"ar",onClick:()=>this.quickBuyHandler(),"data-quick-purchase":"applepay",class:"s-quick-buy-apple-pay","data-is-applepay":"1",buttonstyle:"black",type:this.type})}isPhysicalProduct(){return"product"===this.productType||"group_products"===this.productType||"food"===this.productType}get host(){return e(this)}};O.style=".s-quick-buy-button .s-button-text{display:flex}apple-pay-button{--apple-pay-button-width:100%;--apple-pay-button-height:40px;--apple-pay-button-border-radius:.75rem;--apple-pay-button-box-sizing:content-box}";export{m as salla_add_product_button,y as salla_bought_together,g as salla_product_availability,v as salla_product_options,O as salla_quick_buy}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as s,h as t,H as i,a as l}from"./p-BmH_SCLp.js";import{A as e}from"./p-DCZbpt2a.js";import{B as a}from"./p-D3mWkc-3.js";import{P as n}from"./p-DY4LZmNP.js";import{S as o}from"./p-CeFAfcTv.js";import{S as r}from"./p-8Tsmrwno.js";import{S as h}from"./p-D4oPi1Ov.js";import{S as c}from"./p-CXRKXFgT.js";var m='\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-circle</title>\n<path d="M16 22.964c-4.525 0-8.447 1.713-9.993 4.365-0.371 0.636-0.156 1.452 0.48 1.823s1.453 0.156 1.823-0.48c0.855-1.465 3.624-3.041 7.689-3.041s6.835 1.576 7.689 3.041c0.249 0.424 0.696 0.661 1.155 0.661 0.228 0 0.459-0.059 0.669-0.181 0.637-0.371 0.852-1.187 0.48-1.823-1.545-2.652-5.467-4.365-9.992-4.365zM22.667 13.631c0-3.676-2.991-6.667-6.667-6.667s-6.667 2.991-6.667 6.667 2.991 6.667 6.667 6.667 6.667-2.992 6.667-6.667zM12 13.631c0-2.205 1.795-4 4-4s4 1.795 4 4-1.795 4-4 4-4-1.795-4-4zM16 0.297c-8.823 0-16 7.177-16 16 0 2.941 0.821 5.831 2.373 8.357 0.252 0.411 0.689 0.636 1.137 0.636 0.239 0 0.479-0.064 0.696-0.197 0.628-0.385 0.824-1.207 0.439-1.833-1.295-2.108-1.979-4.516-1.979-6.963 0-7.352 5.981-13.333 13.333-13.333s13.333 5.981 13.333 13.333c0 2.448-0.684 4.856-1.979 6.961-0.385 0.628-0.189 1.448 0.437 1.835 0.627 0.384 1.448 0.189 1.835-0.437 1.553-2.527 2.373-5.416 2.373-8.359 0-8.823-7.177-16-16-16z"></path>\n</svg>\n';const u=class{constructor(t){s(this,t),this.accountLoading=!1,this.opened=!1,this.notifications=salla.lang.get("common.titles.notifications"),this.orders=salla.lang.get("common.titles.orders"),this.pending_orders=salla.lang.get("common.titles.pending_orders"),this.wishlist=salla.lang.get("common.titles.wishlist"),this.profile=salla.lang.get("common.titles.profile"),this.rating=salla.lang.get("common.titles.rating"),this.wallet=salla.lang.get("common.titles.wallet"),this.settings=salla.lang.get("common.titles.settings"),this.loyalty_points=salla.lang.get("pages.loyalty_program.loyalty_points"),this.logout=salla.lang.get("blocks.header.logout"),this.hello=salla.lang.get("pages.checkout.hello"),this.first_name=salla.storage.get("user.first_name")||"",this.last_name=salla.storage.get("user.last_name")||"",this.avatar=salla.storage.get("user.avatar")||salla.url.cdn("images/avatar.png",40,40),this.badges={notifications:salla.helpers.number(salla.storage.get("user.notifications")||0),pending_orders:salla.helpers.number(salla.storage.get("user.pending_orders")||0)},this.sallaAccountEnabled=!1,this.walletBalance="",this.walletBalanceLoading=!1,this.walletBalanceLoaded=!1,this.hasBadges=Number(salla.storage.get("user.pending_orders"))>0||Number(salla.storage.get("user.notifications"))>0,this.inline=!1,this.avatarOnly=!1,this.showHeader=!1,this.relativeDropdown=!1,this.showTrigger=!1,this.onClickOutside=()=>{this.opened=!1},this.OrderUpdate=0,this.accountPrefixedKeys=["orders","pending_orders","wallet","notifications","rating","profile","wishlist","settings"],this.items={notifications:a,orders:'\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>box-bankers</title>\n<path d="M28 1.333h-24c-2.205 0-4 1.795-4 4v5.333c0 0.736 0.597 1.333 1.333 1.333v14.667c0 2.205 1.795 4 4 4h21.333c2.205 0 4-1.795 4-4v-14.667c0.736 0 1.333-0.597 1.333-1.333v-5.333c0-2.205-1.795-4-4-4zM28 26.667c0 0.735-0.599 1.333-1.333 1.333h-21.333c-0.735 0-1.333-0.599-1.333-1.333v-14.667h5.333v2.667c0 1.471 1.196 2.667 2.667 2.667h8c1.471 0 2.667-1.196 2.667-2.667v-2.667h5.333zM12 14.667v-2.667h8v2.667zM29.333 9.333h-26.667v-4c0-0.735 0.599-1.333 1.333-1.333h24c0.735 0 1.333 0.599 1.333 1.333z"></path>\n</svg>\n',pending_orders:n,wishlist:o,wallet:'\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>wallet</title>\n<path d="M28 6.667h-24c-0.736 0-1.333-0.597-1.333-1.333s0.597-1.333 1.333-1.333h24c0.737 0 1.333-0.596 1.333-1.333s-0.596-1.333-1.333-1.333h-24c-2.204 0-3.999 1.793-4 3.997v18.669c0 3.676 2.991 6.667 6.667 6.667h21.333c2.205 0 4-1.795 4-4v-16c0-2.205-1.795-4-4-4zM29.333 26.667c0 0.736-0.597 1.333-1.333 1.333h-21.333c-2.205 0-4-1.795-4-4v-14.895c0.416 0.147 0.865 0.228 1.333 0.228h24c0.736 0 1.333 0.597 1.333 1.333zM22.667 14.667c-2.205 0-4 1.795-4 4s1.795 4 4 4 4-1.795 4-4-1.795-4-4-4zM22.667 20c-0.736 0-1.333-0.597-1.333-1.333s0.597-1.333 1.333-1.333 1.333 0.597 1.333 1.333-0.597 1.333-1.333 1.333z"></path>\n</svg>\n',loyalty_points:c,profile:m}}async componentWillLoad(){await salla.onReady(),await salla.lang.onLoaded(),this.loadTranslations(),this.initiate(),Salla.event.on("api::token.injected",(s=>this.profileUrl=this.buildProfileUrl(s))),this.sallaAccountEnabled=Salla.config.get("store.features")?.includes("salla-account"),this.items=this.sallaAccountEnabled?{...this.items,settings:'\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>settings</title>\n<path d="M29.717 19.037l-1.817-1.499c0.067-0.512 0.1-1.028 0.1-1.539s-0.033-1.027-0.1-1.54l1.817-1.499c1.177-0.969 1.479-2.633 0.716-3.956l-1.159-2.009c-0.761-1.324-2.349-1.895-3.784-1.359l-2.212 0.829c-0.817-0.627-1.704-1.139-2.649-1.535l-0.388-2.332c-0.251-1.507-1.54-2.6-3.067-2.6h-2.319c-1.525 0-2.815 1.093-3.065 2.6l-0.388 2.332c-0.945 0.396-1.833 0.909-2.649 1.535l-2.212-0.829c-1.428-0.533-3.021 0.036-3.783 1.359l-1.16 2.011c-0.763 1.323-0.46 2.985 0.716 3.955l1.817 1.499c-0.067 0.513-0.1 1.029-0.1 1.54s0.033 1.027 0.1 1.539l-1.819 1.5c-1.176 0.971-1.476 2.635-0.715 3.955l1.159 2.011c0.763 1.324 2.356 1.899 3.784 1.36l2.212-0.831c0.816 0.625 1.703 1.139 2.649 1.535l0.388 2.332c0.251 1.507 1.54 2.6 3.067 2.6h2.319c1.527 0 2.816-1.093 3.065-2.6l0.389-2.332c0.947-0.396 1.833-0.909 2.649-1.535l2.212 0.831c1.432 0.539 3.023-0.035 3.783-1.36l1.16-2.011c0.76-1.32 0.459-2.984-0.717-3.956zM28.123 21.663l-1.16 2.011c-0.108 0.188-0.336 0.267-0.536 0.193l-2.931-1.1c-0.459-0.173-0.979-0.079-1.349 0.248-0.923 0.811-1.979 1.423-3.139 1.819-0.464 0.157-0.804 0.559-0.885 1.043l-0.515 3.087c-0.033 0.215-0.216 0.371-0.433 0.371h-2.319c-0.217 0-0.4-0.156-0.436-0.371l-0.513-3.087c-0.080-0.484-0.42-0.884-0.885-1.043-1.16-0.396-2.216-1.008-3.139-1.819-0.248-0.217-0.561-0.332-0.88-0.332-0.157 0-0.316 0.028-0.469 0.084l-2.931 1.1c-0.199 0.079-0.428-0.004-0.537-0.193l-1.159-2.011c-0.109-0.191-0.067-0.428 0.101-0.568l2.409-1.985c0.379-0.312 0.555-0.807 0.46-1.288-0.119-0.605-0.179-1.219-0.179-1.821 0-0.604 0.060-1.217 0.181-1.823 0.095-0.481-0.081-0.976-0.46-1.288l-2.409-1.985c-0.168-0.139-0.211-0.376-0.101-0.567l1.16-2.011c0.107-0.188 0.332-0.268 0.536-0.193l2.931 1.1c0.459 0.172 0.979 0.079 1.348-0.247 0.924-0.812 1.98-1.424 3.139-1.817 0.465-0.159 0.805-0.559 0.885-1.044l0.513-3.088c0.036-0.215 0.219-0.371 0.436-0.371h2.319c0.217 0 0.4 0.156 0.436 0.371l0.515 3.088c0.081 0.484 0.42 0.885 0.885 1.044 1.157 0.393 2.213 1.005 3.139 1.817 0.371 0.325 0.889 0.42 1.349 0.247l2.929-1.099c0.203-0.076 0.428 0.005 0.537 0.193l1.159 2.009c0.109 0.191 0.067 0.428-0.101 0.567l-2.409 1.985c-0.379 0.312-0.555 0.807-0.46 1.288 0.119 0.605 0.179 1.219 0.179 1.823 0 0.603-0.060 1.216-0.181 1.821-0.095 0.48 0.081 0.975 0.46 1.288l2.408 1.984c0.169 0.141 0.212 0.379 0.103 0.569zM16.016 10.667c-2.941 0-5.333 2.392-5.333 5.333s2.392 5.333 5.333 5.333 5.333-2.392 5.333-5.333-2.392-5.333-5.333-5.333zM16.016 18.667c-1.471 0-2.667-1.196-2.667-2.667s1.196-2.667 2.667-2.667 2.667 1.196 2.667 2.667-1.196 2.667-2.667 2.667z"></path>\n</svg>\n'}:this.items,this.host.hasAttribute("with-rating")&&(this.items.rating=h),this.items.logout='\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>send-out</title>\n<path d="M16 26.667h-9.333c-0.736 0-1.333-0.597-1.333-1.333v-18.667c0-0.736 0.597-1.333 1.333-1.333h9.333c0.737 0 1.333-0.596 1.333-1.333s-0.596-1.333-1.333-1.333h-9.333c-2.205 0-4 1.795-4 4v18.667c0 2.205 1.795 4 4 4h9.333c0.737 0 1.333-0.596 1.333-1.333s-0.596-1.333-1.333-1.333zM29.231 15.491c-0.068-0.164-0.167-0.312-0.289-0.436l-5.332-5.332c-0.521-0.521-1.364-0.521-1.885 0s-0.521 1.364 0 1.885l3.057 3.059h-12.781c-0.737 0-1.333 0.596-1.333 1.333s0.596 1.333 1.333 1.333h12.781l-3.057 3.057c-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.391l5.332-5.332c0.124-0.123 0.221-0.271 0.289-0.435 0.135-0.325 0.135-0.693 0-1.019z"></path>\n</svg>\n';let s=Salla.storage.get("token");s||(s=""),this.profileUrl=this.buildProfileUrl(s);const t=this.host.querySelector('[slot="trigger"]');this.triggerSlot='<div class="s-user-menu-trigger"><div class="s-user-menu-avatar-wrap"><img class="s-user-menu-trigger-avatar" src="{avatar}" alt="{first_name}{last_name}" /></div><div class="s-user-menu-trigger-content"><span class="s-user-menu-trigger-hello">{hello}</span><p class="s-user-menu-trigger-name">{first_name} {last_name}</p></div> <i class="s-user-menu-trigger-icon">{icon}</i></div>',t&&(this.triggerSlot=t.innerHTML,t.innerHTML=this.replaceParams(t.innerHTML))}loadTranslations(){this.notifications=Salla.lang.get("common.titles.notifications"),this.orders=Salla.lang.get("common.titles.orders"),this.pending_orders=Salla.lang.get("common.titles.pending_orders"),this.wishlist=Salla.lang.get("common.titles.wishlist"),this.profile=Salla.lang.get("common.titles.profile"),this.hello=Salla.lang.get("pages.checkout.hello"),this.rating=Salla.lang.get("common.titles.rating"),this.wallet=Salla.lang.get("common.titles.wallet"),this.settings=Salla.lang.get("common.titles.settings"),this.loyalty_points=Salla.lang.get("pages.loyalty_program.loyalty_points"),this.logout=Salla.lang.get("blocks.header.logout")}async loadWalletBalance(){if(!Salla.config.isGuest()){this.walletBalanceLoading=!0;try{const s=await salla.api.withoutNotifier((()=>salla.api.request("/balance/wallet?light=1"))),t=Number(s?.data?.balance)||0;this.walletBalance=t?Salla.money({amount:Number(t.toFixed(2)),currency:Salla.config.get("user.currency_code")}):"",this.walletBalanceLoaded=!0}catch{}finally{this.walletBalanceLoading=!1}}}initiate(){return Salla.config.isGuest()?this.autoMountLoginModal():(this.is_loggedIn=!0,!this.inline&&(salla.url.is_page("customer.notifications")||salla.url.is_page("customer.orders.index.pending")||salla.url.is_page("customer.profile")||(Date.now()-(salla.storage.get("user.fetched_at")||0))/1e3/60>30)?this.fetchFreshProfile():void salla.event.on("profile::info.fetched",(s=>{this.updateProfileState(s)})))}autoMountLoginModal(){this.showTrigger&&(document.querySelector("salla-login-modal")||Salla.hooks.mount("body:end",document.createElement("salla-login-modal")))}fetchFreshProfile(){salla.api.token?salla.profile.api.info().then((s=>{this.updateProfileState(s)})):salla.log("trying to fetchFreshProfile before injected the token!!")}updateProfileState(s){this.badges={notifications:salla.helpers.number(s.data.notifications||0),pending_orders:salla.helpers.number(s.data.pending_orders||0)},this.hasBadges=Number(s.data.pending_orders)>0||Number(s.data.notifications)>0,this.first_name=s.data.first_name,this.last_name=s.data.last_name,this.avatar=s.data.avatar||salla.url.cdn("images/avatar.png",40,40)}async open(s){this.opened=!this.opened,s.stopPropagation(),this.opened&&(!window.can_access_wallet||this.walletBalanceLoaded||this.walletBalanceLoading||this.loadWalletBalance(),window.addEventListener("click",this.onClickOutside))}menuItemClicked(s,t){"logout"===t&&(s.preventDefault(),salla.auth.logout("sall-user-menu"))}replaceParams(s){return s.replace(/\{hello\}/g,this.hello).replace(/\{first_name\}/g,this.first_name).replace(/\{last_name\}/g,this.last_name).replace(/\{avatar\}/g,this.avatar).replace(/\{icon\}/g,e)}getTheHeader(){return t("div",{class:{"s-user-menu-trigger-slot":!0,"s-user-menu-red-dot":this.hasBadges,"s-user-menu-trigger-avatar-only":this.avatarOnly},id:"trigger-slot",onClick:s=>this.open(s),onKeyUp:s=>this.open(s),innerHTML:this.replaceParams(this.triggerSlot)})}getItemAnchorLinkAttrs(s){if("profile"===s&&this.profileUrl&&this.sallaAccountEnabled)return{href:this.profileUrl,target:"_blank",rel:"noopener noreferrer"};const t="loyalty_points"===s?"loyalty":s,i=this.accountPrefixedKeys.includes(t)?`account/${t}`:t;return{href:Salla.url.get(i)}}getMenuItem([s,i],l){if(("wallet"!==s||window.can_access_wallet)&&("loyalty_points"!==s||Salla.config.get("store.features").includes("loyalty-system")))return t("li",{class:{"s-user-menu-dropdown-item":!0,"s-user-menu-dropdown-item-logout":l+1===Object.entries(this.items).length}},t("a",{...this.getItemAnchorLinkAttrs(s),class:"s-user-menu-dropdown-item-link",onClick:t=>this.menuItemClicked(t,s)},t("i",{class:"s-user-menu-dropdown-item-prefix",innerHTML:i}),t("span",{class:"s-user-menu-dropdown-item-title"},this[s]),"wallet"!==s||this.inline||!this.walletBalance&&!this.walletBalanceLoading?"":t("span",{class:"s-user-menu-dropdown-item-balance",style:{display:"inline-flex",alignItems:"center",gap:"4px"}},this.walletBalance?t("span",{innerHTML:this.walletBalance}):"",this.walletBalanceLoading?t("salla-loading",{size:"14"}):""),["٠","0",void 0].includes(this.badges[s])?"":t("span",{class:"s-user-menu-dropdown-item-badge"},this.badges[s])))}componentShouldUpdate(){this.opened||window.removeEventListener("click",this.onClickOutside)}render(){return t(i,null,this.is_loggedIn?this.inline?t("ul",{class:"s-user-menu-inline"},Object.entries(this.items).map(((s,t)=>this.getMenuItem(s,t)))):t("div",{class:{"s-user-menu-wrapper":!0,"s-user-menu-relative-dropdown":this.relativeDropdown}},this.getTheHeader(),t("div",{class:{"s-user-menu-toggler":!0,opened:this.opened}},t("div",{class:"s-user-menu-dropdown",onClick:s=>s.stopPropagation(),onKeyUp:s=>s.stopPropagation()},this.showHeader?t("div",{class:"s-user-menu-dropdown-header"},t("img",{src:this.avatar,alt:`${this.first_name} ${this.last_name}`}),t("div",{class:"s-user-menu-dropdown-header-content"},t("span",null,this.hello),t("p",null,this.first_name," ",this.last_name)),t("button",{type:"button",class:"s-user-menu-dropdown-header-close",innerHTML:r,onClick:()=>{this.opened=!1}})):"",t("ul",{class:"s-user-menu-dropdown-list"},Object.entries(this.items).map(((s,t)=>this.getMenuItem(s,t))))))):t("slot",{name:"login-btn"},t("button",{type:"button",class:"s-user-menu-login-btn",onClick:()=>salla.event.dispatch("login::open"),innerHTML:m})))}async componentDidLoad(){await Salla.hooks.registerComponent("salla-user-menu",this),document.lazyLoadInstance?.update(this.host.querySelectorAll(".lazy"))}buildProfileUrl(s){return`${Salla.config.get("account.url","https://accounts.salla.com")}/${salla.config.get("user.language_code")}/user?store=${Salla.config.get("store.id")}&info=${encodeURIComponent(s)}`}get host(){return l(this)}};u.style="";export{u as salla_user_menu}
|
|
4
|
+
import{r as s,h as t,H as i,a as l}from"./p-CJNSdTHZ.js";import{A as e}from"./p-DCZbpt2a.js";import{B as a}from"./p-D3mWkc-3.js";import{P as n}from"./p-DY4LZmNP.js";import{S as o}from"./p-CeFAfcTv.js";import{S as r}from"./p-8Tsmrwno.js";import{S as h}from"./p-D4oPi1Ov.js";import{S as c}from"./p-CXRKXFgT.js";var m='\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-circle</title>\n<path d="M16 22.964c-4.525 0-8.447 1.713-9.993 4.365-0.371 0.636-0.156 1.452 0.48 1.823s1.453 0.156 1.823-0.48c0.855-1.465 3.624-3.041 7.689-3.041s6.835 1.576 7.689 3.041c0.249 0.424 0.696 0.661 1.155 0.661 0.228 0 0.459-0.059 0.669-0.181 0.637-0.371 0.852-1.187 0.48-1.823-1.545-2.652-5.467-4.365-9.992-4.365zM22.667 13.631c0-3.676-2.991-6.667-6.667-6.667s-6.667 2.991-6.667 6.667 2.991 6.667 6.667 6.667 6.667-2.992 6.667-6.667zM12 13.631c0-2.205 1.795-4 4-4s4 1.795 4 4-1.795 4-4 4-4-1.795-4-4zM16 0.297c-8.823 0-16 7.177-16 16 0 2.941 0.821 5.831 2.373 8.357 0.252 0.411 0.689 0.636 1.137 0.636 0.239 0 0.479-0.064 0.696-0.197 0.628-0.385 0.824-1.207 0.439-1.833-1.295-2.108-1.979-4.516-1.979-6.963 0-7.352 5.981-13.333 13.333-13.333s13.333 5.981 13.333 13.333c0 2.448-0.684 4.856-1.979 6.961-0.385 0.628-0.189 1.448 0.437 1.835 0.627 0.384 1.448 0.189 1.835-0.437 1.553-2.527 2.373-5.416 2.373-8.359 0-8.823-7.177-16-16-16z"></path>\n</svg>\n';const u=class{constructor(t){s(this,t),this.accountLoading=!1,this.opened=!1,this.notifications=salla.lang.get("common.titles.notifications"),this.orders=salla.lang.get("common.titles.orders"),this.pending_orders=salla.lang.get("common.titles.pending_orders"),this.wishlist=salla.lang.get("common.titles.wishlist"),this.profile=salla.lang.get("common.titles.profile"),this.rating=salla.lang.get("common.titles.rating"),this.wallet=salla.lang.get("common.titles.wallet"),this.settings=salla.lang.get("common.titles.settings"),this.loyalty_points=salla.lang.get("pages.loyalty_program.loyalty_points"),this.logout=salla.lang.get("blocks.header.logout"),this.hello=salla.lang.get("pages.checkout.hello"),this.first_name=salla.storage.get("user.first_name")||"",this.last_name=salla.storage.get("user.last_name")||"",this.avatar=salla.storage.get("user.avatar")||salla.url.cdn("images/avatar.png",40,40),this.badges={notifications:salla.helpers.number(salla.storage.get("user.notifications")||0),pending_orders:salla.helpers.number(salla.storage.get("user.pending_orders")||0)},this.sallaAccountEnabled=!1,this.walletBalance="",this.walletBalanceLoading=!1,this.walletBalanceLoaded=!1,this.hasBadges=Number(salla.storage.get("user.pending_orders"))>0||Number(salla.storage.get("user.notifications"))>0,this.inline=!1,this.avatarOnly=!1,this.showHeader=!1,this.relativeDropdown=!1,this.showTrigger=!1,this.onClickOutside=()=>{this.opened=!1},this.OrderUpdate=0,this.accountPrefixedKeys=["orders","pending_orders","wallet","notifications","rating","profile","wishlist","settings"],this.items={notifications:a,orders:'\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>box-bankers</title>\n<path d="M28 1.333h-24c-2.205 0-4 1.795-4 4v5.333c0 0.736 0.597 1.333 1.333 1.333v14.667c0 2.205 1.795 4 4 4h21.333c2.205 0 4-1.795 4-4v-14.667c0.736 0 1.333-0.597 1.333-1.333v-5.333c0-2.205-1.795-4-4-4zM28 26.667c0 0.735-0.599 1.333-1.333 1.333h-21.333c-0.735 0-1.333-0.599-1.333-1.333v-14.667h5.333v2.667c0 1.471 1.196 2.667 2.667 2.667h8c1.471 0 2.667-1.196 2.667-2.667v-2.667h5.333zM12 14.667v-2.667h8v2.667zM29.333 9.333h-26.667v-4c0-0.735 0.599-1.333 1.333-1.333h24c0.735 0 1.333 0.599 1.333 1.333z"></path>\n</svg>\n',pending_orders:n,wishlist:o,wallet:'\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>wallet</title>\n<path d="M28 6.667h-24c-0.736 0-1.333-0.597-1.333-1.333s0.597-1.333 1.333-1.333h24c0.737 0 1.333-0.596 1.333-1.333s-0.596-1.333-1.333-1.333h-24c-2.204 0-3.999 1.793-4 3.997v18.669c0 3.676 2.991 6.667 6.667 6.667h21.333c2.205 0 4-1.795 4-4v-16c0-2.205-1.795-4-4-4zM29.333 26.667c0 0.736-0.597 1.333-1.333 1.333h-21.333c-2.205 0-4-1.795-4-4v-14.895c0.416 0.147 0.865 0.228 1.333 0.228h24c0.736 0 1.333 0.597 1.333 1.333zM22.667 14.667c-2.205 0-4 1.795-4 4s1.795 4 4 4 4-1.795 4-4-1.795-4-4-4zM22.667 20c-0.736 0-1.333-0.597-1.333-1.333s0.597-1.333 1.333-1.333 1.333 0.597 1.333 1.333-0.597 1.333-1.333 1.333z"></path>\n</svg>\n',loyalty_points:c,profile:m}}async componentWillLoad(){await salla.onReady(),await salla.lang.onLoaded(),this.loadTranslations(),this.initiate(),Salla.event.on("api::token.injected",(s=>this.profileUrl=this.buildProfileUrl(s))),this.sallaAccountEnabled=Salla.config.get("store.features")?.includes("salla-account"),this.items=this.sallaAccountEnabled?{...this.items,settings:'\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>settings</title>\n<path d="M29.717 19.037l-1.817-1.499c0.067-0.512 0.1-1.028 0.1-1.539s-0.033-1.027-0.1-1.54l1.817-1.499c1.177-0.969 1.479-2.633 0.716-3.956l-1.159-2.009c-0.761-1.324-2.349-1.895-3.784-1.359l-2.212 0.829c-0.817-0.627-1.704-1.139-2.649-1.535l-0.388-2.332c-0.251-1.507-1.54-2.6-3.067-2.6h-2.319c-1.525 0-2.815 1.093-3.065 2.6l-0.388 2.332c-0.945 0.396-1.833 0.909-2.649 1.535l-2.212-0.829c-1.428-0.533-3.021 0.036-3.783 1.359l-1.16 2.011c-0.763 1.323-0.46 2.985 0.716 3.955l1.817 1.499c-0.067 0.513-0.1 1.029-0.1 1.54s0.033 1.027 0.1 1.539l-1.819 1.5c-1.176 0.971-1.476 2.635-0.715 3.955l1.159 2.011c0.763 1.324 2.356 1.899 3.784 1.36l2.212-0.831c0.816 0.625 1.703 1.139 2.649 1.535l0.388 2.332c0.251 1.507 1.54 2.6 3.067 2.6h2.319c1.527 0 2.816-1.093 3.065-2.6l0.389-2.332c0.947-0.396 1.833-0.909 2.649-1.535l2.212 0.831c1.432 0.539 3.023-0.035 3.783-1.36l1.16-2.011c0.76-1.32 0.459-2.984-0.717-3.956zM28.123 21.663l-1.16 2.011c-0.108 0.188-0.336 0.267-0.536 0.193l-2.931-1.1c-0.459-0.173-0.979-0.079-1.349 0.248-0.923 0.811-1.979 1.423-3.139 1.819-0.464 0.157-0.804 0.559-0.885 1.043l-0.515 3.087c-0.033 0.215-0.216 0.371-0.433 0.371h-2.319c-0.217 0-0.4-0.156-0.436-0.371l-0.513-3.087c-0.080-0.484-0.42-0.884-0.885-1.043-1.16-0.396-2.216-1.008-3.139-1.819-0.248-0.217-0.561-0.332-0.88-0.332-0.157 0-0.316 0.028-0.469 0.084l-2.931 1.1c-0.199 0.079-0.428-0.004-0.537-0.193l-1.159-2.011c-0.109-0.191-0.067-0.428 0.101-0.568l2.409-1.985c0.379-0.312 0.555-0.807 0.46-1.288-0.119-0.605-0.179-1.219-0.179-1.821 0-0.604 0.060-1.217 0.181-1.823 0.095-0.481-0.081-0.976-0.46-1.288l-2.409-1.985c-0.168-0.139-0.211-0.376-0.101-0.567l1.16-2.011c0.107-0.188 0.332-0.268 0.536-0.193l2.931 1.1c0.459 0.172 0.979 0.079 1.348-0.247 0.924-0.812 1.98-1.424 3.139-1.817 0.465-0.159 0.805-0.559 0.885-1.044l0.513-3.088c0.036-0.215 0.219-0.371 0.436-0.371h2.319c0.217 0 0.4 0.156 0.436 0.371l0.515 3.088c0.081 0.484 0.42 0.885 0.885 1.044 1.157 0.393 2.213 1.005 3.139 1.817 0.371 0.325 0.889 0.42 1.349 0.247l2.929-1.099c0.203-0.076 0.428 0.005 0.537 0.193l1.159 2.009c0.109 0.191 0.067 0.428-0.101 0.567l-2.409 1.985c-0.379 0.312-0.555 0.807-0.46 1.288 0.119 0.605 0.179 1.219 0.179 1.823 0 0.603-0.060 1.216-0.181 1.821-0.095 0.48 0.081 0.975 0.46 1.288l2.408 1.984c0.169 0.141 0.212 0.379 0.103 0.569zM16.016 10.667c-2.941 0-5.333 2.392-5.333 5.333s2.392 5.333 5.333 5.333 5.333-2.392 5.333-5.333-2.392-5.333-5.333-5.333zM16.016 18.667c-1.471 0-2.667-1.196-2.667-2.667s1.196-2.667 2.667-2.667 2.667 1.196 2.667 2.667-1.196 2.667-2.667 2.667z"></path>\n</svg>\n'}:this.items,this.host.hasAttribute("with-rating")&&(this.items.rating=h),this.items.logout='\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>send-out</title>\n<path d="M16 26.667h-9.333c-0.736 0-1.333-0.597-1.333-1.333v-18.667c0-0.736 0.597-1.333 1.333-1.333h9.333c0.737 0 1.333-0.596 1.333-1.333s-0.596-1.333-1.333-1.333h-9.333c-2.205 0-4 1.795-4 4v18.667c0 2.205 1.795 4 4 4h9.333c0.737 0 1.333-0.596 1.333-1.333s-0.596-1.333-1.333-1.333zM29.231 15.491c-0.068-0.164-0.167-0.312-0.289-0.436l-5.332-5.332c-0.521-0.521-1.364-0.521-1.885 0s-0.521 1.364 0 1.885l3.057 3.059h-12.781c-0.737 0-1.333 0.596-1.333 1.333s0.596 1.333 1.333 1.333h12.781l-3.057 3.057c-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.391l5.332-5.332c0.124-0.123 0.221-0.271 0.289-0.435 0.135-0.325 0.135-0.693 0-1.019z"></path>\n</svg>\n';let s=Salla.storage.get("token");s||(s=""),this.profileUrl=this.buildProfileUrl(s);const t=this.host.querySelector('[slot="trigger"]');this.triggerSlot='<div class="s-user-menu-trigger"><div class="s-user-menu-avatar-wrap"><img class="s-user-menu-trigger-avatar" src="{avatar}" alt="{first_name}{last_name}" /></div><div class="s-user-menu-trigger-content"><span class="s-user-menu-trigger-hello">{hello}</span><p class="s-user-menu-trigger-name">{first_name} {last_name}</p></div> <i class="s-user-menu-trigger-icon">{icon}</i></div>',t&&(this.triggerSlot=t.innerHTML,t.innerHTML=this.replaceParams(t.innerHTML))}loadTranslations(){this.notifications=Salla.lang.get("common.titles.notifications"),this.orders=Salla.lang.get("common.titles.orders"),this.pending_orders=Salla.lang.get("common.titles.pending_orders"),this.wishlist=Salla.lang.get("common.titles.wishlist"),this.profile=Salla.lang.get("common.titles.profile"),this.hello=Salla.lang.get("pages.checkout.hello"),this.rating=Salla.lang.get("common.titles.rating"),this.wallet=Salla.lang.get("common.titles.wallet"),this.settings=Salla.lang.get("common.titles.settings"),this.loyalty_points=Salla.lang.get("pages.loyalty_program.loyalty_points"),this.logout=Salla.lang.get("blocks.header.logout")}async loadWalletBalance(){if(!Salla.config.isGuest()){this.walletBalanceLoading=!0;try{const s=await salla.api.withoutNotifier((()=>salla.api.request("/balance/wallet?light=1"))),t=Number(s?.data?.balance)||0;this.walletBalance=t?Salla.money({amount:Number(t.toFixed(2)),currency:Salla.config.get("user.currency_code")}):"",this.walletBalanceLoaded=!0}catch{}finally{this.walletBalanceLoading=!1}}}initiate(){return Salla.config.isGuest()?this.autoMountLoginModal():(this.is_loggedIn=!0,!this.inline&&(salla.url.is_page("customer.notifications")||salla.url.is_page("customer.orders.index.pending")||salla.url.is_page("customer.profile")||(Date.now()-(salla.storage.get("user.fetched_at")||0))/1e3/60>30)?this.fetchFreshProfile():void salla.event.on("profile::info.fetched",(s=>{this.updateProfileState(s)})))}autoMountLoginModal(){this.showTrigger&&(document.querySelector("salla-login-modal")||Salla.hooks.mount("body:end",document.createElement("salla-login-modal")))}fetchFreshProfile(){salla.api.token?salla.profile.api.info().then((s=>{this.updateProfileState(s)})):salla.log("trying to fetchFreshProfile before injected the token!!")}updateProfileState(s){this.badges={notifications:salla.helpers.number(s.data.notifications||0),pending_orders:salla.helpers.number(s.data.pending_orders||0)},this.hasBadges=Number(s.data.pending_orders)>0||Number(s.data.notifications)>0,this.first_name=s.data.first_name,this.last_name=s.data.last_name,this.avatar=s.data.avatar||salla.url.cdn("images/avatar.png",40,40)}async open(s){this.opened=!this.opened,s.stopPropagation(),this.opened&&(!window.can_access_wallet||this.walletBalanceLoaded||this.walletBalanceLoading||this.loadWalletBalance(),window.addEventListener("click",this.onClickOutside))}menuItemClicked(s,t){"logout"===t&&(s.preventDefault(),salla.auth.logout("sall-user-menu"))}replaceParams(s){return s.replace(/\{hello\}/g,this.hello).replace(/\{first_name\}/g,this.first_name).replace(/\{last_name\}/g,this.last_name).replace(/\{avatar\}/g,this.avatar).replace(/\{icon\}/g,e)}getTheHeader(){return t("div",{class:{"s-user-menu-trigger-slot":!0,"s-user-menu-red-dot":this.hasBadges,"s-user-menu-trigger-avatar-only":this.avatarOnly},id:"trigger-slot",onClick:s=>this.open(s),onKeyUp:s=>this.open(s),innerHTML:this.replaceParams(this.triggerSlot)})}getItemAnchorLinkAttrs(s){if("profile"===s&&this.profileUrl&&this.sallaAccountEnabled)return{href:this.profileUrl,target:"_blank",rel:"noopener noreferrer"};const t="loyalty_points"===s?"loyalty":s,i=this.accountPrefixedKeys.includes(t)?`account/${t}`:t;return{href:Salla.url.get(i)}}getMenuItem([s,i],l){if(("wallet"!==s||window.can_access_wallet)&&("loyalty_points"!==s||Salla.config.get("store.features").includes("loyalty-system")))return t("li",{class:{"s-user-menu-dropdown-item":!0,"s-user-menu-dropdown-item-logout":l+1===Object.entries(this.items).length}},t("a",{...this.getItemAnchorLinkAttrs(s),class:"s-user-menu-dropdown-item-link",onClick:t=>this.menuItemClicked(t,s)},t("i",{class:"s-user-menu-dropdown-item-prefix",innerHTML:i}),t("span",{class:"s-user-menu-dropdown-item-title"},this[s]),"wallet"!==s||this.inline||!this.walletBalance&&!this.walletBalanceLoading?"":t("span",{class:"s-user-menu-dropdown-item-balance",style:{display:"inline-flex",alignItems:"center",gap:"4px"}},this.walletBalance?t("span",{innerHTML:this.walletBalance}):"",this.walletBalanceLoading?t("salla-loading",{size:"14"}):""),["٠","0",void 0].includes(this.badges[s])?"":t("span",{class:"s-user-menu-dropdown-item-badge"},this.badges[s])))}componentShouldUpdate(){this.opened||window.removeEventListener("click",this.onClickOutside)}render(){return t(i,null,this.is_loggedIn?this.inline?t("ul",{class:"s-user-menu-inline"},Object.entries(this.items).map(((s,t)=>this.getMenuItem(s,t)))):t("div",{class:{"s-user-menu-wrapper":!0,"s-user-menu-relative-dropdown":this.relativeDropdown}},this.getTheHeader(),t("div",{class:{"s-user-menu-toggler":!0,opened:this.opened}},t("div",{class:"s-user-menu-dropdown",onClick:s=>s.stopPropagation(),onKeyUp:s=>s.stopPropagation()},this.showHeader?t("div",{class:"s-user-menu-dropdown-header"},t("img",{src:this.avatar,alt:`${this.first_name} ${this.last_name}`}),t("div",{class:"s-user-menu-dropdown-header-content"},t("span",null,this.hello),t("p",null,this.first_name," ",this.last_name)),t("button",{type:"button",class:"s-user-menu-dropdown-header-close",innerHTML:r,onClick:()=>{this.opened=!1}})):"",t("ul",{class:"s-user-menu-dropdown-list"},Object.entries(this.items).map(((s,t)=>this.getMenuItem(s,t))))))):t("slot",{name:"login-btn"},t("button",{type:"button",class:"s-user-menu-login-btn",onClick:()=>salla.event.dispatch("login::open"),innerHTML:m})))}async componentDidLoad(){await Salla.hooks.registerComponent("salla-user-menu",this),document.lazyLoadInstance?.update(this.host.querySelectorAll(".lazy"))}buildProfileUrl(s){return`${Salla.config.get("account.url","https://accounts.salla.com")}/${salla.config.get("user.language_code")}/user?store=${Salla.config.get("store.id")}&info=${encodeURIComponent(s)}`}get host(){return l(this)}};u.style="";export{u as salla_user_menu}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
import{r as e,c as d,h as t,H as r}from"./p-CJNSdTHZ.js";const c=class{constructor(t){e(this,t),this.orderEditProductSelected=d(this,"orderEditProductSelected")}get productData(){if(!this.product)return{};if("object"==typeof this.product)return this.product;try{return JSON.parse(this.product)}catch(e){return{}}}handleSelectProduct(){this.orderEditProductSelected.emit({product:this.productData})}render(){const e=this.productData,d=e?.name||salla.lang.getWithDefault("common.elements.product","منتج"),c=e?.price;return t(r,{key:"7669432a4756da446e16d9a3093a067767c5dd9d"},t("button",{key:"d998dde2a1dc4eae7444fd398910c3a0699730f8",type:"button",class:"s-order-edit-product-card",onClick:()=>this.handleSelectProduct()},t("div",{key:"6a0e6eec84de332598d94be87b49564eeb2cfbc2",class:"s-order-edit-product-card-media"},e?.image?.url?t("img",{src:e.image.url,alt:e.image.alt||d,class:"s-order-edit-product-card-image"}):t("div",{class:"s-order-edit-product-card-placeholder"},t("i",{class:"sicon-shopping-bag"}))),t("div",{key:"4eeb9f7430c19f8e792b0f6856fb86a2f265eb95",class:"s-order-edit-product-card-content"},t("h3",{key:"840ae549097a53f1f297673d69e3155792a4097e",class:"s-order-edit-product-card-title"},d),null!=c&&t("p",{key:"32732854ca599fe446d0b47883b892ac17d90cae",class:"s-order-edit-product-card-price",innerHTML:salla.money(c)}))))}};c.style=":host{display:block;min-width:0}";export{c as salla_order_edit_product_card}
|
|
@@ -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-
|
|
4
|
+
import{r as c,h as l,H as t,a as s}from"./p-CJNSdTHZ.js";import{f as e,t as i}from"./p-CO-PeZ27.js";const a=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:"e7d69dbae46ef54588471875ada751103d14d393"},l("ul",{key:"ff4b15127e6664cca17fa7f6f49e4cda25829d74",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)}};a.style=":host{display:block}";export{a as salla_social}
|