@salla.sa/twilight-components 2.14.353 → 2.14.355
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/bell-ring-BfKPinNo.js +13 -0
- package/dist/cjs/{interfaces-CX9-6aLf.js → camera-DytepEoK.js} +0 -11
- package/dist/cjs/cancel-De6vslRA.js +13 -0
- package/dist/cjs/cart-s-x1Fshk.js +13 -0
- package/dist/cjs/check-circle2-BDvlT4_n.js +13 -0
- package/dist/cjs/{check-CLRvuniI.js → check-x3w3-gpj.js} +2 -2
- package/dist/cjs/{filepond-7SxqaoXb.js → filepond-D0WqQOsJ.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-DwIv84hN.js → filepond-plugin-file-poster-ZuSz5Sia.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-NUNnIo4Q.js → filepond-plugin-file-validate-size-C3-G9fQU.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-CXI-hfww.js → filepond-plugin-file-validate-type-pC6E-hQQ.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-fBeBGIBb.js → filepond-plugin-image-edit-B6RJ-sf_.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-BmLTdQ6d.js → filepond-plugin-image-exif-orientation-BAKA7TOr.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-CssKRM6n.js → filepond-plugin-image-preview-C_5JV3u4.js} +1 -1
- package/dist/{esm/gift-C0JNGIpa.js → cjs/gift-CJ-3Yw_x.js} +4 -2
- package/dist/cjs/image-BoZ6Hums.js +13 -0
- package/dist/cjs/{index-B9TEdQDE.js → index-DdedaQQE.js} +1 -1
- package/dist/cjs/{index-B5soIVRX.js → index-DgOViweO.js} +136 -12
- package/dist/cjs/interfaces-CRqrf5RX.js +15 -0
- package/dist/cjs/keyboard_arrow_down-DHJ3FFZq.js +13 -0
- package/dist/cjs/keyboard_arrow_right-BayM_Il2.js +21 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/minus-CCryh1qf.js +21 -0
- package/dist/cjs/salla-accordion-body_3.cjs.entry.js +775 -0
- package/dist/cjs/salla-accordion_6.cjs.entry.js +768 -0
- package/dist/cjs/salla-add-product-button_4.cjs.entry.js +2389 -0
- package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
- package/dist/cjs/salla-alert_2.cjs.entry.js +194 -0
- package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-apps-icons.cjs.entry.js +2 -2
- package/dist/cjs/salla-booking-field_7.cjs.entry.js +1565 -0
- package/dist/cjs/{salla-cart-item-offers.cjs.entry.js → salla-cart-item-offers_2.cjs.entry.js} +104 -5
- package/dist/cjs/salla-comment-form_8.cjs.entry.js +1661 -0
- package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-contacts.cjs.entry.js +3 -3
- package/dist/cjs/salla-count-down_2.cjs.entry.js +302 -0
- package/dist/cjs/salla-custom-fields.cjs.entry.js +4 -3
- 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-gifting.cjs.entry.js +488 -0
- package/dist/cjs/salla-hook.cjs.entry.js +1 -1
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +91 -0
- package/dist/cjs/salla-installment.cjs.entry.js +1 -1
- package/dist/cjs/salla-list-tile.cjs.entry.js +34 -0
- package/dist/cjs/salla-localization-modal.cjs.entry.js +137 -0
- package/dist/cjs/salla-login-modal.cjs.entry.js +320 -0
- 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.cjs.entry.js +211 -0
- package/dist/cjs/salla-maintenance-alert.cjs.entry.js +40 -0
- package/dist/cjs/salla-menu.cjs.entry.js +139 -0
- package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +220 -0
- package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +598 -0
- package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +69 -0
- 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 +206 -0
- package/dist/cjs/salla-offer.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-summary.cjs.entry.js +3 -3
- 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 +6 -18
- package/dist/cjs/salla-placeholder.cjs.entry.js +51 -0
- package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
- package/dist/cjs/salla-product-size-guide.cjs.entry.js +66 -0
- package/dist/cjs/salla-products-list.cjs.entry.js +762 -0
- package/dist/cjs/salla-products-slider.cjs.entry.js +115 -0
- package/dist/cjs/salla-progress-bar.cjs.entry.js +73 -0
- package/dist/cjs/salla-quick-order.cjs.entry.js +239 -0
- package/dist/cjs/salla-rating-modal.cjs.entry.js +453 -0
- package/dist/cjs/salla-scopes.cjs.entry.js +180 -0
- package/dist/cjs/salla-search.cjs.entry.js +153 -0
- package/dist/cjs/salla-skeleton.cjs.entry.js +36 -0
- package/dist/cjs/salla-slider.cjs.entry.js +10428 -0
- package/dist/cjs/salla-social-share.cjs.entry.js +165 -0
- package/dist/cjs/salla-social.cjs.entry.js +4 -4
- package/dist/cjs/salla-tab-content_3.cjs.entry.js +157 -0
- package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-tooltip.cjs.entry.js +2 -2
- package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-menu.cjs.entry.js +275 -0
- package/dist/cjs/salla-user-profile.cjs.entry.js +145 -0
- package/dist/cjs/salla-user-settings.cjs.entry.js +88 -0
- package/dist/cjs/salla-verify.cjs.entry.js +1 -1
- package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
- package/dist/cjs/search-c7Aa7lM9.js +13 -0
- package/dist/cjs/{special-discount-OVG_9Kf9.js → special-discount-DC2oXurL.js} +0 -8
- package/dist/cjs/star-DGcH7Yso.js +13 -0
- package/dist/cjs/star2-R146a27p.js +13 -0
- package/dist/cjs/twilight.cjs.js +2 -2
- package/dist/cjs/{vanilla-picker-C6fk8_TR.js → vanilla-picker-Cd4v7i9t.js} +1 -1
- package/dist/cjs/{whatsapp2-D7Sbg8Ey.js → whatsapp2-BdMd5Gx1.js} +2 -2
- package/dist/collection/collection-manifest.json +56 -2
- package/dist/collection/components/salla-apps-icons/salla-apps-icons.js +1 -1
- package/dist/collection/components/salla-payments/salla-payments.js +5 -17
- package/dist/collection/components/salla-product-options/salla-product-options.js +36 -3
- package/dist/collection/components/salla-products-slider/salla-products-slider.js +32 -1
- package/dist/collection/components/salla-slider/salla-slider.js +89 -29
- package/dist/collection/components/salla-social/salla-social.js +1 -1
- package/dist/collection/components/salla-social-share/salla-social-share.js +1 -1
- package/dist/collection/components/salla-tabs/salla-tab-content.js +1 -1
- package/dist/collection/components/salla-tabs/salla-tab-header.js +1 -1
- package/dist/collection/components/salla-tabs/salla-tabs.js +1 -1
- package/dist/collection/components/salla-tel-input/salla-tel-input.js +1 -1
- package/dist/collection/components/salla-tooltip/salla-tooltip.js +1 -1
- package/dist/collection/components/salla-user-settings/salla-user-settings.js +1 -1
- package/dist/components/index.js +2 -2
- package/dist/components/salla-apps-icons.js +1 -1
- package/dist/components/salla-payments.js +5 -17
- package/dist/components/salla-product-options2.js +19 -2
- package/dist/components/salla-products-slider2.js +2 -1
- package/dist/components/salla-slider2.js +69 -28
- package/dist/components/salla-social-share.js +1 -1
- package/dist/components/salla-social.js +1 -1
- package/dist/components/salla-tab-content2.js +1 -1
- package/dist/components/salla-tab-header2.js +1 -1
- package/dist/components/salla-tabs2.js +1 -1
- package/dist/components/salla-tel-input2.js +1 -1
- package/dist/components/salla-tooltip2.js +1 -1
- package/dist/components/salla-user-settings.js +1 -1
- package/dist/esm/bell-ring-D3mWkc-3.js +11 -0
- package/dist/esm/{interfaces-CBT_Nxny.js → camera-C6jIkM-X.js} +1 -12
- package/dist/esm/cancel-BsLF_HK7.js +11 -0
- package/dist/esm/cart-DY4LZmNP.js +11 -0
- package/dist/esm/{check-uTyAzPSy.js → check-BsXh13x8.js} +2 -2
- package/dist/esm/check-circle2-BV4kqbdL.js +11 -0
- package/dist/esm/{filepond-Cuqyleyy.js → filepond-YrJ-JCRn.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-C6Wara8q.js → filepond-plugin-file-poster-UWiXxhAl.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-D-M3KSxo.js → filepond-plugin-file-validate-size-CuFnfvIq.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-DzAl1VI8.js → filepond-plugin-file-validate-type-BgYsHZEQ.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-flutfc9I.js → filepond-plugin-image-edit-BQtZWl9D.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-B2UkG6iE.js → filepond-plugin-image-exif-orientation-Dp7a5KRi.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-B4u8N2nE.js → filepond-plugin-image-preview-DvWrR7vg.js} +1 -1
- package/dist/{cjs/gift-BPDUPIY_.js → esm/gift-BChI23pG.js} +2 -4
- package/dist/esm/image-C-tzSDxw.js +11 -0
- package/dist/esm/{index-xWIb6INF.js → index-DwU5NnFF.js} +1 -1
- package/dist/esm/{index-6mr785rH.js → index-PHxPq4LJ.js} +137 -13
- package/dist/esm/interfaces-OF8QcbMM.js +15 -0
- package/dist/esm/keyboard_arrow_down-DCZbpt2a.js +11 -0
- package/dist/esm/keyboard_arrow_right-Vqpj4CWE.js +18 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/minus-DfeagqF1.js +18 -0
- package/dist/esm/salla-accordion-body_3.entry.js +771 -0
- package/dist/esm/salla-accordion_6.entry.js +761 -0
- package/dist/esm/salla-add-product-button_4.entry.js +2384 -0
- package/dist/esm/salla-advertisement.entry.js +1 -1
- package/dist/esm/salla-alert_2.entry.js +191 -0
- package/dist/esm/salla-app-install-alert.entry.js +1 -1
- package/dist/esm/salla-apps-icons.entry.js +2 -2
- package/dist/esm/salla-booking-field_7.entry.js +1539 -0
- package/dist/esm/{salla-cart-item-offers.entry.js → salla-cart-item-offers_2.entry.js} +104 -6
- package/dist/esm/salla-comment-form_8.entry.js +1652 -0
- package/dist/esm/salla-conditional-offer.entry.js +1 -1
- package/dist/esm/salla-contacts.entry.js +3 -3
- package/dist/esm/salla-count-down_2.entry.js +299 -0
- package/dist/esm/salla-custom-fields.entry.js +3 -2
- package/dist/esm/salla-filters-widget.entry.js +1 -1
- package/dist/esm/salla-filters.entry.js +1 -1
- package/dist/esm/salla-gifting.entry.js +486 -0
- package/dist/esm/salla-hook.entry.js +1 -1
- package/dist/esm/salla-infinite-scroll.entry.js +89 -0
- package/dist/esm/salla-installment.entry.js +1 -1
- package/dist/esm/salla-list-tile.entry.js +32 -0
- package/dist/esm/salla-localization-modal.entry.js +135 -0
- package/dist/esm/salla-login-modal.entry.js +318 -0
- 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.entry.js +209 -0
- package/dist/esm/salla-maintenance-alert.entry.js +38 -0
- package/dist/esm/salla-menu.entry.js +137 -0
- package/dist/esm/salla-metadata.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +217 -0
- package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +595 -0
- package/dist/esm/salla-multiple-bundle-product.entry.js +67 -0
- 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 +204 -0
- package/dist/esm/salla-offer.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-summary.entry.js +3 -3
- 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 +6 -18
- package/dist/esm/salla-placeholder.entry.js +49 -0
- package/dist/esm/salla-price-range.entry.js +1 -1
- package/dist/esm/salla-product-size-guide.entry.js +64 -0
- package/dist/esm/salla-products-list.entry.js +760 -0
- package/dist/esm/salla-products-slider.entry.js +113 -0
- package/dist/esm/salla-progress-bar.entry.js +71 -0
- package/dist/esm/salla-quick-order.entry.js +237 -0
- package/dist/esm/salla-rating-modal.entry.js +451 -0
- package/dist/esm/salla-scopes.entry.js +178 -0
- package/dist/esm/salla-search.entry.js +151 -0
- package/dist/esm/salla-skeleton.entry.js +34 -0
- package/dist/esm/salla-slider.entry.js +10426 -0
- package/dist/esm/salla-social-share.entry.js +163 -0
- package/dist/esm/salla-social.entry.js +3 -3
- package/dist/esm/salla-tab-content_3.entry.js +153 -0
- package/dist/esm/salla-tiered-offer.entry.js +1 -1
- package/dist/esm/salla-tooltip.entry.js +2 -2
- package/dist/esm/salla-trust-badges.entry.js +1 -1
- package/dist/esm/salla-user-menu.entry.js +273 -0
- package/dist/esm/salla-user-profile.entry.js +143 -0
- package/dist/esm/salla-user-settings.entry.js +86 -0
- package/dist/esm/salla-verify.entry.js +1 -1
- package/dist/esm/salla-wallet.entry.js +1 -1
- package/dist/esm/search-BscTeWDc.js +11 -0
- package/dist/esm/{special-discount-yRO-ZESF.js → special-discount-Ctkfc4K-.js} +1 -8
- package/dist/esm/star-ZT7ehBBk.js +11 -0
- package/dist/esm/star2-D4oPi1Ov.js +11 -0
- package/dist/esm/twilight.js +3 -3
- package/dist/esm/{vanilla-picker-B4PKRAhm.js → vanilla-picker-fpTcpsmb.js} +1 -1
- package/dist/esm/{whatsapp2-DWksgowB.js → whatsapp2-CgR-T_ZS.js} +2 -2
- package/dist/twilight/p-009d1b75.entry.js +4 -0
- package/dist/twilight/{p-16b8d78c.entry.js → p-04e21492.entry.js} +1 -1
- package/dist/twilight/{p-ac6fc286.entry.js → p-0cc07ad0.entry.js} +1 -1
- package/dist/twilight/p-0f45b27f.entry.js +4 -0
- package/dist/twilight/p-112b4c91.entry.js +4 -0
- package/dist/twilight/p-14749ab0.entry.js +4 -0
- package/dist/twilight/{p-0c87ef6c.entry.js → p-1c66e567.entry.js} +1 -1
- package/dist/twilight/p-1e405d4e.entry.js +4 -0
- package/dist/twilight/{p-33ea3141.entry.js → p-1eb76272.entry.js} +1 -1
- package/dist/twilight/p-2322e6fc.entry.js +4 -0
- package/dist/twilight/{p-7e39343d.entry.js → p-2626b358.entry.js} +1 -1
- package/dist/twilight/{p-18ebec2c.entry.js → p-29e92637.entry.js} +1 -1
- package/dist/twilight/p-2ca5a8af.entry.js +4 -0
- package/dist/twilight/{p-4253fc44.entry.js → p-2cb04fa6.entry.js} +1 -1
- package/dist/twilight/{p-19e07b9e.entry.js → p-2e97a6cd.entry.js} +1 -1
- package/dist/twilight/{p-zHj-W7EE.js → p-2tEKDOI-.js} +1 -1
- package/dist/twilight/p-30b58124.entry.js +4 -0
- package/dist/twilight/{p-8c7b7712.entry.js → p-333171ce.entry.js} +1 -1
- package/dist/twilight/p-33cd8edb.entry.js +4 -0
- package/dist/twilight/p-3774fa61.entry.js +4 -0
- package/dist/twilight/{p-5067322a.entry.js → p-37aa131b.entry.js} +1 -1
- package/dist/twilight/{p-dde21f4b.entry.js → p-3c76e2d4.entry.js} +1 -1
- package/dist/twilight/{p-2d209f96.entry.js → p-3cbbd625.entry.js} +1 -1
- package/dist/twilight/{p-6f5d02c6.entry.js → p-3db132b8.entry.js} +1 -1
- package/dist/twilight/p-3eff2372.entry.js +4 -0
- package/dist/twilight/p-428fe4e6.entry.js +4 -0
- package/dist/twilight/p-475a61f8.entry.js +4 -0
- package/dist/twilight/{p-BijadG7g.js → p-4D4VVK4U.js} +1 -1
- package/dist/twilight/p-4c31b81f.entry.js +4 -0
- package/dist/twilight/{p-c096e336.entry.js → p-52ffcaba.entry.js} +1 -1
- package/dist/twilight/p-534be529.entry.js +4 -0
- package/dist/twilight/p-59697c9b.entry.js +4 -0
- package/dist/twilight/p-5c5aba15.entry.js +4 -0
- package/dist/twilight/p-666bea2d.entry.js +4 -0
- package/dist/twilight/p-6a934903.entry.js +4 -0
- package/dist/twilight/{p-6f576591.entry.js → p-6e89154f.entry.js} +1 -1
- package/dist/twilight/p-6f69cfa5.entry.js +4 -0
- package/dist/twilight/{p-d4aaeef4.entry.js → p-76ce3ec0.entry.js} +1 -1
- package/dist/twilight/p-781f1219.entry.js +4 -0
- package/dist/twilight/p-78e33f77.entry.js +4 -0
- package/dist/twilight/p-79aa2c2f.entry.js +4 -0
- package/dist/twilight/p-7a2bd261.entry.js +4 -0
- package/dist/twilight/p-7a769233.entry.js +4 -0
- package/dist/twilight/{p-6472200c.entry.js → p-7eef10c9.entry.js} +1 -1
- package/dist/twilight/{p-2a26c1d6.entry.js → p-8606c783.entry.js} +1 -1
- package/dist/twilight/p-8719301a.entry.js +4 -0
- package/dist/twilight/p-8ad78dfa.entry.js +4 -0
- package/dist/twilight/{p-300624bb.entry.js → p-9bea43d6.entry.js} +1 -1
- package/dist/twilight/{p-8b018d82.entry.js → p-9c01357f.entry.js} +1 -1
- package/dist/twilight/{p-C0JNGIpa.js → p-BChI23pG.js} +1 -1
- package/dist/twilight/{p-Cuxsz9f-.js → p-BPRHuBhm.js} +1 -1
- package/dist/twilight/{p-B2SkkGH8.js → p-BRh_eoK1.js} +1 -1
- package/dist/twilight/p-BV4kqbdL.js +4 -0
- package/dist/twilight/{p-tFBCbVoG.js → p-BitILwJ_.js} +1 -1
- package/dist/twilight/p-BsLF_HK7.js +4 -0
- package/dist/twilight/{p-uTyAzPSy.js → p-BsXh13x8.js} +1 -1
- package/dist/twilight/p-BscTeWDc.js +4 -0
- package/dist/twilight/{p-ChfiVIJv.js → p-Bx_UY06u.js} +1 -1
- package/dist/twilight/p-C-tzSDxw.js +4 -0
- package/dist/twilight/{p-Bp_xKTyn.js → p-C6S8Hr36.js} +1 -1
- package/dist/twilight/p-C6jIkM-X.js +4 -0
- package/dist/twilight/p-CO-PeZ27.js +4 -0
- package/dist/twilight/{p-DWksgowB.js → p-CgR-T_ZS.js} +1 -1
- package/dist/twilight/p-Ctkfc4K-.js +4 -0
- package/dist/twilight/p-D3mWkc-3.js +4 -0
- package/dist/twilight/p-D4oPi1Ov.js +4 -0
- package/dist/twilight/p-DCZbpt2a.js +4 -0
- package/dist/twilight/p-DY4LZmNP.js +4 -0
- package/dist/twilight/p-DfeagqF1.js +4 -0
- package/dist/twilight/{p-DnELO4MH.js → p-DtkaGJwR.js} +1 -1
- package/dist/twilight/p-OF8QcbMM.js +4 -0
- package/dist/twilight/{p-6mr785rH.js → p-PHxPq4LJ.js} +2 -2
- package/dist/twilight/p-Vqpj4CWE.js +4 -0
- package/dist/twilight/p-ZT7ehBBk.js +4 -0
- package/dist/twilight/p-a5bb66a3.entry.js +4 -0
- package/dist/twilight/p-ad9c9773.entry.js +4 -0
- package/dist/twilight/p-b502e876.entry.js +4 -0
- package/dist/twilight/{p-e909d28b.entry.js → p-b8d8175a.entry.js} +1 -1
- package/dist/twilight/p-ba5fc67a.entry.js +4 -0
- package/dist/twilight/p-c3750eaa.entry.js +4 -0
- package/dist/twilight/p-d7037864.entry.js +4 -0
- package/dist/twilight/p-d9880694.entry.js +4 -0
- package/dist/twilight/p-db0b3ed2.entry.js +4 -0
- package/dist/twilight/{p-81702ecb.entry.js → p-dbb4ede5.entry.js} +1 -1
- package/dist/twilight/{p-28900b2e.entry.js → p-e017e403.entry.js} +1 -1
- package/dist/twilight/p-e31177e7.entry.js +4 -0
- package/dist/twilight/p-e5b90edd.entry.js +4 -0
- package/dist/twilight/{p-b60db6c8.entry.js → p-ec3f15ee.entry.js} +1 -1
- package/dist/twilight/p-edc41bbc.entry.js +4 -0
- package/dist/twilight/p-f2c23e42.entry.js +4 -0
- package/dist/twilight/p-f34f5a30.entry.js +4 -0
- package/dist/twilight/{p-4bc98557.entry.js → p-f578dea7.entry.js} +1 -1
- package/dist/twilight/{p-9946fa76.entry.js → p-ffbd5949.entry.js} +1 -1
- package/dist/twilight/{p-C_h1JDCU.js → p-fq0HEcD_.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-payments/salla-payments.d.ts +0 -2
- package/dist/types/components/salla-product-options/salla-product-options.d.ts +8 -1
- package/dist/types/components/salla-products-slider/salla-products-slider.d.ts +8 -0
- package/dist/types/components/salla-slider/salla-slider.d.ts +20 -2
- package/dist/types/components.d.ts +26 -0
- package/package.json +5 -5
- package/dist/cjs/salla-accordion_62.cjs.entry.js +0 -22470
- package/dist/cjs/salla-review-card.cjs.entry.js +0 -183
- package/dist/cjs/salla-reviews-page.cjs.entry.js +0 -695
- package/dist/cjs/salla-reviews.cjs.entry.js +0 -106
- package/dist/esm/salla-accordion_62.entry.js +0 -22389
- package/dist/esm/salla-review-card.entry.js +0 -181
- package/dist/esm/salla-reviews-page.entry.js +0 -693
- package/dist/esm/salla-reviews.entry.js +0 -104
- package/dist/twilight/p-12e49031.entry.js +0 -4
- package/dist/twilight/p-5bf05092.entry.js +0 -4
- package/dist/twilight/p-67830f2a.entry.js +0 -4
- package/dist/twilight/p-751dddd4.entry.js +0 -4
- package/dist/twilight/p-9b22a7eb.entry.js +0 -4
- package/dist/twilight/p-CBT_Nxny.js +0 -4
- package/dist/twilight/p-Dz7o69vX.js +0 -4
- package/dist/twilight/p-a515a8cc.entry.js +0 -4
- package/dist/twilight/p-c4821f8b.entry.js +0 -4
- package/dist/twilight/p-de807340.entry.js +0 -4
- package/dist/twilight/p-fa585081.entry.js +0 -4
- package/dist/twilight/p-yRO-ZESF.js +0 -4
- package/dist/cjs/{twitter-pOrUNjXi.js → facebook-DbXua6B9.js} +2 -2
- package/dist/esm/{twitter-Dz7o69vX.js → facebook-CO-PeZ27.js} +2 -2
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
import{r as t,c as a,h as s,H as i,a as e,e as l}from"./p-PHxPq4LJ.js";import{P as o}from"./p-DY4LZmNP.js";import{B as n}from"./p-D3mWkc-3.js";import{H as p}from"./p-DgNC8L6e.js";import{i as r}from"./p-BsXh13x8.js";import{C as d}from"./p-C6jIkM-X.js";import"./p-CgtvEd63.js";const c=class{constructor(s){t(this,s),this.success=a(this,"success"),this.failed=a(this,"failed"),this.hostAttributes={},this.hasPreOrder=!1,this.productStatus="sale",this.productType="product",this.selectedOptions=[],this.buyNowText=salla.lang.get("pages.products.buy_now"),this.isDesktopViewport="undefined"==typeof window||window.matchMedia("(min-width: 768px)").matches,this.viewportMediaQuery=null,this.onViewportChange=t=>{this.isDesktopViewport=t.matches,this.btn?.setText(t.matches&&this.passedLabel?this.passedLabel:this.getLabel())},salla.lang.onLoaded((()=>{this.buyNowText=salla.lang.get("pages.products.buy_now")}))}getLabel(){return"sale"===this.productStatus&&this.supportStickyBar&&!this.isDesktopViewport&&this.showQuickBuy&&this.isApplePayActive?o:this.hasPreOrder?salla.lang.get("pages.products.pre_order_now"):"sale"===this.productStatus&&"booking"===this.productType?salla.lang.get("pages.cart.book_now"):"sale"===this.productStatus?salla.lang.get("pages.cart.add_to_cart"):"donating"!==this.productType?salla.lang.get("pages.products.out_of_stock"):salla.lang.get("pages.products.donation_exceed")}addProductToCart(t){if("booking"===this.productType)return t.preventDefault(),this.addBookingProduct();if("submit"===this.hostAttributes.type)return!1;t.preventDefault(),this.btn?.disable();const a=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);return a&&"function"==typeof a.validateAndScroll?a.validateAndScroll().then((async t=>{const a={isValid:t,component:this};if(await salla.hooks.call("salla-add-product-button","validate",a),a.isValid)return this._proceedAddToCart();this.btn?.enable()})).catch((()=>{this.btn?.enable()})):this._proceedAddToCart()}async _proceedAddToCart(){const t=Object.entries({id:this.productId,donation_amount:this.donatingAmount,quantity:this.quantity,endpoint:"quickAdd"}).reduce(((t,[a,s])=>s?(t[a]=s,t):t),{});return salla.cart.addItem(t).then((async t=>(this.selectedOptions=[],this.btn?.enable(),this.success.emit(t),t))).catch((t=>{this.failed.emit(t),this.btn?.enable()}))}addBookingProduct(){return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("booking::add",this.productId),void salla.event.dispatch("login::open")):salla.booking.add(this.productId).then((t=>this.success.emit(t))).catch((t=>this.failed.emit(t)))}getBtnAttributes(){for(let t=0;t<this.host.attributes.length;t++)["id","class"].includes(this.host.attributes[t].name)||(this.hostAttributes[this.host.attributes[t].name]=this.host.attributes[t].value);return this.hostAttributes}getQuickBuyBtnAttributes(){return{...this.getBtnAttributes(),type:this.supportStickyBar&&!this.isDesktopViewport?"plain":"donating"==this.productType?"donate":"buy"}}miniCheckoutWidget(){let t=salla.config.get("store.id");if(t)return s("salla-mini-checkout-widget",{language:salla.lang.locale,"store-id":t,config:{user:salla.config.get("user"),failure_url:window.location.href},products:[this.productId],api:salla.config.get("store.api"),outline:!0,"form-selector":"form.product-form",class:"s-add-product-button-mini-checkout"},s("div",{slot:"widget-label",class:"s-add-product-button-mini-checkout-content"},s("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>full-wallet</title>\n<path d="M29 12h-26c-0.668-0.008-1.284-0.226-1.787-0.59l0.009 0.006c-0.744-0.552-1.222-1.428-1.222-2.416 0-1.657 1.343-3 2.999-3h6c0.552 0 1 0.448 1 1s-0.448 1-1 1v0h-6c-0.552 0-1 0.448-1 1 0 0.326 0.156 0.616 0.397 0.798l0.002 0.002c0.167 0.12 0.374 0.194 0.599 0.2l0.001 0h26c0.552 0 1 0.448 1 1s-0.448 1-1 1v0zM27 12c-0.552 0-1-0.448-1-1v0-3h-3c-0.552 0-1-0.448-1-1s0.448-1 1-1v0h4c0.552 0 1 0.448 1 1v0 4c0 0.552-0.448 1-1 1v0zM29 30h-26c-1.657 0-3-1.343-3-3v0-18c0-0.552 0.448-1 1-1s1 0.448 1 1v0 18c0 0.552 0.448 1 1 1v0h25v-5c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM29 18c-0.552 0-1-0.448-1-1v0-6c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM31 24h-7c-2.209 0-4-1.791-4-4s1.791-4 4-4v0h7c0.552 0 1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM24 18c-1.105 0-2 0.895-2 2s0.895 2 2 2v0h6v-4zM25 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-2.306 1.152c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 3.2-1.6c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1v0zM21 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-15.104 7.552c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 16-8c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1-0.001 0-0.001 0-0.002 0h0z"></path>\n</svg>\n'}),this.buyNowText))}componentWillLoad(){return salla.onReady().then((()=>{if(document.documentElement.classList.add("hydrated"),this.showQuickBuy=this.quickBuy&&salla.config.get("store.settings.buy_now")&&"sale"==this.productStatus&&"booking"!==this.productType,this.isApplePayActive=window.ApplePaySession?.canMakePayments()&&salla.config.get("store.settings.payments")?.includes("apple_pay")&&salla.config.get("store.settings.is_salla_gateway",!1),this.passedLabel=this.host.innerHTML.replace("\x3c!----\x3e","").trim(),this.passedLabel&&this.isDesktopViewport)return this.btn?.setText(this.passedLabel);"submit"===this.host.getAttribute("type")&&this.supportStickyBar&&(this.viewportMediaQuery=window.matchMedia("(min-width: 768px)"),this.viewportMediaQuery.addEventListener("change",this.onViewportChange))}))}render(){return this.host.closest(".swiper-slide")?.classList.contains("swiper-slide-duplicate")?"":this.hasSubscribedOptions?s(i,null,s("salla-product-availability",{...this.getBtnAttributes(),"is-subscribed":!0},s("span",{class:"s-hidden"},s("slot",null)))):"out-and-notify"===this.productStatus&&this.channels||this.hasOutOfStockOption?s(i,null,s("salla-product-availability",{...this.getBtnAttributes()},s("span",{class:"s-hidden"},s("slot",null)))):s(i,{class:{"s-add-product-button-with-quick-buy":this.showQuickBuy,"s-add-product-button-with-sticky-bar":this.supportStickyBar,"s-add-product-button-with-apple-pay":this.showQuickBuy&&this.isApplePayActive}},s("div",{class:{"s-add-product-button-main":this.showQuickBuy,"w-full":!document.getElementById("fast-checkout-js")||["financial_support","donating"].includes(this.productType)}},s("salla-button",{color:"sale"===this.productStatus?"primary":"light",type:"button",fill:"sale"===this.productStatus?"solid":"outline",ref:t=>this.btn=t,onClick:t=>this.addProductToCart(t),disabled:"sale"!==this.productStatus,...this.getBtnAttributes(),"loader-position":"center"},s("slot",null)),this.showQuickBuy&&document.getElementById("fast-checkout-js")&&!["financial_support","donating"].includes(this.productType)?this.miniCheckoutWidget():""),this.showQuickBuy&&this.isApplePayActive?s("salla-quick-buy",{...this.getQuickBuyBtnAttributes()}):"")}async componentDidLoad(){await Salla.hooks.registerComponent("salla-add-product-button",this),this.notifyOptionsAvailability&&salla.event.on("product-options::change",(async t=>{if(!["thumbnail","color","single-option"].includes(t.option.type))return;this.hasSubscribedOptions=!1,this.selectedOptions=await(document.querySelector(`salla-product-options[product-id="${this.productId}"]`)?.getSelectedOptions()),this.hasOutOfStockOption=await(document.querySelector(`salla-product-options[product-id="${this.productId}"]`)?.hasOutOfStockOption());let a=salla.storage.get(`product-${this.productId}-subscribed-options`);if((a||this.subscribedOptions)&&this.hasOutOfStockOption)if(salla.config.isGuest()){const t=a?a.map((t=>t.split(",").map((t=>parseInt(t))))):[];this.hasSubscribedOptions=t.length>0&&t.some((t=>t.every((t=>this.selectedOptions.some((a=>a.id===t))))))}else this.hasSubscribedOptions=!(!this.subscribedOptions||"null"===this.subscribedOptions||"[]"===this.subscribedOptions)&&JSON.parse(this.subscribedOptions).some((t=>t.every((t=>this.selectedOptions.some((a=>a.id===t))))))}))}componentDidRender(){!this.passedLabel||this.supportStickyBar&&!this.isDesktopViewport?(this.btn?.setText(this.getLabel()),salla.lang.onLoaded((()=>this.btn?.setText(this.getLabel())))):this.btn?.setText(this.passedLabel)}disconnectedCallback(){this.viewportMediaQuery?.removeEventListener("change",this.onViewportChange)}get host(){return e(this)}};c.style=":host{display:block}salla-add-product-button[width=wide]{width:100%}";const h=class{constructor(a){t(this,a),this.isUser=salla.config.isUser(),this.translationLoaded=!1,this.notifyOptionsAvailability=!1,this.isSubscribed=!1,this.handleSubmitOptions=async()=>{let t={id:this.productId};if(!this.notifyOptionsAvailability)return t;let a=document.querySelector(`salla-product-options[product-id="${this.productId}"]`),s=Object.values(await(a?.getSelectedOptionsData())||{});if(s.length&&!await(a?.reportValidity())){let t=salla.lang.get("common.messages.required_fields");throw salla.error(t),t}return t.options=[],s.forEach((a=>{a&&!isNaN(a)&&t.options.push(Number(a))})),t},this.typing=t=>{const a=t.target.nextElementSibling;t.target.classList.remove("s-has-error"),a?.classList.contains("s-product-availability-error-msg")&&(a.innerText=""),13===t.keyCode&&this.submit()},salla.lang.onLoaded((()=>{this.translationLoaded=!0,this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.modal?.setTitle(this.title_)})),this.productId||(this.productId=salla.config.get("page.id")),this.isUser||(this.channelsWatcher(this.channels),this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.host.removeAttribute("title"),this.isVisitorSubscribed=this.notifyOptionsAvailability?"":salla.storage.get(`product-${this.productId}-subscribed`))}channelsWatcher(t){this.channels_=t?t.split(","):[]}openModel(){this.handleSubmitOptions().then((t=>t?this.modal.open():null))}async submit(){let t=await this.handleSubmitOptions();if(this.isUser)return salla.api.product.availabilitySubscribe(t).then((()=>this.isSubscribed=!0));if(this.channels_.includes("sms")){let{phone:a,countryCode:s}=await this.mobileInput.getValues();t.country_code=s,t.phone=a}return this.channels_.includes("email")&&""!==this.email.value&&(t.email=this.email.value),await this.validateform(),this.btn.load().then((()=>this.btn.disable())).then((()=>salla.api.product.availabilitySubscribe(t))).then((()=>{if(!this.notifyOptionsAvailability)return salla.storage.set(`product-${this.productId}-subscribed`,!0),void(this.isSubscribed=!0);if(t.options.length){let a=salla.storage.get(`product-${this.productId}-subscribed-options`)||[],s=t.options.join(",");a.includes(s)?salla.log("already subscribed to this options"):(a.push(s),salla.storage.set(`product-${this.productId}-subscribed-options`,a),this.isSubscribed=!0)}})).then((()=>this.btn.stop())).then((()=>this.modal.close())).catch((()=>this.btn.stop()&&this.btn.enable()))}async validateform(){try{if(this.channels_.includes("email")){const t=p.isValidEmail(this.email.value);if(t)return;!t&&this.validateField(this.email,salla.lang.get("common.elements.email_is_valid"))}if(this.channels_.includes("sms")&&await this.mobileInput.isValid())return}catch(t){throw"Please insert required fields"}}validateField(t,a){t.classList.add("s-has-error"),t.nextElementSibling.innerText="* "+a}render(){return s(i,{key:"e5b3121a6e352338ff666ba419100150e838e0d2",class:"s-product-availability-wrap"},this.isSubscribed||this.isVisitorSubscribed?s("div",{class:"s-product-availability-subscribed"},s("span",{innerHTML:n,class:"s-product-availability-subs-icon"}),salla.lang.get("pages.products.notify_availability_success")):s("salla-button",{width:"wide",onClick:()=>this.isUser?this.submit():this.openModel()},salla.lang.get("pages.products.notify_availability")),this.isUser||this.isSubscribed||this.isVisitorSubscribed?"":this.renderModal())}renderModal(){return s("salla-modal",{ref:t=>this.modal=t,"modal-title":this.title_,subTitle:salla.lang.get("pages.products.notify_availability_subtitle"),width:"sm"},s("span",{slot:"icon",class:"s-product-availability-header-icon",innerHTML:n}),s("div",{class:"s-product-availability-body"},this.channels_.includes("email")?[s("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.email")),s("input",{class:"s-product-availability-input",onKeyDown:t=>this.typing(t),placeholder:salla.lang.get("common.elements.email_placeholder")||"your@email.com",ref:t=>this.email=t,type:"email"}),s("span",{class:"s-product-availability-error-msg"})]:"",this.channels_.includes("sms")?[s("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.mobile")),s("salla-tel-input",{ref:t=>this.mobileInput=t,onKeyDown:t=>this.typing(t)})]:""),s("div",{slot:"footer",class:"s-product-availability-footer"},s("salla-button",{class:"modal-cancel-btn",width:"wide",color:"light",fill:"outline",onClick:()=>this.modal.close()},salla.lang.get("common.elements.cancel")),s("salla-button",{class:"submit-btn","loader-position":"center",width:"wide",ref:t=>this.btn=t,onClick:()=>this.submit()},salla.lang.get("common.elements.submit"))))}get host(){return e(this)}static get watchers(){return{channels:["channelsWatcher"]}}};var u,y;h.style="",function(t){t.COLOR="color",t.DATE="date",t.DATETIME="datetime",t.DONATION="donation",t.IMAGE="image",t.MULTIPLE_OPTIONS="multiple-options",t.NUMBER="number",t.SINGLE_OPTION="single-option",t.DIGITAL_CARD_VALUE="digital-code-value",t.COUNTRY="country",t.SPLITTER="splitter",t.TEXT="text",t.TEXTAREA="textarea",t.THUMBNAIL="thumbnail",t.TIME="time",t.RADIO="radio",t.CHECKBOX="checkbox",t.MAP="map",t.FILE="file",t.COLOR_PICKER="color_picker",t.BOOKING="booking"}(u||(u={})),function(t){t.Sar="SAR"}(y||(y={}));const m=class{constructor(i){if(t(this,i),this.changed=a(this,"changed"),this.fileTypes={pdf:"application/pdf",png:"image/png",jpg:"image/jpeg",word:"application/doc,application/ms-doc,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",exl:"application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",txt:"text/plain"},this.outOfStockText="",this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.selectDonationAmount=salla.lang.getWithDefault("pages.products.select_donation_amount","تحديد مبلغ التبرع"),this.selectAmount=salla.lang.getWithDefault("pages.products.select_amount","اختر المبلغ"),this.isCustomDonation=!1,this.selectedOptions=[],this.canDisabled=!1,this.disableCardValue=!0,this.availableDigitalCardValues=[],this.userInitiatedValidation=!1,this.isCartMode=!1,this.outSkus=[],this.ignoreDefaultCardValue=!1,this.productId=salla.config.get("page.id"),this.handleDonationOptions=(t,a,s)=>{if("custom"===a&&"input"===s){const a=t.target;return salla.helpers.inputDigitsOnly(a),salla.event.emit("product-options::donation-changed",{id:this.productId,price:a.value}),void a.dispatchEvent(new window.Event("change",{bubbles:!0}))}const i="option"===s?String(t.target?.value??""):"";if("option"===s&&"custom"===a&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()),this.isCustomDonation="custom"===i,this.donationInput){if("custom"===i?(this.donationInput.value="",this.donationInput.focus()):this.donationInput.value=i,"custom"===a)return;salla.event.emit("product-options::donation-changed",{id:this.productId,price:i})}},this.hideLabel=t=>!(t.type!==u.DONATION||!t.donation||t.donation.can_donate),this.getExpireDonationMessage=t=>{if(!t.donation)return;const a=t.donation.target_amount<=t.donation.collected_amount;return s("div",{class:{"s-product-options-donation-message":!0,"s-product-options-donation-completed":a,"s-product-options-donation-expired":!a}},s("p",null,t.donation.target_message),s("span",{innerHTML:a?salla.money(t.donation.target_amount):""}))},salla.lang.onLoaded((()=>{this.outOfStockText=salla.lang.get("pages.products.out_of_stock"),this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.selectDonationAmount=salla.lang.getWithDefault("pages.products.select_donation_amount","تحديد مبلغ التبرع"),this.selectAmount=salla.lang.getWithDefault("pages.products.select_amount","اختر المبلغ")})),this.options)try{return void this.setOptionsData(Array.isArray(this.options)?this.options:JSON.parse(this.options))}catch(t){salla.log("Bad json passed via options prop")}Array.isArray(this.optionsData)||(salla.log("Options is not an array[] ---\x3e ",this.optionsData),this.setOptionsData([])),this.productId&&!salla.url.is_page("cart")&&salla.api.product.getDetails(this.productId,["options"]).then((t=>this.setOptionsData(t.data.options)))}async setOptionsData(t){this.optionsData=t;const a=this;this.optionsData[0]?.details?.forEach((function(t){Object.entries(t.skus_availability||{}).filter((t=>!t[1])).map((t=>a.outSkus.push(Number(t[0]))))}))}async getSelectedOptionsData(){const t={},a=this.host.getElementSallaData(),s=void 0!==this.bundleContext?this.bundleContext:null;return a.forEach(((a,i)=>{if(s){if(i.startsWith("bundle[")&&i.includes("[options][")){const s=i.split("[options][")[1].replace("]","");t[s]=a}}else i.startsWith("options[")&&(t[i.replace("options[","").replace("]","")]=a)})),t}async reportValidity(){const t=this.host.querySelectorAll("[required]");let a=!0;for(let s=0;s<t.length;s++)"reportValidity"in t[s]&&!t[s].reportValidity()&&(a=!1);return a}async hasOutOfStockOption(){return this.selectedOptions.some((t=>t.is_out))||this.selectedSkus?.length&&this.selectedSkus?.every((t=>this.outSkus.includes(t)))}async getSelectedOptions(){return this.selectedOptions}async getOption(t){return this.optionsData.find((a=>a.id===t))}invalidHandler(t,a){const s=t.target.closest(".s-product-options-option");s.classList.contains("s-product-options-option-error")||s.classList.add("s-product-options-option-error"),!this.userInitiatedValidation&&!salla.helpers.isIOSDevice()||salla.url.is_page("cart")||this.host.querySelector(".s-product-options-option-error")===s&&this.scrollToElement(s)}scrollToElement(t){t&&t.scrollIntoView({behavior:"smooth",block:"center"})}changedHandler(t,a,s=!0){const i={event:t,option:a,detail:null,productId:this.productId};if(a.details){const s=a.details.find((a=>Number(a.id)===Number(t.target.value)));i.detail=s}"country"===a.type&&this.handleCountryOptionChange(t,i.detail);const e=t.target.closest(".s-product-options-option");(t.target.value||(a.type===u.FILE||a.type===u.IMAGE)&&"added"===t.type||a.type===u.MAP&&"selected"===t.type&&t.target.lat&&t.target.lng)&&setTimeout((()=>{e.classList.remove("s-product-options-option-error")}),200),a.type===u.DONATION&&salla.event.emit("product-options::donation-changed",{id:this.productId,price:t.target.value}),this.setSelectedSkus(),this.handleRequiredMultipleOptions(a);const l=this.selectedOptions.findIndex((t=>t.option_id===i.option.id));if(i.option.type===u.MULTIPLE_OPTIONS){const t=this.selectedOptions.findIndex((t=>t.option_id===i.option.id&&t?.id===i.detail?.id));t>-1?this.selectedOptions.splice(t,1):this.selectedOptions.push({...i.detail,option_id:i.option.id})}else i.detail&&0!==Object.keys(i.detail).length?l>-1?this.selectedOptions[l]={...i.detail,option_id:i.option.id}:this.selectedOptions.push({...i.detail,option_id:i.option.id}):l>-1&&this.selectedOptions.splice(l,1);this.optionsData=this.optionsData.map((t=>t.id===i.option.id?{...t,details:t.details.map((t=>({...t,is_selected:i.option.type===u.MULTIPLE_OPTIONS?this.selectedOptions.some((a=>a.id===t.id)):Number(t.id)===Number(i.detail?.id),value:i.detail?.value})))}:t)),s&&(this.changed.emit(i),salla.event.emit("product-options::change",i))}setSelectedSkus(){this.selectedSkus=this.selectedOptions.map((t=>Object.keys(t.skus_availability||{}))).reduce(((t,a)=>t.filter((t=>a.includes(t)))),[]).map((t=>Number(t)))}handleRequiredMultipleOptions(t){if(t.type!==u.MULTIPLE_OPTIONS||!t.required)return;const a=this.host.querySelector(`[data-option-id="${t.id}"]`),s=a.querySelectorAll("input:checked").length;a.querySelectorAll("input").forEach((t=>t.toggleAttribute("required",!s)))}getLatLng(t,a){return t?t.split(",")["lat"===a?0:1]:""}getDisplayForType(t){return this[`${t.type}Option`]?this[`${t.type}Option`](t):t.type===u.COLOR_PICKER?this.colorPickerOption(t):t.type===u.MULTIPLE_OPTIONS?this.multipleOptions(t):t.type===u.SINGLE_OPTION?this.singleOption(t):t.type===u.RADIO?this.radioOption(t):t.type===u.DIGITAL_CARD_VALUE?this.digitalCardValuesOption(t):t.type===u.COUNTRY?this.countryOption(t):t.type===u.BOOKING&&salla.url.is_page("cart")?s("salla-booking-field",{onInvalidInput:a=>this.invalidHandler(a,t),option:t,productId:t.value}):(salla.log(`Couldn't find options type(${t.type})😢`),"")}getOptionShownWhen(t){return t.visibility_condition?{"data-show-when":`options[${t.visibility_condition.option}] ${t.visibility_condition.operator} ${t.visibility_condition.value}`}:{}}getAvailableDigitalCardSKUs(t){const a=this.optionsData.find((({type:t})=>"digital-code-value"===t));if(!a)throw new Error("product-options:: No digital card options found");const s=Object.keys(t.skus_availability).filter((a=>!1===t.skus_availability[a]));this.availableDigitalCardValues=a.details.filter((t=>!Object.keys(t.skus_availability).filter((t=>s.includes(t))).length))}handleCountryOptionChange(t,a){t.stopImmediatePropagation(),this.ignoreDefaultCardValue=!0;const s=this.host.querySelector("input[data-code-value]:checked");if(s&&(s.checked=!1),!this.optionsData.find((({type:t})=>"digital-code-value"===t)))throw new Error("product-options:: No digital card options found");this.getAvailableDigitalCardSKUs(a)}getSelectedDigitalCardOptions(t){const a=t.details.find((t=>t.is_selected)),s=t.details.find((t=>!!t.is_default))||t.details[0];if(["digital-code-value","country"].includes(t.type))return a||s}async componentWillLoad(){if(salla.url.is_page("cart")&&(this.disableCardValue=!1,this.fillSelectedOptions()),this.config)try{this.optionConfig="string"==typeof this.config?JSON.parse(this.config):this.config}catch(t){console.error("Failed to parse JSON in config prop:",t)}if(this.optionsData.filter((({type:t})=>["country","digital-card-value"].includes(t))).length>0&&salla.url.is_page("cart")){const t=this.optionsData.find((t=>"country"===t.type)),a=t&&this.getSelectedDigitalCardOptions(t);a&&this.getAvailableDigitalCardSKUs(a)}return this.outOfStockText=salla.lang.get("pages.products.out_of_stock"),await salla.onReady(),this.canDisabled=!salla.config.get("store.settings.product.notify_options_availability")||salla.url.is_page("cart"),this.pasteHandler=this.handlePaste.bind(this),document.addEventListener("paste",this.pasteHandler),!salla.storage.get("cart.id")&&this.optionsData.some((t=>["file","image"].includes(t.type)))?salla.api.cart.getCurrentCartId(!1,"salla-product-options"):null}disconnectedCallback(){this.pasteHandler&&document.removeEventListener("paste",this.pasteHandler)}handlePaste(t){const a=t.target;if(!(Salla.helpers.isAppleDevice()&&(a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement)&&a.classList.contains("s-form-control")&&this.host.contains(a)))return;t.preventDefault();const s=t.clipboardData?.getData("text")||"",i=a.selectionStart,e=a.selectionEnd,l=a.value.slice(0,i)+s+a.value.slice(e);a.value=l,a.setSelectionRange(i+s.length,i+s.length);try{a.dispatchEvent(new window.Event("change",{bubbles:!0}))}catch(t){Salla.log("Error on change")}}hideDigitalCardsOptions(t){return this.disableCardValue&&t.type===u.DIGITAL_CARD_VALUE&&!salla.url.is_page("cart")}render(){if(0!==this.optionsData?.length)return s(i,{class:"s-product-options-wrapper"},s("salla-conditional-fields",null,this.optionsData.map((t=>s("div",{key:t.id,class:"s-product-options-option-container"+(t.visibility_condition||this.hideDigitalCardsOptions(t)?" hidden":""),"data-option-id":t.id,...this.getOptionShownWhen(t)},"splitter"===t.name?this.splitterOption():s("div",{class:{"s-product-options-option":!0,"s-product-options-option-booking":t.type===u.BOOKING&&salla.url.is_page("cart")},"data-option-type":t.type,"data-option-required":`${t.required}`},s("label",{htmlFor:this.generateInputId(t.id),class:"s-product-options-option-label "+(this.hideLabel(t)?"s-product-options-option-label-hidden":"")},s("b",null,t.name,t.required&&s("span",null," * ")," "),s("small",null,t.placeholder)),s("div",{class:"s-product-options-option-content "+(this.hideLabel(t)||t.type===u.BOOKING&&salla.url.is_page("cart")?"s-product-options-option-content-full-width":"")},this.getDisplayForType(t))))))))}generateUniqueKey(t){const a=this.bundleContext;let s=this.uniqueKey?`${t}-${this.uniqueKey}`:t;if(a)try{const t="string"==typeof a?JSON.parse(a):a,{sectionId:i,productId:e}=t;s=`${s}-bundle-${i}-${e}`}catch(t){}return s}generateInputId(t){return this.generateUniqueKey(`option-${t}`)}generateInputName(t){const a=this.bundleContext,s=t.toString();if(a)try{const t="string"==typeof a?JSON.parse(a):a,{sectionId:i,productId:e}=t;return`bundle[${i}][${e}][options][${s}]`}catch(t){return`options[${s}]`}return`options[${s}]`}fillSelectedOptions(){this.selectedOptions=this.optionsData.reduce(((t,a)=>{const s=a.details.filter((t=>t.is_selected)).map((t=>({...t,option_id:a.id})));return t.concat(s)}),[])}async componentDidLoad(){if(!this.optionsData?.length)return;await Salla.hooks.registerComponent("salla-product-options",this);const t=this.optionsData.find((t=>t.type===u.DONATION))?.details?.find((t=>t.is_selected));if(t&&setTimeout((()=>{salla.event.emit("product-options::donation-changed",{id:this.productId,price:t.additional_price})}),1e3),!salla.url.is_page("cart")&&!this.isCartMode){const t=[u.SINGLE_OPTION,u.MULTIPLE_OPTIONS,u.COLOR,u.THUMBNAIL,u.DONATION,u.DIGITAL_CARD_VALUE,u.COUNTRY];this.optionsData.some((a=>t.includes(a.type)&&a.details?.some((t=>t.is_selected))))&&requestAnimationFrame((()=>{try{const t=this.host.closest("form");if(!t)return;const a=new FormData(t),s=a.get("id")||a.get("product_id");if(s&&String(s)!==String(this.productId))return;salla.product.getPrice(a)}catch(t){salla.log("Error updating price for pre-selected options:",t)}}))}}async enterCartMode(){this.isCartMode=!0,this.disableCardValue=!1,this.canDisabled=!0,this.fillSelectedOptions()}async enableUserInitiatedValidation(){this.userInitiatedValidation=!0}async validateAndScroll(){return await this.enableUserInitiatedValidation(),this.reportValidity()}donationOption(t,a){return s("div",{class:"s-product-options-donation-wrapper"},t.donation?.can_donate?[t.donation?s("div",{key:t.id,class:"s-product-options-donation-progress"},s("salla-progress-bar",{donation:t.donation})):"",t.details.length?[s("h4",{key:t.id},this.selectAmount),s("div",{key:t.id,class:"s-product-options-donation-options"},t.details.map(((a,i)=>s("div",{key:t.id,class:"s-product-options-donation-options-item"},s("input",{id:this.generateUniqueKey(`donation-option-${i}`),type:"radio",name:"donating_option",checked:a.is_selected,value:a.additional_price,onChange:s=>this.handleDonationOptions(s,a,"option",t)}),s("label",{htmlFor:this.generateUniqueKey(`donation-option-${i}`)},s("span",{innerHTML:salla.money(a.name)}))))),t.donation?.custom_amount_enabled?s("div",{class:"s-product-options-donation-options-item"},s("input",{id:this.generateUniqueKey("donation-option-custom"),type:"radio",name:"donating_option",value:"custom",onChange:a=>this.handleDonationOptions(a,"custom","option",t)}),s("label",{htmlFor:this.generateUniqueKey("donation-option-custom")},s("span",null," ",this.selectDonationAmount," "))):"")]:"",s("div",{key:t.id,class:{"s-product-options-donation-input-group":!0,shown:!t.details.length||t.details.length&&this.isCustomDonation}},s("input",{type:"text",id:"donating-amount",name:"donation_amount",class:"s-form-control",ref:t=>{this.donationInput=t},value:t.details.length&&t.details.some((t=>t.is_selected))?t.details.find((t=>t.is_selected)).additional_price:t.value,placeholder:t.placeholder,onInput:a=>this.handleDonationOptions(a,"custom","input",t),onBlur:a=>this.changedHandler(a,t),onInvalid:a=>this.invalidHandler(a,t)}),s("span",{class:"s-product-options-donation-amount-currency"},salla.config.currency(salla.config.get("user.currency_code")).symbol))]:this.getExpireDonationMessage(t))}fileUploader(t,a=null){return s("salla-file-upload",{...a||{},"payload-name":"file",value:t.value,"instant-upload":!0,name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,height:"120px",onAdded:a=>this.changedHandler(a,t),url:salla.cart.api.getUploadImageEndpoint(),"form-data":{cart_item_id:this.productId,product_id:this.productId},onInvalidInput:a=>this.invalidHandler(a,t),class:{"s-product-options-image-input":!0,required:t.required}},s("div",{class:"s-product-options-filepond-placeholder"},s("span",{class:"s-product-options-filepond-placeholder-icon",innerHTML:a.accept?.split(",").every((t=>t.includes("image")))?d:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>file-upload</title>\n<path d="M21.333 24c0.341 0 0.683-0.131 0.943-0.391 0.521-0.521 0.521-1.364 0-1.885l-5.333-5.333c-0.123-0.123-0.271-0.22-0.433-0.288-0.327-0.135-0.693-0.135-1.019 0-0.163 0.068-0.311 0.165-0.433 0.288l-5.333 5.333c-0.521 0.521-0.521 1.364 0 1.885s1.364 0.521 1.885 0l3.057-3.057v10.115c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-10.115l3.057 3.057c0.26 0.26 0.601 0.391 0.943 0.391zM28.943 9.724l-9.333-9.333c-0.249-0.251-0.589-0.391-0.943-0.391h-12c-2.205 0-4 1.795-4 4v24c0 2.205 1.795 4 4 4h4c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333h-4c-0.735 0-1.333-0.599-1.333-1.333v-24c0-0.735 0.599-1.333 1.333-1.333h11.448l8.552 8.552v16.781c0 0.735-0.599 1.333-1.333 1.333h-4c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h4c2.205 0 4-1.795 4-4v-17.333c0-0.353-0.14-0.693-0.391-0.943z"></path>\n</svg>\n'}),s("p",{class:"s-product-options-filepond-placeholder-text"},salla.lang.get("common.uploader.drag_and_drop")),s("span",{class:"filepond--label-action"},salla.lang.get("common.uploader.browse"))))}imageOption(t){return this.fileUploader(t,{accept:"image/png,image/jpeg,image/jpg,image/gif"})}fileOption(t){const a=t.details.map((t=>this.fileTypes[t.name])).filter(Boolean);return a?.length?this.fileUploader(t,{accept:a.join(",")}):"File types not selected."}numberOption(t){return s("input",{type:"text",value:t.value,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onBlur:a=>this.changedHandler(a,t),onInvalid:a=>this.invalidHandler(a,t),onInput:t=>salla.helpers.inputDigitsOnly(t.target)})}splitterOption(){return s("div",{class:"s-product-options-splitter"})}textOption(t){return s("div",{class:"s-product-options-text"},s("input",{type:"text",value:t.value,maxLength:t?.length,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t)}))}textareaOption(t){return s("div",{class:"s-product-options-textarea"},s("div",{class:"mt-1"},s("textarea",{rows:4,value:t.value,maxLength:t?.length,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t)})))}mapOption(t){return s("salla-map",{zoom:15,lat:this.getLatLng(t.value,"lat"),lng:this.getLatLng(t.value,"lng"),name:this.generateInputName(t.id),searchable:!0,required:t.required,onInvalidInput:a=>this.invalidHandler(a,t),onSelected:a=>this.changedHandler(a,t)})}colorPickerOption(t){return s("salla-color-picker",{onSubmitted:a=>this.changedHandler(a,t),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,onInvalidInput:a=>this.invalidHandler(a,t),color:t.value})}timeOption(t){return s("salla-datetime-picker",{noCalendar:!0,enableTime:!0,dateFormat:"h:i K",value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,name:this.generateInputName(t.id),class:"s-product-options-time-element",onInvalidInput:a=>this.invalidHandler(a,t),onPicked:a=>this.changedHandler(a,t)})}dateOption(t){return s("div",{class:"s-product-options-date-element"},s("salla-datetime-picker",{value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,minDate:new Date,name:this.generateInputName(t.id),onInvalidInput:a=>this.invalidHandler(a,t),onPicked:a=>this.changedHandler(a,t)}))}datetimeOption(t){return s("div",{class:"s-product-options-datetime-element"},s("salla-datetime-picker",{enableTime:!0,value:t.value,dateFormat:"Y-m-d G:i:K",placeholder:t.name,required:!t.visibility_condition&&t.required,name:this.generateInputName(t.id),maxDate:t.to_date_time,minDate:t.from_date_time,onInvalidInput:a=>this.invalidHandler(a,t),onPicked:a=>this.changedHandler(a,t)}))}getOptionDetailName(t,a=!0,s){let i;return s&&s===u.COLOR&&(i=t.name+(a&&this.isOptionDetailOut(t)&&!salla.url.is_page("cart")&&!this.hideOutLabel?` <br/> <p> ${this.outOfStockText} </p>`:"")+(t.additional_price?` <p> (${salla.money(t.additional_price,!1)}) </p>`:"")),i||(i=t.name+(a&&this.isOptionDetailOut(t)&&!salla.url.is_page("cart")&&!this.hideOutLabel?` - ${this.outOfStockText}`:"")+(t.additional_price?` (${salla.money(t.additional_price,!1)})`:"")),i.replace("<i class=sicon-sar></i>",salla.config.currency()?.symbol||"ر.س")}isOptionDetailOut(t){if(t.is_out||!t.skus_availability||!this.selectedSkus?.length)return t.is_out;const a=this.selectedOptions.filter((a=>a.id===t.id)).length;if(a&&1===this.selectedOptions.length)return!1;if(a){const a=this.selectedSkus.filter((t=>this.outSkus.includes(t)));return Object.keys(t.skus_availability).some((t=>a.includes(Number(t))))}return this.selectedOptions.some((a=>a.is_out&&a.option_id!==t.option_id))}renderInput(t,a,i,e,l,o){const n=this.generateUniqueKey(`${t}-${i.id}-${a.id}`),p=this.isOptionDetailOut(a);return s("label",{class:{"s-product-options-disabled":p}},s("input",{id:n,type:t,name:l,value:a.id,disabled:p,required:e,checked:a.is_selected,onInvalid:t=>this.invalidHandler(t,i),onChange:t=>this.changedHandler(t,i)}),s("div",{class:{"s-product-options-grid-mode-span":o,"s-product-options-disabled":p}},this.getOptionDetailName(a)))}renderOptionDetails(t,a,s,i=!1){const e=this.generateInputName(a.id),l="radio"===t?e:`${e}[]`;return a?.details.map((e=>this.renderInput(t,e,a,s,l,i)))}renderSelect(t){return s("div",null,s("select",{id:this.generateInputId(t.id),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,class:"s-form-control",onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t)},s("option",{value:""},t.placeholder),t?.details.map((t=>s("option",{key:t.id,value:t.id,disabled:this.canDisabled&&this.isOptionDetailOut(t),selected:t.is_selected},this.getOptionDetailName(t))))))}renderButtonStyle(t,a,i){return s("div",{class:"s-product-options-grid-mode"},this.renderOptionDetails(t,a,i,!0))}singleOption(t){return"button"===this.optionConfig?.["single-option"]?.type?this.renderButtonStyle("radio",t,!t.visibility_condition&&t.required):this.renderSelect(t)}multipleOptions(t){const a="button"===this.optionConfig?.["multiple-option"]?.type,i=t.required&&!t.details.some((t=>t.is_selected))&&!t.visibility_condition;return a?this.renderButtonStyle("checkbox",t,i):s("div",{class:{"s-product-options-multiple-options-wrapper":!0,required:t.required}},this.renderOptionDetails("checkbox",t,i))}radioOption(t){return this.singleOption(t)}colorOption(t){return s("fieldset",{class:"s-product-options-colors-wrapper"},t?.details.map((a=>s("div",{class:"s-product-options-colors-item",key:a.id},s("input",{type:"radio",value:a.id,required:!t.visibility_condition&&t.required,checked:a.is_selected,name:this.generateInputName(t.id),disabled:this.canDisabled&&this.isOptionDetailOut(a),id:this.generateUniqueKey(`color-${this.productId}-${t.id}-${a.id}`),onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t)}),s("label",{htmlFor:this.generateUniqueKey(`color-${this.productId}-${t.id}-${a.id}`)},s("span",{style:{backgroundColor:a.color}}),s("div",{innerHTML:this.getOptionDetailName(a,!0,t.type)}))))))}thumbnailOption(t){return s("div",{class:"s-product-options-thumbnails-wrapper"},t.details.map((a=>s("div",{key:a.id},s("input",{type:"radio",value:a.id,"data-itemid":a.id,required:!t.visibility_condition&&t.required,checked:a.is_selected,name:this.generateInputName(t.id),"data-img-id":a.option_value,disabled:this.canDisabled&&this.isOptionDetailOut(a),id:this.generateUniqueKey(`option_${this.productId}-${t.id}_${a.id}`),onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t)}),s("label",{htmlFor:this.generateUniqueKey(`option_${this.productId}-${t.id}_${a.id}`),"data-img-id":a.option_value,class:"go-to-slide"},s("img",{"data-src":a.image,src:a.image,title:a.name,alt:a.name}),s("span",{innerHTML:r,class:"s-product-options-thumbnails-icon"}),this.isOptionDetailOut(a)?[s("small",{key:a.id,class:"s-product-options-thumbnails-stock-badge"},this.outOfStockText),this.canDisabled?s("div",{key:a.id,class:"s-product-options-thumbnails-badge-overlay"}):""]:""),s("p",null,this.getOptionDetailName(a,!1)," ")))))}digitalCardValuesOption(t){return s("div",{class:"s-product-options-digital-card-wrapper"},this.availableDigitalCardValues.length>0?this.availableDigitalCardValues.map((a=>{const i=String(a.id);return s("label",{htmlFor:this.generateUniqueKey(i.toString()),key:i,class:"s-product-options-digital-card-option"},s("input",{type:"radio","data-code-value":!0,class:"s-form-control s-product-options-digital-card-input",value:a.id,name:this.generateInputName(t.id),id:this.generateUniqueKey(i.toString()),required:!t.visibility_condition&&t.required,onInvalid:a=>this.invalidHandler(a,t),...this.ignoreDefaultCardValue?{}:{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===a.id}}),s("span",null,a.name," ",salla.config?.currency()?.symbol))})):s("div",{class:"s-product-options-digital-card-out-of-stock"}))}countryOption(t){return s("div",{class:"s-product-options-digital-card-wrapper"},t.details.map((a=>s("label",{htmlFor:this.generateUniqueKey(a.id.toString()),key:a.id,class:{"s-product-options-digital-card-option":!0,"s-product-options-digital-card-option-stock-out":a.is_out}},s("input",{id:this.generateUniqueKey(a.id.toString()),type:"radio",class:"s-form-control s-product-options-digital-card-input",value:a.id,name:this.generateInputName(t.id),disabled:a.is_out,required:!t.visibility_condition&&t.required,onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t),onClick:()=>{this.disableCardValue=!1},...salla.url.is_page("cart")?{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===a.id}:{}}),s("img",{loading:"lazy",alt:a.code,height:24,width:24,class:"s-product-options-country-flag",src:`https://cdn.assets.salla.network/prod/admin/cp/assets/flags/1x1/${String(a.code).toLocaleLowerCase()}.svg`,onError:t=>{t.currentTarget.onerror=null,t.currentTarget.src=salla.url.cdn("images/globe.svg")}}),s("span",null,a.name)))))}get host(){return e(this)}};m.style="";var g={request:(t,a,s,i=null,e=null)=>l.request({url:a,data:s,method:t.toLowerCase(),responseType:"json"}).then(i).catch(e),get:(t,a=null,s=null,i)=>l.get(t,{params:i}).then(a).catch(s),post(t,a,s=null,i=null){return this.request("post",t,a,s,i)},put(t,a,s=null,i=null){return this.request("put",t,a,s,i)},delete(t,a,s=null,i=null){return this.request("delete",t,a,s,i)},requestWithSupportAjax(t,a,s="post"){return new Promise(((i,e)=>{if(!window?.isLegacyTheme)return this.request(s,t,a,(({data:t})=>i(t)),(({response:t})=>e(t)));$.ajax({url:t,method:s.toUpperCase(),data:a,async:!1,success:function({data:t}){return i(t)},error:function({response:t}){return e(t)}})}))}},w={options:[],header:[navigator.platform,navigator.userAgent,navigator.appVersion,navigator.vendor,window.opera],dataos:[{name:"Windows Phone",value:"Windows Phone",version:"OS"},{name:"Windows",value:"Win",version:"NT"},{name:"iPhone",value:"iPhone",version:"OS"},{name:"iPad",value:"iPad",version:"OS"},{name:"Kindle",value:"Silk",version:"Silk"},{name:"Android",value:"Android",version:"Android"},{name:"PlayBook",value:"PlayBook",version:"OS"},{name:"BlackBerry",value:"BlackBerry",version:"/"},{name:"Macintosh",value:"Mac",version:"OS X"},{name:"Linux",value:"Linux",version:"rv"},{name:"Palm",value:"Palm",version:"PalmOS"}],databrowser:[{name:"Chrome",value:"Chrome",version:"Chrome"},{name:"Firefox",value:"Firefox",version:"Firefox"},{name:"Safari",value:"Safari",version:"Version"},{name:"Internet Explorer",value:"MSIE",version:"MSIE"},{name:"Opera",value:"Opera",version:"Opera"},{name:"BlackBerry",value:"CLDC",version:"CLDC"},{name:"Mozilla",value:"Mozilla",version:"Mozilla"}],init:function(){var t=this.header.join(" ");return{os:this.matchItem(t,this.dataos),browser:this.matchItem(t,this.databrowser)}},matchItem:function(t,a){var s,i,e,l=0,o=0;for(l=0;l<a.length;l+=1)if(new RegExp(a[l].value,"i").test(t)){if(s=new RegExp(a[l].version+"[- /:;]([\\d._]+)","i"),e="",(i=t.match(s))&&i[1]&&(i=i[1]),i)for(i=i.split(/[._]+/),o=0;o<i.length;o+=1)e+=0===o?i[o]+".":i[o];else e="0";return{name:a[l].name,version:parseFloat(e)}}return{name:"unknown",version:0}}};async function v(t,a,s=!1){if(salla.logger.log("🍏 Pay: mutateShippingContact called",a,s),t.detail.requiredShippingContactFields&&0!=t.detail.requiredShippingContactFields.length)if(s){if(salla.config.isGuest()&&salla.config.get("store.features").includes("guest-checkout")){if(!(a.emailAddress&&a.givenName&&a.familyName&&a.phoneNumber)){salla.logger.warn("🍏 Pay: Guest contact fields are required",a);const s=[];return a.emailAddress||s.push(new window.ApplePayError("shippingContactInvalid","emailAddress","Email address is required")),a.phoneNumber||s.push(new window.ApplePayError("shippingContactInvalid","phoneNumber","Phone number is required")),a.givenName&&a.familyName||s.push(new window.ApplePayError("shippingContactInvalid","name","Name is required")),void t.session.completePayment({status:t.session.STATUS_INVALID_SHIPPING_CONTACT,errors:s})}await async function(t,a){return salla.logger.log("🍏 Pay: Updating guest contact",a),new Promise(((s,i)=>{g.post(t.detail.guestContactSelected.url.replace("{id}",t.id),{email:a.emailAddress||null,first_name:a.givenName||null,last_name:a.familyName||null,phone_number:a.phoneNumber||null,country_code:a.countryCode||null},(async({data:a})=>{"function"==typeof t.detail.guestContactSelected?.onSuccess&&t.detail.guestContactSelected.onSuccess(a),s(a)}),(({response:a})=>{salla.logger.warn("🍏 Pay: Failed to update guest contact via api",a),"function"==typeof t.detail.guestContactSelected?.onFailed&&t.detail.guestContactSelected.onFailed(a),i({response:a})}))}))}(t,a)}}else if(t.detail.requiredShippingContactFields.includes("postalAddress"))return g.post(t.detail.shippingContactSelected.url.replace("{id}",t.id),{country:a.country,city:a.locality,local:a.subLocality||a.administrativeArea||a.locality,description:a.subAdministrativeArea,street:a.addressLines?.join(", ")||a.administrativeArea,country_code:a.countryCode,postal_code:a.postalCode},(async({data:a})=>{if("function"==typeof t.detail.shippingContactSelected.onSuccess&&t.detail.shippingContactSelected.onSuccess(a),t.address_id=a.data.address_id,t.shipping_methods=a.data.shipping_methods,!t.shipping_methods||t.shipping_methods&&!t.shipping_methods.length)return salla.logger.warn("🍏 Pay: We dont found any supported methods",a),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]});try{await t.selectApplePayShippingMethod(t.shipping_methods[0])}catch(a){return salla.logger.warn("Failed set the shipping details to api",a),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}try{await t.recalculateTotal()}catch(a){return salla.logger.warn("🍏 Pay: Failed recalculate total",a),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}const s={newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),newShippingMethods:t.mappingShippingMethods(t.shipping_methods)};salla.logger.log("🍏 Pay: completeShippingContactSelection",s),t.session.completeShippingContactSelection(s)}),(({response:a})=>{salla.logger.warn("🍏 Pay: Failed add address via api",a),"function"==typeof t.detail.shippingContactSelected.onFailed&&t.detail.shippingContactSelected.onFailed(a);let s=a?.data?.error?.fields,i=function(t){return Object.entries(t).filter((([t,a])=>a&&a.length>0)).map((([t,a])=>new window.ApplePayError("shippingContactInvalid",t,a[0])))}({countryCode:s?.country_code&&s.country_code.length>0?s.country_code[0]:null,locality:s?.city&&s.city.length>0?s.city[0]:null,country:s?.country&&s.country.length>0?s.country[0]:null});0===i.length&&a?.data?.error?.message&&i.push(new window.ApplePayError("shippingContactInvalid","locality",a?.data?.error?.message)),t.session.completeShippingContactSelection({newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:i})}))}window.Salla=window.Salla||{},window.Salla.Payments=window.Salla.Payments||{},window.SallaApplePay={session:null,detail:null,address_id:null,shipping_methods:[],total:void 0,request:void 0,id:void 0,countryCode:null,totals:[],shippingCompany:null,init:function(){document.removeEventListener("payments::apple-pay.start-transaction",SallaApplePay.startSession),Salla.event.addEventListener("payments::apple-pay.start-transaction",SallaApplePay.startSession)},initDefault:function(){SallaApplePay.detail.onError||(SallaApplePay.detail.onError=function(t){salla.notify.error(t)}),SallaApplePay.detail.authorized.onFailed||(SallaApplePay.detail.authorized.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse(t),SallaApplePay.onCancel({},t.data.error.message)}),SallaApplePay.detail.validateMerchant.onFailed||(SallaApplePay.detail.validateMerchant.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse(t),SallaApplePay.onCancel({},t.data.error.message)}),SallaApplePay.detail.authorized.onSuccess||(SallaApplePay.detail.authorized.onSuccess=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleAfterResponseActions(t)})},prepareLineItems:function(){return SallaApplePay.detail?.items?.length||(SallaApplePay.detail.items=[{label:salla.lang.get("pages.cart.items_total"),amount:parseFloat(SallaApplePay.detail.amount).toString()}]),SallaApplePay.detail.items},prepareTotal:function(){return{label:window.location.hostname||"Salla",amount:parseFloat(SallaApplePay.detail.amount).toString()}},isPhysical:()=>SallaApplePay.detail?.requiredShippingContactFields?.includes("postalAddress"),startSession:async function(t){SallaApplePay.detail=t.detail||t,salla.log("🍏 Pay: payments::apple-pay.start-transaction",SallaApplePay.detail),SallaApplePay.initDefault();let a=SallaApplePay.getApplePaySessionVersion(),s=SallaApplePay.detail.supportedNetworks||["masterCard","visa"];5===a&&s.push("mada"),SallaApplePay.request={countryCode:SallaApplePay.detail.countryCode||"SA",supportsCouponCode:!0,couponCode:"",currencyCode:SallaApplePay.detail.currency||"SAR",requiredShippingContactFields:SallaApplePay.detail.requiredShippingContactFields?SallaApplePay.detail.requiredShippingContactFields:[],merchantCapabilities:["supports3DS"],supportedNetworks:s,supportedCountries:SallaApplePay.detail.supportedCountries||["SA"],total:SallaApplePay.prepareTotal(),shippingContact:SallaApplePay.detail.shippingContact?SallaApplePay.detail.shippingContact:{},shippingMethods:SallaApplePay.detail.shippingMethods&&SallaApplePay.detail.shippingMethods.length?SallaApplePay.mappingShippingMethods(t.detail.shippingMethods):[],lineItems:SallaApplePay.prepareLineItems()},salla.log("🍏 Pay: init ",SallaApplePay.request),SallaApplePay.session=new ApplePaySession(a,SallaApplePay.request),SallaApplePay.session.onshippingcontactselected=SallaApplePay.onShippingContactSelected,SallaApplePay.session.onshippingmethodselected=SallaApplePay.onShippingMethodSelected,SallaApplePay.session.onvalidatemerchant=SallaApplePay.onValidateMerchant,SallaApplePay.session.onpaymentauthorized=SallaApplePay.onPaymentAuthorized,SallaApplePay.session.oncancel=SallaApplePay.onCancel,SallaApplePay.session.oncouponcodechanged=SallaApplePay.onCouponCodeChanged,SallaApplePay.session.onpaymentmethodselected=SallaApplePay.onPaymentMethodSelected,SallaApplePay.session.begin()},onPaymentMethodSelected:async t=>{if(salla.logger.log("🍏 Pay: onPaymentMethodSelected",t),SallaApplePay.isPhysical())salla.logger.log("🍏 Pay: completePaymentMethodSelection",{newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()}),SallaApplePay.session.completePaymentMethodSelection({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()});else try{await SallaApplePay.recalculateTotal();const t={newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()};salla.logger.log("🍏 Pay: completePaymentMethodSelection",t),SallaApplePay.session.completePaymentMethodSelection(t)}catch(t){salla.logger.warn("🍏 Pay: Failed recalculate total",t),SallaApplePay.session.completePaymentMethodSelection({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems(),status:SallaApplePay.session.STATUS_FAILURE,errors:[new window.ApplePayError("unknown",void 0,t?.response?.data?.error?.message||t?.response?.data?.error?.code||"Failed to recalculate total")]})}},onCouponCodeChanged:t=>(Salla.event.dispatch("payments::apple-pay.coupon.change",t),g.post(SallaApplePay.detail.onCouponCodeChanged.url.replace("{id}",SallaApplePay.id),{coupon:t.couponCode,payment_method:"apple_pay"},(async({data:t})=>{"function"==typeof SallaApplePay.detail.onCouponCodeChanged.onSuccess&&SallaApplePay.detail.onCouponCodeChanged.onSuccess(t),salla.log("🍏 Pay: Coupon applied success"),await SallaApplePay.recalculateTotal(),SallaApplePay.session.completeCouponCodeChange({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()})}),(async t=>{let a=t?.response;Salla.event.dispatch("payments::apple-pay.coupon.failed",a),"function"==typeof SallaApplePay.detail.onCouponCodeChanged.onFailed&&SallaApplePay.detail.onCouponCodeChanged.onFailed(a),await SallaApplePay.recalculateTotal(),SallaApplePay.session.completeCouponCodeChange({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems(),errors:[new window.ApplePayError("couponCodeInvalid")]})}))),onCancel:(t={},a=null)=>{SallaApplePay.detail.onError(a||salla.lang.get("pages.checkout.payment_failed")),Salla.event.createAndDispatch("payments::apple-pay.canceled",t)},onPaymentAuthorized:async t=>{salla.logger.log("🍏 Pay: onPaymentAuthorized",t.payment);try{await v(SallaApplePay,t.payment.shippingContact,!0)}catch(t){salla.logger.error("🍏 Pay: Failed to update guest contact details",t);const a=t?.response||t,s=a?.data?.error?.fields||{},i=[];return s?.email&&s.email.length>0&&i.push(new window.ApplePayError("shippingContactInvalid","emailAddress",s.email[0])),s?.phone&&s.phone.length>0&&i.push(new window.ApplePayError("shippingContactInvalid","phoneNumber",s.phone[0])),s?.first_name&&s.first_name.length>0?i.push(new window.ApplePayError("shippingContactInvalid","name",s.first_name[0])):s?.last_name&&s.last_name.length>0&&i.push(new window.ApplePayError("shippingContactInvalid","name",s.last_name[0])),0===i.length&&i.push(new window.ApplePayError("shippingContactInvalid","name",a?.data?.error?.message||a?.data?.error?.code||"Invalid shipping contact details")),Salla.event.dispatch("payments::apple-pay.authorized.failed",a),"function"==typeof SallaApplePay.detail.authorized.onFailed&&SallaApplePay.detail.authorized.onFailed(a),void SallaApplePay.session.completePayment({status:ApplePaySession.STATUS_INVALID_SHIPPING_CONTACT,errors:i})}Salla.event.dispatch("payments::apple-pay.authorized.init",t),g.post(SallaApplePay.detail.authorized.url.replace("{id}",SallaApplePay.id),{payment_method:"apple_pay",applepay_token:JSON.stringify(t.payment)},(({data:t})=>{Salla.event.dispatch("payments::apple-pay.authorized.success",t),"function"==typeof SallaApplePay.detail.authorized.onSuccess&&SallaApplePay.detail.authorized.onSuccess(t),SallaApplePay.session.completePayment(ApplePaySession.STATUS_SUCCESS)}),(t=>{let a=t?.response;Salla.event.dispatch("payments::apple-pay.authorized.failed",a),"function"==typeof SallaApplePay.detail.authorized.onFailed&&SallaApplePay.detail.authorized.onFailed(a),SallaApplePay.session.completePayment({status:ApplePaySession.STATUS_FAILURE,errors:[new window.ApplePayError("unknown",void 0,a?.data?.error?.message||a?.data?.error?.code||"Failed to parse authorized response")]})}))},onValidateMerchant:async t=>{try{Salla.event.dispatch("payments::apple-pay.validate-merchant.init",t);const{data:a}=await g.post(SallaApplePay.detail.validateMerchant.url.replace("{id}",SallaApplePay.id),{validation_url:t.validationURL});Salla.event.dispatch("payments::apple-pay.validate-merchant.success",a);const s=t=>{SallaApplePay.session.completeMerchantValidation(t)};if("function"==typeof SallaApplePay.detail.validateMerchant.onSuccess){const t=await SallaApplePay.detail.validateMerchant.onSuccess(a);if(t?.redirect)return window.location=t.redirect,SallaApplePay.abortValidateMerchant(t)}s(a.data)}catch(t){console.error(t),SallaApplePay.abortValidateMerchant(t?.response)}},abortValidateMerchant:(t=null)=>{SallaApplePay.abortSession(),Salla.event.dispatch("payments::apple-pay.validate-merchant.failed",t),"function"==typeof SallaApplePay.detail.validateMerchant.onFailed&&SallaApplePay.detail.validateMerchant.onFailed(t)},onShippingContactSelected:async t=>{salla.logger.log("🍏 Pay: onShippingContactSelected",t.shippingContact),await v(SallaApplePay,t.shippingContact)},onShippingMethodSelected:async t=>{let a=t.shippingMethod.identifier.split(","),s={ship_id:a[0],private_ship_id:void 0===a[1]?null:a[1],type:void 0===a[2]?null:a[2],route_id:void 0===a[3]?null:a[3]};if(salla.logger.log("🍏 Pay: onShippingMethodSelected",{event:t,previous:SallaApplePay.shippingCompany,current:s}),SallaApplePay.shouldUpdateShippingCompany(s))try{await SallaApplePay.selectApplePayShippingMethod(s),await SallaApplePay.recalculateTotal()}catch(t){return salla.logger.warn("🍏 Pay: Failed set the shipping details to api",t),void SallaApplePay.session.completeShippingMethodSelection({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems(),status:SallaApplePay.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}salla.logger.log("🍏 Pay: completeShippingMethodSelection",{newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()}),SallaApplePay.session.completeShippingMethodSelection({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()})},abortSession:()=>{SallaApplePay.session&&SallaApplePay.session.abort()},shouldUpdateShippingCompany:t=>SallaApplePay.shippingCompany?.ship_id!=t?.ship_id||SallaApplePay.shippingCompany?.private_ship_id!=t?.private_ship_id,getApplePaySessionVersion:()=>{if("sallapp"===(navigator.userAgent||navigator.vendor||window.opera))return 5;let t=w.init(),a=parseFloat(t.os.version);if("Macintosh"===t.os.name){if(a<10.142)return 1}else if(a<12.11)return 1;return 5},recalculateTotal:()=>(salla.logger.log("🍏 Pay: recalculate total"),g.get(SallaApplePay.detail.recalculateTotal.url.replace("{id}",SallaApplePay.id),(({data:t})=>{salla.logger.log("🍏 Pay: recalculate total success",t);let a=t.data.initial_data?.cart||t.data.cart,s=t.data.initial_data?.payments||t.data.payments;salla.logger.log("🍏 Pay: recalculate total success",{cart:a,payments:s}),SallaApplePay.detail.amount=s?.gateways?.applePay?.supportedMultiCurrency?a.total_in_customer_currency:a.total,SallaApplePay.detail.items=(a.totals||a.items).map((t=>({label:t.title,amount:"مجاني"===t.amount||"Free"===t.amount?0:t.amount.toString().replace("+","")}))),SallaApplePay.detail.items.pop(),SallaApplePay.totals=SallaApplePay.detail.items}),(t=>(salla.logger.warn("🍏 Pay: recalculate total failed",t),t?.response?.data?.message)))),selectApplePayShippingMethod:t=>{salla.logger.log("🍏 Pay: select shipping method ",t),SallaApplePay.shippingCompany=t;const a={address_id:SallaApplePay.address_id,company_id:t.ship_id,private_company_id:t.private_ship_id,type:t.type||void 0,route_id:t.route_id||void 0,payment_method:"apple_pay"};return g.post(SallaApplePay.detail.shippingMethodSelected.url.replace("{id}",SallaApplePay.id),a,(({data:t})=>("function"==typeof SallaApplePay.detail.shippingMethodSelected.onSuccess&&SallaApplePay.detail.shippingMethodSelected.onSuccess(t),!0)),(t=>{salla.logger.warn("🍏 Pay: Set shipping method failed",t),"function"==typeof SallaApplePay.detail.shippingMethodSelected.onFailed&&SallaApplePay.detail.shippingMethodSelected.onFailed(t);let a=t?.response?.data?.error;return a?.data?.fields?.address_id?a?.data?.fields?.address_id[0]:a?.data?.message}))},mappingShippingMethods:t=>t.map((t=>({label:t.shipping_title,amount:t.enable_free_shipping?0:t.ship_cost,detail:"",identifier:t.ship_id.toString()+(t.private_ship_id?","+t.private_ship_id.toString():"")+(t.type?","+t.type:"")+(t.route_id?","+t.route_id:"")})))},window.ApplePaySession?.canMakePayments()?SallaApplePay.init():document.querySelectorAll("data-show-if-apple-pay-supported").forEach((t=>t.style.display="none"));const S=class{constructor(s){t(this,s),this.validationFailed=a(this,"validationFailed"),this.requireLogin=a(this,"requireLogin"),this.type="buy",this.options={},this.quickBuy=salla.lang.get("pages.products.buy_now"),salla.lang.onLoaded((()=>{this.quickBuy=salla.lang.get("pages.products.buy_now")}))}async quickBuyHandler(){if(salla.config.isGuest()&&!this.isGuestCheckout()){this.requireLogin.emit({productId:this.productId});let t="salla-quick-buy::user.logged-in";return salla.event.on(t,(()=>this.settlePayment())),salla.api.auth.setAfterLoginEvent(t),salla.auth.event.dispatch("login::open",{withoutReload:!0})}await this.settlePayment()}async settlePayment(){let t=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);if(t&&!await t.reportValidity())return this.validationFailed.emit({productId:this.productId}),salla.error(salla.lang.get("common.messages.required_fields"));let a=this.host.getElementSallaData();if(!this.isApplePayActive)return salla.api.request("checkout/quick-purchase/"+this.productId,a,"post").then((t=>(t.data.redirect&&(window.location.href=t.data.redirect),t)));a.is_applepay=!0,"append"in a&&a.append("is_applepay",!0),salla.event.dispatch("payments::apple-pay.start-transaction",{amount:this.amount,currency:this.currency||"SAR",requiredShippingContactFields:this.getRequiredShippingContactFields(),shippingMethods:this.isRequireShipping?[]:void 0,supportedNetworks:salla.config.get("store.settings.buy_now.networks"),supportedCountries:salla.config.get("store.settings.buy_now.countries"),countryCode:salla.config.get("store.store_country")||"SA",validateMerchant:{url:salla.url.get("checkout/applepay/validate"),onSuccess:t=>this.applePayOnly&&!this.productId?this.cartId?(window.SallaApplePay.id=this.cartId,salla.log("🍏 Pay: create checkout success: with id #"+this.cartId),Promise.resolve(t)):(salla.logger.warn("🍏 Pay: trying to create applePay transaction without cartId/ProductId !"),Promise.resolve(t)):salla.api.request("checkout/quick-purchase/"+this.productId,"object"==typeof a?a:void 0,"post",{}).then((t=>t?.data?.redirect?(salla.log("🍏 Pay: create checkout success: redirect exits, go to checkout page"),window.location.href=t.data.redirect.url,t):t?.data?.id?(window.SallaApplePay.id=t.data.id,void salla.log("🍏 Pay: create checkout success: with id #"+window.SallaApplePay.id)):(salla.logger.warn("🍏 Pay: create checkout success: No id, or redirect"),t)))},authorized:{url:salla.url.get("checkout/{id}/payments/submit"),onFailed:t=>{window.SallaApplePay.onCancel({},t?.data?.error?.message||t?.data?.error?.code||salla.lang.get("pages.checkout.payment_failed"))},onSuccess:t=>{window.location.href=t.redirect.url,salla.log("🍏 Pay: authorized Success:: redirect to thank you page, order placed")}},shippingMethodSelected:this.isRequireShipping?{url:salla.url.get("checkout/{id}/shipping/details")}:void 0,shippingContactSelected:this.isRequireShipping?{url:salla.url.get("checkout/{id}/address/add")}:void 0,guestContactSelected:this.isGuestCheckout()?{url:salla.url.get("checkout/{id}/customer")}:void 0,onCouponCodeChanged:{url:salla.url.get("checkout/{id}/coupons")},recalculateTotal:{url:salla.url.get("checkout/{id}/payments/recalculate?payment_method=apple_pay")},onError:function(t){salla.log(t),salla.notify.error(t)}})}isGuestCheckout(){return salla.config.isGuest()&&salla.config.get("store.features").includes("guest-checkout")}getRequiredShippingContactFields(){let t=[];return this.isRequireShipping&&t.push("postalAddress"),this.isGuestCheckout()&&t.push("email","phone","name"),t}componentWillLoad(){console.log("🍏 Pay: Quick Buy Component Loaded");const t="undefined"!=typeof window&&!!window.ApplePaySession?.canMakePayments?.(),a=salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??!0,s=salla?.config?.get?.("store.settings.is_salla_gateway",!1)??!0;this.isApplePayActive=t&&a&&s;const i=async()=>{if(!this.currency&&salla?.config?.get&&(this.currency=salla.config.get("store.settings.buy_now.multi_currency")?salla.config.get("user.currency_code"):"SAR"),!this.productId&&salla?.config?.get&&salla.url?.is_page&&(this.productId=salla.config.get("page.id")),this.applePayOnly||this.productId){if(this.amount&&this.isRequireShipping||!this.productId||!salla?.product?.getDetails||await salla.product.getDetails(this.productId,[]).then((t=>{this.amount=t.data.price,this.isRequireShipping=t?.data?.is_require_shipping||!1})).catch((t=>{salla?.logger?.warn?.("🍏 Pay: Failed load the quick buy, get the product details failed: ",t)})),"donate"===this.type&&salla?.event?.on?salla.event.on("product-options::donation-changed",(t=>{String(t.id)===String(this.productId)&&(this.amount=t.price)})):salla?.url?.is_page?.("product.single")&&salla?.product?.event?.onPriceUpdated&&salla.product.event.onPriceUpdated((t=>{this.amount=t.data.price})),this.isApplePayActive=(salla?.helpers?.hasApplePay?.()??t)&&(salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??a)&&(salla?.config?.get?.("store.settings.is_salla_gateway",!1)??s),!document.getElementById("apple-pay-sdk")&&this.isApplePayActive){const t=document.createElement("script");t.src="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",t.setAttribute("id","apple-pay-sdk"),t.async=!0,document.body.appendChild(t)}}else salla?.logger?.warn?.("🍏 Pay: Failed load the quick buy, the product id is missing")};return new Promise((t=>{"function"==typeof salla?.onReady?salla.onReady((()=>i().then((()=>t(!0))))):i().then((()=>t(!0)))}))}render(){return s(i,{key:"9a36fa6b7163dae6feed474712e3d0c3003d012c"},this.quickBuyButton())}quickBuyButton(){return s("apple-pay-button",{locale:salla?.config?.get?.("user.language_code")||"ar",onClick:()=>this.quickBuyHandler(),"data-quick-purchase":"applepay",class:"s-quick-buy-apple-pay","data-is-applepay":"1",buttonstyle:"black",type:this.type})}get host(){return e(this)}};S.style=".s-quick-buy-button .s-button-text{display:flex}apple-pay-button{--apple-pay-button-width:100%;--apple-pay-button-height:40px;--apple-pay-button-border-radius:.75rem;--apple-pay-button-box-sizing:content-box}";export{c as salla_add_product_button,h as salla_product_availability,m as salla_product_options,S as salla_quick_buy}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
import{r as s,h as t,H as i,a as e,f as a,i as n,j as r,d as l}from"./p-PHxPq4LJ.js";import{i as o}from"./p-BsXh13x8.js";import{a as h}from"./p-CgtvEd63.js";import{H as c}from"./p-DgNC8L6e.js";import{S as m}from"./p-D4oPi1Ov.js";import{a as d}from"./p-BedNk7k1.js";import{S as u}from"./p-DiKTtDW5.js";const p=class{constructor(t){s(this,t),this.placeholder=salla.lang.get("blocks.comments.placeholder"),this.submitText=salla.lang.get("blocks.comments.submit"),salla.lang.onLoaded((()=>{this.placeholder=salla.lang.get("blocks.comments.placeholder"),this.submitText=salla.lang.get("blocks.comments.submit")})),salla.onReady((()=>{this.canComment=salla.config.get("user.can_comment"),this.itemId=salla.config.get("page.id"),this.type=salla.url.is_page("page-single")?"page":salla.url.is_page("blog.single")?"blog":"product"}))}submit(){this.commentForm.reportValidity()?this.submitBtn.load().then((()=>salla.comment.add({id:this.itemId,comment:this.commentField.value,type:this.type}))).finally((()=>this.submitBtn.stop)):salla.log("CommentForm:: validation error!")}render(){return t(i,{key:"fbea28507c188a338ee066b5198bcf93de2fbda2"},this.canComment?t("form",{ref:s=>this.commentForm=s},t("div",{class:"s-comment-form-wrapper"},this.showAvatar?t("img",{class:"s-comment-form-avatar",src:salla.config.get("user.avatar"),alt:"user avatar"}):"",t("div",{class:"s-comment-form-content"},t("textarea",{cols:30,rows:5,minlength:"4",maxlength:"500",ref:s=>this.commentField=s,placeholder:this.placeholder,class:"s-comment-form-input",required:!0}),t("br",null),t("div",{class:"s-comment-form-action"},t("salla-button",{ref:s=>this.submitBtn=s,"loader-position":"center",onClick:()=>this.submit()},this.submitText))))):"")}};p.style=":host{display:block}";const g=class{constructor(t){s(this,t),this.has_bought_trans=salla.lang.get("blocks.comments.has_bought"),this.rated_trans=salla.lang.get("pages.rating.rated"),this.waiting_approval_trans=salla.lang.get("blocks.comments.waiting_approval"),this.has_order_trans=salla.lang.get("blocks.comments.has_order"),this.allowLikes=salla.config.get("store.settings.rating.allow_likes"),this.allowAttachImages=salla.config.get("store.settings.rating.allow_attach_images"),this.helpfulLabel=salla.lang.getWithDefault("blocks.comments.helpful","مفيد"),this.likesCount=0,this.likedComments=[],salla.lang.onLoaded((()=>{const s=(s,t,i)=>new Promise((e=>{salla.helpers.setNested(salla.lang.messages[s],t,i),e(!0)}));this.has_bought_trans=salla.lang.get("blocks.comments.has_bought"),this.rated_trans=salla.lang.get("pages.rating.rated"),this.waiting_approval_trans=salla.lang.get("blocks.comments.waiting_approval"),this.has_order_trans=salla.lang.get("blocks.comments.has_order"),(async()=>{await s("ar.trans","blocks.comments.helpful","مفيد"),await s("en.trans","blocks.comments.helpful","Helpful"),this.helpfulLabel=salla.lang.getWithDefault("blocks.comments.helpful","مفيد")})()}))}componentDidLoad(){this.likesCount=this.comment.likes_count;try{this.likedComments=JSON.parse(localStorage.getItem("liked_comments")||"[]"),this.likedComments.includes(this.comment.id)&&(this.likeBtn.classList.add("liked"),this.likeBtn.fill="solid")}catch{salla.log("Bad json for liked_comments")}}getReplies(){return Array.isArray(this.comment.replies)?this.comment.replies:[this.comment.replies]}getDate(s){const[t]=s.split(" "),[i,e,a]=t.split("-");return`${parseInt(a,10)}/${parseInt(e,10)}/${parseInt(i,10)}`}getTime(s){const[,t]=s.split(" "),[i,e]=t.split(":");return`${parseInt(i,10)}:${parseInt(e,10)}`}async toggleLike(){if(salla.config.isGuest())return salla.notify.error(salla.lang.get("common.messages.must_login"));this.likedComments=JSON.parse(localStorage.getItem("liked_comments")||"[]");const s=this.likedComments.includes(this.comment.id);try{const t=s?`rating/${this.comment.id}/unlike`:`rating/${this.comment.id}/like`,i=await salla.api.request(t,"","put");salla.log(i.message),s?(this.likeBtn.classList.remove("liked"),this.likeBtn.fill="outline",this.updateLikedComments(this.comment.id,!1),this.likesCount--):(this.likeBtn.classList.add("liked"),this.likeBtn.fill="solid",this.updateLikedComments(this.comment.id,!0),this.likesCount++)}catch(s){409==s.response.status&&(this.likeBtn.classList.contains("liked")?(this.likeBtn.fill="outline",this.likeBtn.classList.remove("liked"),this.updateLikedComments(this.comment.id,!1),this.likesCount--):(this.likeBtn.fill="solid",this.likeBtn.classList.add("liked"),salla.logger.warn("Like already exists"),this.updateLikedComments(this.comment.id,!0)))}}updateLikedComments(s,t){this.likedComments=JSON.parse(localStorage.getItem("liked_comments")||"[]"),t?this.likedComments.includes(s)||this.likedComments.push(s):this.likedComments=this.likedComments.filter((t=>t!==s)),localStorage.setItem("liked_comments",JSON.stringify(this.likedComments))}PinnedIcon(){return t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"16",height:"16",color:"#555555",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},t("path",{d:"M12 16V21"}),t("path",{d:"M8 5.2918C8 5.02079 8 4.88529 8.01312 4.77132C8.1194 3.84789 8.84789 3.1194 9.77133 3.01312C9.88529 3 10.0208 3 10.2918 3H13.7082C13.9792 3 14.1147 3 14.2287 3.01312C15.1521 3.1194 15.8806 3.84789 15.9869 4.77132C16 4.88529 16 5.02079 16 5.2918C16 5.37885 16 5.42237 15.9967 5.46264C15.9708 5.78281 15.7927 6.07104 15.5179 6.2374C15.4834 6.25832 15.4444 6.27779 15.3666 6.31672L15.1055 6.44726C14.7021 6.64897 14.5003 6.74983 14.3681 6.90564C14.26 7.03286 14.1856 7.18509 14.1515 7.34846C14.1097 7.54854 14.1539 7.76968 14.2424 8.21197L15 12H15.3333C15.9533 12 16.2633 12 16.5176 12.0681C17.2078 12.2531 17.7469 12.7922 17.9319 13.4824C18 13.7367 18 14.0467 18 14.6667C18 14.9767 18 15.1317 17.9659 15.2588C17.8735 15.6039 17.6039 15.8735 17.2588 15.9659C17.1317 16 16.9767 16 16.6667 16H7.33333C7.02334 16 6.86835 16 6.74118 15.9659C6.39609 15.8735 6.12654 15.6039 6.03407 15.2588C6 15.1317 6 14.9767 6 14.6667C6 14.0467 6 13.7367 6.06815 13.4824C6.25308 12.7922 6.79218 12.2531 7.48236 12.0681C7.73669 12 8.04669 12 8.66667 12H9L9.75761 8.21197C9.84606 7.76968 9.89029 7.54854 9.84852 7.34846C9.81441 7.18509 9.73995 7.03286 9.63194 6.90564C9.49965 6.74983 9.29794 6.64897 8.89452 6.44726L8.63344 6.31672C8.55558 6.27779 8.51665 6.25832 8.48208 6.2374C8.20731 6.07104 8.02917 5.78281 8.00326 5.46264C8 5.42237 8 5.37885 8 5.2918Z"}))}render(){let s="admin"==this.comment.type;return t(i,{key:"05979122884df06d634ab4f75f61d12cee93b228",class:s?"s-comments-item-admin":"s-comments-item"},t("div",{key:"d3be984afb159d8d6a1d4c0daf0bb72c97136a3a",class:{"s-comments-item-wrapper":!s,"s-comments-item-admin-wrapper":s},id:`s-comments-item-${this.comment.id}`},t("div",{key:"29a48174434b634e4afa5a1f2339b04705ea9f90",class:"s-comments-item-inner s-comments-flex-1"},s&&t("span",{key:"b2536843c0549b2eb24759a09f51a97b68e36654",class:"s-comments-item-reply-icon",innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>reply</title>\n<path d="M20 14.667h-12.609l9.401-6.927c0.592-0.436 0.72-1.271 0.283-1.863-0.439-0.595-1.273-0.72-1.864-0.283l-12.667 9.333c-0.343 0.251-0.544 0.649-0.544 1.072s0.201 0.821 0.543 1.073l12.667 9.333c0.237 0.176 0.515 0.26 0.789 0.26 0.409 0 0.813-0.188 1.075-0.543 0.437-0.592 0.309-1.427-0.283-1.863l-9.4-6.928h12.609c4.412 0 8 3.588 8 8 0 0.737 0.597 1.333 1.333 1.333s1.333-0.596 1.333-1.333c0-5.881-4.785-10.667-10.667-10.667z"></path>\n</svg>\n'}),t("div",{key:"553ad8fd8a3ada5cbca3c744f8b80a259ae7d2c2",class:"s-comments-item-avatar"},t("img",{key:"57d429fa1dc545d3fe16c1f4713b960d1d7ef9f8","data-src":this.comment?.avatar,alt:this.comment?.name,src:this.comment?.avatar,class:"s-comments-item-avatar-img lazy"})),t("div",{key:"8b2a3206dfa97c41a731baf18794e44ce096876f",class:"s-comments-flex-1"},t("div",{key:"95ebefb4d82bb66d7cbc567554d0b9da2e4b416a",class:"s-comments-item-user-wrapper"},t("div",{key:"1e6091d08973e5fc2ae8a982e6b09e5d349fede3",class:"s-comments-item-user-info"},t("h3",{key:"ee5ea0ea457fc43ee49cae033097297ab8358f76",class:this.comment.is_pinned?"s-comments-item-user-info-name":"s-comments-item-user-info-name-with-margin"},this.comment?.name),this.comment.is_pinned?t("div",{class:"s-comments-item-pinned-icon-with-margin"},this.PinnedIcon()):null,!this.comment.has_order&&!this.comment.rating||this.comment.is_pending||this.hideBought?null:t("div",{class:"s-comments-flex"},this.comment.has_order?[t("span",{class:"s-comments-item-has-order-check-icon",innerHTML:o}),t("span",{class:"s-comments-item-has-order-check-text"},this.has_bought_trans," ",this.comment.rating?", ":"")]:null,this.comment.rating?t("span",{class:"s-comments-item-rated-widget"},this.rated_trans):null)),t("p",{key:"80c430d77b6ae3e959db9bc089fd7fe834e56bd2",class:"s-comments-item-timestamp s-ltr"},this.getDate(this.comment.created_at?.date),t("span",{key:"49a1b26309490d6252f0fbd53b50374cbf10071d",class:"s-comments-item-time"}," - ",this.getTime(this.comment.created_at?.date))),this.comment.rating||this.comment.stars?t("salla-rating-stars",{size:"mini",class:"s-comments-item-stars",value:this.comment.rating||this.comment.stars}):null),t("div",{key:"780bee1166000b296e6956921c71cfd4f48e8153",class:"s-comments-item-content"},t("p",{key:"9ff2a32cbd551ff911300ce6cfa1065770117a18",innerHTML:this.comment.content}),this.allowAttachImages&&t("div",{key:"f47022f4916c3d4e0641273612b4a5f7c69a4595",class:"s-comments-item-images"},this.comment.images.map(((s,i)=>t("img",{key:i,src:s,alt:"",onClick:()=>this.modal.open()}))),t("salla-modal",{key:"8e70ec00301d369bbed5c1f11a1887a0498e2b0c",ref:s=>this.modal=s,width:"sm"},t("salla-slider",{key:"65cb35fd60869f64780fbb5bfc61fbc3cddc49c9",id:`s-comments-item-${this.comment.id}-images`,class:"s-comments-item-images-slider",type:"thumbs","auto-height":!0,showControls:this.comment.images.length>1,"show-thumbs-controls":"false"},t("div",{key:"bb0cf465f99ecfe9ee10dfb96949cd7b5793da90",slot:"items"},this.comment.images.map(((s,i)=>t("img",{key:i,src:s,alt:""})))),t("div",{key:"e195759f1df5a87b761478ac4a379411f284785c",slot:"thumbs"},this.comment.images.map(((s,i)=>t("div",{class:"s-comments-item-images-slider-thumb"},t("img",{key:i,src:s,alt:""})))))))),this.allowLikes&&!s&&salla.url.is_page("product.single")?t("salla-button",{ref:s=>this.likeBtn=s,class:"s-comments-item-like-btn "+(this.likedComments.includes(this.comment.id)?"liked":""),loaderPosition:"center",fill:"outline",size:"small",onClick:()=>this.toggleLike()},t("span",null,this.helpfulLabel," ",this.likesCount>0?`(${this.likesCount})`:""),t("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>thumbs-up</title>\n<path d="M26.667 10.667h-8.261l1.279-3.38c0.723-1.911 0.087-4.051-1.549-5.203-0.909-0.639-2.004-0.881-3.085-0.684-1.101 0.203-2.061 0.837-2.703 1.787l-5.452 8.067c-0.148 0.22-0.228 0.48-0.228 0.747v12c0 3.676 2.991 6.667 6.667 6.667h8.688c2.535 0 4.817-1.407 5.955-3.671l2.548-5.063c0.093-0.187 0.143-0.392 0.143-0.6v-6.667c0-2.205-1.795-4-4-4zM28 21.017l-2.405 4.78c-0.683 1.359-2.052 2.203-3.573 2.203h-8.688c-2.205 0-4-1.795-4-4v-11.592l5.223-7.728c0.237-0.352 0.584-0.585 0.975-0.657 0.367-0.067 0.749 0.017 1.068 0.241 0.631 0.444 0.879 1.317 0.591 2.079l-1.963 5.185c-0.156 0.409-0.099 0.869 0.149 1.229s0.66 0.576 1.099 0.576h10.192c0.735 0 1.333 0.599 1.333 1.333zM2.667 10.667c-0.736 0-1.333 0.597-1.333 1.333v16c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-16c0-0.736-0.597-1.333-1.333-1.333z"></path>\n</svg>\n'})):"",this.comment.is_pending?t("span",{class:"s-comments-item-pending-text"},this.waiting_approval_trans):null))),this.getReplies().length&&!s?this.getReplies().map((s=>t("div",null,t("salla-comment-item",{comment:s})))):null))}get host(){return e(this)}};var v;g.style=":host{display:block}",function(s){s.PAGE="page",s.PRODUCT="product",s.BLOG="blog"}(v||(v={}));const f=class{constructor(t){s(this,t),this.type=v.PAGE,this.showFormAvatar=!1,this.hideBought=!1,this.testimonials=!1,this.noComments=salla.lang.get("blocks.comments.no_comments"),this.comment_title=salla.lang.get("blocks.comments.title"),this.comment_name=salla.lang.get("blocks.comments.comment"),this.showRatingSummary=salla.config.get("store.settings.rating.show_rating_summary"),this.allowLikes=salla.config.get("store.settings.rating.allow_likes"),salla.onReady((()=>{this.allowLikes=salla.config.get("store.settings.rating.allow_likes"),this.showRatingSummary=salla.config.get("store.settings.rating.show_rating_summary")})),salla.lang.onLoaded((()=>{this.comment_title=salla.lang.get("blocks.comments.title"),this.comment_name=salla.lang.get("blocks.comments.comment"),this.noComments=salla.lang.get("pages.rating.no_ratings");const s=(s,t,i)=>new Promise((e=>{salla.helpers.setNested(salla.lang.messages[s],t,i),e(!0)}));(async()=>{await s("ar.trans","blocks.comments.most_helpful","الأكثر إفادة"),await s("en.trans","blocks.comments.most_helpful","Most helpful"),this.mostHelpfulLabel=salla.lang.get("blocks.comments.most_helpful"),this.comment_title=salla.lang.get("blocks.comments.title"),this.comment_name=salla.lang.get("blocks.comments.comment"),this.noComments=salla.lang.get("pages.rating.no_ratings")})()}))}pluralize(s,t){const i=s.split("|"),e=[{condition:0===t,index:0},{condition:1===t,index:1},{condition:2===t,index:2},{condition:t>2&&t<=10,index:3},{condition:t>=11,index:4}],{index:a}=e.find((({condition:s})=>s))||{index:i.length-1};return i[a].replace(":count",salla.helpers.number(t.toString())).replace(/\{[0-9]+\}/g,"").replace(/\[\d+,\d+\]|\[11,\*\]/g,"")}wrapConsoleError(){Salla.infiniteScroll.errorWrapped||((()=>{const s=console.error.bind(console);console.error=(...t)=>{const i=t[0];return"string"==typeof i&&i.toLowerCase().replace(/\s/g,"").includes("infinitescroll")?console.log(...t):s(...t)}})(),Salla.infiniteScroll.errorWrapped=!0)}initiateInfiniteScroll(){this.wrapper?(this.wrapConsoleError(),this.infiniteScroll=salla.infiniteScroll.initiate(this.wrapper,this.wrapper,{path:()=>this.nextPage,history:!1,nextPage:this.nextPage,scrollThreshold:!1},!0),this.infiniteScroll?.on("request",(()=>{this.loading()})),this.infiniteScroll?.on("load",(s=>{this.pagination=s.pagination,this.nextPage="object"==typeof s.pagination.links&&s.pagination.links.next?s.pagination.links.next:null;for(const t of this.handleResponse(s))this.wrapper.append(t);const t=this.host.querySelectorAll("salla-comment-item:not(.animated):not(.s-comments-item-admin)");this.animateItems(t),this.loading(!1)})),this.infiniteScroll?.on("error",(s=>{salla.console.error("Error loading more comments:",s)}))):console.error("Wrapper is undefined. Cannot initiate infinite scroll.")}loading(s=!0){const t=this.status?.querySelector(".s-button-text");t&&(c.toggleElementClassIf(t,"s-button-hide","s-button-show",(()=>s)),this.btnLoader.style.display=s?"inherit":"none")}animateItems(s){h({targets:s,opacity:[0,1],duration:1200,translateY:[20,0],delay:(s,t)=>100*t,easing:"easeOutExpo",complete:()=>{for(const t of s)t.classList.add("animated")}})}async reload(){if(this.showPlaceholder=!1,this.wrapper){this.wrapper.innerHTML="";const s=document.createElement("salla-loading");this.wrapper.append(s)}this.nextPage=null,this.loadInitialData()}getCommentHTML(s){const t=document.createElement("salla-comment-item");return t.comment=s,t.hideBought=this.hideBought,t}handleResponse(s){return s.data?.map((s=>this.getCommentHTML(s)))||[]}componentWillLoad(){return salla.onReady().then((()=>{this.showRatingSummary=salla.config.get("store.settings.rating.show_rating_summary")})).then((()=>this.loading())).then((()=>(this.hideTitle=this.hideTitle||this.testimonials,this.hideForm=this.hideForm||this.testimonials,this.loadInitialData())))}async loadInitialData(){try{let s={data:[],pagination:{}};const t=new URLSearchParams(window.location.search);if(t.has("sort")&&(this.sort=t.get("sort")),this.testimonials){const t={sort:this.sort,type:"store"};s=await salla.api.request("reviews",{params:t},"get")}else s=await salla.api.comment.getComments(this.type,this.itemId,1,5,this.sort);if(!s.data||!s.data.length)return this.showPlaceholder=!1,void this.loading(!1);if(this.wrapper&&(this.wrapper.innerHTML=""),this.comments=s.data,this.pagination=s.pagination,this.total=s.pagination.total,this.nextPage="object"==typeof s.pagination.links&&s.pagination.links.next?s.pagination.links.next:null,this.nextPage&&this.sort)try{const s=new URL(this.nextPage,window.location.origin);s.searchParams.get("sort")||(s.searchParams.set("sort",this.sort),this.nextPage=s.toString())}catch(s){const t=this.nextPage.includes("?");/[?&]sort=/.test(this.nextPage)||(this.nextPage=this.nextPage+(t?"&":"?")+`sort=${this.sort}`)}setTimeout((()=>{for(const t of this.handleResponse(s))this.wrapper.append(t);this.initiateInfiniteScroll();const t=this.wrapper.querySelectorAll("salla-comment-item:not(.animated)");this.animateItems(t)}),100)}catch(s){console.error("Error loading initial data:",s),this.showPlaceholder=!0,this.loading(!1)}}async loadMore(){this.infiniteScroll?.loadNextPage()}render(){return this.showPlaceholder?t("div",null,this.total&&!this.hideTitle?t("h2",{class:"s-comments-title"},this.blockTitle?this.blockTitle:this.comment_title):"",this.hideForm||this.testimonials?"":t("salla-comment-form",{showAvatar:this.showFormAvatar,type:this.type,"item-id":this.itemId}),t("div",{class:"s-comments-placeholder"},t("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>chat-bubbles</title>\n<path d="M15.333 17.333c4.779 0 8.667-3.888 8.667-8.667s-3.888-8.667-8.667-8.667h-6.667c-4.779 0-8.667 3.888-8.667 8.667 0 2.985 1.513 5.712 4 7.297v4.703c0 0.497 0.277 0.953 0.717 1.183 0.195 0.1 0.405 0.151 0.616 0.151 0.269 0 0.536-0.081 0.764-0.241l6.323-4.425zM11.236 14.908l-4.569 3.199v-2.913c0-0.5-0.28-0.959-0.725-1.187-2.020-1.035-3.275-3.080-3.275-5.34 0-3.308 2.692-6 6-6h6.667c3.308 0 6 2.692 6 6s-2.692 6-6 6h-3.333c-0.273 0-0.54 0.084-0.764 0.241zM29.196 12.964c-0.543-0.5-1.388-0.464-1.884 0.077-0.5 0.541-0.465 1.385 0.077 1.884 1.253 1.156 1.944 2.72 1.944 4.408 0 2.26-1.255 4.305-3.275 5.339-0.445 0.228-0.725 0.687-0.725 1.188v2.572l-5.441-2.939c-0.195-0.104-0.412-0.16-0.633-0.16h-2.592c-1.688 0-3.309-0.724-4.451-1.988-0.492-0.545-1.335-0.591-1.883-0.096-0.547 0.493-0.589 1.336-0.096 1.883 1.644 1.823 3.988 2.868 6.429 2.868h2.255l7.111 3.84c0.199 0.107 0.417 0.16 0.635 0.16 0.236 0 0.472-0.063 0.683-0.188 0.404-0.241 0.651-0.676 0.651-1.145v-4.036c2.487-1.585 4-4.311 4-7.297 0-2.407-1.023-4.727-2.804-6.369z"></path>\n</svg>\n'}),t("p",null,this.noComments))):t("div",{class:`s-comments s-comments-${this.testimonials?"testimonials":this.type}`},t("div",{class:this.type===v.PAGE?"s-comments-page-container":"s-comments-container"},this.total&&!this.hideTitle?t("h2",{class:"s-comments-title"},this.blockTitle?this.blockTitle:this.comment_title):"",!this.hideForm&&t("salla-comment-form",{showAvatar:this.showFormAvatar,type:this.type,"item-id":this.itemId}),salla.url.is_page("product.single")?t("salla-reviews-summary",{itemId:this.itemId}):"",t("div",{class:"s-comments-header "+(this.total?"has-total":"")},!!this.total&&t("span",{class:"s-comments-count-label",innerHTML:this.pluralize(this.comment_name,this.total)}),this.total&&!this.testimonials&&this.type!==v.BLOG?t("div",{class:"s-comments-filter-wrapper"},t("label",{class:"s-comments-filter-label",htmlFor:"comments-filter"},salla.lang.get("pages.categories.sorting")),t("select",{id:"comments-filter","aria-label":salla.lang.get("pages.categories.sorting"),class:"s-form-control s-comments-sort-input",onChange:s=>{this.sort=s.target.value,this.reload()}},t("option",{value:"latest",selected:!0},salla.lang.get("pages.testimonials.sort_by_date_desc")),t("option",{value:"oldest"},salla.lang.get("pages.testimonials.sort_by_date_asc")),this.allowLikes&&t("option",{value:"most_helpful"},this.mostHelpfulLabel))):""),t("div",{ref:s=>{this.wrapper=s}}),this.nextPage&&t("div",{class:"s-infinite-scroll-wrapper",ref:s=>{this.status=s}},t("button",{onClick:()=>this.loadMore(),class:"s-infinite-scroll-btn s-button-btn s-button-primary",type:"button"},t("span",{class:"s-button-text s-infinite-scroll-btn-text"},this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more")),t("span",{class:"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader",ref:s=>{this.btnLoader=s},style:{display:"none"}})))))}get host(){return e(this)}};f.style=":host{display:block}";const w=class{constructor(t){s(this,t),this.translationsLoaded=!1,this.labels=[],this.reviewLabel="",this.selectedStar=0,this.name="rating",this.size="medium",this.reviews=0,this.editable=!1}async componentWillLoad(){await new Promise((s=>{salla.lang.onLoaded((()=>{this.labels=[salla.lang.get("pages.rating.poor"),salla.lang.get("pages.rating.average"),salla.lang.get("pages.rating.good"),salla.lang.get("pages.rating.very_good"),salla.lang.get("pages.rating.excellent")],this.value&&this.withLabel&&(this.reviewLabel=this.labels[this.value-1]),this.reviewsElement&&(this.reviewsElement.innerText=`(${salla.helpers.number(salla.lang.choice("pages.rating.reviews",this.reviews))})`),this.translationsLoaded=!0,s()}))}))}initiateRating(){this.host.addEventListener("click",this.handleRating.bind(this))}handleRating(){if(!this.starsElem)return;let s=this.starsElem.querySelectorAll(".s-rating-stars-hovered"),t=s[s.length-1];if(!t)return;let i=parseInt(t.getAttribute("data-star"));this.starsElem.querySelector(".rating_hidden_input").value=i.toString(),this.starsElem.querySelectorAll(".s-rating-stars-btn-star").forEach(((s,t)=>c.toggleElementClassIf(s,"s-rating-stars-selected","s-rating-stars-unselected",(()=>t<i)))),this.starsElem.querySelectorAll("[aria-pressed]").forEach((s=>s.removeAttribute("aria-pressed"))),t.setAttribute("aria-pressed","true"),this.selectedStar=i,this.withLabel&&(this.reviewLabel=this.labels[i-1])}triggerRatingProgrammatically(s){if(!this.starsElem)return;const t=this.starsElem.querySelectorAll(".s-rating-stars-btn-star");t&&s>=0&&s<=t.length&&(t.forEach(((t,i)=>{t.classList.toggle("s-rating-stars-hovered",i<=s)})),this.handleRating())}highlightSelectedStars(){let s="s-rating-stars-hovered",t=this.starsElem?.querySelectorAll(".s-rating-stars-btn-star");t?.forEach(((i,e)=>{i.addEventListener("mouseover",(()=>{for(let i=0;i<=e;i++)t[i].classList.add(s);this.withLabel&&(this.reviewLabel=this.labels[e])})),i.addEventListener("mouseout",(()=>{i.classList.remove(s),this.withLabel&&(this.reviewLabel=this.selectedStar?this.labels[this.selectedStar-1]:"")}))})),this.starsElem?.addEventListener("mouseout",(()=>t.forEach((t=>t.classList.remove(s)))))}createStars(s){let i=[];for(let e=0;e<5;e++)i.push(t("span",{class:{"s-rating-stars-btn-star":!0,["s-rating-stars-"+this.size]:!0,"s-rating-stars-selected":e<s},innerHTML:m}));return this.reviews>0&&i.push(t("span",{class:"s-rating-stars-reviews",ref:s=>this.reviewsElement=s},"(",salla.helpers.number(salla.lang.choice("pages.rating.reviews",this.reviews)),")")),i}render(){return this.translationsLoaded?this.host.closest(".swiper-slide")?.classList.contains("swiper-slide-duplicate")?"":t(i,null,t("div",{class:"s-rating-stars-wrapper"},!this.value&&0!=this.value||this.editable?t("div",{class:"s-rating-stars-element",ref:s=>this.starsElem=s},t("input",{type:"hidden",class:"rating_hidden_input",name:this.name,value:""}),[1,2,3,4,5].map((s=>t("button",{class:"s-rating-stars-btn-star s-rating-stars-"+this.size,"data-star":s},t("span",{innerHTML:m}))))):this.createStars(this.value),this.withLabel&&this.reviewLabel?t("span",{class:"s-rating-stars-label"},this.reviewLabel):"")):t(i,null)}componentDidLoad(){if(this.initiateRating(),this.highlightSelectedStars(),this.value&&this.editable){const s=this.starsElem?.querySelectorAll(".s-rating-stars-btn-star");s&&this.value>=0&&this.value<=s.length&&this.triggerRatingProgrammatically(this.value-1)}}get host(){return e(this)}};w.style="";const b=class{constructor(t){s(this,t),this.currentSlide=0,this.showPurchaseCount=!1,this.startPoint={x:0,y:0},this.isSwiping=!1,this.isRTL="rtl",this.handlePointerDown=s=>{s.isPrimary&&(this.sliderElement?.setPointerCapture(s.pointerId),this.startSwipe(s.clientX,s.clientY),s.preventDefault())},this.handlePointerMove=s=>{this.isSwiping&&s.isPrimary&&s.preventDefault()},this.handlePointerUp=s=>{this.isSwiping&&s.isPrimary&&(this.sliderElement?.releasePointerCapture(s.pointerId),this.endSwipe(s.clientX,s.clientY))},this.handlePointerCancel=s=>{this.isSwiping&&s.isPrimary&&(this.sliderElement?.releasePointerCapture(s.pointerId),this.isSwiping=!1)},this.goToSlide=s=>{this.currentSlide=Math.max(0,Math.min(s,this.images.length-1))}}async componentDidLoad(){await salla.onReady(),this.showPurchaseCount=!!salla.config.get("store.settings.product.total_sold_enabled",!1),this.isRTL=salla.config.get("theme.is_rtl",!0),this.purchasedCount=salla.lang.getWithDefault("blocks.home.reviews.purchased_count",this.isRTL?` تم شراءه ${this.review.product?.sold_quantity} مرة`:`Purchased ${this.review.product.sold_quantity} times`,{count:this.review.product?.sold_quantity}),this.initializeSlider()}disconnectedCallback(){this.removeEventListeners()}get images(){const{review:s}=this;return s?.images?.length>1?s.images.map(((s,t)=>({url:s,alt:"",id:t}))):s?.product?.images||[]}get hasMultipleImages(){return this.images.length>1}get slideTransform(){return`translateX(${100*this.currentSlide*(this.isRTL?1:-1)}%)`}initializeSlider(){this.hasMultipleImages&&(this.sliderElement=this.el.querySelector(".s-review-card-slider-container"),this.sliderElement&&(this.sliderElement.style.touchAction="pan-y pinch-zoom",this.addEventListeners()))}addEventListeners(){this.sliderElement&&(this.sliderElement.addEventListener("pointerdown",this.handlePointerDown,{passive:!1}),this.sliderElement.addEventListener("pointermove",this.handlePointerMove,{passive:!1}),this.sliderElement.addEventListener("pointerup",this.handlePointerUp,{passive:!0}),this.sliderElement.addEventListener("pointercancel",this.handlePointerCancel,{passive:!0}))}removeEventListeners(){this.sliderElement&&(this.sliderElement.removeEventListener("pointerdown",this.handlePointerDown),this.sliderElement.removeEventListener("pointermove",this.handlePointerMove),this.sliderElement.removeEventListener("pointerup",this.handlePointerUp),this.sliderElement.removeEventListener("pointercancel",this.handlePointerCancel))}startSwipe(s,t){this.startPoint={x:s,y:t},this.isSwiping=!0}componentDidRender(){this.removeEventListeners(),this.addEventListeners()}endSwipe(s,t){this.isSwiping=!1,this.processSwipe(s-this.startPoint.x,t-this.startPoint.y)}processSwipe(s,t){if(Math.abs(s)<10||Math.abs(t)>Math.abs(s))return;const i=s<0;(this.isRTL?!i:i)?this.goToNextSlide():this.goToPrevSlide()}goToNextSlide(){this.currentSlide<this.images.length-1&&this.currentSlide++}goToPrevSlide(){this.currentSlide>0&&this.currentSlide--}renderStars(){return Array(5).fill(null).map(((s,i)=>t("span",{key:i,innerHTML:this.review.stars>=i+1?' <svg width="18" height="17" view-box="0 0 18 17" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M9.00045 13.6951L3.71036 16.6563L4.89186 10.71L0.440918 6.59397L6.4612 5.88017L9.00045 0.375122L11.5396 5.88017L17.5599 6.59397L13.109 10.71L14.2905 16.6563L9.00045 13.6951Z" fill="currentcolor" />\n</svg>':' <svg width="18" height="17" view-box="0 0 18 17" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M9.00045 13.6951L3.71036 16.6563L4.89186 10.71L0.440918 6.59397L6.4612 5.88017L9.00045 0.375122L11.5396 5.88017L17.5599 6.59397L13.109 10.71L14.2905 16.6563L9.00045 13.6951Z" fill="#DDDDDD" />\n</svg>'})))}renderDots(){return this.images.map((({url:s},i)=>t("button",{key:s||i,type:"button",class:"s-review-card-slider-dot "+(this.currentSlide===i?"active":""),onClick:()=>this.goToSlide(i),"aria-label":`Go to slide ${i+1}`,onPointerDown:()=>this.goToSlide(i)})))}renderSlider(){return this.hasMultipleImages?t("div",{class:"s-review-card-slider-container"},t("div",{class:"s-review-card-slides",style:{transform:this.slideTransform}},this.images.map((s=>t("div",{key:s?.id,class:"s-review-card-slider-slide"},t("img",{src:s.url,alt:s.alt||"Product image",width:275,height:275,loading:"lazy",draggable:!1}))))),t("div",{class:"s-review-card-slider-dots"},this.renderDots())):null}renderSingleImage(){const s=this.review?.product?.image;return!s||this.hasMultipleImages?null:t("img",{src:s.url,alt:s.alt||"Product image",class:"s-review-card-image",width:275,height:275,loading:"lazy",decoding:"async",draggable:!1})}renderHeader(){return t("div",{class:"s-review-card-header"},t("div",{class:"s-review-card-reviewer-name"},t("p",null,this.review?.name),this.review?.has_order&&t("span",{class:"s-review-card-verified-icon",innerHTML:o})),t("div",{class:"s-review-card-stars"},this.renderStars()))}renderProductInfo(){const s=this.review?.product;return s?t("a",{href:this.review?.product?.url,class:"s-review-card-product-container"},t("img",{alt:s.image?.alt||"Product",src:s.image?.url,class:"s-review-card-product-image",width:60,height:60,loading:"lazy",decoding:"async",draggable:!1}),t("div",{class:"s-review-card-product-details"},t("p",{class:"s-review-card-product-details-name"},s.name),this.showPurchaseCount?t("p",{class:"s-review-card-product-details-purchase-count"},t("span",{innerHTML:' <svg width="12" height="17" view-box="0 0 12 17" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M6 16.2501C9.10658 16.2501 11.625 13.7317 11.625 10.6251C11.625 9.976 11.4523 9.35252 11.25 8.77232C9.99998 10.0075 9.05002 10.6251 8.4 10.6251C11.3966 5.37512 9.75 3.12512 5.25 0.125122C5.625 3.87475 3.15302 5.58043 2.14634 6.52757C1.0559 7.5535 0.375 9.00977 0.375 10.6251C0.375 13.7317 2.89339 16.2501 6 16.2501ZM6.53205 2.92636C8.96333 4.98908 8.97495 6.59185 7.09725 9.88157C6.5265 10.8815 7.2486 12.1251 8.4 12.1251C8.9163 12.1251 9.43807 11.9745 9.98917 11.6789C9.52342 13.4466 7.91393 14.7501 6 14.7501C3.72182 14.7501 1.875 12.9033 1.875 10.6251C1.875 9.47072 2.34959 8.39582 3.17419 7.62002C3.2687 7.53115 3.74812 7.1062 3.76858 7.08782C4.08646 6.8017 4.34835 6.54985 4.60718 6.2727C5.52998 5.28461 6.19283 4.18735 6.53205 2.92636Z" fill="currentcolor" />\n </svg>'}),this.purchasedCount):null)):null}render(){return t("div",{key:"251b76f2f2935ab7be248f589badaebe0f297cb2",class:"s-review-card-container"},this.renderSlider(),this.renderSingleImage(),y(),t("div",{key:"2621097a4115e278b1b99d46b6be22341a7ea064",class:"s-review-card-content"},this.renderHeader(),t("p",{key:"cd641970280867954f431fc3a2812080ebe32bd9",class:"s-review-card-review-content",innerHTML:this.review?.content}),y(),this.renderProductInfo()))}get el(){return e(this)}},y=()=>t("div",{class:"s-review-card-divider "});b.style=":host{display:block}";const k=class{constructor(t){s(this,t),this.limit=5,this.type="store",this.sort="latest",this.hideCustomerInfo=!1,this.reviews=[],this.showReviews=!1,this.testimonialText=salla.lang.get("blocks.home.testimonials"),this.displayAllLinkText=salla.lang.get("blocks.home.display_all"),this.displayAllURL=null,this.source=this.source,salla.onReady((()=>{this.displayAllURL=salla.url.get("testimonials"),this.isRTL=salla.config.get("theme.is_rtl",!0)})),salla.lang.onLoaded((()=>{this.testimonialText=salla.lang.get("blocks.home.testimonials"),this.displayAllLinkText=salla.lang.get("blocks.home.display_all")}))}fetchReviews(){if("json"===this.source)return Promise.resolve(JSON.parse(this.sourceValue));const s=["products","categories"].includes(this.source),t={limit:this.limit,source:this.source,items:s?JSON.parse(this.sourceValue):this.sourceValue,sort:this.sort,type:this.type,hide_customer_info:this.hideCustomerInfo?1:0};return salla.api.request("reviews",{params:t},"get")}componentWillLoad(){return new Promise((s=>salla.onReady(s))).then((()=>this.fetchReviews())).then((s=>s.data||[])).then((s=>{s.length&&(this.reviews=s,this.showReviews=!0,c.generateReviewSchema(this.reviews))}))}render(){return t("div",{key:"aa4937182950d1b0fbcb67aa577d6fb3c413af79",class:"s-reviews-container"},t("div",{key:"dbfb22a037c29a0bf88b73481aa8ea4988ef819a",class:"s-reviews-header-wrapper"},t("h1",{key:"7b874af56f8933777942d829d1311cd0854e5a12",class:"s-reviews-header"},this.testimonialText),this.displayAllLink?t("a",{href:this.displayAllURL,class:"s-reviews-display-all"},this.displayAllLinkText,t("span",{class:"s-reviews-display-all-icon",innerHTML:d})):null),t("salla-slider",{key:"0050aac87a3aadc858aa352ba7ac82158bb586de",centered:!0,"slides-per-view":1,type:"testimonials",class:"s-reviews-testimonials-slider","controls-outer":!0,"auto-play":!0,id:`testimonials-${this.source}-slider`},t("div",{key:"7d1801d35aeba19fa913609202128b6866ca7118",slot:"items"},this.reviews.map(((s,i)=>t("div",{key:i,class:"s-reviews-swiper-slide"},t("div",{class:"s-reviews-testimonial"},t("div",{class:"s-reviews-testimonial__inner"},t("div",{class:"s-reviews-testimonial__avatar"},t("img",{src:"images/s-empty.png","data-src":s.avatar,alt:s.name?s.name:"testimonial-"+i,class:"lazy"})),t("div",{class:"s-reviews-testimonial__text"},t("p",{innerHTML:s.content}),t("div",{class:"s-reviews-testimonial__name_wrapper"},t("div",{class:"s-reviews-testimonial__info"},s.name&&t("h2",null,`${s.name}`)),t("div",{class:"s-reviews-testimonial__rating"},t("salla-rating-stars",{size:"small",value:s.stars})))),t("span",{class:"s-reviews-testimonial__icon",innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>quote-open</title>\n<path d="M8 12v-5.333c0-0.737-0.596-1.333-1.333-1.333-3.676 0-6.667 2.991-6.667 6.667v8c0 3.676 2.991 6.667 6.667 6.667h1.333c3.676 0 6.667-2.991 6.667-6.667v-1.333c0-3.676-2.991-6.667-6.667-6.667zM12 20c0 2.205-1.795 4-4 4h-1.333c-2.205 0-4-1.795-4-4v-8c0-1.739 1.115-3.221 2.667-3.772v5.105c0 0.737 0.596 1.333 1.333 1.333h1.333c2.205 0 4 1.795 4 4zM25.333 12v-5.333c0-0.737-0.596-1.333-1.333-1.333-3.676 0-6.667 2.991-6.667 6.667v8c0 3.676 2.991 6.667 6.667 6.667h1.333c3.676 0 6.667-2.991 6.667-6.667v-1.333c0-3.676-2.991-6.667-6.667-6.667zM29.333 20c0 2.205-1.795 4-4 4h-1.333c-2.205 0-4-1.795-4-4v-8c0-1.739 1.115-3.221 2.667-3.772v5.105c0 0.737 0.596 1.333 1.333 1.333h1.333c2.205 0 4 1.795 4 4z"></path>\n</svg>\n'})))))))))}};var _,C,L,x,M,S,T,z,H,$,P,I;function D(){if($)return H;$=1;var s=n(),t=function(){if(C)return _;C=1;var s=a();return _=function(){return s.Date.now()}}(),i=function(){if(z)return T;z=1;var s=function(){if(S)return M;S=1;var s=function(){if(x)return L;x=1;var s=/\s/;return L=function(t){for(var i=t.length;i--&&s.test(t.charAt(i)););return i}}(),t=/^\s+/;return M=function(i){return i?i.slice(0,s(i)+1).replace(t,""):i}}(),t=n(),i=r(),e=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,l=/^0o[0-7]+$/i,o=parseInt;return T=function(n){if("number"==typeof n)return n;if(i(n))return NaN;if(t(n)){var r="function"==typeof n.valueOf?n.valueOf():n;n=t(r)?r+"":r}if("string"!=typeof n)return 0===n?n:+n;n=s(n);var h=a.test(n);return h||l.test(n)?o(n.slice(2),h?2:8):e.test(n)?NaN:+n}}(),e=Math.max,l=Math.min;return H=function(a,n,r){var o,h,c,m,d,u,p=0,g=!1,v=!1,f=!0;if("function"!=typeof a)throw new TypeError("Expected a function");function w(s){var t=o,i=h;return o=h=void 0,p=s,m=a.apply(i,t)}function b(s){var t=s-u;return void 0===u||t>=n||t<0||v&&s-p>=c}function y(){var s=t();if(b(s))return k(s);d=setTimeout(y,function(s){var t=n-(s-u);return v?l(t,c-(s-p)):t}(s))}function k(s){return d=void 0,f&&o?w(s):(o=h=void 0,m)}function _(){var s=t(),i=b(s);if(o=arguments,h=this,u=s,i){if(void 0===d)return function(s){return p=s,d=setTimeout(y,n),g?w(s):m}(u);if(v)return clearTimeout(d),d=setTimeout(y,n),w(u)}return void 0===d&&(d=setTimeout(y,n)),m}return n=i(n)||0,s(r)&&(g=!!r.leading,c=(v="maxWait"in r)?e(i(r.maxWait)||0,n):c,f="trailing"in r?!!r.trailing:f),_.cancel=function(){void 0!==d&&clearTimeout(d),p=0,o=u=h=d=void 0},_.flush=function(){return void 0===d?m:k(t())},_},H}k.style="";var E=l(function(){if(I)return P;I=1;var s=D(),t=n();return P=function(i,e,a){var n=!0,r=!0;if("function"!=typeof i)throw new TypeError("Expected a function");return t(a)&&(n="leading"in a?!!a.leading:n,r="trailing"in a?!!a.trailing:r),s(i,e,{leading:n,maxWait:e,trailing:r})}}());class R{constructor(s){this.grid=s,this.create=()=>{this.mutationObserver.observe(this.grid,{childList:!0});for(const s of Array.from(this.grid.children))this.resizeObserver.observe(s)},this.onContainerMutation=s=>{const t=s.flatMap((s=>Array.from(s.removedNodes))),i=s.flatMap((s=>Array.from(s.addedNodes)));for(const s of t)s instanceof Element&&this.resizeObserver.unobserve(s);for(const s of i)s instanceof Element&&this.resizeObserver.observe(s);t.length>0&&0===i.length&&this.update()},this.onChildrenResize=s=>{s.filter((s=>null!==s.target.parentElement)).length>0&&this.update()},this.update=E((()=>{const s=window.getComputedStyle(this.grid);if(!1===s.getPropertyValue("display").includes("grid"))return void this.clean();const t=function(s){return window.getComputedStyle(s).getPropertyValue("grid-template-columns").trim().split(/\s+(?=(?:[^()]*\([^()]*\))*[^()]*$)/)}(this.grid);if(t.length<=1)return void this.clean();const i=Number.parseFloat(s.getPropertyValue("row-gap").trim())||0,e=Array.from(this.grid.children);for(let s=0;s<t.length;s++){const t=e[s];t?.style.removeProperty("margin-top")}for(let s=0;s<e.length;s++){const a=e[s-t.length],n=e[s];if(void 0!==a&&void 0!==n){const s=a.getBoundingClientRect().bottom;n.style.removeProperty("margin-top");const t=n.getBoundingClientRect().top;if(t-i!==s){const e=Math.round(100*(s-(t-i)+Number.EPSILON))/100;n.style.setProperty("margin-top",`${e}px`)}}}}),32),this.destroy=()=>{this.resizeObserver.disconnect(),this.mutationObserver.disconnect(),this.clean()},this.clean=()=>{for(const s of Array.from(this.grid.children))s.style.removeProperty("margin-top")},this.mutationObserver=new MutationObserver(this.onContainerMutation),this.resizeObserver=new ResizeObserver(this.onChildrenResize),!1===CSS.supports("grid-template-rows","masonry")&&this.create()}[Symbol.dispose](){this.destroy()}}const N=class{constructor(t){s(this,t),this.reviews=[],this.isLoading=!1,this.pagination=null,this.sort="latest"}getUrlParams(){const s=new URLSearchParams(window.location.search);return{sort:s.get("sort")||null,page:Number.parseInt(s.get("page"))||1}}updateUrlParams(s){const t=new URL(window.location.href);for(const[i,e]of Object.entries(s))e?t.searchParams.set(i,e.toString()):t.searchParams.delete(i);window.history.replaceState({},"",t.toString())}fetchReviews(s,t){const i=this.getUrlParams();return salla.api.request("reviews",{params:{type:"products",format:"lite",per_page:8,page:t||i.page||1,sort:s||i.sort||null}})}async initializeMasonry(){const s=this.el.querySelector(".s-reviews-page-grid");if(s)try{new R(s),salla.logger.info("Masonry initialized successfully")}catch(s){salla.logger.error("Masonry initialization failed:",s)}}animateReviewCards(){const s=this.wrapper.querySelectorAll("salla-review-card:not(.animated)");c.animateItems(s)}initiateInfiniteScroll(){this.wrapper?(this.infiniteScroll=salla.infiniteScroll.initiate(this.wrapper,this.wrapper,{path:()=>this.pagination?.links?.next||null,history:!1,scrollThreshold:!1},!0),this.infiniteScroll?.on("request",(()=>{this.isLoading=!0})),this.infiniteScroll?.on("load",(s=>{this.pagination=s.pagination,this.reviews=[...this.reviews,...s.data],this.isLoading=!1,this.updateUrlParams({page:s.pagination.current_page})})),this.infiniteScroll?.on("error",(s=>{salla.logger.error("Error loading more reviews:",s),this.isLoading=!1}))):salla.logger.error("Wrapper is undefined. Cannot initiate infinite scroll.")}componentDidRender(){setTimeout((()=>{requestAnimationFrame(this.animateReviewCards.bind(this))}),176)}async componentWillLoad(){try{await salla.onReady(),this.langTitlesReviews=salla.lang.get("common.titles.reviews"),this.langSorting=salla.lang.get("pages.categories.sorting"),this.placeholderText=salla.lang.choice("pages.rating.reviews",0),this.langLoadMore=salla.lang.get("common.elements.load_more"),this.langSortByTopRating=salla.lang.get("pages.testimonials.sort_by_rating_desc"),this.langSortByMostRecent=salla.lang.get("pages.testimonials.sort_by_date_desc"),this.langSortByLeastRated=salla.lang.get("pages.testimonials.sort_by_rating_asc"),this.langSortByLeastRecent=salla.lang.get("pages.testimonials.sort_by_date_asc");const s=this.getUrlParams(),t=await this.fetchReviews(s.sort);this.sort=s.sort,this.reviews=t.data,this.pagination=t.pagination,this.langRatingReviews=salla.lang.choice("pages.rating.reviews",this.pagination?.total)}catch(s){salla.logger.error("Error loading reviews:",s)}}async handleSorting(s){const t=s.target.value;this.sort=t,this.updateUrlParams({sort:t,page:1});const i=await this.fetchReviews(t,1);this.reviews=i.data,this.pagination=i.pagination}async componentDidLoad(){await this.initializeMasonry(),this.initiateInfiniteScroll(),this.sort=this.getUrlParams().sort||"latest",this.updateUrlParams({sort:this.sort,page:1})}disconnectedCallback(){this.infiniteScroll&&this.infiniteScroll.destroy()}renderSortingOptions(){return[{value:"latest",label:this.langSortByMostRecent},{value:"oldest",label:this.langSortByLeastRecent},{value:"top_rating",label:this.langSortByTopRating},{value:"bottom_rating",label:this.langSortByLeastRated}].map((s=>t("option",{key:s.value,value:s.value,selected:s.value===this.sort},s.label)))}render(){return t("host",{key:"5e3b4042e6412dd2fdef3d776d4204c731df6c80"},t("div",{key:"a9daf869bac109b7c627c9fd8fd7c84cd4dd2965",class:"s-reviews-page-header-wrapper"},t("h2",{key:"01cd6892650d8288003d79b4c12e82c4693e1cb6",class:"s-reviews-page-title"},this.langTitlesReviews,t("span",{key:"935329858a3cc699da6fb6fb8c8515348ded9eb4",class:"s-reviews-page-count"},"(",this.langRatingReviews,")")),t("div",{key:"e74312403c6dc7625c0c2090e6627a8a6b5fca9b",class:"s-reviews-page-filter-wrapper"},t("label",{key:"bf51576936b030ee59836861b03fa3b06471ed1f",class:"s-reviews-page-filter-label",htmlFor:"testimonials-filter"},this.langSorting),t("select",{key:"72f09a679c5f42b08f55b908f67f3d3627b3a50c",onChange:s=>this.handleSorting(s),disabled:!this.reviews.length,class:"s-reviews-page-filter"},this.renderSortingOptions()))),this.reviews.length?t("main",{class:"s-reviews-page-grid",ref:s=>{this.wrapper=s}},this.reviews.map((s=>t("salla-review-card",{key:s.id,review:s})))):t("div",{class:"s-products-list-placeholder"},t("span",{innerHTML:u}),t("p",null,this.placeholderText)),this.pagination?.links?.next&&this.reviews.length?t("div",{class:"s-reviews-page-load-more-container"},t("salla-button",{class:"s-reviews-page-load-more-btn",loading:this.isLoading,onClick:()=>this.infiniteScroll?.loadNextPage(),onKeyUp:()=>this.infiniteScroll?.loadNextPage()},this.langLoadMore)):null)}get el(){return e(this)}};N.style=":host{display:block}";const j=class{constructor(t){s(this,t),this.canRender=!1,this.showRatingSummary=!1,this.recommendationOnly=!1,this.showRecommendation=!1}async componentWillLoad(){try{await salla.onReady(),this.initializeLanguages(),this.loadConfig(),(this.showRatingSummary||this.showRecommendation)&&await this.loadSummary()}catch(s){console.error("Failed to initialize reviews summary component:",s)}}async loadConfig(){this.showRatingSummary=salla.config.get("store.settings.rating.show_rating_summary"),this.showRecommendation=salla.config.get("store.settings.rating.show_recommendation"),this.recommendationOnly=this.showRecommendation&&!this.showRatingSummary}initializeLanguages(){return Salla.lang.onLoaded((()=>{Salla.lang.addBulk({"blocks.comments.based_on":{ar:"بناءً على",en:"Based on"},"blocks.comments.recommended":{ar:"أوصوا بالمنتج",en:"Recommended"}}),this.basedOnLabel=salla.lang.get("blocks.comments.based_on"),this.recommendedLabel=salla.lang.get("blocks.comments.recommended")}))}async loadSummary(){if(!this.itemId)return console.error("Error loading reviews summary: itemId is not defined"),this.canRender=!1;try{const s=await salla.api.request(`rating/summary/${this.itemId}`);if(!s?.data||Array.isArray(s.data.reviews)&&!s.data.reviews.length)return this.canRender=!1,void(this.data=null);this.data=s.data,this.canRender=!0}catch(s){this.canRender=!1,this.data=null,console.error("Error loading reviews summary:",s)}}renderRecommendation(){return this.showRecommendation&&this.data?.recommendation?t("div",{class:("s-reviews-summary-header-section "+(this.recommendationOnly?"s-reviews-summary-recommendation-only":"")).trim()},t("h4",{class:"s-reviews-summary-recommendation-percentage"},"%",this.data?.recommendation),t("p",{class:"s-reviews-summary-count"},this.recommendedLabel)):null}render(){if(!this.canRender)return null;if(this.recommendationOnly)return this.renderRecommendation();const s={1:0,2:0,3:0,4:0,5:0,...this.data.reviews},e=Object.keys(s).reverse().map((i=>{const e=s[i];return t("div",{key:i,class:"s-reviews-summary-row"},t("div",{class:"s-reviews-summary-row-rate"},i," ",t("span",{innerHTML:m})),t("salla-progress-bar",{class:"s-reviews-summary-progress",value:e,target:100,hideUnits:!0,height:"16px"}),t("span",{class:"s-reviews-summary-percentage"},e,"%"))}));return t(i,{class:"s-reviews-summary-wrapper"},t("div",{class:"s-reviews-summary-header"},t("div",{class:"s-reviews-summary-header-section"},t("h3",{class:"s-reviews-summary-average"},this.data.rating),t("div",null,t("salla-rating-stars",{size:"large",value:this.data.rating}),t("p",{class:"s-reviews-summary-count"},this.basedOnLabel," ",salla.helpers.number(salla.lang.choice("pages.rating.reviews",this.data.count))))),this.renderRecommendation()),t("div",{class:"s-reviews-summary-rows"},e))}};j.style=":host{display:block}";export{p as salla_comment_form,g as salla_comment_item,f as salla_comments,w as salla_rating_stars,b as salla_review_card,k as salla_reviews,N as salla_reviews_page,j as salla_reviews_summary}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as s,h as t,H as o}from"./p-
|
|
4
|
+
import{r as s,h as t,H as o}from"./p-PHxPq4LJ.js";const e=class{constructor(t){s(this,t),this.bordered=!0,this.placeholderImage="images/placeholder.png",this.optionsData=[]}componentWillLoad(){this.parseOptionsData()}componentWillUpdate(){this.parseOptionsData()}parseOptionsData(){if(this.options)if("string"==typeof this.options)try{this.optionsData=JSON.parse(this.options)}catch(s){this.optionsData=[]}else this.optionsData=Array.isArray(this.options)?this.options:[];else this.optionsData=[]}renderOptionValue(s){return s.is_image?t("div",{class:"s-order-details-option-image-container"},t("a",{href:s.value,target:"_blank"},t("img",{class:"s-order-details-option-image",src:s.value||this.placeholderImage,alt:s.name}))):s.color?t("span",{title:s.value,class:"s-order-details-option-color-swatch",style:{backgroundColor:s.color}}):s.is_file?t("a",{href:s.value,target:"_blank",class:"s-order-details-option-file-link"},salla.lang.get("common.elements.attachments")):s.is_color_picker?t("div",{class:"s-order-details-option-color-picker"},t("div",{class:"s-order-details-option-color-picker-content"},t("span",{class:"s-order-details-option-color-picker-text"},s.value),t("span",{class:"s-order-details-option-color-picker-swatch",style:{backgroundColor:s.value,width:"1rem"}})),t("salla-button",{onClick:t=>this.copyToClipboard(t,s.value),shape:"link",class:"s-order-details-option-color-picker-button"},t("span",{class:"s-order-details-option-color-copy-icon",innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>swap-fill</title>\n<path d="M28 10.667h-2.667c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333h2.667c0.735 0 1.333 0.597 1.333 1.333v13.333c0 0.736-0.599 1.333-1.333 1.333h-13.333c-0.735 0-1.333-0.597-1.333-1.333v-2.667c0-0.737-0.597-1.333-1.333-1.333s-1.333 0.596-1.333 1.333v2.667c0 2.205 1.795 4 4 4h13.333c2.205 0 4-1.795 4-4v-13.333c0-2.205-1.795-4-4-4zM21.333 17.333v-13.333c0-2.205-1.795-4-4-4h-13.333c-2.205 0-4 1.795-4 4v13.333c0 2.205 1.795 4 4 4h13.333c2.205 0 4-1.795 4-4zM2.667 17.333v-13.333c0-0.736 0.599-1.333 1.333-1.333h13.333c0.735 0 1.333 0.597 1.333 1.333v13.333c0 0.736-0.599 1.333-1.333 1.333h-13.333c-0.735 0-1.333-0.597-1.333-1.333z"></path>\n</svg>\n'}))):s.is_map&&s.latitude&&s.longitude?t("salla-map",{id:`location_map_${s.id}`,class:`map_${s.id}`,zoom:15,readonly:!0,lat:s.latitude,lng:s.longitude},t("div",{slot:"button"},t("button",{type:"button",class:"s-order-details-option-map-button",onClick:()=>this.openMap(s.id)},salla.lang.get("common.elements.show_location")))):t("span",{class:"s-order-details-option-default-text"},s.display_value||s.value)}copyToClipboard(s,t){s.preventDefault(),navigator.clipboard&&navigator.clipboard.writeText(t)}openMap(s){const t=document.querySelector(`salla-map.map_${s}`);t&&t.open&&t.open()}render(){if(!this.optionsData.length)return null;const s=this.bordered?"s-order-details-options-container":"s-order-details-options-container-borderless";return t(o,{class:"s-order-details-options-wrapper"},t("h2",{class:"s-order-details-options-title"},salla.lang.get("pages.cart.item_options")),t("div",{class:s},t("dl",{class:"s-order-details-options-list"},this.optionsData.map((s=>t("div",{key:s.id,class:"s-order-details-options-item"},t("dt",{class:"s-order-details-options-item-name"},s.name,":"),t("dd",{class:s.is_image?"s-order-details-options-item-value-image":"s-order-details-options-item-value-text"},this.renderOptionValue(s))))))))}};e.style="";export{e as salla_order_details_options}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as s,c as t,h as i,H as e,a as h}from"./p-
|
|
4
|
+
import{r as s,c as t,h as i,H as e,a as h}from"./p-PHxPq4LJ.js";import{H as a}from"./p-DgNC8L6e.js";import{F as l}from"./p-DL4h2bc3.js";import"./p-CgtvEd63.js";const r=class{constructor(i){s(this,i),this.changed=t(this,"changed"),this.initialItemCount=10,this.expandedItemCount=15,this.calculatedInitialHeight=0,this.calculatedExpandedHeight=0,this.isOpen=!0,this.isShowMore=!1,this.showMoreLabel="عرض المزيد",this.showLessLabel="عرض أقل",this.page=salla.config.get("page"),this.searchQuery="",this.filteredCount=0}connectedCallback(){this.withLoadMore="price"!=this.option.key&&Array.isArray(this.option.values)&&this.option.values.length>this.initialItemCount,salla.onReady((()=>{this.page=salla.config.get("page")})),salla.lang.onLoaded((()=>{this.showMoreLabel=salla.lang.getWithDefault("common.titles.more",this.showMoreLabel),this.showLessLabel=salla.lang.getWithDefault("common.elements.show_less",this.showLessLabel)}))}componentDidLoad(){const s=this.widgetValues.querySelectorAll(".s-filters-label");if(s.length>0){const t=Math.min(this.initialItemCount,s.length);this.calculatedInitialHeight=35*this.initialItemCount,this.calculatedExpandedHeight=s.length>this.initialItemCount?35*this.expandedItemCount:35*t}this.widgetValues.scrollHeight<this.calculatedInitialHeight&&(this.withLoadMore=!1),this.withLoadMore&&this.widgetValues&&(this.widgetValues.style.maxHeight=`${this.calculatedInitialHeight}px`),this.widgetContent.style.height=`${this.widgetContent.scrollHeight}px`}async setWidgetHeight(s=250){this.widgetContent.removeAttribute("style"),setTimeout((()=>{this.widgetContent.style.height=this.widgetContent.scrollHeight+"px"}),s)}async reset(){this.option.type===l.RANGE&&this.priceRange.reset(),Array.from(this.host.querySelectorAll("input")).forEach((s=>s.checked=!1))}async showMore(){this.isShowMore=!this.isShowMore,this.widgetContent.style.height="auto",this.isShowMore||(this.widgetValues.scrollTop=0);const s=this.isShowMore?this.calculatedExpandedHeight:this.calculatedInitialHeight,t=this.searchQuery?this.filteredCount:Array.isArray(this.option.values)?this.option.values.length:0;this.widgetValues.style.maxHeight=`${s}px`,this.widgetValues.style.overflowY=this.isShowMore&&t>this.expandedItemCount?"auto":"hidden",setTimeout((()=>{this.widgetContent.style.height=`${this.widgetContent.scrollHeight}px`}),400)}async toggleWidget(){this.isOpen=!this.isOpen,a.toggleElementClassIf(this.widgetContent,"s-filters-widget-opened","s-filters-widget-closed",(()=>this.isOpen))}renderFilterOption(s){if(![l.VALUES,l.MINIMUM,l.VARIANTS].includes(s.type))return"";const t=s.values.filter((s=>{if(!this.searchQuery)return!0;const t="number"==typeof s?String(s):s?.value||s?.key||"";return String(t).toLowerCase().includes(this.searchQuery.toLowerCase())}));return this.filteredCount=t.length,0===t.length?i("div",{class:"s-filters-widget-empty-state"},salla.lang.get("common.elements.no_options")||"لا توجد نتائج"):t.map((t=>{let e="number"==typeof t?t:t.key||t.value;return i("label",{class:"s-filters-label",htmlFor:`${s.key}-option-${e}`,key:`${s.key}-option-${e}`},i("input",{id:`${s.key}-option-${e}`,name:s.key,type:"radio",checked:this.isSelectedOption(s,e),class:"s-filters-radio",onChange:t=>this.changed.emit({event:t,option:s,value:e})}),this.getOptionLabel(s,t))}))}isSelectedOption(s,t){return s.type===l.MINIMUM?this.filtersData[s.key]==t:s.type===l.VARIANTS?this.filtersData[s.type]&&this.filtersData[s.type][Object.keys(this.filtersData[s.type])[0]]==t:s.type===l.RANGE?this.filtersData[s.key]&&this.filtersData[s.key].min==t.min&&this.filtersData[s.key].max==t.max:s.type===l.VALUES&&this.filtersData[s.key]&&Number(this.filtersData[s.key])==Number(t)}getOptionLabel(s,t){return"rating"==s.key?i("salla-rating-stars",{size:"small",value:t}):i("span",{class:"s-filters-option-name"},t.value||"null")}render(){return i(e,{key:"077daba99bcd27c940a4e4efaf1bfee325952b9f",class:"s-filters-widget-container"},i("h3",{key:"2ad33389bea9078357d8feabda3d1d813cc57887",class:"s-filters-widget-title",onClick:()=>this.toggleWidget()},i("span",{key:"8084e6e7032fde8a71c962db8025a17e22a0e017"},this.option.label),i("span",{key:"56fa918f5391b3cfe6e58ffff2a5178515c49679",class:"s-filters-widget-plusminus "+(this.isOpen?"s-filters-widget-plusminus-active":"")})),i("div",{key:"6935232082047b6147f24c332d48f0b8e6b028ba",class:"s-filters-widget-content",ref:s=>this.widgetContent=s},Array.isArray(this.option.values)&&this.option.values.length>5&&i("div",{key:"1dc3c9aa881bcc2998d6460b296e92fb9dbeccc9",class:"s-filters-widget-search-wrapper",style:{padding:"8px 0",marginBottom:"8px"}},i("input",{key:"296e9b6356ec5f646ecb7e255e79f9302b73b94a",type:"text",class:"s-filters-widget-search-input",placeholder:salla.lang.get("blocks.header.search_placeholder")||"بحث...",value:this.searchQuery,onInput:s=>this.searchQuery=s.target.value})),i("div",{key:"de9f573e83242f244a0f700e95913ce5701aba6c",class:"s-filters-widget-values",ref:s=>this.widgetValues=s},i("slot",{key:"af9a5e720b01c69a5da1f9fa0c5e24fd811f7606"}),this.option.type!==l.RANGE?this.renderFilterOption(this.option):i("salla-price-range",{onChanged:s=>{this.changed.emit(s.detail)},ref:s=>this.priceRange=s,filtersData:this.filtersData,option:this.option})),this.withLoadMore&&(!this.searchQuery||this.filteredCount>this.initialItemCount)&&i("a",{key:"0d849529f9fe7d9543f63cc3a035850ec5578b2c",class:"s-filters-widget-more",onClick:()=>this.showMore()},this.isShowMore?this.showLessLabel:this.showMoreLabel)))}get host(){return h(this)}};r.style=":host{display:block}";export{r as salla_filters_widget}
|