@salla.sa/twilight-components 2.14.487 → 2.14.489
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-D8YNIT7U.js → filepond-C-1J1qrF.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-DSZGbtH3.js → filepond-plugin-file-poster-B8fUrKqJ.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-CDPCt-vD.js → filepond-plugin-file-validate-size-BJ4Bw3Ju.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-PPR9wk_f.js → filepond-plugin-file-validate-type-D_Smjf6h.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-CbzNxXz5.js → filepond-plugin-image-edit-BDZBDL-U.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-CHOCkxIA.js → filepond-plugin-image-exif-orientation-B68mU2op.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-DPzPSwHT.js → filepond-plugin-image-preview-B2RzZ9r9.js} +1 -1
- package/dist/cjs/{functions-BJ567SZR.js → functions-DdZX56J7.js} +1 -1
- package/dist/cjs/{index-AuVRM2C2.js → index-B5CW9Xve.js} +1 -1
- package/dist/cjs/{index-KEg0BIuu.js → index-DWea49r_.js} +6 -2
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-accordion_6.cjs.entry.js +3 -2
- 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_2.cjs.entry.js +21 -13
- package/dist/cjs/salla-cart-coupons.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-summary-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-cashback-banner.cjs.entry.js +1 -1
- package/dist/cjs/salla-comment-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-points-banner.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-points-history.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-program.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty-reward.cjs.entry.js +2 -2
- package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
- package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-map_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-menu.cjs.entry.js +1 -1
- package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-next-order-coupon.cjs.entry.js +1 -1
- package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-branch.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-cancel.cjs.entry.js +296 -0
- package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit-product-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-options-modal_3.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-embed.cjs.entry.js +1 -1
- package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
- package/dist/cjs/salla-products-list.cjs.entry.js +1 -1
- package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
- package/dist/cjs/salla-rating-modal.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 +5 -2
- 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/salla-wishlist-actions.cjs.entry.js +1 -1
- package/dist/cjs/{tracked-promise-DFl5fI3j.js → tracked-promise-DNxhV4_1.js} +1 -1
- package/dist/cjs/twilight.cjs.js +2 -2
- package/dist/cjs/{vanilla-picker-CUpM_-PS.js → vanilla-picker-ClijNDRd.js} +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/salla-breadcrumb/salla-breadcrumb.js +2 -1
- package/dist/collection/components/salla-bullet-delivery/salla-bullet-delivery.js +20 -12
- package/dist/collection/components/salla-order-cancel/interfaces.js +1 -0
- package/dist/collection/components/salla-order-cancel/salla-order-cancel.css +17 -0
- package/dist/collection/components/salla-order-cancel/salla-order-cancel.js +366 -0
- package/dist/collection/components/salla-user-menu/salla-user-menu.js +4 -1
- package/dist/components/index.js +2 -2
- package/dist/components/salla-breadcrumb.js +2 -1
- package/dist/components/salla-bullet-delivery.js +20 -12
- package/dist/components/salla-order-cancel.d.ts +11 -0
- package/dist/components/salla-order-cancel.js +347 -0
- package/dist/components/salla-user-menu.js +4 -1
- package/dist/esm/{filepond-plugin-file-poster-Bm-5APBo.js → filepond-plugin-file-poster-B9sxi6Yz.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-DkYobKMY.js → filepond-plugin-file-validate-size-HWpVatr_.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-BXKbNDGH.js → filepond-plugin-file-validate-type-SgpUhQB_.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-B64dqBYZ.js → filepond-plugin-image-edit-0F90Q6lM.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-BelOzBrj.js → filepond-plugin-image-exif-orientation-CXJDp_1v.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-X67Ek3oE.js → filepond-plugin-image-preview-APl1nt4k.js} +1 -1
- package/dist/esm/{filepond-BsLighF8.js → filepond-z2hEBvHC.js} +1 -1
- package/dist/esm/{functions-DobdGlrA.js → functions-BCdJLPcs.js} +1 -1
- package/dist/esm/{index-DBMDFsFH.js → index-DNWyGkAx.js} +6 -2
- package/dist/esm/{index-yDeCyY3S.js → index-DhwQVX77.js} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/salla-accordion-body_2.entry.js +1 -1
- package/dist/esm/salla-accordion_6.entry.js +3 -2
- 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_2.entry.js +21 -13
- package/dist/esm/salla-cart-coupons.entry.js +1 -1
- package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
- package/dist/esm/salla-cart-summary-card.entry.js +1 -1
- package/dist/esm/salla-cashback-banner.entry.js +1 -1
- package/dist/esm/salla-comment-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-points-banner.entry.js +1 -1
- package/dist/esm/salla-loyalty-points-history.entry.js +1 -1
- package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
- package/dist/esm/salla-loyalty-program.entry.js +3 -3
- package/dist/esm/salla-loyalty-reward.entry.js +2 -2
- package/dist/esm/salla-loyalty.entry.js +1 -1
- package/dist/esm/salla-maintenance-alert.entry.js +1 -1
- package/dist/esm/salla-map_2.entry.js +1 -1
- package/dist/esm/salla-menu.entry.js +1 -1
- package/dist/esm/salla-metadata.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-next-order-coupon.entry.js +1 -1
- package/dist/esm/salla-notification-item.entry.js +1 -1
- package/dist/esm/salla-notifications.entry.js +1 -1
- package/dist/esm/salla-offer-modal.entry.js +1 -1
- package/dist/esm/salla-offer.entry.js +1 -1
- package/dist/esm/salla-order-branch.entry.js +1 -1
- package/dist/esm/salla-order-cancel.entry.js +294 -0
- package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-order-details-options.entry.js +1 -1
- package/dist/esm/salla-order-details.entry.js +1 -1
- package/dist/esm/salla-order-edit-item.entry.js +1 -1
- package/dist/esm/salla-order-edit-product-card.entry.js +1 -1
- package/dist/esm/salla-order-edit.entry.js +1 -1
- package/dist/esm/salla-order-options-modal_3.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-embed.entry.js +1 -1
- package/dist/esm/salla-product-size-guide.entry.js +1 -1
- package/dist/esm/salla-products-list.entry.js +1 -1
- package/dist/esm/salla-quick-order.entry.js +1 -1
- package/dist/esm/salla-rating-modal.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 +5 -2
- 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/salla-wishlist-actions.entry.js +1 -1
- package/dist/esm/{tracked-promise-6uJz7V9Q.js → tracked-promise-CjtqaGP2.js} +1 -1
- package/dist/esm/twilight.js +3 -3
- package/dist/esm/{vanilla-picker-Bw2Vk5YA.js → vanilla-picker-DPMDb9SB.js} +1 -1
- package/dist/twilight/{p-519551ab.entry.js → p-02e2f661.entry.js} +1 -1
- package/dist/twilight/{p-ef06457d.entry.js → p-04a6cb8f.entry.js} +1 -1
- package/dist/twilight/p-06966ed6.entry.js +4 -0
- package/dist/twilight/{p-51fbf1bb.entry.js → p-082f3913.entry.js} +1 -1
- package/dist/twilight/{p-4a3ccff2.entry.js → p-08641aeb.entry.js} +1 -1
- package/dist/twilight/{p-c253f69c.entry.js → p-094dcf0c.entry.js} +1 -1
- package/dist/twilight/{p-000022be.entry.js → p-0a9af711.entry.js} +1 -1
- package/dist/twilight/{p-14e936b0.entry.js → p-0cd023d2.entry.js} +1 -1
- package/dist/twilight/{p-d3d2a114.entry.js → p-12ccff98.entry.js} +1 -1
- package/dist/twilight/{p-29620c50.entry.js → p-14f8ba23.entry.js} +1 -1
- package/dist/twilight/{p-57785b92.entry.js → p-160fc21e.entry.js} +1 -1
- package/dist/twilight/{p-24d268c7.entry.js → p-1a957d13.entry.js} +1 -1
- package/dist/twilight/{p-f856fe4d.entry.js → p-1aeeb0f0.entry.js} +1 -1
- package/dist/twilight/{p-c9608410.entry.js → p-1efc0eed.entry.js} +1 -1
- package/dist/twilight/{p-7bd7baa5.entry.js → p-24127075.entry.js} +1 -1
- package/dist/twilight/{p-fd99de6e.entry.js → p-26faf85e.entry.js} +1 -1
- package/dist/twilight/{p-fdb0f6cc.entry.js → p-338a55c1.entry.js} +1 -1
- package/dist/twilight/{p-ce0685d1.entry.js → p-39b8ffcd.entry.js} +1 -1
- package/dist/twilight/{p-4836c3eb.entry.js → p-3c10826c.entry.js} +1 -1
- package/dist/twilight/{p-7b0f537a.entry.js → p-3ce46edf.entry.js} +1 -1
- package/dist/twilight/{p-6e2b2072.entry.js → p-3e7a3c6e.entry.js} +1 -1
- package/dist/twilight/{p-0c219cad.entry.js → p-3f924fc5.entry.js} +2 -2
- package/dist/twilight/{p-b7da726a.entry.js → p-40407996.entry.js} +1 -1
- package/dist/twilight/{p-4f8ec3a6.entry.js → p-43a2f42e.entry.js} +1 -1
- package/dist/twilight/p-46cd5ece.entry.js +4 -0
- package/dist/twilight/{p-60545378.entry.js → p-47dd6817.entry.js} +1 -1
- package/dist/twilight/{p-5119fe5d.entry.js → p-4ab4e5ea.entry.js} +1 -1
- package/dist/twilight/{p-f5d229a7.entry.js → p-4b17c9a0.entry.js} +1 -1
- package/dist/twilight/{p-d01178f0.entry.js → p-5171b440.entry.js} +1 -1
- package/dist/twilight/{p-f267ac72.entry.js → p-52283d18.entry.js} +1 -1
- package/dist/twilight/{p-5e14fbf5.entry.js → p-56365c64.entry.js} +1 -1
- package/dist/twilight/p-5993b7d0.entry.js +4 -0
- package/dist/twilight/{p-18f264f9.entry.js → p-5b989746.entry.js} +1 -1
- package/dist/twilight/{p-C_vo3xPL.js → p-5wempgCB.js} +1 -1
- package/dist/twilight/{p-c46cf468.entry.js → p-602df9ed.entry.js} +1 -1
- package/dist/twilight/{p-ad1d3cdf.entry.js → p-61813e83.entry.js} +1 -1
- package/dist/twilight/{p-d8fb7f9a.entry.js → p-6494c6bf.entry.js} +1 -1
- package/dist/twilight/{p-3a7f5c6e.entry.js → p-6852162e.entry.js} +1 -1
- package/dist/twilight/{p-de41e9b5.entry.js → p-6891f00b.entry.js} +1 -1
- package/dist/twilight/{p-ddd22625.entry.js → p-69766916.entry.js} +1 -1
- package/dist/twilight/{p-ab404907.entry.js → p-6ab60f90.entry.js} +1 -1
- package/dist/twilight/{p-e84f7790.entry.js → p-6e7a6f4b.entry.js} +1 -1
- package/dist/twilight/{p-CDTIhPDr.js → p-6sBYUIya.js} +1 -1
- package/dist/twilight/{p-da827143.entry.js → p-78f161f2.entry.js} +1 -1
- package/dist/twilight/{p-67ce35b0.entry.js → p-7a0d2f4d.entry.js} +1 -1
- package/dist/twilight/{p-11f843fd.entry.js → p-7bbea228.entry.js} +1 -1
- package/dist/twilight/{p-acd8aa32.entry.js → p-7fb92e0b.entry.js} +1 -1
- package/dist/twilight/{p-b4f4e0b7.entry.js → p-844c6c1f.entry.js} +1 -1
- package/dist/twilight/{p-08dfa3c5.entry.js → p-85c6c44f.entry.js} +1 -1
- package/dist/twilight/{p-0412fe67.entry.js → p-85fc94be.entry.js} +1 -1
- package/dist/twilight/{p-00fcfe8e.entry.js → p-8fec15f8.entry.js} +1 -1
- package/dist/twilight/{p-1bb06699.entry.js → p-90534314.entry.js} +1 -1
- package/dist/twilight/{p-8336df51.entry.js → p-9273a620.entry.js} +1 -1
- package/dist/twilight/{p-546b31a3.entry.js → p-9474d525.entry.js} +1 -1
- package/dist/twilight/{p-46294bef.entry.js → p-991b1e85.entry.js} +1 -1
- package/dist/twilight/{p-39a49ae9.entry.js → p-9fc965a7.entry.js} +1 -1
- package/dist/twilight/{p-uiIu01tD.js → p-Bw7P5SwX.js} +1 -1
- package/dist/twilight/{p-Dwu1e7SR.js → p-BwggHXVj.js} +1 -1
- package/dist/twilight/{p-CcfoPQKG.js → p-C5HojqDY.js} +1 -1
- package/dist/twilight/{p-BR9zeoCF.js → p-C72A7Y44.js} +1 -1
- package/dist/twilight/{p-qj0-UBFk.js → p-Ca18LMTl.js} +1 -1
- package/dist/twilight/{p-BTYXaopE.js → p-CsSICzhL.js} +1 -1
- package/dist/twilight/{p-C_htBBK4.js → p-DJ3ziTwG.js} +1 -1
- package/dist/twilight/{p-DBMDFsFH.js → p-DNWyGkAx.js} +1 -1
- package/dist/twilight/{p-lQbFKmnv.js → p-DQUSqsnq.js} +1 -1
- package/dist/twilight/{p-CMW3pjiL.js → p-Dp4UckOj.js} +1 -1
- package/dist/twilight/{p-76672fe3.entry.js → p-a965c431.entry.js} +1 -1
- package/dist/twilight/{p-967d356e.entry.js → p-aaf7cbb1.entry.js} +1 -1
- package/dist/twilight/{p-fa900f26.entry.js → p-ab2a5243.entry.js} +1 -1
- package/dist/twilight/{p-49275f85.entry.js → p-ac7c0ea4.entry.js} +1 -1
- package/dist/twilight/{p-18efb27e.entry.js → p-afc451ef.entry.js} +1 -1
- package/dist/twilight/{p-79bff80a.entry.js → p-b0d5084c.entry.js} +1 -1
- package/dist/twilight/{p-52cab4a6.entry.js → p-b5d32897.entry.js} +1 -1
- package/dist/twilight/{p-130633cc.entry.js → p-b6cdfd09.entry.js} +1 -1
- package/dist/twilight/{p-cf1b9798.entry.js → p-c4c32432.entry.js} +1 -1
- package/dist/twilight/{p-ce1bc4b0.entry.js → p-c84ada78.entry.js} +1 -1
- package/dist/twilight/{p-6bdcd67d.entry.js → p-c9aa80c3.entry.js} +1 -1
- package/dist/twilight/{p-5dfb7601.entry.js → p-ca028945.entry.js} +1 -1
- package/dist/twilight/{p-f12670a1.entry.js → p-cbc66d20.entry.js} +1 -1
- package/dist/twilight/{p-636e6994.entry.js → p-cee1f87a.entry.js} +1 -1
- package/dist/twilight/{p-9ab52d09.entry.js → p-cfc209db.entry.js} +1 -1
- package/dist/twilight/{p-4336dce1.entry.js → p-d239611f.entry.js} +1 -1
- package/dist/twilight/{p-1e418b8f.entry.js → p-d3f3eed5.entry.js} +1 -1
- package/dist/twilight/{p-e21a23d2.entry.js → p-da66f939.entry.js} +1 -1
- package/dist/twilight/{p-3f153e79.entry.js → p-db9dc344.entry.js} +1 -1
- package/dist/twilight/{p-44f67d40.entry.js → p-de942889.entry.js} +1 -1
- package/dist/twilight/{p-8a7f48ce.entry.js → p-e2da0555.entry.js} +1 -1
- package/dist/twilight/{p-1b4fd0db.entry.js → p-e9cdcf2f.entry.js} +1 -1
- package/dist/twilight/{p-1547f282.entry.js → p-ed02b506.entry.js} +1 -1
- package/dist/twilight/{p-cc75ae11.entry.js → p-edc4193f.entry.js} +1 -1
- package/dist/twilight/{p-61332673.entry.js → p-ef2d94d3.entry.js} +1 -1
- package/dist/twilight/{p-b3b050e7.entry.js → p-f01c12dc.entry.js} +1 -1
- package/dist/twilight/{p-1450bf80.entry.js → p-f12a28f9.entry.js} +1 -1
- package/dist/twilight/{p-2f48e8e1.entry.js → p-f14fe365.entry.js} +1 -1
- package/dist/twilight/{p-a767d9fe.entry.js → p-f2dbde1c.entry.js} +1 -1
- package/dist/twilight/{p-b3b78bf5.entry.js → p-f2e9d83b.entry.js} +1 -1
- package/dist/twilight/{p-b835777d.entry.js → p-f6205375.entry.js} +1 -1
- package/dist/twilight/{p-ffd6ad27.entry.js → p-f6d6dada.entry.js} +1 -1
- package/dist/twilight/p-f8933bd5.entry.js +4 -0
- package/dist/twilight/{p-96779a0c.entry.js → p-f9192741.entry.js} +1 -1
- package/dist/twilight/{p-7a5894fb.entry.js → p-fa5fa155.entry.js} +1 -1
- package/dist/twilight/{p-37ced7ab.entry.js → p-fc676125.entry.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-order-cancel/interfaces.d.ts +20 -0
- package/dist/types/components/salla-order-cancel/salla-order-cancel.d.ts +42 -0
- package/dist/types/components/salla-user-menu/salla-user-menu.d.ts +1 -0
- package/dist/types/components.d.ts +31 -0
- package/package.json +5 -5
- package/dist/twilight/p-b3f26711.entry.js +0 -4
- package/dist/twilight/p-cf96947a.entry.js +0 -4
- package/dist/twilight/p-e5022e8f.entry.js +0 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,c as e,h as i,H as s,a as o}from"./p-
|
|
4
|
+
import{r as t,c as e,h as i,H as s,a as o}from"./p-DNWyGkAx.js";import{L as n}from"./p-BO5AoBAP.js";import{S as a}from"./p-BscTeWDc.js";const r="BulletDeliveryAPI",l=t=>{const e=null==t?Number.NaN:Number(t);return!Number.isNaN(e)&&0!==e};async function h(t,e,i){try{return await t()}catch(t){return console.error(`${r}: ${i}`,t),e}}const c=new Map;function d(t){const e=c.get(t);return!e||Date.now()-e.timestamp>3e5?(c.delete(t),null):e.data}function u(t,e){c.set(t,{data:e,timestamp:Date.now()})}const p=t=>"SA"===String(t).toUpperCase(),m={async getCountries(t=!1,e){const i=e?.trim()?null:"countries_"+(t?1:0);if(i){const t=d(i);if(t)return t}const s=await h((async()=>{const i={for_branch:t?1:0};return t&&(i.for_allocation=1),e?.trim()&&(i.query=e.trim()),((await salla.api.request("shipping/countries",{params:i}))?.data??[]).map((t=>({id:t.id,code:t.code,name:t.name,has_regions:p(t.code)})))}),[],"Error getting countries");return i&&s.length>0&&u(i,s),s},async getRegions(t,e){if(!l(t))return console.warn(`${r}: getRegions called without valid country_id`),[];const i=e?.trim()?null:`regions_${t}`;if(i){const t=d(i);if(t)return t}const s=await h((async()=>{const i={};return e?.trim()&&(i.query=e.trim()),((await salla.api.request(`shipping/countries/${t}/regions`,{params:i}))?.data??[]).map((e=>({id:e.id,name:e.name,code:e.code,country_id:Number(t)})))}),[],"Error fetching regions");return i&&s.length>0&&u(i,s),s},async getCities(t,e,i){if(!l(t))return console.warn(`${r}: getCities called without valid country_id`),[];const s=i?.trim()?null:`cities_${t}_${e||"all"}`;if(s){const t=d(s);if(t)return t}const o=await h((async()=>{const s={for_branch:0,country_id:t};return e&&(s.region_id=e),i?.trim()&&(s.query=i.trim()),((await salla.api.request("shipping/cities",{params:s}))?.data??[]).map((e=>({id:e.id,name:e.name,country_id:t,...null!=e.region_id&&{region_id:e.region_id}})))}),[],"Error fetching cities");return s&&o.length>0&&u(s,o),o},getDistricts:async(t,e)=>l(t)?h((async()=>{const i={for_branch:0,city_id:t};e?.trim()&&(i.query=e.trim());const s=(await salla.api.request("shipping/districts",{params:i}))?.data;return(Array.isArray(s)?s:Array.isArray(s?.districts)?s.districts:[]).map((e=>({id:e.id,name:e.name,name_en:e.name_en,city_id:t})))}),[],"Error fetching districts"):(console.warn(`${r}: getDistricts called without valid city_id`),[]),getSavedAddresses:async()=>h((async()=>{const t=(await salla.api.request("address"))?.data;return Array.isArray(t)?t:[]}),[],"Error fetching user addresses"),async getBranches({query:t,lat:e,lng:i,country_id:s,per_page:o=20}={}){const n=t?.trim()?.length>=2||e||i||!s?null:`branches_${s}`;if(n){const t=d(n);if(t)return t}const a=await h((async()=>{const n={per_page:o};t?.trim().length>=2&&(n.query=t),e&&(n.lat=e),i&&(n.lng=i),s&&(n.country_id=s);const a=await salla.api.request("branches",{params:n});return Array.isArray(a?.data)?a.data:[]}),[],"Error fetching branches");return n&&a.length>0&&u(n,a),a},saveAddressLocation:async t=>h((async()=>{const e=await salla.api.request("address/location",{...t,for_allocation:!0},"post"),i=e?.data??e;return{success:!0,address:"object"==typeof i&&null!=i&&"id"in i?i:void 0}}),{success:!1},"Error saving address/location"),setDeliveryScope:async t=>h((async()=>(await salla.api.withoutNotifier((()=>salla.scope.change({id:t}))),salla.storage.set("scope",{...salla.storage.get("scope")||{},id:t}),!0)),!1,"Error setting delivery scope"),async allocateScope(t){const e=t=>t?.error?.message??t?.message??"Failed to allocate scope";try{const e=await salla.api.withoutNotifier((()=>salla.api.request("scopes/allocation",t,"post")));return{success:!0,data:e?.data??e}}catch(t){console.error(`${r}: Error allocating scope`,t);const i=t;return{success:!1,error:null!=i?.response?.data?e(i.response.data):i?.message??"Unknown error"}}},getAddressToken:async()=>h((async()=>{const t=await salla.api.request("address/autocomplete-token");return t?.data?.token??null}),null,"Error fetching address autocomplete token")};function g(){c.clear()}const b=t=>t*(Math.PI/180);function f(t,e,i,s){const o=b(i-t),n=b(s-e),a=Math.sin(o/2)**2+Math.cos(b(t))*Math.cos(b(i))*Math.sin(n/2)**2;return 12742*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}function v(t,e){const[i,s]=String(t).trim().split(":").map(Number);return Number.isNaN(i)||Number.isNaN(s)?t:new Date(2e3,0,1,i,s).toLocaleTimeString(e,{hour:"numeric",minute:"2-digit",hour12:!0})}const y=(t,e,i)=>{if("branch"===t.type){const e=t.branch_details?.city??t.branch_details?.name;return e?`${i} ${e}`.trim():""}if("address"===t.type&&t.address_details){const i=[t.address_details.district?.name,t.address_details.city?.name,t.address_details.country?.name].filter(Boolean).join("، ")||t.address_details.short_address||"";return i?`${e} ${i}`.trim():""}return""},w=t=>null!=t?Number(t):void 0,S=t=>w(t?.address_details?.country?.id),k=t=>t?.country_code??t?.address_details?.country?.code??"",C=t=>w(t?.address_details?.region?.id),x=t=>w(t?.address_details?.city?.id),_=t=>w(t?.address_details?.district?.id),A=t=>t?.branch_details?.id,$=t=>t?.branch_details?.latitude,M=t=>t?.branch_details?.longitude,L=t=>{if(!t||"address"!==t.type||t.address_id)return!1;const e=S(t),i=x(t),s=_(t),o=k(t),n=null!=s&&0!==Number(s),a=Boolean(t.address_details?.district?.name?.trim()),r=!p(o)||n||a;return!!(e&&i&&r)},E=(t,e,i)=>!t||!p(t)||null!=e&&0!==Number(e)&&null!=i&&("number"==typeof i?0!==i:String(i).trim().length>0),z={[GeolocationPositionError.PERMISSION_DENIED]:"Location permission denied",[GeolocationPositionError.POSITION_UNAVAILABLE]:"Location unavailable",[GeolocationPositionError.TIMEOUT]:"Location timeout"},I=globalThis,P=I.ShadowRoot&&(void 0===I.ShadyCSS||I.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,T=Symbol(),B=new WeakMap;let N=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==T)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(P&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=B.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&B.set(e,t))}return t}toString(){return this.cssText}};const D=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,s)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[s+1]),t[0]);return new N(i,t,T)},O=P?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new N("string"==typeof t?t:t+"",void 0,T))(e)})(t):t
|
|
5
5
|
/**
|
|
6
6
|
* @license
|
|
7
7
|
* Copyright 2017 Google LLC
|
|
@@ -1016,4 +1016,4 @@ const X=globalThis,tt=X.trustedTypes,et=tt?tt.createPolicy("lit-html",{createHTM
|
|
|
1016
1016
|
width: 100%;
|
|
1017
1017
|
height: 100%;
|
|
1018
1018
|
}
|
|
1019
|
-
`,Ss([zi({type:Object})],ks.prototype,"position",2),Ss([zi({type:String})],ks.prototype,"pano",2),Ss([zi({type:Number})],ks.prototype,"zoom",2),Ss([zi({type:Object})],ks.prototype,"pov",2),Ss([zi({type:Boolean})],ks.prototype,"visible",2),Ss([zi({type:Boolean})],ks.prototype,"motionTracking",2),Ss([zi({type:Object})],ks.prototype,"options",2),Ss([Pi(".panorama")],ks.prototype,"panoramaElement",2),Ss([Ii()],ks.prototype,"panorama",2),ks=Ss([li("gmap-street-view-panorama")],ks);var Cs='<svg width="15" height="14" viewBox="0 0 15 14" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path\n d="M1.14453 5.83032L1.14453 9.16486C1.14453 11.0511 1.14453 11.9943 1.73032 12.5803C2.3161 13.1663 3.25891 13.1663 5.14453 13.1663L9.14453 13.1663C11.0301 13.1663 11.9729 13.1663 12.5587 12.5803C13.1445 11.9943 13.1445 11.0511 13.1445 9.16486V5.83032"\n stroke="currentcolor" stroke-linecap="round" />\n <path\n d="M9.14453 10.1619C8.68846 10.5667 7.9624 10.8285 7.14453 10.8285C6.32666 10.8285 5.60059 10.5667 5.14453 10.1619"\n stroke="currentcolor" stroke-linecap="round" />\n <path\n d="M5.90256 4.44533C5.71455 5.12426 5.03086 6.29542 3.73185 6.46516C2.58488 6.61502 1.71497 6.11437 1.49277 5.90504C1.24779 5.7353 0.689441 5.19216 0.552703 4.85269C0.415966 4.51322 0.575492 3.77771 0.689441 3.47785L1.14495 2.15892C1.25615 1.82765 1.51646 1.04411 1.78334 0.779094C2.05022 0.514073 2.59054 0.502543 2.81294 0.502543L7.48329 0.502543C8.68543 0.519525 11.3139 0.491824 11.8335 0.502545C12.3532 0.513266 12.6654 0.948828 12.7565 1.13553C13.5318 3.01341 13.8333 4.08889 13.8333 4.54717C13.7321 5.03605 13.3133 5.95787 11.8335 6.36332C10.2956 6.7847 9.42363 5.96509 9.15007 5.65043M5.27015 5.65044C5.48665 5.91635 6.16578 6.45158 7.15029 6.46516C8.1348 6.47873 8.98485 5.79188 9.28681 5.44676C9.37227 5.34492 9.55687 5.04279 9.7483 4.44533"\n stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" />\n</svg>\n ';const xs={lat:24.7756042,lng:46.7360729},_s="salla-bullet-delivery-override-ip";function As(t,e){localStorage.getItem("salla-bullet-delivery-debug")&&(void 0!==e?console.log(t,e):console.log(t))}const $s=class{constructor(i){t(this,i),this.bulletDeliveryConfirmed=e(this,"bulletDeliveryConfirmed"),this.bulletDeliveryClosed=e(this,"bulletDeliveryClosed"),this.addressCreated=e(this,"addressCreated"),this.headerContextUpdate=e(this,"headerContextUpdate"),this.confirming=!1,this.pendingCartSubmitResolver=null,this.pendingCartSubmitPromise=null,this.cartSubmitConfirmationPending=!1,this.branchSearchDebounceTimer=null,this.countrySearchTimer=null,this.regionSearchTimer=null,this.citySearchTimer=null,this.districtSearchTimer=null,this.citySearchCounter=0,this.componentReady=!1,this.pendingOpen=!1,this.tabChanging=!1,this.intentStorageKey="bullet_delivery_intent",this.sessionShownKey="bullet_delivery_shown",this.incompleteIntentPromptKey="bullet_delivery_incomplete_intent_prompted",this.cartItemAddedEvent="cart::item.added",this.cartItemAddedHandler=null,this.cartSubmittingHandler=null,this.useCartEventApi=!1,this.authLoggedInHandler=null,this.authLoggedOutHandler=null,this.loginClosedHandler=null,this.hasExplicitPreselectedIdsForOpen=!1,this.bulletDeliveryOpenHandler=t=>{this.preselectedAddressId=t?.preselected_address_id,this.preselectedBranchId=t?.preselected_branch_id,this.hasExplicitPreselectedIdsForOpen=null!=t?.preselected_address_id||null!=t?.preselected_branch_id,this.open()},this.closeHandler=null,this.bulletDeliveryMobileSelectHandler=null,this.savedAddressesLoaded=!1,this.gmapRef=null,this.autoGeolocationTriggered=!1,this.activeTab="address",this.isLoggedIn=!1,this.viewMode="main",this.countries=[],this.regions=[],this.cities=[],this.districts=[],this.loadingRegions=!1,this.selectedCountry=null,this.selectedRegion=null,this.selectedCity=null,this.selectedDistrict=null,this.districtName="",this.savedAddresses=[],this.selectedSavedAddress=null,this.selectedSessionAddress=!1,this.branches=[],this.filteredBranches=[],this.selectedBranch=null,this.branchSearchQuery="",this.loadingCountries=!1,this.loadingCities=!1,this.loadingDistricts=!1,this.loadingBranches=!1,this.loadingNearestBranch=!1,this.locationError="",this.savingAddress=!1,this.loadingSavedAddresses=!1,this.showCartWillBeClearedBanner=!1,this.countrySearchQuery="",this.regionSearchQuery="",this.citySearchQuery="",this.districtSearchQuery="",this.searchingCountries=!1,this.searchingRegions=!1,this.searchingCities=!1,this.searchingDistricts=!1,this.displayedCountries=[],this.displayedRegions=[],this.displayedCities=[],this.displayedDistricts=[],this.allocationOutOfCoverageMessage=null,this.mapLocationData=null,this.addressToken=null,this.loadingToken=!1,this.mapReady=!1,this.mapStep="map",this.addressDescription="",this.newAddressForm={...$s.INITIAL_ADDRESS_FORM},this.handleCountrySearch=t=>{this.countrySearchQuery=t},this.handleRegionSearch=t=>{this.regionSearchQuery=t},this.handleCitySearch=t=>{if(this.citySearchQuery=t,this.citySearchTimer&&clearTimeout(this.citySearchTimer),!t.trim())return this.displayedCities=this.cities,void(this.searchingCities=!1);if(t.trim().length<$s.DROPDOWN_SEARCH_MIN_CHARS)return;const e=++this.citySearchCounter;this.citySearchTimer=setTimeout((async()=>{this.searchingCities=!0;try{const i=p(this.selectedCountry?.code??"")?this.selectedRegion?.id:void 0,s=await m.getCities(this.selectedCountry?.id,i,t);e===this.citySearchCounter&&(this.displayedCities=s)}catch{e===this.citySearchCounter&&(this.displayedCities=this.cities)}finally{e===this.citySearchCounter&&(this.searchingCities=!1)}}),$s.DROPDOWN_SEARCH_DEBOUNCE_MS)},this.handleDistrictSearch=t=>{this.districtSearchQuery=t},this.handleCountryDropdownClosed=()=>{this.countrySearchQuery="",this.displayedCountries=this.countries,this.searchingCountries=!1},this.handleRegionDropdownClosed=()=>{this.regionSearchQuery="",this.displayedRegions=this.regions,this.searchingRegions=!1},this.handleCityDropdownClosed=()=>{this.citySearchQuery="",this.citySearchTimer&&(clearTimeout(this.citySearchTimer),this.citySearchTimer=null),++this.citySearchCounter,this.displayedCities=this.cities,this.searchingCities=!1},this.handleDistrictDropdownClosed=()=>{this.districtSearchQuery="",this.displayedDistricts=this.districts,this.searchingDistricts=!1},this.handleMapLocationChanged=t=>{const e=t.detail;e?.position?.lat&&e?.position?.lng&&(this.mapLocationData={lat:e.position.lat,lng:e.position.lng,shortAddress:e.place?.placeId??e.place?.place_id??void 0,formattedAddress:e.place?.formattedAddress??e.place?.formatted_address??void 0},this.updateLocationBias(),setTimeout((()=>{const t=this.gmapRef?.locationMarker;t&&(t.gmpDraggable=!1)}),100))},this.handleMapReady=()=>{if(this.mapReady=!0,this.gmapRef&&"function"==typeof this.gmapRef.resize&&this.gmapRef.resize(),this.updateLocationBias(),!this.autoGeolocationTriggered&&!this.hasMapLocation()&&this.gmapRef){const t=this.gmapRef.getCurrentLocation;if("function"==typeof t){this.autoGeolocationTriggered=!0;try{const e=t.call(this.gmapRef,!0);e&&"function"==typeof e.catch&&e.catch((t=>As("Auto geolocation failed",t)))}catch(t){As("Auto geolocation threw",t)}}}},this.handleSubmitAddAddress=async t=>{if(t.preventDefault(),this.savingAddress)return;const e=this.hasMapLocation();if((e||this.selectedCountry&&this.selectedCity)&&(e||E(this.selectedCountry?.code,this.selectedRegion?.id,this.selectedDistrict?.id??(this.districtName?.trim()||null)))){this.savingAddress=!0;try{const t=this.buildAddressLocationPayload(),{success:e,address:i}=await m.saveAddressLocation(t);if(e){await this.loadSavedAddresses();const t=i??this.savedAddresses[0]??null;t?.is_in_coverage&&(this.selectedSessionAddress=!1,this.selectedSavedAddress=t),this.addressCreated.emit({address:t}),this.viewMode="main",this.districtName="",this.mapLocationData=null,this.mapStep="map",this.addressDescription=""}else this.isLoggedIn?Salla.notify?.error(Salla.lang.get("common.errors.error_occurred")):(Salla.notify?.error(Salla.lang.get("pages.checkout.login_to_use_saved_addresses")),this.handleLogin())}catch(t){console.error("SallaBulletDelivery: Error saving address",t),this.isLoggedIn?Salla.notify?.error(Salla.lang.get("common.errors.error_occurred")):(Salla.notify?.error(Salla.lang.get("pages.checkout.login_to_use_saved_addresses")),this.handleLogin())}finally{this.savingAddress=!1}}},this.handleCountrySelected=t=>{const e=this.countries.find((e=>String(e.id)===String(t.id)))||t;this.countrySearchQuery="",this.displayedCountries=this.countries,this.applyCountryChange(e||null)},this.handleRegionSelected=t=>{const e=this.regions.find((e=>String(e.id)===String(t.id)))||t;this.selectedRegion=e||null,this.regionSearchQuery="",this.displayedRegions=this.regions,this.updateNewAddressForm({region_id:e?.id,city_id:void 0,district_id:void 0,city:void 0,district:void 0}),e&&this.selectedCountry&&this.loadCities(this.selectedCountry.id,e.id)},this.handleCitySelected=t=>{const e=p(this.selectedCountry?.code??""),i=this.cities.find((e=>String(e.id)===String(t.id)))||t;this.selectedCity=i||null,this.selectedDistrict=null,this.districtName="",this.citySearchQuery="",this.displayedCities=this.cities,i&&(this.updateNewAddressForm({city:i,district:void 0}),e&&this.loadDistricts(i.id))},this.handleDistrictSelected=t=>{const e=this.districts.find((e=>String(e.id)===String(t.id)))||t;this.selectedDistrict=e||null,this.districtName="",this.districtSearchQuery="",this.displayedDistricts=this.districts,e&&this.updateNewAddressForm({district:e})}}get supportsPickup(){return Boolean(Salla.config.get("store.shipping.support_pickup"))||Boolean(Salla.config.get("store.support_pickup"))}get openingType(){return Salla.config.get("store.settings.bullet_delivery.settings.type")}get isRequired(){return!!Salla.config.get("store.settings.bullet_delivery.settings.is_required")}get isSupportsDelivery(){return!!Salla.config.get("store.settings.bullet_delivery.supports_delivery")}get isMobileApp(){return Salla.config.isMobileApp()}async open(){if(this.isMobileApp)Salla.event.dispatch("salla::bullet-delivery.open-sheet");else if(this.componentReady&&this.modal){this.resetState(),this.modal.open(),Salla.event.dispatch("salla::bullet-delivery.modal.opened");try{this.isLoggedIn=!this.isGuestUser();const t=this.cleanStaleGuestAddressIdIfNeeded(this.getStoredIntent());this.applyPreselectedIdsFromIntent(t);const e=!this.isLoggedIn&&"address"===t?.type&&null!=S(t)&&null!=x(t);if(this.activeTab=this.supportsPickup&&t?.type&&("address"===t.type||"branch"===t.type)?t.type:"address",this.fetchAddressToken(),this.isLoggedIn&&"address"===this.activeTab&&(this.loadingSavedAddresses=!0),await Promise.all([this.loadCountries(e),this.isLoggedIn&&"address"===this.activeTab?this.loadSavedAddresses().then((()=>{this.savedAddressesLoaded=!0})).finally((()=>{this.loadingSavedAddresses=!1})):Promise.resolve()]),this.isLoggedIn&&this.preselectedAddressId){const t=this.savedAddresses.find((t=>t.id===this.preselectedAddressId));t&&(this.selectedSessionAddress=!1,this.selectedSavedAddress=t)}if("branch"===this.activeTab){const e=$(t),i=M(t);if(null!=e&&null!=i?await this.loadBranchesWithLocation(e,i):await this.loadBranches(),this.preselectedBranchId){const t=this.branches.find((t=>t.id===this.preselectedBranchId));t&&(this.selectedBranch=t)}}await this.prefillFromSessionStorage()}catch(t){console.error("SallaBulletDelivery: Error loading data",t)}finally{this.overrideScopeSwitchUI()}}else this.pendingOpen=!0}async close(){if(!this.shouldForceNonClosable()||this.confirming)return this.cartSubmitConfirmationPending&&!this.confirming&&this.resolvePendingCartSubmit(),this.bulletDeliveryClosed.emit(),this.modal?.close()}resetState(){this.viewMode="main",this.autoGeolocationTriggered=!1,this.selectedCountry=null,this.selectedRegion=null,this.selectedCity=null,this.selectedDistrict=null,this.districtName="",this.selectedSavedAddress=null,this.selectedSessionAddress=!1,this.selectedBranch=null,this.branchSearchQuery="",this.regions=[],this.cities=[],this.districts=[],this.branches=[],this.filteredBranches=[],this.newAddressForm={...$s.INITIAL_ADDRESS_FORM},this.showCartWillBeClearedBanner=!1,this.allocationOutOfCoverageMessage=null,this.locationError="",this.savedAddressesLoaded=!1,this.loadingSavedAddresses=!1,this.loadingCountries=!1,this.resetSearchState()}getIntentStorage(){const t=Boolean(Salla.config.get("store.settings.bullet_delivery.settings.remember_last_session"));return Salla.storage[t?"store":"session"]}getShownStorage(){return Salla.storage.session}getStoredIntent(){return this.getIntentStorage().get(this.intentStorageKey)}isGuestUser(){return"guest"===String(Salla.config.get("user.type")??"guest")}cleanStaleGuestAddressIdIfNeeded(t){if(!this.isGuestUser()||"address"!==t?.type||!t.address_id)return t;const e={...t,address_id:void 0};return this.setStoredIntent(e),e}applyPreselectedIdsFromIntent(t){this.hasExplicitPreselectedIdsForOpen?this.hasExplicitPreselectedIdsForOpen=!1:(this.preselectedAddressId=void 0,this.preselectedBranchId=void 0,this.isGuestUser()?"branch"===t?.type&&t.branch_id&&(this.preselectedBranchId=t.branch_id):"address"===t?.type&&t.address_id?this.preselectedAddressId=t.address_id:"branch"===t?.type&&t.branch_id&&(this.preselectedBranchId=t.branch_id))}hasIncompleteUserAddressIntent(){if(this.isGuestUser())return!1;const t=this.getStoredIntent();return!(!t||"address"!==t.type||t.address_id||!t.address_details)&&L(t)}isIntentMethodSupported(t){return"branch"===t.type?this.supportsPickup:"address"===t.type&&this.isSupportsDelivery}hasCompleteIntentForLoggedInUser(){if(this.isGuestUser())return!1;const t=this.getStoredIntent();return!!(t&&this.isIntentMethodSupported(t)&&("address"===t.type?t.address_id:"branch"===t.type&&t.branch_id))}shouldForceNonClosable(){return!this.isGuestUser()&&!!Salla.url.is_page("cart")&&!this.hasCompleteIntentForLoggedInUser()}shouldPromptIncompleteIntentThisSession(){const t=this.getShownStorage();return this.hasIncompleteUserAddressIntent()&&!0!==t.get(this.incompleteIntentPromptKey)}markIncompleteIntentPrompted(){this.getShownStorage().set(this.incompleteIntentPromptKey,!0)}setStoredIntent(t){this.getIntentStorage().set(this.intentStorageKey,t),this.overrideScopeSwitchUI()}clearBulletDeliveryStoredData(){Salla.storage.session.remove(this.intentStorageKey),Salla.storage.store.remove(this.intentStorageKey),Salla.storage.session.remove(this.sessionShownKey),Salla.storage.session.remove(this.incompleteIntentPromptKey),this.overrideScopeSwitchUI()}async prefillAddressFromStoredIntent(){const t=this.getStoredIntent();if(!t||"address"!==t.type||null==x(t))return;const e=S(t);if(!e)return;const i=this.countries.find((t=>String(t.id)===String(e)));if(!i)return;this.selectedCountry=i,this.updateNewAddressForm({country_id:Number(i.id)});const s=p(i.code),o=x(t),n=C(t),a=_(t),r=t.address_details?.district?.name,[l,h,c]=await Promise.all([s?m.getRegions(i.id):Promise.resolve([]),m.getCities(i.id,s&&null!=n?n:void 0),null!=o?m.getDistricts(Number(o)):Promise.resolve([])]);if(s&&(this.regions=l,this.displayedRegions=this.regions),this.cities=h,this.displayedCities=this.cities,this.districts=c,this.displayedDistricts=this.districts,this.loadingCities=!1,this.loadingRegions=!1,this.loadingDistricts=!1,s&&null!=n){const t=this.regions.find((t=>String(t.id)===String(n)));t&&(this.selectedRegion=t,this.updateNewAddressForm({region_id:t.id}))}if(null!=o&&this.cities.length>0){const t=this.cities.find((t=>String(t.id)===String(o)));t&&(this.selectedCity=t,this.updateNewAddressForm({city_id:t.id,city:t}))}if(this.districts.length>0){const t=this.findPrefillDistrict(a,r);t&&(this.updateNewAddressForm({district_id:t.id,district:t}),this.selectedDistrict=t)}!this.selectedDistrict&&r&&(this.districtName=r)}updateNewAddressForm(t){this.newAddressForm={...this.newAddressForm,...t}}hasBeenShownThisSession(){return!0===this.getShownStorage().get(this.sessionShownKey)}markShownThisSession(){this.getShownStorage().set(this.sessionShownKey,!0)}getIPLocationConfig(){const t="store.shipping.delivery_location",e={countryId:Salla.config.get(`${t}.country_id`),regionId:Salla.config.get(`${t}.region_id`),cityId:Salla.config.get(`${t}.city_id`),districtId:Salla.config.get(`${t}.district_id`)};return localStorage.getItem(_s)?JSON.parse(localStorage.getItem(_s)):e}async loadCountries(t=!1){this.loadingCountries=!0;const e="branch"===this.activeTab;try{this.countries=await m.getCountries(e),this.displayedCountries=this.countries;const{countryId:i,regionId:s,cityId:o,districtId:n}=this.getIPLocationConfig();As("getIPLocationConfig",this.getIPLocationConfig());const a=i&&this.countries.length>0?this.countries.find((t=>String(t.id)===String(i))):null;a&&(this.selectedCountry=a,this.updateNewAddressForm({country_id:Number(this.selectedCountry.id)}),!t)&&(null!=s||null!=o||null!=n?await this.prefillFromIPLocation(a,{regionId:s,cityId:o,districtId:n}):p(this.selectedCountry.code)?await this.loadRegions(this.selectedCountry.id):await this.loadCities(this.selectedCountry.id))}finally{this.loadingCountries=!1}}async prefillFromIPLocation(t,e){const i=p(t.code),{regionId:s,cityId:o,districtId:n}=e,[a,r,l]=await Promise.all([i?m.getRegions(t.id):Promise.resolve([]),m.getCities(t.id,i&&null!=s?s:void 0),null!=o?m.getDistricts(Number(o)):Promise.resolve([])]);if(i&&(this.regions=a,this.displayedRegions=this.regions),this.cities=r,this.displayedCities=this.cities,this.districts=l,this.displayedDistricts=this.districts,this.loadingRegions=!1,this.loadingCities=!1,this.loadingDistricts=!1,i&&null!=s){const t=this.regions.find((t=>String(t.id)===String(s)));t&&(this.selectedRegion=t,this.updateNewAddressForm({region_id:t.id}))}if(null!=o&&this.cities.length>0){const t=this.cities.find((t=>String(t.id)===String(o)));t&&(this.selectedCity=t,this.updateNewAddressForm({city_id:t.id,city:t}))}if(null!=n&&this.districts.length>0){const t=this.findPrefillDistrict(n);t&&(this.selectedDistrict=t,this.updateNewAddressForm({district_id:t.id,district:t}))}}async loadCities(t,e){this.loadingCities=!0,this.cities=[],this.displayedCities=[],this.districts=[],this.displayedDistricts=[],this.selectedCity=null,this.selectedDistrict=null,this.districtName="";try{this.cities=await m.getCities(t,e),this.displayedCities=this.cities}finally{this.loadingCities=!1}}async loadDistricts(t){this.loadingDistricts=!0,this.districts=[],this.displayedDistricts=[],this.selectedDistrict=null,this.districtName="";try{this.districts=await m.getDistricts(t),this.displayedDistricts=this.districts}finally{this.loadingDistricts=!1}}findPrefillDistrict(t,e){if(0===this.districts.length)return;if(null!=t){const e=this.districts.find((e=>String(e.id)===String(t)));if(e)return e}const i=e?.trim().toLowerCase();return i?this.districts.find((t=>{const e=t.name?.trim().toLowerCase(),s=t.name_en?.trim().toLowerCase();return e===i||s===i})):void 0}async loadBranches(){this.loadingBranches=!0;try{this.branches=await m.getBranches({country_id:this.selectedCountry?.id}),this.filterBranches()}finally{this.loadingBranches=!1}}filterBranches(){this.filteredBranches=((t,e)=>{if(!e)return t;const i=e.toLowerCase();return t.filter((t=>t.name.toLowerCase().includes(i)||t.city?.name?.toLowerCase().includes(i)))})(this.branches,this.branchSearchQuery)}async prefillFromSessionStorage(){try{const t=this.getStoredIntent();if(!t)return;if("address"!==this.activeTab||"address"!==t.type||this.isLoggedIn||await this.prefillAddressFromStoredIntent(),"branch"===this.activeTab&&"branch"===t.type){const e=S(t);if(null!=e){const i=this.countries.find((t=>String(t.id)===String(e)));if(i){this.selectedCountry=i,this.updateNewAddressForm({country_id:Number(i.id)});const e=A(t);if(null!=e&&this.branches.length>0){const t=this.branches.find((t=>t.id===e));t&&(this.selectedBranch=t)}}}}}catch(t){console.error("[BulletDelivery] Error prefilling from session storage:",t)}}async loadSavedAddresses(){this.savedAddresses=await m.getSavedAddresses();const t=this.getStoredIntent();if(L(t))this.selectedSessionAddress=!0,this.selectedSavedAddress=null;else{const t=this.savedAddresses.find((t=>t.is_default&&!1!==t.is_in_coverage));if(t)this.selectedSavedAddress=t;else{const t=this.savedAddresses.find((t=>!1!==t.is_in_coverage));t&&(this.selectedSavedAddress=t)}}}applyCountryChange(t){this.selectedCountry=t,this.selectedRegion=null,this.regions=[],this.displayedRegions=[],this.cities=[],this.displayedCities=[],this.districts=[],this.displayedDistricts=[],this.selectedCity=null,this.selectedDistrict=null,this.districtName="",this.allocationOutOfCoverageMessage=null,this.regionSearchQuery="",this.citySearchQuery="",this.districtSearchQuery="",this.searchingRegions=!1,this.searchingCities=!1,this.searchingDistricts=!1,this.clearSearchTimers(),this.selectedCountry&&(this.updateNewAddressForm({country_id:Number(this.selectedCountry.id),region_id:void 0,city_id:void 0,district_id:void 0,city:void 0,district:void 0}),"branch"===this.activeTab?this.loadBranches():p(this.selectedCountry.code)?this.loadRegions(this.selectedCountry.id):this.loadCities(this.selectedCountry.id))}async loadRegions(t){this.loadingRegions=!0,this.regions=[],this.displayedRegions=[],this.selectedRegion=null,this.cities=[],this.displayedCities=[],this.districts=[],this.displayedDistricts=[],this.selectedCity=null,this.selectedDistrict=null,this.districtName="";try{this.regions=await m.getRegions(t),this.displayedRegions=this.regions}finally{this.loadingRegions=!1}}emitHeaderContextUpdate(t,e,i){let s="";"address"===t.type?e?s=e.district?.name&&e.city?.name?`${e.district.name}، ${e.city.name}`:e.city?.name??"":this.selectedCity?s=this.selectedDistrict?`${this.selectedDistrict.name}، ${this.selectedCity.name}`:this.selectedCity.name:t.address_details&&(s=[t.address_details.district?.name,t.address_details.city.name,t.address_details.country.name].filter(Boolean).join("، ")||t.address_details.short_address||""):i?s=i.name:t.branch_details&&(s=t.branch_details.city??t.branch_details.name);const o="address"===t.type?Salla.lang.get("mobile_app.strings.delivery"):Salla.lang.get("mobile_app.strings.pickup");this.headerContextUpdate.emit({type:t.type,display_text:s?`${o}: ${s}`:"",country_code:t.country_code,city:this.selectedCity?.name??t.address_details?.city?.name,district:this.selectedDistrict?.name??t.address_details?.district?.name,branch_name:i?.name??t.branch_details?.name})}handleBranchSearch(t){const e=t.target.value;if(this.branchSearchQuery=e,this.branchSearchDebounceTimer&&clearTimeout(this.branchSearchDebounceTimer),!e?.trim())return this.branchSearchQuery="",void this.loadBranches();this.branchSearchDebounceTimer=setTimeout((async()=>{if(!(e.trim().length<2)){this.loadingBranches=!0;try{this.branches=await m.getBranches({country_id:this.selectedCountry?.id,query:e}),this.filterBranches()}finally{this.loadingBranches=!1}}}),1e3)}clearSearchTimers(){[this.countrySearchTimer,this.regionSearchTimer,this.citySearchTimer,this.districtSearchTimer].forEach((t=>{t&&clearTimeout(t)})),this.countrySearchTimer=this.regionSearchTimer=this.citySearchTimer=this.districtSearchTimer=null}resetSearchState(){this.countrySearchQuery="",this.regionSearchQuery="",this.citySearchQuery="",this.districtSearchQuery="",this.searchingCountries=!1,this.searchingRegions=!1,this.searchingCities=!1,this.searchingDistricts=!1,this.displayedCountries=[],this.displayedRegions=[],this.displayedCities=[],this.displayedDistricts=[],this.clearSearchTimers()}async loadBranchesWithLocation(t,e){this.loadingBranches=!0;try{if(this.branches=await m.getBranches({country_id:this.selectedCountry?.id,lat:t,lng:e}),this.filterBranches(),!this.selectedCountry&&this.branches.length>0){const t=this.branches[0];if(t.country){const e=this.countries.find((e=>e.id===t.country.id));e&&(this.selectedCountry=e,this.updateNewAddressForm({country_id:Number(e.id)}))}}}finally{this.loadingBranches=!1}}async handleFindNearestBranch(){if(navigator.geolocation){this.loadingNearestBranch=!0,this.locationError="";try{const t=await new Promise(((t,e)=>{navigator.geolocation.getCurrentPosition(t,e,{enableHighAccuracy:!0,timeout:1e4,maximumAge:0})})),{latitude:e,longitude:i}=t.coords;await this.loadBranchesWithLocation(e,i);const s=function(t,e,i){let s=null,o=Number.POSITIVE_INFINITY;for(const n of t){const t=null!=n.location?.lat?Number(n.location.lat):Number.NaN,a=null!=n.location?.lng?Number(n.location.lng):Number.NaN;if(Number.isNaN(t)||Number.isNaN(a)||!1===n.is_open)continue;const r=f(e,i,t,a);r<o&&(o=r,s=n)}return s}(this.branches,e,i);s&&(this.selectedBranch=s,this.branchSearchQuery="",this.filterBranches())}catch(t){const e=t;this.locationError=z["number"==typeof e?.code?e.code:-1]??"An error occurred while detecting location"}finally{this.loadingNearestBranch=!1}}else this.locationError=Salla.lang.get("pages.checkout.current_location_not_supported")}handleBranchSelect(t){this.selectedBranch=t}handleSavedAddressSelect(t){!1!==t.is_in_coverage?(this.selectedSavedAddress=t,this.selectedSessionAddress=!1):Salla.notify?.error(Salla.lang.get("pages.checkout.shipping_not_available"))}handleSessionAddressSelect(){this.selectedSessionAddress=!0,this.selectedSavedAddress=null}async handleAddNewAddress(){this.viewMode="add-address",this.mapLocationData=null,this.autoGeolocationTriggered=!1,this.fetchAddressToken();const t=this.getStoredIntent(),e=S(t);if(e&&this.countries.length>0){const t=this.countries.find((t=>t.id===e));t&&(this.selectedCountry=t,this.updateNewAddressForm({country_id:Number(t.id)}),p(t.code)?await this.loadRegions(t.id):await this.loadCities(t.id))}}handleBackToAddressList(){this.viewMode="main",this.mapLocationData=null,this.mapStep="map",this.addressDescription="",this.autoGeolocationTriggered=!1}async fetchAddressToken(){if(!this.addressToken&&!this.loadingToken){this.loadingToken=!0;try{const t=salla.config.get("store.settings.keys.maps");t&&function(t,e){if(typeof document>"u")return Promise.resolve();if(ni)return ri;let i;ni=!0,i={...t},Array.isArray(i.libraries)&&(i.libraries=i.libraries),!e&&!i.v&&(e="quarterly"),i.loading||(i.loading="async"),i.callback="googleMapsInitCallback";let s=`https://maps.googleapis.com/maps/api/js?${Object.keys(i).map((t=>`${encodeURIComponent(t)}=${encodeURIComponent(i[t])}`)).join("&")}`;e&&(s+=`&v=${e}`);const o=document.createElement("script");return o.src=s,o.async=!0,o.defer=!0,o.onerror=t=>{console.error("Failed to load Google Maps script:",t)},document.body.appendChild(o),ri}({key:t,libraries:["marker","places"],language:salla.config.get("user.language_code")||"ar"}).catch((t=>As("Failed to load Google Maps SDK",t))),this.addressToken=await m.getAddressToken()}catch{As("SallaBulletDelivery: Failed to fetch address token")}finally{this.loadingToken=!1}}}updateLocationBias(){if(!this.gmapRef)return;const t=this.hasMapLocation()?{lat:this.mapLocationData.lat,lng:this.mapLocationData.lng}:this.mapInitialCenter;this.gmapRef.autocompleteLocationBias={center:t,radius:5e5}}hasMapLocation(){return null!=this.mapLocationData?.lat&&null!=this.mapLocationData?.lng}get isMapSettingEnabled(){return Salla.config.get("store.settings.bullet_delivery.settings.map_enabled")}get isMapModeAvailable(){return this.isMapSettingEnabled&&!!salla.config.get("store.settings.keys.maps")&&!!this.addressToken}get mapInitialCenter(){const t=salla.config.get("user.default_geo_location"),e=this.toCoordinate(t?.lat),i=this.toCoordinate(t?.lng);return null!=e&&null!=i&&e>=-90&&e<=90&&i>=-180&&i<=180?{lat:e,lng:i}:xs}toCoordinate(t){if("string"==typeof t&&""===t.trim())return null;if(null==t)return null;const e=Number(t);return Number.isFinite(e)?e:null}buildAddressLocationPayload(){if(this.isMapModeAvailable&&this.hasMapLocation())return{lat:this.mapLocationData.lat,lng:this.mapLocationData.lng,...this.mapLocationData.shortAddress&&{short_address:this.mapLocationData.shortAddress},...this.addressDescription?.trim()&&{description:this.addressDescription.trim()}};const t=this.selectedDistrict?.name??this.districtName?.trim()??"";return function(t){const{countryId:e,countryCode:i,regionId:s,cityId:o,districtId:n,description:a="",lat:r,lng:l,shortAddress:h}=t,c=a||"";return{country_id:Number(e)||void 0,region_id:null!=s?Number(s):void 0,city_id:null!=o?Number(o):void 0,district_id:null!=n?Number(n):void 0,description:c,...i&&p(i)&&{local:c},...null!=r&&null!=l&&{lat:r,lng:l},...h&&{short_address:h}}}({countryId:this.selectedCountry?.id??0,countryCode:this.selectedCountry?.code,regionId:this.selectedRegion?.id,cityId:this.selectedCity?.id,districtId:this.selectedDistrict?.id,description:t,lat:this.mapLocationData?.lat,lng:this.mapLocationData?.lng,shortAddress:this.mapLocationData?.shortAddress})}async handleTabChange(t){if(!this.tabChanging){this.tabChanging=!0;try{this.activeTab=t,"add-address"===this.viewMode&&(this.viewMode="main"),this.showCartWillBeClearedBanner=!1,this.allocationOutOfCoverageMessage=null,this.resetSearchState();const e="branch"===t;this.countries=await m.getCountries(e),this.displayedCountries=this.countries;const i=this.selectedCountry?.id;if(null!=i&&(this.selectedCountry=this.countries.find((t=>t.id===i))||null),!this.selectedCountry){const{countryId:t}=this.getIPLocationConfig();t&&this.countries.length>0&&(this.selectedCountry=this.countries.find((e=>String(e.id)===String(t)))||null),this.selectedCountry||1!==this.countries.length||(this.selectedCountry=this.countries[0])}if(this.selectedCountry)if("branch"===t){const t=this.getStoredIntent(),e=$(t),i=M(t);null!=e&&null!=i?await this.loadBranchesWithLocation(e,i):await this.loadBranches();const s=A(t);if(null!=s&&this.branches.length>0){const t=this.branches.find((t=>t.id===s));t&&(this.selectedBranch=t)}}else if("address"===t){if(this.isLoggedIn&&!this.savedAddressesLoaded){this.loadingSavedAddresses=!0;try{await this.loadSavedAddresses(),this.savedAddressesLoaded=!0}finally{this.loadingSavedAddresses=!1}}if(!this.isLoggedIn){const t=this.getStoredIntent();t&&x(t)&&await this.prefillAddressFromStoredIntent()}}}finally{this.tabChanging=!1}}}isConfirmDisabled(){return"branch"===this.activeTab?!this.selectedBranch:!("address"!==this.activeTab||this.isLoggedIn&&this.selectedSessionAddress||(this.isLoggedIn&&this.selectedSavedAddress?!1!==this.selectedSavedAddress.is_in_coverage:this.selectedCountry&&this.selectedCity&&E(this.selectedCountry?.code,this.selectedRegion?.id,this.selectedDistrict?.id??(this.districtName?.trim()||null))))}handleLogin(){Salla.auth.setCanRedirect(!1),Salla.event.dispatch("salla::bullet-delivery.modal.close.requested"),Salla.event.dispatch("login::open",Salla.url.is_page("cart")?{withoutReload:!0,source:"cart-submit"}:{withoutReload:!0,source:"bullet-delivery"})}resolvePendingCartSubmit(){if(!this.pendingCartSubmitResolver)return;const t=this.pendingCartSubmitResolver;this.pendingCartSubmitResolver=null,this.pendingCartSubmitPromise=null,this.cartSubmitConfirmationPending=!1,t()}buildIntentAddress(){if("address"!==this.activeTab||!this.selectedCountry||!this.selectedCity)return;const t={id:this.selectedCountry.id,name:this.selectedCountry.name,code:this.selectedCountry.code},e={id:this.selectedCity.id,name:this.selectedCity.name},i=this.selectedRegion?{id:this.selectedRegion.id,name:this.selectedRegion.name,code:this.selectedRegion.code}:void 0,s=this.selectedDistrict?{id:this.selectedDistrict.id,name:this.selectedDistrict.name}:this.districtName?{id:0,name:this.districtName}:void 0,o=this.selectedSavedAddress?.short_address;return{country:t,region:i,city:e,district:s,short_address:o}}buildIntentAddressFromSaved(t){return{country:{id:t.country?.id??t.country_id??0,name:t.country?.name??"",code:t.country?.code},region:t.region?{id:t.region.id,name:t.region.name,code:t.region.code}:void 0,city:{id:t.city?.id??t.city_id??0,name:t.city?.name??""},district:t.district?{id:t.district.id,name:t.district.name}:void 0,short_address:t.short_address}}buildIntentBranch(){if("branch"!==this.activeTab||!this.selectedBranch)return;const t=this.selectedBranch,e=null!=t.location?.lat?Number(t.location.lat):void 0,i=null!=t.location?.lng?Number(t.location.lng):void 0;return{id:t.id,name:t.name,city:t.city?.name,latitude:e,longitude:i}}buildAllocationConfirmedAddressData(t){return"address"!==this.activeTab?null:{saved_address:t??this.selectedSavedAddress??void 0,country:this.selectedCountry??void 0,region:this.selectedRegion??void 0,city:this.selectedCity??void 0,district:this.selectedDistrict??void 0,district_name:this.districtName?.trim()||void 0,short_address:t?.short_address??this.selectedSavedAddress?.short_address,form_data:{...this.newAddressForm}}}buildAllocationConfirmedAddressFromIntent(t){if("address"!==t.type)return null;const e=t.address_details,i=Number(t.country_id)||0;return{country:e?.country?{id:e.country.id,name:e.country.name,code:e.country.code??t.country_code??""}:void 0,region:e?.region?{id:Number(e.region.id),name:e.region.name,country_id:i,code:e.region.code??void 0}:void 0,city:e?.city?{id:Number(e.city.id),name:e.city.name,country_id:i}:void 0,district:e?.district?{id:Number(e.district.id),name:e.district.name,city_id:Number(e.city?.id)||0}:void 0,short_address:e?.short_address}}buildBranchFromIntent(t){if("branch"!==t.type||!t.branch_details)return null;const e=t.branch_details,i={id:e.id,name:e.name};return e.city&&(i.city={id:0,name:e.city}),null!=e.latitude&&null!=e.longitude&&(i.location={lat:String(e.latitude),lng:String(e.longitude)}),i}buildAllocationRequestFromIntent(t){if("branch"===t.type)return{type:"branch",branch_id:null!=t.branch_id?String(t.branch_id):""};if(null!=t.address_id)return{type:"address",address_id:String(t.address_id)};const e=t.address_details,i={type:"address",country_id:null!=t.country_id?String(t.country_id):"",city_id:null!=e?.city?.id?String(e.city.id):""};return null!=e?.region?.id&&(i.region_id=String(e.region.id)),null!=e?.district?.id&&(i.district_id=String(e.district.id)),i}applyMobileBulletDeliverySelection(t){if(!t||"address"!==t.type&&"branch"!==t.type)return void console.warn("SallaBulletDelivery: ignoring invalid mobile select payload",t);const e=t.allocation_headers??{},i=e["s-scope-allocation-type"]??t.type,s=e["s-scope-allocation-id"];i&&Salla.api.setHeader("s-scope-allocation-type",i),s&&Salla.api.setHeader("s-scope-allocation-id",String(s));const o=Salla.config.get("store.scope",Salla.storage.get("scope"))||{};Salla.storage.set("scope",{...o,allocation_type:i,allocation_id:s?String(s):void 0}),this.markShownThisSession();const n={...t,allocation_headers:{"s-scope-allocation-type":i,"s-scope-allocation-id":s?String(s):void 0}};this.setStoredIntent(n),g();const a=this.buildBranchFromIntent(n),r={...n,address:this.buildAllocationConfirmedAddressFromIntent(n),branch:a,allocation_request:this.buildAllocationRequestFromIntent(n),allocation_response:null};Salla.event.dispatch("salla::bullet-delivery.allocation.confirmed",r),this.bulletDeliveryConfirmed.emit({...n,branch:a??void 0}),this.emitHeaderContextUpdate(n,void 0,a??void 0),setTimeout((()=>window.location.reload()),100)}extractMobileSelectPayload(t){return t&&"object"==typeof t?"payload"in t&&t.payload?t.payload:t:null}async handleConfirm(){if(this.isConfirmDisabled()||this.confirming)return;this.confirming=!0,this.confirmBtn?.load();let t=!1;try{const e={type:this.activeTab,country_id:Number(this.selectedCountry?.id)||0,country_code:this.selectedCountry?.code||""};let i,s,o;if("address"===this.activeTab)if(this.isLoggedIn&&this.selectedSessionAddress){const t=await this.saveSessionAddressToProfile();if(!t)return Salla.notify?.error(Salla.lang.get("common.errors.error_occurred")),void this.confirmBtn?.stop();e.address_id=t.id,i=t,this.selectedSessionAddress=!1,this.selectedSavedAddress=t,e.address_details=this.buildIntentAddressFromSaved(t)}else this.isLoggedIn&&this.selectedSavedAddress?(e.address_id=this.selectedSavedAddress.id,i=this.selectedSavedAddress,e.address_details=this.buildIntentAddressFromSaved(this.selectedSavedAddress)):e.address_details=this.buildIntentAddress();else e.branch_details=this.buildIntentBranch(),e.branch_id=this.selectedBranch?.id,s=this.selectedBranch||void 0;"address"===this.activeTab?this.isLoggedIn&&this.selectedSavedAddress?o={type:"address",address_id:String(this.selectedSavedAddress.id)}:(o={type:"address",country_id:String(this.selectedCountry?.id||0),city_id:String(this.selectedCity?.id||"")},p(this.selectedCountry?.code??"")&&(this.selectedRegion?.id&&(o.region_id=String(this.selectedRegion.id)),o.district_id=String(this.selectedDistrict?.id||""))):o={type:"branch",branch_id:String(this.selectedBranch?.id||"")};const n=await m.allocateScope(o);if(!n.success){console.error("BulletDelivery: Scope allocation failed",n.error);const t=n.error||("address"===this.activeTab?Salla.lang.get("pages.checkout.address_out_of_coverage"):Salla.lang.get("pages.checkout.failed_to_set_pickup"));return this.allocationOutOfCoverageMessage=t,this.confirmBtn?.stop(),void(this.confirming=!1)}let a;if(n.data){const t=n.data;a=t.id;const i=t?.allocation?.type,s=t?.allocation?.branch_id;i&&Salla.api.setHeader("s-scope-allocation-type",i),s&&Salla.api.setHeader("s-scope-allocation-id",String(s));const o=Salla.config.get("store.scope",Salla.storage.get("scope"))||{};Salla.storage.set("scope",{...o,id:a,allocation_type:i,allocation_id:s?String(s):void 0}),e.allocation_headers={"s-scope-allocation-type":i,"s-scope-allocation-id":s?String(s):void 0}}this.markShownThisSession(),this.setStoredIntent(e),a&&(await m.setDeliveryScope(a),g());const r={...e,address:this.buildAllocationConfirmedAddressData(i),branch:s??null,allocation_request:o,allocation_response:n.data??null};Salla.event.dispatch("salla::bullet-delivery.allocation.confirmed",r),this.bulletDeliveryConfirmed.emit({...e,address:i,branch:s}),this.emitHeaderContextUpdate(e,i,s),t=!0,setTimeout((()=>{if(this.confirmBtn?.stop(),this.close(),this.confirming=!1,this.cartSubmitConfirmationPending)this.resolvePendingCartSubmit();else if(a){const t=Salla.storage.get("scope")||{};let e=Salla.helpers.addParamToUrl("scope",a);t.allocation_id&&(e=Salla.helpers.addParamToUrl("allocation_id",t.allocation_id,e)),t.allocation_type&&(e=Salla.helpers.addParamToUrl("allocation_type",t.allocation_type,e)),window.location.replace(e)}else window.location.reload()}),500)}finally{t||(this.confirming=!1)}}getCartViewConfig(t){if(!t||!Salla.url.is_page("cart"))return null;if(!this.isIntentMethodSupported(t))return null;const e="address"===t.type;return{title:"branch"===t.type?Salla.lang.get("pages.checkout.pickup_option"):Salla.lang.get("pages.checkout.delivery_option"),subtitle:y(t,Salla.lang.get("common.elements.to"),""),buttonText:Salla.lang.get("common.elements.edit"),isAddress:e,intent:t}}createCartViewElement(){const t=this.getStoredIntent(),e=this.getCartViewConfig(t);if(!e)return null;const{title:i,subtitle:s,buttonText:o,intent:a}=e,r="branch"===a.type?{preselected_branch_id:A(a)}:{preselected_address_id:a.address_id},l=document.createElement("span");l.className="s-bullet-delivery-cart-view-icon s-bullet-delivery-tab-icon",l.setAttribute("aria-hidden","true"),l.innerHTML=n;const h=document.createElement("span");h.className="s-bullet-delivery-cart-view-title",h.textContent=i;const c=document.createElement("span");c.className="s-bullet-delivery-cart-view-subtitle",c.textContent=s;const d=document.createElement("div");d.className="s-bullet-delivery-cart-view-text",d.append(h,c);const u=document.createElement("div");u.className="s-bullet-delivery-cart-view-info",u.append(l,d);const p=document.createElement("salla-button");p.className="s-bullet-delivery-cart-view-button",p.setAttribute("fill","outline"),p.setAttribute("color","primary"),p.textContent=o,p.addEventListener("click",(()=>Salla.event.emit("salla::bullet-delivery.modal.open.requested",r)));const m=document.createElement("div");return m.className="s-bullet-delivery-cart-view",m.append(u,p),m}renderTabs(){return this.supportsPickup?i("div",{class:"s-bullet-delivery-tabs"},this.isSupportsDelivery&&i("button",{type:"button",class:{"s-bullet-delivery-tab":!0,"s-bullet-delivery-tab--active":"address"===this.activeTab},onClick:()=>this.handleTabChange("address")},i("span",{class:"s-bullet-delivery-tab-icon",innerHTML:n,"aria-hidden":"true"}),i("span",null,Salla.lang.get("mobile_app.strings.delivery"))),i("button",{type:"button",class:{"s-bullet-delivery-tab":!0,"s-bullet-delivery-tab--active":"branch"===this.activeTab},onClick:()=>this.handleTabChange("branch")},i("span",{class:"s-bullet-delivery-tab-icon",innerHTML:Cs,"aria-hidden":"true"}),i("span",null,Salla.lang.get("mobile_app.strings.pickup")))):null}renderAlert(t){return i("div",{class:"s-bullet-delivery-allocation-out-of-coverage",role:"alert"},i("span",{class:"s-bullet-delivery-allocation-out-of-coverage-icon","aria-hidden":"true"},i("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",role:"img","aria-hidden":"true"},i("title",null,"Information"),i("circle",{cx:"10",cy:"10",r:"9",stroke:"currentColor","stroke-width":"1.5",fill:"currentColor"}),i("text",{x:"10",y:"14","text-anchor":"middle",fill:"white","font-size":"12","font-weight":"bold"},"i"))),i("span",{class:"s-bullet-delivery-allocation-out-of-coverage-text"},t))}renderAllocationOutOfCoverageAlert(){const t=this.allocationOutOfCoverageMessage||Salla.lang.get("pages.checkout.shipping_not_available");return this.renderAlert(t)}renderCountrySelect(){return i("div",{class:"s-bullet-delivery-field"},i("salla-searchable-dropdown",{label:Salla.lang.get("blocks.buy_as_gift.receiver_country"),placeholder:Salla.lang.get("pages.checkout.select_country"),items:this.displayedCountries,selectedItem:this.selectedCountry,loading:this.loadingCountries,searching:this.searchingCountries,disabled:this.countries.length<=1,required:!0,inputId:"bullet-delivery-country",searchQuery:this.countrySearchQuery,clientSearch:!0,onItemSelected:t=>this.handleCountrySelected(t.detail),onSearchInput:t=>this.handleCountrySearch(t.detail),onDropdownClosed:()=>this.handleCountryDropdownClosed()}))}renderRegionSelect(){return p(this.selectedCountry?.code??"")&&this.selectedCountry?i("div",{class:"s-bullet-delivery-field"},i("salla-searchable-dropdown",{label:Salla.lang.get("pages.checkout.region_field"),placeholder:Salla.lang.get("pages.checkout.select_region"),items:this.displayedRegions,selectedItem:this.selectedRegion,loading:this.loadingRegions,searching:this.searchingRegions,disabled:this.loadingRegions||0===this.regions.length,required:!0,inputId:"bullet-delivery-region",searchQuery:this.regionSearchQuery,clientSearch:!0,onItemSelected:t=>this.handleRegionSelected(t.detail),onSearchInput:t=>this.handleRegionSearch(t.detail),onDropdownClosed:()=>this.handleRegionDropdownClosed()})):null}renderCityDistrictSelects(){const t=p(this.selectedCountry?.code??""),e=t,s=e&&this.selectedCity&&!this.loadingDistricts&&0===this.districts.length,o=!this.selectedCountry||t&&!this.selectedRegion||this.loadingCities||0===this.cities.length,n=!this.selectedCountry||t&&!this.selectedRegion||!this.selectedCity||this.loadingDistricts;return i("div",{class:"s-bullet-delivery-field-row"},i("div",{class:"s-bullet-delivery-field"},i("salla-searchable-dropdown",{label:Salla.lang.get("blocks.buy_as_gift.receiver_city"),placeholder:Salla.lang.get("pages.checkout.select_city"),items:this.displayedCities,selectedItem:this.selectedCity,loading:this.loadingCities,searching:this.searchingCities,disabled:o,required:!0,inputId:"bullet-delivery-city",searchQuery:this.citySearchQuery,onItemSelected:t=>this.handleCitySelected(t.detail),onSearchInput:t=>this.handleCitySearch(t.detail),onDropdownClosed:()=>this.handleCityDropdownClosed(),dropUp:!0})),e&&i("div",{class:"s-bullet-delivery-field"},s?i("div",null,i("label",{class:"s-bullet-delivery-label",htmlFor:"bullet-delivery-district"},Salla.lang.get("pages.checkout.district_field"),i("span",{class:"text-red-500"}," *")),i("input",{id:"bullet-delivery-district",type:"text",class:"form-input",placeholder:Salla.lang.get("pages.checkout.select_district"),value:this.districtName,disabled:n,onInput:t=>{this.districtName=t.target.value,this.updateNewAddressForm({district:void 0})}})):i("salla-searchable-dropdown",{label:Salla.lang.get("pages.checkout.district_field"),placeholder:Salla.lang.get("pages.checkout.select_district"),items:this.displayedDistricts,selectedItem:this.selectedDistrict,loading:this.loadingDistricts,searching:this.searchingDistricts,disabled:n||0===this.districts.length,required:!0,inputId:"bullet-delivery-district",searchQuery:this.districtSearchQuery,clientSearch:!0,onItemSelected:t=>this.handleDistrictSelected(t.detail),onSearchInput:t=>this.handleDistrictSearch(t.detail),onDropdownClosed:()=>this.handleDistrictDropdownClosed(),dropUp:!0})))}renderSavedAddressesEmptyState(){return i("div",{class:"s-bullet-delivery-saved-addresses-empty"},i("div",{class:"s-bullet-delivery-saved-addresses-empty-icon","aria-hidden":"true"},i("svg",{width:"28",height:"28",viewBox:"0 0 28 29",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i("title",null,"No Saved Adresses"),i("path",{d:"M20.16 0C21.4613 0 22.6773 0.341333 23.808 1.024C24.9387 1.70667 25.8347 2.61333 26.496 3.744C27.1787 4.91733 27.52 6.18667 27.52 7.552C27.52 9.45067 26.8267 11.232 25.44 12.896C24.4587 14.0907 23.0827 15.2427 21.312 16.352H21.28C20.9387 16.5653 20.5653 16.672 20.16 16.672C19.7547 16.672 19.3813 16.5653 19.04 16.352H19.008C17.2373 15.2213 15.8613 14.0693 14.88 12.896C13.4933 11.232 12.8 9.45067 12.8 7.552C12.8 6.18667 13.1413 4.91733 13.824 3.744C14.4853 2.61333 15.3813 1.70667 16.512 1.024C17.6427 0.341333 18.8587 0 20.16 0ZM11.488 1.984C9.67467 2.368 8.04267 3.14667 6.592 4.32C5.14133 5.49333 4.01067 6.92267 3.2 8.608C2.34667 10.3573 1.92 12.224 1.92 14.208C1.92 14.72 1.952 15.2427 2.016 15.776L2.08 15.744C2.57067 15.488 2.94933 15.3067 3.216 15.2C3.48267 15.0933 3.73867 15.0933 3.984 15.2C4.22933 15.3067 4.4 15.488 4.496 15.744C4.592 16 4.58667 16.256 4.48 16.512C4.37333 16.768 4.19733 16.9493 3.952 17.056C3.70667 17.1627 3.36 17.3227 2.912 17.536L2.656 17.664C2.57067 17.7067 2.48533 17.7387 2.4 17.76C2.89067 19.4667 3.70133 20.9973 4.832 22.352C5.96267 23.7067 7.296 24.7573 8.832 25.504C10.432 26.272 12.1173 26.656 13.888 26.656C15.4667 26.656 16.9813 26.3467 18.432 25.728C19.8187 25.1307 21.0667 24.288 22.176 23.2C21.92 23.0507 21.7653 22.8373 21.712 22.56C21.6587 22.2827 21.7013 22.0267 21.84 21.792C21.9787 21.5573 22.176 21.408 22.432 21.344C22.8373 21.2587 23.2 21.12 23.52 20.928C23.6907 20.8427 23.8613 20.8 24.032 20.8C24.8 19.5413 25.3333 18.176 25.632 16.704C25.6747 16.4267 25.808 16.2133 26.032 16.064C26.256 15.9147 26.496 15.8667 26.752 15.92C27.008 15.9733 27.2107 16.1173 27.36 16.352C27.5093 16.5867 27.552 16.832 27.488 17.088C27.0613 19.2853 26.1973 21.264 24.896 23.024C23.5947 24.784 22.0053 26.1547 20.128 27.136C18.1653 28.16 16.0853 28.672 13.888 28.672C11.3707 28.672 9.03467 28.0107 6.88 26.688C4.78933 25.408 3.12533 23.68 1.888 21.504C0.629333 19.264 0 16.832 0 14.208C0 11.904 0.490667 9.73867 1.472 7.712C2.41067 5.74933 3.728 4.09067 5.424 2.736C7.12 1.38133 9.01333 0.48 11.104 0.032C11.36 -0.032 11.6 0.0106667 11.824 0.16C12.048 0.309333 12.1867 0.522667 12.24 0.8C12.2933 1.07733 12.2453 1.328 12.096 1.552C11.9467 1.776 11.744 1.92 11.488 1.984ZM14.72 7.552C14.72 8.96 15.2533 10.304 16.32 11.584C17.1733 12.5867 18.3893 13.6 19.968 14.624C20.032 14.6453 20.096 14.656 20.16 14.656C20.224 14.656 20.288 14.6453 20.352 14.624C21.9307 13.6213 23.1467 12.608 24 11.584C25.0667 10.304 25.6 8.96 25.6 7.552C25.6 6.57067 25.3547 5.65333 24.864 4.8C24.3733 3.94667 23.7067 3.26933 22.864 2.768C22.0213 2.26667 21.12 2.016 20.16 2.016C19.2 2.016 18.2987 2.26667 17.456 2.768C16.6133 3.26933 15.9467 3.94667 15.456 4.8C14.9653 5.65333 14.72 6.57067 14.72 7.552ZM17.28 7.68C17.28 6.848 17.5627 6.13867 18.128 5.552C18.6933 4.96533 19.3707 4.672 20.16 4.672C20.9493 4.672 21.6267 4.96533 22.192 5.552C22.7573 6.13867 23.04 6.848 23.04 7.68C23.04 8.512 22.7573 9.216 22.192 9.792C21.6267 10.368 20.9493 10.656 20.16 10.656C19.3707 10.656 18.6933 10.368 18.128 9.792C17.5627 9.216 17.28 8.512 17.28 7.68ZM6.752 14.688C7.62667 14.7733 8.53333 15.0293 9.472 15.456C9.70667 15.5627 9.87733 15.744 9.984 16C10.0907 16.256 10.0907 16.512 9.984 16.768C9.87733 17.024 9.70133 17.2 9.456 17.296C9.21067 17.392 8.97067 17.3867 8.736 17.28C7.94667 16.9387 7.22133 16.736 6.56 16.672C6.28267 16.6293 6.064 16.5013 5.904 16.288C5.744 16.0747 5.68 15.8293 5.712 15.552C5.744 15.2747 5.86133 15.0507 6.064 14.88C6.26667 14.7093 6.496 14.6453 6.752 14.688ZM17.6 20.544C18.304 20.864 18.976 21.0987 19.616 21.248C19.872 21.312 20.0693 21.4613 20.208 21.696C20.3467 21.9307 20.3893 22.1813 20.336 22.448C20.2827 22.7147 20.144 22.9227 19.92 23.072C19.696 23.2213 19.4453 23.264 19.168 23.2C18.4213 23.0293 17.632 22.752 16.8 22.368C16.5653 22.2613 16.4 22.08 16.304 21.824C16.208 21.568 16.2133 21.312 16.32 21.056C16.4267 20.8 16.6027 20.624 16.848 20.528C17.0933 20.432 17.344 20.4373 17.6 20.544ZM12.832 17.44C13.0027 17.568 13.248 17.7493 13.568 17.984L14.496 18.688C14.7093 18.8587 14.8373 19.0773 14.88 19.344C14.9227 19.6107 14.8693 19.856 14.72 20.08C14.5707 20.304 14.368 20.4427 14.112 20.496C13.856 20.5493 13.6107 20.5013 13.376 20.352L11.744 19.072C11.5307 18.9227 11.4027 18.7093 11.36 18.432C11.3173 18.1547 11.3707 17.904 11.52 17.68C11.6693 17.456 11.872 17.3227 12.128 17.28C12.384 17.2373 12.6187 17.2907 12.832 17.44ZM20.16 8.672C20.416 8.672 20.64 8.576 20.832 8.384C21.024 8.192 21.12 7.95733 21.12 7.68C21.12 7.40267 21.024 7.16267 20.832 6.96C20.64 6.75733 20.416 6.656 20.16 6.656C19.904 6.656 19.68 6.75733 19.488 6.96C19.296 7.16267 19.2 7.40267 19.2 7.68C19.2 7.95733 19.296 8.192 19.488 8.384C19.68 8.576 19.904 8.672 20.16 8.672Z",fill:"#666666"}))),i("p",{class:"s-bullet-delivery-saved-addresses-empty-title"},Salla.lang.get("pages.checkout.no_saved_addresses")),i("p",{class:"s-bullet-delivery-saved-addresses-empty-desc"},Salla.lang.get("pages.checkout.add_address_simplify_shipping")),i("salla-button",{onClick:()=>this.handleAddNewAddress(),onKeyUp:()=>this.handleAddNewAddress()},Salla.lang.get("pages.checkout.add_new_address")))}async saveSessionAddressToProfile(){const t=this.getStoredIntent(),e=S(t),i=x(t),s=_(t);if(!t||"address"!==t.type||!e||!i)return null;const o=k(t);if(p(o)&&!s)return null;const n=p(o),a=t.address_details?.district?.name??"",r={country_id:e,region_id:C(t),city_id:i,district_id:s,description:a};n&&(r.local=a);try{const{success:t,address:e}=await m.saveAddressLocation(r);if(!t)return null;const i=e??null;return i&&this.addressCreated.emit({address:i}),i}catch(t){return console.error("SallaBulletDelivery: Error saving session address",t),null}}renderSavedAddresses(){if(!this.isLoggedIn)return null;if(this.loadingSavedAddresses)return i("div",{class:"s-bullet-delivery-addresses-list s-scrollbar"},[1,2,3].map((t=>i("div",{key:t,class:"s-bullet-delivery-address-item s-bullet-delivery-address-item--skeleton"},i("salla-skeleton",{class:"s-bullet-delivery-skel-radio",height:"18px",width:"18px"}),i("salla-skeleton",{class:"s-bullet-delivery-skel-map",height:"36px",width:"36px"}),i("div",{class:"s-bullet-delivery-address-content"},i("div",{class:"s-bullet-delivery-address-lines"},i("salla-skeleton",{height:"18px",width:"72%"}),i("salla-skeleton",{height:"16px",width:"56%"})))))));const t=this.getStoredIntent(),e=L(t),s=e&&t?.address_details&&[t.address_details.city?.name,t.address_details.country?.name].filter(Boolean).join("، ")||"",o=e&&t?.address_details?(t.address_details.district?.name??"").trim():"";return 0!==this.savedAddresses.length||e?i("div",{class:"s-bullet-delivery-addresses-list s-scrollbar"},e&&this.renderAddressRow({key:"session-address",line1:s,line2:o,selected:this.selectedSessionAddress,onClick:()=>this.handleSessionAddressSelect()}),this.savedAddresses.map((t=>{const e=[t.building_number,t.street].filter(Boolean).join("، ")||t.formatted?.address_one||t.short_address||"",i=[t.district?.name,t.city?.name,t.country?.name].filter(Boolean).join("، "),s=(t.formatted?.address_two||i)??"",o=!1!==t.is_in_coverage;return this.renderAddressRow({key:String(t.id),line1:e,line2:s,selected:this.selectedSavedAddress?.id===t.id,disabled:!o,onClick:()=>o&&this.handleSavedAddressSelect(t)})}))):this.renderSavedAddressesEmptyState()}renderAddressRow(t){const{key:e,line1:s,line2:o,selected:n,disabled:a=!1,onClick:r}=t;return i("button",{key:e,class:{"s-bullet-delivery-address-item":!0,"s-bullet-delivery-address-item--selected":n,"s-bullet-delivery-address-item--disabled":a},type:"button",onClick:a?void 0:r,onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),a||r())}},i("input",{type:"radio",name:"saved_address",class:"s-bullet-delivery-radio",checked:n,disabled:a,onClick:t=>t.stopPropagation()}),i("span",{class:"s-bullet-delivery-address-map-icon",innerHTML:'<svg width="35" height="35" viewBox="0 0 35 35" fill="none" xmlns="http://www.w3.org/2000/svg">\n <g filter="url(#filter0_d_24181_220540)">\n <mask id="mask0_24181_220540" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="1" y="0" width="33" height="32">\n <rect x="1.90958" y="0.576577" width="30.8468" height="30.8468" rx="9.22523" fill="#D9D9D9" stroke="white" stroke-width="1.15315"/>\n </mask>\n <g mask="url(#mask0_24181_220540)">\n <rect x="1.90958" y="0.576577" width="30.8468" height="30.8468" rx="9.22523" fill="#E8E8E8" stroke="white" stroke-width="1.15315"/>\n <path d="M17.9096 6.77445L28.7204 5.33301H32.4681L32.7564 11.8195V23.6393L10.4141 23.9276V10.8105L17.9096 6.77445Z" fill="#97E7C8"/>\n <path d="M-2.70303 10.6664H10.2699M41.6934 5.47722C38.378 5.47722 34.7744 5.47722 27.8555 5.47722C20.9366 5.47722 18.4862 6.63037 15.4591 8.64839C12.4321 10.6664 10.2699 10.6664 10.2699 10.6664M10.2699 34.4502V23.6394M10.2699 10.6664V23.6394M-6.16249 23.6394H10.2699M10.2699 23.6394H21.0807M38.8105 23.6394H21.0807M21.0807 23.6394V34.4502" stroke="white" stroke-width="2.30631"/>\n <rect x="2.34202" y="1.00901" width="29.982" height="29.982" rx="8.79279" stroke="white" stroke-width="2.01802"/>\n </g>\n <g clip-path="url(#clip0_24181_220540)">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M18.069 19.8621C19.4995 18.6902 22.171 16.0948 22.171 13.0548C22.171 11.7333 21.6461 10.466 20.7117 9.5316C19.7773 8.5972 18.51 8.07227 17.1885 8.07227C15.8671 8.07227 14.5998 8.5972 13.6654 9.5316C12.731 10.466 12.2061 11.7333 12.2061 13.0548C12.2061 16.0948 14.8776 18.6902 16.3081 19.8621C16.5553 20.0679 16.8669 20.1806 17.1885 20.1806C17.5102 20.1806 17.8218 20.0679 18.069 19.8621ZM17.1885 14.1618C17.517 14.1618 17.838 14.0644 18.1111 13.8819C18.3842 13.6995 18.597 13.4401 18.7227 13.1367C18.8484 12.8333 18.8812 12.4994 18.8172 12.1773C18.7531 11.8552 18.595 11.5593 18.3627 11.3271C18.1305 11.0948 17.8346 10.9367 17.5125 10.8726C17.1904 10.8085 16.8565 10.8414 16.5531 10.9671C16.2497 11.0928 15.9903 11.3056 15.8079 11.5787C15.6254 11.8518 15.528 12.1728 15.528 12.5012C15.528 12.9416 15.703 13.364 16.0144 13.6754C16.3258 13.9868 16.7481 14.1618 17.1885 14.1618Z" fill="#55575D"/>\n </g>\n </g>\n <defs>\n <filter id="filter0_d_24181_220540" x="-0.000325561" y="0" width="34.6667" height="34.6667" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">\n <feFlood flood-opacity="0" result="BackgroundImageFix"/>\n <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>\n <feOffset dy="1.33333"/>\n <feGaussianBlur stdDeviation="0.666667"/>\n <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.04 0"/>\n <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_24181_220540"/>\n <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_24181_220540" result="shape"/>\n </filter>\n <clipPath id="clip0_24181_220540">\n <rect width="12.1081" height="12.1081" fill="white" transform="translate(11.1338 8.07227)"/>\n </clipPath>\n </defs>\n </svg>\n ',"aria-hidden":"true"}),i("div",{class:"s-bullet-delivery-address-content"},i("div",{class:"s-bullet-delivery-address-lines"},i("span",{class:"s-bullet-delivery-address-line1"},s),i("span",{class:"s-bullet-delivery-address-line2"},o))))}renderMapSection(){const t=p(this.selectedCountry?.code??""),e=this.mapLocationData,s=null!=e?.lat&&null!=e?.lng,o=s?{lat:e.lat,lng:e.lng}:this.mapInitialCenter;return i("div",{class:"s-bullet-delivery-map-container"},i("gmap-map",{ref:t=>this.gmapRef=t,center:o,zoom:16,"min-zoom":4,"max-zoom":21,"map-id":"DEMO_MAP_ID","enable-autocomplete":!0,"enable-geolocation":!0,"show-location-marker":!0,"location-marker-position":s?{lat:e.lat,lng:e.lng,accuracy:50}:{...o,accuracy:50},language:Salla.lang.getLocale?.()??document.documentElement.lang??"ar","geolocation-button-label":Salla.lang.get("pages.checkout.current_location"),"autocomplete-placeholder":Salla.lang.get("pages.checkout.search_for_address"),"autocomplete-hint":t?Salla.lang.get("pages.checkout.short_address_format_validation"):void 0,"autocomplete-country":this.selectedCountry?.code?.toLowerCase(),"autocomplete-resolve":!1,"autocomplete-auth-token":this.addressToken,"location-marker-background":"#4285F4","location-marker-border-color":"#1967D2","location-marker-glyph-color":"#FFFFFF","location-marker-scale":1.3,"onGmap-location-changed":this.handleMapLocationChanged,"onGmap-ready":this.handleMapReady}))}renderAddressConfirmation(){const t=this.mapLocationData?.formattedAddress??"",e=this.mapLocationData?.shortAddress;return i("div",{class:"s-bullet-delivery-address-confirm"},i("div",{class:"s-bullet-delivery-address-confirm-card"},i("div",{class:"s-bullet-delivery-address-confirm-details"},i("span",{class:"s-bullet-delivery-address-confirm-label"},Salla.lang.get("pages.checkout.selected_address")),i("p",{class:"s-bullet-delivery-address-confirm-text"},t),e&&i("span",{class:"s-bullet-delivery-address-confirm-tag"},e,i("span",{class:"s-bullet-delivery-address-confirm-tag-icon",innerHTML:'<svg width="13" height="15" viewBox="0 0 8.97576 11.7781" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M6.2453 8.52122L5.8322 8.24311L5.86126 8.20024L6.27435 8.47694L6.2453 8.52122ZM6.42386 8.25126L6.00758 7.97882C5.96896 8.03798 5.92999 8.0975 5.88995 8.15737L6.30376 8.43372C6.34414 8.37136 6.38489 8.31184 6.42386 8.25126ZM6.63572 7.92213L6.21518 7.65677L6.11244 7.81797L6.5305 8.08723L6.63572 7.92213ZM6.43484 9.81081L5.92538 9.45547C5.32487 10.316 4.76617 11.0388 4.48664 11.3927L4.97413 11.7781C5.25827 11.4182 5.82512 10.6831 6.43484 9.81081ZM3.55487 10.1647C3.44257 10.0113 3.33097 9.85652 3.22327 9.70417L2.717 10.0638C2.82611 10.2179 2.93913 10.3745 3.0525 10.5307L3.55487 10.1647ZM3.11734 9.55006L2.99688 9.37823L2.48707 9.73216L2.60965 9.90753L3.11734 9.55006ZM6.58577 9.59257L6.07206 9.24113L5.95266 9.41402L6.46248 9.76865C6.50499 9.71091 6.54538 9.65174 6.58577 9.59151V9.59257ZM2.96535 9.33607C2.46191 8.60767 2.02898 7.92319 1.68072 7.30887L1.14044 7.61461C1.49933 8.24736 1.94182 8.9453 2.4566 9.68929L2.96535 9.33607ZM7.01161 8.95416L6.49152 8.6144C6.39055 8.7678 6.28533 8.92652 6.17763 9.08453L6.69134 9.43386C6.80329 9.27018 6.911 9.11146 7.01374 8.95486L7.01161 8.95416ZM8.97363 4.48559C8.97434 3.96621 8.88471 3.45073 8.70898 2.96217L8.12442 3.17262C8.27605 3.5935 8.35364 4.03777 8.35293 4.48559C8.35293 4.99505 8.11733 5.71955 7.65216 6.63927L8.2059 6.91916C8.72599 5.89847 8.97576 5.10204 8.97576 4.4863L8.97363 4.48559ZM0.749309 5.26111C0.699001 5.09389 0.661447 4.92313 0.637001 4.75059L0.0216118 4.83208C0.0488916 5.03579 0.0921143 5.23738 0.150217 5.43436L0.749309 5.26111ZM0.621058 4.58443V4.39737L0 4.3832V4.48594C0 4.51995 5.62238e-07 4.5738 0.00389767 4.6188L0.621058 4.58443ZM1.3275 2.25361L0.820874 1.89472C0.314958 2.60824 0.0297605 3.45427 0.000709258 4.32864L0.621058 4.35061C0.645858 3.59705 0.89173 2.86793 1.3275 2.25361ZM8.69233 2.91151C8.66612 2.84065 8.63706 2.76944 8.60766 2.70106L8.03797 2.94835C8.06348 3.00752 8.08792 3.06846 8.11131 3.12939L8.69233 2.91151ZM8.52227 2.51684C8.43264 2.33367 8.33025 2.15689 8.21653 1.98754L7.70282 2.33367C7.80095 2.47928 7.88846 2.63163 7.96534 2.78964L8.52227 2.51684ZM6.33848 0.397516C5.7571 0.13393 5.12577 -0.00140612 4.48735 1.10152e-05C4.25494 1.10152e-05 4.02288 0.0177252 3.79331 0.0531534L3.88825 0.664646C4.08665 0.634178 4.28682 0.618943 4.48735 0.618589C5.0372 0.617526 5.58137 0.73444 6.08197 0.961535L6.33848 0.397516ZM3.47906 0.752862L3.31644 0.150581C3.11946 0.203369 2.92602 0.269974 2.73825 0.349688L2.97987 0.921501C3.14214 0.853125 3.30865 0.796084 3.47835 0.750382L3.47906 0.752862ZM3.84184 0.673858L3.7391 0.061657C3.6647 0.0737026 3.58959 0.0885822 3.51519 0.104525L3.64876 0.710702C3.71182 0.694051 3.77666 0.681651 3.84078 0.671023L3.84184 0.673858ZM4.68149 10.6292C4.68149 10.6253 5.02975 10.2041 5.49138 9.58159L5.08998 9.28293C4.8434 9.6156 4.63083 9.8884 4.4877 10.0705C4.2436 9.76121 3.79791 9.18302 3.32069 8.49819L2.91043 8.78481C3.63494 9.82286 4.28824 10.6218 4.29462 10.6296L4.48735 10.8659L4.68149 10.6292ZM5.57039 9.47318L5.16757 9.17629L5.10344 9.26097L5.50556 9.55821C5.52752 9.52739 5.54843 9.50117 5.56968 9.47212L5.57039 9.47318ZM6.01997 8.85035L5.60759 8.56445C5.48359 8.74123 5.35463 8.92156 5.22213 9.10154L5.62566 9.39772C5.75993 9.21278 5.89137 9.02927 6.0175 8.85L6.01997 8.85035ZM8.12194 4.47708C8.12229 3.76958 7.91539 3.07731 7.52639 2.48601L7.10833 2.76023C7.44419 3.2704 7.62311 3.86807 7.62204 4.47886C7.62204 5.12436 7.14872 6.20669 6.25309 7.60788L6.67434 7.87714C7.63196 6.37108 8.11875 5.2271 8.11875 4.47567L8.12194 4.47708ZM2.68015 7.53667C2.55863 7.34394 2.44314 7.15653 2.33791 6.97584L1.9064 7.22951C2.01481 7.41444 2.13314 7.60788 2.25785 7.8077L2.68015 7.53667ZM2.29009 6.89436L2.23801 6.80366L1.80365 7.05237L1.8568 7.14554L2.29009 6.89436ZM2.22596 6.78205C1.65627 5.78155 1.35513 4.98371 1.35513 4.47567C1.35513 4.17453 1.39835 3.87516 1.48338 3.58642L1.00368 3.44541C0.905193 3.77915 0.854885 4.12528 0.855239 4.47319C0.855239 5.07618 1.16984 5.93567 1.79161 7.02757L2.22596 6.78205ZM7.50867 2.46263C7.48812 2.43181 7.46616 2.39851 7.44455 2.36946L7.03535 2.65465C7.05413 2.68087 7.07326 2.7078 7.09133 2.73508L7.50867 2.46263ZM2.36732 2.17389L2.02579 1.8026C1.85148 1.9638 1.69312 2.14201 1.55389 2.33438L1.95777 2.62985C2.07893 2.46369 2.21604 2.30994 2.36767 2.1707L2.36732 2.17389ZM7.38396 2.28726C7.24012 2.09772 7.07786 1.9227 6.90037 1.76434L6.5677 2.13811C6.7211 2.27415 6.86104 2.42472 6.98504 2.58769L7.38396 2.28726ZM2.50726 2.04848L2.19124 1.66302C2.16183 1.68675 2.13278 1.7112 2.10373 1.73635L2.43286 2.11402C2.45731 2.08993 2.48246 2.06867 2.50726 2.04848ZM4.48664 1.34203C4.8884 1.34133 5.28626 1.41856 5.65861 1.56878L5.84602 1.10431C4.62658 0.613984 3.23744 0.819114 2.21214 1.6414L2.52568 2.03112C3.08084 1.58295 3.77311 1.34026 4.48664 1.3431V1.34203ZM4.72649 9.03245C4.86927 8.82839 5.00708 8.62609 5.13817 8.43053C5.67207 7.64862 6.15567 6.83342 6.58506 5.98987C7.08141 4.98406 7.12463 4.54723 7.12853 4.47035V4.45618C7.12853 2.99689 5.94558 1.81394 4.48628 1.81394C3.02699 1.81394 1.84404 2.99689 1.84404 4.45618V4.47035C1.84404 4.54759 1.89081 4.98406 2.3868 5.98987C2.8169 6.83342 3.3005 7.64862 3.83476 8.43053C3.96336 8.62326 4.10401 8.82874 4.24643 9.03245L4.48522 9.3754L4.72649 9.03245ZM3.0316 3.00362C3.83547 2.19975 5.13887 2.20011 5.94274 3.00398C6.32537 3.3866 6.54183 3.90456 6.54538 4.44555C6.53971 4.49374 6.48125 4.87707 6.06178 5.73018C5.64373 6.55177 5.17289 7.34571 4.6528 8.10671C4.59895 8.18749 4.54368 8.26933 4.48699 8.35223C4.43102 8.26933 4.37504 8.18784 4.32119 8.10671C3.80146 7.34536 3.33061 6.55177 2.91221 5.73018C2.48636 4.86644 2.43357 4.48346 2.42932 4.44555C2.43109 3.90421 2.64791 3.38589 3.0316 3.00362Z" fill="url(#paint0_linear_0_471)"/>\n<defs>\n<linearGradient id="paint0_linear_0_471" x1="-0.000253536" y1="5.88509" x2="8.97608" y2="5.88509" gradientUnits="userSpaceOnUse">\n<stop offset="0.2" stop-color="#4498B6"/>\n<stop offset="0.49" stop-color="#273265"/>\n<stop offset="1" stop-color="#C93732"/>\n</linearGradient>\n</defs>\n</svg>\n'}))),i("button",{type:"button",class:"s-bullet-delivery-address-confirm-edit",onClick:()=>{this.mapStep="map"}},Salla.lang.get("common.elements.edit"))),i("div",{class:"s-bullet-delivery-address-confirm-description"},i("label",{class:"s-bullet-delivery-address-confirm-description-label"},Salla.lang.get("pages.checkout.address_description"),i("span",{class:"s-bullet-delivery-address-confirm-description-optional"},Salla.lang.get("common.elements.optional"))),i("input",{type:"text",class:"s-bullet-delivery-address-confirm-description-input form-input",placeholder:Salla.lang.get("pages.checkout.address_description_placeholder"),value:this.addressDescription,onInput:t=>{this.addressDescription=t.target.value}})))}renderGuestDeliveryForm(){if(this.isMapModeAvailable)return"confirm"===this.mapStep&&this.hasMapLocation()?this.renderAddressConfirmation():this.renderMapSection();const t=p(this.selectedCountry?.code??"");return[this.renderCountrySelect(),t?this.renderRegionSelect():null,this.renderCityDistrictSelects()]}renderDeliveryTab(){return i("div",{class:{"s-bullet-delivery-content":!0,"s-bullet-delivery-content--active":"address"===this.activeTab,"s-hidden":"address"!==this.activeTab}},this.isLoggedIn?this.renderSavedAddresses():this.renderGuestDeliveryContent())}renderGuestDeliveryContent(){if(!this.isMapModeAvailable)return this.renderGuestDeliveryForm();const t=this.hasMapLocation(),e="confirm"===this.mapStep&&t,s=e?this.savingAddress?Salla.lang.get("pages.checkout.loading"):Salla.lang.get("pages.checkout.confirm_address"):Salla.lang.get("pages.checkout.confirm_location");return i("form",{onSubmit:i=>{i.preventDefault(),e||!t?this.handleSubmitAddAddress(i):this.mapStep="confirm"}},this.renderGuestDeliveryForm(),i("div",{class:"s-bullet-delivery-form-actions s-bullet-delivery-form-actions--single",style:{padding:"24px"}},i("salla-button",{type:"submit",loading:this.savingAddress,disabled:!t||this.savingAddress,width:"wide"},s),!this.isLoggedIn&&i("button",{type:"button",class:"s-bullet-delivery-login-prompt",onClick:()=>this.handleLogin()},Salla.lang.get("pages.checkout.login_to_use_saved_addresses"))))}renderBranchSearch(){return i("div",{class:"s-bullet-delivery-branch-search"},i("div",{class:"s-bullet-delivery-search-row"},i("div",{class:"s-bullet-delivery-search s-bullet-delivery-branch-search-wrap"},i("span",{class:"s-bullet-delivery-search-icon s-bullet-delivery-branch-search-icon",innerHTML:a,"aria-hidden":"true"}),i("input",{type:"text",class:"s-bullet-delivery-branch-search-input form-input",placeholder:Salla.lang.get("pages.checkout.search_for_city_or_branch"),value:this.branchSearchQuery,onInput:t=>this.handleBranchSearch(t),autocomplete:"off"})),i("button",{type:"button",class:{"s-bullet-delivery-location-btn":!0,"s-bullet-delivery-location-btn--full":!0,"s-bullet-delivery-location-btn--loading":this.loadingNearestBranch},onClick:()=>this.handleFindNearestBranch(),disabled:this.loadingNearestBranch},this.loadingNearestBranch?i("span",{class:"s-bullet-delivery-location-icon","aria-hidden":"true"},i("salla-skeleton",{height:"18px",width:"18px"})):i("span",{class:"s-bullet-delivery-location-icon",innerHTML:'<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path\n d="M13.3258 7.65006C13.3258 10.7797 10.7888 13.3167 7.65916 13.3167C4.52955 13.3167 1.99249 10.7797 1.99249 7.65006C1.99249 4.52045 4.52955 1.9834 7.65916 1.9834C10.7888 1.9834 13.3258 4.52045 13.3258 7.65006Z"\n stroke="#555555" stroke-width="1.3" />\n <path d="M14.65 7.65039H13.3167" stroke="#555555" stroke-width="1.3" stroke-linecap="round"\n stroke-linejoin="round" />\n <path d="M1.98336 7.65039L0.650024 7.65039" stroke="#555555" stroke-width="1.3"\n stroke-linecap="round" stroke-linejoin="round" />\n <path d="M7.65002 0.650065L7.65002 1.9834" stroke="#555555" stroke-width="1.3"\n stroke-linecap="round" stroke-linejoin="round" />\n <path d="M7.65002 13.3171L7.65002 14.6504" stroke="#555555" stroke-width="1.3"\n stroke-linecap="round" stroke-linejoin="round" />\n <path\n d="M9.64999 7.65039C9.64999 8.75496 8.75456 9.65039 7.64999 9.65039C6.54542 9.65039 5.64999 8.75496 5.64999 7.65039C5.64999 6.54582 6.54542 5.65039 7.64999 5.65039C8.75456 5.65039 9.64999 6.54582 9.64999 7.65039Z"\n stroke="#555555" stroke-width="1.3" />\n</svg>\n ',"aria-hidden":"true"}),i("span",null,Salla.lang.get("pages.checkout.nearest_to_my_location")))),this.locationError&&"branch"===this.activeTab&&i("span",{class:"s-bullet-delivery-error"},this.locationError))}renderBranchList(){return this.loadingBranches?i("div",{class:"s-bullet-delivery-branches-wrap"},i("div",{class:"s-bullet-delivery-branches-loading"},[1,2,3,4].map((t=>i("div",{key:t,class:"s-bullet-delivery-branch-skeleton"},i("salla-skeleton",{class:"s-bullet-delivery-branch-skeleton-radio",type:"circle",height:"16px",width:"16px"}),i("div",{class:"s-bullet-delivery-branch-skeleton-icon"},i("salla-skeleton",{height:"34px",width:"34px"})),i("div",{class:"s-bullet-delivery-branch-skeleton-content"},i("salla-skeleton",{class:"s-bullet-delivery-branch-skeleton-title",height:"12px",width:"124px"})),i("salla-skeleton",{class:"s-bullet-delivery-branch-skeleton-time",height:"12px",width:"88px"}),i("div",{class:"s-bullet-delivery-branch-skeleton-map"},i("salla-skeleton",{height:"32px",width:"32px"}))))))):0===this.filteredBranches.length?i("salla-placeholder",{alignment:"center",class:"s-bullet-delivery-placeholder"},i("span",{slot:"title"},Salla.lang.get("pages.checkout.no_pickup_branches_found"))):i("div",{class:"s-bullet-delivery-branches-wrap"},i("ul",{class:"s-bullet-delivery-branches-list s-scrollbar"},this.filteredBranches.map((t=>i("li",{key:t.id,class:{"s-bullet-delivery-branch-item":!0,"s-bullet-delivery-branch-item--selected":this.selectedBranch?.id===t.id,"s-bullet-delivery-branch-item--disabled":!1===t.is_open},tabIndex:!1===t.is_open?-1:0,role:"option","aria-disabled":!1===t.is_open,onClick:()=>!1!==t.is_open&&this.handleBranchSelect(t),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),!1!==t.is_open&&this.handleBranchSelect(t))}},i("input",{type:"radio",name:"branch",class:"s-bullet-delivery-radio",checked:this.selectedBranch?.id===t.id,disabled:!1===t.is_open}),i("span",{class:"s-bullet-delivery-branch-icon","aria-hidden":"true"},i("span",{innerHTML:Cs})),i("div",{class:"s-bullet-delivery-branch-info"},i("span",{class:"s-bullet-delivery-branch-name"},t.name),t.preparation_time?i("span",{class:"s-bullet-delivery-branch-prep"},`${Salla.lang.get("pages.checkout.processing_time")}: ${t.preparation_time}`):null),(()=>{if(t.always_open)return i("span",{class:"s-bullet-delivery-branch-time"},Salla.lang.get("pages.orders.branch_always_open"));const e=(s=t.working_hours,s?.[0]?.times?.[0]??null);var s;return e?i("span",{class:"s-bullet-delivery-branch-time"},function(t,e,i,s){const o=String(t).trim(),n=String(e).trim();return o&&n?"00:00"===o?`${s} ${v(n,i)}`:`${v(o,i)} - ${v(n,i)}`:""}(e.from,e.to,Salla.config.get("user.language_code")||"ar",Salla.lang.get("pages.checkout.until"))):null})(),null!=t.location?.lat&&null!=t.location?.lng&&i("a",{href:`https://www.google.com/maps?q=${t.location.lat},${t.location.lng}`,target:"_blank",rel:"noopener noreferrer",class:"s-bullet-delivery-branch-map-link",title:Salla.lang.get("common.elements.open_in_google_maps"),onClick:t=>t.stopPropagation()},i("span",{class:"s-bullet-delivery-branch-map-link-icon",innerHTML:'<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path\n d="M7.94798 3.19336C11.1309 2.1083 12.7223 1.56578 13.5783 2.42174C14.4342 3.27771 13.8917 4.86914 12.8066 8.05201L12.0678 10.2195C11.2344 12.6639 10.8178 13.8861 10.131 13.9872C9.94631 14.0144 9.75517 13.9981 9.57248 13.9394C8.89297 13.7212 8.53377 12.4326 7.81538 9.8553C7.65604 9.28364 7.57637 8.99781 7.39494 8.7795C7.34228 8.71614 7.28386 8.65772 7.2205 8.60506C7.00219 8.42363 6.71636 8.34396 6.1447 8.18462C3.56741 7.46623 2.27876 7.10703 2.0606 6.42752C2.00195 6.24483 1.98558 6.05369 2.01277 5.86903C2.11392 5.18221 3.33613 4.76556 5.78054 3.93225L7.94798 3.19336Z"\n stroke="#555555" stroke-width="1.2" />\n</svg>\n '.replace(/mask0_25437_34440/g,`mask0_branch_${t.id}`),"aria-hidden":"true"}),i("span",{class:"sr-only"},Salla.lang.get("common.elements.open_in_google_maps"))))))))}renderPickupTab(){return i("div",{class:{"s-bullet-delivery-content":!0,"s-bullet-delivery-content--active":"branch"===this.activeTab,"s-hidden":"branch"!==this.activeTab}},this.renderCountrySelect(),this.renderBranchSearch(),this.renderBranchList())}renderAddAddressForm(){Salla.lang.get("pages.checkout.add_new_address");const t=this.isMapModeAvailable,e=p(this.selectedCountry?.code??""),s=this.hasMapLocation();let o,n;if(t)"map"===this.mapStep?(o=s,n=Salla.lang.get("pages.checkout.confirm_location")):(o=s,n=this.savingAddress?Salla.lang.get("pages.checkout.loading"):Salla.lang.get("pages.checkout.confirm_address"));else{const t=this.selectedCountry&&this.selectedCity&&(!e||this.selectedRegion)&&(!e||!!this.selectedDistrict||!!(this.districtName&&this.districtName.trim().length>0));o=s||t,n=this.savingAddress?Salla.lang.get("pages.checkout.loading"):Salla.lang.get("pages.checkout.confirm_address")}return this.savedAddresses.length>0||L(this.getStoredIntent()),i("div",{class:"s-bullet-delivery-add-address"},i("form",{class:"s-bullet-delivery-add-address-form",onSubmit:e=>{e.preventDefault(),t&&"map"===this.mapStep&&s?this.mapStep="confirm":this.handleSubmitAddAddress(e)}},this.renderGuestDeliveryForm(),i("div",{class:"s-bullet-delivery-form-actions s-bullet-delivery-form-actions--single"},i("salla-button",{type:"submit",loading:this.savingAddress,disabled:!o||this.savingAddress,class:"s-bullet-delivery-add-address-submit"},n))))}renderFooter(){if("address"===this.activeTab&&!this.isLoggedIn&&this.isMapModeAvailable)return null;const t="address"===this.activeTab&&this.isLoggedIn;return i("div",{class:"s-bullet-delivery-footer"},i("salla-button",{ref:t=>{this.confirmBtn=t},disabled:this.isConfirmDisabled(),onClick:()=>this.handleConfirm(),"loader-position":"center",width:"wide"},"branch"===this.activeTab?Salla.lang.get("pages.checkout.confirm_receipt_from_the_branch"):Salla.lang.get("pages.checkout.confirm_address")),t&&i("salla-button",{onClick:()=>this.handleAddNewAddress(),width:"wide",shape:"link"},Salla.lang.get("pages.checkout.add_new_address")),!this.isLoggedIn&&i("salla-button",{shape:"link",onClick:this.handleLogin},Salla.lang.get("pages.checkout.login_to_use_saved_addresses")))}renderMainView(){const t=this.isLoggedIn&&"address"===this.activeTab&&0===this.savedAddresses.length&&!L(this.getStoredIntent()),e="branch"===this.activeTab&&this.supportsPickup?this.renderPickupTab():this.renderDeliveryTab();return i("div",null,this.showCartWillBeClearedBanner&&this.renderAlert(Salla.lang.get("blocks.scope.empty_cart_warning")),this.allocationOutOfCoverageMessage&&this.renderAllocationOutOfCoverageAlert(),e,!t&&this.renderFooter())}handleAfterAddToCart(){if("after_add_to_cart"!==this.openingType)return;const t=this.shouldPromptIncompleteIntentThisSession();this.hasBeenShownThisSession()&&!t||this.modal?.hasAttribute?.("visible")||(t&&this.markIncompleteIntentPrompted(),this.open())}overrideScopeSwitchUI(){const t=this.getStoredIntent(),e=document.querySelector('[onclick*="scopes"]');if(!e)return;if(!t||"address"!==t.type&&"branch"!==t.type)return e.style.display="none",void(e.onclick=()=>this.open());const i=(t,e)=>t&&t.length>e?`${t.slice(0,e)}...`:t??"",s="branch"===t.type?`${Salla.lang.get("mobile_app.strings.pickup")} ${Salla.lang.get("common.elements.from")} ${i(t.branch_details?.name,20)}`:`${Salla.lang.get("mobile_app.strings.delivery")} ${Salla.lang.get("common.elements.to")} ${i(t.address_details?.city?.name,10)}`;e.style.display="inline-flex",e.onclick=()=>this.open();const o=e.querySelector('span:not([class*="sicon"]):not([class*="icon"])');if(o)o.textContent=s;else{const t=Array.from(e.childNodes).find((t=>t.nodeType===Node.TEXT_NODE&&t.textContent?.trim()));t&&(t.textContent=` ${s}`)}}async componentWillLoad(){await Salla.onReady();try{this.overrideScopeSwitchUI(),this.cartSubmittingHandler=async()=>{this.pendingCartSubmitPromise?await this.pendingCartSubmitPromise:this.hasCompleteIntentForLoggedInUser()||(this.cartSubmitConfirmationPending=!0,this.pendingCartSubmitPromise=new Promise((t=>{if(this.pendingCartSubmitResolver=t,this.isGuestUser())return Salla.auth.setCanRedirect(!1),void Salla.event.dispatch("login::open",{withoutReload:!0,source:"cart-submit"});this.open()})),await this.pendingCartSubmitPromise)},Salla.cart.event.onSubmitting(this.cartSubmittingHandler)}catch(t){console.warn("SallaBulletDelivery: overrideScopeSwitchUI failed",t)}Salla.event.on("salla::bullet-delivery.modal.open.requested",this.bulletDeliveryOpenHandler),this.closeHandler=this.close.bind(this),Salla.event.on("salla::bullet-delivery.modal.close.requested",this.closeHandler),this.isRTL=Salla.config.get("theme.is_rtl"),this.authLoggedInHandler=()=>{if(this.cartSubmitConfirmationPending)return Salla.event.dispatch("login::close"),this.hasCompleteIntentForLoggedInUser()?void this.resolvePendingCartSubmit():void(this.modal?.hasAttribute?.("visible")||this.open());this.hasIncompleteUserAddressIntent()&&(this.modal?.hasAttribute?.("visible")||this.open())},Salla.event.on("auth::logged.in",this.authLoggedInHandler),this.authLoggedOutHandler=()=>{this.clearBulletDeliveryStoredData()},Salla.event.on("auth::logged.out",this.authLoggedOutHandler),this.loginClosedHandler=()=>{this.cartSubmitConfirmationPending&&this.isGuestUser()&&(this.hasCompleteIntentForLoggedInUser()||this.resolvePendingCartSubmit())},Salla.event.on("salla-login::closed",this.loginClosedHandler),this.cartItemAddedHandler=()=>this.handleAfterAddToCart(),"function"==typeof Salla.cart?.event?.onItemAdded?(this.useCartEventApi=!0,Salla.cart.event.onItemAdded(this.cartItemAddedHandler)):Salla.event.on(this.cartItemAddedEvent,this.cartItemAddedHandler)}render(){return this.isMobileApp?null:i(s,{class:"s-bullet-delivery"},i("salla-modal",{ref:t=>{this.modal=t},isClosable:!this.isRequired&&!this.shouldForceNonClosable(),class:"s-bullet-delivery-modal",width:"sm"},i("div",{class:"s-bullet-delivery-inner"},i("div",{class:"s-bullet-delivery-header"},i("h2",{class:"s-bullet-delivery-title"},"address"===this.activeTab?Salla.lang.get("blocks.home.add_address_for_order_delivery"):Salla.lang.get("blocks.home.choose_branch_for_order_pickup")),i("p",{class:"s-bullet-delivery-subtitle"},"address"===this.activeTab?Salla.lang.get("blocks.home.products_available_for_delivery_shown_while_shopping"):Salla.lang.get("blocks.home.choose_branch_for_order_pickup_description"))),this.renderTabs(),"main"===this.viewMode&&this.renderMainView(),"add-address"===this.viewMode&&this.renderAddAddressForm())))}componentDidLoad(){if(this.componentReady=!0,this.isMobileApp)return this.hasBeenShownThisSession()||Salla.event.dispatch("salla::bullet-delivery.open-sheet"),this.bulletDeliveryMobileSelectHandler=t=>{const e=this.extractMobileSelectPayload(t);e?this.applyMobileBulletDeliverySelection(e):console.warn("SallaBulletDelivery: received empty mobile select payload",t)},void Salla.event.on("salla::bullet-delivery.select",this.bulletDeliveryMobileSelectHandler);if(this.pendingOpen)return this.pendingOpen=!1,void this.open();switch(this.openingType){case"first_visit":this.hasBeenShownThisSession()?this.shouldPromptIncompleteIntentThisSession()&&(this.markIncompleteIntentPrompted(),this.open()):this.open();break;case"on_cart_click":Salla.url.is_page("cart")&&(!0===this.getShownStorage().get(this.sessionShownKey)?this.shouldPromptIncompleteIntentThisSession()&&(this.markIncompleteIntentPrompted(),this.open()):this.open())}const t=this.createCartViewElement();t&&"function"==typeof salla?.hooks?.mount&&Salla.hooks.mount("cart:items.start",t).catch((()=>{}))}disconnectedCallback(){this.componentReady=!1,Salla.event.off("salla::bullet-delivery.modal.open.requested",this.bulletDeliveryOpenHandler),this.closeHandler&&(Salla.event.off("salla::bullet-delivery.modal.close.requested",this.closeHandler),this.closeHandler=null),this.cartItemAddedHandler&&(this.useCartEventApi&&"function"==typeof Salla.cart?.event?.offItemAdded?Salla.cart.event.offItemAdded(this.cartItemAddedHandler):Salla.event.off(this.cartItemAddedEvent,this.cartItemAddedHandler),this.cartItemAddedHandler=null),this.cartSubmittingHandler&&("function"==typeof Salla.cart?.event?.offSubmitting?Salla.cart.event.offSubmitting(this.cartSubmittingHandler):Salla.event.off("cart::submitting",this.cartSubmittingHandler),this.cartSubmittingHandler=null),this.authLoggedInHandler&&(Salla.event.off("auth::logged.in",this.authLoggedInHandler),this.authLoggedInHandler=null),this.authLoggedOutHandler&&(Salla.event.off("auth::logged.out",this.authLoggedOutHandler),this.authLoggedOutHandler=null),this.loginClosedHandler&&(Salla.event.off("salla-login::closed",this.loginClosedHandler),this.loginClosedHandler=null),this.bulletDeliveryMobileSelectHandler&&(Salla.event.off("salla::bullet-delivery.select",this.bulletDeliveryMobileSelectHandler),this.bulletDeliveryMobileSelectHandler=null)}};$s.INITIAL_ADDRESS_FORM={country_id:0,is_default:!1,city_id:void 0,district_id:void 0,street:void 0,building_number:void 0,additional_number:void 0,postal_code:void 0,description:void 0},$s.DROPDOWN_SEARCH_DEBOUNCE_MS=400,$s.DROPDOWN_SEARCH_MIN_CHARS=2,$s.style="@supports (interpolate-size: allow-keywords) and (block-size: calc-size(auto, size)) {\n .s-bullet-delivery .s-bullet-delivery-modal .s-modal-body, .s-bullet-delivery-inner {\n @apply [interpolate-size:allow-keywords];\n }\n .s-bullet-delivery .s-bullet-delivery-modal .s-modal-body {\n @apply [overflow:clip] [transition:block-size_500ms_ease];\n }\n .s-bullet-delivery-inner {\n @apply [overflow:clip] [transition:block-size_500ms_ease];\n block-size: calc-size(auto, size);\n }\n}\n\n/* Allow searchable dropdown popover to paint outside the modal body */\n.s-bullet-delivery .s-bullet-delivery-modal .s-modal-body:has(.s-searchable-dropdown--open) {\n overflow: visible !important;\n}\n\n.s-bullet-delivery-map-container {\n width: 100%;\n height: 450px;\n border-radius: 8px;\n overflow: hidden;\n margin-bottom: 12px;\n}\n.s-bullet-delivery-map-container gmap-map {\n display: block;\n width: 100%;\n height: 100%;\n}\n\n.s-bullet-delivery-address-confirm {\n display: flex;\n flex-direction: column;\n gap: 20px;\n padding: 0 24px;\n}\n\n.s-bullet-delivery-address-confirm-card {\n display: flex;\n align-items: flex-start;\n gap: 12px;\n}\n\n.s-bullet-delivery-address-confirm-edit {\n border: 1px solid #eee;\n border-radius: 8px;\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 500;\n line-height: 1;\n color: #333;\n background: white;\n cursor: pointer;\n white-space: nowrap;\n height: 32px;\n flex-shrink: 0;\n align-self: center;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n}\n\n.s-bullet-delivery-address-confirm-details {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 4px;\n flex: 1;\n min-width: 0;\n}\n\n.s-bullet-delivery-address-confirm-label {\n font-size: 12px;\n color: #666;\n}\n\n.s-bullet-delivery-address-confirm-text {\n font-size: 14px;\n font-weight: 700;\n color: #333;\n margin: 0;\n word-break: break-word;\n}\n\n.s-bullet-delivery-address-confirm-tag {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n border: 1px solid #eee;\n border-radius: 140px;\n padding: 4px 8px;\n font-size: 12px;\n color: #333;\n margin-top: 4px;\n}\n\n.s-bullet-delivery-address-confirm-tag-icon {\n width: 9px;\n display: inline-flex;\n flex-shrink: 0;\n}\n.s-bullet-delivery-address-confirm-tag-icon svg {\n width: 100%;\n height: 100%;\n}\n\n.s-bullet-delivery-address-confirm-description {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.s-bullet-delivery-address-confirm-description-label {\n font-size: 14px;\n font-weight: 500;\n color: #444;\n}\n\n.s-bullet-delivery-address-confirm-description-optional {\n font-weight: 400;\n color: #999;\n margin-inline-start: 4px;\n}\n\n.s-bullet-delivery-address-confirm-description-input {\n width: 100%;\n border: 1px solid #eee;\n border-radius: 8px;\n padding: 10px 12px;\n font-size: 14px;\n}\n\n.s-bullet-delivery-login-prompt {\n display: block;\n width: 100%;\n text-align: center;\n background: none;\n border: none;\n color: var(--color-primary, #004956);\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n padding: 12px 0;\n}\n\n@keyframes s-bullet-delivery-fade-in {\n from {\n opacity: 0;\n transform: translateY(6px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}";const Ms=class{constructor(i){t(this,i),this.itemSelected=e(this,"itemSelected"),this.searchInput=e(this,"searchInput"),this.dropdownOpened=e(this,"dropdownOpened"),this.dropdownClosed=e(this,"dropdownClosed"),this.placeholder="",this.items=[],this.selectedItem=null,this.loading=!1,this.searching=!1,this.disabled=!1,this.required=!1,this.noResultsText="",this.inputId="",this.searchQuery="",this.clientSearch=!1,this.dropUp=!1,this.searchable=!0,this.keepParentScroll=!1,this.isOpen=!1,this.focusedIndex=-1,this.clientSearchQuery="",this.scrollableAncestor=null,this.handleTriggerClick=()=>{this.isOpen?this.close():this.open()},this.handleTriggerKeyDown=t=>{this.isOpen?this.navigateItems(t):"Enter"===t.key||" "===t.key||"ArrowDown"===t.key?(t.preventDefault(),this.open()):"Escape"===t.key&&this.close()},this.handleSearchInputChange=t=>{const e=t.target.value;this.clientSearch&&(this.clientSearchQuery=e),this.searchInput.emit(e),this.focusedIndex=-1},this.handleSearchKeyDown=t=>{this.navigateItems(t)}}connectedCallback(){this.boundHandleClickOutside=this.handleClickOutside.bind(this),document.addEventListener("mousedown",this.boundHandleClickOutside)}disconnectedCallback(){document.removeEventListener("mousedown",this.boundHandleClickOutside),this.scrollableAncestor&&(this.scrollableAncestor.style.overflow="",this.scrollableAncestor=null)}onItemsChange(){this.focusedIndex=-1}normalizeArabic(t){return t.replace(/[أإآا]/g,"ا")}get filteredItems(){if(!this.clientSearch||!this.clientSearchQuery.trim())return this.items;const t=this.normalizeArabic(this.clientSearchQuery.trim().toLowerCase());return this.items.filter((e=>{const i=this.normalizeArabic(e.name.toLowerCase()),s=e.name_en?e.name_en.toLowerCase():"";return i.includes(t)||s.includes(t)}))}getDisplayName(t){const e=salla?.config?.get("user.language_code");return e&&"ar"!==e&&t.name_en?.trim()?t.name_en.trim():t.name}handleClickOutside(t){this.isOpen&&(this.host.contains(t.target)||this.close())}findScrollableAncestor(){let t=this.host.parentElement;for(;t;){const e=getComputedStyle(t),i=e.overflowY;if("auto"===i||"scroll"===i||"hidden"===i||"clip"===e.overflow)return t;t=t.parentElement}return null}open(){this.disabled||this.loading||(this.isOpen=!0,this.focusedIndex=-1,this.keepParentScroll||(this.scrollableAncestor=this.findScrollableAncestor(),this.scrollableAncestor&&(this.scrollableAncestor.style.overflow="visible")),this.dropdownOpened.emit(),requestAnimationFrame((()=>this.searchInputRef?.focus())))}close(){this.isOpen&&(this.isOpen=!1,this.focusedIndex=-1,this.clientSearchQuery="",this.scrollableAncestor&&(this.scrollableAncestor.style.overflow="",this.scrollableAncestor=null),this.dropdownClosed.emit())}navigateItems(t){const e=this.filteredItems,i=e.length;switch(t.key){case"ArrowDown":t.preventDefault(),this.focusedIndex=i>0?(this.focusedIndex+1)%i:-1,this.scrollFocusedIntoView();break;case"ArrowUp":t.preventDefault(),this.focusedIndex=i>0?(this.focusedIndex-1+i)%i:-1,this.scrollFocusedIntoView();break;case"Enter":t.preventDefault(),this.focusedIndex>=0&&this.focusedIndex<i&&this.selectItem(e[this.focusedIndex]);break;case"Escape":t.preventDefault(),this.close()}}scrollFocusedIntoView(){this.focusedIndex<0||requestAnimationFrame((()=>{const t=this.panelRef?.querySelector(".s-searchable-dropdown-list"),e=t?.children[this.focusedIndex];e?.scrollIntoView({block:"nearest"})}))}selectItem(t){this.itemSelected.emit(t),this.close()}render(){const t=null!=this.selectedItem,e=`${this.inputId}-listbox`;return i(s,{key:"e95aedae8c83fe27ef5e94065bd34a0c105ab565",class:"s-searchable-dropdown"},i("div",{key:"3bd95a9a3652934d7a0904b6813f372a517dc415",class:{"s-searchable-dropdown":!0,"s-searchable-dropdown--open":this.isOpen}},this.label&&i("label",{key:"85b95c812b9aa2c496b394a750c362d69c50546a",class:"s-searchable-dropdown-label",htmlFor:this.inputId},this.label,this.required&&i("span",{key:"a863108db25faffd654d2a49832c9ab78c4d3124",class:"s-searchable-dropdown-required"}," *")),i("div",{key:"fb3ce40726d9b5f0060d1279bd0a17339da978b1",class:{"s-searchable-dropdown-trigger":!0,"s-searchable-dropdown-trigger--disabled":this.disabled||this.loading,"s-searchable-dropdown-trigger--open":this.isOpen},role:"combobox","aria-expanded":this.isOpen?"true":"false","aria-haspopup":"listbox","aria-controls":e,"aria-disabled":this.disabled||this.loading?"true":"false",tabIndex:this.disabled||this.loading?-1:0,onClick:this.handleTriggerClick,onKeyDown:this.handleTriggerKeyDown},t?i("span",{class:"s-searchable-dropdown-trigger-text"},this.getDisplayName(this.selectedItem)):i("span",{class:"s-searchable-dropdown-trigger-placeholder"},this.placeholder),i("i",{key:"493e615e79b3483aca3bf2b40c45b8be38190788",class:{"sicon-keyboard_arrow_down":!0,"s-searchable-dropdown-trigger-icon":!0,"s-searchable-dropdown-trigger-icon--open":this.isOpen},"aria-hidden":"true"})),this.isOpen&&i("div",{key:"db839d1fcc73c7bc68cd324ca2e8c91f42bb991c",class:{"s-searchable-dropdown-panel":!0,"s-searchable-dropdown-panel--up":this.dropUp},ref:t=>this.panelRef=t},this.searchable&&i("div",{key:"d3b91389e90e87345672cd7ec630b555114372b2",class:"s-searchable-dropdown-search-wrap"},i("i",{key:"67d56ff8ad837b683d12fb750ccee6412bd8de4c",class:"sicon-search s-searchable-dropdown-search-icon","aria-hidden":"true"}),i("input",{key:"f400a683b9b54ae8e448279ce19130cb346dcc5f",ref:t=>this.searchInputRef=t,id:this.inputId,type:"text",class:"s-searchable-dropdown-search-input",placeholder:this.placeholder,value:this.clientSearch?this.clientSearchQuery:this.searchQuery,onInput:this.handleSearchInputChange,onKeyDown:this.handleSearchKeyDown,autocomplete:"off","aria-autocomplete":"list","aria-expanded":this.isOpen?"true":"false","aria-controls":e})),i("div",{key:"75bd2f369824326cb1ef87c5f3dad2e80975f4d9",id:e,class:"s-searchable-dropdown-list s-scrollbar",role:"listbox"},this.renderListContent()))))}renderListContent(){if(this.searching||this.loading)return i("div",{class:"s-searchable-dropdown-loading"},i("svg",{class:"s-searchable-dropdown-spinner",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round",opacity:"0.25"}),i("path",{d:"M12 2a10 10 0 0 1 10 10",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round"})));const t=this.filteredItems;return 0===t.length?i("div",{class:"s-searchable-dropdown-empty"},this.noResultsText||salla?.lang?.get("common.elements.no_options")||"No results found"):t.map(((t,e)=>{const s=this.selectedItem?.id===t.id;return i("button",{key:t.id,type:"button",role:"option",class:{"s-searchable-dropdown-item":!0,"s-searchable-dropdown-item--selected":s,"s-searchable-dropdown-item--focused":this.focusedIndex===e&&!s},"aria-selected":s?"true":"false",onClick:()=>this.selectItem(t)},i("span",{class:{"s-searchable-dropdown-item-name":!0,"s-searchable-dropdown-item-name--selected":s}},this.getDisplayName(t)),s&&i("i",{class:"sicon-check s-searchable-dropdown-item-check","aria-hidden":"true"}))}))}get host(){return o(this)}static get watchers(){return{items:["onItemsChange"]}}};export{$s as salla_bullet_delivery,Ms as salla_searchable_dropdown}
|
|
1019
|
+
`,Ss([zi({type:Object})],ks.prototype,"position",2),Ss([zi({type:String})],ks.prototype,"pano",2),Ss([zi({type:Number})],ks.prototype,"zoom",2),Ss([zi({type:Object})],ks.prototype,"pov",2),Ss([zi({type:Boolean})],ks.prototype,"visible",2),Ss([zi({type:Boolean})],ks.prototype,"motionTracking",2),Ss([zi({type:Object})],ks.prototype,"options",2),Ss([Pi(".panorama")],ks.prototype,"panoramaElement",2),Ss([Ii()],ks.prototype,"panorama",2),ks=Ss([li("gmap-street-view-panorama")],ks);var Cs='<svg width="15" height="14" viewBox="0 0 15 14" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path\n d="M1.14453 5.83032L1.14453 9.16486C1.14453 11.0511 1.14453 11.9943 1.73032 12.5803C2.3161 13.1663 3.25891 13.1663 5.14453 13.1663L9.14453 13.1663C11.0301 13.1663 11.9729 13.1663 12.5587 12.5803C13.1445 11.9943 13.1445 11.0511 13.1445 9.16486V5.83032"\n stroke="currentcolor" stroke-linecap="round" />\n <path\n d="M9.14453 10.1619C8.68846 10.5667 7.9624 10.8285 7.14453 10.8285C6.32666 10.8285 5.60059 10.5667 5.14453 10.1619"\n stroke="currentcolor" stroke-linecap="round" />\n <path\n d="M5.90256 4.44533C5.71455 5.12426 5.03086 6.29542 3.73185 6.46516C2.58488 6.61502 1.71497 6.11437 1.49277 5.90504C1.24779 5.7353 0.689441 5.19216 0.552703 4.85269C0.415966 4.51322 0.575492 3.77771 0.689441 3.47785L1.14495 2.15892C1.25615 1.82765 1.51646 1.04411 1.78334 0.779094C2.05022 0.514073 2.59054 0.502543 2.81294 0.502543L7.48329 0.502543C8.68543 0.519525 11.3139 0.491824 11.8335 0.502545C12.3532 0.513266 12.6654 0.948828 12.7565 1.13553C13.5318 3.01341 13.8333 4.08889 13.8333 4.54717C13.7321 5.03605 13.3133 5.95787 11.8335 6.36332C10.2956 6.7847 9.42363 5.96509 9.15007 5.65043M5.27015 5.65044C5.48665 5.91635 6.16578 6.45158 7.15029 6.46516C8.1348 6.47873 8.98485 5.79188 9.28681 5.44676C9.37227 5.34492 9.55687 5.04279 9.7483 4.44533"\n stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" />\n</svg>\n ';const xs={lat:24.7756042,lng:46.7360729},_s="salla-bullet-delivery-override-ip";function As(t,e){localStorage.getItem("salla-bullet-delivery-debug")&&(void 0!==e?console.log(t,e):console.log(t))}const $s=class{constructor(i){t(this,i),this.bulletDeliveryConfirmed=e(this,"bulletDeliveryConfirmed"),this.bulletDeliveryClosed=e(this,"bulletDeliveryClosed"),this.addressCreated=e(this,"addressCreated"),this.headerContextUpdate=e(this,"headerContextUpdate"),this.confirming=!1,this.pendingCartSubmitResolver=null,this.pendingCartSubmitPromise=null,this.cartSubmitConfirmationPending=!1,this.branchSearchDebounceTimer=null,this.countrySearchTimer=null,this.regionSearchTimer=null,this.citySearchTimer=null,this.districtSearchTimer=null,this.citySearchCounter=0,this.componentReady=!1,this.pendingOpen=!1,this.tabChanging=!1,this.intentStorageKey="bullet_delivery_intent",this.sessionShownKey="bullet_delivery_shown",this.incompleteIntentPromptKey="bullet_delivery_incomplete_intent_prompted",this.cartItemAddedEvent="cart::item.added",this.cartItemAddedHandler=null,this.cartSubmittingHandler=null,this.useCartEventApi=!1,this.authLoggedInHandler=null,this.authLoggedOutHandler=null,this.loginClosedHandler=null,this.hasExplicitPreselectedIdsForOpen=!1,this.bulletDeliveryOpenHandler=t=>{this.preselectedAddressId=t?.preselected_address_id,this.preselectedBranchId=t?.preselected_branch_id,this.hasExplicitPreselectedIdsForOpen=null!=t?.preselected_address_id||null!=t?.preselected_branch_id,this.open()},this.closeHandler=null,this.bulletDeliveryMobileSelectHandler=null,this.savedAddressesLoaded=!1,this.gmapRef=null,this.autoGeolocationTriggered=!1,this.activeTab="address",this.isLoggedIn=!1,this.viewMode="main",this.countries=[],this.regions=[],this.cities=[],this.districts=[],this.loadingRegions=!1,this.selectedCountry=null,this.selectedRegion=null,this.selectedCity=null,this.selectedDistrict=null,this.districtName="",this.savedAddresses=[],this.selectedSavedAddress=null,this.selectedSessionAddress=!1,this.branches=[],this.filteredBranches=[],this.selectedBranch=null,this.branchSearchQuery="",this.loadingCountries=!1,this.loadingCities=!1,this.loadingDistricts=!1,this.loadingBranches=!1,this.loadingNearestBranch=!1,this.locationError="",this.savingAddress=!1,this.loadingSavedAddresses=!1,this.showCartWillBeClearedBanner=!1,this.countrySearchQuery="",this.regionSearchQuery="",this.citySearchQuery="",this.districtSearchQuery="",this.searchingCountries=!1,this.searchingRegions=!1,this.searchingCities=!1,this.searchingDistricts=!1,this.displayedCountries=[],this.displayedRegions=[],this.displayedCities=[],this.displayedDistricts=[],this.allocationOutOfCoverageMessage=null,this.mapLocationData=null,this.addressToken=null,this.loadingToken=!1,this.mapReady=!1,this.mapStep="map",this.addressDescription="",this.newAddressForm={...$s.INITIAL_ADDRESS_FORM},this.handleCountrySearch=t=>{this.countrySearchQuery=t},this.handleRegionSearch=t=>{this.regionSearchQuery=t},this.handleCitySearch=t=>{if(this.citySearchQuery=t,this.citySearchTimer&&clearTimeout(this.citySearchTimer),!t.trim())return this.displayedCities=this.cities,void(this.searchingCities=!1);if(t.trim().length<$s.DROPDOWN_SEARCH_MIN_CHARS)return;const e=++this.citySearchCounter;this.citySearchTimer=setTimeout((async()=>{this.searchingCities=!0;try{const i=p(this.selectedCountry?.code??"")?this.selectedRegion?.id:void 0,s=await m.getCities(this.selectedCountry?.id,i,t);e===this.citySearchCounter&&(this.displayedCities=s)}catch{e===this.citySearchCounter&&(this.displayedCities=this.cities)}finally{e===this.citySearchCounter&&(this.searchingCities=!1)}}),$s.DROPDOWN_SEARCH_DEBOUNCE_MS)},this.handleDistrictSearch=t=>{this.districtSearchQuery=t},this.handleCountryDropdownClosed=()=>{this.countrySearchQuery="",this.displayedCountries=this.countries,this.searchingCountries=!1},this.handleRegionDropdownClosed=()=>{this.regionSearchQuery="",this.displayedRegions=this.regions,this.searchingRegions=!1},this.handleCityDropdownClosed=()=>{this.citySearchQuery="",this.citySearchTimer&&(clearTimeout(this.citySearchTimer),this.citySearchTimer=null),++this.citySearchCounter,this.displayedCities=this.cities,this.searchingCities=!1},this.handleDistrictDropdownClosed=()=>{this.districtSearchQuery="",this.displayedDistricts=this.districts,this.searchingDistricts=!1},this.handleMapLocationChanged=t=>{const e=t.detail;e?.position?.lat&&e?.position?.lng&&(this.mapLocationData={lat:e.position.lat,lng:e.position.lng,shortAddress:e.place?.placeId??e.place?.place_id??void 0,formattedAddress:e.place?.formattedAddress??e.place?.formatted_address??void 0},this.updateLocationBias(),setTimeout((()=>{const t=this.gmapRef?.locationMarker;t&&(t.gmpDraggable=!1)}),100))},this.handleMapReady=()=>{if(this.mapReady=!0,this.gmapRef&&"function"==typeof this.gmapRef.resize&&this.gmapRef.resize(),this.updateLocationBias(),!this.autoGeolocationTriggered&&!this.hasMapLocation()&&this.gmapRef){const t=this.gmapRef.getCurrentLocation;if("function"==typeof t){this.autoGeolocationTriggered=!0;try{const e=t.call(this.gmapRef,!0);e&&"function"==typeof e.catch&&e.catch((t=>As("Auto geolocation failed",t)))}catch(t){As("Auto geolocation threw",t)}}}},this.handleSubmitAddAddress=async t=>{if(t.preventDefault(),this.savingAddress)return;const e=this.hasMapLocation();if((e||this.selectedCountry&&this.selectedCity)&&(e||E(this.selectedCountry?.code,this.selectedRegion?.id,this.selectedDistrict?.id??(this.districtName?.trim()||null)))){this.savingAddress=!0;try{const t=this.buildAddressLocationPayload(),{success:e,address:i}=await m.saveAddressLocation(t);if(e){await this.loadSavedAddresses();const t=i??this.savedAddresses[0]??null;t?.is_in_coverage&&(this.selectedSessionAddress=!1,this.selectedSavedAddress=t),this.addressCreated.emit({address:t}),this.viewMode="main",this.districtName="",this.mapLocationData=null,this.mapStep="map",this.addressDescription=""}else this.isLoggedIn?Salla.notify?.error(Salla.lang.get("common.errors.error_occurred")):(Salla.notify?.error(Salla.lang.get("pages.checkout.login_to_use_saved_addresses")),this.handleLogin())}catch(t){console.error("SallaBulletDelivery: Error saving address",t),this.isLoggedIn?Salla.notify?.error(Salla.lang.get("common.errors.error_occurred")):(Salla.notify?.error(Salla.lang.get("pages.checkout.login_to_use_saved_addresses")),this.handleLogin())}finally{this.savingAddress=!1}}},this.handleCountrySelected=t=>{const e=this.countries.find((e=>String(e.id)===String(t.id)))||t;this.countrySearchQuery="",this.displayedCountries=this.countries,this.applyCountryChange(e||null)},this.handleRegionSelected=t=>{const e=this.regions.find((e=>String(e.id)===String(t.id)))||t;this.selectedRegion=e||null,this.regionSearchQuery="",this.displayedRegions=this.regions,this.updateNewAddressForm({region_id:e?.id,city_id:void 0,district_id:void 0,city:void 0,district:void 0}),e&&this.selectedCountry&&this.loadCities(this.selectedCountry.id,e.id)},this.handleCitySelected=t=>{const e=p(this.selectedCountry?.code??""),i=this.cities.find((e=>String(e.id)===String(t.id)))||t;this.selectedCity=i||null,this.selectedDistrict=null,this.districtName="",this.citySearchQuery="",this.displayedCities=this.cities,i&&(this.updateNewAddressForm({city:i,district:void 0}),e&&this.loadDistricts(i.id))},this.handleDistrictSelected=t=>{const e=this.districts.find((e=>String(e.id)===String(t.id)))||t;this.selectedDistrict=e||null,this.districtName="",this.districtSearchQuery="",this.displayedDistricts=this.districts,e&&this.updateNewAddressForm({district:e})}}get supportsPickup(){return Boolean(Salla.config.get("store.shipping.support_pickup"))||Boolean(Salla.config.get("store.support_pickup"))}get openingType(){return Salla.config.get("store.settings.bullet_delivery.settings.type")}get isRequired(){return!!Salla.config.get("store.settings.bullet_delivery.settings.is_required")}get isSupportsDelivery(){return!!Salla.config.get("store.settings.bullet_delivery.supports_delivery")}get isMobileApp(){return Salla.config.isMobileApp()}async open(){if(this.isMobileApp)Salla.event.dispatch("salla::bullet-delivery.open-sheet");else if(this.componentReady&&this.modal){this.resetState(),this.modal.open(),Salla.event.dispatch("salla::bullet-delivery.modal.opened");try{this.isLoggedIn=!this.isGuestUser();const t=this.cleanStaleGuestAddressIdIfNeeded(this.getStoredIntent());this.applyPreselectedIdsFromIntent(t);const e=!this.isLoggedIn&&"address"===t?.type&&null!=S(t)&&null!=x(t);if(this.activeTab=this.supportsPickup&&t?.type&&("address"===t.type||"branch"===t.type)?t.type:"address",this.fetchAddressToken(),this.isLoggedIn&&"address"===this.activeTab&&(this.loadingSavedAddresses=!0),await Promise.all([this.loadCountries(e),this.isLoggedIn&&"address"===this.activeTab?this.loadSavedAddresses().then((()=>{this.savedAddressesLoaded=!0})).finally((()=>{this.loadingSavedAddresses=!1})):Promise.resolve()]),this.isLoggedIn&&this.preselectedAddressId){const t=this.savedAddresses.find((t=>t.id===this.preselectedAddressId));t&&(this.selectedSessionAddress=!1,this.selectedSavedAddress=t)}if("branch"===this.activeTab){const e=$(t),i=M(t);if(null!=e&&null!=i?await this.loadBranchesWithLocation(e,i):await this.loadBranches(),this.preselectedBranchId){const t=this.branches.find((t=>t.id===this.preselectedBranchId));t&&(this.selectedBranch=t)}}await this.prefillFromSessionStorage()}catch(t){console.error("SallaBulletDelivery: Error loading data",t)}finally{this.overrideScopeSwitchUI()}}else this.pendingOpen=!0}async close(){if(!this.shouldForceNonClosable()||this.confirming)return this.cartSubmitConfirmationPending&&!this.confirming&&this.resolvePendingCartSubmit(),this.bulletDeliveryClosed.emit(),this.modal?.close()}resetState(){this.viewMode="main",this.autoGeolocationTriggered=!1,this.selectedCountry=null,this.selectedRegion=null,this.selectedCity=null,this.selectedDistrict=null,this.districtName="",this.selectedSavedAddress=null,this.selectedSessionAddress=!1,this.selectedBranch=null,this.branchSearchQuery="",this.regions=[],this.cities=[],this.districts=[],this.branches=[],this.filteredBranches=[],this.newAddressForm={...$s.INITIAL_ADDRESS_FORM},this.showCartWillBeClearedBanner=!1,this.allocationOutOfCoverageMessage=null,this.locationError="",this.savedAddressesLoaded=!1,this.loadingSavedAddresses=!1,this.loadingCountries=!1,this.resetSearchState()}getIntentStorage(){const t=Boolean(Salla.config.get("store.settings.bullet_delivery.settings.remember_last_session"));return Salla.storage[t?"store":"session"]}getShownStorage(){return Salla.storage.session}getStoredIntent(){return this.getIntentStorage().get(this.intentStorageKey)}isGuestUser(){return"guest"===String(Salla.config.get("user.type")??"guest")}cleanStaleGuestAddressIdIfNeeded(t){if(!this.isGuestUser()||"address"!==t?.type||!t.address_id)return t;const e={...t,address_id:void 0};return this.setStoredIntent(e),e}applyPreselectedIdsFromIntent(t){this.hasExplicitPreselectedIdsForOpen?this.hasExplicitPreselectedIdsForOpen=!1:(this.preselectedAddressId=void 0,this.preselectedBranchId=void 0,this.isGuestUser()?"branch"===t?.type&&t.branch_id&&(this.preselectedBranchId=t.branch_id):"address"===t?.type&&t.address_id?this.preselectedAddressId=t.address_id:"branch"===t?.type&&t.branch_id&&(this.preselectedBranchId=t.branch_id))}hasIncompleteUserAddressIntent(){if(this.isGuestUser())return!1;const t=this.getStoredIntent();return!(!t||"address"!==t.type||t.address_id||!t.address_details)&&L(t)}isIntentMethodSupported(t){return"branch"===t.type?this.supportsPickup:"address"===t.type&&this.isSupportsDelivery}hasCompleteIntentForLoggedInUser(){if(this.isGuestUser())return!1;const t=this.getStoredIntent();return!!(t&&this.isIntentMethodSupported(t)&&("address"===t.type?t.address_id:"branch"===t.type&&t.branch_id))}shouldForceNonClosable(){return!this.isGuestUser()&&!!Salla.url.is_page("cart")&&!this.hasCompleteIntentForLoggedInUser()}shouldPromptIncompleteIntentThisSession(){const t=this.getShownStorage();return this.hasIncompleteUserAddressIntent()&&!0!==t.get(this.incompleteIntentPromptKey)}markIncompleteIntentPrompted(){this.getShownStorage().set(this.incompleteIntentPromptKey,!0)}setStoredIntent(t){this.getIntentStorage().set(this.intentStorageKey,t),this.overrideScopeSwitchUI()}clearBulletDeliveryStoredData(){Salla.storage.session.remove(this.intentStorageKey),Salla.storage.store.remove(this.intentStorageKey),Salla.storage.session.remove(this.sessionShownKey),Salla.storage.session.remove(this.incompleteIntentPromptKey),this.overrideScopeSwitchUI()}async prefillAddressFromStoredIntent(){const t=this.getStoredIntent();if(!t||"address"!==t.type||null==x(t))return;const e=S(t);if(!e)return;const i=this.countries.find((t=>String(t.id)===String(e)));if(!i)return;this.selectedCountry=i,this.updateNewAddressForm({country_id:Number(i.id)});const s=p(i.code),o=x(t),n=C(t),a=_(t),r=t.address_details?.district?.name,[l,h,c]=await Promise.all([s?m.getRegions(i.id):Promise.resolve([]),m.getCities(i.id,s&&null!=n?n:void 0),null!=o?m.getDistricts(Number(o)):Promise.resolve([])]);if(s&&(this.regions=l,this.displayedRegions=this.regions),this.cities=h,this.displayedCities=this.cities,this.districts=c,this.displayedDistricts=this.districts,this.loadingCities=!1,this.loadingRegions=!1,this.loadingDistricts=!1,s&&null!=n){const t=this.regions.find((t=>String(t.id)===String(n)));t&&(this.selectedRegion=t,this.updateNewAddressForm({region_id:t.id}))}if(null!=o&&this.cities.length>0){const t=this.cities.find((t=>String(t.id)===String(o)));t&&(this.selectedCity=t,this.updateNewAddressForm({city_id:t.id,city:t}))}if(this.districts.length>0){const t=this.findPrefillDistrict(a,r);t&&(this.updateNewAddressForm({district_id:t.id,district:t}),this.selectedDistrict=t)}!this.selectedDistrict&&r&&(this.districtName=r)}updateNewAddressForm(t){this.newAddressForm={...this.newAddressForm,...t}}hasBeenShownThisSession(){return!0===this.getShownStorage().get(this.sessionShownKey)}markShownThisSession(){this.getShownStorage().set(this.sessionShownKey,!0)}getIPLocationConfig(){const t="store.shipping.delivery_location",e={countryId:Salla.config.get(`${t}.country_id`),regionId:Salla.config.get(`${t}.region_id`),cityId:Salla.config.get(`${t}.city_id`),districtId:Salla.config.get(`${t}.district_id`)};return localStorage.getItem(_s)?JSON.parse(localStorage.getItem(_s)):e}async loadCountries(t=!1){this.loadingCountries=!0;const e="branch"===this.activeTab;try{this.countries=await m.getCountries(e),this.displayedCountries=this.countries;const{countryId:i,regionId:s,cityId:o,districtId:n}=this.getIPLocationConfig();As("getIPLocationConfig",this.getIPLocationConfig());const a=i&&this.countries.length>0?this.countries.find((t=>String(t.id)===String(i))):null;a&&(this.selectedCountry=a,this.updateNewAddressForm({country_id:Number(this.selectedCountry.id)}),!t)&&(null!=s||null!=o||null!=n?await this.prefillFromIPLocation(a,{regionId:s,cityId:o,districtId:n}):p(this.selectedCountry.code)?await this.loadRegions(this.selectedCountry.id):await this.loadCities(this.selectedCountry.id))}finally{this.loadingCountries=!1}}async prefillFromIPLocation(t,e){const i=p(t.code),{regionId:s,cityId:o,districtId:n}=e,[a,r,l]=await Promise.all([i?m.getRegions(t.id):Promise.resolve([]),m.getCities(t.id,i&&null!=s?s:void 0),null!=o?m.getDistricts(Number(o)):Promise.resolve([])]);if(i&&(this.regions=a,this.displayedRegions=this.regions),this.cities=r,this.displayedCities=this.cities,this.districts=l,this.displayedDistricts=this.districts,this.loadingRegions=!1,this.loadingCities=!1,this.loadingDistricts=!1,i&&null!=s){const t=this.regions.find((t=>String(t.id)===String(s)));t&&(this.selectedRegion=t,this.updateNewAddressForm({region_id:t.id}))}if(null!=o&&this.cities.length>0){const t=this.cities.find((t=>String(t.id)===String(o)));t&&(this.selectedCity=t,this.updateNewAddressForm({city_id:t.id,city:t}))}if(null!=n&&this.districts.length>0){const t=this.findPrefillDistrict(n);t&&(this.selectedDistrict=t,this.updateNewAddressForm({district_id:t.id,district:t}))}}async loadCities(t,e){this.loadingCities=!0,this.cities=[],this.displayedCities=[],this.districts=[],this.displayedDistricts=[],this.selectedCity=null,this.selectedDistrict=null,this.districtName="";try{this.cities=await m.getCities(t,e),this.displayedCities=this.cities}finally{this.loadingCities=!1}}async loadDistricts(t){this.loadingDistricts=!0,this.districts=[],this.displayedDistricts=[],this.selectedDistrict=null,this.districtName="";try{this.districts=await m.getDistricts(t),this.displayedDistricts=this.districts}finally{this.loadingDistricts=!1}}findPrefillDistrict(t,e){if(0===this.districts.length)return;if(null!=t){const e=this.districts.find((e=>String(e.id)===String(t)));if(e)return e}const i=e?.trim().toLowerCase();return i?this.districts.find((t=>{const e=t.name?.trim().toLowerCase(),s=t.name_en?.trim().toLowerCase();return e===i||s===i})):void 0}async loadBranches(){this.loadingBranches=!0;try{this.branches=await m.getBranches({country_id:this.selectedCountry?.id}),this.filterBranches()}finally{this.loadingBranches=!1}}filterBranches(){this.filteredBranches=((t,e)=>{if(!e)return t;const i=e.toLowerCase();return t.filter((t=>t.name.toLowerCase().includes(i)||t.city?.name?.toLowerCase().includes(i)))})(this.branches,this.branchSearchQuery)}async prefillFromSessionStorage(){try{const t=this.getStoredIntent();if(!t)return;if("address"!==this.activeTab||"address"!==t.type||this.isLoggedIn||await this.prefillAddressFromStoredIntent(),"branch"===this.activeTab&&"branch"===t.type){const e=S(t);if(null!=e){const i=this.countries.find((t=>String(t.id)===String(e)));if(i){this.selectedCountry=i,this.updateNewAddressForm({country_id:Number(i.id)});const e=A(t);if(null!=e&&this.branches.length>0){const t=this.branches.find((t=>t.id===e));t&&(this.selectedBranch=t)}}}}}catch(t){console.error("[BulletDelivery] Error prefilling from session storage:",t)}}async loadSavedAddresses(){const t=this.selectedSavedAddress?.id;this.savedAddresses=await m.getSavedAddresses();const e=this.getStoredIntent();if(L(e))return this.selectedSessionAddress=!0,void(this.selectedSavedAddress=null);if(null!=t){const e=this.savedAddresses.find((e=>e.id===t&&!1!==e.is_in_coverage));if(e)return this.selectedSessionAddress=!1,void(this.selectedSavedAddress=e)}const i=this.savedAddresses.find((t=>t.is_default&&!1!==t.is_in_coverage));if(i)this.selectedSavedAddress=i;else{const t=this.savedAddresses.find((t=>!1!==t.is_in_coverage));t&&(this.selectedSavedAddress=t)}}applyCountryChange(t){this.selectedCountry=t,this.selectedRegion=null,this.regions=[],this.displayedRegions=[],this.cities=[],this.displayedCities=[],this.districts=[],this.displayedDistricts=[],this.selectedCity=null,this.selectedDistrict=null,this.districtName="",this.allocationOutOfCoverageMessage=null,this.regionSearchQuery="",this.citySearchQuery="",this.districtSearchQuery="",this.searchingRegions=!1,this.searchingCities=!1,this.searchingDistricts=!1,this.clearSearchTimers(),this.selectedCountry&&(this.updateNewAddressForm({country_id:Number(this.selectedCountry.id),region_id:void 0,city_id:void 0,district_id:void 0,city:void 0,district:void 0}),"branch"===this.activeTab?this.loadBranches():p(this.selectedCountry.code)?this.loadRegions(this.selectedCountry.id):this.loadCities(this.selectedCountry.id))}async loadRegions(t){this.loadingRegions=!0,this.regions=[],this.displayedRegions=[],this.selectedRegion=null,this.cities=[],this.displayedCities=[],this.districts=[],this.displayedDistricts=[],this.selectedCity=null,this.selectedDistrict=null,this.districtName="";try{this.regions=await m.getRegions(t),this.displayedRegions=this.regions}finally{this.loadingRegions=!1}}emitHeaderContextUpdate(t,e,i){let s="";"address"===t.type?e?s=e.district?.name&&e.city?.name?`${e.district.name}، ${e.city.name}`:e.city?.name??"":this.selectedCity?s=this.selectedDistrict?`${this.selectedDistrict.name}، ${this.selectedCity.name}`:this.selectedCity.name:t.address_details&&(s=[t.address_details.district?.name,t.address_details.city.name,t.address_details.country.name].filter(Boolean).join("، ")||t.address_details.short_address||""):i?s=i.name:t.branch_details&&(s=t.branch_details.city??t.branch_details.name);const o="address"===t.type?Salla.lang.get("mobile_app.strings.delivery"):Salla.lang.get("mobile_app.strings.pickup");this.headerContextUpdate.emit({type:t.type,display_text:s?`${o}: ${s}`:"",country_code:t.country_code,city:this.selectedCity?.name??t.address_details?.city?.name,district:this.selectedDistrict?.name??t.address_details?.district?.name,branch_name:i?.name??t.branch_details?.name})}handleBranchSearch(t){const e=t.target.value;if(this.branchSearchQuery=e,this.branchSearchDebounceTimer&&clearTimeout(this.branchSearchDebounceTimer),!e?.trim())return this.branchSearchQuery="",void this.loadBranches();this.branchSearchDebounceTimer=setTimeout((async()=>{if(!(e.trim().length<2)){this.loadingBranches=!0;try{this.branches=await m.getBranches({country_id:this.selectedCountry?.id,query:e}),this.filterBranches()}finally{this.loadingBranches=!1}}}),1e3)}clearSearchTimers(){[this.countrySearchTimer,this.regionSearchTimer,this.citySearchTimer,this.districtSearchTimer].forEach((t=>{t&&clearTimeout(t)})),this.countrySearchTimer=this.regionSearchTimer=this.citySearchTimer=this.districtSearchTimer=null}resetSearchState(){this.countrySearchQuery="",this.regionSearchQuery="",this.citySearchQuery="",this.districtSearchQuery="",this.searchingCountries=!1,this.searchingRegions=!1,this.searchingCities=!1,this.searchingDistricts=!1,this.displayedCountries=[],this.displayedRegions=[],this.displayedCities=[],this.displayedDistricts=[],this.clearSearchTimers()}async loadBranchesWithLocation(t,e){this.loadingBranches=!0;try{if(this.branches=await m.getBranches({country_id:this.selectedCountry?.id,lat:t,lng:e}),this.filterBranches(),!this.selectedCountry&&this.branches.length>0){const t=this.branches[0];if(t.country){const e=this.countries.find((e=>e.id===t.country.id));e&&(this.selectedCountry=e,this.updateNewAddressForm({country_id:Number(e.id)}))}}}finally{this.loadingBranches=!1}}async handleFindNearestBranch(){if(navigator.geolocation){this.loadingNearestBranch=!0,this.locationError="";try{const t=await new Promise(((t,e)=>{navigator.geolocation.getCurrentPosition(t,e,{enableHighAccuracy:!0,timeout:1e4,maximumAge:0})})),{latitude:e,longitude:i}=t.coords;await this.loadBranchesWithLocation(e,i);const s=function(t,e,i){let s=null,o=Number.POSITIVE_INFINITY;for(const n of t){const t=null!=n.location?.lat?Number(n.location.lat):Number.NaN,a=null!=n.location?.lng?Number(n.location.lng):Number.NaN;if(Number.isNaN(t)||Number.isNaN(a)||!1===n.is_open)continue;const r=f(e,i,t,a);r<o&&(o=r,s=n)}return s}(this.branches,e,i);s&&(this.selectedBranch=s,this.branchSearchQuery="",this.filterBranches())}catch(t){const e=t;this.locationError=z["number"==typeof e?.code?e.code:-1]??"An error occurred while detecting location"}finally{this.loadingNearestBranch=!1}}else this.locationError=Salla.lang.get("pages.checkout.current_location_not_supported")}handleBranchSelect(t){this.selectedBranch=t}handleSavedAddressSelect(t){!1!==t.is_in_coverage?(this.selectedSavedAddress=t,this.selectedSessionAddress=!1):Salla.notify?.error(Salla.lang.get("pages.checkout.shipping_not_available"))}handleSessionAddressSelect(){this.selectedSessionAddress=!0,this.selectedSavedAddress=null}async handleAddNewAddress(){this.viewMode="add-address",this.mapLocationData=null,this.autoGeolocationTriggered=!1,this.fetchAddressToken();const t=this.getStoredIntent(),e=S(t);if(e&&this.countries.length>0){const t=this.countries.find((t=>t.id===e));t&&(this.selectedCountry=t,this.updateNewAddressForm({country_id:Number(t.id)}),p(t.code)?await this.loadRegions(t.id):await this.loadCities(t.id))}}handleBackToAddressList(){this.viewMode="main",this.mapLocationData=null,this.mapStep="map",this.addressDescription="",this.autoGeolocationTriggered=!1}async fetchAddressToken(){if(!this.addressToken&&!this.loadingToken){this.loadingToken=!0;try{const t=salla.config.get("store.settings.keys.maps");t&&function(t,e){if(typeof document>"u")return Promise.resolve();if(ni)return ri;let i;ni=!0,i={...t},Array.isArray(i.libraries)&&(i.libraries=i.libraries),!e&&!i.v&&(e="quarterly"),i.loading||(i.loading="async"),i.callback="googleMapsInitCallback";let s=`https://maps.googleapis.com/maps/api/js?${Object.keys(i).map((t=>`${encodeURIComponent(t)}=${encodeURIComponent(i[t])}`)).join("&")}`;e&&(s+=`&v=${e}`);const o=document.createElement("script");return o.src=s,o.async=!0,o.defer=!0,o.onerror=t=>{console.error("Failed to load Google Maps script:",t)},document.body.appendChild(o),ri}({key:t,libraries:["marker","places"],language:salla.config.get("user.language_code")||"ar"}).catch((t=>As("Failed to load Google Maps SDK",t))),this.addressToken=await m.getAddressToken()}catch{As("SallaBulletDelivery: Failed to fetch address token")}finally{this.loadingToken=!1}}}updateLocationBias(){if(!this.gmapRef)return;const t=this.hasMapLocation()?{lat:this.mapLocationData.lat,lng:this.mapLocationData.lng}:this.mapInitialCenter;this.gmapRef.autocompleteLocationBias={center:t,radius:5e5}}hasMapLocation(){return null!=this.mapLocationData?.lat&&null!=this.mapLocationData?.lng}get isMapSettingEnabled(){return Salla.config.get("store.settings.bullet_delivery.settings.map_enabled")}get isMapModeAvailable(){return this.isMapSettingEnabled&&!!salla.config.get("store.settings.keys.maps")&&!!this.addressToken}get mapInitialCenter(){const t=salla.config.get("user.default_geo_location"),e=this.toCoordinate(t?.lat),i=this.toCoordinate(t?.lng);return null!=e&&null!=i&&e>=-90&&e<=90&&i>=-180&&i<=180?{lat:e,lng:i}:xs}toCoordinate(t){if("string"==typeof t&&""===t.trim())return null;if(null==t)return null;const e=Number(t);return Number.isFinite(e)?e:null}buildAddressLocationPayload(){if(this.isMapModeAvailable&&this.hasMapLocation())return{lat:this.mapLocationData.lat,lng:this.mapLocationData.lng,...this.mapLocationData.shortAddress&&{short_address:this.mapLocationData.shortAddress},...this.addressDescription?.trim()&&{description:this.addressDescription.trim()}};const t=this.selectedDistrict?.name??this.districtName?.trim()??"";return function(t){const{countryId:e,countryCode:i,regionId:s,cityId:o,districtId:n,description:a="",lat:r,lng:l,shortAddress:h}=t,c=a||"";return{country_id:Number(e)||void 0,region_id:null!=s?Number(s):void 0,city_id:null!=o?Number(o):void 0,district_id:null!=n?Number(n):void 0,description:c,...i&&p(i)&&{local:c},...null!=r&&null!=l&&{lat:r,lng:l},...h&&{short_address:h}}}({countryId:this.selectedCountry?.id??0,countryCode:this.selectedCountry?.code,regionId:this.selectedRegion?.id,cityId:this.selectedCity?.id,districtId:this.selectedDistrict?.id,description:t,lat:this.mapLocationData?.lat,lng:this.mapLocationData?.lng,shortAddress:this.mapLocationData?.shortAddress})}async handleTabChange(t){if(!this.tabChanging){this.tabChanging=!0;try{this.activeTab=t,"add-address"===this.viewMode&&(this.viewMode="main"),this.showCartWillBeClearedBanner=!1,this.allocationOutOfCoverageMessage=null,this.resetSearchState();const e="branch"===t;this.countries=await m.getCountries(e),this.displayedCountries=this.countries;const i=this.selectedCountry?.id;if(null!=i&&(this.selectedCountry=this.countries.find((t=>t.id===i))||null),!this.selectedCountry){const{countryId:t}=this.getIPLocationConfig();t&&this.countries.length>0&&(this.selectedCountry=this.countries.find((e=>String(e.id)===String(t)))||null),this.selectedCountry||1!==this.countries.length||(this.selectedCountry=this.countries[0])}if(this.selectedCountry)if("branch"===t){const t=this.getStoredIntent(),e=$(t),i=M(t);null!=e&&null!=i?await this.loadBranchesWithLocation(e,i):await this.loadBranches();const s=A(t);if(null!=s&&this.branches.length>0){const t=this.branches.find((t=>t.id===s));t&&(this.selectedBranch=t)}}else if("address"===t){if(this.isLoggedIn&&!this.savedAddressesLoaded){this.loadingSavedAddresses=!0;try{await this.loadSavedAddresses(),this.savedAddressesLoaded=!0}finally{this.loadingSavedAddresses=!1}}if(!this.isLoggedIn){const t=this.getStoredIntent();t&&x(t)&&await this.prefillAddressFromStoredIntent()}}}finally{this.tabChanging=!1}}}isConfirmDisabled(){return"branch"===this.activeTab?!this.selectedBranch:!("address"!==this.activeTab||this.isLoggedIn&&this.selectedSessionAddress||(this.isLoggedIn&&this.selectedSavedAddress?!1!==this.selectedSavedAddress.is_in_coverage:this.selectedCountry&&this.selectedCity&&E(this.selectedCountry?.code,this.selectedRegion?.id,this.selectedDistrict?.id??(this.districtName?.trim()||null))))}handleLogin(){Salla.auth.setCanRedirect(!1),Salla.event.dispatch("salla::bullet-delivery.modal.close.requested"),Salla.event.dispatch("login::open",Salla.url.is_page("cart")?{withoutReload:!0,source:"cart-submit"}:{withoutReload:!0,source:"bullet-delivery"})}resolvePendingCartSubmit(){if(!this.pendingCartSubmitResolver)return;const t=this.pendingCartSubmitResolver;this.pendingCartSubmitResolver=null,this.pendingCartSubmitPromise=null,this.cartSubmitConfirmationPending=!1,t()}buildIntentAddress(){if("address"!==this.activeTab||!this.selectedCountry||!this.selectedCity)return;const t={id:this.selectedCountry.id,name:this.selectedCountry.name,code:this.selectedCountry.code},e={id:this.selectedCity.id,name:this.selectedCity.name},i=this.selectedRegion?{id:this.selectedRegion.id,name:this.selectedRegion.name,code:this.selectedRegion.code}:void 0,s=this.selectedDistrict?{id:this.selectedDistrict.id,name:this.selectedDistrict.name}:this.districtName?{id:0,name:this.districtName}:void 0,o=this.selectedSavedAddress?.short_address;return{country:t,region:i,city:e,district:s,short_address:o}}buildIntentAddressFromSaved(t){return{country:{id:t.country?.id??t.country_id??0,name:t.country?.name??"",code:t.country?.code},region:t.region?{id:t.region.id,name:t.region.name,code:t.region.code}:void 0,city:{id:t.city?.id??t.city_id??0,name:t.city?.name??""},district:t.district?{id:t.district.id,name:t.district.name}:void 0,short_address:t.short_address}}buildIntentBranch(){if("branch"!==this.activeTab||!this.selectedBranch)return;const t=this.selectedBranch,e=null!=t.location?.lat?Number(t.location.lat):void 0,i=null!=t.location?.lng?Number(t.location.lng):void 0;return{id:t.id,name:t.name,city:t.city?.name,latitude:e,longitude:i}}buildAllocationConfirmedAddressData(t){return"address"!==this.activeTab?null:{saved_address:t??this.selectedSavedAddress??void 0,country:this.selectedCountry??void 0,region:this.selectedRegion??void 0,city:this.selectedCity??void 0,district:this.selectedDistrict??void 0,district_name:this.districtName?.trim()||void 0,short_address:t?.short_address??this.selectedSavedAddress?.short_address,form_data:{...this.newAddressForm}}}buildAllocationConfirmedAddressFromIntent(t){if("address"!==t.type)return null;const e=t.address_details,i=Number(t.country_id)||0;return{country:e?.country?{id:e.country.id,name:e.country.name,code:e.country.code??t.country_code??""}:void 0,region:e?.region?{id:Number(e.region.id),name:e.region.name,country_id:i,code:e.region.code??void 0}:void 0,city:e?.city?{id:Number(e.city.id),name:e.city.name,country_id:i}:void 0,district:e?.district?{id:Number(e.district.id),name:e.district.name,city_id:Number(e.city?.id)||0}:void 0,short_address:e?.short_address}}buildBranchFromIntent(t){if("branch"!==t.type||!t.branch_details)return null;const e=t.branch_details,i={id:e.id,name:e.name};return e.city&&(i.city={id:0,name:e.city}),null!=e.latitude&&null!=e.longitude&&(i.location={lat:String(e.latitude),lng:String(e.longitude)}),i}buildAllocationRequestFromIntent(t){if("branch"===t.type)return{type:"branch",branch_id:null!=t.branch_id?String(t.branch_id):""};if(null!=t.address_id)return{type:"address",address_id:String(t.address_id)};const e=t.address_details,i={type:"address",country_id:null!=t.country_id?String(t.country_id):"",city_id:null!=e?.city?.id?String(e.city.id):""};return null!=e?.region?.id&&(i.region_id=String(e.region.id)),null!=e?.district?.id&&(i.district_id=String(e.district.id)),i}applyMobileBulletDeliverySelection(t){if(!t||"address"!==t.type&&"branch"!==t.type)return void console.warn("SallaBulletDelivery: ignoring invalid mobile select payload",t);const e=t.allocation_headers??{},i=e["s-scope-allocation-type"]??t.type,s=e["s-scope-allocation-id"];i&&Salla.api.setHeader("s-scope-allocation-type",i),s&&Salla.api.setHeader("s-scope-allocation-id",String(s));const o=Salla.config.get("store.scope",Salla.storage.get("scope"))||{};Salla.storage.set("scope",{...o,allocation_type:i,allocation_id:s?String(s):void 0}),this.markShownThisSession();const n={...t,allocation_headers:{"s-scope-allocation-type":i,"s-scope-allocation-id":s?String(s):void 0}};this.setStoredIntent(n),g();const a=this.buildBranchFromIntent(n),r={...n,address:this.buildAllocationConfirmedAddressFromIntent(n),branch:a,allocation_request:this.buildAllocationRequestFromIntent(n),allocation_response:null};Salla.event.dispatch("salla::bullet-delivery.allocation.confirmed",r),this.bulletDeliveryConfirmed.emit({...n,branch:a??void 0}),this.emitHeaderContextUpdate(n,void 0,a??void 0),setTimeout((()=>window.location.reload()),100)}extractMobileSelectPayload(t){return t&&"object"==typeof t?"payload"in t&&t.payload?t.payload:t:null}async handleConfirm(){if(this.isConfirmDisabled()||this.confirming)return;this.confirming=!0,this.confirmBtn?.load();let t=!1;try{const e={type:this.activeTab,country_id:Number(this.selectedCountry?.id)||0,country_code:this.selectedCountry?.code||""};let i,s,o;if("address"===this.activeTab)if(this.isLoggedIn&&this.selectedSessionAddress){const t=await this.saveSessionAddressToProfile();if(!t)return Salla.notify?.error(Salla.lang.get("common.errors.error_occurred")),void this.confirmBtn?.stop();e.address_id=t.id,i=t,this.selectedSessionAddress=!1,this.selectedSavedAddress=t,e.address_details=this.buildIntentAddressFromSaved(t)}else this.isLoggedIn&&this.selectedSavedAddress?(e.address_id=this.selectedSavedAddress.id,i=this.selectedSavedAddress,e.address_details=this.buildIntentAddressFromSaved(this.selectedSavedAddress)):e.address_details=this.buildIntentAddress();else e.branch_details=this.buildIntentBranch(),e.branch_id=this.selectedBranch?.id,s=this.selectedBranch||void 0;"address"===this.activeTab?this.isLoggedIn&&i?o={type:"address",address_id:String(i.id)}:(o={type:"address",country_id:String(this.selectedCountry?.id||0),city_id:String(this.selectedCity?.id||"")},p(this.selectedCountry?.code??"")&&(this.selectedRegion?.id&&(o.region_id=String(this.selectedRegion.id)),o.district_id=String(this.selectedDistrict?.id||""))):o={type:"branch",branch_id:String(this.selectedBranch?.id||"")};const n=await m.allocateScope(o);if(!n.success){console.error("BulletDelivery: Scope allocation failed",n.error);const t=n.error||("address"===this.activeTab?Salla.lang.get("pages.checkout.address_out_of_coverage"):Salla.lang.get("pages.checkout.failed_to_set_pickup"));return this.allocationOutOfCoverageMessage=t,this.confirmBtn?.stop(),void(this.confirming=!1)}let a;if(n.data){const t=n.data;a=t.id;const i=t?.allocation?.type,s=t?.allocation?.branch_id;i&&Salla.api.setHeader("s-scope-allocation-type",i),s&&Salla.api.setHeader("s-scope-allocation-id",String(s));const o=Salla.config.get("store.scope",Salla.storage.get("scope"))||{};Salla.storage.set("scope",{...o,id:a,allocation_type:i,allocation_id:s?String(s):void 0}),e.allocation_headers={"s-scope-allocation-type":i,"s-scope-allocation-id":s?String(s):void 0}}this.markShownThisSession(),this.setStoredIntent(e),a&&(await m.setDeliveryScope(a),g());const r={...e,address:this.buildAllocationConfirmedAddressData(i),branch:s??null,allocation_request:o,allocation_response:n.data??null};Salla.event.dispatch("salla::bullet-delivery.allocation.confirmed",r),this.bulletDeliveryConfirmed.emit({...e,address:i,branch:s}),this.emitHeaderContextUpdate(e,i,s),t=!0,setTimeout((()=>{if(this.confirmBtn?.stop(),this.close(),this.confirming=!1,this.cartSubmitConfirmationPending)this.resolvePendingCartSubmit();else if(a){const t=Salla.storage.get("scope")||{};let e=Salla.helpers.addParamToUrl("scope",a);t.allocation_id&&(e=Salla.helpers.addParamToUrl("allocation_id",t.allocation_id,e)),t.allocation_type&&(e=Salla.helpers.addParamToUrl("allocation_type",t.allocation_type,e)),window.location.replace(e)}else window.location.reload()}),500)}finally{t||(this.confirming=!1)}}getCartViewConfig(t){if(!t||!Salla.url.is_page("cart"))return null;if(!this.isIntentMethodSupported(t))return null;const e="address"===t.type;return{title:"branch"===t.type?Salla.lang.get("pages.checkout.pickup_option"):Salla.lang.get("pages.checkout.delivery_option"),subtitle:y(t,Salla.lang.get("common.elements.to"),""),buttonText:Salla.lang.get("common.elements.edit"),isAddress:e,intent:t}}createCartViewElement(){const t=this.getStoredIntent(),e=this.getCartViewConfig(t);if(!e)return null;const{title:i,subtitle:s,buttonText:o,intent:a}=e,r="branch"===a.type?{preselected_branch_id:A(a)}:{preselected_address_id:a.address_id},l=document.createElement("span");l.className="s-bullet-delivery-cart-view-icon s-bullet-delivery-tab-icon",l.setAttribute("aria-hidden","true"),l.innerHTML=n;const h=document.createElement("span");h.className="s-bullet-delivery-cart-view-title",h.textContent=i;const c=document.createElement("span");c.className="s-bullet-delivery-cart-view-subtitle",c.textContent=s;const d=document.createElement("div");d.className="s-bullet-delivery-cart-view-text",d.append(h,c);const u=document.createElement("div");u.className="s-bullet-delivery-cart-view-info",u.append(l,d);const p=document.createElement("salla-button");p.className="s-bullet-delivery-cart-view-button",p.setAttribute("fill","outline"),p.setAttribute("color","primary"),p.textContent=o,p.addEventListener("click",(()=>Salla.event.emit("salla::bullet-delivery.modal.open.requested",r)));const m=document.createElement("div");return m.className="s-bullet-delivery-cart-view",m.append(u,p),m}renderTabs(){return this.supportsPickup?i("div",{class:"s-bullet-delivery-tabs"},this.isSupportsDelivery&&i("button",{type:"button",class:{"s-bullet-delivery-tab":!0,"s-bullet-delivery-tab--active":"address"===this.activeTab},onClick:()=>this.handleTabChange("address")},i("span",{class:"s-bullet-delivery-tab-icon",innerHTML:n,"aria-hidden":"true"}),i("span",null,Salla.lang.get("mobile_app.strings.delivery"))),i("button",{type:"button",class:{"s-bullet-delivery-tab":!0,"s-bullet-delivery-tab--active":"branch"===this.activeTab},onClick:()=>this.handleTabChange("branch")},i("span",{class:"s-bullet-delivery-tab-icon",innerHTML:Cs,"aria-hidden":"true"}),i("span",null,Salla.lang.get("mobile_app.strings.pickup")))):null}renderAlert(t){return i("div",{class:"s-bullet-delivery-allocation-out-of-coverage",role:"alert"},i("span",{class:"s-bullet-delivery-allocation-out-of-coverage-icon","aria-hidden":"true"},i("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",role:"img","aria-hidden":"true"},i("title",null,"Information"),i("circle",{cx:"10",cy:"10",r:"9",stroke:"currentColor","stroke-width":"1.5",fill:"currentColor"}),i("text",{x:"10",y:"14","text-anchor":"middle",fill:"white","font-size":"12","font-weight":"bold"},"i"))),i("span",{class:"s-bullet-delivery-allocation-out-of-coverage-text"},t))}renderAllocationOutOfCoverageAlert(){const t=this.allocationOutOfCoverageMessage||Salla.lang.get("pages.checkout.shipping_not_available");return this.renderAlert(t)}renderCountrySelect(){return i("div",{class:"s-bullet-delivery-field"},i("salla-searchable-dropdown",{label:Salla.lang.get("blocks.buy_as_gift.receiver_country"),placeholder:Salla.lang.get("pages.checkout.select_country"),items:this.displayedCountries,selectedItem:this.selectedCountry,loading:this.loadingCountries,searching:this.searchingCountries,disabled:this.countries.length<=1,required:!0,inputId:"bullet-delivery-country",searchQuery:this.countrySearchQuery,clientSearch:!0,onItemSelected:t=>this.handleCountrySelected(t.detail),onSearchInput:t=>this.handleCountrySearch(t.detail),onDropdownClosed:()=>this.handleCountryDropdownClosed()}))}renderRegionSelect(){return p(this.selectedCountry?.code??"")&&this.selectedCountry?i("div",{class:"s-bullet-delivery-field"},i("salla-searchable-dropdown",{label:Salla.lang.get("pages.checkout.region_field"),placeholder:Salla.lang.get("pages.checkout.select_region"),items:this.displayedRegions,selectedItem:this.selectedRegion,loading:this.loadingRegions,searching:this.searchingRegions,disabled:this.loadingRegions||0===this.regions.length,required:!0,inputId:"bullet-delivery-region",searchQuery:this.regionSearchQuery,clientSearch:!0,onItemSelected:t=>this.handleRegionSelected(t.detail),onSearchInput:t=>this.handleRegionSearch(t.detail),onDropdownClosed:()=>this.handleRegionDropdownClosed()})):null}renderCityDistrictSelects(){const t=p(this.selectedCountry?.code??""),e=t,s=e&&this.selectedCity&&!this.loadingDistricts&&0===this.districts.length,o=!this.selectedCountry||t&&!this.selectedRegion||this.loadingCities||0===this.cities.length,n=!this.selectedCountry||t&&!this.selectedRegion||!this.selectedCity||this.loadingDistricts;return i("div",{class:"s-bullet-delivery-field-row"},i("div",{class:"s-bullet-delivery-field"},i("salla-searchable-dropdown",{label:Salla.lang.get("blocks.buy_as_gift.receiver_city"),placeholder:Salla.lang.get("pages.checkout.select_city"),items:this.displayedCities,selectedItem:this.selectedCity,loading:this.loadingCities,searching:this.searchingCities,disabled:o,required:!0,inputId:"bullet-delivery-city",searchQuery:this.citySearchQuery,onItemSelected:t=>this.handleCitySelected(t.detail),onSearchInput:t=>this.handleCitySearch(t.detail),onDropdownClosed:()=>this.handleCityDropdownClosed(),dropUp:!0})),e&&i("div",{class:"s-bullet-delivery-field"},s?i("div",null,i("label",{class:"s-bullet-delivery-label",htmlFor:"bullet-delivery-district"},Salla.lang.get("pages.checkout.district_field"),i("span",{class:"text-red-500"}," *")),i("input",{id:"bullet-delivery-district",type:"text",class:"form-input",placeholder:Salla.lang.get("pages.checkout.select_district"),value:this.districtName,disabled:n,onInput:t=>{this.districtName=t.target.value,this.updateNewAddressForm({district:void 0})}})):i("salla-searchable-dropdown",{label:Salla.lang.get("pages.checkout.district_field"),placeholder:Salla.lang.get("pages.checkout.select_district"),items:this.displayedDistricts,selectedItem:this.selectedDistrict,loading:this.loadingDistricts,searching:this.searchingDistricts,disabled:n||0===this.districts.length,required:!0,inputId:"bullet-delivery-district",searchQuery:this.districtSearchQuery,clientSearch:!0,onItemSelected:t=>this.handleDistrictSelected(t.detail),onSearchInput:t=>this.handleDistrictSearch(t.detail),onDropdownClosed:()=>this.handleDistrictDropdownClosed(),dropUp:!0})))}renderSavedAddressesEmptyState(){return i("div",{class:"s-bullet-delivery-saved-addresses-empty"},i("div",{class:"s-bullet-delivery-saved-addresses-empty-icon","aria-hidden":"true"},i("svg",{width:"28",height:"28",viewBox:"0 0 28 29",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i("title",null,"No Saved Adresses"),i("path",{d:"M20.16 0C21.4613 0 22.6773 0.341333 23.808 1.024C24.9387 1.70667 25.8347 2.61333 26.496 3.744C27.1787 4.91733 27.52 6.18667 27.52 7.552C27.52 9.45067 26.8267 11.232 25.44 12.896C24.4587 14.0907 23.0827 15.2427 21.312 16.352H21.28C20.9387 16.5653 20.5653 16.672 20.16 16.672C19.7547 16.672 19.3813 16.5653 19.04 16.352H19.008C17.2373 15.2213 15.8613 14.0693 14.88 12.896C13.4933 11.232 12.8 9.45067 12.8 7.552C12.8 6.18667 13.1413 4.91733 13.824 3.744C14.4853 2.61333 15.3813 1.70667 16.512 1.024C17.6427 0.341333 18.8587 0 20.16 0ZM11.488 1.984C9.67467 2.368 8.04267 3.14667 6.592 4.32C5.14133 5.49333 4.01067 6.92267 3.2 8.608C2.34667 10.3573 1.92 12.224 1.92 14.208C1.92 14.72 1.952 15.2427 2.016 15.776L2.08 15.744C2.57067 15.488 2.94933 15.3067 3.216 15.2C3.48267 15.0933 3.73867 15.0933 3.984 15.2C4.22933 15.3067 4.4 15.488 4.496 15.744C4.592 16 4.58667 16.256 4.48 16.512C4.37333 16.768 4.19733 16.9493 3.952 17.056C3.70667 17.1627 3.36 17.3227 2.912 17.536L2.656 17.664C2.57067 17.7067 2.48533 17.7387 2.4 17.76C2.89067 19.4667 3.70133 20.9973 4.832 22.352C5.96267 23.7067 7.296 24.7573 8.832 25.504C10.432 26.272 12.1173 26.656 13.888 26.656C15.4667 26.656 16.9813 26.3467 18.432 25.728C19.8187 25.1307 21.0667 24.288 22.176 23.2C21.92 23.0507 21.7653 22.8373 21.712 22.56C21.6587 22.2827 21.7013 22.0267 21.84 21.792C21.9787 21.5573 22.176 21.408 22.432 21.344C22.8373 21.2587 23.2 21.12 23.52 20.928C23.6907 20.8427 23.8613 20.8 24.032 20.8C24.8 19.5413 25.3333 18.176 25.632 16.704C25.6747 16.4267 25.808 16.2133 26.032 16.064C26.256 15.9147 26.496 15.8667 26.752 15.92C27.008 15.9733 27.2107 16.1173 27.36 16.352C27.5093 16.5867 27.552 16.832 27.488 17.088C27.0613 19.2853 26.1973 21.264 24.896 23.024C23.5947 24.784 22.0053 26.1547 20.128 27.136C18.1653 28.16 16.0853 28.672 13.888 28.672C11.3707 28.672 9.03467 28.0107 6.88 26.688C4.78933 25.408 3.12533 23.68 1.888 21.504C0.629333 19.264 0 16.832 0 14.208C0 11.904 0.490667 9.73867 1.472 7.712C2.41067 5.74933 3.728 4.09067 5.424 2.736C7.12 1.38133 9.01333 0.48 11.104 0.032C11.36 -0.032 11.6 0.0106667 11.824 0.16C12.048 0.309333 12.1867 0.522667 12.24 0.8C12.2933 1.07733 12.2453 1.328 12.096 1.552C11.9467 1.776 11.744 1.92 11.488 1.984ZM14.72 7.552C14.72 8.96 15.2533 10.304 16.32 11.584C17.1733 12.5867 18.3893 13.6 19.968 14.624C20.032 14.6453 20.096 14.656 20.16 14.656C20.224 14.656 20.288 14.6453 20.352 14.624C21.9307 13.6213 23.1467 12.608 24 11.584C25.0667 10.304 25.6 8.96 25.6 7.552C25.6 6.57067 25.3547 5.65333 24.864 4.8C24.3733 3.94667 23.7067 3.26933 22.864 2.768C22.0213 2.26667 21.12 2.016 20.16 2.016C19.2 2.016 18.2987 2.26667 17.456 2.768C16.6133 3.26933 15.9467 3.94667 15.456 4.8C14.9653 5.65333 14.72 6.57067 14.72 7.552ZM17.28 7.68C17.28 6.848 17.5627 6.13867 18.128 5.552C18.6933 4.96533 19.3707 4.672 20.16 4.672C20.9493 4.672 21.6267 4.96533 22.192 5.552C22.7573 6.13867 23.04 6.848 23.04 7.68C23.04 8.512 22.7573 9.216 22.192 9.792C21.6267 10.368 20.9493 10.656 20.16 10.656C19.3707 10.656 18.6933 10.368 18.128 9.792C17.5627 9.216 17.28 8.512 17.28 7.68ZM6.752 14.688C7.62667 14.7733 8.53333 15.0293 9.472 15.456C9.70667 15.5627 9.87733 15.744 9.984 16C10.0907 16.256 10.0907 16.512 9.984 16.768C9.87733 17.024 9.70133 17.2 9.456 17.296C9.21067 17.392 8.97067 17.3867 8.736 17.28C7.94667 16.9387 7.22133 16.736 6.56 16.672C6.28267 16.6293 6.064 16.5013 5.904 16.288C5.744 16.0747 5.68 15.8293 5.712 15.552C5.744 15.2747 5.86133 15.0507 6.064 14.88C6.26667 14.7093 6.496 14.6453 6.752 14.688ZM17.6 20.544C18.304 20.864 18.976 21.0987 19.616 21.248C19.872 21.312 20.0693 21.4613 20.208 21.696C20.3467 21.9307 20.3893 22.1813 20.336 22.448C20.2827 22.7147 20.144 22.9227 19.92 23.072C19.696 23.2213 19.4453 23.264 19.168 23.2C18.4213 23.0293 17.632 22.752 16.8 22.368C16.5653 22.2613 16.4 22.08 16.304 21.824C16.208 21.568 16.2133 21.312 16.32 21.056C16.4267 20.8 16.6027 20.624 16.848 20.528C17.0933 20.432 17.344 20.4373 17.6 20.544ZM12.832 17.44C13.0027 17.568 13.248 17.7493 13.568 17.984L14.496 18.688C14.7093 18.8587 14.8373 19.0773 14.88 19.344C14.9227 19.6107 14.8693 19.856 14.72 20.08C14.5707 20.304 14.368 20.4427 14.112 20.496C13.856 20.5493 13.6107 20.5013 13.376 20.352L11.744 19.072C11.5307 18.9227 11.4027 18.7093 11.36 18.432C11.3173 18.1547 11.3707 17.904 11.52 17.68C11.6693 17.456 11.872 17.3227 12.128 17.28C12.384 17.2373 12.6187 17.2907 12.832 17.44ZM20.16 8.672C20.416 8.672 20.64 8.576 20.832 8.384C21.024 8.192 21.12 7.95733 21.12 7.68C21.12 7.40267 21.024 7.16267 20.832 6.96C20.64 6.75733 20.416 6.656 20.16 6.656C19.904 6.656 19.68 6.75733 19.488 6.96C19.296 7.16267 19.2 7.40267 19.2 7.68C19.2 7.95733 19.296 8.192 19.488 8.384C19.68 8.576 19.904 8.672 20.16 8.672Z",fill:"#666666"}))),i("p",{class:"s-bullet-delivery-saved-addresses-empty-title"},Salla.lang.get("pages.checkout.no_saved_addresses")),i("p",{class:"s-bullet-delivery-saved-addresses-empty-desc"},Salla.lang.get("pages.checkout.add_address_simplify_shipping")),i("salla-button",{onClick:()=>this.handleAddNewAddress(),onKeyUp:()=>this.handleAddNewAddress()},Salla.lang.get("pages.checkout.add_new_address")))}async saveSessionAddressToProfile(){const t=this.getStoredIntent(),e=S(t),i=x(t),s=_(t);if(!t||"address"!==t.type||!e||!i)return null;const o=k(t);if(p(o)&&!s)return null;const n=p(o),a=t.address_details?.district?.name??"",r={country_id:e,region_id:C(t),city_id:i,district_id:s,description:a};n&&(r.local=a);try{const{success:t,address:e}=await m.saveAddressLocation(r);if(!t)return null;const i=e??null;return i&&this.addressCreated.emit({address:i}),i}catch(t){return console.error("SallaBulletDelivery: Error saving session address",t),null}}renderSavedAddresses(){if(!this.isLoggedIn)return null;if(this.loadingSavedAddresses)return i("div",{class:"s-bullet-delivery-addresses-list s-scrollbar"},[1,2,3].map((t=>i("div",{key:t,class:"s-bullet-delivery-address-item s-bullet-delivery-address-item--skeleton"},i("salla-skeleton",{class:"s-bullet-delivery-skel-radio",height:"18px",width:"18px"}),i("salla-skeleton",{class:"s-bullet-delivery-skel-map",height:"36px",width:"36px"}),i("div",{class:"s-bullet-delivery-address-content"},i("div",{class:"s-bullet-delivery-address-lines"},i("salla-skeleton",{height:"18px",width:"72%"}),i("salla-skeleton",{height:"16px",width:"56%"})))))));const t=this.getStoredIntent(),e=L(t),s=e&&t?.address_details&&[t.address_details.city?.name,t.address_details.country?.name].filter(Boolean).join("، ")||"",o=e&&t?.address_details?(t.address_details.district?.name??"").trim():"";return 0!==this.savedAddresses.length||e?i("div",{class:"s-bullet-delivery-addresses-list s-scrollbar"},e&&this.renderAddressRow({key:"session-address",line1:s,line2:o,selected:this.selectedSessionAddress,onClick:()=>this.handleSessionAddressSelect()}),this.savedAddresses.map((t=>{const e=[t.building_number,t.street].filter(Boolean).join("، ")||t.formatted?.address_one||t.short_address||"",i=[t.district?.name,t.city?.name,t.country?.name].filter(Boolean).join("، "),s=(t.formatted?.address_two||i)??"",o=!1!==t.is_in_coverage;return this.renderAddressRow({key:String(t.id),line1:e,line2:s,selected:this.selectedSavedAddress?.id===t.id,disabled:!o,onClick:()=>o&&this.handleSavedAddressSelect(t)})}))):this.renderSavedAddressesEmptyState()}renderAddressRow(t){const{key:e,line1:s,line2:o,selected:n,disabled:a=!1,onClick:r}=t;return i("button",{key:e,class:{"s-bullet-delivery-address-item":!0,"s-bullet-delivery-address-item--selected":n,"s-bullet-delivery-address-item--disabled":a},type:"button",onClick:a?void 0:r,onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),a||r())}},i("input",{type:"radio",name:"saved_address",class:"s-bullet-delivery-radio",checked:n,disabled:a}),i("span",{class:"s-bullet-delivery-address-map-icon",innerHTML:'<svg width="35" height="35" viewBox="0 0 35 35" fill="none" xmlns="http://www.w3.org/2000/svg">\n <g filter="url(#filter0_d_24181_220540)">\n <mask id="mask0_24181_220540" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="1" y="0" width="33" height="32">\n <rect x="1.90958" y="0.576577" width="30.8468" height="30.8468" rx="9.22523" fill="#D9D9D9" stroke="white" stroke-width="1.15315"/>\n </mask>\n <g mask="url(#mask0_24181_220540)">\n <rect x="1.90958" y="0.576577" width="30.8468" height="30.8468" rx="9.22523" fill="#E8E8E8" stroke="white" stroke-width="1.15315"/>\n <path d="M17.9096 6.77445L28.7204 5.33301H32.4681L32.7564 11.8195V23.6393L10.4141 23.9276V10.8105L17.9096 6.77445Z" fill="#97E7C8"/>\n <path d="M-2.70303 10.6664H10.2699M41.6934 5.47722C38.378 5.47722 34.7744 5.47722 27.8555 5.47722C20.9366 5.47722 18.4862 6.63037 15.4591 8.64839C12.4321 10.6664 10.2699 10.6664 10.2699 10.6664M10.2699 34.4502V23.6394M10.2699 10.6664V23.6394M-6.16249 23.6394H10.2699M10.2699 23.6394H21.0807M38.8105 23.6394H21.0807M21.0807 23.6394V34.4502" stroke="white" stroke-width="2.30631"/>\n <rect x="2.34202" y="1.00901" width="29.982" height="29.982" rx="8.79279" stroke="white" stroke-width="2.01802"/>\n </g>\n <g clip-path="url(#clip0_24181_220540)">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M18.069 19.8621C19.4995 18.6902 22.171 16.0948 22.171 13.0548C22.171 11.7333 21.6461 10.466 20.7117 9.5316C19.7773 8.5972 18.51 8.07227 17.1885 8.07227C15.8671 8.07227 14.5998 8.5972 13.6654 9.5316C12.731 10.466 12.2061 11.7333 12.2061 13.0548C12.2061 16.0948 14.8776 18.6902 16.3081 19.8621C16.5553 20.0679 16.8669 20.1806 17.1885 20.1806C17.5102 20.1806 17.8218 20.0679 18.069 19.8621ZM17.1885 14.1618C17.517 14.1618 17.838 14.0644 18.1111 13.8819C18.3842 13.6995 18.597 13.4401 18.7227 13.1367C18.8484 12.8333 18.8812 12.4994 18.8172 12.1773C18.7531 11.8552 18.595 11.5593 18.3627 11.3271C18.1305 11.0948 17.8346 10.9367 17.5125 10.8726C17.1904 10.8085 16.8565 10.8414 16.5531 10.9671C16.2497 11.0928 15.9903 11.3056 15.8079 11.5787C15.6254 11.8518 15.528 12.1728 15.528 12.5012C15.528 12.9416 15.703 13.364 16.0144 13.6754C16.3258 13.9868 16.7481 14.1618 17.1885 14.1618Z" fill="#55575D"/>\n </g>\n </g>\n <defs>\n <filter id="filter0_d_24181_220540" x="-0.000325561" y="0" width="34.6667" height="34.6667" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">\n <feFlood flood-opacity="0" result="BackgroundImageFix"/>\n <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>\n <feOffset dy="1.33333"/>\n <feGaussianBlur stdDeviation="0.666667"/>\n <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.04 0"/>\n <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_24181_220540"/>\n <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_24181_220540" result="shape"/>\n </filter>\n <clipPath id="clip0_24181_220540">\n <rect width="12.1081" height="12.1081" fill="white" transform="translate(11.1338 8.07227)"/>\n </clipPath>\n </defs>\n </svg>\n ',"aria-hidden":"true"}),i("div",{class:"s-bullet-delivery-address-content"},i("div",{class:"s-bullet-delivery-address-lines"},i("span",{class:"s-bullet-delivery-address-line1"},s),i("span",{class:"s-bullet-delivery-address-line2"},o))))}renderMapSection(){const t=p(this.selectedCountry?.code??""),e=this.mapLocationData,s=null!=e?.lat&&null!=e?.lng,o=s?{lat:e.lat,lng:e.lng}:this.mapInitialCenter;return i("div",{class:"s-bullet-delivery-map-container"},i("gmap-map",{ref:t=>this.gmapRef=t,center:o,zoom:16,"min-zoom":4,"max-zoom":21,"map-id":"DEMO_MAP_ID","enable-autocomplete":!0,"enable-geolocation":!0,"show-location-marker":!0,"location-marker-position":s?{lat:e.lat,lng:e.lng,accuracy:50}:{...o,accuracy:50},language:Salla.lang.getLocale?.()??document.documentElement.lang??"ar","geolocation-button-label":Salla.lang.get("pages.checkout.current_location"),"autocomplete-placeholder":Salla.lang.get("pages.checkout.search_for_address"),"autocomplete-hint":t?Salla.lang.get("pages.checkout.short_address_format_validation"):void 0,"autocomplete-country":this.selectedCountry?.code?.toLowerCase(),"autocomplete-resolve":!1,"autocomplete-auth-token":this.addressToken,"location-marker-background":"#4285F4","location-marker-border-color":"#1967D2","location-marker-glyph-color":"#FFFFFF","location-marker-scale":1.3,"onGmap-location-changed":this.handleMapLocationChanged,"onGmap-ready":this.handleMapReady}))}renderAddressConfirmation(){const t=this.mapLocationData?.formattedAddress??"",e=this.mapLocationData?.shortAddress;return i("div",{class:"s-bullet-delivery-address-confirm"},i("div",{class:"s-bullet-delivery-address-confirm-card"},i("div",{class:"s-bullet-delivery-address-confirm-details"},i("span",{class:"s-bullet-delivery-address-confirm-label"},Salla.lang.get("pages.checkout.selected_address")),i("p",{class:"s-bullet-delivery-address-confirm-text"},t),e&&i("span",{class:"s-bullet-delivery-address-confirm-tag"},e,i("span",{class:"s-bullet-delivery-address-confirm-tag-icon",innerHTML:'<svg width="13" height="15" viewBox="0 0 8.97576 11.7781" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M6.2453 8.52122L5.8322 8.24311L5.86126 8.20024L6.27435 8.47694L6.2453 8.52122ZM6.42386 8.25126L6.00758 7.97882C5.96896 8.03798 5.92999 8.0975 5.88995 8.15737L6.30376 8.43372C6.34414 8.37136 6.38489 8.31184 6.42386 8.25126ZM6.63572 7.92213L6.21518 7.65677L6.11244 7.81797L6.5305 8.08723L6.63572 7.92213ZM6.43484 9.81081L5.92538 9.45547C5.32487 10.316 4.76617 11.0388 4.48664 11.3927L4.97413 11.7781C5.25827 11.4182 5.82512 10.6831 6.43484 9.81081ZM3.55487 10.1647C3.44257 10.0113 3.33097 9.85652 3.22327 9.70417L2.717 10.0638C2.82611 10.2179 2.93913 10.3745 3.0525 10.5307L3.55487 10.1647ZM3.11734 9.55006L2.99688 9.37823L2.48707 9.73216L2.60965 9.90753L3.11734 9.55006ZM6.58577 9.59257L6.07206 9.24113L5.95266 9.41402L6.46248 9.76865C6.50499 9.71091 6.54538 9.65174 6.58577 9.59151V9.59257ZM2.96535 9.33607C2.46191 8.60767 2.02898 7.92319 1.68072 7.30887L1.14044 7.61461C1.49933 8.24736 1.94182 8.9453 2.4566 9.68929L2.96535 9.33607ZM7.01161 8.95416L6.49152 8.6144C6.39055 8.7678 6.28533 8.92652 6.17763 9.08453L6.69134 9.43386C6.80329 9.27018 6.911 9.11146 7.01374 8.95486L7.01161 8.95416ZM8.97363 4.48559C8.97434 3.96621 8.88471 3.45073 8.70898 2.96217L8.12442 3.17262C8.27605 3.5935 8.35364 4.03777 8.35293 4.48559C8.35293 4.99505 8.11733 5.71955 7.65216 6.63927L8.2059 6.91916C8.72599 5.89847 8.97576 5.10204 8.97576 4.4863L8.97363 4.48559ZM0.749309 5.26111C0.699001 5.09389 0.661447 4.92313 0.637001 4.75059L0.0216118 4.83208C0.0488916 5.03579 0.0921143 5.23738 0.150217 5.43436L0.749309 5.26111ZM0.621058 4.58443V4.39737L0 4.3832V4.48594C0 4.51995 5.62238e-07 4.5738 0.00389767 4.6188L0.621058 4.58443ZM1.3275 2.25361L0.820874 1.89472C0.314958 2.60824 0.0297605 3.45427 0.000709258 4.32864L0.621058 4.35061C0.645858 3.59705 0.89173 2.86793 1.3275 2.25361ZM8.69233 2.91151C8.66612 2.84065 8.63706 2.76944 8.60766 2.70106L8.03797 2.94835C8.06348 3.00752 8.08792 3.06846 8.11131 3.12939L8.69233 2.91151ZM8.52227 2.51684C8.43264 2.33367 8.33025 2.15689 8.21653 1.98754L7.70282 2.33367C7.80095 2.47928 7.88846 2.63163 7.96534 2.78964L8.52227 2.51684ZM6.33848 0.397516C5.7571 0.13393 5.12577 -0.00140612 4.48735 1.10152e-05C4.25494 1.10152e-05 4.02288 0.0177252 3.79331 0.0531534L3.88825 0.664646C4.08665 0.634178 4.28682 0.618943 4.48735 0.618589C5.0372 0.617526 5.58137 0.73444 6.08197 0.961535L6.33848 0.397516ZM3.47906 0.752862L3.31644 0.150581C3.11946 0.203369 2.92602 0.269974 2.73825 0.349688L2.97987 0.921501C3.14214 0.853125 3.30865 0.796084 3.47835 0.750382L3.47906 0.752862ZM3.84184 0.673858L3.7391 0.061657C3.6647 0.0737026 3.58959 0.0885822 3.51519 0.104525L3.64876 0.710702C3.71182 0.694051 3.77666 0.681651 3.84078 0.671023L3.84184 0.673858ZM4.68149 10.6292C4.68149 10.6253 5.02975 10.2041 5.49138 9.58159L5.08998 9.28293C4.8434 9.6156 4.63083 9.8884 4.4877 10.0705C4.2436 9.76121 3.79791 9.18302 3.32069 8.49819L2.91043 8.78481C3.63494 9.82286 4.28824 10.6218 4.29462 10.6296L4.48735 10.8659L4.68149 10.6292ZM5.57039 9.47318L5.16757 9.17629L5.10344 9.26097L5.50556 9.55821C5.52752 9.52739 5.54843 9.50117 5.56968 9.47212L5.57039 9.47318ZM6.01997 8.85035L5.60759 8.56445C5.48359 8.74123 5.35463 8.92156 5.22213 9.10154L5.62566 9.39772C5.75993 9.21278 5.89137 9.02927 6.0175 8.85L6.01997 8.85035ZM8.12194 4.47708C8.12229 3.76958 7.91539 3.07731 7.52639 2.48601L7.10833 2.76023C7.44419 3.2704 7.62311 3.86807 7.62204 4.47886C7.62204 5.12436 7.14872 6.20669 6.25309 7.60788L6.67434 7.87714C7.63196 6.37108 8.11875 5.2271 8.11875 4.47567L8.12194 4.47708ZM2.68015 7.53667C2.55863 7.34394 2.44314 7.15653 2.33791 6.97584L1.9064 7.22951C2.01481 7.41444 2.13314 7.60788 2.25785 7.8077L2.68015 7.53667ZM2.29009 6.89436L2.23801 6.80366L1.80365 7.05237L1.8568 7.14554L2.29009 6.89436ZM2.22596 6.78205C1.65627 5.78155 1.35513 4.98371 1.35513 4.47567C1.35513 4.17453 1.39835 3.87516 1.48338 3.58642L1.00368 3.44541C0.905193 3.77915 0.854885 4.12528 0.855239 4.47319C0.855239 5.07618 1.16984 5.93567 1.79161 7.02757L2.22596 6.78205ZM7.50867 2.46263C7.48812 2.43181 7.46616 2.39851 7.44455 2.36946L7.03535 2.65465C7.05413 2.68087 7.07326 2.7078 7.09133 2.73508L7.50867 2.46263ZM2.36732 2.17389L2.02579 1.8026C1.85148 1.9638 1.69312 2.14201 1.55389 2.33438L1.95777 2.62985C2.07893 2.46369 2.21604 2.30994 2.36767 2.1707L2.36732 2.17389ZM7.38396 2.28726C7.24012 2.09772 7.07786 1.9227 6.90037 1.76434L6.5677 2.13811C6.7211 2.27415 6.86104 2.42472 6.98504 2.58769L7.38396 2.28726ZM2.50726 2.04848L2.19124 1.66302C2.16183 1.68675 2.13278 1.7112 2.10373 1.73635L2.43286 2.11402C2.45731 2.08993 2.48246 2.06867 2.50726 2.04848ZM4.48664 1.34203C4.8884 1.34133 5.28626 1.41856 5.65861 1.56878L5.84602 1.10431C4.62658 0.613984 3.23744 0.819114 2.21214 1.6414L2.52568 2.03112C3.08084 1.58295 3.77311 1.34026 4.48664 1.3431V1.34203ZM4.72649 9.03245C4.86927 8.82839 5.00708 8.62609 5.13817 8.43053C5.67207 7.64862 6.15567 6.83342 6.58506 5.98987C7.08141 4.98406 7.12463 4.54723 7.12853 4.47035V4.45618C7.12853 2.99689 5.94558 1.81394 4.48628 1.81394C3.02699 1.81394 1.84404 2.99689 1.84404 4.45618V4.47035C1.84404 4.54759 1.89081 4.98406 2.3868 5.98987C2.8169 6.83342 3.3005 7.64862 3.83476 8.43053C3.96336 8.62326 4.10401 8.82874 4.24643 9.03245L4.48522 9.3754L4.72649 9.03245ZM3.0316 3.00362C3.83547 2.19975 5.13887 2.20011 5.94274 3.00398C6.32537 3.3866 6.54183 3.90456 6.54538 4.44555C6.53971 4.49374 6.48125 4.87707 6.06178 5.73018C5.64373 6.55177 5.17289 7.34571 4.6528 8.10671C4.59895 8.18749 4.54368 8.26933 4.48699 8.35223C4.43102 8.26933 4.37504 8.18784 4.32119 8.10671C3.80146 7.34536 3.33061 6.55177 2.91221 5.73018C2.48636 4.86644 2.43357 4.48346 2.42932 4.44555C2.43109 3.90421 2.64791 3.38589 3.0316 3.00362Z" fill="url(#paint0_linear_0_471)"/>\n<defs>\n<linearGradient id="paint0_linear_0_471" x1="-0.000253536" y1="5.88509" x2="8.97608" y2="5.88509" gradientUnits="userSpaceOnUse">\n<stop offset="0.2" stop-color="#4498B6"/>\n<stop offset="0.49" stop-color="#273265"/>\n<stop offset="1" stop-color="#C93732"/>\n</linearGradient>\n</defs>\n</svg>\n'}))),i("button",{type:"button",class:"s-bullet-delivery-address-confirm-edit",onClick:()=>{this.mapStep="map"}},Salla.lang.get("common.elements.edit"))),i("div",{class:"s-bullet-delivery-address-confirm-description"},i("label",{class:"s-bullet-delivery-address-confirm-description-label"},Salla.lang.get("pages.checkout.address_description"),i("span",{class:"s-bullet-delivery-address-confirm-description-optional"},Salla.lang.get("common.elements.optional"))),i("input",{type:"text",class:"s-bullet-delivery-address-confirm-description-input form-input",placeholder:Salla.lang.get("pages.checkout.address_description_placeholder"),value:this.addressDescription,onInput:t=>{this.addressDescription=t.target.value}})))}renderGuestDeliveryForm(){if(this.isMapModeAvailable)return"confirm"===this.mapStep&&this.hasMapLocation()?this.renderAddressConfirmation():this.renderMapSection();const t=p(this.selectedCountry?.code??"");return[this.renderCountrySelect(),t?this.renderRegionSelect():null,this.renderCityDistrictSelects()]}renderDeliveryTab(){return i("div",{class:{"s-bullet-delivery-content":!0,"s-bullet-delivery-content--active":"address"===this.activeTab,"s-hidden":"address"!==this.activeTab}},this.isLoggedIn?this.renderSavedAddresses():this.renderGuestDeliveryContent())}renderGuestDeliveryContent(){if(!this.isMapModeAvailable)return this.renderGuestDeliveryForm();const t=this.hasMapLocation(),e="confirm"===this.mapStep&&t,s=e?this.savingAddress?Salla.lang.get("pages.checkout.loading"):Salla.lang.get("pages.checkout.confirm_address"):Salla.lang.get("pages.checkout.confirm_location");return i("form",{onSubmit:i=>{i.preventDefault(),e||!t?this.handleSubmitAddAddress(i):this.mapStep="confirm"}},this.renderGuestDeliveryForm(),i("div",{class:"s-bullet-delivery-form-actions s-bullet-delivery-form-actions--single",style:{padding:"24px"}},i("salla-button",{type:"submit",loading:this.savingAddress,disabled:!t||this.savingAddress,width:"wide"},s),!this.isLoggedIn&&i("button",{type:"button",class:"s-bullet-delivery-login-prompt",onClick:()=>this.handleLogin()},Salla.lang.get("pages.checkout.login_to_use_saved_addresses"))))}renderBranchSearch(){return i("div",{class:"s-bullet-delivery-branch-search"},i("div",{class:"s-bullet-delivery-search-row"},i("div",{class:"s-bullet-delivery-search s-bullet-delivery-branch-search-wrap"},i("span",{class:"s-bullet-delivery-search-icon s-bullet-delivery-branch-search-icon",innerHTML:a,"aria-hidden":"true"}),i("input",{type:"text",class:"s-bullet-delivery-branch-search-input form-input",placeholder:Salla.lang.get("pages.checkout.search_for_city_or_branch"),value:this.branchSearchQuery,onInput:t=>this.handleBranchSearch(t),autocomplete:"off"})),i("button",{type:"button",class:{"s-bullet-delivery-location-btn":!0,"s-bullet-delivery-location-btn--full":!0,"s-bullet-delivery-location-btn--loading":this.loadingNearestBranch},onClick:()=>this.handleFindNearestBranch(),disabled:this.loadingNearestBranch},this.loadingNearestBranch?i("span",{class:"s-bullet-delivery-location-icon","aria-hidden":"true"},i("salla-skeleton",{height:"18px",width:"18px"})):i("span",{class:"s-bullet-delivery-location-icon",innerHTML:'<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path\n d="M13.3258 7.65006C13.3258 10.7797 10.7888 13.3167 7.65916 13.3167C4.52955 13.3167 1.99249 10.7797 1.99249 7.65006C1.99249 4.52045 4.52955 1.9834 7.65916 1.9834C10.7888 1.9834 13.3258 4.52045 13.3258 7.65006Z"\n stroke="#555555" stroke-width="1.3" />\n <path d="M14.65 7.65039H13.3167" stroke="#555555" stroke-width="1.3" stroke-linecap="round"\n stroke-linejoin="round" />\n <path d="M1.98336 7.65039L0.650024 7.65039" stroke="#555555" stroke-width="1.3"\n stroke-linecap="round" stroke-linejoin="round" />\n <path d="M7.65002 0.650065L7.65002 1.9834" stroke="#555555" stroke-width="1.3"\n stroke-linecap="round" stroke-linejoin="round" />\n <path d="M7.65002 13.3171L7.65002 14.6504" stroke="#555555" stroke-width="1.3"\n stroke-linecap="round" stroke-linejoin="round" />\n <path\n d="M9.64999 7.65039C9.64999 8.75496 8.75456 9.65039 7.64999 9.65039C6.54542 9.65039 5.64999 8.75496 5.64999 7.65039C5.64999 6.54582 6.54542 5.65039 7.64999 5.65039C8.75456 5.65039 9.64999 6.54582 9.64999 7.65039Z"\n stroke="#555555" stroke-width="1.3" />\n</svg>\n ',"aria-hidden":"true"}),i("span",null,Salla.lang.get("pages.checkout.nearest_to_my_location")))),this.locationError&&"branch"===this.activeTab&&i("span",{class:"s-bullet-delivery-error"},this.locationError))}renderBranchList(){return this.loadingBranches?i("div",{class:"s-bullet-delivery-branches-wrap"},i("div",{class:"s-bullet-delivery-branches-loading"},[1,2,3,4].map((t=>i("div",{key:t,class:"s-bullet-delivery-branch-skeleton"},i("salla-skeleton",{class:"s-bullet-delivery-branch-skeleton-radio",type:"circle",height:"16px",width:"16px"}),i("div",{class:"s-bullet-delivery-branch-skeleton-icon"},i("salla-skeleton",{height:"34px",width:"34px"})),i("div",{class:"s-bullet-delivery-branch-skeleton-content"},i("salla-skeleton",{class:"s-bullet-delivery-branch-skeleton-title",height:"12px",width:"124px"})),i("salla-skeleton",{class:"s-bullet-delivery-branch-skeleton-time",height:"12px",width:"88px"}),i("div",{class:"s-bullet-delivery-branch-skeleton-map"},i("salla-skeleton",{height:"32px",width:"32px"}))))))):0===this.filteredBranches.length?i("salla-placeholder",{alignment:"center",class:"s-bullet-delivery-placeholder"},i("span",{slot:"title"},Salla.lang.get("pages.checkout.no_pickup_branches_found"))):i("div",{class:"s-bullet-delivery-branches-wrap"},i("ul",{class:"s-bullet-delivery-branches-list s-scrollbar"},this.filteredBranches.map((t=>i("li",{key:t.id,class:{"s-bullet-delivery-branch-item":!0,"s-bullet-delivery-branch-item--selected":this.selectedBranch?.id===t.id,"s-bullet-delivery-branch-item--disabled":!1===t.is_open},tabIndex:!1===t.is_open?-1:0,role:"option","aria-disabled":!1===t.is_open,onClick:()=>!1!==t.is_open&&this.handleBranchSelect(t),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),!1!==t.is_open&&this.handleBranchSelect(t))}},i("input",{type:"radio",name:"branch",class:"s-bullet-delivery-radio",checked:this.selectedBranch?.id===t.id,disabled:!1===t.is_open}),i("span",{class:"s-bullet-delivery-branch-icon","aria-hidden":"true"},i("span",{innerHTML:Cs})),i("div",{class:"s-bullet-delivery-branch-info"},i("span",{class:"s-bullet-delivery-branch-name"},t.name),t.preparation_time?i("span",{class:"s-bullet-delivery-branch-prep"},`${Salla.lang.get("pages.checkout.processing_time")}: ${t.preparation_time}`):null),(()=>{if(t.always_open)return i("span",{class:"s-bullet-delivery-branch-time"},Salla.lang.get("pages.orders.branch_always_open"));const e=(s=t.working_hours,s?.[0]?.times?.[0]??null);var s;return e?i("span",{class:"s-bullet-delivery-branch-time"},function(t,e,i,s){const o=String(t).trim(),n=String(e).trim();return o&&n?"00:00"===o?`${s} ${v(n,i)}`:`${v(o,i)} - ${v(n,i)}`:""}(e.from,e.to,Salla.config.get("user.language_code")||"ar",Salla.lang.get("pages.checkout.until"))):null})(),null!=t.location?.lat&&null!=t.location?.lng&&i("a",{href:`https://www.google.com/maps?q=${t.location.lat},${t.location.lng}`,target:"_blank",rel:"noopener noreferrer",class:"s-bullet-delivery-branch-map-link",title:Salla.lang.get("common.elements.open_in_google_maps"),onClick:t=>t.stopPropagation()},i("span",{class:"s-bullet-delivery-branch-map-link-icon",innerHTML:'<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path\n d="M7.94798 3.19336C11.1309 2.1083 12.7223 1.56578 13.5783 2.42174C14.4342 3.27771 13.8917 4.86914 12.8066 8.05201L12.0678 10.2195C11.2344 12.6639 10.8178 13.8861 10.131 13.9872C9.94631 14.0144 9.75517 13.9981 9.57248 13.9394C8.89297 13.7212 8.53377 12.4326 7.81538 9.8553C7.65604 9.28364 7.57637 8.99781 7.39494 8.7795C7.34228 8.71614 7.28386 8.65772 7.2205 8.60506C7.00219 8.42363 6.71636 8.34396 6.1447 8.18462C3.56741 7.46623 2.27876 7.10703 2.0606 6.42752C2.00195 6.24483 1.98558 6.05369 2.01277 5.86903C2.11392 5.18221 3.33613 4.76556 5.78054 3.93225L7.94798 3.19336Z"\n stroke="#555555" stroke-width="1.2" />\n</svg>\n '.replace(/mask0_25437_34440/g,`mask0_branch_${t.id}`),"aria-hidden":"true"}),i("span",{class:"sr-only"},Salla.lang.get("common.elements.open_in_google_maps"))))))))}renderPickupTab(){return i("div",{class:{"s-bullet-delivery-content":!0,"s-bullet-delivery-content--active":"branch"===this.activeTab,"s-hidden":"branch"!==this.activeTab}},this.renderCountrySelect(),this.renderBranchSearch(),this.renderBranchList())}renderAddAddressForm(){Salla.lang.get("pages.checkout.add_new_address");const t=this.isMapModeAvailable,e=p(this.selectedCountry?.code??""),s=this.hasMapLocation();let o,n;if(t)"map"===this.mapStep?(o=s,n=Salla.lang.get("pages.checkout.confirm_location")):(o=s,n=this.savingAddress?Salla.lang.get("pages.checkout.loading"):Salla.lang.get("pages.checkout.confirm_address"));else{const t=this.selectedCountry&&this.selectedCity&&(!e||this.selectedRegion)&&(!e||!!this.selectedDistrict||!!(this.districtName&&this.districtName.trim().length>0));o=s||t,n=this.savingAddress?Salla.lang.get("pages.checkout.loading"):Salla.lang.get("pages.checkout.confirm_address")}return this.savedAddresses.length>0||L(this.getStoredIntent()),i("div",{class:"s-bullet-delivery-add-address"},i("form",{class:"s-bullet-delivery-add-address-form",onSubmit:e=>{e.preventDefault(),t&&"map"===this.mapStep&&s?this.mapStep="confirm":this.handleSubmitAddAddress(e)}},this.renderGuestDeliveryForm(),i("div",{class:"s-bullet-delivery-form-actions s-bullet-delivery-form-actions--single"},i("salla-button",{type:"submit",loading:this.savingAddress,disabled:!o||this.savingAddress,class:"s-bullet-delivery-add-address-submit"},n))))}renderFooter(){if("address"===this.activeTab&&!this.isLoggedIn&&this.isMapModeAvailable)return null;const t="address"===this.activeTab&&this.isLoggedIn;return i("div",{class:"s-bullet-delivery-footer"},i("salla-button",{ref:t=>{this.confirmBtn=t},disabled:this.isConfirmDisabled(),onClick:()=>this.handleConfirm(),"loader-position":"center",width:"wide"},"branch"===this.activeTab?Salla.lang.get("pages.checkout.confirm_receipt_from_the_branch"):Salla.lang.get("pages.checkout.confirm_address")),t&&i("salla-button",{onClick:()=>this.handleAddNewAddress(),width:"wide",shape:"link"},Salla.lang.get("pages.checkout.add_new_address")),!this.isLoggedIn&&i("salla-button",{shape:"link",onClick:this.handleLogin},Salla.lang.get("pages.checkout.login_to_use_saved_addresses")))}renderMainView(){const t=this.isLoggedIn&&"address"===this.activeTab&&0===this.savedAddresses.length&&!L(this.getStoredIntent()),e="branch"===this.activeTab&&this.supportsPickup?this.renderPickupTab():this.renderDeliveryTab();return i("div",null,this.showCartWillBeClearedBanner&&this.renderAlert(Salla.lang.get("blocks.scope.empty_cart_warning")),this.allocationOutOfCoverageMessage&&this.renderAllocationOutOfCoverageAlert(),e,!t&&this.renderFooter())}handleAfterAddToCart(){if("after_add_to_cart"!==this.openingType)return;const t=this.shouldPromptIncompleteIntentThisSession();this.hasBeenShownThisSession()&&!t||this.modal?.hasAttribute?.("visible")||(t&&this.markIncompleteIntentPrompted(),this.open())}overrideScopeSwitchUI(){const t=this.getStoredIntent(),e=document.querySelector('[onclick*="scopes"]');if(!e)return;if(!t||"address"!==t.type&&"branch"!==t.type)return e.style.display="none",void(e.onclick=()=>this.open());const i=(t,e)=>t&&t.length>e?`${t.slice(0,e)}...`:t??"",s="branch"===t.type?`${Salla.lang.get("mobile_app.strings.pickup")} ${Salla.lang.get("common.elements.from")} ${i(t.branch_details?.name,20)}`:`${Salla.lang.get("mobile_app.strings.delivery")} ${Salla.lang.get("common.elements.to")} ${i(t.address_details?.city?.name,10)}`;e.style.display="inline-flex",e.onclick=()=>this.open();const o=e.querySelector('span:not([class*="sicon"]):not([class*="icon"])');if(o)o.textContent=s;else{const t=Array.from(e.childNodes).find((t=>t.nodeType===Node.TEXT_NODE&&t.textContent?.trim()));t&&(t.textContent=` ${s}`)}}async componentWillLoad(){await Salla.onReady();try{this.overrideScopeSwitchUI(),this.cartSubmittingHandler=async()=>{this.pendingCartSubmitPromise?await this.pendingCartSubmitPromise:this.hasCompleteIntentForLoggedInUser()||(this.cartSubmitConfirmationPending=!0,this.pendingCartSubmitPromise=new Promise((t=>{if(this.pendingCartSubmitResolver=t,this.isGuestUser())return Salla.auth.setCanRedirect(!1),void Salla.event.dispatch("login::open",{withoutReload:!0,source:"cart-submit"});this.open()})),await this.pendingCartSubmitPromise)},Salla.cart.event.onSubmitting(this.cartSubmittingHandler)}catch(t){console.warn("SallaBulletDelivery: overrideScopeSwitchUI failed",t)}Salla.event.on("salla::bullet-delivery.modal.open.requested",this.bulletDeliveryOpenHandler),this.closeHandler=this.close.bind(this),Salla.event.on("salla::bullet-delivery.modal.close.requested",this.closeHandler),this.isRTL=Salla.config.get("theme.is_rtl"),this.authLoggedInHandler=()=>{if(this.cartSubmitConfirmationPending)return Salla.event.dispatch("login::close"),this.hasCompleteIntentForLoggedInUser()?void this.resolvePendingCartSubmit():void(this.modal?.hasAttribute?.("visible")||this.open());this.hasIncompleteUserAddressIntent()&&(this.modal?.hasAttribute?.("visible")||this.open())},Salla.event.on("auth::logged.in",this.authLoggedInHandler),this.authLoggedOutHandler=()=>{this.clearBulletDeliveryStoredData()},Salla.event.on("auth::logged.out",this.authLoggedOutHandler),this.loginClosedHandler=()=>{this.cartSubmitConfirmationPending&&this.isGuestUser()&&(this.hasCompleteIntentForLoggedInUser()||this.resolvePendingCartSubmit())},Salla.event.on("salla-login::closed",this.loginClosedHandler),this.cartItemAddedHandler=()=>this.handleAfterAddToCart(),"function"==typeof Salla.cart?.event?.onItemAdded?(this.useCartEventApi=!0,Salla.cart.event.onItemAdded(this.cartItemAddedHandler)):Salla.event.on(this.cartItemAddedEvent,this.cartItemAddedHandler)}render(){return this.isMobileApp?null:i(s,{class:"s-bullet-delivery"},i("salla-modal",{ref:t=>{this.modal=t},isClosable:!this.isRequired&&!this.shouldForceNonClosable(),class:"s-bullet-delivery-modal",width:"sm"},i("div",{class:"s-bullet-delivery-inner"},i("div",{class:"s-bullet-delivery-header"},i("h2",{class:"s-bullet-delivery-title"},"address"===this.activeTab?Salla.lang.get("blocks.home.add_address_for_order_delivery"):Salla.lang.get("blocks.home.choose_branch_for_order_pickup")),i("p",{class:"s-bullet-delivery-subtitle"},"address"===this.activeTab?Salla.lang.get("blocks.home.products_available_for_delivery_shown_while_shopping"):Salla.lang.get("blocks.home.choose_branch_for_order_pickup_description"))),this.renderTabs(),"main"===this.viewMode&&this.renderMainView(),"add-address"===this.viewMode&&this.renderAddAddressForm())))}componentDidLoad(){if(this.componentReady=!0,this.isMobileApp)return this.hasBeenShownThisSession()||Salla.event.dispatch("salla::bullet-delivery.open-sheet"),this.bulletDeliveryMobileSelectHandler=t=>{const e=this.extractMobileSelectPayload(t);e?this.applyMobileBulletDeliverySelection(e):console.warn("SallaBulletDelivery: received empty mobile select payload",t)},void Salla.event.on("salla::bullet-delivery.select",this.bulletDeliveryMobileSelectHandler);if(this.pendingOpen)return this.pendingOpen=!1,void this.open();switch(this.openingType){case"first_visit":this.hasBeenShownThisSession()?this.shouldPromptIncompleteIntentThisSession()&&(this.markIncompleteIntentPrompted(),this.open()):this.open();break;case"on_cart_click":Salla.url.is_page("cart")&&(!0===this.getShownStorage().get(this.sessionShownKey)?this.shouldPromptIncompleteIntentThisSession()&&(this.markIncompleteIntentPrompted(),this.open()):this.open())}const t=this.createCartViewElement();t&&"function"==typeof salla?.hooks?.mount&&Salla.hooks.mount("cart:items.start",t).catch((()=>{}))}disconnectedCallback(){this.componentReady=!1,Salla.event.off("salla::bullet-delivery.modal.open.requested",this.bulletDeliveryOpenHandler),this.closeHandler&&(Salla.event.off("salla::bullet-delivery.modal.close.requested",this.closeHandler),this.closeHandler=null),this.cartItemAddedHandler&&(this.useCartEventApi&&"function"==typeof Salla.cart?.event?.offItemAdded?Salla.cart.event.offItemAdded(this.cartItemAddedHandler):Salla.event.off(this.cartItemAddedEvent,this.cartItemAddedHandler),this.cartItemAddedHandler=null),this.cartSubmittingHandler&&("function"==typeof Salla.cart?.event?.offSubmitting?Salla.cart.event.offSubmitting(this.cartSubmittingHandler):Salla.event.off("cart::submitting",this.cartSubmittingHandler),this.cartSubmittingHandler=null),this.authLoggedInHandler&&(Salla.event.off("auth::logged.in",this.authLoggedInHandler),this.authLoggedInHandler=null),this.authLoggedOutHandler&&(Salla.event.off("auth::logged.out",this.authLoggedOutHandler),this.authLoggedOutHandler=null),this.loginClosedHandler&&(Salla.event.off("salla-login::closed",this.loginClosedHandler),this.loginClosedHandler=null),this.bulletDeliveryMobileSelectHandler&&(Salla.event.off("salla::bullet-delivery.select",this.bulletDeliveryMobileSelectHandler),this.bulletDeliveryMobileSelectHandler=null)}};$s.INITIAL_ADDRESS_FORM={country_id:0,is_default:!1,city_id:void 0,district_id:void 0,street:void 0,building_number:void 0,additional_number:void 0,postal_code:void 0,description:void 0},$s.DROPDOWN_SEARCH_DEBOUNCE_MS=400,$s.DROPDOWN_SEARCH_MIN_CHARS=2,$s.style="@supports (interpolate-size: allow-keywords) and (block-size: calc-size(auto, size)) {\n .s-bullet-delivery .s-bullet-delivery-modal .s-modal-body, .s-bullet-delivery-inner {\n @apply [interpolate-size:allow-keywords];\n }\n .s-bullet-delivery .s-bullet-delivery-modal .s-modal-body {\n @apply [overflow:clip] [transition:block-size_500ms_ease];\n }\n .s-bullet-delivery-inner {\n @apply [overflow:clip] [transition:block-size_500ms_ease];\n block-size: calc-size(auto, size);\n }\n}\n\n/* Allow searchable dropdown popover to paint outside the modal body */\n.s-bullet-delivery .s-bullet-delivery-modal .s-modal-body:has(.s-searchable-dropdown--open) {\n overflow: visible !important;\n}\n\n.s-bullet-delivery-map-container {\n width: 100%;\n height: 450px;\n border-radius: 8px;\n overflow: hidden;\n margin-bottom: 12px;\n}\n.s-bullet-delivery-map-container gmap-map {\n display: block;\n width: 100%;\n height: 100%;\n}\n\n.s-bullet-delivery-address-confirm {\n display: flex;\n flex-direction: column;\n gap: 20px;\n padding: 0 24px;\n}\n\n.s-bullet-delivery-address-confirm-card {\n display: flex;\n align-items: flex-start;\n gap: 12px;\n}\n\n.s-bullet-delivery-address-confirm-edit {\n border: 1px solid #eee;\n border-radius: 8px;\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 500;\n line-height: 1;\n color: #333;\n background: white;\n cursor: pointer;\n white-space: nowrap;\n height: 32px;\n flex-shrink: 0;\n align-self: center;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n}\n\n.s-bullet-delivery-address-confirm-details {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 4px;\n flex: 1;\n min-width: 0;\n}\n\n.s-bullet-delivery-address-confirm-label {\n font-size: 12px;\n color: #666;\n}\n\n.s-bullet-delivery-address-confirm-text {\n font-size: 14px;\n font-weight: 700;\n color: #333;\n margin: 0;\n word-break: break-word;\n}\n\n.s-bullet-delivery-address-confirm-tag {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n border: 1px solid #eee;\n border-radius: 140px;\n padding: 4px 8px;\n font-size: 12px;\n color: #333;\n margin-top: 4px;\n}\n\n.s-bullet-delivery-address-confirm-tag-icon {\n width: 9px;\n display: inline-flex;\n flex-shrink: 0;\n}\n.s-bullet-delivery-address-confirm-tag-icon svg {\n width: 100%;\n height: 100%;\n}\n\n.s-bullet-delivery-address-confirm-description {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.s-bullet-delivery-address-confirm-description-label {\n font-size: 14px;\n font-weight: 500;\n color: #444;\n}\n\n.s-bullet-delivery-address-confirm-description-optional {\n font-weight: 400;\n color: #999;\n margin-inline-start: 4px;\n}\n\n.s-bullet-delivery-address-confirm-description-input {\n width: 100%;\n border: 1px solid #eee;\n border-radius: 8px;\n padding: 10px 12px;\n font-size: 14px;\n}\n\n.s-bullet-delivery-login-prompt {\n display: block;\n width: 100%;\n text-align: center;\n background: none;\n border: none;\n color: var(--color-primary, #004956);\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n padding: 12px 0;\n}\n\n@keyframes s-bullet-delivery-fade-in {\n from {\n opacity: 0;\n transform: translateY(6px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}";const Ms=class{constructor(i){t(this,i),this.itemSelected=e(this,"itemSelected"),this.searchInput=e(this,"searchInput"),this.dropdownOpened=e(this,"dropdownOpened"),this.dropdownClosed=e(this,"dropdownClosed"),this.placeholder="",this.items=[],this.selectedItem=null,this.loading=!1,this.searching=!1,this.disabled=!1,this.required=!1,this.noResultsText="",this.inputId="",this.searchQuery="",this.clientSearch=!1,this.dropUp=!1,this.searchable=!0,this.keepParentScroll=!1,this.isOpen=!1,this.focusedIndex=-1,this.clientSearchQuery="",this.scrollableAncestor=null,this.handleTriggerClick=()=>{this.isOpen?this.close():this.open()},this.handleTriggerKeyDown=t=>{this.isOpen?this.navigateItems(t):"Enter"===t.key||" "===t.key||"ArrowDown"===t.key?(t.preventDefault(),this.open()):"Escape"===t.key&&this.close()},this.handleSearchInputChange=t=>{const e=t.target.value;this.clientSearch&&(this.clientSearchQuery=e),this.searchInput.emit(e),this.focusedIndex=-1},this.handleSearchKeyDown=t=>{this.navigateItems(t)}}connectedCallback(){this.boundHandleClickOutside=this.handleClickOutside.bind(this),document.addEventListener("mousedown",this.boundHandleClickOutside)}disconnectedCallback(){document.removeEventListener("mousedown",this.boundHandleClickOutside),this.scrollableAncestor&&(this.scrollableAncestor.style.overflow="",this.scrollableAncestor=null)}onItemsChange(){this.focusedIndex=-1}normalizeArabic(t){return t.replace(/[أإآا]/g,"ا")}get filteredItems(){if(!this.clientSearch||!this.clientSearchQuery.trim())return this.items;const t=this.normalizeArabic(this.clientSearchQuery.trim().toLowerCase());return this.items.filter((e=>{const i=this.normalizeArabic(e.name.toLowerCase()),s=e.name_en?e.name_en.toLowerCase():"";return i.includes(t)||s.includes(t)}))}getDisplayName(t){const e=salla?.config?.get("user.language_code");return e&&"ar"!==e&&t.name_en?.trim()?t.name_en.trim():t.name}handleClickOutside(t){this.isOpen&&(this.host.contains(t.target)||this.close())}findScrollableAncestor(){let t=this.host.parentElement;for(;t;){const e=getComputedStyle(t),i=e.overflowY;if("auto"===i||"scroll"===i||"hidden"===i||"clip"===e.overflow)return t;t=t.parentElement}return null}open(){this.disabled||this.loading||(this.isOpen=!0,this.focusedIndex=-1,this.keepParentScroll||(this.scrollableAncestor=this.findScrollableAncestor(),this.scrollableAncestor&&(this.scrollableAncestor.style.overflow="visible")),this.dropdownOpened.emit(),requestAnimationFrame((()=>this.searchInputRef?.focus())))}close(){this.isOpen&&(this.isOpen=!1,this.focusedIndex=-1,this.clientSearchQuery="",this.scrollableAncestor&&(this.scrollableAncestor.style.overflow="",this.scrollableAncestor=null),this.dropdownClosed.emit())}navigateItems(t){const e=this.filteredItems,i=e.length;switch(t.key){case"ArrowDown":t.preventDefault(),this.focusedIndex=i>0?(this.focusedIndex+1)%i:-1,this.scrollFocusedIntoView();break;case"ArrowUp":t.preventDefault(),this.focusedIndex=i>0?(this.focusedIndex-1+i)%i:-1,this.scrollFocusedIntoView();break;case"Enter":t.preventDefault(),this.focusedIndex>=0&&this.focusedIndex<i&&this.selectItem(e[this.focusedIndex]);break;case"Escape":t.preventDefault(),this.close()}}scrollFocusedIntoView(){this.focusedIndex<0||requestAnimationFrame((()=>{const t=this.panelRef?.querySelector(".s-searchable-dropdown-list"),e=t?.children[this.focusedIndex];e?.scrollIntoView({block:"nearest"})}))}selectItem(t){this.itemSelected.emit(t),this.close()}render(){const t=null!=this.selectedItem,e=`${this.inputId}-listbox`;return i(s,{key:"e95aedae8c83fe27ef5e94065bd34a0c105ab565",class:"s-searchable-dropdown"},i("div",{key:"3bd95a9a3652934d7a0904b6813f372a517dc415",class:{"s-searchable-dropdown":!0,"s-searchable-dropdown--open":this.isOpen}},this.label&&i("label",{key:"85b95c812b9aa2c496b394a750c362d69c50546a",class:"s-searchable-dropdown-label",htmlFor:this.inputId},this.label,this.required&&i("span",{key:"a863108db25faffd654d2a49832c9ab78c4d3124",class:"s-searchable-dropdown-required"}," *")),i("div",{key:"fb3ce40726d9b5f0060d1279bd0a17339da978b1",class:{"s-searchable-dropdown-trigger":!0,"s-searchable-dropdown-trigger--disabled":this.disabled||this.loading,"s-searchable-dropdown-trigger--open":this.isOpen},role:"combobox","aria-expanded":this.isOpen?"true":"false","aria-haspopup":"listbox","aria-controls":e,"aria-disabled":this.disabled||this.loading?"true":"false",tabIndex:this.disabled||this.loading?-1:0,onClick:this.handleTriggerClick,onKeyDown:this.handleTriggerKeyDown},t?i("span",{class:"s-searchable-dropdown-trigger-text"},this.getDisplayName(this.selectedItem)):i("span",{class:"s-searchable-dropdown-trigger-placeholder"},this.placeholder),i("i",{key:"493e615e79b3483aca3bf2b40c45b8be38190788",class:{"sicon-keyboard_arrow_down":!0,"s-searchable-dropdown-trigger-icon":!0,"s-searchable-dropdown-trigger-icon--open":this.isOpen},"aria-hidden":"true"})),this.isOpen&&i("div",{key:"db839d1fcc73c7bc68cd324ca2e8c91f42bb991c",class:{"s-searchable-dropdown-panel":!0,"s-searchable-dropdown-panel--up":this.dropUp},ref:t=>this.panelRef=t},this.searchable&&i("div",{key:"d3b91389e90e87345672cd7ec630b555114372b2",class:"s-searchable-dropdown-search-wrap"},i("i",{key:"67d56ff8ad837b683d12fb750ccee6412bd8de4c",class:"sicon-search s-searchable-dropdown-search-icon","aria-hidden":"true"}),i("input",{key:"f400a683b9b54ae8e448279ce19130cb346dcc5f",ref:t=>this.searchInputRef=t,id:this.inputId,type:"text",class:"s-searchable-dropdown-search-input",placeholder:this.placeholder,value:this.clientSearch?this.clientSearchQuery:this.searchQuery,onInput:this.handleSearchInputChange,onKeyDown:this.handleSearchKeyDown,autocomplete:"off","aria-autocomplete":"list","aria-expanded":this.isOpen?"true":"false","aria-controls":e})),i("div",{key:"75bd2f369824326cb1ef87c5f3dad2e80975f4d9",id:e,class:"s-searchable-dropdown-list s-scrollbar",role:"listbox"},this.renderListContent()))))}renderListContent(){if(this.searching||this.loading)return i("div",{class:"s-searchable-dropdown-loading"},i("svg",{class:"s-searchable-dropdown-spinner",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round",opacity:"0.25"}),i("path",{d:"M12 2a10 10 0 0 1 10 10",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round"})));const t=this.filteredItems;return 0===t.length?i("div",{class:"s-searchable-dropdown-empty"},this.noResultsText||salla?.lang?.get("common.elements.no_options")||"No results found"):t.map(((t,e)=>{const s=this.selectedItem?.id===t.id;return i("button",{key:t.id,type:"button",role:"option",class:{"s-searchable-dropdown-item":!0,"s-searchable-dropdown-item--selected":s,"s-searchable-dropdown-item--focused":this.focusedIndex===e&&!s},"aria-selected":s?"true":"false",onClick:()=>this.selectItem(t)},i("span",{class:{"s-searchable-dropdown-item-name":!0,"s-searchable-dropdown-item-name--selected":s}},this.getDisplayName(t)),s&&i("i",{class:"sicon-check s-searchable-dropdown-item-check","aria-hidden":"true"}))}))}get host(){return o(this)}static get watchers(){return{items:["onItemsChange"]}}};export{$s as salla_bullet_delivery,Ms as salla_searchable_dropdown}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as s,h as t,H as o}from"./p-
|
|
4
|
+
import{r as s,h as t,H as o}from"./p-DNWyGkAx.js";const e=class{constructor(t){s(this,t),this.bordered=!0,this.placeholderImage="images/placeholder.png",this.optionsData=[]}componentWillLoad(){this.parseOptionsData()}componentWillUpdate(){this.parseOptionsData()}parseOptionsData(){if(this.options)if("string"==typeof this.options)try{this.optionsData=JSON.parse(this.options)}catch(s){this.optionsData=[]}else this.optionsData=Array.isArray(this.options)?this.options:[];else this.optionsData=[]}renderOptionValue(s){return s.is_image?t("div",{class:"s-order-details-option-image-container"},t("a",{href:s.value,target:"_blank"},t("img",{class:"s-order-details-option-image",src:s.value||this.placeholderImage,alt:s.name}))):s.color?t("span",{title:s.value,class:"s-order-details-option-color-swatch",style:{backgroundColor:s.color}}):s.is_file?t("a",{href:s.value,target:"_blank",class:"s-order-details-option-file-link"},salla.lang.get("common.elements.attachments")):s.is_color_picker?t("div",{class:"s-order-details-option-color-picker"},t("div",{class:"s-order-details-option-color-picker-content"},t("span",{class:"s-order-details-option-color-picker-text"},s.value),t("span",{class:"s-order-details-option-color-picker-swatch",style:{backgroundColor:s.value,width:"1rem"}})),t("salla-button",{onClick:t=>this.copyToClipboard(t,s.value),shape:"link",class:"s-order-details-option-color-picker-button"},t("span",{class:"s-order-details-option-color-copy-icon",innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>swap-fill</title>\n<path d="M28 10.667h-2.667c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333h2.667c0.735 0 1.333 0.597 1.333 1.333v13.333c0 0.736-0.599 1.333-1.333 1.333h-13.333c-0.735 0-1.333-0.597-1.333-1.333v-2.667c0-0.737-0.597-1.333-1.333-1.333s-1.333 0.596-1.333 1.333v2.667c0 2.205 1.795 4 4 4h13.333c2.205 0 4-1.795 4-4v-13.333c0-2.205-1.795-4-4-4zM21.333 17.333v-13.333c0-2.205-1.795-4-4-4h-13.333c-2.205 0-4 1.795-4 4v13.333c0 2.205 1.795 4 4 4h13.333c2.205 0 4-1.795 4-4zM2.667 17.333v-13.333c0-0.736 0.599-1.333 1.333-1.333h13.333c0.735 0 1.333 0.597 1.333 1.333v13.333c0 0.736-0.599 1.333-1.333 1.333h-13.333c-0.735 0-1.333-0.597-1.333-1.333z"></path>\n</svg>\n'}))):s.is_map&&s.latitude&&s.longitude?t("salla-map",{id:`location_map_${s.id}`,class:`map_${s.id}`,zoom:15,readonly:!0,lat:s.latitude,lng:s.longitude},t("div",{slot:"button"},t("button",{type:"button",class:"s-order-details-option-map-button",onClick:()=>this.openMap(s.id)},salla.lang.get("common.elements.show_location")))):t("span",{class:"s-order-details-option-default-text"},s.display_value||s.value)}copyToClipboard(s,t){s.preventDefault(),navigator.clipboard&&navigator.clipboard.writeText(t)}openMap(s){const t=document.querySelector(`salla-map.map_${s}`);t&&t.open&&t.open()}render(){if(!this.optionsData.length)return null;const s=this.bordered?"s-order-details-options-container":"s-order-details-options-container-borderless";return t(o,{class:"s-order-details-options-wrapper"},t("h2",{class:"s-order-details-options-title"},salla.lang.get("pages.cart.item_options")),t("div",{class:s},t("dl",{class:"s-order-details-options-list"},this.optionsData.map((s=>t("div",{key:s.id,class:"s-order-details-options-item"},t("dt",{class:"s-order-details-options-item-name"},s.name,":"),t("dd",{class:s.is_image?"s-order-details-options-item-value-image":"s-order-details-options-item-value-text"},this.renderOptionValue(s))))))))}};e.style="";export{e as salla_order_details_options}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,h as a,H as s,a as l}from"./p-
|
|
4
|
+
import{r as t,h as a,H as s,a as l}from"./p-DNWyGkAx.js";const i=class{constructor(a){t(this,a),this.alertDelay=null,this.data=salla.config.get("store.app_install_prompt"),this.open=!1,this.closing=!1}connectedCallback(){salla.onReady((()=>{if(this.data=salla.config.get("store.app_install_prompt"),this.isMobileOrTabletDevice()){if(!this.data)return salla.logger.error("Failed to retrieve salla-app-install-alert config");this.ctaLink=salla.url.get("app"),this.alertDelay=setTimeout((()=>this.open=!0),3e3)}}))}disconnectedCallback(){clearTimeout(this.alertDelay)}isMobileOrTabletDevice(t=1024){if("undefined"==typeof window||"undefined"==typeof navigator||"undefined"==typeof document)return!1;const a=window.matchMedia(`(max-width: ${t}px)`).matches,s=/Macintosh|Android|iPhone|iPad|iPod/i.test(navigator.userAgent),l="ontouchstart"in window||"ontouchend"in document||navigator.maxTouchPoints>0;return s&&a&&l}closeAlert(){salla.storage.set("app_install_prompt_disabled",!0),this.closing=!0,this.host.addEventListener("animationend",(()=>{this.closing=!1,this.open=!1}),{once:!0})}shouldShowAlert(){return!salla.config.isMobileApp()}render(){return this.data&&this.shouldShowAlert()?a(s,{class:`s-app-install-alert-wrapper ${this.open?"open":""} ${this.closing?"closing":""}`,position:this.data.position},a("div",null,a("img",{src:this.data.icon,width:"58",height:"58",alt:`${salla.config.get("store.name")}`})),a("div",{class:"s-app-install-alert-content"},a("h2",{class:"s-app-install-alert-title"},this.data.title),a("p",{class:"s-app-install-alert-sub-title"},this.data.sub_title," "," ",a("a",{href:this.ctaLink,target:"_blank","aria-label":"download app",class:"s-app-install-alert-cta"},salla.lang.getWithDefault("blocks.footer.download_app_now","حمله الآن")))),a("button",{class:"s-app-install-alert-cancel-button","aria-label":"close alert",onClick:()=>this.closeAlert()},a("i",{class:"sicon-cancel"}))):null}get host(){return l(this)}};i.style=":host{display:block}";export{i as salla_app_install_alert}
|