PluginProbe ʕ •ᴥ•ʔ
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / trunk
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments vtrunk
4.7.0 4.6.6 4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.1 4.5.0 4.4.2 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.3 4.2.2 4.2.1 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.11.0 1.11.1 1.11.2 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.9.0 1.9.1 1.9.2 1.9.3 1.9.4 1.9.5 2.0.0 2.0.1 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.10.0 2.10.1 2.11.0 2.11.1 2.11.2 2.11.3 2.11.4 2.12.0 2.13.0 2.14.0 2.14.1 2.15.0 2.15.1 2.16.0 2.16.1 2.16.2 2.16.3 2.17.0 2.17.1 2.17.2 2.18.0 2.19.0 2.19.2 2.19.3 2.19.4 2.2.0 2.2.1 2.20.0 2.20.1 2.20.2 2.20.3 2.20.4 2.20.5 2.20.6 2.21.0 2.22.0 2.22.1 2.23.0 2.24.0 2.25.0 2.25.1 2.25.2 2.26.0 2.27.0 2.27.1 2.28.0 2.29.0 2.29.1 2.29.2 2.29.3 2.29.4 2.3.0 2.3.1 2.30.0 2.31.0 2.31.1 2.31.2 2.31.3 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.40.0 2.40.1 2.5.0 2.5.1 2.5.2 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.9.0 3.0.0 3.0.0-RC1 3.0.0-RC2 3.0.0-beta1 3.0.0-beta2 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.10.0 3.10.1 3.11.0 3.12.0 3.13.0 3.13.1 3.13.2 3.13.3 3.13.4 3.14.0 3.15.0 3.15.1 3.15.2 3.15.3 3.15.4 3.15.5 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.16.6 3.16.7 3.16.8 3.17.0 3.17.1 3.17.2 3.17.3 3.17.4 3.17.5 3.17.6 3.18.0 3.19.0 3.19.1 3.19.2 3.2.0 3.2.1 3.2.2 3.20.0 3.20.1 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 4.0.0 4.0.1 4.0.2 4.0.3 trunk 4.1.0 0.2.19.1 4.1.1 1.0.0 4.2.0 1.0.1 1.0.2
surecart / dist / components / cjs / sc-checkout-autofill-provider_11.cjs.entry.js
surecart / dist / components / cjs Last commit date
MockProcessor-ad11752f.js 2 months ago MockProcessor-ad11752f.js.map 2 months ago add-query-args-49dcb630.js 1 year ago add-query-args-49dcb630.js.map 1 year ago address-7404695f.js 4 months ago address-7404695f.js.map 4 months ago animation-registry-b597d2f4.js 3 months ago animation-registry-b597d2f4.js.map 3 months ago app-globals-464bf4c9.js 3 months ago app-globals-464bf4c9.js.map 3 months ago consumer-b58230e6.js 2 months ago consumer-b58230e6.js.map 2 months ago currency-71fce0f0.js 1 year ago currency-71fce0f0.js.map 1 year ago error-66b4ae42.js 1 week ago error-66b4ae42.js.map 1 week ago fetch-5e8dc1d5.js 1 month ago fetch-5e8dc1d5.js.map 1 month ago floating-ui.dom.esm-7fad5c49.js 6 months ago floating-ui.dom.esm-7fad5c49.js.map 6 months ago form-data-0da9940f.js 1 year ago form-data-0da9940f.js.map 1 year ago functions-033a6a55.js 3 months ago functions-033a6a55.js.map 3 months ago geo-permission-8128c254.js 1 month ago geo-permission-8128c254.js.map 1 month ago getters-4e5fc4d4.js 1 week ago getters-4e5fc4d4.js.map 1 week ago getters-68a0d178.js 2 months ago getters-68a0d178.js.map 2 months ago getters-bc65a40b.js 2 months ago getters-bc65a40b.js.map 2 months ago getters-c3cd6c93.js 1 week ago getters-c3cd6c93.js.map 1 week ago getters-d68c08ed.js 2 months ago getters-d68c08ed.js.map 2 months ago google-5d965da2.js 1 week ago google-5d965da2.js.map 1 week ago google-8dbad1a6.js 1 week ago google-8dbad1a6.js.map 1 week ago google-maps-8b4e4fed.js 2 days ago google-maps-8b4e4fed.js.map 2 days ago index-7ced8198.js 2 months ago index-7ced8198.js.map 2 months ago index-a4a4f390.js 1 month ago index-a4a4f390.js.map 1 month ago index-adacfa36.js 1 year ago index-adacfa36.js.map 1 year ago index-be4abba1.js 2 months ago index-be4abba1.js.map 2 months ago index-c2d0eb49.js 1 week ago index-c2d0eb49.js.map 1 week ago index-c3de642f.js 2 months ago index-c3de642f.js.map 2 months ago index-f3933112.js 1 month ago index-f3933112.js.map 1 month ago index-fb76df07.js 2 years ago index-fb76df07.js.map 2 years ago index.cjs.js 1 week ago index.cjs.js.map 1 month ago inline-aa15f113.js 1 year ago inline-aa15f113.js.map 1 year ago lazy-2b509fa7.js 1 year ago lazy-2b509fa7.js.map 1 year ago library-08bc52a5.js 3 months ago library-08bc52a5.js.map 3 months ago loader.cjs.js 2 days ago loader.cjs.js.map 1 year ago media-43b85f3d.js 1 year ago media-43b85f3d.js.map 1 year ago mutations-463da571.js 1 week ago mutations-463da571.js.map 1 week ago mutations-627c79a0.js 1 week ago mutations-627c79a0.js.map 1 week ago mutations-98f05402.js 1 week ago mutations-98f05402.js.map 1 week ago mutations-d5d6ddf1.js 2 months ago mutations-d5d6ddf1.js.map 2 months ago page-align-5a2ab493.js 1 year ago page-align-5a2ab493.js.map 1 year ago price-da3cab3d.js 4 months ago price-da3cab3d.js.map 4 months ago pure-bd6f0a6e.js 1 year ago pure-bd6f0a6e.js.map 1 year ago quantity-aa458329.js 3 months ago quantity-aa458329.js.map 3 months ago razorpay-88fe8897.js 3 months ago razorpay-88fe8897.js.map 3 months ago remove-query-args-b57e8cd3.js 1 year ago remove-query-args-b57e8cd3.js.map 1 year ago sc-address_5.cjs.entry.js 2 days ago sc-address_5.cjs.entry.js.map 2 days ago sc-alert.cjs.entry.js 1 month ago sc-alert.cjs.entry.js.map 1 year ago sc-avatar_2.cjs.entry.js 1 week ago sc-avatar_2.cjs.entry.js.map 1 month ago sc-badge-notice.cjs.entry.js 1 month ago sc-badge-notice.cjs.entry.js.map 1 year ago sc-block-ui.cjs.entry.js 1 month ago sc-block-ui.cjs.entry.js.map 5 months ago sc-breadcrumb.cjs.entry.js 1 month ago sc-breadcrumb.cjs.entry.js.map 1 year ago sc-breadcrumbs.cjs.entry.js 1 month ago sc-breadcrumbs.cjs.entry.js.map 1 year ago sc-button-group.cjs.entry.js 1 month ago sc-button-group.cjs.entry.js.map 1 year ago sc-button_6.cjs.entry.js 1 month ago sc-button_6.cjs.entry.js.map 1 month ago sc-cancel-dialog_3.cjs.entry.js 1 month ago sc-cancel-dialog_3.cjs.entry.js.map 1 month ago sc-cancel-discount_4.cjs.entry.js 1 month ago sc-cancel-discount_4.cjs.entry.js.map 2 months ago sc-card_2.cjs.entry.js 1 month ago sc-card_2.cjs.entry.js.map 4 months ago sc-cart-button.cjs.entry.js 1 week ago sc-cart-button.cjs.entry.js.map 1 year ago sc-cart-form-submit.cjs.entry.js 2 months ago sc-cart-form-submit.cjs.entry.js.map 1 year ago sc-cart-form.cjs.entry.js 1 week ago sc-cart-form.cjs.entry.js.map 1 month ago sc-cart-header.cjs.entry.js 1 week ago sc-cart-header.cjs.entry.js.map 1 year ago sc-cart-icon.cjs.entry.js 1 week ago sc-cart-icon.cjs.entry.js.map 1 year ago sc-cart-loader.cjs.entry.js 1 week ago sc-cart-loader.cjs.entry.js.map 1 year ago sc-cart-session-provider_3.cjs.entry.js 2 days ago sc-cart-session-provider_3.cjs.entry.js.map 2 days ago sc-cart-submit.cjs.entry.js 2 months ago sc-cart-submit.cjs.entry.js.map 1 year ago sc-cart.cjs.entry.js 1 week ago sc-cart.cjs.entry.js.map 2 months ago sc-cc-logo_2.cjs.entry.js 1 month ago sc-cc-logo_2.cjs.entry.js.map 1 month ago sc-charges-list.cjs.entry.js 1 month ago sc-charges-list.cjs.entry.js.map 2 months ago sc-checkout-autofill-provider_11.cjs.entry.js 2 days ago sc-checkout-autofill-provider_11.cjs.entry.js.map 2 days ago sc-checkout-form-errors.cjs.entry.js 2 months ago sc-checkout-form-errors.cjs.entry.js.map 1 year ago sc-checkout-mollie-payment_3.cjs.entry.js 1 week ago sc-checkout-mollie-payment_3.cjs.entry.js.map 2 months ago sc-checkout-product-bundle-component-variants.cjs.entry.js 1 week ago sc-checkout-product-bundle-component-variants.cjs.entry.js.map 1 month ago sc-checkout-product-price-variant-selector.cjs.entry.js 1 week ago sc-checkout-product-price-variant-selector.cjs.entry.js.map 1 month ago sc-checkout.cjs.entry.js 1 week ago sc-checkout.cjs.entry.js.map 1 month ago sc-choice-container.cjs.entry.js 1 month ago sc-choice-container.cjs.entry.js.map 1 year ago sc-choice.cjs.entry.js 1 month ago sc-choice.cjs.entry.js.map 1 year ago sc-choices.cjs.entry.js 1 month ago sc-choices.cjs.entry.js.map 1 year ago sc-column_2.cjs.entry.js 1 month ago sc-column_2.cjs.entry.js.map 1 month ago sc-compact-address_18.cjs.entry.js 2 days ago sc-compact-address_18.cjs.entry.js.map 1 month ago sc-conditional-form.cjs.entry.js 1 week ago sc-conditional-form.cjs.entry.js.map 2 months ago sc-consumer.cjs.entry.js 2 months ago sc-consumer.cjs.entry.js.map 1 year ago sc-coupon-form.cjs.entry.js 1 week ago sc-coupon-form.cjs.entry.js.map 5 months ago sc-custom-order-price-input.cjs.entry.js 1 month ago sc-custom-order-price-input.cjs.entry.js.map 2 months ago sc-customer-details.cjs.entry.js 1 month ago sc-customer-details.cjs.entry.js.map 7 months ago sc-customer-edit.cjs.entry.js 1 month ago sc-customer-edit.cjs.entry.js.map 2 months ago sc-customer-email.cjs.entry.js 1 week ago sc-customer-email.cjs.entry.js.map 1 month ago sc-customer-firstname.cjs.entry.js 1 week ago sc-customer-firstname.cjs.entry.js.map 2 months ago sc-customer-lastname.cjs.entry.js 1 week ago sc-customer-lastname.cjs.entry.js.map 2 months ago sc-customer-name.cjs.entry.js 1 week ago sc-customer-name.cjs.entry.js.map 2 months ago sc-dashboard-customer-details.cjs.entry.js 1 month ago sc-dashboard-customer-details.cjs.entry.js.map 2 months ago sc-dashboard-downloads-list.cjs.entry.js 1 month ago sc-dashboard-downloads-list.cjs.entry.js.map 2 months ago sc-dialog.cjs.entry.js 1 month ago sc-dialog.cjs.entry.js.map 5 months ago sc-divider.cjs.entry.js 1 month ago sc-divider.cjs.entry.js.map 1 year ago sc-donation-choices.cjs.entry.js 2 months ago sc-donation-choices.cjs.entry.js.map 1 year ago sc-downloads-list.cjs.entry.js 1 month ago sc-downloads-list.cjs.entry.js.map 1 month ago sc-dropdown_3.cjs.entry.js 1 month ago sc-dropdown_3.cjs.entry.js.map 6 months ago sc-empty_3.cjs.entry.js 1 month ago sc-empty_3.cjs.entry.js.map 4 months ago sc-express-payment.cjs.entry.js 1 week ago sc-express-payment.cjs.entry.js.map 3 months ago sc-feature-demo-banner.cjs.entry.js 1 month ago sc-feature-demo-banner.cjs.entry.js.map 1 year ago sc-flex.cjs.entry.js 1 month ago sc-flex.cjs.entry.js.map 1 year ago sc-form-control_2.cjs.entry.js 1 month ago sc-form-control_2.cjs.entry.js.map 2 months ago sc-form-row.cjs.entry.js 1 month ago sc-form-row.cjs.entry.js.map 1 year ago sc-form.cjs.entry.js 1 month ago sc-form.cjs.entry.js.map 1 year ago sc-format-bytes.cjs.entry.js 2 months ago sc-format-bytes.cjs.entry.js.map 1 year ago sc-format-interval.cjs.entry.js 2 months ago sc-format-interval.cjs.entry.js.map 1 year ago sc-format-number.cjs.entry.js 2 months ago sc-format-number.cjs.entry.js.map 1 year ago sc-fulfillment-shipping-status-badge.cjs.entry.js 2 days ago sc-fulfillment-shipping-status-badge.cjs.entry.js.map 2 days ago sc-fulfillments.cjs.entry.js 2 days ago sc-fulfillments.cjs.entry.js.map 2 days ago sc-heading_2.cjs.entry.js 1 month ago sc-heading_2.cjs.entry.js.map 1 year ago sc-image-slider.cjs.entry.js 1 month ago sc-image-slider.cjs.entry.js.map 1 month ago sc-invoice-status-badge.cjs.entry.js 1 month ago sc-invoice-status-badge.cjs.entry.js.map 4 months ago sc-invoices-list.cjs.entry.js 1 month ago sc-invoices-list.cjs.entry.js.map 2 months ago sc-license.cjs.entry.js 1 month ago sc-license.cjs.entry.js.map 2 months ago sc-licenses-list.cjs.entry.js 1 month ago sc-licenses-list.cjs.entry.js.map 1 month ago sc-line-item-bump.cjs.entry.js 1 week ago sc-line-item-bump.cjs.entry.js.map 1 year ago sc-line-item-total.cjs.entry.js 1 week ago sc-line-item-total.cjs.entry.js.map 6 months ago sc-line-item.cjs.entry.js 1 month ago sc-line-item.cjs.entry.js.map 1 year ago sc-line-items-provider.cjs.entry.js 1 month ago sc-line-items-provider.cjs.entry.js.map 1 year ago sc-line-items.cjs.entry.js 1 week ago sc-line-items.cjs.entry.js.map 1 month ago sc-login-form.cjs.entry.js 1 month ago sc-login-form.cjs.entry.js.map 2 months ago sc-manual-payment-method_3.cjs.entry.js 1 month ago sc-manual-payment-method_3.cjs.entry.js.map 3 months ago sc-menu-divider.cjs.entry.js 1 month ago sc-menu-divider.cjs.entry.js.map 1 year ago sc-menu-label_2.cjs.entry.js 2 days ago sc-menu-label_2.cjs.entry.js.map 2 days ago sc-mollie-add-method.cjs.entry.js 1 month ago sc-mollie-add-method.cjs.entry.js.map 2 months ago sc-order-confirmation-customer.cjs.entry.js 2 months ago sc-order-confirmation-customer.cjs.entry.js.map 1 year ago sc-order-confirmation-details.cjs.entry.js 2 months ago sc-order-confirmation-details.cjs.entry.js.map 11 months ago sc-order-confirmation-line-items_2.cjs.entry.js 1 month ago sc-order-confirmation-line-items_2.cjs.entry.js.map 1 month ago sc-order-confirmation.cjs.entry.js 1 month ago sc-order-confirmation.cjs.entry.js.map 2 months ago sc-order-coupon-form.cjs.entry.js 1 week ago sc-order-coupon-form.cjs.entry.js.map 2 months ago sc-order-detail.cjs.entry.js 2 months ago sc-order-detail.cjs.entry.js.map 1 year ago sc-order-fulfillment-badge.cjs.entry.js 1 month ago sc-order-fulfillment-badge.cjs.entry.js.map 4 months ago sc-order-manual-instructions.cjs.entry.js 2 months ago sc-order-manual-instructions.cjs.entry.js.map 1 year ago sc-order-password.cjs.entry.js 2 months ago sc-order-password.cjs.entry.js.map 1 year ago sc-order-return-badge.cjs.entry.js 1 month ago sc-order-return-badge.cjs.entry.js.map 4 months ago sc-order-shipment-badge.cjs.entry.js 2 days ago sc-order-shipment-badge.cjs.entry.js.map 2 days ago sc-order-status-badge.cjs.entry.js 1 month ago sc-order-status-badge.cjs.entry.js.map 4 months ago sc-order-submit.cjs.entry.js 1 week ago sc-order-submit.cjs.entry.js.map 2 months ago sc-order-summary.cjs.entry.js 1 week ago sc-order-summary.cjs.entry.js.map 1 month ago sc-order.cjs.entry.js 1 month ago sc-order.cjs.entry.js.map 1 month ago sc-orders-list.cjs.entry.js 2 days ago sc-orders-list.cjs.entry.js.map 2 days ago sc-pagination.cjs.entry.js 2 months ago sc-pagination.cjs.entry.js.map 1 year ago sc-password-nag.cjs.entry.js 1 month ago sc-password-nag.cjs.entry.js.map 2 months ago sc-password.cjs.entry.js 1 month ago sc-password.cjs.entry.js.map 1 month ago sc-payment-method-choice_2.cjs.entry.js 1 month ago sc-payment-method-choice_2.cjs.entry.js.map 1 year ago sc-payment-method-details.cjs.entry.js 1 month ago sc-payment-method-details.cjs.entry.js.map 1 year ago sc-payment-methods-list.cjs.entry.js 1 month ago sc-payment-methods-list.cjs.entry.js.map 2 months ago sc-payment.cjs.entry.js 1 week ago sc-payment.cjs.entry.js.map 3 months ago sc-paypal-add-method.cjs.entry.js 1 month ago sc-paypal-add-method.cjs.entry.js.map 2 months ago sc-paypal-buttons_2.cjs.entry.js 1 week ago sc-paypal-buttons_2.cjs.entry.js.map 2 months ago sc-paystack-add-method.cjs.entry.js 1 month ago sc-paystack-add-method.cjs.entry.js.map 2 months ago sc-pill-option.cjs.entry.js 1 month ago sc-pill-option.cjs.entry.js.map 1 year ago sc-popover.cjs.entry.js 1 month ago sc-popover.cjs.entry.js.map 6 months ago sc-premium-tag.cjs.entry.js 1 month ago sc-premium-tag.cjs.entry.js.map 1 year ago sc-price-choice-container.cjs.entry.js 1 month ago sc-price-choice-container.cjs.entry.js.map 1 month ago sc-price-choice.cjs.entry.js 1 month ago sc-price-choice.cjs.entry.js.map 2 months ago sc-price-choices.cjs.entry.js 1 week ago sc-price-choices.cjs.entry.js.map 1 year ago sc-price-input.cjs.entry.js 1 month ago sc-price-input.cjs.entry.js.map 1 year ago sc-price-range_4.cjs.entry.js 1 month ago sc-price-range_4.cjs.entry.js.map 1 year ago sc-price.cjs.entry.js 2 months ago sc-price.cjs.entry.js.map 11 months ago sc-product-buy-button.cjs.entry.js 1 week ago sc-product-buy-button.cjs.entry.js.map 2 months ago sc-product-donation-amount-choice.cjs.entry.js 1 week ago sc-product-donation-amount-choice.cjs.entry.js.map 2 months ago sc-product-donation-choices.cjs.entry.js 1 week ago sc-product-donation-choices.cjs.entry.js.map 2 months ago sc-product-donation-custom-amount.cjs.entry.js 1 week ago sc-product-donation-custom-amount.cjs.entry.js.map 2 months ago sc-product-item-list.cjs.entry.js 1 week ago sc-product-item-list.cjs.entry.js.map 2 months ago sc-product-item.cjs.entry.js 1 month ago sc-product-item.cjs.entry.js.map 1 year ago sc-product-pills-variant-option.cjs.entry.js 1 week ago sc-product-pills-variant-option.cjs.entry.js.map 1 year ago sc-product-price-choices.cjs.entry.js 1 week ago sc-product-price-choices.cjs.entry.js.map 1 year ago sc-product-price-modal.cjs.entry.js 1 week ago sc-product-price-modal.cjs.entry.js.map 2 months ago sc-product-price.cjs.entry.js 1 week ago sc-product-price.cjs.entry.js.map 2 months ago sc-product-quantity.cjs.entry.js 1 week ago sc-product-quantity.cjs.entry.js.map 1 year ago sc-product-selected-price.cjs.entry.js 1 week ago sc-product-selected-price.cjs.entry.js.map 2 months ago sc-product-text.cjs.entry.js 1 week ago sc-product-text.cjs.entry.js.map 1 year ago sc-provider.cjs.entry.js 2 months ago sc-provider.cjs.entry.js.map 1 year ago sc-provisional-banner.cjs.entry.js 1 month ago sc-provisional-banner.cjs.entry.js.map 11 months ago sc-purchase-downloads-list.cjs.entry.js 1 month ago sc-purchase-downloads-list.cjs.entry.js.map 1 month ago sc-razorpay-add-method.cjs.entry.js 1 month ago sc-razorpay-add-method.cjs.entry.js.map 2 months ago sc-recurring-price-choice-container.cjs.entry.js 2 months ago sc-recurring-price-choice-container.cjs.entry.js.map 1 year ago sc-review-stars.cjs.entry.js 2 months ago sc-review-stars.cjs.entry.js.map 6 months ago sc-rich-text.cjs.entry.js 1 month ago sc-rich-text.cjs.entry.js.map 1 month ago sc-skeleton.cjs.entry.js 1 month ago sc-skeleton.cjs.entry.js.map 1 year ago sc-spacing.cjs.entry.js 1 month ago sc-spacing.cjs.entry.js.map 1 year ago sc-stripe-add-method.cjs.entry.js 1 month ago sc-stripe-add-method.cjs.entry.js.map 2 months ago sc-stripe-element.cjs.entry.js 1 week ago sc-stripe-element.cjs.entry.js.map 2 months ago sc-stripe-payment-element.cjs.entry.js 1 week ago sc-stripe-payment-element.cjs.entry.js.map 2 months ago sc-stripe-payment-request.cjs.entry.js 1 week ago sc-stripe-payment-request.cjs.entry.js.map 2 months ago sc-subscription-ad-hoc-confirm.cjs.entry.js 1 month ago sc-subscription-ad-hoc-confirm.cjs.entry.js.map 6 months ago sc-subscription-details_2.cjs.entry.js 1 month ago sc-subscription-details_2.cjs.entry.js.map 1 month ago sc-subscription-payment-method.cjs.entry.js 1 month ago sc-subscription-payment-method.cjs.entry.js.map 2 months ago sc-subscription-payment.cjs.entry.js 1 month ago sc-subscription-payment.cjs.entry.js.map 2 months ago sc-subscription-switch.cjs.entry.js 1 month ago sc-subscription-switch.cjs.entry.js.map 2 months ago sc-subscription-variation-confirm.cjs.entry.js 1 month ago sc-subscription-variation-confirm.cjs.entry.js.map 1 year ago sc-subscription.cjs.entry.js 1 month ago sc-subscription.cjs.entry.js.map 1 month ago sc-subscriptions-list.cjs.entry.js 1 month ago sc-subscriptions-list.cjs.entry.js.map 2 months ago sc-summary.cjs.entry.js 1 month ago sc-summary.cjs.entry.js.map 1 year ago sc-swap.cjs.entry.js 1 week ago sc-swap.cjs.entry.js.map 2 months ago sc-switch.cjs.entry.js 1 month ago sc-switch.cjs.entry.js.map 7 months ago sc-tab-group.cjs.entry.js 1 month ago sc-tab-group.cjs.entry.js.map 1 year ago sc-tab-panel.cjs.entry.js 1 month ago sc-tab-panel.cjs.entry.js.map 1 year ago sc-tab.cjs.entry.js 1 month ago sc-tab.cjs.entry.js.map 1 year ago sc-table-head.cjs.entry.js 1 month ago sc-table-head.cjs.entry.js.map 1 year ago sc-table_3.cjs.entry.js 1 month ago sc-table_3.cjs.entry.js.map 10 months ago sc-tag.cjs.entry.js 1 month ago sc-tag.cjs.entry.js.map 4 months ago sc-test-mode-info.cjs.entry.js 1 month ago sc-test-mode-info.cjs.entry.js.map 6 months ago sc-text.cjs.entry.js 1 month ago sc-text.cjs.entry.js.map 1 year ago sc-toggle.cjs.entry.js 1 month ago sc-toggle.cjs.entry.js.map 1 year ago sc-toggles.cjs.entry.js 1 month ago sc-toggles.cjs.entry.js.map 1 year ago sc-total.cjs.entry.js 1 week ago sc-total.cjs.entry.js.map 1 year ago sc-upcoming-invoice.cjs.entry.js 1 month ago sc-upcoming-invoice.cjs.entry.js.map 2 months ago sc-upgrade-required.cjs.entry.js 2 months ago sc-upgrade-required.cjs.entry.js.map 1 year ago sc-upsell-countdown-timer.cjs.entry.js 1 month ago sc-upsell-countdown-timer.cjs.entry.js.map 1 year ago sc-upsell-no-thanks-button.cjs.entry.js 1 week ago sc-upsell-no-thanks-button.cjs.entry.js.map 2 months ago sc-upsell-submit-button.cjs.entry.js 1 week ago sc-upsell-submit-button.cjs.entry.js.map 2 months ago sc-upsell-totals.cjs.entry.js 1 week ago sc-upsell-totals.cjs.entry.js.map 2 months ago sc-upsell.cjs.entry.js 1 week ago sc-upsell.cjs.entry.js.map 2 months ago sc-verification-code.cjs.entry.js 1 month ago sc-verification-code.cjs.entry.js.map 2 months ago sc-visually-hidden.cjs.entry.js 1 month ago sc-visually-hidden.cjs.entry.js.map 1 year ago sc-wordpress-password-edit.cjs.entry.js 1 month ago sc-wordpress-password-edit.cjs.entry.js.map 2 months ago sc-wordpress-user-edit.cjs.entry.js 1 month ago sc-wordpress-user-edit.cjs.entry.js.map 2 months ago sc-wordpress-user.cjs.entry.js 1 month ago sc-wordpress-user.cjs.entry.js.map 1 year ago store-01e8edc2.js 2 months ago store-01e8edc2.js.map 2 months ago store-401bdb4d.js 2 months ago store-401bdb4d.js.map 2 months ago store-9c215436.js 1 month ago store-9c215436.js.map 1 month ago surecart.cjs.js 2 days ago surecart.cjs.js.map 1 year ago tax-a4582e73.js 1 year ago tax-a4582e73.js.map 1 year ago universe-1db52218.js 2 months ago universe-1db52218.js.map 2 months ago util-a15c420c.js 2 months ago util-a15c420c.js.map 2 months ago utils-a9d13080.js 3 months ago utils-a9d13080.js.map 3 months ago verification-19455819.js 1 month ago verification-19455819.js.map 1 month ago watchers-08c6f04b.js 1 week ago watchers-08c6f04b.js.map 1 week ago watchers-517825ae.js 2 months ago watchers-517825ae.js.map 2 months ago watchers-a136c7bc.js 1 week ago watchers-a136c7bc.js.map 1 week ago watchers-b5cd03f1.js 1 week ago watchers-b5cd03f1.js.map 1 week ago watchers-c1bcf0a8.js 1 week ago watchers-c1bcf0a8.js.map 1 week ago
sc-checkout-autofill-provider_11.cjs.entry.js
1619 lines
1 'use strict';
2
3 Object.defineProperty(exports, '__esModule', { value: true });
4
5 const index = require('./index-be4abba1.js');
6 const mutations = require('./mutations-98f05402.js');
7 const mutations$1 = require('./mutations-627c79a0.js');
8 const store = require('./store-9c215436.js');
9 const index$2 = require('./index-c2d0eb49.js');
10 const index$1 = require('./index-a4a4f390.js');
11 const geoPermission = require('./geo-permission-8128c254.js');
12 const getters = require('./getters-d68c08ed.js');
13 const index$3 = require('./index-f3933112.js');
14 require('./watchers-c1bcf0a8.js');
15 const getters$1 = require('./getters-4e5fc4d4.js');
16 const watchers = require('./watchers-517825ae.js');
17 const getters$2 = require('./getters-c3cd6c93.js');
18 const store$1 = require('./store-01e8edc2.js');
19 require('./fetch-5e8dc1d5.js');
20 const index$4 = require('./index-7ced8198.js');
21 const index$5 = require('./index-fb76df07.js');
22 const mutations$2 = require('./mutations-d5d6ddf1.js');
23 const addQueryArgs = require('./add-query-args-49dcb630.js');
24 const formData = require('./form-data-0da9940f.js');
25 const removeQueryArgs = require('./remove-query-args-b57e8cd3.js');
26 require('./index-c3de642f.js');
27 require('./utils-a9d13080.js');
28 require('./google-8dbad1a6.js');
29 require('./currency-71fce0f0.js');
30 require('./price-da3cab3d.js');
31 require('./util-a15c420c.js');
32 require('./address-7404695f.js');
33
34 const ScCheckoutAutofillProvider = class {
35 constructor(hostRef) {
36 index.registerInstance(this, hostRef);
37 }
38 componentWillLoad() {
39 this.maybeApplyProfile();
40 this.removeUserListener = store.onChange('loggedIn', loggedIn => {
41 if (!loggedIn) {
42 // A later login on the same checkout should re-apply.
43 this.appliedForCheckoutId = undefined;
44 return;
45 }
46 this.maybeApplyProfile();
47 });
48 this.removeCheckoutListener = mutations.onChange('checkout', () => this.maybeApplyProfile());
49 }
50 disconnectedCallback() {
51 var _a, _b;
52 (_a = this.removeUserListener) === null || _a === void 0 ? void 0 : _a.call(this);
53 (_b = this.removeCheckoutListener) === null || _b === void 0 ? void 0 : _b.call(this);
54 }
55 async maybeApplyProfile() {
56 var _a, _b, _c, _d, _e, _f, _g, _h;
57 if (!store.state.loggedIn)
58 return;
59 const checkoutId = (_a = mutations.state.checkout) === null || _a === void 0 ? void 0 : _a.id;
60 if (!checkoutId)
61 return;
62 if (this.appliedForCheckoutId === checkoutId)
63 return;
64 this.appliedForCheckoutId = checkoutId;
65 try {
66 const customer = await index$1.getCurrentCustomer(mutations.state.mode);
67 const patch = {};
68 // The shipping/billing fields on Customer are typed as `string | Address`; here they
69 // are expanded into Address objects via the `expand` param, so this cast is safe.
70 const shippingAddress = customer === null || customer === void 0 ? void 0 : customer.shipping_address;
71 const billingAddress = customer === null || customer === void 0 ? void 0 : customer.billing_address;
72 if (index$1.hasAddressData(shippingAddress) && index$1.isAddressEmpty((_b = mutations.state.checkout) === null || _b === void 0 ? void 0 : _b.shipping_address)) {
73 patch.shipping_address = shippingAddress;
74 }
75 if (index$1.hasAddressData(billingAddress) && index$1.isAddressEmpty((_c = mutations.state.checkout) === null || _c === void 0 ? void 0 : _c.billing_address)) {
76 patch.billing_address = billingAddress;
77 }
78 if ((customer === null || customer === void 0 ? void 0 : customer.first_name) && !((_d = mutations.state.checkout) === null || _d === void 0 ? void 0 : _d.first_name)) {
79 patch.first_name = customer.first_name;
80 }
81 if ((customer === null || customer === void 0 ? void 0 : customer.last_name) && !((_e = mutations.state.checkout) === null || _e === void 0 ? void 0 : _e.last_name)) {
82 patch.last_name = customer.last_name;
83 }
84 if ((customer === null || customer === void 0 ? void 0 : customer.phone) && !((_f = mutations.state.checkout) === null || _f === void 0 ? void 0 : _f.phone)) {
85 patch.phone = customer.phone;
86 }
87 // Respect the customer's saved billing-matches-shipping preference so the checkout
88 // toggle reflects their profile instead of the checkout default.
89 if (typeof (customer === null || customer === void 0 ? void 0 : customer.billing_matches_shipping) === 'boolean' && ((_g = mutations.state.checkout) === null || _g === void 0 ? void 0 : _g.billing_matches_shipping) !== customer.billing_matches_shipping) {
90 patch.billing_matches_shipping = customer.billing_matches_shipping;
91 }
92 // Nothing to apply — skip the lock entirely.
93 if (!Object.keys(patch).length)
94 return;
95 mutations$1.lockCheckout('customer-profile-autofill');
96 try {
97 mutations.state.checkout = (await index$2.createOrUpdateCheckout({ id: (_h = mutations.state.checkout) === null || _h === void 0 ? void 0 : _h.id, data: patch }));
98 }
99 finally {
100 mutations$1.unLockCheckout('customer-profile-autofill');
101 }
102 }
103 catch (e) {
104 // Convenience feature — don't block checkout; clear the flag so a later trigger can retry.
105 this.appliedForCheckoutId = undefined;
106 console.error(e);
107 }
108 }
109 render() {
110 return (index.h(index.Host, { key: '9c330e8ab3d753d44009663266b94c7f07492230' }, index.h("slot", { key: '408db421d26ecaa8df18c8d2ac7c1ac9be170a23' })));
111 }
112 };
113
114 /**
115 * Get the customer's coordinates via the browser Geolocation API.
116 * The browser prompts for permission if not already granted; resolves
117 * null when denied, unsupported, or the lookup fails — never throws.
118 */
119 const getGeoCoordinates = async () => {
120 try {
121 if (!(navigator === null || navigator === void 0 ? void 0 : navigator.geolocation)) {
122 return null;
123 }
124 return await new Promise(resolve => {
125 navigator.geolocation.getCurrentPosition(({ coords }) => resolve({ latitude: coords.latitude, longitude: coords.longitude }), () => resolve(null), { maximumAge: 15 * 60 * 1000, timeout: 10000 });
126 });
127 }
128 catch {
129 return null;
130 }
131 };
132
133 const scCheckoutGeoPermissionCss = ":host{display:block}.geo-permission{--body-spacing:var(--sc-spacing-x-large);--width:460px}.geo-permission__content{line-height:1.5}.geo-permission__content p{margin:0 0 var(--sc-spacing-small)}.geo-permission__content p:first-child{margin-top:0}.geo-permission__content p:last-child{margin-bottom:0}";
134 const ScCheckoutGeoPermissionStyle0 = scCheckoutGeoPermissionCss;
135
136 /** localStorage key that remembers the customer's decision so we honor it on future visits. */
137 const DECISION_KEY = 'sc_geo_capture_decision';
138 const ScCheckoutGeoPermission = class {
139 constructor(hostRef) {
140 index.registerInstance(this, hostRef);
141 this.open = false;
142 }
143 /** Whether the cart currently has at least one line item. */
144 cartHasItems() {
145 var _a, _b, _c;
146 return !!((_c = (_b = (_a = mutations.state.checkout) === null || _a === void 0 ? void 0 : _a.line_items) === null || _b === void 0 ? void 0 : _b.pagination) === null || _c === void 0 ? void 0 : _c.count);
147 }
148 /** Whether the customer dismissed our explainer ("Not now") on a previous visit. */
149 wasDismissed() {
150 try {
151 return window.localStorage.getItem(DECISION_KEY) === 'declined';
152 }
153 catch {
154 return false;
155 }
156 }
157 /** Remember a dismissal so we don't re-show the explainer on every visit. */
158 rememberDismissed() {
159 try {
160 window.localStorage.setItem(DECISION_KEY, 'declined');
161 }
162 catch {
163 // Storage unavailable (private mode etc.) — the dismissal simply isn't remembered.
164 }
165 }
166 /**
167 * The browser's current geolocation permission, or null if the Permissions API is
168 * unavailable (e.g. older Safari). Lets us avoid showing an explainer whose Allow
169 * button can't actually trigger a prompt.
170 */
171 async getPermissionState() {
172 var _a, _b;
173 try {
174 const status = await ((_a = navigator.permissions) === null || _a === void 0 ? void 0 : _a.query({ name: 'geolocation' }));
175 return (_b = status === null || status === void 0 ? void 0 : status.state) !== null && _b !== void 0 ? _b : null;
176 }
177 catch {
178 return null;
179 }
180 }
181 async componentDidLoad() {
182 // Nothing to do unless the merchant enabled capture and the browser can actually geolocate.
183 if (!mutations.state.captureGeoAddressEnabled)
184 return;
185 if (!(window === null || window === void 0 ? void 0 : window.isSecureContext) || !(navigator === null || navigator === void 0 ? void 0 : navigator.geolocation))
186 return;
187 // Don't request location for an empty cart — there's nothing to price yet, and a
188 // full-screen prompt before adding items feels premature. The cart loads async, so
189 // if it's not ready we wait for the first change that adds an item.
190 if (this.cartHasItems()) {
191 this.maybePromptForLocation();
192 return;
193 }
194 this.removeCartListener = mutations.onChange('checkout', () => {
195 var _a;
196 if (!this.cartHasItems())
197 return;
198 (_a = this.removeCartListener) === null || _a === void 0 ? void 0 : _a.call(this);
199 this.removeCartListener = undefined;
200 this.maybePromptForLocation();
201 });
202 }
203 disconnectedCallback() {
204 var _a;
205 (_a = this.removeCartListener) === null || _a === void 0 ? void 0 : _a.call(this);
206 }
207 /** Decide, based on the browser permission, whether to capture silently, explain, or do nothing. */
208 async maybePromptForLocation() {
209 const permission = await this.getPermissionState();
210 // Already granted at the browser level: capture silently — no need to ask again.
211 if (permission === 'granted') {
212 this.capture();
213 return;
214 }
215 // Blocked at the browser level: JS can't re-prompt, so don't show an Allow button we can't fulfill.
216 // Checkout continues normally with no capture; the customer can re-enable in their browser settings.
217 if (permission === 'denied')
218 return;
219 // State is 'prompt' (or unknown): respect a prior "Not now", otherwise explain before prompting.
220 if (this.wasDismissed())
221 return;
222 this.open = true;
223 }
224 /** Capture coordinates into the checkout store. They ride along on the next update/finalize. */
225 async capture() {
226 if (mutations.state.geoCoordinates)
227 return;
228 mutations.state.geoCoordinates = await getGeoCoordinates();
229 }
230 /** Customer opted in — close and fire the native browser prompt. */
231 onAllow() {
232 this.open = false;
233 this.capture();
234 }
235 /** Customer dismissed — remember it and close. Checkout continues with no capture. */
236 onDecline() {
237 this.rememberDismissed();
238 this.open = false;
239 }
240 render() {
241 const { geoCapture } = mutations.state;
242 // Shared defaults (see getGeoPermissionDefaults) so merchant fields can stay empty and
243 // the admin placeholders and this dialog never drift apart.
244 const defaults = geoPermission.getGeoPermissionDefaults();
245 const title = (geoCapture === null || geoCapture === void 0 ? void 0 : geoCapture.title) || defaults.title;
246 const content = (geoCapture === null || geoCapture === void 0 ? void 0 : geoCapture.content) || defaults.content;
247 const allowLabel = (geoCapture === null || geoCapture === void 0 ? void 0 : geoCapture.allowLabel) || defaults.allowLabel;
248 const declineLabel = (geoCapture === null || geoCapture === void 0 ? void 0 : geoCapture.declineLabel) || defaults.declineLabel;
249 return (index.h(index.Host, { key: '0ad4ae587e752158efb5c99d8c8fcb14930997bb' }, index.h("sc-dialog", { key: '2fc8c24f596da900c5c9ab489a4e57b2d884ee7e', open: this.open, noHeader: true, onScRequestClose: () => this.onDecline(), class: "geo-permission" }, index.h("sc-dashboard-module", { key: '45f9bcc6b76f56ad5bae67eac7e8c5cb063a7f30', style: { '--sc-dashboard-module-spacing': '1em' } }, index.h("sc-flex", { key: '7d7fb2fc9a4e3d8beb9347b2a714f7d209b7bbd5', slot: "heading", "align-items": "center", "justify-content": "flex-start" }, index.h("sc-icon", { key: '588595f82cdcda2b20ba59f0b47378d3f309eddd', name: "map-pin", style: { color: 'var(--sc-color-primary-500)' } }), title), index.h("div", { key: 'b2ab9bc87c22b19f2540f3e5574f9e336a5d97f7', slot: "description", class: "geo-permission__content", innerHTML: content })), index.h("sc-button", { key: '3994b2422d57fba69b9f147b9a65e9740c7daf36', slot: "footer", type: "text", onClick: () => this.onDecline() }, declineLabel), index.h("sc-button", { key: 'e7b2b56522060bd72732e65e61e201d03c5e3748', slot: "footer", type: "primary", onClick: () => this.onAllow() }, allowLabel, index.h("sc-icon", { key: '7a93908aacf286ccdf684e4822e1490535b38d2d', name: "map-pin", slot: "suffix" })))));
250 }
251 };
252 ScCheckoutGeoPermission.style = ScCheckoutGeoPermissionStyle0;
253
254 /**
255 * Reconstruct a bundle's `bundle_component_variants` map from its component
256 * line items (componentProductId -> variantId).
257 *
258 * The platform treats `bundle_component_variants` on the parent as write-only:
259 * it's accepted on create/update but reads back empty, so the live selection
260 * has to be derived from each component line item's chosen variant. Any update
261 * that re-posts the map (e.g. a stock swap) must rebuild the *full* map this way
262 * — seeding from the empty parent field drops the other components and trips the
263 * platform's "selection required" validation.
264 */
265 const getBundleComponentVariants = (parentId, lineItems = []) => {
266 const map = {};
267 (lineItems || []).forEach(item => {
268 var _a, _b, _c;
269 if ((item === null || item === void 0 ? void 0 : item.bundle_line_item) !== parentId)
270 return;
271 const productId = (_b = (_a = item === null || item === void 0 ? void 0 : item.price) === null || _a === void 0 ? void 0 : _a.product) === null || _b === void 0 ? void 0 : _b.id;
272 const variantId = (_c = item === null || item === void 0 ? void 0 : item.variant) === null || _c === void 0 ? void 0 : _c.id;
273 if (productId && variantId)
274 map[productId] = variantId;
275 });
276 return map;
277 };
278 /** Available stock for a line item (variant takes precedence over product). */
279 const getAvailableStock = (lineItem) => {
280 var _a, _b, _c;
281 const product = (_a = lineItem === null || lineItem === void 0 ? void 0 : lineItem.price) === null || _a === void 0 ? void 0 : _a.product;
282 const stock = ((_b = lineItem === null || lineItem === void 0 ? void 0 : lineItem.variant) === null || _b === void 0 ? void 0 : _b.id) ? (_c = lineItem === null || lineItem === void 0 ? void 0 : lineItem.variant) === null || _c === void 0 ? void 0 : _c.available_stock : product === null || product === void 0 ? void 0 : product.available_stock;
283 return Math.max(Number(stock) || 0, 0);
284 };
285 /** Out-of-stock line items (standalone items and bundle components). */
286 const getOutOfStockLineItems = (lineItems = []) => (lineItems || []).filter(lineItem => (lineItem === null || lineItem === void 0 ? void 0 : lineItem.purchasable_status) === 'out_of_stock' && getAvailableStock(lineItem) < lineItem.quantity);
287 /**
288 * A bundle is atomic, so a short component caps the bundle, not the component:
289 * floor(stock / perBundleQty), smallest cap across components. Returns a map of
290 * bundle parent id -> reduced quantity.
291 *
292 * `swappedProductsByParent` lists component products being swapped to an in-stock
293 * variant — those are skipped so they don't cap a bundle they no longer limit.
294 */
295 const getBundleQuantityReductions = (lineItems = [], swappedProductsByParent = new Map()) => {
296 const reductions = new Map();
297 getOutOfStockLineItems(lineItems).forEach(component => {
298 var _a, _b, _c, _d;
299 if (!component.component_line_item || !component.bundle_line_item)
300 return;
301 const parent = (lineItems || []).find(li => li.id === component.bundle_line_item);
302 if (!(parent === null || parent === void 0 ? void 0 : parent.id))
303 return;
304 // Skip a component that's being swapped — its old stock no longer caps the bundle.
305 const productId = (_b = (_a = component.price) === null || _a === void 0 ? void 0 : _a.product) === null || _b === void 0 ? void 0 : _b.id;
306 if (productId && ((_c = swappedProductsByParent.get(parent.id)) === null || _c === void 0 ? void 0 : _c.has(productId)))
307 return;
308 const perBundle = index$3.getPerBundleQuantity(component, parent.quantity);
309 const maxBundles = Math.floor(getAvailableStock(component) / perBundle);
310 const current = (_d = reductions.get(parent.id)) !== null && _d !== void 0 ? _d : parent.quantity;
311 reductions.set(parent.id, Math.max(Math.min(current, maxBundles), 0));
312 });
313 return reductions;
314 };
315 /**
316 * Payload to fix a stock alert. Posts parents only (components derive from the
317 * parent): bundles drop to their reduced quantity, standalone items to available
318 * stock. A swapped component is excluded from its bundle's cap, so any *other*
319 * short component still reduces the bundle correctly.
320 */
321 const buildStockAdjustedLineItems = (lineItems = [], bundleVariantOverrides = new Map()) => {
322 // Component products being swapped, keyed by bundle parent.
323 const swappedProductsByParent = new Map(Array.from(bundleVariantOverrides, ([parentId, map]) => [parentId, new Set(Object.keys(map))]));
324 const reductions = getBundleQuantityReductions(lineItems, swappedProductsByParent);
325 const standalone = new Map();
326 getOutOfStockLineItems(lineItems).forEach(lineItem => {
327 if (lineItem.component_line_item || !lineItem.id)
328 return;
329 standalone.set(lineItem.id, getAvailableStock(lineItem));
330 });
331 return (lineItems || [])
332 .filter(lineItem => !lineItem.component_line_item)
333 .map(lineItem => {
334 var _a, _b, _c, _d;
335 const id = lineItem.id;
336 const hasSwap = !!id && bundleVariantOverrides.has(id);
337 let quantity = lineItem.quantity;
338 if (id && reductions.has(id))
339 quantity = (_a = reductions.get(id)) !== null && _a !== void 0 ? _a : quantity;
340 else if (id && standalone.has(id))
341 quantity = (_b = standalone.get(id)) !== null && _b !== void 0 ? _b : quantity;
342 return {
343 id,
344 price_id: (_c = lineItem.price) === null || _c === void 0 ? void 0 : _c.id,
345 quantity,
346 ...(((_d = lineItem === null || lineItem === void 0 ? void 0 : lineItem.variant) === null || _d === void 0 ? void 0 : _d.id) ? { variant: lineItem.variant.id } : {}),
347 ...(id && hasSwap ? { bundle_component_variants: bundleVariantOverrides.get(id) } : {}),
348 };
349 });
350 };
351 /**
352 * Rows for the stock alert dialog. Bundle components roll up into a single
353 * parent row (the bundle quantity is what changes); standalone items show
354 * themselves.
355 */
356 const buildStockAlertRows = (lineItems = []) => {
357 const reductions = getBundleQuantityReductions(lineItems);
358 const seenParents = new Set();
359 const rows = [];
360 getOutOfStockLineItems(lineItems).forEach(lineItem => {
361 var _a, _b, _c;
362 if (lineItem.component_line_item && lineItem.bundle_line_item) {
363 const parent = (lineItems || []).find(li => li.id === lineItem.bundle_line_item);
364 if (!(parent === null || parent === void 0 ? void 0 : parent.id) || seenParents.has(parent.id))
365 return;
366 seenParents.add(parent.id);
367 const product = (_a = parent.price) === null || _a === void 0 ? void 0 : _a.product;
368 rows.push({
369 name: product === null || product === void 0 ? void 0 : product.name,
370 variant: parent === null || parent === void 0 ? void 0 : parent.variant_display_options,
371 image: parent === null || parent === void 0 ? void 0 : parent.image,
372 from: parent.quantity,
373 to: Math.max((_b = reductions.get(parent.id)) !== null && _b !== void 0 ? _b : parent.quantity, 0),
374 });
375 return;
376 }
377 const product = (_c = lineItem.price) === null || _c === void 0 ? void 0 : _c.product;
378 rows.push({
379 name: product === null || product === void 0 ? void 0 : product.name,
380 variant: lineItem === null || lineItem === void 0 ? void 0 : lineItem.variant_display_options,
381 image: lineItem === null || lineItem === void 0 ? void 0 : lineItem.image,
382 from: lineItem.quantity,
383 to: getAvailableStock(lineItem),
384 });
385 });
386 return rows;
387 };
388
389 const scCheckoutStockAlertCss = ":host{display:block}sc-table{height:auto}h4{display:block;margin:0;font-weight:var(--sc-font-weight-bold);font-size:var(--sc-font-size-medium)}.stock-alert{--body-spacing:var(--sc-spacing-x-large);--width:500px}.stock-alert__image{width:50px;height:50px;object-fit:cover;margin-right:10px;display:block}.stock-alert__product-info{display:flex;flex-direction:column;gap:var(--sc-spacing-xx-small)}.stock-alert__variant{color:var(--sc-color-gray-500);font-size:var(--sc-font-size-small)}.stock-alert__quantity{color:var(--sc-color-gray-500);font-weight:var(--sc-font-weight-bold);display:flex;align-items:center;justify-content:flex-end;gap:var(--sc-spacing-xx-small)}";
390 const ScCheckoutStockAlertStyle0 = scCheckoutStockAlertCss;
391
392 const ScCheckoutStockAlert = class {
393 constructor(hostRef) {
394 index.registerInstance(this, hostRef);
395 this.scUpdateLineItem = index.createEvent(this, "scUpdateLineItem", 7);
396 this.stockErrors = [];
397 this.busy = undefined;
398 this.error = undefined;
399 }
400 /** Current checkout line items. */
401 get lineItems() {
402 var _a, _b;
403 return ((_b = (_a = mutations.state.checkout) === null || _a === void 0 ? void 0 : _a.line_items) === null || _b === void 0 ? void 0 : _b.data) || [];
404 }
405 /**
406 * Update the checkout to the max available stock.
407 *
408 * Bundle shortages reduce the whole bundle quantity (a bundle is atomic). A
409 * bundle that can't make even one unit (reduced to 0) is first rescued by
410 * swapping a gone variant to an in-stock sibling when one exists; otherwise
411 * the unfulfillable bundle is dropped from the cart, matching the "→ 0" the
412 * dialog already shows.
413 */
414 async onSubmit() {
415 let attemptedBundleSwap = false;
416 try {
417 this.busy = true;
418 this.error = null;
419 const items = this.lineItems;
420 const reductions = getBundleQuantityReductions(items);
421 // Only bundles reduced to 0 need rescuing — try swapping the gone
422 // variant to an in-stock sibling so we don't drop a recoverable bundle.
423 // If no swap exists the bundle stays at 0 and is removed below.
424 const parentOverrides = new Map();
425 getOutOfStockLineItems(items).forEach(oos => {
426 var _a, _b, _c;
427 if (!oos.component_line_item || !oos.bundle_line_item)
428 return;
429 const parent = items.find(li => li.id === oos.bundle_line_item);
430 if (!(parent === null || parent === void 0 ? void 0 : parent.id) || ((_a = reductions.get(parent.id)) !== null && _a !== void 0 ? _a : 0) >= 1)
431 return;
432 const product = (_b = oos.price) === null || _b === void 0 ? void 0 : _b.product;
433 if (!(product === null || product === void 0 ? void 0 : product.id))
434 return;
435 const swap = (((_c = product === null || product === void 0 ? void 0 : product.variants) === null || _c === void 0 ? void 0 : _c.data) || []).find(v => { var _a, _b; return v.id !== ((_a = oos.variant) === null || _a === void 0 ? void 0 : _a.id) && ((_b = v.available_stock) !== null && _b !== void 0 ? _b : 0) > 0; });
436 if (!(swap === null || swap === void 0 ? void 0 : swap.id))
437 return;
438 // Rebuild the full selection from the component line items (the parent
439 // field reads back empty), then swap the gone variant — posting only the
440 // swapped component would fail the platform's per-component requirement.
441 const map = parentOverrides.get(parent.id) || getBundleComponentVariants(parent.id, items);
442 map[product.id] = swap.id;
443 parentOverrides.set(parent.id, map);
444 });
445 attemptedBundleSwap = parentOverrides.size > 0;
446 // Bundles still capped at 0 (no in-stock swap) fall to quantity 0 and are
447 // filtered out here — the unfulfillable bundle is simply removed.
448 const lineItems = buildStockAdjustedLineItems(items, parentOverrides).filter(lineItem => !!lineItem.quantity);
449 mutations.state.checkout = (await index$2.updateCheckout({
450 id: mutations.state.checkout.id,
451 data: { line_items: lineItems },
452 }));
453 }
454 catch (error) {
455 // A rejected bundle swap surfaces as a generic 500 — show an actionable
456 // message so the shopper can remove the item or pick another bundle.
457 if (attemptedBundleSwap) {
458 this.error = wp.i18n.__('We could not automatically update an out-of-stock bundle item. Please remove it or choose a different bundle.', 'surecart');
459 }
460 else {
461 // Build the message defensively — `additionalErrors?.length && ...`
462 // used to evaluate to the literal `0` when there were no additional
463 // errors, which then got stringified into the displayed error.
464 const additionalErrors = ((error === null || error === void 0 ? void 0 : error.additional_errors) || []).map(e => e === null || e === void 0 ? void 0 : e.message).filter(Boolean);
465 const parts = [(error === null || error === void 0 ? void 0 : error.message) || wp.i18n.__('Something went wrong.', 'surecart')];
466 if (additionalErrors.length)
467 parts.push(additionalErrors.join('. '));
468 this.error = parts.join(' ');
469 }
470 }
471 finally {
472 this.busy = false;
473 }
474 }
475 render() {
476 const stockErrors = buildStockAlertRows(this.lineItems);
477 // we have at least one fully out-of-stock item.
478 const hasOutOfStockItems = stockErrors === null || stockErrors === void 0 ? void 0 : stockErrors.some(item => (item === null || item === void 0 ? void 0 : item.to) < 1);
479 return (index.h(index.Host, { key: 'acbef859b372585f275753310f0a0522d627b9ec' }, index.h("sc-dialog", { key: '41f51f533d77c8f96c3c265aaaadee5ed2a80c90', open: !!stockErrors.length && getters.currentFormState() === 'draft', noHeader: true, onScRequestClose: e => e.preventDefault(), class: "stock-alert" }, index.h("sc-dashboard-module", { key: '00ee738effe3092df20007eaed0e3ac0c4b1863b', class: "subscription-cancel", error: this.error, style: { '--sc-dashboard-module-spacing': '1em' } }, index.h("sc-flex", { key: '54cc0304e2e6f8ce0476a05edbf1ba5222bb35a1', slot: "heading", "align-items": "center", "justify-content": "flex-start" }, index.h("sc-icon", { key: 'c58a11c951145aca4d0421fdc24643325b1daada', name: "alert-circle", style: { color: 'var(--sc-color-primary-500' } }), hasOutOfStockItems ? wp.i18n.__('Out of Stock', 'surecart') : wp.i18n.__('Quantity Update', 'surecart')), index.h("span", { key: '9d3a9107639d100d4d815564af2714214058c190', slot: "description" }, hasOutOfStockItems
480 ? wp.i18n.__('Some items are no longer available. Your cart will be updated.', 'surecart')
481 : wp.i18n.__('Available quantities for these items have changed. Your cart will be updated.', 'surecart')), index.h("sc-card", { key: 'a01d877d96b63f948d5ae969fa414851e36127c2', "no-padding": true }, index.h("sc-table", { key: '3b432e96899754d2bd44c298a3b30bb1e8f95d5e' }, index.h("sc-table-cell", { key: '687fa517eef975afa99dbd9ca4b820bd8228e1ad', slot: "head" }, wp.i18n.__('Description', 'surecart')), index.h("sc-table-cell", { key: '2a7f0e9bb3152acbccd57ba55e07b0eec2b3cef8', slot: "head", style: { width: '100px', textAlign: 'right' } }, wp.i18n.__('Quantity', 'surecart')), stockErrors.map((item, index$1) => {
482 const isLastChild = index$1 === stockErrors.length - 1;
483 return (index.h("sc-table-row", { style: {
484 '--columns': '2',
485 ...(isLastChild ? { border: 'none' } : {}),
486 } }, index.h("sc-table-cell", null, index.h("sc-flex", { justifyContent: "flex-start", alignItems: "center" }, (item === null || item === void 0 ? void 0 : item.image) && index.h("img", { ...item.image, class: "stock-alert__image" }), index.h("div", { class: "stock-alert__product-info" }, index.h("h4", null, item.name), (item === null || item === void 0 ? void 0 : item.variant) && index.h("span", { class: "stock-alert__variant" }, item.variant)))), index.h("sc-table-cell", { style: { width: '100px', textAlign: 'right' } }, index.h("span", { class: "stock-alert__quantity" }, index.h("span", null, item === null || item === void 0 ? void 0 : item.from), " ", index.h("sc-icon", { name: "arrow-right" }), " ", index.h("span", null, Math.max(item === null || item === void 0 ? void 0 : item.to, 0))))));
487 })))), index.h("sc-button", { key: 'b2fc3f985615956ba887dd9243c5b4693652cd03', slot: "footer", type: "primary", loading: this.busy, onClick: () => this.onSubmit() }, wp.i18n.__('Continue', 'surecart'), index.h("sc-icon", { key: '4a8e198f3ad2374764abc70a96516b832aeda135', name: "arrow-right", slot: "suffix" })), this.busy && index.h("sc-block-ui", { key: '67747c60ab6ff8e5838d8d4c30543205cbc55248', spinner: true }))));
488 }
489 };
490 ScCheckoutStockAlert.style = ScCheckoutStockAlertStyle0;
491
492 const checkoutTestCompleteCss = ".confirm__icon{margin-bottom:var(--sc-spacing-medium);display:flex;justify-content:center}.confirm__icon-container{background:var(--sc-color-primary-500);width:55px;height:55px;border-radius:999999px;display:flex;align-items:center;justify-content:center;font-size:26px;line-height:1;color:white}sc-dialog::part(overlay){backdrop-filter:blur(4px)}";
493 const ScCheckoutTestCompleteStyle0 = checkoutTestCompleteCss;
494
495 const ScCheckoutTestComplete = class {
496 constructor(hostRef) {
497 index.registerInstance(this, hostRef);
498 this.scOrderPaid = index.createEvent(this, "scOrderPaid", 7);
499 this.scSetState = index.createEvent(this, "scSetState", 7);
500 this.showSuccessModal = false;
501 this.manualPaymentMethod = undefined;
502 this.checkoutStatus = undefined;
503 this.successUrl = undefined;
504 }
505 /**
506 * Watch for paid checkout machine state.
507 * This is triggered by Stripe, Paypal or Paystack when payment succeeds.
508 */
509 handleConfirmOrderEvent() {
510 if (this.checkoutStatus === 'test_mode_restricted') {
511 this.confirmOrder();
512 }
513 }
514 /** Confirm the order. */
515 async confirmOrder() {
516 var _a;
517 this.manualPaymentMethod = (_a = (getters$1.state.manualPaymentMethods || [])) === null || _a === void 0 ? void 0 : _a.find(p => p.id === watchers.state.id);
518 this.showSuccessModal = true;
519 mutations$1.clearCheckout();
520 }
521 handleSuccessModal() {
522 if (this.showSuccessModal) {
523 setTimeout(() => {
524 var _a;
525 (_a = this.continueButton) === null || _a === void 0 ? void 0 : _a.focus();
526 }, 50);
527 }
528 }
529 render() {
530 var _a, _b, _c, _d, _e;
531 return (index.h(index.Host, { key: '8880988be24c475421d2b54c9dfd945684766746' }, index.h("slot", { key: '0301cb11f3a0e1d10d60df81dc880ffc77693aaa' }), index.h("sc-dialog", { key: 'a96eb1959b206b58dc1ada90b707963e779e62f4', open: !!this.showSuccessModal, style: { '--body-spacing': 'var(--sc-spacing-xxx-large)', '--width': '400px' }, noHeader: true, onScRequestClose: e => e.preventDefault() }, index.h("div", { key: '496ecd0823810af00622b5a37748b9c2c9837b5f', class: "confirm__icon" }, index.h("div", { key: '9677f7f47900bf129659b27a00eb90e06368a36f', class: "confirm__icon-container" }, index.h("sc-icon", { key: '167e6fbc7a880b4092aadf657c3a780ac8136cda', name: "check" }))), index.h("sc-dashboard-module", { key: 'ff63fb9cc9c26176ff347c9809cab0c186ecbdf1', heading: wp.i18n.__('Test checkout successful!', 'surecart'), style: { '--sc-dashboard-module-spacing': 'var(--sc-spacing-x-large)', 'textAlign': 'center' } }, index.h("span", { key: '02716802dc259ae7505ab69a817e3a6da55129c9', slot: "description" }, wp.i18n.__('This is a simulated test checkout, and no orders were processed. To perform a test order, please contact your store administrator. ', 'surecart')), !!((_a = this.manualPaymentMethod) === null || _a === void 0 ? void 0 : _a.name) && !!((_b = this.manualPaymentMethod) === null || _b === void 0 ? void 0 : _b.instructions) && (index.h("sc-alert", { key: 'fe6f7c7134aa4a30fb9eeb04451b418018e05c13', type: "info", open: true, style: { 'text-align': 'left' } }, index.h("span", { key: 'c3ccaecdf4d8a9407ef333691d631c83a713b23a', slot: "title" }, (_c = this.manualPaymentMethod) === null || _c === void 0 ? void 0 : _c.name), index.h("div", { key: '4881bc45861b75cd49989239a6ea074e8418f5a6', innerHTML: (_d = this.manualPaymentMethod) === null || _d === void 0 ? void 0 : _d.instructions }))), index.h("sc-button", { key: 'b27f7d8f4844d5c6fc05efc5915232fd2c3cf079', href: (_e = window === null || window === void 0 ? void 0 : window.scData) === null || _e === void 0 ? void 0 : _e.home_url, size: "large", type: "primary", ref: el => (this.continueButton = el) }, wp.i18n.__('Go to Homepage', 'surecart'), index.h("sc-icon", { key: 'c1ba21e3fec1994dd1d27c0207138e58428c0113', name: "arrow-right", slot: "suffix" }))))));
532 }
533 get el() { return index.getElement(this); }
534 static get watchers() { return {
535 "checkoutStatus": ["handleConfirmOrderEvent"],
536 "showSuccessModal": ["handleSuccessModal"]
537 }; }
538 };
539 ScCheckoutTestComplete.style = ScCheckoutTestCompleteStyle0;
540
541 const ScCheckoutUnsavedChangesWarning = class {
542 constructor(hostRef) {
543 index.registerInstance(this, hostRef);
544 this.state = undefined;
545 }
546 /**
547 * Add event listener for beforeunload.
548 */
549 componentDidLoad() {
550 window.addEventListener('beforeunload', e => this.warnIfUnsavedChanges(e), { capture: true });
551 }
552 /**
553 * Warn if status is updaing, finalizing, paying or confirming.
554 */
555 warnIfUnsavedChanges(e) {
556 if (['updating', 'finalizing', 'confirming'].includes(this.state)) {
557 console.log({ e });
558 e.preventDefault();
559 e.returnValue = wp.i18n.__('Your payment is processing. Exiting this page could cause an error in your order. Please do not navigate away from this page.', 'surecart');
560 return e.returnValue;
561 }
562 }
563 };
564
565 const ScFormComponentsValidator = class {
566 constructor(hostRef) {
567 index.registerInstance(this, hostRef);
568 /** Whether *we* escalated the phone to required (vs. the merchant's own config), so we can undo it. */
569 this.phoneRequiredByShipping = false;
570 this.disabled = undefined;
571 this.taxProtocol = undefined;
572 this.hasAddress = undefined;
573 this.hasTaxIDField = undefined;
574 this.hasBumpsField = undefined;
575 this.hasTaxLine = undefined;
576 this.hasBumpLine = undefined;
577 this.hasShippingChoices = undefined;
578 this.hasShippingAmount = undefined;
579 this.hasInvoiceDetails = undefined;
580 this.hasInvoiceMemo = undefined;
581 this.hasTrialLineItem = undefined;
582 this.hasCustomerPhone = undefined;
583 }
584 handleOrderChange() {
585 var _a, _b, _c, _d, _e, _f, _g, _h, _j;
586 // bail if we don't have address invalid error or disabled.
587 if (this.disabled)
588 return;
589 // make sure to add the address field if it's not there.
590 if (getters$2.shippingAddressRequired()) {
591 this.addAddressField();
592 }
593 // require the phone when the checkout needs a shipping label.
594 this.handlePhoneRequiredForShipping();
595 // add order bumps.
596 if ((_c = (_b = (_a = mutations.state.checkout) === null || _a === void 0 ? void 0 : _a.recommended_bumps) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.length) {
597 this.addBumps();
598 }
599 if (!!((_d = mutations.state.checkout) === null || _d === void 0 ? void 0 : _d.tax_amount)) {
600 this.addTaxLine();
601 }
602 // add shipping choices.
603 if (((_e = mutations.state.checkout) === null || _e === void 0 ? void 0 : _e.shipping_enabled) && ((_f = mutations.state.checkout) === null || _f === void 0 ? void 0 : _f.selected_shipping_choice_required)) {
604 this.addShippingChoices();
605 }
606 if (!!((_g = mutations.state.checkout) === null || _g === void 0 ? void 0 : _g.shipping_amount)) {
607 this.addShippingAmount();
608 }
609 // automatically add invoice details if we have an invoice.
610 if (!!((_h = mutations.state.checkout) === null || _h === void 0 ? void 0 : _h.invoice)) {
611 this.addInvoiceDetails();
612 this.addInvoiceMemo();
613 }
614 // automatically add trial line item if we have a trial amount.
615 if (!!((_j = mutations.state.checkout) === null || _j === void 0 ? void 0 : _j.trial_amount)) {
616 this.addTrialLineItem();
617 }
618 }
619 handleHasAddressChange() {
620 if (!this.hasAddress)
621 return;
622 this.handleShippingAddressRequired();
623 }
624 componentWillLoad() {
625 var _a, _b;
626 this.hasAddress = !!this.el.querySelector('sc-order-shipping-address');
627 this.hasTaxIDField = !!this.el.querySelector('sc-order-tax-id-input');
628 this.hasBumpsField = !!this.el.querySelector('sc-order-bumps');
629 this.hasTaxLine = !!this.el.querySelector('sc-line-item-tax');
630 this.hasShippingChoices = !!this.el.querySelector('sc-shipping-choices');
631 this.hasShippingAmount = !!this.el.querySelector('sc-line-item-shipping');
632 this.hasInvoiceDetails = !!this.el.querySelector('sc-invoice-details');
633 this.hasInvoiceMemo = !!this.el.querySelector('sc-invoice-memo');
634 this.hasTrialLineItem = !!this.el.querySelector('sc-line-item-trial');
635 this.hasCustomerPhone = !!this.el.querySelector('sc-customer-phone');
636 // if eu vat is required, add the tax id field.
637 if (((_a = this.taxProtocol) === null || _a === void 0 ? void 0 : _a.tax_enabled) && ((_b = this.taxProtocol) === null || _b === void 0 ? void 0 : _b.eu_vat_required)) {
638 this.addTaxIDField();
639 }
640 // if razorpay is available, add the customer phone field.
641 if (getters$1.getAvailableProcessor('razorpay')) {
642 this.addCustomerPhone();
643 }
644 this.handleOrderChange();
645 this.removeCheckoutListener = mutations.onChange('checkout', () => this.handleOrderChange());
646 this.removePaymentRequiresShippingListener = mutations.onChange('paymentMethodRequiresShipping', () => this.handleOrderChange());
647 }
648 disconnectedCallback() {
649 this.removeCheckoutListener();
650 this.removePaymentRequiresShippingListener();
651 }
652 handleShippingAddressRequired() {
653 var _a;
654 if (!((_a = mutations.state.checkout) === null || _a === void 0 ? void 0 : _a.shipping_address_required))
655 return;
656 // get the address
657 const address = this.el.querySelector('sc-order-shipping-address');
658 if (!address)
659 return;
660 // require the address.
661 address.required = true;
662 // if we have a customer name field, require that.
663 const customerName = this.el.querySelector('sc-customer-name');
664 if (!!customerName) {
665 customerName.required = true;
666 return;
667 }
668 // if we have a customer first name field, require that.
669 const customerFirstName = this.el.querySelector('sc-customer-firstname');
670 const customerLastName = this.el.querySelector('sc-customer-lastname');
671 // if we have a customer first name field, require that.
672 if (!!customerFirstName) {
673 customerFirstName.required = true;
674 // if we have a customer last name field, require that.
675 if (!!customerLastName) {
676 customerLastName.required = true;
677 }
678 return; // we're done here.
679 }
680 // require the name and show the name input.
681 address.requireName = true;
682 address.showName = true;
683 }
684 addAddressField() {
685 if (this.hasAddress) {
686 return;
687 }
688 const payment = this.el.querySelector('sc-payment');
689 const shippingAddress = document.createElement('sc-order-shipping-address');
690 payment.parentNode.insertBefore(shippingAddress, payment);
691 if (getters$2.fullShippingAddressRequired()) {
692 const billingAddress = document.createElement('sc-order-billing-address');
693 billingAddress.label = wp.i18n.__('Billing Address', 'surecart');
694 payment.parentNode.insertBefore(billingAddress, payment);
695 }
696 else {
697 shippingAddress.label = wp.i18n.__('Address', 'surecart');
698 }
699 this.hasAddress = true;
700 }
701 addTaxIDField() {
702 if (this.hasTaxIDField)
703 return;
704 const payment = this.el.querySelector('sc-payment');
705 const taxInput = document.createElement('sc-order-tax-id-input');
706 payment.parentNode.insertBefore(taxInput, payment);
707 this.hasTaxIDField = true;
708 }
709 handlePhoneRequiredForShipping() {
710 const existing = this.el.querySelector('sc-customer-phone');
711 // needed only when the checkout requires a shipping label (live carrier rates).
712 const needed = getters$2.fullShippingAddressRequired();
713 if (!needed) {
714 // undo only our own escalation — if the merchant already placed a required phone block, we don't touch it.
715 if (this.phoneRequiredByShipping && existing) {
716 existing.required = false;
717 this.phoneRequiredByShipping = false;
718 }
719 return;
720 }
721 // if the merchant already placed the optional phone block, escalate it.
722 if (existing) {
723 if (!existing.required) {
724 existing.required = true;
725 this.phoneRequiredByShipping = true;
726 }
727 return;
728 }
729 // otherwise add a required phone field.
730 this.addCustomerPhone();
731 this.phoneRequiredByShipping = true;
732 }
733 addCustomerPhone() {
734 if (this.hasCustomerPhone)
735 return;
736 const payment = this.el.querySelector('sc-payment');
737 if (!payment)
738 return;
739 const customerPhone = document.createElement('sc-customer-phone');
740 customerPhone.label = wp.i18n.__('Phone', 'surecart');
741 customerPhone.required = true;
742 payment.parentNode.insertBefore(customerPhone, payment);
743 this.hasCustomerPhone = true;
744 }
745 addBumps() {
746 if (this.hasBumpsField)
747 return;
748 const attachReferenceElement = this.el.querySelector('sc-order-billing-address') || this.el.querySelector('sc-payment');
749 const bumps = document.createElement('sc-order-bumps');
750 attachReferenceElement === null || attachReferenceElement === void 0 ? void 0 : attachReferenceElement.parentNode.insertBefore(bumps, attachReferenceElement.nextSibling);
751 this.hasBumpsField = true;
752 }
753 addTaxLine() {
754 var _a;
755 if (this.hasTaxLine)
756 return;
757 const total = this.el.querySelector('sc-line-item-total[total=total]');
758 const tax = document.createElement('sc-line-item-tax');
759 if (!total)
760 return;
761 if (((_a = total === null || total === void 0 ? void 0 : total.previousElementSibling) === null || _a === void 0 ? void 0 : _a.tagName) === 'SC-DIVIDER') {
762 total.parentNode.insertBefore(tax, total.previousElementSibling);
763 }
764 else {
765 total.parentNode.insertBefore(tax, total);
766 }
767 this.hasTaxLine = true;
768 }
769 addShippingChoices() {
770 if (this.hasShippingChoices)
771 return;
772 const payment = this.el.querySelector('sc-payment');
773 const shippingChoices = document.createElement('sc-shipping-choices');
774 payment.parentNode.insertBefore(shippingChoices, payment);
775 this.hasShippingChoices = true;
776 }
777 addShippingAmount() {
778 var _a;
779 if (this.hasShippingAmount)
780 return;
781 let insertBeforeElement = this.el.querySelector('sc-line-item-tax');
782 const total = this.el.querySelector('sc-line-item-total[total=total]');
783 if (!total)
784 return;
785 if (!insertBeforeElement) {
786 insertBeforeElement = ((_a = total === null || total === void 0 ? void 0 : total.previousElementSibling) === null || _a === void 0 ? void 0 : _a.tagName) === 'SC-DIVIDER' ? total.previousElementSibling : total;
787 }
788 const shippingAmount = document.createElement('sc-line-item-shipping');
789 insertBeforeElement.parentNode.insertBefore(shippingAmount, insertBeforeElement);
790 this.hasShippingAmount = true;
791 }
792 addInvoiceDetails() {
793 if (this.hasInvoiceDetails)
794 return;
795 let lineItems = this.el.querySelector('sc-line-items');
796 const invoiceDetails = document.createElement('sc-invoice-details');
797 lineItems.parentNode.insertBefore(invoiceDetails, lineItems);
798 // Add sc-line-item-invoice-number inside sc-invoice-details.
799 const invoiceNumber = document.createElement('sc-line-item-invoice-number');
800 invoiceDetails.appendChild(invoiceNumber);
801 // Add sc-line-item-invoice-due-date inside sc-invoice-details.
802 const invoiceDueDate = document.createElement('sc-line-item-invoice-due-date');
803 invoiceDetails.appendChild(invoiceDueDate);
804 // Add invoice sc-line-item-invoice-receipt-download inside sc-invoice-details.
805 const invoiceReceiptDownload = document.createElement('sc-line-item-invoice-receipt-download');
806 invoiceDetails.appendChild(invoiceReceiptDownload);
807 // Add sc-divider inside sc-invoice-details.
808 const divider = document.createElement('sc-divider');
809 invoiceDetails.appendChild(divider);
810 this.hasInvoiceDetails = true;
811 }
812 addInvoiceMemo() {
813 if (this.hasInvoiceMemo)
814 return;
815 const orderSummary = this.el.querySelector('sc-order-summary');
816 const invoiceDetails = document.createElement('sc-invoice-details');
817 // Add sc-divider inside sc-invoice-details.
818 orderSummary.parentNode.insertBefore(invoiceDetails, orderSummary.nextSibling);
819 // Add sc-invoice-memo inside sc-invoice-details.
820 const invoiceMemo = document.createElement('sc-invoice-memo');
821 invoiceDetails.appendChild(invoiceMemo);
822 this.hasInvoiceMemo = true;
823 }
824 addTrialLineItem() {
825 if (this.hasTrialLineItem)
826 return;
827 const subtotal = this.el.querySelector('sc-line-item-total[total=subtotal]');
828 const trialItem = document.createElement('sc-line-item-trial');
829 if (!subtotal)
830 return;
831 // Insert the trial item before the coupon form.
832 subtotal.parentNode.insertBefore(trialItem, subtotal.nextSibling);
833 this.hasTrialLineItem = true;
834 }
835 render() {
836 return index.h("slot", { key: '8a6fa5b922f635e11a27fe7c39ee54db7bff3e8a' });
837 }
838 get el() { return index.getElement(this); }
839 static get watchers() { return {
840 "hasAddress": ["handleHasAddressChange"]
841 }; }
842 };
843
844 const ScFormErrorProvider = class {
845 constructor(hostRef) {
846 index.registerInstance(this, hostRef);
847 }
848 componentWillLoad() {
849 this.maybeAddErrorsComponent();
850 }
851 maybeAddErrorsComponent() {
852 var _a, _b;
853 if (!!this.el.querySelector('sc-checkout-form-errors'))
854 return;
855 const errorsComponent = document.createElement('sc-checkout-form-errors');
856 (_b = (_a = this.el.querySelector('sc-form')) === null || _a === void 0 ? void 0 : _a.prepend) === null || _b === void 0 ? void 0 : _b.call(_a, errorsComponent);
857 }
858 render() {
859 return index.h("slot", { key: '3d8313540ae4b4eaaf3a968a7edc6b6ccf1efe79' });
860 }
861 get el() { return index.getElement(this); }
862 };
863
864 const ScFormStateProvider = class {
865 constructor(hostRef) {
866 index.registerInstance(this, hostRef);
867 this.scSetCheckoutFormState = index.createEvent(this, "scSetCheckoutFormState", 7);
868 /** Holds our state machine service */
869 this._stateService = store$1.v(store$1.checkoutMachine);
870 this.checkoutState = store$1.checkoutMachine.initialState;
871 }
872 /** Set the state. */
873 setState(name) {
874 const { send } = this._stateService;
875 mutations.updateFormState(name);
876 return send(name);
877 }
878 /** Watch for checkout state changes and emit to listeners. */
879 handleCheckoutStateChange(state) {
880 this.scSetCheckoutFormState.emit(state.value);
881 }
882 /** Init the state service. */
883 componentWillLoad() {
884 // Start state machine.
885 this._stateService.subscribe(state => (this.checkoutState = state));
886 this._stateService.start();
887 }
888 /** Remove state machine on disconnect. */
889 disconnectedCallback() {
890 this._stateService.stop();
891 }
892 /** Allow children to set the form state. */
893 handleSetStateEvent(e) {
894 this.setState(e.detail);
895 }
896 /** Update the state when the order is paid. */
897 async handlePaid() {
898 this.setState('PAID');
899 }
900 render() {
901 // handle expired.
902 if (this.checkoutState.value === 'expired') {
903 return (index.h("sc-block-ui", null, index.h("div", null, wp.i18n.__('Please refresh the page.', 'surecart'))));
904 }
905 return index.h("slot", null);
906 }
907 static get watchers() { return {
908 "checkoutState": ["handleCheckoutStateChange"]
909 }; }
910 };
911
912 const scLoginProviderCss = ":host{display:block}";
913 const ScLoginProviderStyle0 = scLoginProviderCss;
914
915 const ScLoginProvider = class {
916 constructor(hostRef) {
917 index.registerInstance(this, hostRef);
918 this.scSetLoggedIn = index.createEvent(this, "scSetLoggedIn", 7);
919 this.scSetCustomer = index.createEvent(this, "scSetCustomer", 7);
920 this.loggedIn = undefined;
921 this.order = undefined;
922 this.notice = undefined;
923 this.open = undefined;
924 this.loading = undefined;
925 this.error = undefined;
926 }
927 /** Listen for open event. */
928 handleLoginPrompt() {
929 this.open = true;
930 }
931 /** Focus on first input. */
932 handleLoginDialogChange(val) {
933 if (val) {
934 setTimeout(() => {
935 this.loginForm.querySelector('sc-input').triggerFocus();
936 }, 100);
937 }
938 }
939 handleLoggedInChange(val, prev) {
940 if (prev === false && val) {
941 this.notice = true;
942 }
943 }
944 handleOrderChange(val, prev) {
945 if ((val === null || val === void 0 ? void 0 : val.updated_at) !== (prev === null || prev === void 0 ? void 0 : prev.updated_at)) {
946 this.notice = false;
947 }
948 }
949 /** Handle form submit. */
950 async handleFormSubmit(e) {
951 e.preventDefault();
952 e.stopImmediatePropagation();
953 this.error = null;
954 const { login, password } = await e.target.getFormJson();
955 try {
956 this.loading = true;
957 const { name, email } = (await index$4.apiFetch({
958 method: 'POST',
959 path: 'surecart/v1/login',
960 data: {
961 login,
962 password,
963 },
964 }));
965 this.scSetLoggedIn.emit(true);
966 this.scSetCustomer.emit({ name, email });
967 this.open = false;
968 }
969 catch (e) {
970 console.error(e);
971 this.error = (e === null || e === void 0 ? void 0 : e.message) || wp.i18n.__('Something went wrong', 'surecart');
972 }
973 finally {
974 this.loading = false;
975 }
976 }
977 render() {
978 return (index.h(index.Host, { key: 'a7955874f1327b383868e7b96f827aa361f1b674' }, index.h("slot", { key: '89199341bb6bde3f60a356d387f2c30745e148c5' }), !this.loggedIn && (index.h("sc-dialog", { key: '4598d2a3e739c9020d36698469b64473437a6838', label: wp.i18n.__('Login to your account', 'surecart'), open: this.open, onScRequestClose: () => (this.open = false) }, index.h("sc-form", { key: '3b155a0713dad930ea33aea118fa3481ddb95275', ref: el => (this.loginForm = el), onScFormSubmit: e => {
979 e.preventDefault();
980 e.stopImmediatePropagation();
981 }, onScSubmit: e => this.handleFormSubmit(e) }, !!this.error && (index.h("sc-alert", { key: '6d69d5146e29e655db7c0866bd717fc6312831cb', type: "danger", open: !!this.error }, this.error)), index.h("sc-input", { key: '2e4159fabd323c600c155ea7781129c82549988e', label: wp.i18n.__('Email or Username', 'surecart'), type: "text", name: "login", required: true, autofocus: this.open }), index.h("sc-input", { key: '104370ec20b6e55e73a3e82f08b29b3447a0da8f', label: wp.i18n.__('Password', 'surecart'), type: "password", name: "password", required: true }), index.h("sc-button", { key: '15238c5a73e3600bc06d5c6ca1bdabf2115aa985', type: "primary", full: true, loading: this.loading, submit: true }, wp.i18n.__('Login', 'surecart')))))));
982 }
983 static get watchers() { return {
984 "open": ["handleLoginDialogChange"],
985 "loggedIn": ["handleLoggedInChange"],
986 "order": ["handleOrderChange"]
987 }; }
988 };
989 ScLoginProvider.style = ScLoginProviderStyle0;
990
991 const scOrderConfirmProviderCss = ".confirm__icon{margin-bottom:var(--sc-spacing-medium);display:flex;justify-content:center}.confirm__icon-container{background:var(--sc-color-primary-500);width:55px;height:55px;border-radius:999999px;display:flex;align-items:center;justify-content:center;font-size:26px;line-height:1;color:white}sc-dialog::part(overlay){backdrop-filter:blur(4px)}";
992 const ScOrderConfirmProviderStyle0 = scOrderConfirmProviderCss;
993
994 const ScOrderConfirmProvider = class {
995 constructor(hostRef) {
996 index.registerInstance(this, hostRef);
997 this.scOrderPaid = index.createEvent(this, "scOrderPaid", 7);
998 this.scSetState = index.createEvent(this, "scSetState", 7);
999 this.showSuccessModal = false;
1000 this.manualPaymentMethod = undefined;
1001 this.checkoutStatus = undefined;
1002 this.successUrl = undefined;
1003 }
1004 /**
1005 * Watch for paid checkout machine state.
1006 * This is triggered by Stripe, Paypal or Paystack when payment succeeds.
1007 */
1008 handleConfirmOrderEvent() {
1009 if (this.checkoutStatus === 'confirming') {
1010 this.confirmOrder();
1011 }
1012 else if (this.checkoutStatus === 'confirmed') {
1013 index$5.speak(wp.i18n.__('Order has been confirmed. Please select continue to go to the next step.', 'surecart'));
1014 }
1015 }
1016 /** Confirm the order. */
1017 async confirmOrder() {
1018 var _a, _b, _c, _d;
1019 try {
1020 mutations.state.checkout = (await index$4.apiFetch({
1021 method: 'PATCH',
1022 path: addQueryArgs.addQueryArgs(`surecart/v1/checkouts/${(_a = mutations.state === null || mutations.state === void 0 ? void 0 : mutations.state.checkout) === null || _a === void 0 ? void 0 : _a.id}/confirm`, { expand: index$2.expand }),
1023 }));
1024 this.scSetState.emit('CONFIRMED');
1025 }
1026 catch (e) {
1027 console.error(e);
1028 mutations$2.createErrorNotice(e);
1029 }
1030 finally {
1031 this.manualPaymentMethod = ((_b = mutations.state.checkout) === null || _b === void 0 ? void 0 : _b.manual_payment_method) || null;
1032 const checkout = mutations.state.checkout;
1033 const formId = mutations.state.formId;
1034 // If there is an initial upsell redirect to it.
1035 if (!!((_c = checkout === null || checkout === void 0 ? void 0 : checkout.current_upsell) === null || _c === void 0 ? void 0 : _c.permalink)) {
1036 setTimeout(() => {
1037 var _a;
1038 return window.location.assign(addQueryArgs.addQueryArgs((_a = checkout === null || checkout === void 0 ? void 0 : checkout.current_upsell) === null || _a === void 0 ? void 0 : _a.permalink, {
1039 sc_checkout_id: checkout === null || checkout === void 0 ? void 0 : checkout.id,
1040 sc_form_id: formId,
1041 }));
1042 }, 50);
1043 mutations$1.clearCheckout();
1044 return;
1045 }
1046 // get success url.
1047 const successUrl = ((_d = checkout === null || checkout === void 0 ? void 0 : checkout.metadata) === null || _d === void 0 ? void 0 : _d.success_url) || this.successUrl;
1048 if (successUrl) {
1049 // set state to redirecting.
1050 this.scSetState.emit('REDIRECT');
1051 const redirectUrl = addQueryArgs.addQueryArgs(successUrl, { sc_order: checkout === null || checkout === void 0 ? void 0 : checkout.id });
1052 setTimeout(() => window.location.assign(redirectUrl), 50);
1053 }
1054 else {
1055 this.showSuccessModal = true;
1056 }
1057 mutations$1.clearCheckout();
1058 }
1059 }
1060 getSuccessUrl() {
1061 var _a, _b, _c, _d, _e;
1062 const url = ((_b = (_a = mutations.state.checkout) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.success_url) || this.successUrl;
1063 return url ? addQueryArgs.addQueryArgs(url, { sc_order: (_c = mutations.state.checkout) === null || _c === void 0 ? void 0 : _c.id }) : (_e = (_d = window === null || window === void 0 ? void 0 : window.scData) === null || _d === void 0 ? void 0 : _d.pages) === null || _e === void 0 ? void 0 : _e.dashboard;
1064 }
1065 handleSuccessModal() {
1066 if (this.showSuccessModal) {
1067 setTimeout(() => {
1068 var _a;
1069 (_a = this.continueButton) === null || _a === void 0 ? void 0 : _a.focus();
1070 }, 50);
1071 }
1072 }
1073 render() {
1074 var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1075 return (index.h(index.Host, { key: '23ea682f197a8dba118628be80b95fcd6bca042f' }, index.h("slot", { key: 'b49138493aa4b86147ca69fec428dab62af8fd82' }), index.h("sc-dialog", { key: 'f9fb9fe80452e7d397f7b4b5d639615ffde6f5d9', open: !!this.showSuccessModal, style: { '--body-spacing': 'var(--sc-spacing-xxx-large)', '--width': '400px' }, noHeader: true, onScRequestClose: e => e.preventDefault() }, index.h("div", { key: '70ce3e2764616a1ec685e5176f41e2381c462f82', class: "confirm__icon" }, index.h("div", { key: '8b07ac141660edbdca3855473b0060e37d40955c', class: "confirm__icon-container" }, index.h("sc-icon", { key: 'dd3362a844697ae077420671c82ad0b5658cbff8', name: "check" }))), index.h("sc-dashboard-module", { key: '178cb4426acb703c033eb0769498ac0de8763ef6', heading: ((_b = (_a = store$1.state === null || store$1.state === void 0 ? void 0 : store$1.state.text) === null || _a === void 0 ? void 0 : _a.success) === null || _b === void 0 ? void 0 : _b.title) || wp.i18n.__('Thanks for your order!', 'surecart'), style: { '--sc-dashboard-module-spacing': 'var(--sc-spacing-x-large)', 'textAlign': 'center' } }, index.h("span", { key: '44b6d8fcf9dbebdfdc0cbc351fa899a69eb47466', slot: "description" }, ((_d = (_c = store$1.state === null || store$1.state === void 0 ? void 0 : store$1.state.text) === null || _c === void 0 ? void 0 : _c.success) === null || _d === void 0 ? void 0 : _d.description) || wp.i18n.__('Your payment was successful. A receipt is on its way to your inbox.', 'surecart')), !!((_e = this.manualPaymentMethod) === null || _e === void 0 ? void 0 : _e.name) && !!((_f = this.manualPaymentMethod) === null || _f === void 0 ? void 0 : _f.instructions) && (index.h("sc-alert", { key: '7d464418bcd7baa53b6145843a431c3625cdc15d', type: "info", open: true, style: { 'text-align': 'left' } }, index.h("span", { key: '5b4278490c3c21116ec9e83b625a04acf743f251', slot: "title" }, (_g = this.manualPaymentMethod) === null || _g === void 0 ? void 0 : _g.name), index.h("div", { key: '61c09fb86c656dc77acb31c56d68f10e7e50b2e7', innerHTML: (_h = this.manualPaymentMethod) === null || _h === void 0 ? void 0 : _h.instructions }))), index.h("sc-button", { key: '77d3d960fbd46b5a951d321ee201f34835aed439', href: this.getSuccessUrl(), size: "large", type: "primary", ref: el => (this.continueButton = el) }, ((_k = (_j = store$1.state === null || store$1.state === void 0 ? void 0 : store$1.state.text) === null || _j === void 0 ? void 0 : _j.success) === null || _k === void 0 ? void 0 : _k.button) || wp.i18n.__('Continue', 'surecart'), index.h("sc-icon", { key: '80b3621d1cf7e6669f7ff471f6fc024f5378b4d8', name: "arrow-right", slot: "suffix" }))))));
1076 }
1077 get el() { return index.getElement(this); }
1078 static get watchers() { return {
1079 "checkoutStatus": ["handleConfirmOrderEvent"],
1080 "showSuccessModal": ["handleSuccessModal"]
1081 }; }
1082 };
1083 ScOrderConfirmProvider.style = ScOrderConfirmProviderStyle0;
1084
1085 const ScSessionProvider = class {
1086 constructor(hostRef) {
1087 index.registerInstance(this, hostRef);
1088 this.scUpdateOrderState = index.createEvent(this, "scUpdateOrderState", 7);
1089 this.scUpdateDraftState = index.createEvent(this, "scUpdateDraftState", 7);
1090 this.scPaid = index.createEvent(this, "scPaid", 7);
1091 this.scSetState = index.createEvent(this, "scSetState", 7);
1092 this.prices = [];
1093 this.persist = true;
1094 }
1095 handlePricesChange() {
1096 let line_items = this.addInitialPrices() || [];
1097 // line_items = this.addPriceChoices(line_items);
1098 if (!(line_items === null || line_items === void 0 ? void 0 : line_items.length)) {
1099 return;
1100 }
1101 return this.loadUpdate({ line_items });
1102 }
1103 /**
1104 * Finalize the order.
1105 *
1106 * @returns {Promise<Order>}
1107 */
1108 async finalize() {
1109 return await this.handleFormSubmit();
1110 }
1111 async getFormData() {
1112 let data = {};
1113 const form = this.el.querySelector('sc-form');
1114 if (form) {
1115 const json = await form.getFormJson();
1116 data = formData.parseFormData(json);
1117 }
1118 return data;
1119 }
1120 /**
1121 * Handles the form submission.
1122 * @param e
1123 */
1124 async handleFormSubmit() {
1125 var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1126 mutations$2.removeNotice();
1127 mutations.updateFormState('FINALIZE');
1128 if (((_a = mutations.state === null || mutations.state === void 0 ? void 0 : mutations.state.checkout) === null || _a === void 0 ? void 0 : _a.payment_method_required) && (watchers.state === null || watchers.state === void 0 ? void 0 : watchers.state.id) === 'stripe' && getters$1.state.config.stripe.paymentElement) {
1129 // not initialized.
1130 if (!((_b = getters$1.state === null || getters$1.state === void 0 ? void 0 : getters$1.state.instances) === null || _b === void 0 ? void 0 : _b.stripeElements)) {
1131 mutations.updateFormState('REJECT');
1132 this.handleErrorResponse({ message: 'Stripe Elements not found.', code: 'stripe_elements_not_found' });
1133 return new Error('Stripe Elements not found.');
1134 }
1135 // submit the elements.
1136 const { error } = await ((_c = getters$1.state === null || getters$1.state === void 0 ? void 0 : getters$1.state.instances) === null || _c === void 0 ? void 0 : _c.stripeElements.submit());
1137 if (error) {
1138 console.error({ error });
1139 mutations.updateFormState('REJECT');
1140 mutations$2.createErrorNotice(error);
1141 return;
1142 }
1143 }
1144 // Get current form state.
1145 let data = await this.getFormData();
1146 if (((_d = window === null || window === void 0 ? void 0 : window.scData) === null || _d === void 0 ? void 0 : _d.recaptcha_site_key) && (window === null || window === void 0 ? void 0 : window.grecaptcha)) {
1147 try {
1148 data['grecaptcha'] = await window.grecaptcha.execute(window.scData.recaptcha_site_key, { action: 'surecart_checkout_submit' });
1149 }
1150 catch (e) {
1151 console.error(e);
1152 mutations.updateFormState('REJECT');
1153 this.handleErrorResponse(e);
1154 return new Error(e === null || e === void 0 ? void 0 : e.message);
1155 }
1156 }
1157 // first lets make sure the session is updated before we process it.
1158 try {
1159 await this.update(data);
1160 }
1161 catch (e) {
1162 console.error(e);
1163 mutations.updateFormState('REJECT');
1164 this.handleErrorResponse(e);
1165 }
1166 // first validate server-side and get key
1167 try {
1168 mutations.state.checkout = await index$2.finalizeCheckout({
1169 id: (_e = mutations.state === null || mutations.state === void 0 ? void 0 : mutations.state.checkout) === null || _e === void 0 ? void 0 : _e.id,
1170 query: {
1171 ...((watchers.state === null || watchers.state === void 0 ? void 0 : watchers.state.method) ? { payment_method_type: watchers.state === null || watchers.state === void 0 ? void 0 : watchers.state.method } : {}),
1172 return_url: addQueryArgs.addQueryArgs(window.location.href, {
1173 ...(((_f = mutations.state === null || mutations.state === void 0 ? void 0 : mutations.state.checkout) === null || _f === void 0 ? void 0 : _f.id) ? { checkout_id: (_g = mutations.state === null || mutations.state === void 0 ? void 0 : mutations.state.checkout) === null || _g === void 0 ? void 0 : _g.id } : {}),
1174 is_surecart_payment_redirect: true,
1175 }),
1176 },
1177 data,
1178 processor: {
1179 id: watchers.state.id,
1180 manual: watchers.state.manual,
1181 },
1182 });
1183 if ((_l = (_k = (_j = (_h = mutations.state.checkout) === null || _h === void 0 ? void 0 : _h.payment_intent) === null || _j === void 0 ? void 0 : _j.processor_data) === null || _k === void 0 ? void 0 : _k.mollie) === null || _l === void 0 ? void 0 : _l.checkout_url) {
1184 mutations.updateFormState('PAYING');
1185 return setTimeout(() => { var _a, _b, _c, _d; return window.location.assign((_d = (_c = (_b = (_a = mutations.state.checkout) === null || _a === void 0 ? void 0 : _a.payment_intent) === null || _b === void 0 ? void 0 : _b.processor_data) === null || _c === void 0 ? void 0 : _c.mollie) === null || _d === void 0 ? void 0 : _d.checkout_url); }, 50);
1186 }
1187 // the checkout is paid.
1188 if (['paid', 'processing'].includes((_m = mutations.state.checkout) === null || _m === void 0 ? void 0 : _m.status)) {
1189 this.scPaid.emit();
1190 }
1191 setTimeout(() => {
1192 mutations.updateFormState('PAYING');
1193 }, 50);
1194 return mutations.state.checkout;
1195 }
1196 catch (e) {
1197 console.error(e);
1198 this.handleErrorResponse(e);
1199 return new Error(e === null || e === void 0 ? void 0 : e.message);
1200 }
1201 }
1202 /**
1203 * Handle paid event and update the
1204 */
1205 async handlePaid() {
1206 mutations.updateFormState('PAID');
1207 }
1208 async handleAbandonedCartUpdate(e) {
1209 const abandoned_checkout_enabled = e.detail;
1210 this.loadUpdate({
1211 abandoned_checkout_enabled,
1212 });
1213 }
1214 /** Find or create session on load. */
1215 componentDidLoad() {
1216 this.findOrCreateOrder();
1217 }
1218 /** Find or create an order */
1219 async findOrCreateOrder() {
1220 var _a;
1221 // get URL params.
1222 const { redirect_status, checkout_id, line_items, coupon, is_surecart_payment_redirect } = addQueryArgs.getQueryArgs(window.location.href);
1223 // remove params we don't want.
1224 window.history.replaceState({}, document.title, removeQueryArgs.removeQueryArgs(window.location.href, 'redirect_status', 'coupon', 'line_items', 'confirm_checkout_id', 'checkout_id', 'no_cart', 'is_surecart_payment_redirect'));
1225 // handle abandoned checkout.
1226 if (!!is_surecart_payment_redirect && !!checkout_id) {
1227 mutations.updateFormState('FINALIZE');
1228 mutations.updateFormState('PAYING');
1229 return this.handleCheckoutIdFromUrl(checkout_id, coupon, {
1230 refresh_status: true,
1231 });
1232 }
1233 // handle redirect status.
1234 if (!!redirect_status) {
1235 return this.handleRedirectStatus(redirect_status, checkout_id);
1236 }
1237 // handle abandoned checkout.
1238 if (!!checkout_id) {
1239 return this.handleCheckoutIdFromUrl(checkout_id, coupon);
1240 }
1241 // handle initial line items.
1242 if (!!line_items) {
1243 return this.handleInitialLineItems(line_items, coupon);
1244 }
1245 // we have an existing saved checkout id in the session, and we are persisting.
1246 const id = (_a = mutations.state === null || mutations.state === void 0 ? void 0 : mutations.state.checkout) === null || _a === void 0 ? void 0 : _a.id;
1247 if (id && this.persist) {
1248 return this.handleExistingCheckout(id, coupon);
1249 }
1250 return this.handleNewCheckout(coupon);
1251 }
1252 /** Handle payment instrument redirect status */
1253 async handleRedirectStatus(status, id) {
1254 var _a, _b;
1255 console.info('Handling payment redirect.');
1256 // status failed.
1257 if (status === 'failed') {
1258 mutations$2.createErrorNotice(wp.i18n.__('Payment unsuccessful. Please try again.', 'surecart'));
1259 return;
1260 }
1261 // get the
1262 if (!id) {
1263 mutations$2.createErrorNotice(wp.i18n.__('Could not find checkout. Please contact us before attempting to purchase again.', 'surecart'));
1264 return;
1265 }
1266 // success, refetch the checkout
1267 try {
1268 mutations.updateFormState('FINALIZE');
1269 mutations.state.checkout = (await index$2.fetchCheckout({
1270 id,
1271 query: {
1272 refresh_status: true,
1273 },
1274 }));
1275 // TODO: should we even check this?
1276 if (((_a = mutations.state.checkout) === null || _a === void 0 ? void 0 : _a.status) && ['paid', 'processing'].includes((_b = mutations.state.checkout) === null || _b === void 0 ? void 0 : _b.status)) {
1277 setTimeout(() => {
1278 mutations.updateFormState('PAID');
1279 this.scPaid.emit();
1280 }, 100);
1281 }
1282 }
1283 catch (e) {
1284 this.handleErrorResponse(e);
1285 }
1286 }
1287 /** Handle abandoned checkout from URL */
1288 async handleCheckoutIdFromUrl(id, promotion_code = '', query = {}) {
1289 var _a;
1290 console.info('Handling existing checkout from url.', promotion_code, id);
1291 // if coupon code, load the checkout with the code.
1292 if (promotion_code) {
1293 return this.loadUpdate({
1294 id,
1295 discount: { promotion_code },
1296 refresh_line_items: true,
1297 ...query,
1298 });
1299 }
1300 try {
1301 mutations.updateFormState('FETCH');
1302 mutations.state.checkout = (await index$2.fetchCheckout({
1303 id,
1304 query: {
1305 refresh_line_items: true,
1306 ...query,
1307 },
1308 }));
1309 mutations.updateFormState('RESOLVE');
1310 }
1311 catch (e) {
1312 this.handleErrorResponse(e);
1313 }
1314 // handle status.
1315 switch ((_a = mutations.state.checkout) === null || _a === void 0 ? void 0 : _a.status) {
1316 case 'paid':
1317 case 'processing':
1318 return setTimeout(() => {
1319 mutations.updateFormState('FINALIZE');
1320 mutations.updateFormState('PAID');
1321 this.scPaid.emit();
1322 }, 100);
1323 case 'payment_failed':
1324 mutations$2.createErrorNotice({
1325 message: wp.i18n.__('Payment unsuccessful.', 'surecart'),
1326 });
1327 mutations.updateFormState('REJECT');
1328 return;
1329 case 'payment_intent_canceled':
1330 mutations.updateFormState('REJECT');
1331 return;
1332 case 'canceled':
1333 mutations$1.clearCheckout();
1334 mutations$2.createErrorNotice({
1335 message: wp.i18n.__('Payment canceled. Please try again.', 'surecart'),
1336 });
1337 mutations.updateFormState('REJECT');
1338 return;
1339 }
1340 }
1341 /** Handle line items (and maybe ) */
1342 async handleInitialLineItems(line_items, promotion_code) {
1343 console.info('Handling initial line items.');
1344 // TODO: move this to central store.
1345 const address = this.el.querySelector('sc-order-shipping-address');
1346 return this.loadUpdate({
1347 line_items,
1348 refresh_line_items: true,
1349 ...(promotion_code ? { discount: { promotion_code } } : {}),
1350 ...((address === null || address === void 0 ? void 0 : address.defaultCountry)
1351 ? {
1352 shipping_address: {
1353 country: address === null || address === void 0 ? void 0 : address.defaultCountry,
1354 },
1355 }
1356 : {}),
1357 });
1358 }
1359 /** Handle a brand new checkout. */
1360 async handleNewCheckout(promotion_code) {
1361 var _a, _b, _c;
1362 // get existing form data from defaults (default country selection, etc).
1363 const data = this.getFormData();
1364 let line_items = mutations.state.initialLineItems || [];
1365 const address = this.el.querySelector('sc-order-shipping-address');
1366 try {
1367 mutations.updateFormState('FETCH');
1368 mutations.state.checkout = (await index$2.createCheckout({
1369 data: {
1370 ...data,
1371 ...(promotion_code ? { discount: { promotion_code } } : {}),
1372 ...((address === null || address === void 0 ? void 0 : address.defaultCountry)
1373 ? {
1374 shipping_address: {
1375 country: address === null || address === void 0 ? void 0 : address.defaultCountry,
1376 },
1377 }
1378 : {}),
1379 line_items,
1380 ...(((_a = mutations.state.taxProtocol) === null || _a === void 0 ? void 0 : _a.eu_vat_required) ? { tax_identifier: { number_type: 'eu_vat' } } : {}),
1381 },
1382 }));
1383 mutations.updateFormState('RESOLVE');
1384 }
1385 catch (e) {
1386 console.error(e);
1387 this.handleErrorResponse(e);
1388 // Handle any invalid coupon set on checkout URL.
1389 if (((_c = (_b = e === null || e === void 0 ? void 0 : e.additional_errors) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.code) === 'checkout.discount.coupon.blank') {
1390 await this.handleNewCheckout(false);
1391 mutations$2.createErrorNotice(e);
1392 }
1393 }
1394 }
1395 /** Handle existing checkout */
1396 async handleExistingCheckout(id, promotion_code) {
1397 var _a, _b, _c;
1398 if (!id)
1399 return this.handleNewCheckout(promotion_code);
1400 console.info('Handling existing checkout.');
1401 try {
1402 mutations.updateFormState('FETCH');
1403 mutations.state.checkout = (await index$2.createOrUpdateCheckout({
1404 id,
1405 data: {
1406 ...(promotion_code ? { discount: { promotion_code } } : {}),
1407 ...(((_a = mutations.state.taxProtocol) === null || _a === void 0 ? void 0 : _a.eu_vat_required) ? { tax_identifier: { number_type: 'eu_vat' } } : {}),
1408 refresh_line_items: true,
1409 },
1410 }));
1411 mutations.updateFormState('RESOLVE');
1412 }
1413 catch (e) {
1414 console.error(e);
1415 this.handleErrorResponse(e);
1416 // Handle any invalid coupon set on checkout URL.
1417 if (((_c = (_b = e === null || e === void 0 ? void 0 : e.additional_errors) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.code) === 'checkout.discount.coupon.blank') {
1418 await this.handleExistingCheckout(id, false);
1419 mutations$2.createErrorNotice(e);
1420 }
1421 }
1422 }
1423 /** Handle the error response. */
1424 async handleErrorResponse(e) {
1425 var _a, _b, _c, _d, _e, _f;
1426 // reinitalize if order not found.
1427 if (['checkout.not_found'].includes(e === null || e === void 0 ? void 0 : e.code)) {
1428 mutations$1.clearCheckout();
1429 return this.handleNewCheckout(false);
1430 }
1431 if (['test_mode_restricted'].includes(e === null || e === void 0 ? void 0 : e.code)) {
1432 mutations.updateFormState('TEST_MODE_RESTRICTED');
1433 return;
1434 }
1435 const hasPriceVersionChangeError = ((e === null || e === void 0 ? void 0 : e.additional_errors) || []).some(error => {
1436 var _a, _b;
1437 const purchasableStatuses = ((_b = (_a = error === null || error === void 0 ? void 0 : error.data) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.purchasable_statuses) || [];
1438 return ['price_old_version', 'variant_old_version'].some(status => purchasableStatuses.includes(status));
1439 });
1440 if (hasPriceVersionChangeError) {
1441 await this.loadUpdate({
1442 id: (_a = mutations.state === null || mutations.state === void 0 ? void 0 : mutations.state.checkout) === null || _a === void 0 ? void 0 : _a.id,
1443 refresh_line_items: true,
1444 status: 'draft',
1445 });
1446 mutations$2.createInfoNotice(((_c = (_b = e === null || e === void 0 ? void 0 : e.additional_errors) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.message) ||
1447 wp.i18n.__('Some products in your order were outdated and have been updated. Please review your order summary before proceeding to payment.', 'surecart'));
1448 mutations.updateFormState('REJECT');
1449 return;
1450 }
1451 // If got Product out of stock error, then fetch the checkout again.
1452 if (((_e = (_d = e === null || e === void 0 ? void 0 : e.additional_errors) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.code) === 'checkout.product.out_of_stock') {
1453 this.fetch();
1454 mutations.updateFormState('REJECT');
1455 return;
1456 }
1457 if (['order.invalid_status_transition'].includes(e === null || e === void 0 ? void 0 : e.code)) {
1458 await this.loadUpdate({
1459 id: (_f = mutations.state === null || mutations.state === void 0 ? void 0 : mutations.state.checkout) === null || _f === void 0 ? void 0 : _f.id,
1460 status: 'draft',
1461 });
1462 this.handleFormSubmit();
1463 return;
1464 }
1465 // expired
1466 if ((e === null || e === void 0 ? void 0 : e.code) === 'rest_cookie_invalid_nonce') {
1467 mutations.updateFormState('EXPIRE');
1468 return;
1469 }
1470 // paid
1471 if ((e === null || e === void 0 ? void 0 : e.code) === 'readonly') {
1472 mutations$1.clearCheckout();
1473 window.location.assign(removeQueryArgs.removeQueryArgs(window.location.href, 'order'));
1474 return;
1475 }
1476 mutations$2.createErrorNotice(e);
1477 mutations.updateFormState('REJECT');
1478 }
1479 /** Looks through children and finds items needed for initial session. */
1480 async initialize(args = {}) {
1481 let line_items = mutations.state.initialLineItems || [];
1482 return this.loadUpdate({ ...((line_items === null || line_items === void 0 ? void 0 : line_items.length) ? { line_items } : {}), ...args });
1483 }
1484 /** Add prices that are passed into the component. */
1485 addInitialPrices() {
1486 var _a;
1487 if (!((_a = this === null || this === void 0 ? void 0 : this.prices) === null || _a === void 0 ? void 0 : _a.length))
1488 return [];
1489 // check for id
1490 if (this.prices.some(p => !(p === null || p === void 0 ? void 0 : p.id))) {
1491 return;
1492 }
1493 // add prices that are passed into this component.
1494 return this.prices.map(price => {
1495 return {
1496 price_id: price.id,
1497 quantity: price.quantity,
1498 variant: price.variant,
1499 };
1500 });
1501 }
1502 // /** Add default prices that may be selected in form. */
1503 // addPriceChoices(line_items = []) {
1504 // // const elements = this.el.querySelectorAll('[price-id]') as any;
1505 // // elements.forEach(el => {
1506 // // // handle price choices.
1507 // // if (el.checked) {
1508 // // line_items.push({
1509 // // quantity: el.quantity || 1,
1510 // // price_id: el.priceId,
1511 // // ...(el.defaultAmount ? { ad_hoc_amount: el.defaultAmount } : {}),
1512 // // });
1513 // // }
1514 // // // handle donation default amount.
1515 // // if (el.defaultAmount) {
1516 // // line_items.push({
1517 // // quantity: el.quantity || 1,
1518 // // price_id: el.priceId,
1519 // // ad_hoc_amount: el.defaultAmount,
1520 // // });
1521 // // }
1522 // // });
1523 // // return line_items;
1524 // }
1525 getSessionId() {
1526 var _a, _b;
1527 // check url first.
1528 const checkoutId = removeQueryArgs.getQueryArg(window.location.href, 'checkout_id');
1529 if (!!checkoutId) {
1530 return checkoutId;
1531 }
1532 // check existing order.
1533 if ((_a = mutations.state === null || mutations.state === void 0 ? void 0 : mutations.state.checkout) === null || _a === void 0 ? void 0 : _a.id) {
1534 return (_b = mutations.state === null || mutations.state === void 0 ? void 0 : mutations.state.checkout) === null || _b === void 0 ? void 0 : _b.id;
1535 }
1536 // we don't have and order id.
1537 return null;
1538 }
1539 async fetchCheckout(id, { query = {}, data = {} } = {}) {
1540 try {
1541 mutations.updateFormState('FETCH');
1542 const checkout = (await index$2.createOrUpdateCheckout({
1543 id,
1544 query,
1545 data,
1546 }));
1547 mutations.updateFormState('RESOLVE');
1548 return checkout;
1549 }
1550 catch (e) {
1551 this.handleErrorResponse(e);
1552 }
1553 }
1554 /** Fetch a session. */
1555 async fetch(query = {}) {
1556 try {
1557 mutations.updateFormState('FETCH');
1558 mutations.state.checkout = (await index$2.fetchCheckout({
1559 id: this.getSessionId(),
1560 query,
1561 }));
1562 mutations.updateFormState('RESOLVE');
1563 }
1564 catch (e) {
1565 this.handleErrorResponse(e);
1566 }
1567 }
1568 /** Update a session */
1569 async update(data = {}, query = {}) {
1570 try {
1571 mutations.state.checkout = (await index$2.createOrUpdateCheckout({
1572 id: (data === null || data === void 0 ? void 0 : data.id) ? data.id : this.getSessionId(),
1573 data,
1574 query,
1575 }));
1576 }
1577 catch (e) {
1578 // reinitalize if order not found.
1579 if (['checkout.not_found'].includes(e === null || e === void 0 ? void 0 : e.code)) {
1580 mutations$1.clearCheckout();
1581 return this.initialize();
1582 }
1583 console.error(e);
1584 throw e;
1585 }
1586 }
1587 /** Updates a session with loading status changes. */
1588 async loadUpdate(data = {}) {
1589 try {
1590 mutations.updateFormState('FETCH');
1591 await this.update(data);
1592 mutations.updateFormState('RESOLVE');
1593 }
1594 catch (e) {
1595 this.handleErrorResponse(e);
1596 }
1597 }
1598 render() {
1599 return (index.h("sc-line-items-provider", { key: '3f3e2b8570b16d272135364bf84373106a15d564', order: mutations.state === null || mutations.state === void 0 ? void 0 : mutations.state.checkout, onScUpdateLineItems: e => this.loadUpdate({ line_items: e.detail }) }, index.h("slot", { key: '4aab176d4e7477428008d314765658692cbf2630' })));
1600 }
1601 get el() { return index.getElement(this); }
1602 static get watchers() { return {
1603 "prices": ["handlePricesChange"]
1604 }; }
1605 };
1606
1607 exports.sc_checkout_autofill_provider = ScCheckoutAutofillProvider;
1608 exports.sc_checkout_geo_permission = ScCheckoutGeoPermission;
1609 exports.sc_checkout_stock_alert = ScCheckoutStockAlert;
1610 exports.sc_checkout_test_complete = ScCheckoutTestComplete;
1611 exports.sc_checkout_unsaved_changes_warning = ScCheckoutUnsavedChangesWarning;
1612 exports.sc_form_components_validator = ScFormComponentsValidator;
1613 exports.sc_form_error_provider = ScFormErrorProvider;
1614 exports.sc_form_state_provider = ScFormStateProvider;
1615 exports.sc_login_provider = ScLoginProvider;
1616 exports.sc_order_confirm_provider = ScOrderConfirmProvider;
1617 exports.sc_session_provider = ScSessionProvider;
1618
1619 //# sourceMappingURL=sc-checkout-autofill-provider_11.cjs.entry.js.map