@salla.sa/twilight-components 2.14.414 → 2.14.415
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/{filepond-Dp_H5r_e.js → filepond-BSgA0m51.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-BhLJq633.js → filepond-plugin-file-poster-B_U56Mab.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-Bzp5Z1pf.js → filepond-plugin-file-validate-size-CMrqQo_q.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-ClWX5bbr.js → filepond-plugin-file-validate-type-DVXx7vBT.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-CQZ3PQWR.js → filepond-plugin-image-edit-DGNKXZ2S.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-NA--NS7o.js → filepond-plugin-image-exif-orientation-CDzotJbv.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-C9HHOV4A.js → filepond-plugin-image-preview-BpPTY8Td.js} +1 -1
- package/dist/cjs/{functions-PtQY5Mwc.js → functions-Dn6MANYA.js} +1 -1
- package/dist/cjs/{index-B-m5HL7n.js → index-B5bZG9f4.js} +1 -1
- package/dist/cjs/{index-BV8LF8_q.js → index-DKILCfeB.js} +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-accordion_6.cjs.entry.js +1 -1
- package/dist/cjs/salla-add-product-button_5.cjs.entry.js +1 -1
- package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
- package/dist/cjs/salla-alert_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
- package/dist/cjs/salla-badge.cjs.entry.js +1 -1
- package/dist/cjs/salla-booking-field_7.cjs.entry.js +10 -10
- package/dist/cjs/salla-bullet-delivery.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-coupons.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-comment-form_8.cjs.entry.js +1 -1
- package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
- package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
- package/dist/cjs/salla-count-down.cjs.entry.js +1 -1
- package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
- package/dist/cjs/salla-delivery-promise.cjs.entry.js +1 -1
- package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters.cjs.entry.js +1 -1
- package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
- package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
- package/dist/cjs/salla-hook.cjs.entry.js +1 -1
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
- package/dist/cjs/salla-installment.cjs.entry.js +1 -1
- package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
- package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-banner.cjs.entry.js +2 -2
- package/dist/cjs/salla-loyalty-hero_2.cjs.entry.js +2 -2
- package/dist/cjs/salla-loyalty-panel.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-program.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty-reward.cjs.entry.js +2 -2
- package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
- package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-map.cjs.entry.js +1 -1
- package/dist/cjs/salla-menu.cjs.entry.js +1 -1
- package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-orders.cjs.entry.js +1 -1
- package/dist/cjs/salla-payments.cjs.entry.js +1 -1
- package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
- package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
- package/dist/cjs/salla-product-card_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
- package/dist/cjs/salla-products-list.cjs.entry.js +1 -1
- package/dist/cjs/salla-progress-bar.cjs.entry.js +1 -1
- package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
- package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-reward-action_4.cjs.entry.js +3 -3
- package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
- package/dist/cjs/salla-search.cjs.entry.js +1 -1
- package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
- package/dist/cjs/salla-slider.cjs.entry.js +1 -1
- package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
- package/dist/cjs/salla-social.cjs.entry.js +1 -1
- package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
- package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
- package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-settings.cjs.entry.js +1 -1
- package/dist/cjs/salla-verify.cjs.entry.js +1 -1
- package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
- package/dist/cjs/{tracked-promise-D3TH8tBr.js → tracked-promise-CYjUhHsR.js} +1 -1
- package/dist/cjs/twilight.cjs.js +1 -1
- package/dist/cjs/{vanilla-picker-BzsL3dA6.js → vanilla-picker-Cu_O9pv0.js} +1 -1
- package/dist/components/index.js +2 -2
- package/dist/esm/{filepond-DePctYW6.js → filepond-B3rUfZ_Q.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-BLTrMyXv.js → filepond-plugin-file-poster-DEDQEC6r.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-DS-qwPwO.js → filepond-plugin-file-validate-size--a2eBQUT.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-C5a7dkS0.js → filepond-plugin-file-validate-type-DxbdaAsO.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-Bn3oms-h.js → filepond-plugin-image-edit-DyPAs_ZT.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-C5xozSoC.js → filepond-plugin-image-exif-orientation-CECU3kdx.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-e9o-BI5K.js → filepond-plugin-image-preview-BvMmLc3M.js} +1 -1
- package/dist/esm/{functions-avO3JHt1.js → functions-DlXFEByO.js} +1 -1
- package/dist/esm/{index-6ZT_-rrT.js → index-BJrHu3Q4.js} +2 -2
- package/dist/esm/{index-DLd2oDnH.js → index-s83vHKfp.js} +1 -1
- package/dist/esm/loader.js +2 -2
- package/dist/esm/salla-accordion-body_2.entry.js +1 -1
- package/dist/esm/salla-accordion_6.entry.js +1 -1
- package/dist/esm/salla-add-product-button_5.entry.js +1 -1
- package/dist/esm/salla-advertisement.entry.js +1 -1
- package/dist/esm/salla-alert_2.entry.js +1 -1
- package/dist/esm/salla-app-install-alert.entry.js +1 -1
- package/dist/esm/salla-apps-icons.entry.js +1 -1
- package/dist/esm/salla-badge.entry.js +1 -1
- package/dist/esm/salla-booking-field_7.entry.js +10 -10
- package/dist/esm/salla-bullet-delivery.entry.js +1 -1
- package/dist/esm/salla-cart-coupons.entry.js +1 -1
- package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
- package/dist/esm/salla-comment-form_8.entry.js +1 -1
- package/dist/esm/salla-conditional-offer.entry.js +1 -1
- package/dist/esm/salla-contacts.entry.js +1 -1
- package/dist/esm/salla-cookies-bar.entry.js +1 -1
- package/dist/esm/salla-count-down.entry.js +1 -1
- package/dist/esm/salla-custom-fields.entry.js +1 -1
- package/dist/esm/salla-delivery-promise.entry.js +1 -1
- package/dist/esm/salla-edit-order-button.entry.js +1 -1
- package/dist/esm/salla-filters-widget.entry.js +1 -1
- package/dist/esm/salla-filters.entry.js +1 -1
- package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
- package/dist/esm/salla-gifting.entry.js +1 -1
- package/dist/esm/salla-hook.entry.js +1 -1
- package/dist/esm/salla-infinite-scroll.entry.js +1 -1
- package/dist/esm/salla-installment.entry.js +1 -1
- package/dist/esm/salla-list-tile.entry.js +1 -1
- package/dist/esm/salla-localization-modal.entry.js +1 -1
- package/dist/esm/salla-login-modal.entry.js +1 -1
- package/dist/esm/salla-loyalty-banner.entry.js +2 -2
- package/dist/esm/salla-loyalty-hero_2.entry.js +2 -2
- package/dist/esm/salla-loyalty-panel.entry.js +3 -3
- package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
- package/dist/esm/salla-loyalty-program.entry.js +3 -3
- package/dist/esm/salla-loyalty-reward.entry.js +2 -2
- package/dist/esm/salla-loyalty.entry.js +1 -1
- package/dist/esm/salla-maintenance-alert.entry.js +1 -1
- package/dist/esm/salla-map.entry.js +1 -1
- package/dist/esm/salla-menu.entry.js +1 -1
- package/dist/esm/salla-metadata.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-notification-item.entry.js +1 -1
- package/dist/esm/salla-notifications.entry.js +1 -1
- package/dist/esm/salla-offer-modal.entry.js +1 -1
- package/dist/esm/salla-offer.entry.js +1 -1
- package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-order-details-options.entry.js +1 -1
- package/dist/esm/salla-order-details.entry.js +1 -1
- package/dist/esm/salla-order-edit-item.entry.js +1 -1
- package/dist/esm/salla-order-edit.entry.js +1 -1
- package/dist/esm/salla-order-summary.entry.js +1 -1
- package/dist/esm/salla-order-totals-card.entry.js +1 -1
- package/dist/esm/salla-orders.entry.js +1 -1
- package/dist/esm/salla-payments.entry.js +1 -1
- package/dist/esm/salla-placeholder.entry.js +1 -1
- package/dist/esm/salla-price-range.entry.js +1 -1
- package/dist/esm/salla-product-card_2.entry.js +1 -1
- package/dist/esm/salla-product-size-guide.entry.js +1 -1
- package/dist/esm/salla-products-list.entry.js +1 -1
- package/dist/esm/salla-progress-bar.entry.js +1 -1
- package/dist/esm/salla-quick-order.entry.js +1 -1
- package/dist/esm/salla-rating-modal.entry.js +1 -1
- package/dist/esm/salla-reward-action_4.entry.js +3 -3
- package/dist/esm/salla-scopes.entry.js +1 -1
- package/dist/esm/salla-search.entry.js +1 -1
- package/dist/esm/salla-skeleton.entry.js +1 -1
- package/dist/esm/salla-slider.entry.js +1 -1
- package/dist/esm/salla-social-share.entry.js +1 -1
- package/dist/esm/salla-social.entry.js +1 -1
- package/dist/esm/salla-tab-content_3.entry.js +1 -1
- package/dist/esm/salla-tiered-offer.entry.js +1 -1
- package/dist/esm/salla-tooltip.entry.js +1 -1
- package/dist/esm/salla-trust-badges.entry.js +1 -1
- package/dist/esm/salla-user-menu.entry.js +1 -1
- package/dist/esm/salla-user-profile.entry.js +1 -1
- package/dist/esm/salla-user-settings.entry.js +1 -1
- package/dist/esm/salla-verify.entry.js +1 -1
- package/dist/esm/salla-wallet.entry.js +1 -1
- package/dist/esm/{tracked-promise-BCWK9qFO.js → tracked-promise-BpC4uz19.js} +1 -1
- package/dist/esm/twilight.js +2 -2
- package/dist/esm/{vanilla-picker-DWxX7cio.js → vanilla-picker-EWATXRmN.js} +1 -1
- package/dist/twilight/{p-09f2c951.entry.js → p-00ddd52f.entry.js} +1 -1
- package/dist/twilight/{p-881a00c8.entry.js → p-038c5d40.entry.js} +1 -1
- package/dist/twilight/{p-20764356.entry.js → p-0a768074.entry.js} +1 -1
- package/dist/twilight/{p-e054c3b2.entry.js → p-0eb6ff2f.entry.js} +1 -1
- package/dist/twilight/{p-29ff944d.entry.js → p-0f3c0d0b.entry.js} +1 -1
- package/dist/twilight/{p-15e2e287.entry.js → p-1340cc10.entry.js} +1 -1
- package/dist/twilight/{p-603b88a8.entry.js → p-14483d4f.entry.js} +1 -1
- package/dist/twilight/{p-6d3fdd76.entry.js → p-1a5ec95f.entry.js} +1 -1
- package/dist/twilight/{p-59e89ee3.entry.js → p-1bc51071.entry.js} +1 -1
- package/dist/twilight/{p-af7a4f68.entry.js → p-1bcf0168.entry.js} +1 -1
- package/dist/twilight/{p-eb073d38.entry.js → p-1cfc81cb.entry.js} +1 -1
- package/dist/twilight/{p-d02e8b25.entry.js → p-1dabd43d.entry.js} +1 -1
- package/dist/twilight/{p-861203e4.entry.js → p-1e542b72.entry.js} +1 -1
- package/dist/twilight/{p-80f95744.entry.js → p-1efb7a3d.entry.js} +1 -1
- package/dist/twilight/{p-1affa2bf.entry.js → p-1f421639.entry.js} +1 -1
- package/dist/twilight/{p-29463486.entry.js → p-20a86446.entry.js} +1 -1
- package/dist/twilight/{p-352a6706.entry.js → p-23a530eb.entry.js} +1 -1
- package/dist/twilight/{p-4ad1939b.entry.js → p-26b97651.entry.js} +1 -1
- package/dist/twilight/{p-48f1953b.entry.js → p-291693b7.entry.js} +1 -1
- package/dist/twilight/p-293a2370.entry.js +4 -0
- package/dist/twilight/{p-af2fb7b2.entry.js → p-2b6e8d69.entry.js} +1 -1
- package/dist/twilight/{p-6673ee84.entry.js → p-2c99cc69.entry.js} +1 -1
- package/dist/twilight/{p-87ba43f4.entry.js → p-31c8711f.entry.js} +1 -1
- package/dist/twilight/{p-b1137d6a.entry.js → p-3201fa7d.entry.js} +1 -1
- package/dist/twilight/{p-4c9e53ef.entry.js → p-32644ff6.entry.js} +1 -1
- package/dist/twilight/{p-0d2707d1.entry.js → p-34900416.entry.js} +1 -1
- package/dist/twilight/{p-b30e4954.entry.js → p-3f02973f.entry.js} +1 -1
- package/dist/twilight/{p-19615f59.entry.js → p-404c2e14.entry.js} +1 -1
- package/dist/twilight/{p-d75c4d8f.entry.js → p-4370441c.entry.js} +1 -1
- package/dist/twilight/{p-19af24cd.entry.js → p-479420b3.entry.js} +1 -1
- package/dist/twilight/{p-a326832f.entry.js → p-4aa90fca.entry.js} +1 -1
- package/dist/twilight/{p-89409e62.entry.js → p-4b7be330.entry.js} +1 -1
- package/dist/twilight/{p-083e1a33.entry.js → p-4bef45b0.entry.js} +1 -1
- package/dist/twilight/{p-7060d38e.entry.js → p-4cf8947e.entry.js} +1 -1
- package/dist/twilight/{p-de2d21e1.entry.js → p-4fb84597.entry.js} +1 -1
- package/dist/twilight/{p-611b6487.entry.js → p-555eb535.entry.js} +1 -1
- package/dist/twilight/{p-78e1c27b.entry.js → p-5b78a478.entry.js} +1 -1
- package/dist/twilight/{p-3e5e5939.entry.js → p-5c4dcfbf.entry.js} +1 -1
- package/dist/twilight/{p-2caf7100.entry.js → p-5c710f88.entry.js} +1 -1
- package/dist/twilight/{p-4f4a9efe.entry.js → p-5de3e90f.entry.js} +1 -1
- package/dist/twilight/{p-e4ee1bb9.entry.js → p-62bc6e04.entry.js} +1 -1
- package/dist/twilight/{p-ed39ea6e.entry.js → p-65cece5f.entry.js} +1 -1
- package/dist/twilight/{p-8ae540e2.entry.js → p-66b013a9.entry.js} +1 -1
- package/dist/twilight/{p-b6ee8954.entry.js → p-67617d49.entry.js} +1 -1
- package/dist/twilight/{p-3763e5ac.entry.js → p-6c5450b6.entry.js} +1 -1
- package/dist/twilight/{p-95ff5c23.entry.js → p-7810ffdb.entry.js} +1 -1
- package/dist/twilight/{p-4b3cd6e7.entry.js → p-78fa7baa.entry.js} +1 -1
- package/dist/twilight/{p-33498ca4.entry.js → p-7bae206a.entry.js} +1 -1
- package/dist/twilight/{p-c98464bd.entry.js → p-7f41d7a1.entry.js} +1 -1
- package/dist/twilight/{p-20cfe41f.entry.js → p-8246a2a1.entry.js} +1 -1
- package/dist/twilight/{p-ffb2c726.entry.js → p-8a8952c9.entry.js} +1 -1
- package/dist/twilight/{p-e513efab.entry.js → p-8dfd35fd.entry.js} +1 -1
- package/dist/twilight/{p-0ee39d71.entry.js → p-8e37135a.entry.js} +1 -1
- package/dist/twilight/{p-b05422f7.entry.js → p-8eaf0791.entry.js} +1 -1
- package/dist/twilight/{p-4fccc704.entry.js → p-909a325c.entry.js} +1 -1
- package/dist/twilight/{p-ccbc611f.entry.js → p-90c2bb26.entry.js} +1 -1
- package/dist/twilight/{p-4cc69951.entry.js → p-96dfe5f7.entry.js} +1 -1
- package/dist/twilight/{p-4b55f671.entry.js → p-995be2a3.entry.js} +1 -1
- package/dist/twilight/{p-CaURqicX.js → p-B--H81EX.js} +1 -1
- package/dist/twilight/{p-6ZT_-rrT.js → p-BJrHu3Q4.js} +2 -2
- package/dist/twilight/{p-C4Sm8mDk.js → p-BhL20bfQ.js} +1 -1
- package/dist/twilight/{p-RUoY6zEi.js → p-BokHJNvn.js} +1 -1
- package/dist/twilight/{p-DZCJAoVw.js → p-C50OVcDe.js} +2 -2
- package/dist/twilight/{p-BbupQHPq.js → p-CbR-jw9t.js} +1 -1
- package/dist/twilight/{p-CZCe7gL1.js → p-Cn23iQH-.js} +1 -1
- package/dist/twilight/{p-BwkVGCUs.js → p-CraZjTa1.js} +1 -1
- package/dist/twilight/{p-C5kLhs7f.js → p-CyRmFTSk.js} +1 -1
- package/dist/twilight/{p-Ce_mZAOv.js → p-DDjn6-rT.js} +1 -1
- package/dist/twilight/{p-C3wnAzO7.js → p-DJMIuJ3l.js} +1 -1
- package/dist/twilight/{p-9436c499.entry.js → p-a1be369b.entry.js} +1 -1
- package/dist/twilight/{p-0efac7e2.entry.js → p-b3338aba.entry.js} +1 -1
- package/dist/twilight/{p-16c2826c.entry.js → p-b4560bcf.entry.js} +1 -1
- package/dist/twilight/{p-a5c01307.entry.js → p-b45e0eb4.entry.js} +1 -1
- package/dist/twilight/{p-a0db4ef2.entry.js → p-b866c259.entry.js} +1 -1
- package/dist/twilight/{p-356df60b.entry.js → p-c84ac61b.entry.js} +1 -1
- package/dist/twilight/{p-297cd58e.entry.js → p-caa664d2.entry.js} +1 -1
- package/dist/twilight/{p-15f6bb69.entry.js → p-cad60fb9.entry.js} +1 -1
- package/dist/twilight/{p-4a654724.entry.js → p-ccf80fc5.entry.js} +1 -1
- package/dist/twilight/{p-35449c67.entry.js → p-ce6c21be.entry.js} +1 -1
- package/dist/twilight/{p-515958ec.entry.js → p-d0f37850.entry.js} +1 -1
- package/dist/twilight/{p-11c9a417.entry.js → p-d2cee8e2.entry.js} +1 -1
- package/dist/twilight/{p-afdccf8a.entry.js → p-d32a5200.entry.js} +1 -1
- package/dist/twilight/{p-edba3e00.entry.js → p-db66c636.entry.js} +1 -1
- package/dist/twilight/{p-c2eaa583.entry.js → p-df385d43.entry.js} +1 -1
- package/dist/twilight/{p-7f9cf58a.entry.js → p-e2dddc75.entry.js} +1 -1
- package/dist/twilight/{p-b5cada55.entry.js → p-e2facd9b.entry.js} +1 -1
- package/dist/twilight/{p-969c474d.entry.js → p-e715cf82.entry.js} +1 -1
- package/dist/twilight/{p-97277641.entry.js → p-e9e0b4b0.entry.js} +1 -1
- package/dist/twilight/{p-5333d535.entry.js → p-f0fed4a2.entry.js} +1 -1
- package/dist/twilight/{p-8f8045fa.entry.js → p-f2ee2742.entry.js} +1 -1
- package/dist/twilight/{p-f72f19b4.entry.js → p-f2f94c2a.entry.js} +1 -1
- package/dist/twilight/{p-2f1157d9.entry.js → p-f9ec3859.entry.js} +1 -1
- package/dist/twilight/{p-DU8NQm6S.js → p-sXTTBYrW.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/package.json +5 -5
- package/dist/twilight/p-03ec20de.entry.js +0 -4
|
@@ -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,i as n,j as r,k as l,d as o}from"./p-6ZT_-rrT.js";import{S as h}from"./p-BZp0rKEO.js";import{a as c}from"./p-CgtvEd63.js";import{H as m}from"./p-CHf8XdiS.js";import{S as d}from"./p-D4oPi1Ov.js";import{a as u}from"./p-BedNk7k1.js";import{S as p}from"./p-DiKTtDW5.js";const g=class{constructor(i){s(this,i),this.commentAdded=t(this,"commentAdded"),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(){if(!this.commentForm.reportValidity())return void salla.log("CommentForm:: validation error!");const s=this.commentField.value;this.submitBtn.load().then((()=>salla.comment.add({id:this.itemId,comment:s,type:this.type}))).then((()=>{this.commentAdded.emit({name:salla.config.get("user.name"),avatar:salla.config.get("user.avatar"),content:s,is_pending:!0,created_at:{date:(new Date).toISOString().replace("T"," ").substring(0,19)},images:[]}),this.commentField.value=""})).finally((()=>this.submitBtn.stop()))}render(){return i(e,{key:"2203b9f365e0658a3bc40fb0274ba9ddc0d1e040"},this.canComment?i("form",{ref:s=>this.commentForm=s},i("div",{class:"s-comment-form-wrapper"},this.showAvatar?i("img",{class:"s-comment-form-avatar",src:salla.config.get("user.avatar"),alt:"user avatar"}):"",i("div",{class:"s-comment-form-content"},i("textarea",{cols:30,rows:5,minlength:"4",maxlength:"500",ref:s=>this.commentField=s,placeholder:this.placeholder,class:"s-comment-form-input",required:!0}),i("br",null),i("div",{class:"s-comment-form-action"},i("salla-button",{ref:s=>this.submitBtn=s,"loader-position":"center",onClick:()=>this.submit()},this.submitText))))):"")}};g.style=":host{display:block}";const v=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 i("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"},i("path",{d:"M12 16V21"}),i("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 i(e,{key:"05b9da17f0e07e1115c87c671998e8123b8b0bb4",class:s?"s-comments-item-admin":"s-comments-item"},i("div",{key:"49552e9efab0aa751db6d7051318f626f9124e5a",class:{"s-comments-item-wrapper":!s,"s-comments-item-admin-wrapper":s},id:`s-comments-item-${this.comment.id}`},i("div",{key:"e795f238ee0a562675843e6da0f495512abf550c",class:"s-comments-item-inner s-comments-flex-1"},s&&i("span",{key:"05270553da039c8cdf611d7a1a0ac1ff9d5d88f2",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'}),i("div",{key:"be2ca109e89c83691d3a0a7a9e03f6e1b94fb09e",class:"s-comments-item-avatar"},i("img",{key:"402cff5a2003bf385ae8f9f7890555ef2886de87","data-src":this.comment?.avatar,alt:this.comment?.name,src:this.comment?.avatar,class:"s-comments-item-avatar-img lazy"})),i("div",{key:"af7992ad18ed3d756594cf678d01c1fdd2af6cca",class:"s-comments-flex-1"},i("div",{key:"b11dc77d96bf83c0dddd1edaa5fb57286b5b6f55",class:"s-comments-item-user-wrapper"},i("div",{key:"f899a929d3e67c7898d22cf7abc56891cdf0fa7c",class:"s-comments-item-user-info"},i("h3",{key:"9968169cbd69eb6d1d7e0b0498db03a0431d2a16",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?i("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:i("div",{class:"s-comments-flex"},this.comment.has_order?[i("span",{class:"s-comments-item-has-order-check-icon",innerHTML:h}),i("span",{class:"s-comments-item-has-order-check-text"},this.has_bought_trans," ",this.comment.rating?", ":"")]:null,this.comment.rating?i("span",{class:"s-comments-item-rated-widget"},this.rated_trans):null)),i("p",{key:"cafa0be66307c6b377f90033745b939da66344c8",class:"s-comments-item-timestamp s-ltr"},this.getDate(this.comment.created_at?.date),i("span",{key:"608db7108242f10e4d649bb23d1382f49227aeb8",class:"s-comments-item-time"}," - ",this.getTime(this.comment.created_at?.date))),this.comment.rating||this.comment.stars?i("salla-rating-stars",{size:"mini",class:"s-comments-item-stars",value:this.comment.rating||this.comment.stars}):null),i("div",{key:"9b86497c3791f7e890b560207068de4ca38d6e60",class:"s-comments-item-content"},i("p",{key:"82433f42c6b0ee29cdd42725ce1aba4dd62e67d8",innerHTML:this.comment.content}),this.allowAttachImages&&i("div",{key:"9a1bd14eb18f637588f152b8842d4637b9a6e7c1",class:"s-comments-item-images"},this.comment.images.map(((s,t)=>i("img",{key:t,src:s,alt:"",onClick:()=>this.modal.open()}))),i("salla-modal",{key:"be260096b68a1a58889bed09c68b3a2c75adefa6",ref:s=>this.modal=s,width:"sm"},i("salla-slider",{key:"8f78ee0ab370e4f99eb68fe1afa4491c4a6a0b80",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"},i("div",{key:"eea6149852a409f2e25b8f9ec4375087e1c9beb8",slot:"items"},this.comment.images.map(((s,t)=>i("img",{key:t,src:s,alt:""})))),i("div",{key:"9f693fcd5afc5e443e0ff590d6e7e386746e2a98",slot:"thumbs"},this.comment.images.map(((s,t)=>i("div",{class:"s-comments-item-images-slider-thumb"},i("img",{key:t,src:s,alt:""})))))))),this.allowLikes&&!s&&this.comment.id&&salla.url.is_page("product.single")?i("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()},i("span",null,this.helpfulLabel," ",this.likesCount>0?`(${this.likesCount})`:""),i("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>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?i("span",{class:"s-comments-item-pending-text"},this.waiting_approval_trans):null))),this.getReplies().length&&!s?this.getReplies().map((s=>i("div",null,i("salla-comment-item",{comment:s})))):null))}get host(){return a(this)}};var f;v.style=":host{display:block}",function(s){s.PAGE="page",s.PRODUCT="product",s.BLOG="blog"}(f||(f={}));const w=class{constructor(t){s(this,t),this.type=f.PAGE,this.showFormAvatar=!1,this.hideBought=!1,this.testimonials=!1,this.customerId=null,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)}patchNextPageUrl(){if(this.nextPage)try{const s=new URL(this.nextPage,window.location.origin);this.sort&&!s.searchParams.get("sort")&&s.searchParams.set("sort",this.sort),this.customerId&&!s.searchParams.get("private_comments")&&s.searchParams.set("private_comments",this.customerId),this.nextPage=s.toString()}catch(s){const t=this.nextPage.includes("?");if(this.sort&&!/[?&]sort=/.test(this.nextPage)&&(this.nextPage=this.nextPage+(t?"&":"?")+`sort=${this.sort}`),this.customerId&&!/[?&]private_comments=/.test(this.nextPage)){const s=this.nextPage.includes("?")?"&":"?";this.nextPage=this.nextPage+s+`private_comments=${this.customerId}`}}}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,this.patchNextPageUrl();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&&(m.toggleElementClassIf(t,"s-button-hide","s-button-show",(()=>s)),this.btnLoader.style.display=s?"inherit":"none")}animateItems(s){c({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())))}onCommentAdded(s){const t=s.detail;t&&(this.showPlaceholder||!this.total?(this.showPlaceholder=!1,this.total=(this.total||0)+1,this.comments=this.comments||[]):this.total=(this.total||0)+1,setTimeout((()=>{if(!this.wrapper)return;const s=this.getCommentHTML(t);this.wrapper.prepend(s),this.animateItems([s])}),0))}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{const i=t.get("private_comments");this.customerId=i&&"user"===Salla.config.get("user.type")&&Salla.config.get("user.id")?Salla.config.get("user.id"):null,s=await salla.api.comment.getComments(this.type,this.itemId,1,5,this.sort,this.customerId)}if(!s.data||!s.data.length)return this.showPlaceholder=!1,void this.loading(!1);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.patchNextPageUrl(),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?i("div",null,this.total&&!this.hideTitle?i("h2",{class:"s-comments-title"},this.blockTitle?this.blockTitle:this.comment_title):"",this.hideForm||this.testimonials?"":i("salla-comment-form",{showAvatar:this.showFormAvatar,type:this.type,"item-id":this.itemId}),i("div",{class:"s-comments-placeholder"},i("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>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'}),i("p",null,this.noComments))):i("div",{class:`s-comments s-comments-${this.testimonials?"testimonials":this.type}`},i("div",{class:this.type===f.PAGE?"s-comments-page-container":"s-comments-container"},this.total&&!this.hideTitle?i("h2",{class:"s-comments-title"},this.blockTitle?this.blockTitle:this.comment_title):"",!this.hideForm&&i("salla-comment-form",{showAvatar:this.showFormAvatar,type:this.type,"item-id":this.itemId}),salla.url.is_page("product.single")?i("salla-reviews-summary",{itemId:this.itemId}):"",i("div",{class:"s-comments-header "+(this.total?"has-total":"")},!!this.total&&i("span",{class:"s-comments-count-label",innerHTML:this.pluralize(this.comment_name,this.total)}),this.total&&!this.testimonials&&this.type!==f.BLOG?i("div",{class:"s-comments-filter-wrapper"},i("label",{class:"s-comments-filter-label",htmlFor:"comments-filter"},salla.lang.get("pages.categories.sorting")),i("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()}},i("option",{value:"latest",selected:!0},salla.lang.get("pages.testimonials.sort_by_date_desc")),i("option",{value:"oldest"},salla.lang.get("pages.testimonials.sort_by_date_asc")),this.allowLikes&&i("option",{value:"most_helpful"},this.mostHelpfulLabel))):""),i("div",{ref:s=>{this.wrapper=s}}),this.nextPage&&i("div",{class:"s-infinite-scroll-wrapper",ref:s=>{this.status=s}},i("button",{onClick:()=>this.loadMore(),class:"s-infinite-scroll-btn s-button-btn s-button-primary",type:"button"},i("span",{class:"s-button-text s-infinite-scroll-btn-text"},this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more")),i("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 a(this)}};w.style=":host{display:block}";const b=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)=>m.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 t=[];for(let e=0;e<5;e++)t.push(i("span",{class:{"s-rating-stars-btn-star":!0,["s-rating-stars-"+this.size]:!0,"s-rating-stars-selected":e<s},innerHTML:d}));return this.reviews>0&&t.push(i("span",{class:"s-rating-stars-reviews",ref:s=>this.reviewsElement=s},"(",salla.helpers.number(salla.lang.choice("pages.rating.reviews",this.reviews)),")")),t}render(){return this.translationsLoaded?this.host.closest(".swiper-slide")?.classList.contains("swiper-slide-duplicate")?"":i(e,null,i("div",{class:"s-rating-stars-wrapper"},!this.value&&0!=this.value||this.editable?i("div",{class:"s-rating-stars-element",ref:s=>this.starsElem=s},i("input",{type:"hidden",class:"rating_hidden_input",name:this.name,value:""}),[1,2,3,4,5].map((s=>i("button",{class:"s-rating-stars-btn-star s-rating-stars-"+this.size,"data-star":s},i("span",{innerHTML:d}))))):this.createStars(this.value),this.withLabel&&this.reviewLabel?i("span",{class:"s-rating-stars-label"},this.reviewLabel):"")):i(e,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 a(this)}};b.style="";const y=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,t)=>i("span",{key:t,innerHTML:this.review.stars>=t+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},t)=>i("button",{key:s||t,type:"button",class:"s-review-card-slider-dot "+(this.currentSlide===t?"active":""),onClick:()=>this.goToSlide(t),"aria-label":`Go to slide ${t+1}`,onPointerDown:()=>this.goToSlide(t)})))}renderSlider(){return this.hasMultipleImages?i("div",{class:"s-review-card-slider-container"},i("div",{class:"s-review-card-slides",style:{transform:this.slideTransform}},this.images.map((s=>i("div",{key:s?.id,class:"s-review-card-slider-slide"},i("img",{src:s.url,alt:s.alt||"Product image",width:275,height:275,loading:"lazy",draggable:!1}))))),i("div",{class:"s-review-card-slider-dots"},this.renderDots())):null}renderSingleImage(){const s=this.review?.product?.image;return!s||this.hasMultipleImages?null:i("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 i("div",{class:"s-review-card-header"},i("div",{class:"s-review-card-reviewer-name"},i("p",null,this.review?.name),this.review?.has_order&&i("span",{class:"s-review-card-verified-icon",innerHTML:h})),i("div",{class:"s-review-card-stars"},this.renderStars()))}renderProductInfo(){const s=this.review?.product;return s?i("a",{href:this.review?.product?.url,class:"s-review-card-product-container"},i("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}),i("div",{class:"s-review-card-product-details"},i("p",{class:"s-review-card-product-details-name"},s.name),this.showPurchaseCount?i("p",{class:"s-review-card-product-details-purchase-count"},i("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 i("div",{key:"18de38dbba7c660404090a488ff40bebb3b5cfb9",class:"s-review-card-container"},this.renderSlider(),this.renderSingleImage(),k(),i("div",{key:"cb01e59c058d9ac64cd16e66e2f2d90859680c17",class:"s-review-card-content"},this.renderHeader(),i("p",{key:"63bf8afb138423ea10a0e689b126c462b623e462",class:"s-review-card-review-content",innerHTML:this.review?.content}),k(),this.renderProductInfo()))}get el(){return a(this)}},k=()=>i("div",{class:"s-review-card-divider "});y.style=":host{display:block}";const _=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,m.generateReviewSchema(this.reviews))}))}render(){return i("div",{key:"9bf5e2e2e0050844eae92fffbf4d908825000cff",class:"s-reviews-container"},i("div",{key:"4a12a82e0c79cb72acc348ceb971cbab45f1923d",class:"s-reviews-header-wrapper"},i("h1",{key:"eb59728207a75bb4b2ec6a77b94b6899b01b8906",class:"s-reviews-header"},this.testimonialText),this.displayAllLink?i("a",{href:this.displayAllURL,class:"s-reviews-display-all"},this.displayAllLinkText,i("span",{class:"s-reviews-display-all-icon",innerHTML:u})):null),i("salla-slider",{key:"258d5dd3049b51725f08a66f2baf9e9f62c8a9e1",centered:!0,"slides-per-view":1,type:"testimonials",class:"s-reviews-testimonials-slider","controls-outer":!0,"auto-play":!0,id:`testimonials-${this.source}-slider`},i("div",{key:"e2b66faec336425bc4fddeb00681c0e24ed9dce7",slot:"items"},this.reviews.map(((s,t)=>i("div",{key:t,class:"s-reviews-swiper-slide"},i("div",{class:"s-reviews-testimonial"},i("div",{class:"s-reviews-testimonial__inner"},i("div",{class:"s-reviews-testimonial__avatar"},i("img",{src:"images/s-empty.png","data-src":s.avatar,alt:s.name?s.name:"testimonial-"+t,class:"lazy"})),i("div",{class:"s-reviews-testimonial__text"},i("p",{innerHTML:s.content}),i("div",{class:"s-reviews-testimonial__name_wrapper"},i("div",{class:"s-reviews-testimonial__info"},s.name&&i("h2",null,`${s.name}`)),i("div",{class:"s-reviews-testimonial__rating"},i("salla-rating-stars",{size:"small",value:s.stars})))),i("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,D;function E(){if(P)return $;P=1;var s=r(),t=function(){if(L)return C;L=1;var s=n();return C=function(){return s.Date.now()}}(),i=function(){if(H)return z;H=1;var s=function(){if(T)return S;T=1;var s=function(){if(M)return x;M=1;var s=/\s/;return x=function(t){for(var i=t.length;i--&&s.test(t.charAt(i)););return i}}(),t=/^\s+/;return S=function(i){return i?i.slice(0,s(i)+1).replace(t,""):i}}(),t=r(),i=l(),e=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,n=/^0o[0-7]+$/i,o=parseInt;return z=function(r){if("number"==typeof r)return r;if(i(r))return NaN;if(t(r)){var l="function"==typeof r.valueOf?r.valueOf():r;r=t(l)?l+"":l}if("string"!=typeof r)return 0===r?r:+r;r=s(r);var h=a.test(r);return h||n.test(r)?o(r.slice(2),h?2:8):e.test(r)?NaN:+r}}(),e=Math.max,a=Math.min;return $=function(n,r,l){var o,h,c,m,d,u,p=0,g=!1,v=!1,f=!0;if("function"!=typeof n)throw new TypeError("Expected a function");function w(s){var t=o,i=h;return o=h=void 0,p=s,m=n.apply(i,t)}function b(s){var t=s-u;return void 0===u||t>=r||t<0||v&&s-p>=c}function y(){var s=t();if(b(s))return k(s);d=setTimeout(y,function(s){var t=r-(s-u);return v?a(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,r),g?w(s):m}(u);if(v)return clearTimeout(d),d=setTimeout(y,r),w(u)}return void 0===d&&(d=setTimeout(y,r)),m}return r=i(r)||0,s(l)&&(g=!!l.leading,c=(v="maxWait"in l)?e(i(l.maxWait)||0,r):c,f="trailing"in l?!!l.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())},_},$}_.style="";var R=o(function(){if(D)return I;D=1;var s=E(),t=r();return I=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 N{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=R((()=>{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 j=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 N(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)");m.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=>i("option",{key:s.value,value:s.value,selected:s.value===this.sort},s.label)))}render(){return i("host",{key:"c0980c4458788ec29d9da4a60caf9eb420805abd"},i("div",{key:"802681314a0f74c98d92c6227e35a9aa6e53105c",class:"s-reviews-page-header-wrapper"},i("h2",{key:"f533920b6ccf80377af688cf88a3273ca0d5b8ea",class:"s-reviews-page-title"},this.langTitlesReviews,i("span",{key:"e5d13f7d4529c066d64fc142137dd52bdd54d106",class:"s-reviews-page-count"},"(",this.langRatingReviews,")")),i("div",{key:"ddf2fc71aa2d099d3db2a1219c4777448304575c",class:"s-reviews-page-filter-wrapper"},i("label",{key:"7c7ba82fa5157dab64776ac80ae890f5334bfa39",class:"s-reviews-page-filter-label",htmlFor:"testimonials-filter"},this.langSorting),i("select",{key:"ee1fbe63384ad7d5220511d0d919d374e9a78dd9",onChange:s=>this.handleSorting(s),disabled:!this.reviews.length,class:"s-reviews-page-filter"},this.renderSortingOptions()))),this.reviews.length?i("main",{class:"s-reviews-page-grid",ref:s=>{this.wrapper=s}},this.reviews.map((s=>i("salla-review-card",{key:s.id,review:s})))):i("div",{class:"s-products-list-placeholder"},i("span",{innerHTML:p}),i("p",null,this.placeholderText)),this.pagination?.links?.next&&this.reviews.length?i("div",{class:"s-reviews-page-load-more-container"},i("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 a(this)}};j.style=":host{display:block}";const O=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?i("div",{class:("s-reviews-summary-header-section "+(this.recommendationOnly?"s-reviews-summary-recommendation-only":"")).trim()},i("h4",{class:"s-reviews-summary-recommendation-percentage"},"%",this.data?.recommendation),i("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},t=Object.keys(s).reverse().map((t=>{const e=s[t];return i("div",{key:t,class:"s-reviews-summary-row"},i("div",{class:"s-reviews-summary-row-rate"},t," ",i("span",{innerHTML:d})),i("salla-progress-bar",{class:"s-reviews-summary-progress",value:e,target:100,hideUnits:!0,height:"16px"}),i("span",{class:"s-reviews-summary-percentage"},e,"%"))}));return i(e,{class:"s-reviews-summary-wrapper"},i("div",{class:"s-reviews-summary-header"},i("div",{class:"s-reviews-summary-header-section"},i("h3",{class:"s-reviews-summary-average"},this.data.rating),i("div",null,i("salla-rating-stars",{size:"large",value:this.data.rating}),i("p",{class:"s-reviews-summary-count"},this.basedOnLabel," ",salla.helpers.number(salla.lang.choice("pages.rating.reviews",this.data.count))))),this.renderRecommendation()),i("div",{class:"s-reviews-summary-rows"},t))}};O.style=":host{display:block}";export{g as salla_comment_form,v as salla_comment_item,w as salla_comments,b as salla_rating_stars,y as salla_review_card,_ as salla_reviews,j as salla_reviews_page,O as salla_reviews_summary}
|
|
4
|
+
import{r as s,c as t,h as i,H as e,a,i as n,j as r,k as l,d as o}from"./p-BJrHu3Q4.js";import{S as h}from"./p-BZp0rKEO.js";import{a as c}from"./p-CgtvEd63.js";import{H as m}from"./p-CHf8XdiS.js";import{S as d}from"./p-D4oPi1Ov.js";import{a as u}from"./p-BedNk7k1.js";import{S as p}from"./p-DiKTtDW5.js";const g=class{constructor(i){s(this,i),this.commentAdded=t(this,"commentAdded"),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(){if(!this.commentForm.reportValidity())return void salla.log("CommentForm:: validation error!");const s=this.commentField.value;this.submitBtn.load().then((()=>salla.comment.add({id:this.itemId,comment:s,type:this.type}))).then((()=>{this.commentAdded.emit({name:salla.config.get("user.name"),avatar:salla.config.get("user.avatar"),content:s,is_pending:!0,created_at:{date:(new Date).toISOString().replace("T"," ").substring(0,19)},images:[]}),this.commentField.value=""})).finally((()=>this.submitBtn.stop()))}render(){return i(e,{key:"2203b9f365e0658a3bc40fb0274ba9ddc0d1e040"},this.canComment?i("form",{ref:s=>this.commentForm=s},i("div",{class:"s-comment-form-wrapper"},this.showAvatar?i("img",{class:"s-comment-form-avatar",src:salla.config.get("user.avatar"),alt:"user avatar"}):"",i("div",{class:"s-comment-form-content"},i("textarea",{cols:30,rows:5,minlength:"4",maxlength:"500",ref:s=>this.commentField=s,placeholder:this.placeholder,class:"s-comment-form-input",required:!0}),i("br",null),i("div",{class:"s-comment-form-action"},i("salla-button",{ref:s=>this.submitBtn=s,"loader-position":"center",onClick:()=>this.submit()},this.submitText))))):"")}};g.style=":host{display:block}";const v=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 i("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"},i("path",{d:"M12 16V21"}),i("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 i(e,{key:"05b9da17f0e07e1115c87c671998e8123b8b0bb4",class:s?"s-comments-item-admin":"s-comments-item"},i("div",{key:"49552e9efab0aa751db6d7051318f626f9124e5a",class:{"s-comments-item-wrapper":!s,"s-comments-item-admin-wrapper":s},id:`s-comments-item-${this.comment.id}`},i("div",{key:"e795f238ee0a562675843e6da0f495512abf550c",class:"s-comments-item-inner s-comments-flex-1"},s&&i("span",{key:"05270553da039c8cdf611d7a1a0ac1ff9d5d88f2",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'}),i("div",{key:"be2ca109e89c83691d3a0a7a9e03f6e1b94fb09e",class:"s-comments-item-avatar"},i("img",{key:"402cff5a2003bf385ae8f9f7890555ef2886de87","data-src":this.comment?.avatar,alt:this.comment?.name,src:this.comment?.avatar,class:"s-comments-item-avatar-img lazy"})),i("div",{key:"af7992ad18ed3d756594cf678d01c1fdd2af6cca",class:"s-comments-flex-1"},i("div",{key:"b11dc77d96bf83c0dddd1edaa5fb57286b5b6f55",class:"s-comments-item-user-wrapper"},i("div",{key:"f899a929d3e67c7898d22cf7abc56891cdf0fa7c",class:"s-comments-item-user-info"},i("h3",{key:"9968169cbd69eb6d1d7e0b0498db03a0431d2a16",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?i("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:i("div",{class:"s-comments-flex"},this.comment.has_order?[i("span",{class:"s-comments-item-has-order-check-icon",innerHTML:h}),i("span",{class:"s-comments-item-has-order-check-text"},this.has_bought_trans," ",this.comment.rating?", ":"")]:null,this.comment.rating?i("span",{class:"s-comments-item-rated-widget"},this.rated_trans):null)),i("p",{key:"cafa0be66307c6b377f90033745b939da66344c8",class:"s-comments-item-timestamp s-ltr"},this.getDate(this.comment.created_at?.date),i("span",{key:"608db7108242f10e4d649bb23d1382f49227aeb8",class:"s-comments-item-time"}," - ",this.getTime(this.comment.created_at?.date))),this.comment.rating||this.comment.stars?i("salla-rating-stars",{size:"mini",class:"s-comments-item-stars",value:this.comment.rating||this.comment.stars}):null),i("div",{key:"9b86497c3791f7e890b560207068de4ca38d6e60",class:"s-comments-item-content"},i("p",{key:"82433f42c6b0ee29cdd42725ce1aba4dd62e67d8",innerHTML:this.comment.content}),this.allowAttachImages&&i("div",{key:"9a1bd14eb18f637588f152b8842d4637b9a6e7c1",class:"s-comments-item-images"},this.comment.images.map(((s,t)=>i("img",{key:t,src:s,alt:"",onClick:()=>this.modal.open()}))),i("salla-modal",{key:"be260096b68a1a58889bed09c68b3a2c75adefa6",ref:s=>this.modal=s,width:"sm"},i("salla-slider",{key:"8f78ee0ab370e4f99eb68fe1afa4491c4a6a0b80",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"},i("div",{key:"eea6149852a409f2e25b8f9ec4375087e1c9beb8",slot:"items"},this.comment.images.map(((s,t)=>i("img",{key:t,src:s,alt:""})))),i("div",{key:"9f693fcd5afc5e443e0ff590d6e7e386746e2a98",slot:"thumbs"},this.comment.images.map(((s,t)=>i("div",{class:"s-comments-item-images-slider-thumb"},i("img",{key:t,src:s,alt:""})))))))),this.allowLikes&&!s&&this.comment.id&&salla.url.is_page("product.single")?i("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()},i("span",null,this.helpfulLabel," ",this.likesCount>0?`(${this.likesCount})`:""),i("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>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?i("span",{class:"s-comments-item-pending-text"},this.waiting_approval_trans):null))),this.getReplies().length&&!s?this.getReplies().map((s=>i("div",null,i("salla-comment-item",{comment:s})))):null))}get host(){return a(this)}};var f;v.style=":host{display:block}",function(s){s.PAGE="page",s.PRODUCT="product",s.BLOG="blog"}(f||(f={}));const w=class{constructor(t){s(this,t),this.type=f.PAGE,this.showFormAvatar=!1,this.hideBought=!1,this.testimonials=!1,this.customerId=null,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)}patchNextPageUrl(){if(this.nextPage)try{const s=new URL(this.nextPage,window.location.origin);this.sort&&!s.searchParams.get("sort")&&s.searchParams.set("sort",this.sort),this.customerId&&!s.searchParams.get("private_comments")&&s.searchParams.set("private_comments",this.customerId),this.nextPage=s.toString()}catch(s){const t=this.nextPage.includes("?");if(this.sort&&!/[?&]sort=/.test(this.nextPage)&&(this.nextPage=this.nextPage+(t?"&":"?")+`sort=${this.sort}`),this.customerId&&!/[?&]private_comments=/.test(this.nextPage)){const s=this.nextPage.includes("?")?"&":"?";this.nextPage=this.nextPage+s+`private_comments=${this.customerId}`}}}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,this.patchNextPageUrl();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&&(m.toggleElementClassIf(t,"s-button-hide","s-button-show",(()=>s)),this.btnLoader.style.display=s?"inherit":"none")}animateItems(s){c({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())))}onCommentAdded(s){const t=s.detail;t&&(this.showPlaceholder||!this.total?(this.showPlaceholder=!1,this.total=(this.total||0)+1,this.comments=this.comments||[]):this.total=(this.total||0)+1,setTimeout((()=>{if(!this.wrapper)return;const s=this.getCommentHTML(t);this.wrapper.prepend(s),this.animateItems([s])}),0))}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{const i=t.get("private_comments");this.customerId=i&&"user"===Salla.config.get("user.type")&&Salla.config.get("user.id")?Salla.config.get("user.id"):null,s=await salla.api.comment.getComments(this.type,this.itemId,1,5,this.sort,this.customerId)}if(!s.data||!s.data.length)return this.showPlaceholder=!1,void this.loading(!1);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.patchNextPageUrl(),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?i("div",null,this.total&&!this.hideTitle?i("h2",{class:"s-comments-title"},this.blockTitle?this.blockTitle:this.comment_title):"",this.hideForm||this.testimonials?"":i("salla-comment-form",{showAvatar:this.showFormAvatar,type:this.type,"item-id":this.itemId}),i("div",{class:"s-comments-placeholder"},i("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>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'}),i("p",null,this.noComments))):i("div",{class:`s-comments s-comments-${this.testimonials?"testimonials":this.type}`},i("div",{class:this.type===f.PAGE?"s-comments-page-container":"s-comments-container"},this.total&&!this.hideTitle?i("h2",{class:"s-comments-title"},this.blockTitle?this.blockTitle:this.comment_title):"",!this.hideForm&&i("salla-comment-form",{showAvatar:this.showFormAvatar,type:this.type,"item-id":this.itemId}),salla.url.is_page("product.single")?i("salla-reviews-summary",{itemId:this.itemId}):"",i("div",{class:"s-comments-header "+(this.total?"has-total":"")},!!this.total&&i("span",{class:"s-comments-count-label",innerHTML:this.pluralize(this.comment_name,this.total)}),this.total&&!this.testimonials&&this.type!==f.BLOG?i("div",{class:"s-comments-filter-wrapper"},i("label",{class:"s-comments-filter-label",htmlFor:"comments-filter"},salla.lang.get("pages.categories.sorting")),i("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()}},i("option",{value:"latest",selected:!0},salla.lang.get("pages.testimonials.sort_by_date_desc")),i("option",{value:"oldest"},salla.lang.get("pages.testimonials.sort_by_date_asc")),this.allowLikes&&i("option",{value:"most_helpful"},this.mostHelpfulLabel))):""),i("div",{ref:s=>{this.wrapper=s}}),this.nextPage&&i("div",{class:"s-infinite-scroll-wrapper",ref:s=>{this.status=s}},i("button",{onClick:()=>this.loadMore(),class:"s-infinite-scroll-btn s-button-btn s-button-primary",type:"button"},i("span",{class:"s-button-text s-infinite-scroll-btn-text"},this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more")),i("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 a(this)}};w.style=":host{display:block}";const b=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)=>m.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 t=[];for(let e=0;e<5;e++)t.push(i("span",{class:{"s-rating-stars-btn-star":!0,["s-rating-stars-"+this.size]:!0,"s-rating-stars-selected":e<s},innerHTML:d}));return this.reviews>0&&t.push(i("span",{class:"s-rating-stars-reviews",ref:s=>this.reviewsElement=s},"(",salla.helpers.number(salla.lang.choice("pages.rating.reviews",this.reviews)),")")),t}render(){return this.translationsLoaded?this.host.closest(".swiper-slide")?.classList.contains("swiper-slide-duplicate")?"":i(e,null,i("div",{class:"s-rating-stars-wrapper"},!this.value&&0!=this.value||this.editable?i("div",{class:"s-rating-stars-element",ref:s=>this.starsElem=s},i("input",{type:"hidden",class:"rating_hidden_input",name:this.name,value:""}),[1,2,3,4,5].map((s=>i("button",{class:"s-rating-stars-btn-star s-rating-stars-"+this.size,"data-star":s},i("span",{innerHTML:d}))))):this.createStars(this.value),this.withLabel&&this.reviewLabel?i("span",{class:"s-rating-stars-label"},this.reviewLabel):"")):i(e,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 a(this)}};b.style="";const y=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,t)=>i("span",{key:t,innerHTML:this.review.stars>=t+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},t)=>i("button",{key:s||t,type:"button",class:"s-review-card-slider-dot "+(this.currentSlide===t?"active":""),onClick:()=>this.goToSlide(t),"aria-label":`Go to slide ${t+1}`,onPointerDown:()=>this.goToSlide(t)})))}renderSlider(){return this.hasMultipleImages?i("div",{class:"s-review-card-slider-container"},i("div",{class:"s-review-card-slides",style:{transform:this.slideTransform}},this.images.map((s=>i("div",{key:s?.id,class:"s-review-card-slider-slide"},i("img",{src:s.url,alt:s.alt||"Product image",width:275,height:275,loading:"lazy",draggable:!1}))))),i("div",{class:"s-review-card-slider-dots"},this.renderDots())):null}renderSingleImage(){const s=this.review?.product?.image;return!s||this.hasMultipleImages?null:i("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 i("div",{class:"s-review-card-header"},i("div",{class:"s-review-card-reviewer-name"},i("p",null,this.review?.name),this.review?.has_order&&i("span",{class:"s-review-card-verified-icon",innerHTML:h})),i("div",{class:"s-review-card-stars"},this.renderStars()))}renderProductInfo(){const s=this.review?.product;return s?i("a",{href:this.review?.product?.url,class:"s-review-card-product-container"},i("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}),i("div",{class:"s-review-card-product-details"},i("p",{class:"s-review-card-product-details-name"},s.name),this.showPurchaseCount?i("p",{class:"s-review-card-product-details-purchase-count"},i("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 i("div",{key:"18de38dbba7c660404090a488ff40bebb3b5cfb9",class:"s-review-card-container"},this.renderSlider(),this.renderSingleImage(),k(),i("div",{key:"cb01e59c058d9ac64cd16e66e2f2d90859680c17",class:"s-review-card-content"},this.renderHeader(),i("p",{key:"63bf8afb138423ea10a0e689b126c462b623e462",class:"s-review-card-review-content",innerHTML:this.review?.content}),k(),this.renderProductInfo()))}get el(){return a(this)}},k=()=>i("div",{class:"s-review-card-divider "});y.style=":host{display:block}";const _=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,m.generateReviewSchema(this.reviews))}))}render(){return i("div",{key:"9bf5e2e2e0050844eae92fffbf4d908825000cff",class:"s-reviews-container"},i("div",{key:"4a12a82e0c79cb72acc348ceb971cbab45f1923d",class:"s-reviews-header-wrapper"},i("h1",{key:"eb59728207a75bb4b2ec6a77b94b6899b01b8906",class:"s-reviews-header"},this.testimonialText),this.displayAllLink?i("a",{href:this.displayAllURL,class:"s-reviews-display-all"},this.displayAllLinkText,i("span",{class:"s-reviews-display-all-icon",innerHTML:u})):null),i("salla-slider",{key:"258d5dd3049b51725f08a66f2baf9e9f62c8a9e1",centered:!0,"slides-per-view":1,type:"testimonials",class:"s-reviews-testimonials-slider","controls-outer":!0,"auto-play":!0,id:`testimonials-${this.source}-slider`},i("div",{key:"e2b66faec336425bc4fddeb00681c0e24ed9dce7",slot:"items"},this.reviews.map(((s,t)=>i("div",{key:t,class:"s-reviews-swiper-slide"},i("div",{class:"s-reviews-testimonial"},i("div",{class:"s-reviews-testimonial__inner"},i("div",{class:"s-reviews-testimonial__avatar"},i("img",{src:"images/s-empty.png","data-src":s.avatar,alt:s.name?s.name:"testimonial-"+t,class:"lazy"})),i("div",{class:"s-reviews-testimonial__text"},i("p",{innerHTML:s.content}),i("div",{class:"s-reviews-testimonial__name_wrapper"},i("div",{class:"s-reviews-testimonial__info"},s.name&&i("h2",null,`${s.name}`)),i("div",{class:"s-reviews-testimonial__rating"},i("salla-rating-stars",{size:"small",value:s.stars})))),i("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,D;function E(){if(P)return $;P=1;var s=r(),t=function(){if(L)return C;L=1;var s=n();return C=function(){return s.Date.now()}}(),i=function(){if(H)return z;H=1;var s=function(){if(T)return S;T=1;var s=function(){if(M)return x;M=1;var s=/\s/;return x=function(t){for(var i=t.length;i--&&s.test(t.charAt(i)););return i}}(),t=/^\s+/;return S=function(i){return i?i.slice(0,s(i)+1).replace(t,""):i}}(),t=r(),i=l(),e=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,n=/^0o[0-7]+$/i,o=parseInt;return z=function(r){if("number"==typeof r)return r;if(i(r))return NaN;if(t(r)){var l="function"==typeof r.valueOf?r.valueOf():r;r=t(l)?l+"":l}if("string"!=typeof r)return 0===r?r:+r;r=s(r);var h=a.test(r);return h||n.test(r)?o(r.slice(2),h?2:8):e.test(r)?NaN:+r}}(),e=Math.max,a=Math.min;return $=function(n,r,l){var o,h,c,m,d,u,p=0,g=!1,v=!1,f=!0;if("function"!=typeof n)throw new TypeError("Expected a function");function w(s){var t=o,i=h;return o=h=void 0,p=s,m=n.apply(i,t)}function b(s){var t=s-u;return void 0===u||t>=r||t<0||v&&s-p>=c}function y(){var s=t();if(b(s))return k(s);d=setTimeout(y,function(s){var t=r-(s-u);return v?a(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,r),g?w(s):m}(u);if(v)return clearTimeout(d),d=setTimeout(y,r),w(u)}return void 0===d&&(d=setTimeout(y,r)),m}return r=i(r)||0,s(l)&&(g=!!l.leading,c=(v="maxWait"in l)?e(i(l.maxWait)||0,r):c,f="trailing"in l?!!l.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())},_},$}_.style="";var R=o(function(){if(D)return I;D=1;var s=E(),t=r();return I=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 N{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=R((()=>{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 j=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 N(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)");m.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=>i("option",{key:s.value,value:s.value,selected:s.value===this.sort},s.label)))}render(){return i("host",{key:"c0980c4458788ec29d9da4a60caf9eb420805abd"},i("div",{key:"802681314a0f74c98d92c6227e35a9aa6e53105c",class:"s-reviews-page-header-wrapper"},i("h2",{key:"f533920b6ccf80377af688cf88a3273ca0d5b8ea",class:"s-reviews-page-title"},this.langTitlesReviews,i("span",{key:"e5d13f7d4529c066d64fc142137dd52bdd54d106",class:"s-reviews-page-count"},"(",this.langRatingReviews,")")),i("div",{key:"ddf2fc71aa2d099d3db2a1219c4777448304575c",class:"s-reviews-page-filter-wrapper"},i("label",{key:"7c7ba82fa5157dab64776ac80ae890f5334bfa39",class:"s-reviews-page-filter-label",htmlFor:"testimonials-filter"},this.langSorting),i("select",{key:"ee1fbe63384ad7d5220511d0d919d374e9a78dd9",onChange:s=>this.handleSorting(s),disabled:!this.reviews.length,class:"s-reviews-page-filter"},this.renderSortingOptions()))),this.reviews.length?i("main",{class:"s-reviews-page-grid",ref:s=>{this.wrapper=s}},this.reviews.map((s=>i("salla-review-card",{key:s.id,review:s})))):i("div",{class:"s-products-list-placeholder"},i("span",{innerHTML:p}),i("p",null,this.placeholderText)),this.pagination?.links?.next&&this.reviews.length?i("div",{class:"s-reviews-page-load-more-container"},i("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 a(this)}};j.style=":host{display:block}";const O=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?i("div",{class:("s-reviews-summary-header-section "+(this.recommendationOnly?"s-reviews-summary-recommendation-only":"")).trim()},i("h4",{class:"s-reviews-summary-recommendation-percentage"},"%",this.data?.recommendation),i("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},t=Object.keys(s).reverse().map((t=>{const e=s[t];return i("div",{key:t,class:"s-reviews-summary-row"},i("div",{class:"s-reviews-summary-row-rate"},t," ",i("span",{innerHTML:d})),i("salla-progress-bar",{class:"s-reviews-summary-progress",value:e,target:100,hideUnits:!0,height:"16px"}),i("span",{class:"s-reviews-summary-percentage"},e,"%"))}));return i(e,{class:"s-reviews-summary-wrapper"},i("div",{class:"s-reviews-summary-header"},i("div",{class:"s-reviews-summary-header-section"},i("h3",{class:"s-reviews-summary-average"},this.data.rating),i("div",null,i("salla-rating-stars",{size:"large",value:this.data.rating}),i("p",{class:"s-reviews-summary-count"},this.basedOnLabel," ",salla.helpers.number(salla.lang.choice("pages.rating.reviews",this.data.count))))),this.renderRecommendation()),i("div",{class:"s-reviews-summary-rows"},t))}};O.style=":host{display:block}";export{g as salla_comment_form,v as salla_comment_item,w as salla_comments,b as salla_rating_stars,y as salla_review_card,_ as salla_reviews,j as salla_reviews_page,O as salla_reviews_summary}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,c as s,h as i,H as e,a}from"./p-
|
|
4
|
+
import{r as t,c as s,h as i,H as e,a}from"./p-BJrHu3Q4.js";const o=class{constructor(i){t(this,i),this.orderItemUpdated=s(this,"orderItemUpdated"),this.orderItemRemoved=s(this,"orderItemRemoved"),this.handleQuantityChange=t=>{const s=t.detail,i=s?.quantity??parseInt(t.target.value,10);isNaN(i)||i<1||i!==this.quantity&&(this.quantity=i,this.emitUpdate(i))},this.handleOptionsChange=()=>{this.emitUpdate(this.quantity)}}componentWillLoad(){this.quantity=this.item?.quantity||1}componentDidLoad(){const t=this.host.querySelector("salla-quantity-input");t&&t.addEventListener("change",this.handleQuantityChange);const s=this.host.querySelector("salla-product-options");s&&s.addEventListener("change",this.handleOptionsChange)}disconnectedCallback(){const t=this.host.querySelector("salla-quantity-input");t&&t.removeEventListener("change",this.handleQuantityChange);const s=this.host.querySelector("salla-product-options");s&&s.removeEventListener("change",this.handleOptionsChange)}get hasOptions(){const t=this.item.product?.options;return t&&t.length>0}async getSelectedOptions(){const t=this.host.querySelector(`salla-product-options[product-id="${this.item.product?.id}"]`);return await(t?.getSelectedOptionsData())||{}}async emitUpdate(t){const s={itemId:this.item?.id,quantity:t};this.hasOptions&&(s.options=await this.getSelectedOptions()),this.orderItemUpdated.emit(s)}removeItem(){const t=this.item?.id;null!=t&&this.orderItemRemoved.emit({itemId:t})}render(){if(!this.item)return null;const t=this.item.product,s=this.item.name||t?.name||"",a=t?.image?.url||"",o=t?.image?.alt||s,n=t?.url||"#",l=t?.price,r=t?.max_quantity,d=t?.weight_label,c=this.item.product?.options,h={value:this.quantity};return r&&(h.max=r),i(e,null,i("div",null,i("div",{class:"s-order-edit-item-header"},i("div",{class:"s-order-edit-item-media"},a&&i("a",{href:n},i("img",{src:a,alt:o,class:"s-order-edit-item-image"})),i("div",{class:"s-order-edit-item-details"},i("h2",{class:"s-order-edit-item-name"},i("a",{href:n,class:"s-order-edit-item-link"},s)),null!=l&&i("span",{class:"s-order-edit-item-price",innerHTML:salla.money(l)}),d&&i("p",{class:"s-order-edit-item-weight"},salla.lang.getWithDefault("pages.products.weight","الوزن")," ",d))),i("salla-button",{type:"button",shape:"icon",size:"small",color:"danger","aria-label":salla.lang.getWithDefault("common.elements.delete","حذف"),onClick:()=>this.removeItem()},i("i",{class:"sicon-cancel"}))),i("div",{class:"s-order-edit-item-quantity"},i("h3",{class:"s-order-edit-item-quantity-label"},salla.lang.getWithDefault("common.elements.quantity","الكمية")),i("div",{class:"s-order-edit-item-quantity-input"},i("salla-quantity-input",{...h}))),this.hasOptions&&i("form",{onSubmit:t=>t.preventDefault()},i("salla-product-options",{"product-id":t.id,options:JSON.stringify(c),key:`${t.id}-order-edit-item-options`}))))}get host(){return a(this)}};o.style="";export{o as salla_order_edit_item}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as s,c as t,h as i,H as e,a as r}from"./p-6ZT_-rrT.js";import{S as a}from"./p-CciN5Q_x.js";import{S as l}from"./p-DLNIOD9t.js";import{S as h}from"./p-8Tsmrwno.js";const o=class{constructor(i){s(this,i),this.quickOrderSubmited=t(this,"quickOrderSubmited"),this.quickOrderTitle="ليش تنتظر؟",this.subTitle="احصل على المنتج مباشرة الآن",this.payButtonTitle="اطلب المنتج",this.confirmPayButtonTitle="اشتر الآن",this.agreementText=salla.lang.get("pages.checkout.show_full_agreement"),this.isEmailRequired=!1,this.quickOrderStyle="default",this.isAvailable=!1,this.oneClick=!1,this.expanded=!1,this.isTermsRequired=!1,this.countryCode=salla.config.get("user.country_code","SA")||"SA",this.submitSucess=!1,this.placeHolderEmail=salla.lang.get("common.elements.email"),this.emailOptional=salla.lang.get("common.elements.optional"),this.agreementShowText=salla.lang.get("pages.checkout.show_full_agreement"),this.agreementModalHead=salla.lang.get("pages.checkout.full_agreement"),this.userNameLabel=salla.lang.get("pages.products.your_name"),this.termsChecked=!1,salla.onReady((()=>{this.productId=this.productId||salla.config.get("page.id")})),salla.lang.onLoaded((()=>{this.placeHolderEmail=salla.lang.get("common.elements.email"),this.emailOptional=salla.lang.get("common.elements.optional"),this.agreementShowText=salla.lang.get("pages.checkout.show_full_agreement"),this.agreementModalHead=salla.lang.get("pages.checkout.full_agreement"),this.userNameLabel=salla.lang.get("pages.products.your_name")}))}getBtnColor(){return"default"===this.quickOrderStyle?"light":"primary"}getErrorMessage(s,t){return"terms"==t?salla.lang.get("pages.checkout.check_agreement"):salla.lang.get(`common.errors.${s}`,{attribute:"name"==t?this.userNameLabel:this.placeHolderEmail})}handleInvalidInput(s){let t,i=s.target,e=i.validity;e.valueMissing?(t=this.getErrorMessage("field_required",i.name),console.log(this.getErrorMessage("field_required",i.name))):e.typeMismatch&&(t=this.getErrorMessage("invalid_value",i.name)),i.setCustomValidity(t)}async setWrapperHeight(){let s=this.host.querySelector(".s-quick-order-expandable");setTimeout((()=>{s.style.maxHeight=s.style.maxHeight||this.oneClick?null:s.scrollHeight+"px"}),50)}getDarkOrLight(){return"default"===this.quickOrderStyle&&salla.config.get("theme.color.is_dark")?"dark":"light"}getStyleColor(){return{gray:"#f3f3f3",white:"#ffffff",default:salla.config.get("theme.color.primary")}[this.quickOrderStyle]||"#f3f3f3"}async submit(s,t=!1){return s.preventDefault(),t&&!this.oneClick?(this.expanded=!this.expanded,void this.setWrapperHeight()):this.submitBtn.load().then((()=>this.getPayload())).then((s=>salla.api.cart.createQuickOrder(s))).then((()=>{setTimeout((()=>{this.submitBtn.stop(),this.submitSucess=!0,this.quickOrderSubmited.emit()}),200)})).catch((s=>s&&(console.error(s),this.submitBtn.stop())))}async getPayload(){return this.oneClick?{product_ids:[this.productId],agreement:!0}:{product_ids:[this.productId],email:this.emailInput?.value,phone:Number((await(this.phoneInput?.getValues()))?.phone),country_code:(await(this.phoneInput?.getValues()))?.countryCode||this.countryCode,name:this.nameInput?.value,agreement:this.termsChecked}}formatAgreementText(s,t=150){return s?s.length<=t?s:(new DOMParser).parseFromString(s,"text/html").documentElement.innerText.substring(0,t)+"...":""}loadQuickOrderSettings(){let s=salla.config.get("store.settings.quick_order");return s?(this.user=salla.config.get("user")||salla.storage.get("user")||{},this.countryCode=this.user?.country_code||this.countryCode,this.isEmailRequired=!this.user?.email&&this.isEmailRequired,this.oneClick=this.user?.email,this.initComponentData(s),Promise.resolve()):Promise.resolve()}initComponentData(s){this.quickOrderTitle=s.title,this.subTitle=s.sub_title,this.payButtonTitle=s.order_now_button,this.isEmailRequired=s.is_email_required,this.isTermsRequired=s.show_agreement,this.agreementText=s.agreement,this.confirmPayButtonTitle=s.confirm_button,this.thanksMessage=s.thanks_message,this.quickOrderStyle=s.style,this.isAvailable=!0,this.oneClick=this.oneClick&&!this.isTermsRequired}componentWillLoad(){return new Promise((s=>salla.onReady((()=>this.loadQuickOrderSettings().then(s)))))}render(){if(this.isAvailable)return this.submitSucess?i(e,{class:"s-quick-order"},i("div",{class:"s-quick-order-confirm",style:{backgroundColor:salla.config.get("theme.color.primary")+"10",borderColor:salla.config.get("theme.color.primary")+"10",color:salla.config.get("theme.color.primary")}},i("i",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>party-horn</title>\n<path fill="currentColor" d="M5.333 4.013c0.736 0 1.333-0.596 1.333-1.333v-0.013c0-0.737-0.597-1.327-1.333-1.327s-1.333 0.603-1.333 1.34 0.597 1.333 1.333 1.333zM11.333 10c0.341 0 0.683-0.131 0.943-0.391 1.541-1.54 2.391-3.589 2.391-5.771v-2.505c0-0.737-0.597-1.333-1.333-1.333s-1.333 0.596-1.333 1.333v2.505c0 1.468-0.572 2.848-1.609 3.885-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391zM18.667 9.993c0.319 0 0.639-0.115 0.895-0.345 0.383-0.347 0.684-0.325 1.497-0.22 0.923 0.124 2.319 0.307 3.636-0.887 1.293-1.172 1.303-2.54 1.308-3.539 0.005-0.887 0.043-1.228 0.432-1.581 0.361-0.327 0.621-0.335 1.493-0.216 0.923 0.12 2.317 0.307 3.635-0.884 0.545-0.495 0.587-1.337 0.093-1.883-0.493-0.547-1.336-0.589-1.884-0.093-0.361 0.325-0.621 0.333-1.493 0.216-0.921-0.119-2.317-0.305-3.635 0.884-1.293 1.173-1.303 2.541-1.308 3.54-0.005 0.885-0.043 1.227-0.432 1.58-0.383 0.348-0.683 0.327-1.497 0.22-0.924-0.124-2.32-0.305-3.636 0.887-0.545 0.495-0.587 1.339-0.092 1.884 0.264 0.291 0.625 0.437 0.988 0.437zM18.667 16.013c0.736 0 1.333-0.596 1.333-1.333v-0.013c0-0.737-0.597-1.327-1.333-1.327s-1.333 0.603-1.333 1.34 0.597 1.333 1.333 1.333zM30.667 17.333h-2.505c-2.179 0-4.228 0.849-5.771 2.391-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.603 0.391 0.944 0.391s0.683-0.131 0.943-0.391c1.023-1.023 2.439-1.609 3.884-1.609h2.505c0.736 0 1.333-0.596 1.333-1.333s-0.597-1.333-1.333-1.333zM30.667 10.66c-0.736 0-1.333 0.603-1.333 1.34s0.597 1.333 1.333 1.333 1.333-0.596 1.333-1.333v-0.013c0-0.736-0.597-1.327-1.333-1.327zM29.333 26.66c-0.736 0-1.333 0.603-1.333 1.34s0.597 1.333 1.333 1.333 1.333-0.596 1.333-1.333v-0.013c0-0.736-0.597-1.327-1.333-1.327zM7.456 11.057c-0.327-0.327-0.799-0.46-1.249-0.356-0.449 0.107-0.812 0.439-0.959 0.876l-5.036 15.113c-0.487 1.457-0.113 3.037 0.973 4.125 0.772 0.771 1.792 1.183 2.84 1.183 0.428 0 0.861-0.068 1.284-0.209l15.112-5.037c0.439-0.145 0.769-0.508 0.876-0.959 0.107-0.449-0.028-0.921-0.355-1.249zM4.467 29.259c-0.503 0.163-1.023 0.043-1.395-0.329-0.373-0.373-0.497-0.896-0.329-1.396l4.355-13.065 10.436 10.435z"></path>\n</svg>\n'}),i("span",null,this.thanksMessage))):i(e,{class:`s-quick-order s-quick-order-${this.getDarkOrLight()}`},i("div",{class:`s-quick-order-container s-quick-order-${this.quickOrderStyle}`,style:{backgroundColor:this.getStyleColor()}},i("div",{class:"s-quick-order-button-cont"},i("div",null,i("h3",null,this.quickOrderTitle),i("p",null,this.subTitle)),i("salla-button",{class:this.expanded?"s-quick-order-btn-close":"",onClick:s=>this.submit(s,!0),color:this.getBtnColor()},this.oneClick?this.confirmPayButtonTitle:this.expanded?i("i",{innerHTML:h}):this.confirmPayButtonTitle)),i("form",{onSubmit:s=>this.submit(s),class:"s-quick-order-expandable "+(this.expanded?"s-quick-order-shown":"")},Salla.config.isGuest()&&[i("div",{class:"s-form-group"},i("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>portrait</title>\n<path d="M24 1.333h-16c-3.676 0-6.667 2.991-6.667 6.667v16c0 3.028 2.041 5.561 4.811 6.371 0.004 0.001 0.008 0.003 0.012 0.004 0.591 0.172 1.2 0.292 1.844 0.292h16c0.644 0 1.253-0.12 1.843-0.292 0.004-0.001 0.008-0.003 0.012-0.004 2.771-0.809 4.812-3.343 4.812-6.371v-16c0-3.676-2.991-6.667-6.667-6.667zM8.012 28c0.121-1.915 3.363-4 7.988-4s7.868 2.085 7.988 4zM28 24c0 1.24-0.579 2.335-1.467 3.069-0.768-3.288-5.112-5.736-10.533-5.736s-9.765 2.448-10.533 5.736c-0.888-0.735-1.467-1.829-1.467-3.069v-16c0-2.205 1.795-4 4-4h16c2.205 0 4 1.795 4 4zM16 6.667c-3.308 0-6 2.692-6 6s2.692 6 6 6 6-2.692 6-6-2.692-6-6-6zM16 16c-1.839 0-3.333-1.495-3.333-3.333s1.495-3.333 3.333-3.333 3.333 1.495 3.333 3.333-1.495 3.333-3.333 3.333z"></path>\n</svg>\n'}),i("input",{type:"text",required:!0,class:"s-form-control s-quick-order-phone-field",name:"name",placeholder:this.userNameLabel,ref:s=>this.nameInput=s})),i("div",{class:"s-quick-order-flex-input"},i("div",{class:"s-form-group"},i("span",{innerHTML:a}),i("salla-tel-input",{ref:s=>this.phoneInput=s})),i("div",{class:"s-form-group"},i("span",{innerHTML:l}),i("input",{type:"email",class:"s-form-control s-quick-order-email-field",name:"email",required:this.isEmailRequired,placeholder:this.placeHolderEmail+" "+(this.isEmailRequired?"":this.emailOptional),ref:s=>this.emailInput=s})))],this.isTermsRequired&&i("label",{htmlFor:"terms",class:"s-quick-order-terms"},i("input",{type:"checkbox",required:!0,name:"terms",id:"terms",ref:s=>this.termsInput=s,onChange:()=>this.termsChecked=this.termsInput.checked,class:"s-checkbox"}),i("span",{class:"s-form-label"}," ",i("div",{innerHTML:this.formatAgreementText(this.agreementText,150)},this.agreementText.length>150&&i("salla-button",{shape:"link",onClick:()=>this.agreementModal.open()},this.agreementShowText))," ")),i("salla-button",{type:"submit",color:this.getBtnColor(),width:"wide",ref:s=>this.submitBtn=s},this.payButtonTitle)),i("salla-modal",{"modal-title":this.agreementModalHead,ref:s=>this.agreementModal=s},i("article",{innerHTML:this.agreementText}))))}componentDidLoad(){this.host.querySelectorAll("input").forEach((s=>{s.addEventListener("invalid",(s=>{this.handleInvalidInput(s)})),s.addEventListener("input",(()=>{s.setCustomValidity(""),s.reportValidity()}))}))}get host(){return r(this)}};o.style=".s-quick-order-expandable:not(.s-quick-order-shown){overflow:hidden}";export{o as salla_quick_order}
|
|
4
|
+
import{r as s,c as t,h as i,H as e,a as r}from"./p-BJrHu3Q4.js";import{S as a}from"./p-CciN5Q_x.js";import{S as l}from"./p-DLNIOD9t.js";import{S as h}from"./p-8Tsmrwno.js";const o=class{constructor(i){s(this,i),this.quickOrderSubmited=t(this,"quickOrderSubmited"),this.quickOrderTitle="ليش تنتظر؟",this.subTitle="احصل على المنتج مباشرة الآن",this.payButtonTitle="اطلب المنتج",this.confirmPayButtonTitle="اشتر الآن",this.agreementText=salla.lang.get("pages.checkout.show_full_agreement"),this.isEmailRequired=!1,this.quickOrderStyle="default",this.isAvailable=!1,this.oneClick=!1,this.expanded=!1,this.isTermsRequired=!1,this.countryCode=salla.config.get("user.country_code","SA")||"SA",this.submitSucess=!1,this.placeHolderEmail=salla.lang.get("common.elements.email"),this.emailOptional=salla.lang.get("common.elements.optional"),this.agreementShowText=salla.lang.get("pages.checkout.show_full_agreement"),this.agreementModalHead=salla.lang.get("pages.checkout.full_agreement"),this.userNameLabel=salla.lang.get("pages.products.your_name"),this.termsChecked=!1,salla.onReady((()=>{this.productId=this.productId||salla.config.get("page.id")})),salla.lang.onLoaded((()=>{this.placeHolderEmail=salla.lang.get("common.elements.email"),this.emailOptional=salla.lang.get("common.elements.optional"),this.agreementShowText=salla.lang.get("pages.checkout.show_full_agreement"),this.agreementModalHead=salla.lang.get("pages.checkout.full_agreement"),this.userNameLabel=salla.lang.get("pages.products.your_name")}))}getBtnColor(){return"default"===this.quickOrderStyle?"light":"primary"}getErrorMessage(s,t){return"terms"==t?salla.lang.get("pages.checkout.check_agreement"):salla.lang.get(`common.errors.${s}`,{attribute:"name"==t?this.userNameLabel:this.placeHolderEmail})}handleInvalidInput(s){let t,i=s.target,e=i.validity;e.valueMissing?(t=this.getErrorMessage("field_required",i.name),console.log(this.getErrorMessage("field_required",i.name))):e.typeMismatch&&(t=this.getErrorMessage("invalid_value",i.name)),i.setCustomValidity(t)}async setWrapperHeight(){let s=this.host.querySelector(".s-quick-order-expandable");setTimeout((()=>{s.style.maxHeight=s.style.maxHeight||this.oneClick?null:s.scrollHeight+"px"}),50)}getDarkOrLight(){return"default"===this.quickOrderStyle&&salla.config.get("theme.color.is_dark")?"dark":"light"}getStyleColor(){return{gray:"#f3f3f3",white:"#ffffff",default:salla.config.get("theme.color.primary")}[this.quickOrderStyle]||"#f3f3f3"}async submit(s,t=!1){return s.preventDefault(),t&&!this.oneClick?(this.expanded=!this.expanded,void this.setWrapperHeight()):this.submitBtn.load().then((()=>this.getPayload())).then((s=>salla.api.cart.createQuickOrder(s))).then((()=>{setTimeout((()=>{this.submitBtn.stop(),this.submitSucess=!0,this.quickOrderSubmited.emit()}),200)})).catch((s=>s&&(console.error(s),this.submitBtn.stop())))}async getPayload(){return this.oneClick?{product_ids:[this.productId],agreement:!0}:{product_ids:[this.productId],email:this.emailInput?.value,phone:Number((await(this.phoneInput?.getValues()))?.phone),country_code:(await(this.phoneInput?.getValues()))?.countryCode||this.countryCode,name:this.nameInput?.value,agreement:this.termsChecked}}formatAgreementText(s,t=150){return s?s.length<=t?s:(new DOMParser).parseFromString(s,"text/html").documentElement.innerText.substring(0,t)+"...":""}loadQuickOrderSettings(){let s=salla.config.get("store.settings.quick_order");return s?(this.user=salla.config.get("user")||salla.storage.get("user")||{},this.countryCode=this.user?.country_code||this.countryCode,this.isEmailRequired=!this.user?.email&&this.isEmailRequired,this.oneClick=this.user?.email,this.initComponentData(s),Promise.resolve()):Promise.resolve()}initComponentData(s){this.quickOrderTitle=s.title,this.subTitle=s.sub_title,this.payButtonTitle=s.order_now_button,this.isEmailRequired=s.is_email_required,this.isTermsRequired=s.show_agreement,this.agreementText=s.agreement,this.confirmPayButtonTitle=s.confirm_button,this.thanksMessage=s.thanks_message,this.quickOrderStyle=s.style,this.isAvailable=!0,this.oneClick=this.oneClick&&!this.isTermsRequired}componentWillLoad(){return new Promise((s=>salla.onReady((()=>this.loadQuickOrderSettings().then(s)))))}render(){if(this.isAvailable)return this.submitSucess?i(e,{class:"s-quick-order"},i("div",{class:"s-quick-order-confirm",style:{backgroundColor:salla.config.get("theme.color.primary")+"10",borderColor:salla.config.get("theme.color.primary")+"10",color:salla.config.get("theme.color.primary")}},i("i",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>party-horn</title>\n<path fill="currentColor" d="M5.333 4.013c0.736 0 1.333-0.596 1.333-1.333v-0.013c0-0.737-0.597-1.327-1.333-1.327s-1.333 0.603-1.333 1.34 0.597 1.333 1.333 1.333zM11.333 10c0.341 0 0.683-0.131 0.943-0.391 1.541-1.54 2.391-3.589 2.391-5.771v-2.505c0-0.737-0.597-1.333-1.333-1.333s-1.333 0.596-1.333 1.333v2.505c0 1.468-0.572 2.848-1.609 3.885-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391zM18.667 9.993c0.319 0 0.639-0.115 0.895-0.345 0.383-0.347 0.684-0.325 1.497-0.22 0.923 0.124 2.319 0.307 3.636-0.887 1.293-1.172 1.303-2.54 1.308-3.539 0.005-0.887 0.043-1.228 0.432-1.581 0.361-0.327 0.621-0.335 1.493-0.216 0.923 0.12 2.317 0.307 3.635-0.884 0.545-0.495 0.587-1.337 0.093-1.883-0.493-0.547-1.336-0.589-1.884-0.093-0.361 0.325-0.621 0.333-1.493 0.216-0.921-0.119-2.317-0.305-3.635 0.884-1.293 1.173-1.303 2.541-1.308 3.54-0.005 0.885-0.043 1.227-0.432 1.58-0.383 0.348-0.683 0.327-1.497 0.22-0.924-0.124-2.32-0.305-3.636 0.887-0.545 0.495-0.587 1.339-0.092 1.884 0.264 0.291 0.625 0.437 0.988 0.437zM18.667 16.013c0.736 0 1.333-0.596 1.333-1.333v-0.013c0-0.737-0.597-1.327-1.333-1.327s-1.333 0.603-1.333 1.34 0.597 1.333 1.333 1.333zM30.667 17.333h-2.505c-2.179 0-4.228 0.849-5.771 2.391-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.603 0.391 0.944 0.391s0.683-0.131 0.943-0.391c1.023-1.023 2.439-1.609 3.884-1.609h2.505c0.736 0 1.333-0.596 1.333-1.333s-0.597-1.333-1.333-1.333zM30.667 10.66c-0.736 0-1.333 0.603-1.333 1.34s0.597 1.333 1.333 1.333 1.333-0.596 1.333-1.333v-0.013c0-0.736-0.597-1.327-1.333-1.327zM29.333 26.66c-0.736 0-1.333 0.603-1.333 1.34s0.597 1.333 1.333 1.333 1.333-0.596 1.333-1.333v-0.013c0-0.736-0.597-1.327-1.333-1.327zM7.456 11.057c-0.327-0.327-0.799-0.46-1.249-0.356-0.449 0.107-0.812 0.439-0.959 0.876l-5.036 15.113c-0.487 1.457-0.113 3.037 0.973 4.125 0.772 0.771 1.792 1.183 2.84 1.183 0.428 0 0.861-0.068 1.284-0.209l15.112-5.037c0.439-0.145 0.769-0.508 0.876-0.959 0.107-0.449-0.028-0.921-0.355-1.249zM4.467 29.259c-0.503 0.163-1.023 0.043-1.395-0.329-0.373-0.373-0.497-0.896-0.329-1.396l4.355-13.065 10.436 10.435z"></path>\n</svg>\n'}),i("span",null,this.thanksMessage))):i(e,{class:`s-quick-order s-quick-order-${this.getDarkOrLight()}`},i("div",{class:`s-quick-order-container s-quick-order-${this.quickOrderStyle}`,style:{backgroundColor:this.getStyleColor()}},i("div",{class:"s-quick-order-button-cont"},i("div",null,i("h3",null,this.quickOrderTitle),i("p",null,this.subTitle)),i("salla-button",{class:this.expanded?"s-quick-order-btn-close":"",onClick:s=>this.submit(s,!0),color:this.getBtnColor()},this.oneClick?this.confirmPayButtonTitle:this.expanded?i("i",{innerHTML:h}):this.confirmPayButtonTitle)),i("form",{onSubmit:s=>this.submit(s),class:"s-quick-order-expandable "+(this.expanded?"s-quick-order-shown":"")},Salla.config.isGuest()&&[i("div",{class:"s-form-group"},i("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>portrait</title>\n<path d="M24 1.333h-16c-3.676 0-6.667 2.991-6.667 6.667v16c0 3.028 2.041 5.561 4.811 6.371 0.004 0.001 0.008 0.003 0.012 0.004 0.591 0.172 1.2 0.292 1.844 0.292h16c0.644 0 1.253-0.12 1.843-0.292 0.004-0.001 0.008-0.003 0.012-0.004 2.771-0.809 4.812-3.343 4.812-6.371v-16c0-3.676-2.991-6.667-6.667-6.667zM8.012 28c0.121-1.915 3.363-4 7.988-4s7.868 2.085 7.988 4zM28 24c0 1.24-0.579 2.335-1.467 3.069-0.768-3.288-5.112-5.736-10.533-5.736s-9.765 2.448-10.533 5.736c-0.888-0.735-1.467-1.829-1.467-3.069v-16c0-2.205 1.795-4 4-4h16c2.205 0 4 1.795 4 4zM16 6.667c-3.308 0-6 2.692-6 6s2.692 6 6 6 6-2.692 6-6-2.692-6-6-6zM16 16c-1.839 0-3.333-1.495-3.333-3.333s1.495-3.333 3.333-3.333 3.333 1.495 3.333 3.333-1.495 3.333-3.333 3.333z"></path>\n</svg>\n'}),i("input",{type:"text",required:!0,class:"s-form-control s-quick-order-phone-field",name:"name",placeholder:this.userNameLabel,ref:s=>this.nameInput=s})),i("div",{class:"s-quick-order-flex-input"},i("div",{class:"s-form-group"},i("span",{innerHTML:a}),i("salla-tel-input",{ref:s=>this.phoneInput=s})),i("div",{class:"s-form-group"},i("span",{innerHTML:l}),i("input",{type:"email",class:"s-form-control s-quick-order-email-field",name:"email",required:this.isEmailRequired,placeholder:this.placeHolderEmail+" "+(this.isEmailRequired?"":this.emailOptional),ref:s=>this.emailInput=s})))],this.isTermsRequired&&i("label",{htmlFor:"terms",class:"s-quick-order-terms"},i("input",{type:"checkbox",required:!0,name:"terms",id:"terms",ref:s=>this.termsInput=s,onChange:()=>this.termsChecked=this.termsInput.checked,class:"s-checkbox"}),i("span",{class:"s-form-label"}," ",i("div",{innerHTML:this.formatAgreementText(this.agreementText,150)},this.agreementText.length>150&&i("salla-button",{shape:"link",onClick:()=>this.agreementModal.open()},this.agreementShowText))," ")),i("salla-button",{type:"submit",color:this.getBtnColor(),width:"wide",ref:s=>this.submitBtn=s},this.payButtonTitle)),i("salla-modal",{"modal-title":this.agreementModalHead,ref:s=>this.agreementModal=s},i("article",{innerHTML:this.agreementText}))))}componentDidLoad(){this.host.querySelectorAll("input").forEach((s=>{s.addEventListener("invalid",(s=>{this.handleInvalidInput(s)})),s.addEventListener("input",(()=>{s.setCustomValidity(""),s.reportValidity()}))}))}get host(){return r(this)}};o.style=".s-quick-order-expandable:not(.s-quick-order-shown){overflow:hidden}";export{o as salla_quick_order}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,c as s,h as i,H as e,a as n}from"./p-6ZT_-rrT.js";import{A as o,a as l}from"./p-Vqpj4CWE.js";const d=class{constructor(i){t(this,i),this.optionsSaved=s(this,"optionsSaved"),this.productSelected=s(this,"productSelected"),this.product=null,this.sectionId=null,this.sectionIndex=0,this.productIndex=0,this.selectedOptions={},this.optionsResetTokens={},this.isLoading=!1,this.hasUnsavedChanges=!1,this.validationErrors=[]}generateCacheKey(t,s,i){return`${t||"unknown"}-${s||0}-${i||"unknown"}`}handleProductChange(t){setTimeout((()=>{this.modal&&t&&this.modal.setTitle(t.name||"")}),100),this.validationErrors=[],this.hasUnsavedChanges=!1}async open(){this.modal?(this.isLoading=!0,this.product?.name&&this.modal.setTitle(this.product.name),this.modal.open(),setTimeout((async()=>{this.product?.id&&await this.initializeSelectedOptions(),this.product?.name&&this.modal.setTitle(this.product.name),this.modal.stopLoading(),this.isLoading=!1}),300)):requestAnimationFrame((()=>this.open()))}async close(){this.modal&&this.modal.close()}async refreshOptionsState(){this.selectedOptions={...this.selectedOptions}}componentDidLoad(){this.modalOpenListener=t=>{this.product=t.product,this.sectionId=t.sectionId||null,this.sectionIndex=t.sectionIndex||0,this.productIndex=t.productIndex||0,this.open()},salla.event.on("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener=t=>{t&&t.productId&&this.clearProductOptions(t.productId,t.sectionId,t.productIndex)},salla.event.on("multiple-bundle-product-modal::clear-options",this.clearOptionsListener),this.optionChangeListener=t=>{const s=t.detail||t,{option:i,detail:e}=s,n=i||s.option_id&&this.product?.options?.find((t=>t.id===s.option_id||String(t.id)===String(s.option_id))),o=e||(s.id?s:null);this.product?.id&&n&&this.handleOptionChange(Number(this.product.id),n,o)},salla.event.on("product-options::change",this.optionChangeListener),this.checkboxChangeListener=t=>{const s=t.target;if(s&&"checkbox"===s.type&&s.name&&s.name.includes("bundle[")&&s.name.includes("][id]")){const t=s.name.match(/^bundle\[([^\]]+)\]\[([^\]]+)\]\[id\]$/);if(t&&!s.checked){const[,i,e]=t,n=s.value,o=this.host.closest("form");this.cleanupProductDeselection({sectionId:i,productIndex:parseInt(e,10),productId:n,form:o,uncheckedInput:s})}}},document.addEventListener("change",this.checkboxChangeListener)}disconnectedCallback(){this.checkboxChangeListener&&document.removeEventListener("change",this.checkboxChangeListener),this.optionChangeListener&&salla.event.off("product-options::change",this.optionChangeListener),this.modalOpenListener&&salla.event.off("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener&&salla.event.off("multiple-bundle-product-modal::clear-options",this.clearOptionsListener)}cleanupProductDeselection(t){const{sectionId:s,productIndex:i,productId:e,form:n,uncheckedInput:o}=t;if(this.clearProductOptions(e,s,i),n){const t=`bundle[${s}][${i}]`;Array.from(n.querySelectorAll(`input[name^="${t}"]`)).forEach((s=>{if(s===o)return;const i="hidden"===s.type,n=s.getAttribute("data-product-id")===String(e)&&s.name?.startsWith(t);(i||n)&&s.remove()})),requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});n.dispatchEvent(t)}))}}generateFormInputName(t,s,i){return`bundle[${t}][${s}][options][${i}]`}async initializeSelectedOptions(){if(!this.product?.id)return;const t=this.product.id,s=this.generateCacheKey(this.sectionId,this.productIndex,t),i=document.querySelector(`salla-product-options[product-id="${t}"]`);if(i)try{const t=await i.getSelectedOptions();t&&t.length>0&&(this.selectedOptions={...this.selectedOptions,[s]:t})}catch(t){console.warn("Could not initialize selected options:",t)}}clearProductOptions(t,s,i){const e={...this.selectedOptions};if(null==s||null==i||Number.isNaN(i)){const s=`-${String(t)}`,i=[];Object.keys(e).forEach((t=>{t.endsWith(s)&&(delete e[t],i.push(t))})),i.forEach((t=>this.bumpOptionsResetToken(t)))}else{const n=this.generateCacheKey(s,i,t);delete e[n],this.bumpOptionsResetToken(n)}this.selectedOptions=e,this.validationErrors=[],this.hasUnsavedChanges=!1}bumpOptionsResetToken(t){t&&(this.optionsResetTokens={...this.optionsResetTokens,[t]:(this.optionsResetTokens[t]||0)+1})}async handleOptionChange(t,s,i){const e=this.generateCacheKey(this.sectionId,this.productIndex,t),n=document.querySelector(`salla-product-options[product-id="${t}"]`);let o=[];if(n)try{o=await n.getSelectedOptions()||[]}catch(t){console.warn("Could not get current selections from component:",t)}if(o.length>0)this.selectedOptions={...this.selectedOptions,[e]:o};else if(this.selectedOptions[e]&&this.selectedOptions[e].length>0){const t=[...this.selectedOptions[e]||[]],n=t.findIndex((t=>t.option_id===s.id));n>-1?i&&null!=i.id?t[n]={...i,option_id:s.id}:t.splice(n,1):i&&null!=i.id&&t.push({...i,option_id:s.id}),this.selectedOptions={...this.selectedOptions,[e]:t}}else i&&null!=i.id&&(this.selectedOptions={...this.selectedOptions,[e]:[{...i,option_id:s.id}]});this.hasUnsavedChanges=!0,this.validationErrors=[]}async validateOptions(){if(!this.product?.options)return!0;const t=[],s=this.product.id,i=this.generateCacheKey(this.sectionId,this.productIndex,s),e=document.querySelector(`salla-product-options[product-id="${s}"]`);let n=[];if(e)try{n=await e.getSelectedOptions()||[];const t=this.selectedOptions[i]||[];(t.length>n.length||0===n.length&&t.length>0)&&(n=t)}catch(t){n=this.selectedOptions[i]||[]}else n=this.selectedOptions[i]||[];return 0===n.length&&t.push(salla.lang.get("pages.products.no_options_selected")),this.product.options.forEach((s=>{s.required&&(n.some((t=>t.option_id==s.id))||t.push(salla.lang.get("pages.products.required_option_missing",{option:s.name})))})),this.validationErrors=t,0===t.length}async onSave(t){t.preventDefault();const s=this.product?.id;if(!s)return;const i=this.generateCacheKey(this.sectionId,this.productIndex,s);if(await new Promise((t=>setTimeout(t,100))),await this.validateOptions()){this.isLoading=!0;try{const t=document.querySelector(`salla-product-options[product-id="${s}"]`);let e=await(t?.getSelectedOptions());if((!e||0===e.length)&&this.selectedOptions[i]?.length>0&&(e=this.selectedOptions[i]),!e||0===e.length)return void(this.isLoading=!1);this.selectedOptions={...this.selectedOptions,[i]:e};const n=this.host.closest("form");if(!n)return void(this.isLoading=!1);const o=`bundle[${this.sectionId}][${this.productIndex}]`;Array.from(n.querySelectorAll(`input[name^="${o}"][type="hidden"]`)).forEach((t=>t.remove())),Array.from(n.querySelectorAll(`[data-product-id="${s}"][name^="${o}"]`)).forEach((t=>t.remove()));const l=`bundle[${this.sectionId}][${this.productIndex}][id]`,d=document.getElementById(l);if(d)d.checked=!0;else{const t=document.createElement("input");t.type="hidden",t.name=`bundle[${this.sectionId}][${this.productIndex}][id]`,t.value=String(s),t.dataset.productId=String(s),n.appendChild(t)}e.forEach((t=>{const i=t.option_id,e=document.createElement("input");e.type="hidden",e.name=this.generateFormInputName(this.sectionId,this.productIndex??0,i),e.value=String(t.id),e.dataset.productId=String(s),n.appendChild(e)}));const a=new window.Event("change",{bubbles:!0});n.dispatchEvent(a),this.optionsSaved.emit({productId:Number(s),selectedOptions:e,sectionId:this.sectionId,productIndex:this.productIndex}),this.sectionId&&this.productSelected.emit({productId:Number(s),sectionId:this.sectionId,product:this.product,fromModal:!0}),salla.notify.success(salla.lang.get("pages.products.options_saved")),this.hasUnsavedChanges=!1,this.validationErrors=[],this.modal.close()}catch(t){salla.notify.error(salla.lang.get("pages.products.options_save_error"))}finally{this.isLoading=!1}}else salla.notify.error(this.validationErrors.join(", "))}getOptionsWithSelectedState(){if(!this.product?.options)return[];const t=this.generateCacheKey(this.sectionId,this.productIndex,this.product.id),s=this.selectedOptions[t]||[];return this.product.options.map((t=>({...t,details:t.details.map((t=>{const i=s.some((s=>s.id===t.id));return{...t,is_selected:i}}))})))}render(){const t=this.product?.id,s=this.getOptionsWithSelectedState(),n=this.generateCacheKey(this.sectionId,this.productIndex,t),o=this.optionsResetTokens[n]||0,l=this.isLoading||s.some((t=>t.details.some((t=>t.is_selected&&!0===t.is_out))));return i(e,{key:"1a9514ddc173fd5da9a31b29be3e905d11be5782"},i("salla-modal",{key:"50efdd76cff0794bd638490c7f48cc599a49dcfc",isLoading:this.isLoading,ref:t=>this.modal=t,width:"md",centered:!1,id:`s-multiple-bundle-product-options-modal-options-${t}`,class:"s-multiple-bundle-product-options-modal-wrapper"},i("div",{key:"9fec44912babfc95fed6ab99c5cd2e71c8bc5298",slot:"loading"},i("salla-skeleton",{key:"84c3f41d42e81330bd32f7a3c5b44cb07fc02cac",height:"100%",width:"100%"})),this.product?.images&&this.product?.images.length>0&&i("salla-slider",{key:"5de5fd4285de79b8406626fdb00dccd3987142fa",id:`details-slider-${this.product?.id}`,type:"thumbs",loop:!1,"auto-height":!0,"listen-to-thumbnails-option":!0,showThumbsControls:!1,controlsOuter:!1,showControls:!1,class:"s-multiple-bundle-product-options-modal-slider",verticalThumbs:!0,thumbsConfig:{centeredSlides:!0,centeredSlidesBounds:!0,slidesPerView:Math.min(5,Math.max(1,this.product?.images.length)),watchOverflow:!0,watchSlidesProgress:!0,direction:"vertical",spaceBetween:10}},i("div",{key:"d782e027554b6de6bb959940f9a841042f2a55e5",slot:"items"},this.product?.images&&this.product?.images.map(((t,s)=>i("div",{key:s,class:"swiper-slide"},i("img",{src:t.url,alt:t.alt||`${this.product?.name} - Image ${s+1}`,loading:"lazy",onError:t=>{t.target.style.display="none"}}))))),this.product?.images&&this.product?.images.length>1&&i("div",{key:"8b47995edd34d3f5e7c7fd5a24a39c335c6634f1",slot:"thumbs"},this.product?.images&&this.product?.images.map(((t,s)=>i("div",{key:s,"data-caption":`${this.product?.name} - Image ${s+1}`},i("img",{src:t.url,loading:"eager",class:"s-multiple-bundle-product-options-modal-slider-thumb",title:`${this.product?.name} - ${s+1}`,alt:t.alt||`${this.product?.name} - ${s+1}`,onError:t=>{t.target.style.display="none"}})))))),i("salla-product-options",{options:JSON.stringify(s),key:`${n}-reset-${o}`,"product-id":t,"unique-key":`${n}-reset-${o}`}),i("div",{key:"72847766444879b09ab86729279844c51b0cef18",slot:"footer"},i("div",{key:"58ecac81b3d09c211bf0e74e9f74d932a31ed7c1",class:"s-multiple-bundle-product-options-modal-footer"},i("salla-button",{key:"c7e08990104c111d6b6ab3375fb7649a94aa6191",onClick:t=>this.onSave(t),loading:this.isLoading,disabled:l},this.isLoading?salla.lang.get("common.elements.saving"):salla.lang.get("common.elements.save"))))))}get host(){return n(this)}static get watchers(){return{product:["handleProductChange"]}}};d.style=":host{display:block}";const a=class{constructor(i){t(this,i),this.productSelected=s(this,"productSelected"),this.productOptionsSelected=s(this,"productOptionsSelected"),this.selectedProducts={},this.savedOptionsByInstance={},this.handleProductClick=(t,s)=>{const i=this.generateEventName(this.section.id,s),e=document.getElementById(i);if(e){if(e){const i=!e.checked;i||(this.dispatchClearOptionsEvent(t,s),this.clearSavedOptionsState(this.section.id,s)),e.checked=i,requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});e.dispatchEvent(t)}))}this.productSelected.emit({product:t,sectionId:this.section.id})}},this.handleOptionsClick=t=>{this.productOptionsSelected.emit({product:t,sectionId:this.section.id})}}getProductInstanceKey(t,s){return`${t}::${s}`}dispatchClearOptionsEvent(t,s){salla.event.dispatch("multiple-bundle-product-modal::clear-options",{productId:t.id,sectionId:this.section.id,sectionIndex:this.sectionIndex,productIndex:s})}handleOptionsSaved(t){const s=t.detail;if(!s)return;const{sectionId:i,productIndex:e,selectedOptions:n}=s;if(null==i||i!==this.section?.id)return;if(null==e||Number.isNaN(e))return;const o=this.getProductInstanceKey(i,e);if(n?.length)this.savedOptionsByInstance={...this.savedOptionsByInstance,[o]:!0};else if(this.savedOptionsByInstance[o]){const t={...this.savedOptionsByInstance};delete t[o],this.savedOptionsByInstance=t}}clearSavedOptionsState(t,s){const i=this.getProductInstanceKey(t,s);if(!this.savedOptionsByInstance[i])return;const e={...this.savedOptionsByInstance};delete e[i],this.savedOptionsByInstance=e}generateEventName(t,s){return`bundle[${t}][${s}][id]`}render(){return i(e,{key:"3968471eedb925b4dda4d4d381344fb2ed4f97ed"},i("salla-slider",{key:"4bbaab685b7677b79b56cd6a3d80b210b125d568",type:"carousel",controlsOuter:!1,showControls:!1,id:`accordion-multiple-bundle-product-${this.section.id}`,pagination:!0,class:"s-multiple-bundle-product-wrapper-slider",sliderConfig:{spaceBetween:0}},i("div",{key:"b0d1a441b2cf9ed124dec4f210e082ffd0cb200b",slot:"items"},this?.section?.products?.map(((t,s)=>{const e=this.selectedProducts[this.section.id]?.has(t.id)||!1,n=this.savedOptionsByInstance[this.getProductInstanceKey(this.section.id,s)]?salla.lang.getWithDefault("pages.products.edit_selected_options","تعديل الخيارات"):salla.lang.get("pages.products.choose_from_options");let d=salla.config.get("theme.is_rtl",!0)?o:l;return i("div",{class:"s-multiple-bundle-product-slide-one-third "+(0==t.quantity?"s-multiple-bundle-product-slide-one-third-disabled":""),key:t.id},i("div",{class:"s-multiple-bundle-product-card"},i("div",{class:"s-multiple-bundle-product-image-wrapper",onClick:()=>this.handleProductClick(t,s)},i("input",{id:this.generateEventName(this.section.id,s),type:"checkbox",class:"s-multiple-bundle-product-checkbox",checked:e,name:this.generateEventName(this.section.id,s),value:t.id}),i("img",{src:t.image.url||salla.url.cdn("images/s-empty.png"),loading:"lazy",alt:t.image.alt||t.name,class:"s-multiple-bundle-product-image"})),i("div",{class:"s-multiple-bundle-product-content-wrapper"},i("div",{class:"s-multiple-bundle-product-content"},i("div",{class:"s-multiple-bundle-product-details"},i("div",{class:"s-multiple-bundle-product-title-wrapper"},i("h2",{class:"s-multiple-bundle-product-title"},i("a",{href:t?.url||"#",target:"_blank",rel:"noopener noreferrer"},t.name))),i("div",{class:"s-multiple-bundle-product-price-wrapper"},i("span",{class:"s-multiple-bundle-product-price"},i("span",{innerHTML:salla.money(t.price)})),t.sale_price>0&&i("span",{class:"s-multiple-bundle-product-price-discount"},i("span",{innerHTML:salla.money(t.regular_price)})))),t.quantity_in_group>0&&0!==t.quantity&&i("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.pieces"),i("span",null,t.quantity_in_group)),0===t.quantity&&i("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.quantity_in_group_finished"))),t.options?.length>0&&i("button",{class:"s-multiple-bundle-product-button",onClick:()=>this.handleOptionsClick(t),type:"button"},n,i("span",{class:"s-multiple-bundle-product-button-icon",innerHTML:d})))))})))))}get host(){return n(this)}};a.style="";export{d as salla_multiple_bundle_product_options_modal,a as salla_multiple_bundle_product_slider}
|
|
4
|
+
import{r as t,c as s,h as i,H as e,a as n}from"./p-BJrHu3Q4.js";import{A as o,a as l}from"./p-Vqpj4CWE.js";const d=class{constructor(i){t(this,i),this.optionsSaved=s(this,"optionsSaved"),this.productSelected=s(this,"productSelected"),this.product=null,this.sectionId=null,this.sectionIndex=0,this.productIndex=0,this.selectedOptions={},this.optionsResetTokens={},this.isLoading=!1,this.hasUnsavedChanges=!1,this.validationErrors=[]}generateCacheKey(t,s,i){return`${t||"unknown"}-${s||0}-${i||"unknown"}`}handleProductChange(t){setTimeout((()=>{this.modal&&t&&this.modal.setTitle(t.name||"")}),100),this.validationErrors=[],this.hasUnsavedChanges=!1}async open(){this.modal?(this.isLoading=!0,this.product?.name&&this.modal.setTitle(this.product.name),this.modal.open(),setTimeout((async()=>{this.product?.id&&await this.initializeSelectedOptions(),this.product?.name&&this.modal.setTitle(this.product.name),this.modal.stopLoading(),this.isLoading=!1}),300)):requestAnimationFrame((()=>this.open()))}async close(){this.modal&&this.modal.close()}async refreshOptionsState(){this.selectedOptions={...this.selectedOptions}}componentDidLoad(){this.modalOpenListener=t=>{this.product=t.product,this.sectionId=t.sectionId||null,this.sectionIndex=t.sectionIndex||0,this.productIndex=t.productIndex||0,this.open()},salla.event.on("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener=t=>{t&&t.productId&&this.clearProductOptions(t.productId,t.sectionId,t.productIndex)},salla.event.on("multiple-bundle-product-modal::clear-options",this.clearOptionsListener),this.optionChangeListener=t=>{const s=t.detail||t,{option:i,detail:e}=s,n=i||s.option_id&&this.product?.options?.find((t=>t.id===s.option_id||String(t.id)===String(s.option_id))),o=e||(s.id?s:null);this.product?.id&&n&&this.handleOptionChange(Number(this.product.id),n,o)},salla.event.on("product-options::change",this.optionChangeListener),this.checkboxChangeListener=t=>{const s=t.target;if(s&&"checkbox"===s.type&&s.name&&s.name.includes("bundle[")&&s.name.includes("][id]")){const t=s.name.match(/^bundle\[([^\]]+)\]\[([^\]]+)\]\[id\]$/);if(t&&!s.checked){const[,i,e]=t,n=s.value,o=this.host.closest("form");this.cleanupProductDeselection({sectionId:i,productIndex:parseInt(e,10),productId:n,form:o,uncheckedInput:s})}}},document.addEventListener("change",this.checkboxChangeListener)}disconnectedCallback(){this.checkboxChangeListener&&document.removeEventListener("change",this.checkboxChangeListener),this.optionChangeListener&&salla.event.off("product-options::change",this.optionChangeListener),this.modalOpenListener&&salla.event.off("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener&&salla.event.off("multiple-bundle-product-modal::clear-options",this.clearOptionsListener)}cleanupProductDeselection(t){const{sectionId:s,productIndex:i,productId:e,form:n,uncheckedInput:o}=t;if(this.clearProductOptions(e,s,i),n){const t=`bundle[${s}][${i}]`;Array.from(n.querySelectorAll(`input[name^="${t}"]`)).forEach((s=>{if(s===o)return;const i="hidden"===s.type,n=s.getAttribute("data-product-id")===String(e)&&s.name?.startsWith(t);(i||n)&&s.remove()})),requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});n.dispatchEvent(t)}))}}generateFormInputName(t,s,i){return`bundle[${t}][${s}][options][${i}]`}async initializeSelectedOptions(){if(!this.product?.id)return;const t=this.product.id,s=this.generateCacheKey(this.sectionId,this.productIndex,t),i=document.querySelector(`salla-product-options[product-id="${t}"]`);if(i)try{const t=await i.getSelectedOptions();t&&t.length>0&&(this.selectedOptions={...this.selectedOptions,[s]:t})}catch(t){console.warn("Could not initialize selected options:",t)}}clearProductOptions(t,s,i){const e={...this.selectedOptions};if(null==s||null==i||Number.isNaN(i)){const s=`-${String(t)}`,i=[];Object.keys(e).forEach((t=>{t.endsWith(s)&&(delete e[t],i.push(t))})),i.forEach((t=>this.bumpOptionsResetToken(t)))}else{const n=this.generateCacheKey(s,i,t);delete e[n],this.bumpOptionsResetToken(n)}this.selectedOptions=e,this.validationErrors=[],this.hasUnsavedChanges=!1}bumpOptionsResetToken(t){t&&(this.optionsResetTokens={...this.optionsResetTokens,[t]:(this.optionsResetTokens[t]||0)+1})}async handleOptionChange(t,s,i){const e=this.generateCacheKey(this.sectionId,this.productIndex,t),n=document.querySelector(`salla-product-options[product-id="${t}"]`);let o=[];if(n)try{o=await n.getSelectedOptions()||[]}catch(t){console.warn("Could not get current selections from component:",t)}if(o.length>0)this.selectedOptions={...this.selectedOptions,[e]:o};else if(this.selectedOptions[e]&&this.selectedOptions[e].length>0){const t=[...this.selectedOptions[e]||[]],n=t.findIndex((t=>t.option_id===s.id));n>-1?i&&null!=i.id?t[n]={...i,option_id:s.id}:t.splice(n,1):i&&null!=i.id&&t.push({...i,option_id:s.id}),this.selectedOptions={...this.selectedOptions,[e]:t}}else i&&null!=i.id&&(this.selectedOptions={...this.selectedOptions,[e]:[{...i,option_id:s.id}]});this.hasUnsavedChanges=!0,this.validationErrors=[]}async validateOptions(){if(!this.product?.options)return!0;const t=[],s=this.product.id,i=this.generateCacheKey(this.sectionId,this.productIndex,s),e=document.querySelector(`salla-product-options[product-id="${s}"]`);let n=[];if(e)try{n=await e.getSelectedOptions()||[];const t=this.selectedOptions[i]||[];(t.length>n.length||0===n.length&&t.length>0)&&(n=t)}catch(t){n=this.selectedOptions[i]||[]}else n=this.selectedOptions[i]||[];return 0===n.length&&t.push(salla.lang.get("pages.products.no_options_selected")),this.product.options.forEach((s=>{s.required&&(n.some((t=>t.option_id==s.id))||t.push(salla.lang.get("pages.products.required_option_missing",{option:s.name})))})),this.validationErrors=t,0===t.length}async onSave(t){t.preventDefault();const s=this.product?.id;if(!s)return;const i=this.generateCacheKey(this.sectionId,this.productIndex,s);if(await new Promise((t=>setTimeout(t,100))),await this.validateOptions()){this.isLoading=!0;try{const t=document.querySelector(`salla-product-options[product-id="${s}"]`);let e=await(t?.getSelectedOptions());if((!e||0===e.length)&&this.selectedOptions[i]?.length>0&&(e=this.selectedOptions[i]),!e||0===e.length)return void(this.isLoading=!1);this.selectedOptions={...this.selectedOptions,[i]:e};const n=this.host.closest("form");if(!n)return void(this.isLoading=!1);const o=`bundle[${this.sectionId}][${this.productIndex}]`;Array.from(n.querySelectorAll(`input[name^="${o}"][type="hidden"]`)).forEach((t=>t.remove())),Array.from(n.querySelectorAll(`[data-product-id="${s}"][name^="${o}"]`)).forEach((t=>t.remove()));const l=`bundle[${this.sectionId}][${this.productIndex}][id]`,d=document.getElementById(l);if(d)d.checked=!0;else{const t=document.createElement("input");t.type="hidden",t.name=`bundle[${this.sectionId}][${this.productIndex}][id]`,t.value=String(s),t.dataset.productId=String(s),n.appendChild(t)}e.forEach((t=>{const i=t.option_id,e=document.createElement("input");e.type="hidden",e.name=this.generateFormInputName(this.sectionId,this.productIndex??0,i),e.value=String(t.id),e.dataset.productId=String(s),n.appendChild(e)}));const a=new window.Event("change",{bubbles:!0});n.dispatchEvent(a),this.optionsSaved.emit({productId:Number(s),selectedOptions:e,sectionId:this.sectionId,productIndex:this.productIndex}),this.sectionId&&this.productSelected.emit({productId:Number(s),sectionId:this.sectionId,product:this.product,fromModal:!0}),salla.notify.success(salla.lang.get("pages.products.options_saved")),this.hasUnsavedChanges=!1,this.validationErrors=[],this.modal.close()}catch(t){salla.notify.error(salla.lang.get("pages.products.options_save_error"))}finally{this.isLoading=!1}}else salla.notify.error(this.validationErrors.join(", "))}getOptionsWithSelectedState(){if(!this.product?.options)return[];const t=this.generateCacheKey(this.sectionId,this.productIndex,this.product.id),s=this.selectedOptions[t]||[];return this.product.options.map((t=>({...t,details:t.details.map((t=>{const i=s.some((s=>s.id===t.id));return{...t,is_selected:i}}))})))}render(){const t=this.product?.id,s=this.getOptionsWithSelectedState(),n=this.generateCacheKey(this.sectionId,this.productIndex,t),o=this.optionsResetTokens[n]||0,l=this.isLoading||s.some((t=>t.details.some((t=>t.is_selected&&!0===t.is_out))));return i(e,{key:"1a9514ddc173fd5da9a31b29be3e905d11be5782"},i("salla-modal",{key:"50efdd76cff0794bd638490c7f48cc599a49dcfc",isLoading:this.isLoading,ref:t=>this.modal=t,width:"md",centered:!1,id:`s-multiple-bundle-product-options-modal-options-${t}`,class:"s-multiple-bundle-product-options-modal-wrapper"},i("div",{key:"9fec44912babfc95fed6ab99c5cd2e71c8bc5298",slot:"loading"},i("salla-skeleton",{key:"84c3f41d42e81330bd32f7a3c5b44cb07fc02cac",height:"100%",width:"100%"})),this.product?.images&&this.product?.images.length>0&&i("salla-slider",{key:"5de5fd4285de79b8406626fdb00dccd3987142fa",id:`details-slider-${this.product?.id}`,type:"thumbs",loop:!1,"auto-height":!0,"listen-to-thumbnails-option":!0,showThumbsControls:!1,controlsOuter:!1,showControls:!1,class:"s-multiple-bundle-product-options-modal-slider",verticalThumbs:!0,thumbsConfig:{centeredSlides:!0,centeredSlidesBounds:!0,slidesPerView:Math.min(5,Math.max(1,this.product?.images.length)),watchOverflow:!0,watchSlidesProgress:!0,direction:"vertical",spaceBetween:10}},i("div",{key:"d782e027554b6de6bb959940f9a841042f2a55e5",slot:"items"},this.product?.images&&this.product?.images.map(((t,s)=>i("div",{key:s,class:"swiper-slide"},i("img",{src:t.url,alt:t.alt||`${this.product?.name} - Image ${s+1}`,loading:"lazy",onError:t=>{t.target.style.display="none"}}))))),this.product?.images&&this.product?.images.length>1&&i("div",{key:"8b47995edd34d3f5e7c7fd5a24a39c335c6634f1",slot:"thumbs"},this.product?.images&&this.product?.images.map(((t,s)=>i("div",{key:s,"data-caption":`${this.product?.name} - Image ${s+1}`},i("img",{src:t.url,loading:"eager",class:"s-multiple-bundle-product-options-modal-slider-thumb",title:`${this.product?.name} - ${s+1}`,alt:t.alt||`${this.product?.name} - ${s+1}`,onError:t=>{t.target.style.display="none"}})))))),i("salla-product-options",{options:JSON.stringify(s),key:`${n}-reset-${o}`,"product-id":t,"unique-key":`${n}-reset-${o}`}),i("div",{key:"72847766444879b09ab86729279844c51b0cef18",slot:"footer"},i("div",{key:"58ecac81b3d09c211bf0e74e9f74d932a31ed7c1",class:"s-multiple-bundle-product-options-modal-footer"},i("salla-button",{key:"c7e08990104c111d6b6ab3375fb7649a94aa6191",onClick:t=>this.onSave(t),loading:this.isLoading,disabled:l},this.isLoading?salla.lang.get("common.elements.saving"):salla.lang.get("common.elements.save"))))))}get host(){return n(this)}static get watchers(){return{product:["handleProductChange"]}}};d.style=":host{display:block}";const a=class{constructor(i){t(this,i),this.productSelected=s(this,"productSelected"),this.productOptionsSelected=s(this,"productOptionsSelected"),this.selectedProducts={},this.savedOptionsByInstance={},this.handleProductClick=(t,s)=>{const i=this.generateEventName(this.section.id,s),e=document.getElementById(i);if(e){if(e){const i=!e.checked;i||(this.dispatchClearOptionsEvent(t,s),this.clearSavedOptionsState(this.section.id,s)),e.checked=i,requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});e.dispatchEvent(t)}))}this.productSelected.emit({product:t,sectionId:this.section.id})}},this.handleOptionsClick=t=>{this.productOptionsSelected.emit({product:t,sectionId:this.section.id})}}getProductInstanceKey(t,s){return`${t}::${s}`}dispatchClearOptionsEvent(t,s){salla.event.dispatch("multiple-bundle-product-modal::clear-options",{productId:t.id,sectionId:this.section.id,sectionIndex:this.sectionIndex,productIndex:s})}handleOptionsSaved(t){const s=t.detail;if(!s)return;const{sectionId:i,productIndex:e,selectedOptions:n}=s;if(null==i||i!==this.section?.id)return;if(null==e||Number.isNaN(e))return;const o=this.getProductInstanceKey(i,e);if(n?.length)this.savedOptionsByInstance={...this.savedOptionsByInstance,[o]:!0};else if(this.savedOptionsByInstance[o]){const t={...this.savedOptionsByInstance};delete t[o],this.savedOptionsByInstance=t}}clearSavedOptionsState(t,s){const i=this.getProductInstanceKey(t,s);if(!this.savedOptionsByInstance[i])return;const e={...this.savedOptionsByInstance};delete e[i],this.savedOptionsByInstance=e}generateEventName(t,s){return`bundle[${t}][${s}][id]`}render(){return i(e,{key:"3968471eedb925b4dda4d4d381344fb2ed4f97ed"},i("salla-slider",{key:"4bbaab685b7677b79b56cd6a3d80b210b125d568",type:"carousel",controlsOuter:!1,showControls:!1,id:`accordion-multiple-bundle-product-${this.section.id}`,pagination:!0,class:"s-multiple-bundle-product-wrapper-slider",sliderConfig:{spaceBetween:0}},i("div",{key:"b0d1a441b2cf9ed124dec4f210e082ffd0cb200b",slot:"items"},this?.section?.products?.map(((t,s)=>{const e=this.selectedProducts[this.section.id]?.has(t.id)||!1,n=this.savedOptionsByInstance[this.getProductInstanceKey(this.section.id,s)]?salla.lang.getWithDefault("pages.products.edit_selected_options","تعديل الخيارات"):salla.lang.get("pages.products.choose_from_options");let d=salla.config.get("theme.is_rtl",!0)?o:l;return i("div",{class:"s-multiple-bundle-product-slide-one-third "+(0==t.quantity?"s-multiple-bundle-product-slide-one-third-disabled":""),key:t.id},i("div",{class:"s-multiple-bundle-product-card"},i("div",{class:"s-multiple-bundle-product-image-wrapper",onClick:()=>this.handleProductClick(t,s)},i("input",{id:this.generateEventName(this.section.id,s),type:"checkbox",class:"s-multiple-bundle-product-checkbox",checked:e,name:this.generateEventName(this.section.id,s),value:t.id}),i("img",{src:t.image.url||salla.url.cdn("images/s-empty.png"),loading:"lazy",alt:t.image.alt||t.name,class:"s-multiple-bundle-product-image"})),i("div",{class:"s-multiple-bundle-product-content-wrapper"},i("div",{class:"s-multiple-bundle-product-content"},i("div",{class:"s-multiple-bundle-product-details"},i("div",{class:"s-multiple-bundle-product-title-wrapper"},i("h2",{class:"s-multiple-bundle-product-title"},i("a",{href:t?.url||"#",target:"_blank",rel:"noopener noreferrer"},t.name))),i("div",{class:"s-multiple-bundle-product-price-wrapper"},i("span",{class:"s-multiple-bundle-product-price"},i("span",{innerHTML:salla.money(t.price)})),t.sale_price>0&&i("span",{class:"s-multiple-bundle-product-price-discount"},i("span",{innerHTML:salla.money(t.regular_price)})))),t.quantity_in_group>0&&0!==t.quantity&&i("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.pieces"),i("span",null,t.quantity_in_group)),0===t.quantity&&i("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.quantity_in_group_finished"))),t.options?.length>0&&i("button",{class:"s-multiple-bundle-product-button",onClick:()=>this.handleOptionsClick(t),type:"button"},n,i("span",{class:"s-multiple-bundle-product-button-icon",innerHTML:d})))))})))))}get host(){return n(this)}};a.style="";export{d as salla_multiple_bundle_product_options_modal,a as salla_multiple_bundle_product_slider}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as s,h as l,H as t}from"./p-
|
|
4
|
+
import{r as s,h as l,H as t}from"./p-BJrHu3Q4.js";const i=class{constructor(l){s(this,l),this.methods=[],this.shouldRender=!1}async componentDidLoad(){await Salla.onReady(),await Salla.lang.onLoaded(),Salla.config.get("store.support_pickup")&&(this.shouldRender=!0,this.setLabels())}setLabels(){this.methods=[{id:"delivery",title:Salla.lang.getWithDefault("pages.products.promise_delivery_title","متاح للتوصيل"),subtitle:Salla.lang.getWithDefault("pages.products.promise_delivery_subtitle","طلبك يوصلك لباب البيت بسهولة."),iconClass:"sicon-location"},{id:"pickup",title:Salla.lang.getWithDefault("pages.products.promise_pickup_title","متاح للاستلام"),subtitle:Salla.lang.getWithDefault("pages.products.promise_pickup_subtitle","استلام فوري من أقرب فرع."),iconClass:"sicon-store"}]}render(){return this.shouldRender?l(t,{class:"s-fulfillment-methods"},l("div",{class:"s-fulfillment-methods-list"},this.methods.map((s=>l("div",{key:s.id,class:"s-fulfillment-methods-card"},l("div",{class:"s-fulfillment-methods-content"},l("div",{class:"s-fulfillment-methods-icon-wrap"},l("i",{class:`${s.iconClass} s-fulfillment-methods-icon`})),l("div",{class:"s-fulfillment-methods-text"},l("span",{class:"s-fulfillment-methods-title"},s.title),l("span",{class:"s-fulfillment-methods-subtitle"},s.subtitle)))))))):null}};export{i as salla_fulfillment_methods}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as e,h as a,H as t,a as n}from"./p-
|
|
4
|
+
import{r as e,h as a,H as t,a as n}from"./p-BJrHu3Q4.js";import{S as i}from"./p-8Tsmrwno.js";const r=class{constructor(a){e(this,a)}componentWillLoad(){this.title=salla.config.get("maintenance_details.title"),this.message=salla.config.get("maintenance_details.message");const e="undefined"!=typeof window&&!window.matchMedia("(min-width: 768px)").matches;this.buttonTitle=e?salla.config.get("maintenance_details.button_title"):salla.config.get("maintenance_details.button_full_title")}closeAlert(){salla.storage.set("hide_salla-maintenance-alert_at",Date.now()),this.host.style.display="none"}render(){return a(t,{key:"e76dcd0a076d1b72ead3398196f962713e975ce5",class:"s-maintenance-alert-wrapper"},a("button",{key:"2105bc891908dab5a1c9edec1c534a600bb35fe5",class:"s-maintenance-alert-close",innerHTML:i,onClick:()=>this.closeAlert()}),a("div",{key:"a01b014066fbbc08da96962ad9a0c98e24fddf1c",class:"s-maintenance-alert-content"},a("div",{key:"c8b6ac96a881fc40bdb65908bb309378035235ea",class:"s-maintenance-alert-container"},a("div",{key:"5d9fb2968315674e0d3a3172f82f9109db55da1d",class:"s-maintenance-alert-icon"},a("img",{key:"2649551a12d0958375a89cc1dcb8176b28f5e41f",src:salla.url.cdn("images/alert.png"),alt:"Alert"})),a("div",{key:"2b3f99a39857bcf87b034aa48074c1f4229bff95",class:"s-maintenance-alert-text"},a("h2",{key:"5a3c0969cd45f666a8bd043d171e00bc88031f3e"},this.title),a("p",{key:"d3df4ada2bf5f7192b22affeeb10edec481a0038"},this.message))),a("div",{key:"818d96f7680dc4b02fed14a2d8c09dab9b8e5d86"},a("a",{key:"794a0c273fc4d84b0319b38e11fb43af5681ce67",class:"s-maintenance-alert-btn",href:salla.config.get("maintenance_details.button_url")},this.buttonTitle))))}componentDidLoad(){let e=salla.storage.get("hide_salla-maintenance-alert_at");e&&(Date.now()-e)/1e3/60<60&&this.closeAlert()}get host(){return n(this)}};r.style=".s-maintenance-alert-wrapper{display:flex;min-height:40px;width:100%;flex-direction:row;align-items:center;justify-content:center;--tw-bg-opacity:1;background-color:rgba(26, 38, 61, var(--tw-bg-opacity));padding:0.25rem 0.5rem;--tw-text-opacity:1;color:rgba(255, 255, 255, var(--tw-text-opacity))}.s-maintenance-alert-wrapper a{transition:0.35s cubic-bezier(0.2, 1, 0.3, 1)}.s-maintenance-alert-wrapper *{color:inherit}@media (min-width: 640px){.s-maintenance-alert-wrapper{padding-left:2rem;padding-right:2rem}}.s-maintenance-alert-content{margin-top:1rem;margin-bottom:1rem;display:flex;width:100%;align-items:center;justify-content:space-between}@media (min-width: 640px){.s-maintenance-alert-content{padding-left:2rem;padding-right:2rem}}.s-maintenance-alert-container{display:flex;align-items:center}.s-maintenance-alert-icon{margin-right:1.25rem;display:none}@media (min-width: 640px){.s-maintenance-alert-icon{display:block}}.s-maintenance-alert-text h2{margin-bottom:0.5rem;font-size:0.875rem;font-weight:700;line-height:1.4}@media (min-width: 640px){.s-maintenance-alert-text h2{font-size:1.5rem;line-height:2rem}}.s-maintenance-alert-text p{margin:0px;text-align:right;font-size:10px;line-height:1.2}@media (min-width: 640px){.s-maintenance-alert-text p{text-align:center;font-size:0.75rem;line-height:1}}.s-maintenance-alert-btn{position:relative;margin-left:4px;margin-right:4px;display:inline-block;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none;white-space:nowrap;border-radius:0.125rem;border-width:1px;--tw-border-opacity:1;border-color:rgba(93, 213, 196, var(--tw-border-opacity));--tw-bg-opacity:1;background-color:rgba(93, 213, 196, var(--tw-bg-opacity));padding:0.5rem;text-align:center;vertical-align:middle;font-size:0.875rem;font-weight:400;line-height:1.4;--tw-text-opacity:1;color:rgba(255, 255, 255, var(--tw-text-opacity))}.s-maintenance-alert-btn:hover{--tw-bg-opacity:1;background-color:rgba(53, 203, 181, var(--tw-bg-opacity))}.s-maintenance-alert-btn *{pointer-events:none}[dir=rtl] .s-maintenance-alert-btn{margin-left:1.25rem;margin-right:0}@media (min-width: 640px){.s-maintenance-alert-btn{padding:0.5rem 1rem}}";export{r as salla_maintenance_alert}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,c as s,h as e,H as i,a}from"./p-
|
|
4
|
+
import{r as t,c as s,h as e,H as i,a}from"./p-BJrHu3Q4.js";import{F as l}from"./p-DL4h2bc3.js";import{H as r}from"./p-CHf8XdiS.js";import"./p-CgtvEd63.js";const o=class{constructor(e){t(this,e),this.changed=s(this,"changed"),this.isReady=!1,this.filtersData={},salla.event.on("filters::hidden",(()=>this.host.style.display="none")),salla.lang.onLoaded((()=>{this.apply=salla.lang.get("pages.checkout.apply"),this.reset=salla.lang.get("pages.categories.filters_reset")})),salla.event.on("filters::fetched",(({filters:t})=>{this.host.style.display="";let s={};this.filters=t.map((t=>{if(t.label={category_id:salla.lang.get("common.titles.categories"),brand_id:salla.lang.get("common.titles.brands"),rating:salla.lang.get("pages.categories.filter_rating"),price:salla.lang.get("pages.categories.filter_price")}[t.key]||t.label,"rating"==t.key){t.type=l.VALUES;let{max:s,min:e}=t.values;t.values=[5,4,3,2,1].filter((t=>t>=e||t<=s))}this.filtersData.variants&&t.type==l.VARIANTS&&(s.variants=this.filtersData.variants),this.filtersData[t.key]&&t.type!==l.VARIANTS&&(s[t.key]=this.filtersData[t.key]);let e=new URLSearchParams(window.location.search),i=!1;for(let t of e.keys())if(t.includes("filters")){i=!0;break}if("product.index"==salla.config.get("page.slug")&&0==Object.keys(s).length&&!i){let t=window.location.href,e=salla.config.get("page.id"),i=-1!==t.indexOf("?")?"&":"?",a=t+i+"filters[category_id]="+e;s.category_id=e,window.history.pushState({path:a},"",a)}return t})),this.filtersData=s,this.host.childNodes.forEach((async t=>t.setWidgetHeight&&await t.setWidgetHeight()))}))}async componentWillLoad(){try{const t=new URLSearchParams(window.location.search);this.filtersData=await r.extractFiltersFromUrl(t)}catch(t){console.warn("failed to get filters from URL",t.message)}}async getFilters(){return this.filtersData}async applyFilters(){if(!this.isReady)return;let t=Object.keys(this.filtersData).length>0;setTimeout((()=>{if(t){let t=new URL(window.location.href);for(const[s]of t.searchParams.entries())s.startsWith("filters")&&t.searchParams.delete(s);let s=this.encodeFilters(this.filtersData),e=t.search.split("&").filter((t=>!t.includes("filters"))).join("&");t.search=e?t.search.split("&filters")[0]+"&"+s:`?${s}`,window.history.pushState({},"",t.href)}else{let t=new URL(window.location.href);t.searchParams?.delete("filters"),window.history.pushState({},"",t.toString())}salla.event.emit("salla-filters::changed",this.filtersData),this.changed.emit(this.filtersData)}),300)}encodeFilters(t,s="filters"){const e=[];for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){const a=t[i],l=s?`${s}[${i}]`:i;if(Array.isArray(a))for(let t=0;t<a.length;t++)e.push(`${l}[${t}]=${a[t]}`);else e.push("object"==typeof a&&null!==a?this.encodeFilters(a,l):`${l}=${a}`)}return e.join("&")}async resetFilters(){return this.removeFiltersQueryParams(),this.filtersData={},this.host.childNodes.forEach((t=>t.reset&&t.reset())),salla.event.emit("salla-filters::reset"),this.applyFilters()}removeFiltersQueryParams(){const t=new URLSearchParams(window.location.search),s=Array.from(t.keys()).filter((t=>!t.startsWith("filters["))).map((s=>`${encodeURIComponent(s)}=${encodeURIComponent(t.get(s))}`)).join("&"),e=s?`${window.location.pathname}?${s}`:window.location.pathname;window.history.pushState({},"",e)}handleOptionChange(t,s,e){s.type===l.RANGE&&(this.filtersData[s.key]=e);let i=t.target.checked;s.type===l.VARIANTS?(this.filtersData.variants=this.filtersData.variants||{},i&&(this.filtersData.variants[s.key]=e),i||delete this.filtersData.variants[s.key]):"radio"==t.target.type?(i&&(this.filtersData[s.key]=e),i||delete this.filtersData[s.key]):"checkbox"==t.target.type&&(this.filtersData[s.key]=this.filtersData[s.key]||[],i&&this.filtersData[s.key].push(e),this.filtersData[s.key]=this.filtersData[s.key].filter((t=>t!=e))),this.applyFilters()}render(){return e(i,{key:"b41c36d8512dcac97dbe3a75e5c1e0373673913d"},this.filters?.map((t=>e("salla-filters-widget",{option:t,filtersData:this.filtersData,onChanged:({detail:{event:t,option:s,value:e}})=>{this.handleOptionChange(t,s,e)}}))),this.filters?.length?e("div",{class:"s-filters-footer"},e("salla-button",{color:"gray",fill:"outline",onClick:()=>this.resetFilters()},this.reset)):"")}componentDidLoad(){this.isReady=!0}get host(){return a(this)}};o.style=":host{display:block}.s-rating-stars-small{line-height:12px}.s-filters-radio{background-image:none !important}";export{o as salla_filters}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as a,h as t,H as s,a as e}from"./p-
|
|
4
|
+
import{r as a,h as t,H as s,a as e}from"./p-BJrHu3Q4.js";const i=class{constructor(t){if(a(this,t),this.entity="product",this.specs=[],this.download=salla.lang.get("pages.thank_you.download"),this.entityId)try{return void(this.entityId=Array.isArray(this.entityId)?this.entityId:JSON.parse(this.entityId))}catch(a){salla.log("Bad json passed via entityId prop")}}getValue(a){if("file"===a.type)return`<a href="${a.value}" class="text-primary" target="_blank"><span class="sicon-download"></span> ${this.download}</a>`;if("url"===a.type)return`<a href="${a.value}" class="text-blue-700 underline" target="_blank">${a.value}</a>`;if("date"===a.type){const t=new Date(a.value);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}return a.value}async componentWillLoad(){if(await salla.onReady(),!salla.config.get("store.features")?.includes("custom-fields"))return salla.logger.error("feature custom-fields is not activated");if(this.entityId||!salla.url.is_page("product.single")&&!salla.url.is_page("product.showNewUrls")||(this.entityId=salla.config.get("page.id")),!this.entityId)return salla.logger.error("can't render salla-metadata without enity-id prop!");await salla.lang.onLoaded(),this.download=salla.lang.get("pages.thank_you.download");const a=await Salla.api.metadata.fetchValues(this.entity,this.entityId);this.specs=a.data[0]?.sections}render(){if(this.specs.length)return t(s,{class:"s-metadata-wrapper"},this.specs.map((a=>t("div",{class:"s-metadata-box"},t("div",{class:"s-metadata-box-header"},t("i",{class:"sicon-list"}),a.name),a.fields.map((a=>t("div",{class:"s-metadata-row"},t("p",{class:"s-metadata-row-name"},a.name),t("p",{class:"s-metadata-row-value",innerHTML:this.getValue(a)}))))))))}get host(){return e(this)}};i.style="";export{i as salla_metadata}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,h as i,H as e}from"./p-
|
|
4
|
+
import{r as t,h as i,H as e}from"./p-BJrHu3Q4.js";var s,a;!function(t){t.PERCENTAGE="percentage",t.FIXED="fixed",t.FREE_PRODUCT="free_product"}(s||(s={})),function(t){t.PRODUCT_COUNT="products_count",t.PRODUCT_PURCHASE="order_amount"}(a||(a={}));const l=class{constructor(i){t(this,i),this.offer=null,this.products={},this.isLoading=!1,this.canRender=!0}componentWillLoad(){salla.onReady().then((()=>{if(!salla.config.get("store.features")?.includes("conditional-offer")||""!==salla.storage.get("cart")&&!salla.storage.get("cart")?.summary?.count)throw new Error("feature or cart object does not existed")})).then((()=>salla.api.cart.offers())).then((({data:t})=>{if(this.offer=t.find((t=>"conditional"===t.type)),this.offer)return this.isLoading=!0,this.offer.details.discounts.unshift({value:0,min_spend:0}),this.updateInitialOfferValue();this.canRender=!1})).then((()=>{if(this.offer)return this.getProducts()})).then((()=>{this.offer&&salla.event.on("cart::updated",(t=>this.updateOfferValues(t)))})).catch((t=>{this.canRender=!1,salla.logger.warn("salla-conditional-offer:: ",t)})).finally((()=>{this.isLoading=!1}))}getProducts(){const t=this.offer.details.discounts.filter((({type:t})=>t===s.FREE_PRODUCT)).map((({value:t})=>t)).filter(Boolean);if(t.length>0)return salla.product.fetch({source:"selected",source_value:t}).then((t=>{const i=t?.data;if(i&&Array.isArray(i)){const t={...this.products};i.forEach((({id:i,url:e,image:s,name:a,price:l})=>{i&&a&&s?.url&&e&&void 0!==l&&(t[i]={url:e,image:s,name:a,price:l})})),this.products=t}}))}updateInitialOfferValue(){return salla.api.cart.details().then((({data:{cart:t}})=>this.updateOfferValues(t)))}updateOfferValues({items:t,sub_total:i}){const e=this.offer.details.based_on===a.PRODUCT_COUNT?t?.reduce(((t,{quantity:i})=>t+i),0)??0:i;return this.offer={...this.offer,details:{...this.offer?.details,current_value:e}},this.offer}renderTooltip(t){const e=t.value,s=this.products[e];return s?i("salla-tooltip",{class:"absolute left-0 -top-2",targetId:`avatar-product-${e}`,theme:"dark"},i("div",{class:"flex gap-3 text-start"},s?.image?.url&&i("img",{src:s.image.url,alt:s?.image?.alt||s.name||"",class:"w-12 h-12 object-cover rounded-lg flex-shrink-0",loading:"lazy",decoding:"async"}),i("div",{class:"flex-1"},i("div",{class:"leading-tight mb-1"},s.name),i("div",{class:"text-xs text-gray-300",innerHTML:salla.money(s.price)})))):(salla.logger.error(`salla-conditional-offer:: there is no product with id (${t.value})!`),null)}getCheckpointContent(t){if(t.type===s.PERCENTAGE)return`${t.value}%`;if(t.type===s.FIXED)return i("span",{innerHTML:salla.money(t.value)});if(t.type!==s.FREE_PRODUCT)return salla.logger.error(`salla-conditional-offer:: unexpected type (${t.type})!`),"";const e=this.products[t.value];return e?i("a",{class:"s-conditional-offer-product-link",href:e.url},i("img",{class:"s-conditional-offer-checkpoint-image-content",loading:"lazy",decoding:"async",alt:e?.image?.alt||"",src:e?.image?.url})):(salla.logger.error(`salla-conditional-offer:: there is no product with id (${t.value})!`),"")}getOfferType(t){const i=this.offer.details?.based_on;if(i===a.PRODUCT_COUNT)try{return salla.lang.choice("blocks.header.products_count",t.min_spend)}catch(i){return salla.logger.warn("salla-conditional-offer:: invalid products_count interval",i),`${t.min_spend}`}return i===a.PRODUCT_PURCHASE?salla.money(t.min_spend):(salla.logger.warn(`salla-conditional-offer:: Unexpected offer detail's based_on value: ${i}`),`${t.min_spend}`)}clamp(t,i,e){return Math.max(i,Math.min(t,e))}mapValueRanges(t,i,e,s,a){const l=(t-i)*(a-s)/(e-i)+s;return l===Number.POSITIVE_INFINITY?100:l===Number.NEGATIVE_INFINITY?0:this.clamp(l,0,100)}getCheckPointView(t,e){const a=this.offer.details.discounts.findIndex((({min_spend:i})=>i===t.min_spend)),l=this.mapValueRanges(this.offer.details.current_value,this.offer.details.discounts[a-1]?.min_spend??0,t.min_spend,0,100),n=t.min_spend<=this.offer.details.current_value;return i("div",{class:"s-conditional-offer-checkpoint-container"},e>0?[i("div",{key:"progress-line",class:"s-conditional-offer-progress-line-container"},i("div",{class:"s-conditional-offer-progress-line-inactive"}),i("div",{class:"s-conditional-offer-progress-line-active",style:{width:`${l}%`}})),i("div",{key:"checkpoint",class:"s-conditional-offer-checkpoint "+(n?"s-conditional-offer-active-checkpoint":"")},i("div",{class:"s-conditional-offer-item-avatar-content "+(n?"active":""),id:t.type===s.FREE_PRODUCT?`avatar-product-${t.value}`:`avatar-${t.value??e}`},this.products&&this.getCheckpointContent(t)),this.products&&t.type===s.FREE_PRODUCT&&this.renderTooltip(t),i("div",{class:"s-conditional-offer-checkpoint-label "+(n?"active":""),innerHTML:this.getOfferType(t)}))]:i("div",{key:"label",class:{"s-conditional-offer-checkpoint-label":!0,"first-checkpoint":0===e,active:n,hidden:0===e,"sm:block":0===e},innerHTML:this.getOfferType(t)}))}getLoadingSkeletonView(){return i(e,{class:"s-conditional-offer-container"},i("div",{class:"s-conditional-offer-skeleton-inner-container"},i("div",{class:"s-conditional-offer-skeleton-subtitle"},i("salla-skeleton",{height:"16px",width:"30%"})),i("div",{class:"s-conditional-offer-skeleton-subtitle"},i("salla-skeleton",{height:"16px",width:"35%"})),i("div",{class:"s-conditional-offer-skeleton-checkpoints-wrapper"},Array(3).fill(null).map((()=>[i("salla-skeleton",{key:"checkpoint-line",height:"8px"}),i("div",{key:"checkpoint"},i("salla-skeleton",{height:"60px",width:"60px",type:"circle"}))])))))}render(){return this.canRender?this.isLoading?this.getLoadingSkeletonView():this.offer?i(e,{class:"s-conditional-offer-container"},i("div",{class:"s-conditional-offer-title-wrapper"},i("div",{class:"s-conditional-offer-title"},this.offer.title),this.offer.description?i("div",{class:"s-conditional-offer-subtitle"},this.offer.description," ",i("i",{class:"sicon-information"})):null),i("div",{class:"s-conditional-offer-progress-container"},this.offer.details.discounts.map(((t,e)=>i("div",{class:{"flex-1":e>0},key:t.min_spend},this.getCheckPointView(t,e)))))):null:null}};l.style=":host{display:block}";export{l as salla_conditional_offer}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as i,h as c}from"./p-
|
|
4
|
+
import{r as i,h as c}from"./p-BJrHu3Q4.js";const t=class{constructor(c){i(this,c)}render(){return c("a",{key:"c134f5fc8901762ed8fa4a53aed5fd5ec62df689",href:this.notification.url,class:{"s-notifications-item":!0,"s-notifications-item-shadow":!0,"s-notifications-item-read":!this.notification.is_new}},c("span",{key:"78fbafd1dd2998dba7e3a1ad8b34cbeb9e962cf2",class:"s-notifications-item-icon"},c("i",{key:"61357a8087938b3ffae36387a6d8b79979704dba",class:{"s-notifications-item-icon sicon-bell-ring":!0,"s-notifications-item-icon-new":this.notification.is_new}})),c("div",{key:"67c85332e868f4dbb2099524e441d64211d1ba1f",class:"s-notifications-item-content"},c("div",{key:"c7f79cb902edd54f171b8e3c089aa0f6795ca2a2",class:"s-notifications-item-content-leading"},c("h4",{key:"078d34e4cc8093ded2dc3c948100337acfe0101e"},this.notification.title),c("p",{key:"30c20f5308761bcd4011052b2fc8c6f87698a8f9"},this.notification.sub_title)),c("span",{key:"db1f387f53c747bccb3836cf8622f9f67af3a654",class:"s-notifications-item-content-trailing"},c("i",{key:"2f662b2dbff1487831681586c15d17c1a2e68eaa",class:"sicon-time s-notifications-item-content-trailing-icon"}),c("span",{key:"119e37704dc78372f3340fc33df69e20b666a7c5"},this.notification.date))))}};t.style="";export{t as salla_notification_item}
|