MockProcessor-498b60c5.js
1 year ago
MockProcessor-498b60c5.js.map
1 year ago
add-query-args-0e2a8393.js
1 year ago
add-query-args-0e2a8393.js.map
1 year ago
address-b892540d.js
1 year ago
address-b892540d.js.map
1 year ago
animation-registry-12eed2e3.js
1 year ago
animation-registry-12eed2e3.js.map
1 year ago
app-globals-707edcd4.js
1 year ago
app-globals-707edcd4.js.map
1 year ago
consumer-e06b16d3.js
1 year ago
consumer-e06b16d3.js.map
1 year ago
countries-c2f41f03.js
1 year ago
countries-c2f41f03.js.map
1 year ago
currency-a0c9bff4.js
1 year ago
currency-a0c9bff4.js.map
1 year ago
error-12ea55b3.js
1 year ago
error-12ea55b3.js.map
1 year ago
fetch-e3c5d1b9.js
1 year ago
fetch-e3c5d1b9.js.map
1 year ago
form-data-76641f16.js
1 year ago
form-data-76641f16.js.map
1 year ago
functions-2a4a4ba3.js
1 year ago
functions-2a4a4ba3.js.map
1 year ago
getters-09dda855.js
1 year ago
getters-09dda855.js.map
1 year ago
getters-1a55b8a4.js
1 year ago
getters-1a55b8a4.js.map
1 year ago
getters-26526b7c.js
1 year ago
getters-26526b7c.js.map
1 year ago
getters-a7eec27c.js
1 year ago
getters-a7eec27c.js.map
1 year ago
getters-b1d93841.js
1 year ago
getters-b1d93841.js.map
1 year ago
google-a86aa761.js
1 year ago
google-a86aa761.js.map
1 year ago
google-dd89f242.js
1 year ago
google-dd89f242.js.map
1 year ago
index-06061d4e.js
1 year ago
index-06061d4e.js.map
1 year ago
index-675be13e.js
1 year ago
index-675be13e.js.map
1 year ago
index-745b6bec.js
1 year ago
index-745b6bec.js.map
1 year ago
index-822e5799.js
1 year ago
index-822e5799.js.map
1 year ago
index-871d88b8.js
1 year ago
index-871d88b8.js.map
1 year ago
index-c5a96d53.js
2 years ago
index-c5a96d53.js.map
2 years ago
index.js
1 year ago
index.js.map
2 years ago
inline-c012a0f9.js
1 year ago
inline-c012a0f9.js.map
1 year ago
lazy-deb42890.js
1 year ago
lazy-deb42890.js.map
1 year ago
library-e110eea6.js
1 year ago
library-e110eea6.js.map
1 year ago
loader.js
1 year ago
loader.js.map
1 year ago
media-d21119a3.js
1 year ago
media-d21119a3.js.map
1 year ago
mutations-066b82f0.js
1 year ago
mutations-066b82f0.js.map
1 year ago
mutations-7ba12644.js
1 year ago
mutations-7ba12644.js.map
1 year ago
mutations-e77bd122.js
1 year ago
mutations-e77bd122.js.map
1 year ago
mutations-ed6d0770.js
1 year ago
mutations-ed6d0770.js.map
1 year ago
mutations-f11a19f9.js
1 year ago
mutations-f11a19f9.js.map
1 year ago
page-align-0cdacf32.js
1 year ago
page-align-0cdacf32.js.map
1 year ago
price-d5770168.js
1 year ago
price-d5770168.js.map
1 year ago
pure-963214cb.js
1 year ago
pure-963214cb.js.map
1 year ago
quantity-1f39f750.js
1 year ago
quantity-1f39f750.js.map
1 year ago
remove-query-args-938c53ea.js
1 year ago
remove-query-args-938c53ea.js.map
1 year ago
sc-address_3.entry.js
1 year ago
sc-address_3.entry.js.map
1 year ago
sc-alert_13.entry.js
1 year ago
sc-alert_13.entry.js.map
1 year ago
sc-avatar.entry.js
1 year ago
sc-avatar.entry.js.map
1 year ago
sc-badge-notice.entry.js
1 year ago
sc-badge-notice.entry.js.map
1 year ago
sc-breadcrumb.entry.js
1 year ago
sc-breadcrumb.entry.js.map
1 year ago
sc-breadcrumbs.entry.js
1 year ago
sc-breadcrumbs.entry.js.map
1 year ago
sc-button-group.entry.js
1 year ago
sc-button-group.entry.js.map
1 year ago
sc-cancel-dialog_2.entry.js
1 year ago
sc-cancel-dialog_2.entry.js.map
1 year ago
sc-cancel-discount_4.entry.js
1 year ago
sc-cancel-discount_4.entry.js.map
1 year ago
sc-card.entry.js
1 year ago
sc-card.entry.js.map
1 year ago
sc-cart-button.entry.js
1 year ago
sc-cart-button.entry.js.map
1 year ago
sc-cart-form-submit.entry.js
1 year ago
sc-cart-form-submit.entry.js.map
1 year ago
sc-cart-form.entry.js
1 year ago
sc-cart-form.entry.js.map
1 year ago
sc-cart-header.entry.js
1 year ago
sc-cart-header.entry.js.map
1 year ago
sc-cart-icon.entry.js
1 year ago
sc-cart-icon.entry.js.map
1 year ago
sc-cart-loader.entry.js
1 year ago
sc-cart-loader.entry.js.map
1 year ago
sc-cart-session-provider_3.entry.js
1 year ago
sc-cart-session-provider_3.entry.js.map
1 year ago
sc-cart-submit.entry.js
1 year ago
sc-cart-submit.entry.js.map
1 year ago
sc-cart.entry.js
1 year ago
sc-cart.entry.js.map
1 year ago
sc-cc-logo_2.entry.js
1 year ago
sc-cc-logo_2.entry.js.map
1 year ago
sc-charges-list.entry.js
1 year ago
sc-charges-list.entry.js.map
1 year ago
sc-checkout-form-errors.entry.js
1 year ago
sc-checkout-form-errors.entry.js.map
1 year ago
sc-checkout-mollie-payment_2.entry.js
1 year ago
sc-checkout-mollie-payment_2.entry.js.map
1 year ago
sc-checkout-product-price-variant-selector.entry.js
1 year ago
sc-checkout-product-price-variant-selector.entry.js.map
1 year ago
sc-checkout-stock-alert_8.entry.js
1 year ago
sc-checkout-stock-alert_8.entry.js.map
1 year ago
sc-checkout.entry.js
1 year ago
sc-checkout.entry.js.map
1 year ago
sc-choice-container.entry.js
1 year ago
sc-choice-container.entry.js.map
1 year ago
sc-choice.entry.js
1 year ago
sc-choice.entry.js.map
1 year ago
sc-choices.entry.js
1 year ago
sc-choices.entry.js.map
1 year ago
sc-column_2.entry.js
1 year ago
sc-column_2.entry.js.map
1 year ago
sc-compact-address_11.entry.js
1 year ago
sc-compact-address_11.entry.js.map
1 year ago
sc-conditional-form.entry.js
1 year ago
sc-conditional-form.entry.js.map
1 year ago
sc-consumer.entry.js
1 year ago
sc-consumer.entry.js.map
1 year ago
sc-coupon-form.entry.js
1 year ago
sc-coupon-form.entry.js.map
1 year ago
sc-custom-order-price-input.entry.js
1 year ago
sc-custom-order-price-input.entry.js.map
1 year ago
sc-customer-details.entry.js
1 year ago
sc-customer-details.entry.js.map
1 year ago
sc-customer-edit.entry.js
1 year ago
sc-customer-edit.entry.js.map
1 year ago
sc-customer-email.entry.js
1 year ago
sc-customer-email.entry.js.map
1 year ago
sc-customer-firstname.entry.js
1 year ago
sc-customer-firstname.entry.js.map
1 year ago
sc-customer-lastname.entry.js
1 year ago
sc-customer-lastname.entry.js.map
1 year ago
sc-customer-name.entry.js
1 year ago
sc-customer-name.entry.js.map
1 year ago
sc-customer-phone.entry.js
1 year ago
sc-customer-phone.entry.js.map
1 year ago
sc-dashboard-customer-details.entry.js
1 year ago
sc-dashboard-customer-details.entry.js.map
1 year ago
sc-dashboard-downloads-list.entry.js
1 year ago
sc-dashboard-downloads-list.entry.js.map
1 year ago
sc-divider.entry.js
1 year ago
sc-divider.entry.js.map
1 year ago
sc-donation-choices.entry.js
1 year ago
sc-donation-choices.entry.js.map
1 year ago
sc-downloads-list.entry.js
1 year ago
sc-downloads-list.entry.js.map
1 year ago
sc-dropdown_3.entry.js
1 year ago
sc-dropdown_3.entry.js.map
1 year ago
sc-empty.entry.js
1 year ago
sc-empty.entry.js.map
1 year ago
sc-express-payment.entry.js
1 year ago
sc-express-payment.entry.js.map
1 year ago
sc-feature-demo-banner.entry.js
1 year ago
sc-feature-demo-banner.entry.js.map
1 year ago
sc-form-control_2.entry.js
1 year ago
sc-form-control_2.entry.js.map
1 year ago
sc-form-row.entry.js
1 year ago
sc-form-row.entry.js.map
1 year ago
sc-form.entry.js
1 year ago
sc-form.entry.js.map
1 year ago
sc-format-bytes.entry.js
1 year ago
sc-format-bytes.entry.js.map
1 year ago
sc-format-interval.entry.js
1 year ago
sc-format-interval.entry.js.map
1 year ago
sc-fulfillment-shipping-status-badge.entry.js
1 year ago
sc-fulfillment-shipping-status-badge.entry.js.map
1 year ago
sc-fulfillments.entry.js
1 year ago
sc-fulfillments.entry.js.map
1 year ago
sc-heading_2.entry.js
1 year ago
sc-heading_2.entry.js.map
1 year ago
sc-image-slider.entry.js
1 year ago
sc-image-slider.entry.js.map
1 year ago
sc-invoices-list.entry.js
1 year ago
sc-invoices-list.entry.js.map
1 year ago
sc-license.entry.js
1 year ago
sc-license.entry.js.map
1 year ago
sc-licenses-list.entry.js
1 year ago
sc-licenses-list.entry.js.map
1 year ago
sc-line-item-bump.entry.js
1 year ago
sc-line-item-bump.entry.js.map
1 year ago
sc-line-item-total.entry.js
1 year ago
sc-line-item-total.entry.js.map
1 year ago
sc-line-item.entry.js
1 year ago
sc-line-item.entry.js.map
1 year ago
sc-line-items-provider.entry.js
1 year ago
sc-line-items-provider.entry.js.map
1 year ago
sc-line-items.entry.js
1 year ago
sc-line-items.entry.js.map
1 year ago
sc-login-form.entry.js
1 year ago
sc-login-form.entry.js.map
1 year ago
sc-manual-payment-method_3.entry.js
1 year ago
sc-manual-payment-method_3.entry.js.map
1 year ago
sc-menu-divider.entry.js
1 year ago
sc-menu-divider.entry.js.map
1 year ago
sc-menu-label_2.entry.js
1 year ago
sc-menu-label_2.entry.js.map
1 year ago
sc-mollie-add-method.entry.js
1 year ago
sc-mollie-add-method.entry.js.map
1 year ago
sc-order-confirmation-customer.entry.js
1 year ago
sc-order-confirmation-customer.entry.js.map
1 year ago
sc-order-confirmation-details.entry.js
1 year ago
sc-order-confirmation-details.entry.js.map
1 year ago
sc-order-confirmation-line-items_2.entry.js
1 year ago
sc-order-confirmation-line-items_2.entry.js.map
1 year ago
sc-order-confirmation.entry.js
1 year ago
sc-order-confirmation.entry.js.map
1 year ago
sc-order-coupon-form.entry.js
1 year ago
sc-order-coupon-form.entry.js.map
1 year ago
sc-order-detail.entry.js
1 year ago
sc-order-detail.entry.js.map
1 year ago
sc-order-fulfillment-badge.entry.js
1 year ago
sc-order-fulfillment-badge.entry.js.map
1 year ago
sc-order-manual-instructions.entry.js
1 year ago
sc-order-manual-instructions.entry.js.map
1 year ago
sc-order-password.entry.js
1 year ago
sc-order-password.entry.js.map
1 year ago
sc-order-return-badge.entry.js
1 year ago
sc-order-return-badge.entry.js.map
1 year ago
sc-order-shipment-badge.entry.js
1 year ago
sc-order-shipment-badge.entry.js.map
1 year ago
sc-order-status-badge.entry.js
1 year ago
sc-order-status-badge.entry.js.map
1 year ago
sc-order-submit.entry.js
1 year ago
sc-order-submit.entry.js.map
1 year ago
sc-order-summary.entry.js
1 year ago
sc-order-summary.entry.js.map
1 year ago
sc-order.entry.js
1 year ago
sc-order.entry.js.map
1 year ago
sc-orders-list.entry.js
1 year ago
sc-orders-list.entry.js.map
1 year ago
sc-pagination.entry.js
1 year ago
sc-pagination.entry.js.map
1 year ago
sc-password-nag.entry.js
1 year ago
sc-password-nag.entry.js.map
1 year ago
sc-password.entry.js
1 year ago
sc-password.entry.js.map
1 year ago
sc-payment-method-choice_2.entry.js
1 year ago
sc-payment-method-choice_2.entry.js.map
1 year ago
sc-payment-method-details.entry.js
1 year ago
sc-payment-method-details.entry.js.map
1 year ago
sc-payment-methods-list.entry.js
1 year ago
sc-payment-methods-list.entry.js.map
1 year ago
sc-payment.entry.js
1 year ago
sc-payment.entry.js.map
1 year ago
sc-paypal-add-method.entry.js
1 year ago
sc-paypal-add-method.entry.js.map
1 year ago
sc-paypal-buttons_2.entry.js
1 year ago
sc-paypal-buttons_2.entry.js.map
1 year ago
sc-paystack-add-method.entry.js
1 year ago
sc-paystack-add-method.entry.js.map
1 year ago
sc-phone-input.entry.js
1 year ago
sc-phone-input.entry.js.map
1 year ago
sc-pill-option.entry.js
1 year ago
sc-pill-option.entry.js.map
1 year ago
sc-premium-tag.entry.js
1 year ago
sc-premium-tag.entry.js.map
1 year ago
sc-price-choice-container.entry.js
1 year ago
sc-price-choice-container.entry.js.map
1 year ago
sc-price-choice.entry.js
1 year ago
sc-price-choice.entry.js.map
1 year ago
sc-price-choices.entry.js
1 year ago
sc-price-choices.entry.js.map
1 year ago
sc-price-input.entry.js
1 year ago
sc-price-input.entry.js.map
1 year ago
sc-price-range.entry.js
1 year ago
sc-price-range.entry.js.map
1 year ago
sc-price.entry.js
1 year ago
sc-price.entry.js.map
1 year ago
sc-product-buy-button.entry.js
1 year ago
sc-product-buy-button.entry.js.map
1 year ago
sc-product-donation-amount-choice.entry.js
1 year ago
sc-product-donation-amount-choice.entry.js.map
1 year ago
sc-product-donation-choices.entry.js
1 year ago
sc-product-donation-choices.entry.js.map
1 year ago
sc-product-donation-custom-amount.entry.js
1 year ago
sc-product-donation-custom-amount.entry.js.map
1 year ago
sc-product-item-image_3.entry.js
1 year ago
sc-product-item-image_3.entry.js.map
1 year ago
sc-product-item-list.entry.js
1 year ago
sc-product-item-list.entry.js.map
1 year ago
sc-product-item.entry.js
1 year ago
sc-product-item.entry.js.map
1 year ago
sc-product-line-item_2.entry.js
1 year ago
sc-product-line-item_2.entry.js.map
1 year ago
sc-product-pills-variant-option.entry.js
1 year ago
sc-product-pills-variant-option.entry.js.map
1 year ago
sc-product-price-choices.entry.js
1 year ago
sc-product-price-choices.entry.js.map
1 year ago
sc-product-price-modal.entry.js
1 year ago
sc-product-price-modal.entry.js.map
1 year ago
sc-product-price.entry.js
1 year ago
sc-product-price.entry.js.map
1 year ago
sc-product-quantity.entry.js
1 year ago
sc-product-quantity.entry.js.map
1 year ago
sc-product-selected-price.entry.js
1 year ago
sc-product-selected-price.entry.js.map
1 year ago
sc-product-text.entry.js
1 year ago
sc-product-text.entry.js.map
1 year ago
sc-provider.entry.js
1 year ago
sc-provider.entry.js.map
1 year ago
sc-provisional-banner.entry.js
1 year ago
sc-provisional-banner.entry.js.map
1 year ago
sc-purchase-downloads-list.entry.js
1 year ago
sc-purchase-downloads-list.entry.js.map
1 year ago
sc-recurring-price-choice-container.entry.js
1 year ago
sc-recurring-price-choice-container.entry.js.map
1 year ago
sc-rich-text.entry.js
1 year ago
sc-rich-text.entry.js.map
1 year ago
sc-spacing.entry.js
1 year ago
sc-spacing.entry.js.map
1 year ago
sc-stacked-list_2.entry.js
1 year ago
sc-stacked-list_2.entry.js.map
1 year ago
sc-stripe-add-method.entry.js
1 year ago
sc-stripe-add-method.entry.js.map
1 year ago
sc-stripe-element.entry.js
1 year ago
sc-stripe-element.entry.js.map
1 year ago
sc-stripe-payment-element.entry.js
1 year ago
sc-stripe-payment-element.entry.js.map
1 year ago
sc-stripe-payment-request.entry.js
1 year ago
sc-stripe-payment-request.entry.js.map
1 year ago
sc-subscription-ad-hoc-confirm.entry.js
1 year ago
sc-subscription-ad-hoc-confirm.entry.js.map
1 year ago
sc-subscription-details_2.entry.js
1 year ago
sc-subscription-details_2.entry.js.map
1 year ago
sc-subscription-payment-method.entry.js
1 year ago
sc-subscription-payment-method.entry.js.map
1 year ago
sc-subscription-payment.entry.js
1 year ago
sc-subscription-payment.entry.js.map
1 year ago
sc-subscription-switch.entry.js
1 year ago
sc-subscription-switch.entry.js.map
1 year ago
sc-subscription-variation-confirm.entry.js
1 year ago
sc-subscription-variation-confirm.entry.js.map
1 year ago
sc-subscription.entry.js
1 year ago
sc-subscription.entry.js.map
1 year ago
sc-subscriptions-list.entry.js
1 year ago
sc-subscriptions-list.entry.js.map
1 year ago
sc-summary.entry.js
1 year ago
sc-summary.entry.js.map
1 year ago
sc-switch.entry.js
1 year ago
sc-switch.entry.js.map
1 year ago
sc-tab-group.entry.js
1 year ago
sc-tab-group.entry.js.map
1 year ago
sc-tab-panel.entry.js
1 year ago
sc-tab-panel.entry.js.map
1 year ago
sc-tab.entry.js
1 year ago
sc-tab.entry.js.map
1 year ago
sc-table-head.entry.js
1 year ago
sc-table-head.entry.js.map
1 year ago
sc-table_3.entry.js
1 year ago
sc-table_3.entry.js.map
1 year ago
sc-tag.entry.js
1 year ago
sc-tag.entry.js.map
1 year ago
sc-toggle.entry.js
1 year ago
sc-toggle.entry.js.map
1 year ago
sc-toggles.entry.js
1 year ago
sc-toggles.entry.js.map
1 year ago
sc-total.entry.js
1 year ago
sc-total.entry.js.map
1 year ago
sc-upcoming-invoice.entry.js
1 year ago
sc-upcoming-invoice.entry.js.map
1 year ago
sc-upgrade-required.entry.js
1 year ago
sc-upgrade-required.entry.js.map
1 year ago
sc-upsell-countdown-timer.entry.js
1 year ago
sc-upsell-countdown-timer.entry.js.map
1 year ago
sc-upsell-no-thanks-button.entry.js
1 year ago
sc-upsell-no-thanks-button.entry.js.map
1 year ago
sc-upsell-submit-button.entry.js
1 year ago
sc-upsell-submit-button.entry.js.map
1 year ago
sc-upsell-totals.entry.js
1 year ago
sc-upsell-totals.entry.js.map
1 year ago
sc-upsell.entry.js
1 year ago
sc-upsell.entry.js.map
1 year ago
sc-visually-hidden.entry.js
1 year ago
sc-visually-hidden.entry.js.map
1 year ago
sc-wordpress-password-edit.entry.js
1 year ago
sc-wordpress-password-edit.entry.js.map
1 year ago
sc-wordpress-user-edit.entry.js
1 year ago
sc-wordpress-user-edit.entry.js.map
1 year ago
sc-wordpress-user.entry.js
1 year ago
sc-wordpress-user.entry.js.map
1 year ago
store-093f0f6a.js
1 year ago
store-093f0f6a.js.map
1 year ago
store-a8bae355.js
1 year ago
store-a8bae355.js.map
1 year ago
store-dcefd119.js
1 year ago
store-dcefd119.js.map
1 year ago
surecart.js
1 year ago
surecart.js.map
1 year ago
tax-d4911dbc.js
1 year ago
tax-d4911dbc.js.map
1 year ago
universe-5a73abb7.js
1 year ago
universe-5a73abb7.js.map
1 year ago
util-50af2a83.js
1 year ago
util-50af2a83.js.map
1 year ago
utils-e9ee502a.js
1 year ago
utils-e9ee502a.js.map
1 year ago
watchers-38693c1f.js
1 year ago
watchers-38693c1f.js.map
1 year ago
watchers-4d2edfb0.js
1 year ago
watchers-4d2edfb0.js.map
1 year ago
watchers-4e5b728a.js
1 year ago
watchers-4e5b728a.js.map
1 year ago
watchers-67501779.js
1 year ago
watchers-67501779.js.map
1 year ago
watchers-a697b0c8.js
1 year ago
watchers-a697b0c8.js.map
1 year ago
sc-compact-address_11.entry.js
815 lines
| 1 | import { r as registerInstance, c as createEvent, h, a as getElement, H as Host, F as Fragment } from './index-745b6bec.js'; |
| 2 | import { c as countryChoices, h as hasState } from './address-b892540d.js'; |
| 3 | import { r as reportChildrenValidity, F as FormSubmitController } from './form-data-76641f16.js'; |
| 4 | import { s as state } from './store-093f0f6a.js'; |
| 5 | import { s as state$1, o as onChange } from './mutations-066b82f0.js'; |
| 6 | import { o as openWormhole } from './consumer-e06b16d3.js'; |
| 7 | import { a as formLoading, f as formBusy } from './getters-09dda855.js'; |
| 8 | import { l as lockCheckout, b as unLockCheckout } from './mutations-f11a19f9.js'; |
| 9 | import { c as createOrUpdateCheckout } from './index-675be13e.js'; |
| 10 | import { s as speak } from './index-c5a96d53.js'; |
| 11 | import { a as isBumpInOrder } from './index-822e5799.js'; |
| 12 | import { i as intervalString, g as getFormattedPrice } from './price-d5770168.js'; |
| 13 | import { f as fullShippingAddressRequired, s as shippingAddressRequired, a as checkoutIsLocked } from './getters-1a55b8a4.js'; |
| 14 | import { c as createErrorNotice } from './mutations-ed6d0770.js'; |
| 15 | import { u as updateFormState } from './mutations-e77bd122.js'; |
| 16 | import { i as isRtl } from './page-align-0cdacf32.js'; |
| 17 | import './index-06061d4e.js'; |
| 18 | import './utils-e9ee502a.js'; |
| 19 | import './remove-query-args-938c53ea.js'; |
| 20 | import './add-query-args-0e2a8393.js'; |
| 21 | import './google-a86aa761.js'; |
| 22 | import './currency-a0c9bff4.js'; |
| 23 | import './fetch-e3c5d1b9.js'; |
| 24 | |
| 25 | const scCompactAddressCss = ":host{display:block}.sc-address{display:block;position:relative}.sc-address [hidden]{display:none}.sc-address--loading{min-height:70px}.sc-address--loading sc-skeleton{display:block;margin-bottom:1em}.sc-address__control{display:block}.sc-address__control>*{margin-bottom:-1px}.sc-address__columns{display:flex;flex-direction:row;align-items:center;flex-wrap:wrap;justify-content:space-between}.sc-address__columns>*{flex:1;width:50%;margin-left:-1px}.sc-address__columns>*:first-child{margin-left:0}"; |
| 26 | const ScCompactAddressStyle0 = scCompactAddressCss; |
| 27 | |
| 28 | const ScCompactAddress = class { |
| 29 | constructor(hostRef) { |
| 30 | registerInstance(this, hostRef); |
| 31 | this.scChangeAddress = createEvent(this, "scChangeAddress", 7); |
| 32 | this.scInputAddress = createEvent(this, "scInputAddress", 7); |
| 33 | this.address = { |
| 34 | country: null, |
| 35 | city: null, |
| 36 | line_1: null, |
| 37 | line_2: null, |
| 38 | postal_code: null, |
| 39 | state: null, |
| 40 | }; |
| 41 | this.names = { |
| 42 | country: 'shipping_country', |
| 43 | city: 'shipping_city', |
| 44 | line_1: 'shipping_line_1', |
| 45 | line_2: 'shipping_line_2', |
| 46 | postal_code: 'shipping_postal_code', |
| 47 | state: 'shipping_state', |
| 48 | }; |
| 49 | this.placeholders = { |
| 50 | country: '', |
| 51 | postal_code: '', |
| 52 | state: '', |
| 53 | }; |
| 54 | this.label = wp.i18n.__('Country or region', 'surecart'); |
| 55 | this.required = undefined; |
| 56 | this.loading = undefined; |
| 57 | this.countryChoices = countryChoices; |
| 58 | this.regions = undefined; |
| 59 | this.showState = undefined; |
| 60 | this.showPostal = undefined; |
| 61 | } |
| 62 | /** When the state changes, we want to update city and postal fields. */ |
| 63 | handleAddressChange() { |
| 64 | if (!this.address.country) |
| 65 | return; |
| 66 | this.setRegions(); |
| 67 | this.showState = ['US', 'CA'].includes(this.address.country); |
| 68 | this.showPostal = ['US'].includes(this.address.country); |
| 69 | this.scChangeAddress.emit(this.address); |
| 70 | this.scInputAddress.emit(this.address); |
| 71 | } |
| 72 | updateAddress(address) { |
| 73 | this.address = { ...this.address, ...address }; |
| 74 | } |
| 75 | handleAddressInput(address) { |
| 76 | this.scInputAddress.emit({ ...this.address, ...address }); |
| 77 | } |
| 78 | clearAddress() { |
| 79 | var _a; |
| 80 | this.address = { |
| 81 | name: (_a = this.address) === null || _a === void 0 ? void 0 : _a.name, |
| 82 | country: null, |
| 83 | line_1: null, |
| 84 | line_2: null, |
| 85 | city: null, |
| 86 | postal_code: null, |
| 87 | state: null, |
| 88 | }; |
| 89 | } |
| 90 | /** Set the regions based on the country. */ |
| 91 | setRegions() { |
| 92 | if (hasState(this.address.country)) { |
| 93 | import('./countries-c2f41f03.js').then(module => { |
| 94 | this.regions = module === null || module === void 0 ? void 0 : module[this.address.country]; |
| 95 | }); |
| 96 | } |
| 97 | else { |
| 98 | this.regions = []; |
| 99 | } |
| 100 | } |
| 101 | componentWillLoad() { |
| 102 | var _a; |
| 103 | this.handleAddressChange(); |
| 104 | const country = (_a = this.countryChoices.find(country => country.value === this.address.country)) === null || _a === void 0 ? void 0 : _a.value; |
| 105 | if (country) { |
| 106 | this.updateAddress({ country }); |
| 107 | } |
| 108 | } |
| 109 | async reportValidity() { |
| 110 | return reportChildrenValidity(this.el); |
| 111 | } |
| 112 | getStatePlaceholder() { |
| 113 | var _a, _b; |
| 114 | if ((_a = this.placeholders) === null || _a === void 0 ? void 0 : _a.state) |
| 115 | return this.placeholders.state; |
| 116 | if (((_b = this.address) === null || _b === void 0 ? void 0 : _b.country) === 'US') |
| 117 | return wp.i18n.__('State', 'surecart'); |
| 118 | return wp.i18n.__('Province/Region', 'surecart'); |
| 119 | } |
| 120 | render() { |
| 121 | var _a, _b, _c, _d, _e; |
| 122 | return (h("div", { key: 'e7f00d49d60d1c29eb543bf78c64bf4178b0a647', class: "sc-address", part: "base" }, h("sc-form-control", { key: '8cfff22f71d6ea46a499688dea9629a6ec43e56b', exportparts: "label, help-text, form-control", label: this.label, class: "sc-address__control", part: "control", required: this.required }, h("sc-select", { key: 'e7b7f305c33a127a9a1a3467f5a4964b1ce65e94', exportparts: "base:select__base, input, form-control, label, help-text, trigger, panel, caret, search__base, search__input, search__form-control, menu__base, spinner__base, empty", value: (_a = this.address) === null || _a === void 0 ? void 0 : _a.country, onScChange: (e) => { |
| 123 | this.clearAddress(); |
| 124 | this.updateAddress({ country: e.target.value || null }); |
| 125 | }, choices: this.countryChoices, autocomplete: 'country-name', placeholder: ((_b = this.placeholders) === null || _b === void 0 ? void 0 : _b.country) || wp.i18n.__('Select Your Country', 'surecart'), name: this.names.country, search: true, unselect: false, "squared-bottom": this.showState || this.showPostal, required: this.required }), h("div", { key: '8061be1b3d1abe0d1b267548fb245101c065c077', class: "sc-address__columns" }, this.showState && (h("sc-select", { key: '51b79b3a0a6ae522504291346fd253538d30a661', exportparts: "base:select__base, input, form-control, label, help-text, trigger, panel, caret, search__base, search__input, search__form-control, menu__base, spinner__base, empty", placeholder: this.getStatePlaceholder(), name: this.names.state, autocomplete: 'address-level1', value: (_c = this === null || this === void 0 ? void 0 : this.address) === null || _c === void 0 ? void 0 : _c.state, onScChange: (e) => this.updateAddress({ state: e.target.value || null }), choices: this.regions, required: this.required, search: true, "squared-top": true, unselect: false, "squared-right": this.showPostal })), this.showPostal && (h("sc-input", { key: 'e609a33490f65b83069c8cdfb61dd9e7a444be5e', exportparts: "base:input__base, input, form-control, label, help-text", placeholder: ((_d = this.placeholders) === null || _d === void 0 ? void 0 : _d.postal_code) || wp.i18n.__('Postal Code/Zip', 'surecart'), name: this.names.postal_code, onScChange: (e) => this.updateAddress({ postal_code: e.target.value || null }), onScInput: (e) => this.handleAddressInput({ name: e.target.value || null }), autocomplete: 'postal-code', required: this.required, value: (_e = this === null || this === void 0 ? void 0 : this.address) === null || _e === void 0 ? void 0 : _e.postal_code, "squared-top": true, maxlength: 5, "squared-left": this.showState })))), this.loading && h("sc-block-ui", { key: 'edce579e6866af546d1d4b0e17a983f6312e69a5', exportparts: "base:block-ui, content:block-ui__content" }))); |
| 126 | } |
| 127 | get el() { return getElement(this); } |
| 128 | static get watchers() { return { |
| 129 | "address": ["handleAddressChange"] |
| 130 | }; } |
| 131 | }; |
| 132 | ScCompactAddress.style = ScCompactAddressStyle0; |
| 133 | |
| 134 | const scLineItemShippingCss = ":host{display:block}"; |
| 135 | const ScLineItemShippingStyle0 = scLineItemShippingCss; |
| 136 | |
| 137 | const ScLineItemShipping = class { |
| 138 | constructor(hostRef) { |
| 139 | registerInstance(this, hostRef); |
| 140 | this.label = undefined; |
| 141 | } |
| 142 | render() { |
| 143 | const { checkout } = state$1; |
| 144 | // don't show if no shipping amount if no choice selected |
| 145 | if (!(checkout === null || checkout === void 0 ? void 0 : checkout.selected_shipping_choice)) { |
| 146 | return h(Host, { style: { display: 'none' } }); |
| 147 | } |
| 148 | if (state.formState.value === 'loading') { |
| 149 | return (h("sc-line-item", null, h("sc-skeleton", { slot: "title", style: { width: '120px', display: 'inline-block' } }), h("sc-skeleton", { slot: "price", style: { 'width': '70px', 'display': 'inline-block', '--border-radius': '6px' } }))); |
| 150 | } |
| 151 | return (h("sc-line-item", null, h("span", { slot: "description" }, this.label || wp.i18n.__('Shipping', 'surecart')), h("span", { slot: "price" }, (checkout === null || checkout === void 0 ? void 0 : checkout.shipping_amount) ? (h("sc-format-number", { type: "currency", currency: checkout === null || checkout === void 0 ? void 0 : checkout.currency, value: checkout === null || checkout === void 0 ? void 0 : checkout.shipping_amount })) : (wp.i18n.__('Free', 'surecart'))))); |
| 152 | } |
| 153 | }; |
| 154 | ScLineItemShipping.style = ScLineItemShippingStyle0; |
| 155 | |
| 156 | const scLineItemTaxCss = ":host{display:block}"; |
| 157 | const ScLineItemTaxStyle0 = scLineItemTaxCss; |
| 158 | |
| 159 | const ScLineItemTax = class { |
| 160 | constructor(hostRef) { |
| 161 | registerInstance(this, hostRef); |
| 162 | this.order = undefined; |
| 163 | this.loading = undefined; |
| 164 | } |
| 165 | renderLabel() { |
| 166 | var _a, _b, _c; |
| 167 | let label = wp.i18n.sprintf(wp.i18n.__('Estimated %s', 'surecart'), ((_a = this === null || this === void 0 ? void 0 : this.order) === null || _a === void 0 ? void 0 : _a.tax_label) || ''); |
| 168 | if (((_b = this === null || this === void 0 ? void 0 : this.order) === null || _b === void 0 ? void 0 : _b.tax_status) === 'calculated') { |
| 169 | label = ((_c = this.order) === null || _c === void 0 ? void 0 : _c.tax_label) || ''; |
| 170 | } |
| 171 | return (h(Fragment, null, `${wp.i18n.__('Tax:', 'surecart')} ${label}`, this.renderPercent())); |
| 172 | } |
| 173 | renderPercent() { |
| 174 | var _a; |
| 175 | if ((_a = this.order) === null || _a === void 0 ? void 0 : _a.tax_percent) { |
| 176 | return (h(Fragment, null, '(', this.order.tax_percent, "%", ')')); |
| 177 | } |
| 178 | return ''; |
| 179 | } |
| 180 | render() { |
| 181 | var _a, _b, _c, _d, _e, _f, _g; |
| 182 | // hide if tax is 0 |
| 183 | if (!((_a = this === null || this === void 0 ? void 0 : this.order) === null || _a === void 0 ? void 0 : _a.tax_amount)) { |
| 184 | return null; |
| 185 | } |
| 186 | return (h("sc-line-item", null, h("span", { slot: "description" }, this.renderLabel()), ((_b = this.order) === null || _b === void 0 ? void 0 : _b.tax_exclusive_amount) && (h("span", { slot: "price" }, h("sc-format-number", { type: "currency", currency: ((_c = this === null || this === void 0 ? void 0 : this.order) === null || _c === void 0 ? void 0 : _c.currency) || 'usd', value: (_d = this === null || this === void 0 ? void 0 : this.order) === null || _d === void 0 ? void 0 : _d.tax_exclusive_amount }))), ((_e = this.order) === null || _e === void 0 ? void 0 : _e.tax_inclusive_amount) && (h("span", { slot: "price-description" }, '(', h("sc-format-number", { type: "currency", currency: ((_f = this === null || this === void 0 ? void 0 : this.order) === null || _f === void 0 ? void 0 : _f.currency) || 'usd', value: (_g = this === null || this === void 0 ? void 0 : this.order) === null || _g === void 0 ? void 0 : _g.tax_inclusive_amount }), " ", wp.i18n.__('included', 'surecart'), ')')))); |
| 187 | } |
| 188 | }; |
| 189 | openWormhole(ScLineItemTax, ['order', 'loading'], false); |
| 190 | ScLineItemTax.style = ScLineItemTaxStyle0; |
| 191 | |
| 192 | const scOrderBillingAddressCss = ":host{display:block}.order-billing-address__toggle{margin-bottom:var(--sc-form-row-spacing, var(--sc-spacing-medium))}"; |
| 193 | const ScOrderBillingAddressStyle0 = scOrderBillingAddressCss; |
| 194 | |
| 195 | const ScOrderBillingAddress = class { |
| 196 | constructor(hostRef) { |
| 197 | registerInstance(this, hostRef); |
| 198 | this.label = undefined; |
| 199 | this.showName = undefined; |
| 200 | this.namePlaceholder = wp.i18n.__('Name or Company Name', 'surecart'); |
| 201 | this.countryPlaceholder = wp.i18n.__('Country', 'surecart'); |
| 202 | this.cityPlaceholder = wp.i18n.__('City', 'surecart'); |
| 203 | this.line1Placeholder = wp.i18n.__('Address', 'surecart'); |
| 204 | this.line2Placeholder = wp.i18n.__('Address Line 2', 'surecart'); |
| 205 | this.postalCodePlaceholder = wp.i18n.__('Postal Code/Zip', 'surecart'); |
| 206 | this.statePlaceholder = wp.i18n.__('State/Province/Region', 'surecart'); |
| 207 | this.defaultCountry = undefined; |
| 208 | this.toggleLabel = wp.i18n.__('Billing address is same as shipping', 'surecart'); |
| 209 | this.address = { |
| 210 | country: null, |
| 211 | city: null, |
| 212 | line_1: null, |
| 213 | line_2: null, |
| 214 | postal_code: null, |
| 215 | state: null, |
| 216 | }; |
| 217 | } |
| 218 | async reportValidity() { |
| 219 | var _a, _b; |
| 220 | if (!this.input) |
| 221 | return true; |
| 222 | return (_b = (_a = this.input) === null || _a === void 0 ? void 0 : _a.reportValidity) === null || _b === void 0 ? void 0 : _b.call(_a); |
| 223 | } |
| 224 | prefillAddress() { |
| 225 | var _a; |
| 226 | // check if address keys are empty, if so, update them. |
| 227 | const addressKeys = Object.keys(this.address).filter(key => key !== 'country'); |
| 228 | const emptyAddressKeys = addressKeys.filter(key => !this.address[key]); |
| 229 | if (emptyAddressKeys.length === addressKeys.length) { |
| 230 | this.address = { ...this.address, ...(_a = state$1.checkout) === null || _a === void 0 ? void 0 : _a.billing_address }; |
| 231 | } |
| 232 | } |
| 233 | componentWillLoad() { |
| 234 | if (this.defaultCountry && !this.address.country) { |
| 235 | this.address.country = this.defaultCountry; |
| 236 | } |
| 237 | this.prefillAddress(); |
| 238 | onChange('checkout', () => this.prefillAddress()); |
| 239 | } |
| 240 | async updateAddressState(address) { |
| 241 | var _a, _b; |
| 242 | if (JSON.stringify(address) === JSON.stringify(this.address)) |
| 243 | return; // no change, don't update. |
| 244 | this.address = address; |
| 245 | try { |
| 246 | lockCheckout('billing-address'); |
| 247 | state$1.checkout = (await createOrUpdateCheckout({ |
| 248 | id: (_a = state$1 === null || state$1 === void 0 ? void 0 : state$1.checkout) === null || _a === void 0 ? void 0 : _a.id, |
| 249 | data: { |
| 250 | billing_matches_shipping: (_b = state$1.checkout) === null || _b === void 0 ? void 0 : _b.billing_matches_shipping, |
| 251 | billing_address: this.address, |
| 252 | }, |
| 253 | })); |
| 254 | } |
| 255 | catch (e) { |
| 256 | console.error(e); |
| 257 | } |
| 258 | finally { |
| 259 | unLockCheckout('billing-address'); |
| 260 | } |
| 261 | } |
| 262 | async onToggleBillingMatchesShipping(e) { |
| 263 | state$1.checkout = { |
| 264 | ...state$1.checkout, |
| 265 | billing_matches_shipping: e.target.checked, |
| 266 | }; |
| 267 | } |
| 268 | shippingAddressFieldExists() { |
| 269 | return !!document.querySelector('sc-order-shipping-address'); |
| 270 | } |
| 271 | render() { |
| 272 | var _a, _b; |
| 273 | return (h(Fragment, { key: '0ffc2da9c32911a072c8dc9b9062b733255c8871' }, this.shippingAddressFieldExists() && (h("sc-checkbox", { key: '5f312a5c09d9af1ce9e86548f8b2492958e954c3', class: "order-billing-address__toggle", onScChange: e => this.onToggleBillingMatchesShipping(e), checked: (_a = state$1.checkout) === null || _a === void 0 ? void 0 : _a.billing_matches_shipping }, this.toggleLabel)), (!this.shippingAddressFieldExists() || !((_b = state$1.checkout) === null || _b === void 0 ? void 0 : _b.billing_matches_shipping)) && (h("sc-address", { key: '84d0fe61e3e94bb58485b1e0f9552065f3c91e7b', exportparts: "label, help-text, form-control, input__base, select__base, columns, search__base, menu__base", ref: el => { |
| 274 | this.input = el; |
| 275 | }, label: this.label || wp.i18n.__('Billing Address', 'surecart'), placeholders: { |
| 276 | name: this.namePlaceholder, |
| 277 | country: this.countryPlaceholder, |
| 278 | city: this.cityPlaceholder, |
| 279 | line_1: this.line1Placeholder, |
| 280 | line_2: this.line2Placeholder, |
| 281 | postal_code: this.postalCodePlaceholder, |
| 282 | state: this.statePlaceholder, |
| 283 | }, names: { |
| 284 | name: 'billing_name', |
| 285 | country: 'billing_country', |
| 286 | city: 'billing_city', |
| 287 | line_1: 'billing_line_1', |
| 288 | line_2: 'billing_line_2', |
| 289 | postal_code: 'billing_postal_code', |
| 290 | state: 'billing_state', |
| 291 | }, required: true, loading: formLoading(), address: this.address, "show-name": this.showName, onScChangeAddress: e => this.updateAddressState(e.detail) })))); |
| 292 | } |
| 293 | }; |
| 294 | ScOrderBillingAddress.style = ScOrderBillingAddressStyle0; |
| 295 | |
| 296 | const scOrderBumpCss = ":host {\n display: block;\n}\n\n.bump {\n display: grid;\n gap: 1em;\n}\n.bump__text {\n display: grid;\n gap: 0.25em;\n}\n.bump__tag {\n background: var(--sc-color-primary-500);\n color: var(--sc-color-white);\n border-radius: var(--sc-input-border-radius-medium);\n padding: var(--sc-spacing-x-small);\n font-size: var(--sc-font-size-x-small);\n}\n.bump__product {\n display: flex;\n align-items: center;\n gap: var(--sc-choice-padding, 1.3em 1.1em);\n line-height: var(--sc-line-height-dense);\n}\n.bump__product--wrapper {\n container-type: inline-size;\n}\n@container (max-width: 325px) {\n .bump__product {\n flex-direction: column;\n align-items: start;\n }\n}\n.bump__product-title {\n font-weight: var(--sc-font-weight-semibold);\n}\n.bump__product-description {\n color: var(--sc-input-label-color);\n}\n.bump__image {\n width: var(--sc-product-line-item-image-size, 4em);\n height: var(--sc-product-line-item-image-size, 4em);\n flex: 0 0 var(--sc-product-line-item-image-size, 4em);\n object-fit: cover;\n border-radius: 4px;\n border: 1px solid var(--sc-color-gray-200);\n display: block;\n box-shadow: var(--sc-input-box-shadow);\n}\n.bump__price--has-discount .bump__original-price {\n text-decoration: line-through;\n color: var(--sc-color-gray-500);\n font-size: var(--sc-font-size-small);\n}\n.bump__price .bump__new-price {\n font-size: var(--sc-font-size-large);\n color: var(--sc-color-gray-700);\n}\n.bump__price .bump__interval {\n color: var(--sc-color-gray-500);\n}\n.bump__amount {\n display: flex;\n align-items: center;\n gap: var(--sc-spacing-x-small);\n flex-wrap: wrap;\n margin-top: var(--sc-spacing-xx-small);\n}"; |
| 297 | const ScOrderBumpStyle0 = scOrderBumpCss; |
| 298 | |
| 299 | const ScOrderBump = class { |
| 300 | constructor(hostRef) { |
| 301 | registerInstance(this, hostRef); |
| 302 | this.scAddLineItem = createEvent(this, "scAddLineItem", 7); |
| 303 | this.scRemoveLineItem = createEvent(this, "scRemoveLineItem", 7); |
| 304 | var _a; |
| 305 | this.bump = undefined; |
| 306 | this.showControl = undefined; |
| 307 | this.cdnRoot = (_a = window.scData) === null || _a === void 0 ? void 0 : _a.cdn_root; |
| 308 | } |
| 309 | /** Update the line item. */ |
| 310 | updateLineItem(add) { |
| 311 | var _a, _b, _c; |
| 312 | const price_id = ((_a = this.bump.price) === null || _a === void 0 ? void 0 : _a.id) || ((_b = this.bump) === null || _b === void 0 ? void 0 : _b.price); |
| 313 | if (add) { |
| 314 | this.scAddLineItem.emit({ |
| 315 | bump: (_c = this.bump) === null || _c === void 0 ? void 0 : _c.id, |
| 316 | price_id, |
| 317 | quantity: 1, |
| 318 | }); |
| 319 | speak(wp.i18n.__('Order bump applied.', 'surecart')); |
| 320 | } |
| 321 | else { |
| 322 | this.scRemoveLineItem.emit({ |
| 323 | price_id, |
| 324 | quantity: 1, |
| 325 | }); |
| 326 | speak(wp.i18n.__('Order bump Removed.', 'surecart')); |
| 327 | } |
| 328 | } |
| 329 | newPrice() { |
| 330 | var _a, _b, _c, _d, _e, _f; |
| 331 | let amount = null; |
| 332 | let initialAmount = ((_b = (_a = this.bump) === null || _a === void 0 ? void 0 : _a.price) === null || _b === void 0 ? void 0 : _b.amount) || 0; |
| 333 | if ((_c = this.bump) === null || _c === void 0 ? void 0 : _c.amount_off) { |
| 334 | amount = Math.max(0, initialAmount - ((_d = this.bump) === null || _d === void 0 ? void 0 : _d.amount_off)); |
| 335 | } |
| 336 | if ((_e = this.bump) === null || _e === void 0 ? void 0 : _e.percent_off) { |
| 337 | const off = initialAmount * (((_f = this.bump) === null || _f === void 0 ? void 0 : _f.percent_off) / 100); |
| 338 | amount = Math.max(0, initialAmount - off); |
| 339 | } |
| 340 | return amount; |
| 341 | } |
| 342 | renderInterval() { |
| 343 | var _a; |
| 344 | const interval = intervalString((_a = this.bump) === null || _a === void 0 ? void 0 : _a.price, { labels: { interval: '/', period: wp.i18n.__('for', 'surecart') } }); |
| 345 | if (!interval.trim().length) |
| 346 | return null; |
| 347 | return h("span", { class: "bump__interval" }, interval); |
| 348 | } |
| 349 | renderPrice() { |
| 350 | var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; |
| 351 | return (h("div", { slot: "description", class: { 'bump__price': true, 'bump__price--has-discount': !!((_a = this.bump) === null || _a === void 0 ? void 0 : _a.percent_off) || !!((_b = this.bump) === null || _b === void 0 ? void 0 : _b.amount_off) }, part: "price" }, h("span", { "aria-label": |
| 352 | /** translators: %s: old price */ |
| 353 | wp.i18n.sprintf(wp.i18n.__('Originally priced at %s.', 'surecart'), getFormattedPrice({ |
| 354 | amount: (_d = (_c = this.bump) === null || _c === void 0 ? void 0 : _c.price) === null || _d === void 0 ? void 0 : _d.amount, |
| 355 | currency: (_f = (_e = this.bump) === null || _e === void 0 ? void 0 : _e.price) === null || _f === void 0 ? void 0 : _f.currency, |
| 356 | })) }, h("sc-format-number", { type: "currency", class: "bump__original-price", value: (_h = (_g = this.bump) === null || _g === void 0 ? void 0 : _g.price) === null || _h === void 0 ? void 0 : _h.amount, currency: (_k = (_j = this.bump) === null || _j === void 0 ? void 0 : _j.price) === null || _k === void 0 ? void 0 : _k.currency }), ' '), h("span", null, h("span", { "aria-hidden": "true" }, this.newPrice() === 0 && wp.i18n.__('Free', 'surecart'), this.newPrice() !== null && this.newPrice() > 0 && (h("sc-format-number", { type: "currency", class: "bump__new-price", value: this.newPrice(), currency: ((_l = this.bump) === null || _l === void 0 ? void 0 : _l.price).currency })), this.renderInterval())))); |
| 357 | } |
| 358 | renderDiscount() { |
| 359 | var _a, _b, _c, _d, _e, _f, _g, _h; |
| 360 | if (!!((_a = this.bump) === null || _a === void 0 ? void 0 : _a.amount_off)) { |
| 361 | return (h("div", { class: "bump__tag", "aria-label": |
| 362 | /** translators: %1$s: amount off, %2$s: currency */ |
| 363 | wp.i18n.sprintf(wp.i18n.__('You save %1$s%2$s.', 'surecart'), (_b = this.bump) === null || _b === void 0 ? void 0 : _b.amount_off, ((_c = this.bump) === null || _c === void 0 ? void 0 : _c.price).currency) }, h("span", { "aria-hidden": "true" }, wp.i18n.__('Save', 'surecart'), " ", h("sc-format-number", { type: "currency", value: -((_d = this.bump) === null || _d === void 0 ? void 0 : _d.amount_off), currency: ((_e = this.bump) === null || _e === void 0 ? void 0 : _e.price).currency })))); |
| 364 | } |
| 365 | if (!!((_f = this.bump) === null || _f === void 0 ? void 0 : _f.percent_off)) { |
| 366 | return (h("div", { class: "bump__tag", "aria-label": |
| 367 | /** translators: %s: amount percent off */ |
| 368 | wp.i18n.sprintf(wp.i18n.__('You save %s%%.', 'surecart'), (_g = this.bump) === null || _g === void 0 ? void 0 : _g.percent_off) }, h("span", { "aria-hidden": "true" }, wp.i18n.sprintf(wp.i18n.__('Save %s%%', 'surecart'), (_h = this.bump) === null || _h === void 0 ? void 0 : _h.percent_off)))); |
| 369 | } |
| 370 | } |
| 371 | render() { |
| 372 | var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v; |
| 373 | const product = (_b = (_a = this.bump) === null || _a === void 0 ? void 0 : _a.price) === null || _b === void 0 ? void 0 : _b.product; |
| 374 | return (h("sc-choice", { key: '7f3c16c5b13d45e7bdb2a4a1dab35cce9d8db725', value: (_c = this.bump) === null || _c === void 0 ? void 0 : _c.id, type: "checkbox", showControl: this.showControl, checked: isBumpInOrder(this.bump, state$1 === null || state$1 === void 0 ? void 0 : state$1.checkout), onScChange: e => this.updateLineItem(e.target.checked), onKeyDown: e => { |
| 375 | if (e.key === 'Enter' || e.key === ' ') { |
| 376 | e.preventDefault(); |
| 377 | e.stopImmediatePropagation(); |
| 378 | this.updateLineItem(!isBumpInOrder(this.bump, state$1 === null || state$1 === void 0 ? void 0 : state$1.checkout)); |
| 379 | } |
| 380 | }, exportparts: "base, control, checked-icon, title" }, h("div", { key: 'bc2022aaabfc38a9adbea77938df5c521f34f216', part: "base-content", class: "bump" }, h("div", { key: 'a08b4bb806b82ed50f8e6415e41aaf52ed460102', class: "bump__text" }, h("div", { key: '67e93d797f2d572a4b4ac6e60319315bcaf42e58', class: "bump__title", "aria-label": wp.i18n.sprintf( |
| 381 | /* translators: %s: order bump name */ |
| 382 | wp.i18n.__('Product: %s.', 'surecart'), ((_e = (_d = this.bump) === null || _d === void 0 ? void 0 : _d.metadata) === null || _e === void 0 ? void 0 : _e.cta) || ((_f = this.bump) === null || _f === void 0 ? void 0 : _f.name) || (product === null || product === void 0 ? void 0 : product.name)) }, h("span", { key: '2424d99adfee3940e47fc843251391ae1c98fdd3', "aria-hidden": "true" }, ((_h = (_g = this.bump) === null || _g === void 0 ? void 0 : _g.metadata) === null || _h === void 0 ? void 0 : _h.cta) || ((_j = this.bump) === null || _j === void 0 ? void 0 : _j.name) || (product === null || product === void 0 ? void 0 : product.name))), h("div", { key: '3ce230317000dcfb1c712f06065937fff78c8d73', class: "bump__amount" }, h("span", { key: '12f82035ff518babb548e5a3c3421c1d7dd95006' }, this.renderPrice()), h("span", { key: '6f1592c9deb75786bc258fbe141f0484fe4cea69' }, this.renderDiscount())))), ((_l = (_k = this.bump) === null || _k === void 0 ? void 0 : _k.metadata) === null || _l === void 0 ? void 0 : _l.description) && (h("div", { key: 'b0a4f75dd180189ba86dc41673507edf77c459ab', slot: "footer", class: "bump__product--wrapper" }, h("sc-divider", { key: '8992ec8ffa3d7f5f15c77095681b4277826b848b', style: { '--spacing': 'var(--sc-spacing-medium)' } }), h("div", { key: '1f2dab4d72477eaee280232a7dbcf345beeee415', class: "bump__product" }, !!((_m = product === null || product === void 0 ? void 0 : product.line_item_image) === null || _m === void 0 ? void 0 : _m.src) && h("img", { key: '1cefdcc6f9f0b880825979d9ebd8055cfe6517d2', ...product === null || product === void 0 ? void 0 : product.line_item_image, class: "bump__image" }), h("div", { key: '824b1319111ee854a7326bb1b1dd3c083ead8ac1', class: "bump__product-text" }, !!((_p = (_o = this.bump) === null || _o === void 0 ? void 0 : _o.metadata) === null || _p === void 0 ? void 0 : _p.cta) && (h("div", { key: 'a070ad70749c91e4dd83a7936c8e418f9df77304', class: "bump__product-title", "aria-hidden": "true" }, this.bump.name || (product === null || product === void 0 ? void 0 : product.name))), !!((_r = (_q = this.bump) === null || _q === void 0 ? void 0 : _q.metadata) === null || _r === void 0 ? void 0 : _r.description) && (h("div", { key: 'e215a50827d0aa6681fb922fab0838f87f0292d4', class: "bump__product-description", "aria-label": wp.i18n.sprintf( |
| 383 | /* translators: %s: Product description */ |
| 384 | wp.i18n.__('Product description: %s.', 'surecart'), (_t = (_s = this.bump) === null || _s === void 0 ? void 0 : _s.metadata) === null || _t === void 0 ? void 0 : _t.description) }, h("span", { key: 'e28fbabb6fc265356ee1be31efeaede9921a638e', "aria-hidden": "true" }, (_v = (_u = this.bump) === null || _u === void 0 ? void 0 : _u.metadata) === null || _v === void 0 ? void 0 : _v.description))))))))); |
| 385 | } |
| 386 | }; |
| 387 | ScOrderBump.style = ScOrderBumpStyle0; |
| 388 | |
| 389 | const scOrderBumpsCss = ":host{display:block}.bumps__list{display:grid;gap:10px}"; |
| 390 | const ScOrderBumpsStyle0 = scOrderBumpsCss; |
| 391 | |
| 392 | const ScOrderBumps = class { |
| 393 | constructor(hostRef) { |
| 394 | registerInstance(this, hostRef); |
| 395 | this.label = undefined; |
| 396 | this.showControl = undefined; |
| 397 | this.help = undefined; |
| 398 | } |
| 399 | render() { |
| 400 | var _a, _b; |
| 401 | const bumps = (((_b = (_a = state$1 === null || state$1 === void 0 ? void 0 : state$1.checkout) === null || _a === void 0 ? void 0 : _a.recommended_bumps) === null || _b === void 0 ? void 0 : _b.data) || []).filter(bump => { var _a, _b, _c, _d; return ((_d = (_c = (_b = (_a = bump === null || bump === void 0 ? void 0 : bump.price) === null || _a === void 0 ? void 0 : _a.product) === null || _b === void 0 ? void 0 : _b.variants) === null || _c === void 0 ? void 0 : _c.pagination) === null || _d === void 0 ? void 0 : _d.count) === 0; }); // exclude variants for now.; |
| 402 | if (!(bumps === null || bumps === void 0 ? void 0 : bumps.length)) { |
| 403 | return null; |
| 404 | } |
| 405 | return (h("sc-form-control", { label: this.label || wp.i18n.__('Recommended', 'surecart'), help: this.help }, h("div", { class: "bumps__list", "aria-label": wp.i18n.__('Order bump summary', 'surecart') }, bumps.map(bump => (h("sc-order-bump", { key: bump === null || bump === void 0 ? void 0 : bump.id, showControl: this.showControl, bump: bump })))))); |
| 406 | } |
| 407 | }; |
| 408 | ScOrderBumps.style = ScOrderBumpsStyle0; |
| 409 | |
| 410 | const scOrderShippingAddressCss = ":host{display:block}.sc-order-shipping__loading{display:flex;flex-direction:column;gap:0.5em}"; |
| 411 | const ScOrderShippingAddressStyle0 = scOrderShippingAddressCss; |
| 412 | |
| 413 | const ScOrderShippingAddress = class { |
| 414 | constructor(hostRef) { |
| 415 | registerInstance(this, hostRef); |
| 416 | /** Names for the address */ |
| 417 | this.names = { |
| 418 | name: 'shipping_name', |
| 419 | country: 'shipping_country', |
| 420 | city: 'shipping_city', |
| 421 | line_1: 'shipping_line_1', |
| 422 | line_2: 'shipping_line_2', |
| 423 | postal_code: 'shipping_postal_code', |
| 424 | state: 'shipping_state', |
| 425 | }; |
| 426 | this.label = undefined; |
| 427 | this.required = false; |
| 428 | this.full = undefined; |
| 429 | this.showName = undefined; |
| 430 | this.namePlaceholder = wp.i18n.__('Name or Company Name', 'surecart'); |
| 431 | this.countryPlaceholder = wp.i18n.__('Country', 'surecart'); |
| 432 | this.cityPlaceholder = wp.i18n.__('City', 'surecart'); |
| 433 | this.line1Placeholder = wp.i18n.__('Address', 'surecart'); |
| 434 | this.line2Placeholder = wp.i18n.__('Address Line 2', 'surecart'); |
| 435 | this.postalCodePlaceholder = wp.i18n.__('Postal Code/Zip', 'surecart'); |
| 436 | this.statePlaceholder = wp.i18n.__('State/Province/Region', 'surecart'); |
| 437 | this.defaultCountry = undefined; |
| 438 | this.requireName = false; |
| 439 | this.placeholders = { |
| 440 | name: wp.i18n.__('Name or Company Name', 'surecart'), |
| 441 | country: wp.i18n.__('Country', 'surecart'), |
| 442 | city: wp.i18n.__('City', 'surecart'), |
| 443 | line_1: wp.i18n.__('Address', 'surecart'), |
| 444 | line_2: wp.i18n.__('Address Line 2', 'surecart'), |
| 445 | postal_code: wp.i18n.__('Postal Code/Zip', 'surecart'), |
| 446 | state: wp.i18n.__('State/Province/Region', 'surecart'), |
| 447 | }; |
| 448 | this.address = { |
| 449 | country: null, |
| 450 | city: null, |
| 451 | line_1: null, |
| 452 | line_2: null, |
| 453 | postal_code: null, |
| 454 | state: null, |
| 455 | }; |
| 456 | } |
| 457 | async updateAddressState(address) { |
| 458 | var _a; |
| 459 | if (JSON.stringify(address) === JSON.stringify(this.address)) |
| 460 | return; // no change, don't update. |
| 461 | this.address = address; |
| 462 | try { |
| 463 | lockCheckout('shipping-address'); |
| 464 | state$1.checkout = (await createOrUpdateCheckout({ |
| 465 | id: (_a = state$1.checkout) === null || _a === void 0 ? void 0 : _a.id, |
| 466 | data: { |
| 467 | shipping_address: this.address, |
| 468 | }, |
| 469 | })); |
| 470 | } |
| 471 | catch (e) { |
| 472 | console.error(e); |
| 473 | } |
| 474 | finally { |
| 475 | unLockCheckout('shipping-address'); |
| 476 | } |
| 477 | } |
| 478 | async reportValidity() { |
| 479 | var _a, _b; |
| 480 | return (_b = (_a = this.input) === null || _a === void 0 ? void 0 : _a.reportValidity) === null || _b === void 0 ? void 0 : _b.call(_a); |
| 481 | } |
| 482 | prefillAddress() { |
| 483 | var _a; |
| 484 | // check if address keys are empty, if so, update them. |
| 485 | const addressKeys = Object.keys(this.address).filter(key => key !== 'country'); |
| 486 | const emptyAddressKeys = addressKeys.filter(key => !this.address[key]); |
| 487 | if (emptyAddressKeys.length === addressKeys.length) { |
| 488 | this.address = { ...this.address, ...(_a = state$1.checkout) === null || _a === void 0 ? void 0 : _a.shipping_address }; |
| 489 | } |
| 490 | } |
| 491 | componentWillLoad() { |
| 492 | if (this.defaultCountry && !this.address.country) { |
| 493 | this.address.country = this.defaultCountry; |
| 494 | } |
| 495 | this.prefillAddress(); |
| 496 | onChange('checkout', () => this.prefillAddress()); |
| 497 | } |
| 498 | render() { |
| 499 | // use full if checkout requires it, it's set, or we're showing/requiring name field. |
| 500 | if (fullShippingAddressRequired() || this.full || this.requireName || this.showName) { |
| 501 | return (h("sc-address", { exportparts: "label, help-text, form-control, input__base, select__base, columns, search__base, menu__base", ref: el => (this.input = el), label: this.label || wp.i18n.__('Shipping Address', 'surecart'), placeholders: { |
| 502 | name: this.namePlaceholder, |
| 503 | country: this.countryPlaceholder, |
| 504 | city: this.cityPlaceholder, |
| 505 | line_1: this.line1Placeholder, |
| 506 | line_2: this.line2Placeholder, |
| 507 | postal_code: this.postalCodePlaceholder, |
| 508 | state: this.statePlaceholder, |
| 509 | }, names: this.names, required: this.required || shippingAddressRequired(), loading: formLoading(), address: this.address, "show-name": this.showName, "require-name": this.requireName, onScChangeAddress: e => this.updateAddressState(e.detail) })); |
| 510 | } |
| 511 | return (h("sc-compact-address", { ref: el => (this.input = el), required: this.required || shippingAddressRequired(), loading: formLoading(), address: this.address, placeholders: { |
| 512 | name: this.namePlaceholder, |
| 513 | country: this.countryPlaceholder, |
| 514 | city: this.cityPlaceholder, |
| 515 | line_1: this.line1Placeholder, |
| 516 | line_2: this.line2Placeholder, |
| 517 | postal_code: this.postalCodePlaceholder, |
| 518 | state: this.statePlaceholder, |
| 519 | }, names: this.names, label: this.label, onScChangeAddress: e => this.updateAddressState(e.detail) })); |
| 520 | } |
| 521 | }; |
| 522 | ScOrderShippingAddress.style = ScOrderShippingAddressStyle0; |
| 523 | |
| 524 | const scOrderTaxIdInputCss = ":host{display:block}"; |
| 525 | const ScOrderTaxIdInputStyle0 = scOrderTaxIdInputCss; |
| 526 | |
| 527 | const ScOrderTaxIdInput = class { |
| 528 | constructor(hostRef) { |
| 529 | registerInstance(this, hostRef); |
| 530 | this.show = false; |
| 531 | this.otherLabel = undefined; |
| 532 | this.caGstLabel = undefined; |
| 533 | this.auAbnLabel = undefined; |
| 534 | this.gbVatLabel = undefined; |
| 535 | this.euVatLabel = undefined; |
| 536 | this.helpText = undefined; |
| 537 | this.taxIdTypes = undefined; |
| 538 | this.taxIdTypesData = []; |
| 539 | } |
| 540 | handleTaxIdTypesChange() { |
| 541 | this.taxIdTypesData = typeof this.taxIdTypes === 'string' ? JSON.parse(this.taxIdTypes) : this.taxIdTypes; |
| 542 | } |
| 543 | async reportValidity() { |
| 544 | return this.input.reportValidity(); |
| 545 | } |
| 546 | getStatus() { |
| 547 | var _a, _b, _c, _d, _e; |
| 548 | if (((_b = (_a = state$1.checkout) === null || _a === void 0 ? void 0 : _a.tax_identifier) === null || _b === void 0 ? void 0 : _b.number_type) !== 'eu_vat') { |
| 549 | return 'unknown'; |
| 550 | } |
| 551 | if (((_c = state$1.taxProtocol) === null || _c === void 0 ? void 0 : _c.eu_vat_unverified_behavior) === 'apply_reverse_charge') { |
| 552 | return 'unknown'; |
| 553 | } |
| 554 | return ((_e = (_d = state$1.checkout) === null || _d === void 0 ? void 0 : _d.tax_identifier) === null || _e === void 0 ? void 0 : _e.eu_vat_verified) ? 'valid' : 'invalid'; |
| 555 | } |
| 556 | async updateOrder(tax_identifier) { |
| 557 | try { |
| 558 | updateFormState('FETCH'); |
| 559 | state$1.checkout = (await createOrUpdateCheckout({ |
| 560 | id: state$1.checkout.id, |
| 561 | data: { tax_identifier }, |
| 562 | })); |
| 563 | updateFormState('RESOLVE'); |
| 564 | } |
| 565 | catch (e) { |
| 566 | console.error(e); |
| 567 | createErrorNotice(e); |
| 568 | updateFormState('REJECT'); |
| 569 | } |
| 570 | } |
| 571 | componentWillLoad() { |
| 572 | this.handleTaxIdTypesChange(); |
| 573 | } |
| 574 | required() { |
| 575 | var _a, _b, _c; |
| 576 | return ((_a = state$1.taxProtocol) === null || _a === void 0 ? void 0 : _a.eu_vat_required) && ((_c = (_b = state$1.checkout) === null || _b === void 0 ? void 0 : _b.tax_identifier) === null || _c === void 0 ? void 0 : _c.number_type) === 'eu_vat'; |
| 577 | } |
| 578 | render() { |
| 579 | var _a, _b, _c, _d, _e, _f, _g; |
| 580 | return (h("sc-tax-id-input", { key: '6db1e819aab495b21b0e7d7e4b7840cd433abf84', ref: el => (this.input = el), show: this.show, number: (_b = (_a = state$1.checkout) === null || _a === void 0 ? void 0 : _a.tax_identifier) === null || _b === void 0 ? void 0 : _b.number, type: ((_d = (_c = state$1.checkout) === null || _c === void 0 ? void 0 : _c.tax_identifier) === null || _d === void 0 ? void 0 : _d.number_type) || ((_e = this.taxIdTypesData) === null || _e === void 0 ? void 0 : _e[0]) || 'eu_vat', country: (_g = (_f = state$1.checkout) === null || _f === void 0 ? void 0 : _f.shipping_address) === null || _g === void 0 ? void 0 : _g.country, status: this.getStatus(), loading: formBusy(), onScChange: e => { |
| 581 | e.stopImmediatePropagation(); |
| 582 | this.updateOrder(e.detail); |
| 583 | }, otherLabel: this.otherLabel, caGstLabel: this.caGstLabel, auAbnLabel: this.auAbnLabel, gbVatLabel: this.gbVatLabel, euVatLabel: this.euVatLabel, help: this.helpText, taxIdTypes: this.taxIdTypesData, required: this.required() })); |
| 584 | } |
| 585 | static get watchers() { return { |
| 586 | "taxIdTypes": ["handleTaxIdTypesChange"] |
| 587 | }; } |
| 588 | }; |
| 589 | ScOrderTaxIdInput.style = ScOrderTaxIdInputStyle0; |
| 590 | |
| 591 | const scRadioCss = ":host{display:inline-block}::slotted([slot=description]){display:block;color:var(--sc-radio-description-color, var(--sc-input-help-text-color, var(--sc-color-gray-500)));line-height:var(--sc-line-height-dense);margin:0.5em 0 0;font-size:var(--sc-font-size-small)}.radio{display:inline-flex;align-items:flex-start;font-family:var(--sc-input-font-family);font-size:var(--sc-input-font-size-medium);font-weight:var(--sc-input-font-weight);color:var(--sc-input-color);vertical-align:middle;gap:var(--sc-spacing-xx-small)}.radio:not(.radio--editing){cursor:pointer}.radio__icon{display:inline-flex;width:var(--sc-radio-size);height:var(--sc-radio-size)}.radio__icon svg{width:100%;height:100%}.radio__control{flex:0 0 auto;position:relative;display:inline-flex;align-items:center;justify-content:center;width:var(--sc-radio-size);height:var(--sc-radio-size);border:solid var(--sc-input-border-width) var(--sc-input-border-color);border-radius:50%;background-color:var(--sc-input-background-color);color:transparent;transition:var(--sc-input-transition, var(--sc-transition-medium)) border-color, var(--sc-input-transition, var(--sc-transition-medium)) opacity, var(--sc-input-transition, var(--sc-transition-medium)) background-color, var(--sc-input-transition, var(--sc-transition-medium)) color, var(--sc-input-transition, var(--sc-transition-medium)) box-shadow}.radio__control input[type=radio]{position:absolute;opacity:0;padding:0;margin:0;pointer-events:none}.radio:not(.radio--checked):not(.radio--disabled) .radio__control:hover{border-color:var(--sc-input-border-color-hover);background-color:var(--sc-input-background-color-hover)}.radio.radio--focused:not(.radio--checked):not(.radio--disabled) .radio__control{border-color:var(--sc-input-border-color-focus);background-color:var(--sc-input-background-color-focus);box-shadow:0 0 0 var(--sc-focus-ring-width) var(--sc-focus-ring-color-primary)}.radio--checked .radio__control{color:var(--var-sc-checked-radio-background-color, var(--sc-input-background-color));border-color:var(--sc-color-primary-500);background-color:var(--sc-color-primary-500)}.radio.radio--checked:not(.radio--disabled) .radio__control:hover{opacity:0.8}.radio.radio--checked:not(.radio--disabled).radio--focused .radio__control{border-color:var(--var-sc-checked-radio-border-color, var(--sc-input-background-color));background-color:var(--sc-color-primary-500);box-shadow:0 0 0 var(--sc-focus-ring-width) var(--sc-focus-ring-color-primary)}.radio--disabled{opacity:0.5;cursor:not-allowed}.radio:not(.radio--checked) svg circle{opacity:0}.radio__label{line-height:var(--sc-radio-size);margin-left:0.5em;user-select:none}"; |
| 592 | const ScRadioStyle0 = scRadioCss; |
| 593 | |
| 594 | let id = 0; |
| 595 | const ScRadio = class { |
| 596 | constructor(hostRef) { |
| 597 | registerInstance(this, hostRef); |
| 598 | this.scBlur = createEvent(this, "scBlur", 7); |
| 599 | this.scChange = createEvent(this, "scChange", 7); |
| 600 | this.scFocus = createEvent(this, "scFocus", 7); |
| 601 | this.inputId = `radio-${++id}`; |
| 602 | this.labelId = `radio-label-${id}`; |
| 603 | this.hasFocus = false; |
| 604 | this.name = undefined; |
| 605 | this.value = undefined; |
| 606 | this.disabled = false; |
| 607 | this.checked = false; |
| 608 | this.required = false; |
| 609 | this.invalid = false; |
| 610 | this.edit = undefined; |
| 611 | } |
| 612 | /** Simulates a click on the radio. */ |
| 613 | async ceClick() { |
| 614 | this.input.click(); |
| 615 | } |
| 616 | /** Checks for validity and shows the browser's validation message if the control is invalid. */ |
| 617 | async reportValidity() { |
| 618 | this.invalid = !this.input.checkValidity(); |
| 619 | return this.input.reportValidity(); |
| 620 | } |
| 621 | handleCheckedChange() { |
| 622 | if (!this.input) |
| 623 | return; |
| 624 | if (this.checked) { |
| 625 | this.getSiblingRadios().map(radio => (radio.checked = false)); |
| 626 | } |
| 627 | this.input.checked = this.checked; |
| 628 | this.scChange.emit(); |
| 629 | } |
| 630 | handleClick() { |
| 631 | this.checked = true; |
| 632 | } |
| 633 | handleBlur() { |
| 634 | this.hasFocus = false; |
| 635 | this.scBlur.emit(); |
| 636 | } |
| 637 | handleFocus() { |
| 638 | this.hasFocus = true; |
| 639 | this.scFocus.emit(); |
| 640 | } |
| 641 | /** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */ |
| 642 | setCustomValidity(message) { |
| 643 | this.input.setCustomValidity(message); |
| 644 | this.invalid = !this.input.checkValidity(); |
| 645 | } |
| 646 | getAllRadios() { |
| 647 | const radioGroup = this.el.closest('sc-radio-group'); |
| 648 | // Radios must be part of a radio group |
| 649 | if (!radioGroup) { |
| 650 | return []; |
| 651 | } |
| 652 | return [...radioGroup.querySelectorAll('sc-radio')]; |
| 653 | } |
| 654 | getSiblingRadios() { |
| 655 | return this.getAllRadios().filter(radio => radio !== this.el); |
| 656 | } |
| 657 | handleKeyDown(event) { |
| 658 | if (this.edit) |
| 659 | return true; |
| 660 | if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(event.key)) { |
| 661 | const radios = this.getAllRadios().filter(radio => !radio.disabled); |
| 662 | const incr = ['ArrowUp', 'ArrowLeft'].includes(event.key) ? -1 : 1; |
| 663 | let index = radios.indexOf(this.el) + incr; |
| 664 | if (index < 0) |
| 665 | index = radios.length - 1; |
| 666 | if (index > radios.length - 1) |
| 667 | index = 0; |
| 668 | this.getAllRadios().map(radio => (radio.checked = false)); |
| 669 | radios[index].focus(); |
| 670 | radios[index].checked = true; |
| 671 | event.preventDefault(); |
| 672 | } |
| 673 | } |
| 674 | // Prevent clicks on the label from briefly blurring the input |
| 675 | handleMouseDown(event) { |
| 676 | if (this.edit) |
| 677 | return true; |
| 678 | event.preventDefault(); |
| 679 | this.input.focus(); |
| 680 | } |
| 681 | componentDidLoad() { |
| 682 | this.formController = new FormSubmitController(this.el, { |
| 683 | value: (control) => (control.checked ? control.value : undefined), |
| 684 | }).addFormData(); |
| 685 | } |
| 686 | disconnectedCallback() { |
| 687 | var _a; |
| 688 | (_a = this.formController) === null || _a === void 0 ? void 0 : _a.removeFormData(); |
| 689 | } |
| 690 | render() { |
| 691 | const Tag = this.edit ? 'div' : 'label'; |
| 692 | return (h(Tag, { key: 'c20d0787a2b4d5584c4e0cc8fd594bdcbaa11b45', part: "base", class: { |
| 693 | 'radio': true, |
| 694 | 'radio--checked': this.checked, |
| 695 | 'radio--disabled': this.disabled, |
| 696 | 'radio--focused': this.hasFocus, |
| 697 | 'radio--editing': this.edit, |
| 698 | }, htmlFor: this.inputId, onKeyDown: e => this.handleKeyDown(e), onMouseDown: e => this.handleMouseDown(e) }, h("span", { key: 'e15cbef119d6147b9967b3ca019ab8006c0b8a0c', part: "control", class: "radio__control" }, h("span", { key: 'b662bf67deeb25cc4cfa8616b02b9e92f0c64d8e', part: "checked-icon", class: "radio__icon" }, h("svg", { key: '007e260fb2a93f0610b35701d2e0a1f8ac6ef3e4', viewBox: "0 0 16 16" }, h("g", { key: 'ae0c009137298dc3973f918d30ae7c6504454a15', stroke: "none", "stroke-width": "1", fill: "none", "fill-rule": "evenodd" }, h("g", { key: 'daeb2d21f52ec9a40d7384b0279c921100f4d5b9', fill: "currentColor" }, h("circle", { key: '439768c40109d1f0484f91675719381d7b98845c', cx: "8", cy: "8", r: "3.42857143" }))))), h("input", { key: '2293ec56035602faa7d1d7ef96975b20e1c0081d', id: this.inputId, ref: el => (this.input = el), type: "radio", name: this.name, value: this.value, checked: this.checked, disabled: this.disabled, required: this.required, "aria-checked": this.checked ? 'true' : 'false', "aria-disabled": this.disabled ? 'true' : 'false', "aria-labelledby": this.labelId, onClick: () => this.handleClick(), onBlur: () => this.handleBlur(), onFocus: () => this.handleFocus() })), h("span", { key: 'f3733f071bdab3a8de052476b57575ffabb352db', part: "label", id: this.labelId, class: "radio__label" }, h("slot", { key: '8ffd9897ec8da1b50de675b28698f8e9f756d0da' }), h("slot", { key: '18789a992101dc41a03d770b6ed98d846e654b49', name: "description" })))); |
| 699 | } |
| 700 | get el() { return getElement(this); } |
| 701 | static get watchers() { return { |
| 702 | "checked": ["handleCheckedChange"] |
| 703 | }; } |
| 704 | }; |
| 705 | ScRadio.style = ScRadioStyle0; |
| 706 | |
| 707 | const scRadioGroupCss = ":host{display:block}.radio-group{border:none;padding:0;margin:0;min-width:0}.radio-group .radio-group__label{display:inline-block;padding:0;color:var(--sc-input-label-color);font-weight:var(--sc-input-label-font-weight);text-transform:var(--sc-input-label-text-transform, none);letter-spacing:var(--sc-input-label-letter-spacing, 0);margin-bottom:var(--sc-input-label-margin)}.radio-group__hidden-input{position:absolute;opacity:0;padding:0px;margin:0px;pointer-events:none}.radio-group--is-required .radio-group__label:after{content:\" *\";color:var(--sc-color-danger-500)}::slotted(sc-radio:not(:last-of-type)){display:block;margin-bottom:var(--sc-spacing-x-small)}.radio-group--is-rtl.radio-group,.radio-group--is-rtl.radio-group .radio-group__label{text-align:right}"; |
| 708 | const ScRadioGroupStyle0 = scRadioGroupCss; |
| 709 | |
| 710 | const ScRadioGroup = class { |
| 711 | constructor(hostRef) { |
| 712 | registerInstance(this, hostRef); |
| 713 | this.scChange = createEvent(this, "scChange", 7); |
| 714 | this.label = ''; |
| 715 | this.invalid = undefined; |
| 716 | this.value = ''; |
| 717 | this.required = undefined; |
| 718 | } |
| 719 | /** Checks for validity and shows the browser's validation message if the control is invalid. */ |
| 720 | async reportValidity() { |
| 721 | this.invalid = !this.input.checkValidity(); |
| 722 | return this.input.reportValidity(); |
| 723 | } |
| 724 | handleRadioClick(event) { |
| 725 | if (event.target.tagName !== 'SC-RADIO') |
| 726 | return; |
| 727 | event.stopImmediatePropagation(); |
| 728 | const target = event.target; |
| 729 | if (target.disabled) { |
| 730 | return; |
| 731 | } |
| 732 | if (target.checked) { |
| 733 | this.value = target.value; |
| 734 | this.scChange.emit(target.value); |
| 735 | } |
| 736 | } |
| 737 | componentDidLoad() { |
| 738 | const choices = [...this.el.querySelectorAll('sc-radio')]; |
| 739 | choices.forEach(choice => { |
| 740 | if (choice.checked) { |
| 741 | this.value = choice.value; |
| 742 | } |
| 743 | }); |
| 744 | } |
| 745 | render() { |
| 746 | return (h("fieldset", { key: '456b61e9692e45daca1af0161606cb2babf7cfbe', part: "base", class: { |
| 747 | 'radio-group': true, |
| 748 | 'radio-group--invalid': this.invalid, |
| 749 | 'radio-group--is-required': this.required, |
| 750 | 'radio-group--is-rtl': isRtl(), |
| 751 | }, "aria-invalid": this.invalid, role: "radiogroup" }, h("legend", { key: 'c3482d8ba46557d8e5e854dbc4fd2571dbdf3fbd', part: "label", class: "radio-group__label" }, h("slot", { key: '23a97b0f5172d34cd3981c12dd93be2d44aad188', name: "label" }, this.label)), h("input", { key: '174be102ef7b44fead36d7e188d309beda0e8426', type: "text", class: "radio-group__hidden-input", ref: el => (this.input = el), required: this.required, value: this.value, tabindex: "-1" }), h("div", { key: 'd96382aa3a294dc5b2c2919a165909d96d477b49', part: "items", class: "radio-group__items" }, h("slot", { key: '11dc4aea9091689367def2a2d34da6e6ff528d2d' })))); |
| 752 | } |
| 753 | get el() { return getElement(this); } |
| 754 | }; |
| 755 | ScRadioGroup.style = ScRadioGroupStyle0; |
| 756 | |
| 757 | const scShippingChoicesCss = ":host{display:block}.shipping-choice{width:100%;padding:var(--sc-spacing-medium);margin:0;box-sizing:border-box;border-bottom:var(--sc-input-border, 1px solid var(--sc-color-gray-300));background-color:var(--sc-shipping-choice-background-color, var(--sc-input-background-color))}.shipping-choice__empty{background:var(--sc-alert-background-color, var(--sc-color-gray-100));opacity:0.75;padding:var(--sc-spacing-large);border-radius:var(--sc-input-border-radius-medium);line-height:var(--sc-line-height-dense);font-size:var(--sc-font-size-small);border:solid 1px var(--sc-input-border-color, var(--sc-input-border))}.shipping-choice:last-child{border-bottom-width:0}.shipping-choice__text{display:flex;flex-direction:column;gap:var(--sc-spacing-xx-small)}.shipping-choice__price{color:var(--sc-input-label-color);font-weight:var(--sc-price-choice-price-font-weight, var(--sc-font-weight-normal));white-space:nowrap;display:var(--sc-shipping-choice-price-display, inherit)}.shipping-choice__name{display:inline-block;color:var(--sc-price-choice-name-color, var(--sc-input-label-color));font-size:var(--sc-price-choice-name-size, var(--sc-input-label-font-size-medium));font-weight:var(--sc-price-choice-name-font-weight, var(--sc-font-weight-bold));text-transform:var(--sc-price-choice-text-transform, var(--sc-input-label-text-transform, none));line-height:var(--sc-shipping-name-line-height, 1)}.shipping-choice__description{color:var(--sc-input-label-color);font-weight:var(--sc-price-choice-price-font-weight, var(--sc-font-weight-normal));line-height:var(--sc-shipping-description-line-height, 1.2)}sc-radio-group::part(items){border:var(--sc-input-border, 1px solid var(--sc-color-gray-300));border-radius:var(--sc-shipping-choice-border-radius, var(--sc-input-border-radius-medium));box-shadow:var(--sc-shipping-box-shadow, var(--sc-input-box-shadow));overflow:hidden;position:relative}sc-radio::part(base){width:100%}sc-radio::part(label){width:100%;display:flex;justify-content:space-between;gap:var(--sc-spacing-small)}sc-radio-group::slotted(sc-radio:not(:last-of-type)){margin-bottom:0}"; |
| 758 | const ScShippingChoicesStyle0 = scShippingChoicesCss; |
| 759 | |
| 760 | const ScShippingChoices = class { |
| 761 | constructor(hostRef) { |
| 762 | registerInstance(this, hostRef); |
| 763 | this.label = undefined; |
| 764 | this.showDescription = true; |
| 765 | } |
| 766 | /** Maybe update the order. */ |
| 767 | async updateCheckout(selectedShippingChoiceId) { |
| 768 | if (!selectedShippingChoiceId) |
| 769 | return; |
| 770 | try { |
| 771 | lockCheckout('selected_shipping_choice'); |
| 772 | state$1.checkout = (await createOrUpdateCheckout({ |
| 773 | id: state$1.checkout.id, |
| 774 | data: { |
| 775 | selected_shipping_choice_id: selectedShippingChoiceId, |
| 776 | }, |
| 777 | })); |
| 778 | speak(wp.i18n.__('Shipping choice updated.', 'surecart'), 'assertive'); |
| 779 | const { total_amount, currency } = state$1.checkout; |
| 780 | /** translators: %1$s: formatted amount */ |
| 781 | speak(wp.i18n.sprintf(wp.i18n.__('Your order total has changed to: %1$s.', 'surecart'), getFormattedPrice({ amount: total_amount, currency })), 'assertive'); |
| 782 | } |
| 783 | catch (e) { |
| 784 | console.error(e); |
| 785 | createErrorNotice(e); |
| 786 | } |
| 787 | finally { |
| 788 | unLockCheckout('selected_shipping_choice'); |
| 789 | } |
| 790 | } |
| 791 | render() { |
| 792 | var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; |
| 793 | // shipping choice is not rewquired. |
| 794 | if (!((_a = state$1 === null || state$1 === void 0 ? void 0 : state$1.checkout) === null || _a === void 0 ? void 0 : _a.selected_shipping_choice_required)) { |
| 795 | return h(Host, { style: { display: 'none' } }); |
| 796 | } |
| 797 | // no shipping choices but no country either |
| 798 | if (!((_d = (_c = (_b = state$1 === null || state$1 === void 0 ? void 0 : state$1.checkout) === null || _b === void 0 ? void 0 : _b.shipping_choices) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.length) && !((_f = (_e = state$1 === null || state$1 === void 0 ? void 0 : state$1.checkout) === null || _e === void 0 ? void 0 : _e.shipping_address) === null || _f === void 0 ? void 0 : _f.country)) { |
| 799 | return (h("sc-form-control", { label: this.label || wp.i18n.__('Shipping', 'surecart') }, h("div", { class: "shipping-choice__empty" }, wp.i18n.__('To check available shipping choices, please provide your shipping country in the address section.', 'surecart')))); |
| 800 | } |
| 801 | // no shipping choices yet. |
| 802 | if (!((_j = (_h = (_g = state$1 === null || state$1 === void 0 ? void 0 : state$1.checkout) === null || _g === void 0 ? void 0 : _g.shipping_choices) === null || _h === void 0 ? void 0 : _h.data) === null || _j === void 0 ? void 0 : _j.length)) { |
| 803 | return (h("sc-form-control", { part: "empty", label: this.label || wp.i18n.__('Shipping', 'surecart') }, h("div", { class: "shipping-choice__empty" }, wp.i18n.__('Sorry, we are not able to ship to your address.', 'surecart')))); |
| 804 | } |
| 805 | return (h(Host, null, h("sc-radio-group", { part: "base", label: this.label || wp.i18n.__('Shipping', 'surecart'), class: "shipping-choices", onScChange: e => this.updateCheckout(e.detail) }, (((_l = (_k = state$1 === null || state$1 === void 0 ? void 0 : state$1.checkout) === null || _k === void 0 ? void 0 : _k.shipping_choices) === null || _l === void 0 ? void 0 : _l.data) || []).map(({ id, amount, currency, shipping_method }) => { |
| 806 | var _a; |
| 807 | return (h("sc-radio", { key: id, checked: ((_a = state$1 === null || state$1 === void 0 ? void 0 : state$1.checkout) === null || _a === void 0 ? void 0 : _a.selected_shipping_choice) === id, exportparts: "base:radio__base,label:radio__label,control:radio__control,checked-icon:radio__checked-icon", class: "shipping-choice", value: id }, h("div", { class: "shipping-choice__text" }, h("div", { class: "shipping-choice__name" }, (shipping_method === null || shipping_method === void 0 ? void 0 : shipping_method.name) || wp.i18n.__('Standard Shipping', 'surecart')), this.showDescription && !!(shipping_method === null || shipping_method === void 0 ? void 0 : shipping_method.description) && (h("div", { class: "shipping-choice__description" }, shipping_method === null || shipping_method === void 0 ? void 0 : shipping_method.description))), h("div", { class: "shipping-choice__price" }, !!amount ? h("sc-format-number", { type: "currency", value: amount, currency: currency }) : wp.i18n.__('Free', 'surecart')))); |
| 808 | })), checkoutIsLocked('selected_shipping_choice') && h("sc-block-ui", null))); |
| 809 | } |
| 810 | }; |
| 811 | ScShippingChoices.style = ScShippingChoicesStyle0; |
| 812 | |
| 813 | export { ScCompactAddress as sc_compact_address, ScLineItemShipping as sc_line_item_shipping, ScLineItemTax as sc_line_item_tax, ScOrderBillingAddress as sc_order_billing_address, ScOrderBump as sc_order_bump, ScOrderBumps as sc_order_bumps, ScOrderShippingAddress as sc_order_shipping_address, ScOrderTaxIdInput as sc_order_tax_id_input, ScRadio as sc_radio, ScRadioGroup as sc_radio_group, ScShippingChoices as sc_shipping_choices }; |
| 814 | |
| 815 | //# sourceMappingURL=sc-compact-address_11.entry.js.map |