MockProcessor-5c5e066a.js
2 months ago
MockProcessor-5c5e066a.js.map
2 months ago
add-query-args-0e2a8393.js
1 year ago
add-query-args-0e2a8393.js.map
1 year ago
address-b8e2e4c8.js
4 months ago
address-b8e2e4c8.js.map
4 months ago
animation-registry-de37bd7e.js
3 months ago
animation-registry-de37bd7e.js.map
3 months ago
app-globals-0eef0276.js
2 months ago
app-globals-0eef0276.js.map
2 months ago
consumer-f1775a76.js
2 months ago
consumer-f1775a76.js.map
2 months ago
currency-a0c9bff4.js
1 year ago
currency-a0c9bff4.js.map
1 year ago
error-c8bf8e3e.js
6 days ago
error-c8bf8e3e.js.map
6 days ago
fetch-cdff67be.js
1 month ago
fetch-cdff67be.js.map
1 month ago
floating-ui.dom.esm-8dce4ea1.js
6 months ago
floating-ui.dom.esm-8dce4ea1.js.map
6 months ago
form-data-76641f16.js
1 year ago
form-data-76641f16.js.map
1 year ago
functions-4f009ce1.js
3 months ago
functions-4f009ce1.js.map
3 months ago
geo-permission-62aea8ee.js
1 month ago
geo-permission-62aea8ee.js.map
1 month ago
getters-1049a6f8.js
2 months ago
getters-1049a6f8.js.map
2 months ago
getters-1477d792.js
2 months ago
getters-1477d792.js.map
2 months ago
getters-4bb6cc1b.js
2 months ago
getters-4bb6cc1b.js.map
2 months ago
getters-7090a9c1.js
6 days ago
getters-7090a9c1.js.map
6 days ago
getters-9cfeb0de.js
6 days ago
getters-9cfeb0de.js.map
6 days ago
google-52867ad8.js
6 days ago
google-52867ad8.js.map
6 days ago
google-e9085e27.js
6 days ago
google-e9085e27.js.map
6 days ago
google-maps-e8b00ffd.js
3 months ago
google-maps-e8b00ffd.js.map
3 months ago
index-17aac936.js
1 month ago
index-17aac936.js.map
1 month ago
index-18f5a1bc.js
2 months ago
index-18f5a1bc.js.map
2 months ago
index-25e5af33.js
2 months ago
index-25e5af33.js.map
2 months ago
index-824c562b.js
2 months ago
index-824c562b.js.map
2 months ago
index-871d88b8.js
1 year ago
index-871d88b8.js.map
1 year ago
index-a786f689.js
6 days ago
index-a786f689.js.map
6 days ago
index-c5a96d53.js
2 years ago
index-c5a96d53.js.map
2 years ago
index-d602bc13.js
1 month ago
index-d602bc13.js.map
1 month ago
index.js
6 days ago
index.js.map
1 month 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-1bd957d5.js
2 months ago
library-1bd957d5.js.map
2 months ago
loader.js
2 weeks ago
loader.js.map
1 year ago
media-d21119a3.js
1 year ago
media-d21119a3.js.map
1 year ago
mutations-7458343f.js
2 months ago
mutations-7458343f.js.map
2 months ago
mutations-9ffd30f4.js
6 days ago
mutations-9ffd30f4.js.map
6 days ago
mutations-ae7167ad.js
6 days ago
mutations-ae7167ad.js.map
6 days ago
mutations-b310b068.js
6 days ago
mutations-b310b068.js.map
6 days ago
page-align-0cdacf32.js
1 year ago
page-align-0cdacf32.js.map
1 year ago
price-1ff6aa07.js
4 months ago
price-1ff6aa07.js.map
4 months ago
pure-963214cb.js
1 year ago
pure-963214cb.js.map
1 year ago
quantity-5c986f3d.js
3 months ago
quantity-5c986f3d.js.map
3 months ago
razorpay-4c4a3d31.js
3 months ago
razorpay-4c4a3d31.js.map
3 months ago
remove-query-args-938c53ea.js
1 year ago
remove-query-args-938c53ea.js.map
1 year ago
sc-address_5.entry.js
2 weeks ago
sc-address_5.entry.js.map
2 weeks ago
sc-alert.entry.js
1 month ago
sc-alert.entry.js.map
1 year ago
sc-avatar_2.entry.js
6 days ago
sc-avatar_2.entry.js.map
1 month ago
sc-badge-notice.entry.js
1 month ago
sc-badge-notice.entry.js.map
1 year ago
sc-block-ui.entry.js
1 month ago
sc-block-ui.entry.js.map
4 months ago
sc-breadcrumb.entry.js
1 month ago
sc-breadcrumb.entry.js.map
1 year ago
sc-breadcrumbs.entry.js
1 month ago
sc-breadcrumbs.entry.js.map
1 year ago
sc-button-group.entry.js
1 month ago
sc-button-group.entry.js.map
1 year ago
sc-button_6.entry.js
1 month ago
sc-button_6.entry.js.map
1 month ago
sc-cancel-dialog_3.entry.js
1 month ago
sc-cancel-dialog_3.entry.js.map
1 month ago
sc-cancel-discount_4.entry.js
1 month ago
sc-cancel-discount_4.entry.js.map
2 months ago
sc-card_2.entry.js
1 month ago
sc-card_2.entry.js.map
4 months ago
sc-cart-button.entry.js
6 days ago
sc-cart-button.entry.js.map
1 year ago
sc-cart-form-submit.entry.js
2 months ago
sc-cart-form-submit.entry.js.map
1 year ago
sc-cart-form.entry.js
6 days ago
sc-cart-form.entry.js.map
1 month ago
sc-cart-header.entry.js
6 days ago
sc-cart-header.entry.js.map
1 year ago
sc-cart-icon.entry.js
6 days ago
sc-cart-icon.entry.js.map
1 year ago
sc-cart-loader.entry.js
6 days ago
sc-cart-loader.entry.js.map
1 year ago
sc-cart-session-provider_3.entry.js
6 days ago
sc-cart-session-provider_3.entry.js.map
2 months ago
sc-cart-submit.entry.js
2 months ago
sc-cart-submit.entry.js.map
1 year ago
sc-cart.entry.js
6 days ago
sc-cart.entry.js.map
2 months ago
sc-cc-logo_2.entry.js
1 month ago
sc-cc-logo_2.entry.js.map
1 month ago
sc-charges-list.entry.js
1 month ago
sc-charges-list.entry.js.map
2 months ago
sc-checkout-autofill-provider_11.entry.js
6 days ago
sc-checkout-autofill-provider_11.entry.js.map
1 month ago
sc-checkout-form-errors.entry.js
2 months ago
sc-checkout-form-errors.entry.js.map
1 year ago
sc-checkout-mollie-payment_3.entry.js
6 days ago
sc-checkout-mollie-payment_3.entry.js.map
2 months ago
sc-checkout-product-bundle-component-variants.entry.js
6 days ago
sc-checkout-product-bundle-component-variants.entry.js.map
1 month ago
sc-checkout-product-price-variant-selector.entry.js
6 days ago
sc-checkout-product-price-variant-selector.entry.js.map
3 weeks ago
sc-checkout.entry.js
6 days ago
sc-checkout.entry.js.map
1 month ago
sc-choice-container.entry.js
1 month ago
sc-choice-container.entry.js.map
1 year ago
sc-choice.entry.js
1 month ago
sc-choice.entry.js.map
1 year ago
sc-choices.entry.js
1 month ago
sc-choices.entry.js.map
1 year ago
sc-column_2.entry.js
1 month ago
sc-column_2.entry.js.map
1 month ago
sc-compact-address_18.entry.js
6 days ago
sc-compact-address_18.entry.js.map
1 month ago
sc-conditional-form.entry.js
6 days ago
sc-conditional-form.entry.js.map
2 months ago
sc-consumer.entry.js
2 months ago
sc-consumer.entry.js.map
1 year ago
sc-coupon-form.entry.js
6 days ago
sc-coupon-form.entry.js.map
5 months ago
sc-custom-order-price-input.entry.js
1 month ago
sc-custom-order-price-input.entry.js.map
2 months ago
sc-customer-details.entry.js
1 month ago
sc-customer-details.entry.js.map
7 months ago
sc-customer-edit.entry.js
1 month ago
sc-customer-edit.entry.js.map
2 months ago
sc-customer-email.entry.js
6 days ago
sc-customer-email.entry.js.map
1 month ago
sc-customer-firstname.entry.js
6 days ago
sc-customer-firstname.entry.js.map
2 months ago
sc-customer-lastname.entry.js
6 days ago
sc-customer-lastname.entry.js.map
2 months ago
sc-customer-name.entry.js
6 days ago
sc-customer-name.entry.js.map
2 months ago
sc-dashboard-customer-details.entry.js
1 month ago
sc-dashboard-customer-details.entry.js.map
2 months ago
sc-dashboard-downloads-list.entry.js
1 month ago
sc-dashboard-downloads-list.entry.js.map
2 months ago
sc-dialog.entry.js
1 month ago
sc-dialog.entry.js.map
4 months ago
sc-divider.entry.js
1 month ago
sc-divider.entry.js.map
1 year ago
sc-donation-choices.entry.js
2 months ago
sc-donation-choices.entry.js.map
1 year ago
sc-downloads-list.entry.js
1 month ago
sc-downloads-list.entry.js.map
1 month ago
sc-dropdown_3.entry.js
1 month ago
sc-dropdown_3.entry.js.map
6 months ago
sc-empty_3.entry.js
1 month ago
sc-empty_3.entry.js.map
4 months ago
sc-express-payment.entry.js
6 days ago
sc-express-payment.entry.js.map
3 months ago
sc-feature-demo-banner.entry.js
1 month ago
sc-feature-demo-banner.entry.js.map
1 year ago
sc-flex.entry.js
1 month ago
sc-flex.entry.js.map
1 year ago
sc-form-control_2.entry.js
1 month ago
sc-form-control_2.entry.js.map
2 months ago
sc-form-row.entry.js
1 month ago
sc-form-row.entry.js.map
1 year ago
sc-form.entry.js
1 month ago
sc-form.entry.js.map
1 year ago
sc-format-bytes.entry.js
2 months ago
sc-format-bytes.entry.js.map
1 year ago
sc-format-interval.entry.js
2 months ago
sc-format-interval.entry.js.map
1 year ago
sc-format-number.entry.js
2 months ago
sc-format-number.entry.js.map
1 year ago
sc-fulfillment-shipping-status-badge.entry.js
2 months ago
sc-fulfillment-shipping-status-badge.entry.js.map
4 months ago
sc-fulfillments.entry.js
1 month ago
sc-fulfillments.entry.js.map
2 months ago
sc-heading_2.entry.js
1 month ago
sc-heading_2.entry.js.map
1 year ago
sc-image-slider.entry.js
1 month ago
sc-image-slider.entry.js.map
1 month ago
sc-invoice-status-badge.entry.js
1 month ago
sc-invoice-status-badge.entry.js.map
4 months ago
sc-invoices-list.entry.js
1 month ago
sc-invoices-list.entry.js.map
2 months ago
sc-license.entry.js
1 month ago
sc-license.entry.js.map
2 months ago
sc-licenses-list.entry.js
1 month ago
sc-licenses-list.entry.js.map
1 month ago
sc-line-item-bump.entry.js
6 days ago
sc-line-item-bump.entry.js.map
1 year ago
sc-line-item-total.entry.js
6 days ago
sc-line-item-total.entry.js.map
6 months ago
sc-line-item.entry.js
1 month ago
sc-line-item.entry.js.map
1 year ago
sc-line-items-provider.entry.js
1 month ago
sc-line-items-provider.entry.js.map
1 year ago
sc-line-items.entry.js
6 days ago
sc-line-items.entry.js.map
1 month ago
sc-login-form.entry.js
1 month ago
sc-login-form.entry.js.map
2 months ago
sc-manual-payment-method_3.entry.js
1 month ago
sc-manual-payment-method_3.entry.js.map
3 months ago
sc-menu-divider.entry.js
1 month ago
sc-menu-divider.entry.js.map
1 year ago
sc-menu-label_2.entry.js
1 month ago
sc-menu-label_2.entry.js.map
1 month ago
sc-mollie-add-method.entry.js
1 month ago
sc-mollie-add-method.entry.js.map
2 months ago
sc-order-confirmation-customer.entry.js
2 months ago
sc-order-confirmation-customer.entry.js.map
1 year ago
sc-order-confirmation-details.entry.js
2 months ago
sc-order-confirmation-details.entry.js.map
11 months ago
sc-order-confirmation-line-items_2.entry.js
1 month ago
sc-order-confirmation-line-items_2.entry.js.map
1 month ago
sc-order-confirmation.entry.js
1 month ago
sc-order-confirmation.entry.js.map
2 months ago
sc-order-coupon-form.entry.js
6 days ago
sc-order-coupon-form.entry.js.map
2 months ago
sc-order-detail.entry.js
2 months ago
sc-order-detail.entry.js.map
1 year ago
sc-order-fulfillment-badge.entry.js
1 month ago
sc-order-fulfillment-badge.entry.js.map
4 months ago
sc-order-manual-instructions.entry.js
2 months ago
sc-order-manual-instructions.entry.js.map
1 year ago
sc-order-password.entry.js
2 months ago
sc-order-password.entry.js.map
1 year ago
sc-order-return-badge.entry.js
1 month ago
sc-order-return-badge.entry.js.map
4 months ago
sc-order-shipment-badge.entry.js
2 months ago
sc-order-shipment-badge.entry.js.map
4 months ago
sc-order-status-badge.entry.js
1 month ago
sc-order-status-badge.entry.js.map
4 months ago
sc-order-submit.entry.js
6 days ago
sc-order-submit.entry.js.map
2 months ago
sc-order-summary.entry.js
6 days ago
sc-order-summary.entry.js.map
1 month ago
sc-order.entry.js
1 month ago
sc-order.entry.js.map
1 month ago
sc-orders-list.entry.js
1 month ago
sc-orders-list.entry.js.map
1 month ago
sc-pagination.entry.js
2 months ago
sc-pagination.entry.js.map
1 year ago
sc-password-nag.entry.js
1 month ago
sc-password-nag.entry.js.map
2 months ago
sc-password.entry.js
1 month ago
sc-password.entry.js.map
1 month ago
sc-payment-method-choice_2.entry.js
1 month ago
sc-payment-method-choice_2.entry.js.map
1 year ago
sc-payment-method-details.entry.js
1 month ago
sc-payment-method-details.entry.js.map
1 year ago
sc-payment-methods-list.entry.js
1 month ago
sc-payment-methods-list.entry.js.map
2 months ago
sc-payment.entry.js
6 days ago
sc-payment.entry.js.map
3 months ago
sc-paypal-add-method.entry.js
1 month ago
sc-paypal-add-method.entry.js.map
2 months ago
sc-paypal-buttons_2.entry.js
6 days ago
sc-paypal-buttons_2.entry.js.map
2 months ago
sc-paystack-add-method.entry.js
1 month ago
sc-paystack-add-method.entry.js.map
2 months ago
sc-pill-option.entry.js
1 month ago
sc-pill-option.entry.js.map
1 year ago
sc-popover.entry.js
1 month ago
sc-popover.entry.js.map
6 months ago
sc-premium-tag.entry.js
1 month ago
sc-premium-tag.entry.js.map
1 year ago
sc-price-choice-container.entry.js
1 month ago
sc-price-choice-container.entry.js.map
1 month ago
sc-price-choice.entry.js
1 month ago
sc-price-choice.entry.js.map
2 months ago
sc-price-choices.entry.js
6 days ago
sc-price-choices.entry.js.map
1 year ago
sc-price-input.entry.js
1 month ago
sc-price-input.entry.js.map
1 year ago
sc-price-range_4.entry.js
1 month ago
sc-price-range_4.entry.js.map
1 year ago
sc-price.entry.js
2 months ago
sc-price.entry.js.map
11 months ago
sc-product-buy-button.entry.js
6 days ago
sc-product-buy-button.entry.js.map
2 months ago
sc-product-donation-amount-choice.entry.js
6 days ago
sc-product-donation-amount-choice.entry.js.map
2 months ago
sc-product-donation-choices.entry.js
6 days ago
sc-product-donation-choices.entry.js.map
2 months ago
sc-product-donation-custom-amount.entry.js
6 days ago
sc-product-donation-custom-amount.entry.js.map
2 months ago
sc-product-item-list.entry.js
6 days ago
sc-product-item-list.entry.js.map
2 months ago
sc-product-item.entry.js
1 month ago
sc-product-item.entry.js.map
1 year ago
sc-product-pills-variant-option.entry.js
6 days ago
sc-product-pills-variant-option.entry.js.map
1 year ago
sc-product-price-choices.entry.js
6 days ago
sc-product-price-choices.entry.js.map
1 year ago
sc-product-price-modal.entry.js
6 days ago
sc-product-price-modal.entry.js.map
2 months ago
sc-product-price.entry.js
6 days ago
sc-product-price.entry.js.map
2 months ago
sc-product-quantity.entry.js
6 days ago
sc-product-quantity.entry.js.map
1 year ago
sc-product-selected-price.entry.js
6 days ago
sc-product-selected-price.entry.js.map
2 months ago
sc-product-text.entry.js
6 days ago
sc-product-text.entry.js.map
1 year ago
sc-provider.entry.js
2 months ago
sc-provider.entry.js.map
1 year ago
sc-provisional-banner.entry.js
1 month ago
sc-provisional-banner.entry.js.map
11 months ago
sc-purchase-downloads-list.entry.js
1 month ago
sc-purchase-downloads-list.entry.js.map
1 month ago
sc-razorpay-add-method.entry.js
1 month ago
sc-razorpay-add-method.entry.js.map
2 months ago
sc-recurring-price-choice-container.entry.js
2 months ago
sc-recurring-price-choice-container.entry.js.map
1 year ago
sc-review-stars.entry.js
2 months ago
sc-review-stars.entry.js.map
5 months ago
sc-rich-text.entry.js
1 month ago
sc-rich-text.entry.js.map
1 month ago
sc-skeleton.entry.js
1 month ago
sc-skeleton.entry.js.map
1 year ago
sc-spacing.entry.js
1 month ago
sc-spacing.entry.js.map
1 year ago
sc-stripe-add-method.entry.js
1 month ago
sc-stripe-add-method.entry.js.map
2 months ago
sc-stripe-element.entry.js
6 days ago
sc-stripe-element.entry.js.map
2 months ago
sc-stripe-payment-element.entry.js
6 days ago
sc-stripe-payment-element.entry.js.map
2 months ago
sc-stripe-payment-request.entry.js
6 days ago
sc-stripe-payment-request.entry.js.map
2 months ago
sc-subscription-ad-hoc-confirm.entry.js
1 month ago
sc-subscription-ad-hoc-confirm.entry.js.map
6 months ago
sc-subscription-details_2.entry.js
1 month ago
sc-subscription-details_2.entry.js.map
1 month ago
sc-subscription-payment-method.entry.js
1 month ago
sc-subscription-payment-method.entry.js.map
2 months ago
sc-subscription-payment.entry.js
1 month ago
sc-subscription-payment.entry.js.map
2 months ago
sc-subscription-switch.entry.js
1 month ago
sc-subscription-switch.entry.js.map
2 months ago
sc-subscription-variation-confirm.entry.js
1 month ago
sc-subscription-variation-confirm.entry.js.map
1 year ago
sc-subscription.entry.js
1 month ago
sc-subscription.entry.js.map
1 month ago
sc-subscriptions-list.entry.js
1 month ago
sc-subscriptions-list.entry.js.map
2 months ago
sc-summary.entry.js
1 month ago
sc-summary.entry.js.map
1 year ago
sc-swap.entry.js
6 days ago
sc-swap.entry.js.map
2 months ago
sc-switch.entry.js
1 month ago
sc-switch.entry.js.map
7 months ago
sc-tab-group.entry.js
1 month ago
sc-tab-group.entry.js.map
1 year ago
sc-tab-panel.entry.js
1 month ago
sc-tab-panel.entry.js.map
1 year ago
sc-tab.entry.js
1 month ago
sc-tab.entry.js.map
1 year ago
sc-table-head.entry.js
1 month ago
sc-table-head.entry.js.map
1 year ago
sc-table_3.entry.js
1 month ago
sc-table_3.entry.js.map
10 months ago
sc-tag.entry.js
1 month ago
sc-tag.entry.js.map
4 months ago
sc-test-mode-info.entry.js
1 month ago
sc-test-mode-info.entry.js.map
6 months ago
sc-text.entry.js
1 month ago
sc-text.entry.js.map
1 year ago
sc-toggle.entry.js
1 month ago
sc-toggle.entry.js.map
1 year ago
sc-toggles.entry.js
1 month ago
sc-toggles.entry.js.map
1 year ago
sc-total.entry.js
6 days ago
sc-total.entry.js.map
1 year ago
sc-upcoming-invoice.entry.js
1 month ago
sc-upcoming-invoice.entry.js.map
2 months ago
sc-upgrade-required.entry.js
2 months ago
sc-upgrade-required.entry.js.map
1 year ago
sc-upsell-countdown-timer.entry.js
1 month ago
sc-upsell-countdown-timer.entry.js.map
1 year ago
sc-upsell-no-thanks-button.entry.js
6 days ago
sc-upsell-no-thanks-button.entry.js.map
2 months ago
sc-upsell-submit-button.entry.js
6 days ago
sc-upsell-submit-button.entry.js.map
2 months ago
sc-upsell-totals.entry.js
6 days ago
sc-upsell-totals.entry.js.map
2 months ago
sc-upsell.entry.js
6 days ago
sc-upsell.entry.js.map
2 months ago
sc-verification-code.entry.js
1 month ago
sc-verification-code.entry.js.map
2 months ago
sc-visually-hidden.entry.js
1 month ago
sc-visually-hidden.entry.js.map
1 year ago
sc-wordpress-password-edit.entry.js
1 month ago
sc-wordpress-password-edit.entry.js.map
2 months ago
sc-wordpress-user-edit.entry.js
1 month ago
sc-wordpress-user-edit.entry.js.map
2 months ago
sc-wordpress-user.entry.js
1 month ago
sc-wordpress-user.entry.js.map
1 year ago
store-289e460c.js
2 months ago
store-289e460c.js.map
2 months ago
store-ac90a769.js
1 month ago
store-ac90a769.js.map
1 month ago
store-b1758b00.js
2 months ago
store-b1758b00.js.map
2 months ago
surecart.js
2 weeks ago
surecart.js.map
1 year ago
tax-a03623ca.js
1 year ago
tax-a03623ca.js.map
1 year ago
universe-7bd0ac2b.js
2 months ago
universe-7bd0ac2b.js.map
2 months ago
util-dfbf863e.js
2 months ago
util-dfbf863e.js.map
2 months ago
utils-f84b2118.js
3 months ago
utils-f84b2118.js.map
3 months ago
verification-00df9439.js
1 month ago
verification-00df9439.js.map
1 month ago
watchers-2d9a1422.js
6 days ago
watchers-2d9a1422.js.map
6 days ago
watchers-81f32d01.js
6 days ago
watchers-81f32d01.js.map
6 days ago
watchers-843c3dbe.js
6 days ago
watchers-843c3dbe.js.map
6 days ago
watchers-c7bbc6b2.js
2 months ago
watchers-c7bbc6b2.js.map
2 months ago
watchers-df374a91.js
6 days ago
watchers-df374a91.js.map
6 days ago
sc-price-choice.entry.js
832 lines
| 1 | import { r as registerInstance, c as createEvent, h, F as Fragment, H as Host } from './index-25e5af33.js'; |
| 2 | import { o as openWormhole } from './consumer-f1775a76.js'; |
| 3 | import { i as isPriceInOrder } from './index-17aac936.js'; |
| 4 | import { i as intervalString } from './price-1ff6aa07.js'; |
| 5 | import './fetch-cdff67be.js'; |
| 6 | import { a as addQueryArgs } from './add-query-args-0e2a8393.js'; |
| 7 | import { a as apiFetch } from './index-824c562b.js'; |
| 8 | import './currency-a0c9bff4.js'; |
| 9 | import './remove-query-args-938c53ea.js'; |
| 10 | |
| 11 | function _defineProperties(target, props) { |
| 12 | for (var i = 0; i < props.length; i++) { |
| 13 | var descriptor = props[i]; |
| 14 | descriptor.enumerable = descriptor.enumerable || false; |
| 15 | descriptor.configurable = true; |
| 16 | if ("value" in descriptor) descriptor.writable = true; |
| 17 | Object.defineProperty(target, descriptor.key, descriptor); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | function _createClass(Constructor, protoProps, staticProps) { |
| 22 | if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
| 23 | if (staticProps) _defineProperties(Constructor, staticProps); |
| 24 | return Constructor; |
| 25 | } |
| 26 | |
| 27 | function _extends() { |
| 28 | _extends = Object.assign || function (target) { |
| 29 | for (var i = 1; i < arguments.length; i++) { |
| 30 | var source = arguments[i]; |
| 31 | |
| 32 | for (var key in source) { |
| 33 | if (Object.prototype.hasOwnProperty.call(source, key)) { |
| 34 | target[key] = source[key]; |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | return target; |
| 40 | }; |
| 41 | |
| 42 | return _extends.apply(this, arguments); |
| 43 | } |
| 44 | |
| 45 | function _inheritsLoose(subClass, superClass) { |
| 46 | subClass.prototype = Object.create(superClass.prototype); |
| 47 | subClass.prototype.constructor = subClass; |
| 48 | subClass.__proto__ = superClass; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Helpers to enable Immutable compatibility *without* bringing in |
| 53 | * the 'immutable' package as a dependency. |
| 54 | */ |
| 55 | |
| 56 | /** |
| 57 | * Check if an object is immutable by checking if it has a key specific |
| 58 | * to the immutable library. |
| 59 | * |
| 60 | * @param {any} object |
| 61 | * @return {bool} |
| 62 | */ |
| 63 | function isImmutable(object) { |
| 64 | return !!(object && typeof object.hasOwnProperty === 'function' && (object.hasOwnProperty('__ownerID') || // Immutable.Map |
| 65 | object._map && object._map.hasOwnProperty('__ownerID'))); // Immutable.Record |
| 66 | } |
| 67 | /** |
| 68 | * Denormalize an immutable entity. |
| 69 | * |
| 70 | * @param {Schema} schema |
| 71 | * @param {Immutable.Map|Immutable.Record} input |
| 72 | * @param {function} unvisit |
| 73 | * @param {function} getDenormalizedEntity |
| 74 | * @return {Immutable.Map|Immutable.Record} |
| 75 | */ |
| 76 | |
| 77 | function denormalizeImmutable(schema, input, unvisit) { |
| 78 | return Object.keys(schema).reduce(function (object, key) { |
| 79 | // Immutable maps cast keys to strings on write so we need to ensure |
| 80 | // we're accessing them using string keys. |
| 81 | var stringKey = "" + key; |
| 82 | |
| 83 | if (object.has(stringKey)) { |
| 84 | return object.set(stringKey, unvisit(object.get(stringKey), schema[stringKey])); |
| 85 | } else { |
| 86 | return object; |
| 87 | } |
| 88 | }, input); |
| 89 | } |
| 90 | |
| 91 | var getDefaultGetId = function getDefaultGetId(idAttribute) { |
| 92 | return function (input) { |
| 93 | return isImmutable(input) ? input.get(idAttribute) : input[idAttribute]; |
| 94 | }; |
| 95 | }; |
| 96 | |
| 97 | var EntitySchema = /*#__PURE__*/function () { |
| 98 | function EntitySchema(key, definition, options) { |
| 99 | if (definition === void 0) { |
| 100 | definition = {}; |
| 101 | } |
| 102 | |
| 103 | if (options === void 0) { |
| 104 | options = {}; |
| 105 | } |
| 106 | |
| 107 | if (!key || typeof key !== 'string') { |
| 108 | throw new Error("Expected a string key for Entity, but found " + key + "."); |
| 109 | } |
| 110 | |
| 111 | var _options = options, |
| 112 | _options$idAttribute = _options.idAttribute, |
| 113 | idAttribute = _options$idAttribute === void 0 ? 'id' : _options$idAttribute, |
| 114 | _options$mergeStrateg = _options.mergeStrategy, |
| 115 | mergeStrategy = _options$mergeStrateg === void 0 ? function (entityA, entityB) { |
| 116 | return _extends({}, entityA, entityB); |
| 117 | } : _options$mergeStrateg, |
| 118 | _options$processStrat = _options.processStrategy, |
| 119 | processStrategy = _options$processStrat === void 0 ? function (input) { |
| 120 | return _extends({}, input); |
| 121 | } : _options$processStrat, |
| 122 | _options$fallbackStra = _options.fallbackStrategy, |
| 123 | fallbackStrategy = _options$fallbackStra === void 0 ? function (key, schema) { |
| 124 | return undefined; |
| 125 | } : _options$fallbackStra; |
| 126 | this._key = key; |
| 127 | this._getId = typeof idAttribute === 'function' ? idAttribute : getDefaultGetId(idAttribute); |
| 128 | this._idAttribute = idAttribute; |
| 129 | this._mergeStrategy = mergeStrategy; |
| 130 | this._processStrategy = processStrategy; |
| 131 | this._fallbackStrategy = fallbackStrategy; |
| 132 | this.define(definition); |
| 133 | } |
| 134 | |
| 135 | var _proto = EntitySchema.prototype; |
| 136 | |
| 137 | _proto.define = function define(definition) { |
| 138 | this.schema = Object.keys(definition).reduce(function (entitySchema, key) { |
| 139 | var _extends2; |
| 140 | |
| 141 | var schema = definition[key]; |
| 142 | return _extends({}, entitySchema, (_extends2 = {}, _extends2[key] = schema, _extends2)); |
| 143 | }, this.schema || {}); |
| 144 | }; |
| 145 | |
| 146 | _proto.getId = function getId(input, parent, key) { |
| 147 | return this._getId(input, parent, key); |
| 148 | }; |
| 149 | |
| 150 | _proto.merge = function merge(entityA, entityB) { |
| 151 | return this._mergeStrategy(entityA, entityB); |
| 152 | }; |
| 153 | |
| 154 | _proto.fallback = function fallback(id, schema) { |
| 155 | return this._fallbackStrategy(id, schema); |
| 156 | }; |
| 157 | |
| 158 | _proto.normalize = function normalize(input, parent, key, visit, addEntity, visitedEntities) { |
| 159 | var _this = this; |
| 160 | |
| 161 | var id = this.getId(input, parent, key); |
| 162 | var entityType = this.key; |
| 163 | |
| 164 | if (!(entityType in visitedEntities)) { |
| 165 | visitedEntities[entityType] = {}; |
| 166 | } |
| 167 | |
| 168 | if (!(id in visitedEntities[entityType])) { |
| 169 | visitedEntities[entityType][id] = []; |
| 170 | } |
| 171 | |
| 172 | if (visitedEntities[entityType][id].some(function (entity) { |
| 173 | return entity === input; |
| 174 | })) { |
| 175 | return id; |
| 176 | } |
| 177 | |
| 178 | visitedEntities[entityType][id].push(input); |
| 179 | |
| 180 | var processedEntity = this._processStrategy(input, parent, key); |
| 181 | |
| 182 | Object.keys(this.schema).forEach(function (key) { |
| 183 | if (processedEntity.hasOwnProperty(key) && typeof processedEntity[key] === 'object') { |
| 184 | var schema = _this.schema[key]; |
| 185 | var resolvedSchema = typeof schema === 'function' ? schema(input) : schema; |
| 186 | processedEntity[key] = visit(processedEntity[key], processedEntity, key, resolvedSchema, addEntity, visitedEntities); |
| 187 | } |
| 188 | }); |
| 189 | addEntity(this, processedEntity, input, parent, key); |
| 190 | return id; |
| 191 | }; |
| 192 | |
| 193 | _proto.denormalize = function denormalize(entity, unvisit) { |
| 194 | var _this2 = this; |
| 195 | |
| 196 | if (isImmutable(entity)) { |
| 197 | return denormalizeImmutable(this.schema, entity, unvisit); |
| 198 | } |
| 199 | |
| 200 | Object.keys(this.schema).forEach(function (key) { |
| 201 | if (entity.hasOwnProperty(key)) { |
| 202 | var schema = _this2.schema[key]; |
| 203 | entity[key] = unvisit(entity[key], schema); |
| 204 | } |
| 205 | }); |
| 206 | return entity; |
| 207 | }; |
| 208 | |
| 209 | _createClass(EntitySchema, [{ |
| 210 | key: "key", |
| 211 | get: function get() { |
| 212 | return this._key; |
| 213 | } |
| 214 | }, { |
| 215 | key: "idAttribute", |
| 216 | get: function get() { |
| 217 | return this._idAttribute; |
| 218 | } |
| 219 | }]); |
| 220 | |
| 221 | return EntitySchema; |
| 222 | }(); |
| 223 | |
| 224 | var PolymorphicSchema = /*#__PURE__*/function () { |
| 225 | function PolymorphicSchema(definition, schemaAttribute) { |
| 226 | if (schemaAttribute) { |
| 227 | this._schemaAttribute = typeof schemaAttribute === 'string' ? function (input) { |
| 228 | return input[schemaAttribute]; |
| 229 | } : schemaAttribute; |
| 230 | } |
| 231 | |
| 232 | this.define(definition); |
| 233 | } |
| 234 | |
| 235 | var _proto = PolymorphicSchema.prototype; |
| 236 | |
| 237 | _proto.define = function define(definition) { |
| 238 | this.schema = definition; |
| 239 | }; |
| 240 | |
| 241 | _proto.getSchemaAttribute = function getSchemaAttribute(input, parent, key) { |
| 242 | return !this.isSingleSchema && this._schemaAttribute(input, parent, key); |
| 243 | }; |
| 244 | |
| 245 | _proto.inferSchema = function inferSchema(input, parent, key) { |
| 246 | if (this.isSingleSchema) { |
| 247 | return this.schema; |
| 248 | } |
| 249 | |
| 250 | var attr = this.getSchemaAttribute(input, parent, key); |
| 251 | return this.schema[attr]; |
| 252 | }; |
| 253 | |
| 254 | _proto.normalizeValue = function normalizeValue(value, parent, key, visit, addEntity, visitedEntities) { |
| 255 | var schema = this.inferSchema(value, parent, key); |
| 256 | |
| 257 | if (!schema) { |
| 258 | return value; |
| 259 | } |
| 260 | |
| 261 | var normalizedValue = visit(value, parent, key, schema, addEntity, visitedEntities); |
| 262 | return this.isSingleSchema || normalizedValue === undefined || normalizedValue === null ? normalizedValue : { |
| 263 | id: normalizedValue, |
| 264 | schema: this.getSchemaAttribute(value, parent, key) |
| 265 | }; |
| 266 | }; |
| 267 | |
| 268 | _proto.denormalizeValue = function denormalizeValue(value, unvisit) { |
| 269 | var schemaKey = isImmutable(value) ? value.get('schema') : value.schema; |
| 270 | |
| 271 | if (!this.isSingleSchema && !schemaKey) { |
| 272 | return value; |
| 273 | } |
| 274 | |
| 275 | var id = this.isSingleSchema ? undefined : isImmutable(value) ? value.get('id') : value.id; |
| 276 | var schema = this.isSingleSchema ? this.schema : this.schema[schemaKey]; |
| 277 | return unvisit(id || value, schema); |
| 278 | }; |
| 279 | |
| 280 | _createClass(PolymorphicSchema, [{ |
| 281 | key: "isSingleSchema", |
| 282 | get: function get() { |
| 283 | return !this._schemaAttribute; |
| 284 | } |
| 285 | }]); |
| 286 | |
| 287 | return PolymorphicSchema; |
| 288 | }(); |
| 289 | |
| 290 | var UnionSchema = /*#__PURE__*/function (_PolymorphicSchema) { |
| 291 | _inheritsLoose(UnionSchema, _PolymorphicSchema); |
| 292 | |
| 293 | function UnionSchema(definition, schemaAttribute) { |
| 294 | if (!schemaAttribute) { |
| 295 | throw new Error('Expected option "schemaAttribute" not found on UnionSchema.'); |
| 296 | } |
| 297 | |
| 298 | return _PolymorphicSchema.call(this, definition, schemaAttribute) || this; |
| 299 | } |
| 300 | |
| 301 | var _proto = UnionSchema.prototype; |
| 302 | |
| 303 | _proto.normalize = function normalize(input, parent, key, visit, addEntity, visitedEntities) { |
| 304 | return this.normalizeValue(input, parent, key, visit, addEntity, visitedEntities); |
| 305 | }; |
| 306 | |
| 307 | _proto.denormalize = function denormalize(input, unvisit) { |
| 308 | return this.denormalizeValue(input, unvisit); |
| 309 | }; |
| 310 | |
| 311 | return UnionSchema; |
| 312 | }(PolymorphicSchema); |
| 313 | |
| 314 | var ValuesSchema = /*#__PURE__*/function (_PolymorphicSchema) { |
| 315 | _inheritsLoose(ValuesSchema, _PolymorphicSchema); |
| 316 | |
| 317 | function ValuesSchema() { |
| 318 | return _PolymorphicSchema.apply(this, arguments) || this; |
| 319 | } |
| 320 | |
| 321 | var _proto = ValuesSchema.prototype; |
| 322 | |
| 323 | _proto.normalize = function normalize(input, parent, key, visit, addEntity, visitedEntities) { |
| 324 | var _this = this; |
| 325 | |
| 326 | return Object.keys(input).reduce(function (output, key, index) { |
| 327 | var _extends2; |
| 328 | |
| 329 | var value = input[key]; |
| 330 | return value !== undefined && value !== null ? _extends({}, output, (_extends2 = {}, _extends2[key] = _this.normalizeValue(value, input, key, visit, addEntity, visitedEntities), _extends2)) : output; |
| 331 | }, {}); |
| 332 | }; |
| 333 | |
| 334 | _proto.denormalize = function denormalize(input, unvisit) { |
| 335 | var _this2 = this; |
| 336 | |
| 337 | return Object.keys(input).reduce(function (output, key) { |
| 338 | var _extends3; |
| 339 | |
| 340 | var entityOrId = input[key]; |
| 341 | return _extends({}, output, (_extends3 = {}, _extends3[key] = _this2.denormalizeValue(entityOrId, unvisit), _extends3)); |
| 342 | }, {}); |
| 343 | }; |
| 344 | |
| 345 | return ValuesSchema; |
| 346 | }(PolymorphicSchema); |
| 347 | |
| 348 | var validateSchema = function validateSchema(definition) { |
| 349 | var isArray = Array.isArray(definition); |
| 350 | |
| 351 | if (isArray && definition.length > 1) { |
| 352 | throw new Error("Expected schema definition to be a single schema, but found " + definition.length + "."); |
| 353 | } |
| 354 | |
| 355 | return definition[0]; |
| 356 | }; |
| 357 | |
| 358 | var getValues = function getValues(input) { |
| 359 | return Array.isArray(input) ? input : Object.keys(input).map(function (key) { |
| 360 | return input[key]; |
| 361 | }); |
| 362 | }; |
| 363 | |
| 364 | var normalize = function normalize(schema, input, parent, key, visit, addEntity, visitedEntities) { |
| 365 | schema = validateSchema(schema); |
| 366 | var values = getValues(input); // Special case: Arrays pass *their* parent on to their children, since there |
| 367 | // is not any special information that can be gathered from themselves directly |
| 368 | |
| 369 | return values.map(function (value, index) { |
| 370 | return visit(value, parent, key, schema, addEntity, visitedEntities); |
| 371 | }); |
| 372 | }; |
| 373 | |
| 374 | var ArraySchema = /*#__PURE__*/function (_PolymorphicSchema) { |
| 375 | _inheritsLoose(ArraySchema, _PolymorphicSchema); |
| 376 | |
| 377 | function ArraySchema() { |
| 378 | return _PolymorphicSchema.apply(this, arguments) || this; |
| 379 | } |
| 380 | |
| 381 | var _proto = ArraySchema.prototype; |
| 382 | |
| 383 | _proto.normalize = function normalize(input, parent, key, visit, addEntity, visitedEntities) { |
| 384 | var _this = this; |
| 385 | |
| 386 | var values = getValues(input); |
| 387 | return values.map(function (value, index) { |
| 388 | return _this.normalizeValue(value, parent, key, visit, addEntity, visitedEntities); |
| 389 | }).filter(function (value) { |
| 390 | return value !== undefined && value !== null; |
| 391 | }); |
| 392 | }; |
| 393 | |
| 394 | _proto.denormalize = function denormalize(input, unvisit) { |
| 395 | var _this2 = this; |
| 396 | |
| 397 | return input && input.map ? input.map(function (value) { |
| 398 | return _this2.denormalizeValue(value, unvisit); |
| 399 | }) : input; |
| 400 | }; |
| 401 | |
| 402 | return ArraySchema; |
| 403 | }(PolymorphicSchema); |
| 404 | |
| 405 | var _normalize = function normalize(schema, input, parent, key, visit, addEntity, visitedEntities) { |
| 406 | var object = _extends({}, input); |
| 407 | |
| 408 | Object.keys(schema).forEach(function (key) { |
| 409 | var localSchema = schema[key]; |
| 410 | var resolvedLocalSchema = typeof localSchema === 'function' ? localSchema(input) : localSchema; |
| 411 | var value = visit(input[key], input, key, resolvedLocalSchema, addEntity, visitedEntities); |
| 412 | |
| 413 | if (value === undefined || value === null) { |
| 414 | delete object[key]; |
| 415 | } else { |
| 416 | object[key] = value; |
| 417 | } |
| 418 | }); |
| 419 | return object; |
| 420 | }; |
| 421 | |
| 422 | var _denormalize = function denormalize(schema, input, unvisit) { |
| 423 | if (isImmutable(input)) { |
| 424 | return denormalizeImmutable(schema, input, unvisit); |
| 425 | } |
| 426 | |
| 427 | var object = _extends({}, input); |
| 428 | |
| 429 | Object.keys(schema).forEach(function (key) { |
| 430 | if (object[key] != null) { |
| 431 | object[key] = unvisit(object[key], schema[key]); |
| 432 | } |
| 433 | }); |
| 434 | return object; |
| 435 | }; |
| 436 | |
| 437 | var ObjectSchema = /*#__PURE__*/function () { |
| 438 | function ObjectSchema(definition) { |
| 439 | this.define(definition); |
| 440 | } |
| 441 | |
| 442 | var _proto = ObjectSchema.prototype; |
| 443 | |
| 444 | _proto.define = function define(definition) { |
| 445 | this.schema = Object.keys(definition).reduce(function (entitySchema, key) { |
| 446 | var _extends2; |
| 447 | |
| 448 | var schema = definition[key]; |
| 449 | return _extends({}, entitySchema, (_extends2 = {}, _extends2[key] = schema, _extends2)); |
| 450 | }, this.schema || {}); |
| 451 | }; |
| 452 | |
| 453 | _proto.normalize = function normalize() { |
| 454 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { |
| 455 | args[_key] = arguments[_key]; |
| 456 | } |
| 457 | |
| 458 | return _normalize.apply(void 0, [this.schema].concat(args)); |
| 459 | }; |
| 460 | |
| 461 | _proto.denormalize = function denormalize() { |
| 462 | for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { |
| 463 | args[_key2] = arguments[_key2]; |
| 464 | } |
| 465 | |
| 466 | return _denormalize.apply(void 0, [this.schema].concat(args)); |
| 467 | }; |
| 468 | |
| 469 | return ObjectSchema; |
| 470 | }(); |
| 471 | |
| 472 | var visit = function visit(value, parent, key, schema, addEntity, visitedEntities) { |
| 473 | if (typeof value !== 'object' || !value) { |
| 474 | return value; |
| 475 | } |
| 476 | |
| 477 | if (typeof schema === 'object' && (!schema.normalize || typeof schema.normalize !== 'function')) { |
| 478 | var method = Array.isArray(schema) ? normalize : _normalize; |
| 479 | return method(schema, value, parent, key, visit, addEntity, visitedEntities); |
| 480 | } |
| 481 | |
| 482 | return schema.normalize(value, parent, key, visit, addEntity, visitedEntities); |
| 483 | }; |
| 484 | |
| 485 | var addEntities = function addEntities(entities) { |
| 486 | return function (schema, processedEntity, value, parent, key) { |
| 487 | var schemaKey = schema.key; |
| 488 | var id = schema.getId(value, parent, key); |
| 489 | |
| 490 | if (!(schemaKey in entities)) { |
| 491 | entities[schemaKey] = {}; |
| 492 | } |
| 493 | |
| 494 | var existingEntity = entities[schemaKey][id]; |
| 495 | |
| 496 | if (existingEntity) { |
| 497 | entities[schemaKey][id] = schema.merge(existingEntity, processedEntity); |
| 498 | } else { |
| 499 | entities[schemaKey][id] = processedEntity; |
| 500 | } |
| 501 | }; |
| 502 | }; |
| 503 | |
| 504 | var schema = { |
| 505 | Array: ArraySchema, |
| 506 | Entity: EntitySchema, |
| 507 | Object: ObjectSchema, |
| 508 | Union: UnionSchema, |
| 509 | Values: ValuesSchema |
| 510 | }; |
| 511 | var normalize$1 = function normalize(input, schema) { |
| 512 | if (!input || typeof input !== 'object') { |
| 513 | throw new Error("Unexpected input given to normalize. Expected type to be \"object\", found \"" + (input === null ? 'null' : typeof input) + "\"."); |
| 514 | } |
| 515 | |
| 516 | var entities = {}; |
| 517 | var addEntity = addEntities(entities); |
| 518 | var visitedEntities = {}; |
| 519 | var result = visit(input, input, null, schema, addEntity, visitedEntities); |
| 520 | return { |
| 521 | entities: entities, |
| 522 | result: result |
| 523 | }; |
| 524 | }; |
| 525 | |
| 526 | const entities = { |
| 527 | integration: new schema.Entity('integration'), |
| 528 | account: new schema.Entity('account'), |
| 529 | price: new schema.Entity('price'), |
| 530 | product: new schema.Entity('product'), |
| 531 | product_group: new schema.Entity('product_group'), |
| 532 | purchase: new schema.Entity('purchase'), |
| 533 | payment_method: new schema.Entity('payment_method'), |
| 534 | card: new schema.Entity('card'), |
| 535 | invoice: new schema.Entity('invoice'), |
| 536 | current_period: new schema.Entity('current_period'), |
| 537 | refund: new schema.Entity('refund'), |
| 538 | dispute: new schema.Entity('dispute'), |
| 539 | charge: new schema.Entity('charge'), |
| 540 | coupon: new schema.Entity('coupon'), |
| 541 | promotion: new schema.Entity('promotion'), |
| 542 | order: new schema.Entity('order'), |
| 543 | customer: new schema.Entity('customer'), |
| 544 | subscription: new schema.Entity('subscription'), |
| 545 | product_group: new schema.Entity('product_group'), |
| 546 | }; |
| 547 | |
| 548 | const { |
| 549 | price, |
| 550 | product, |
| 551 | purchase, |
| 552 | payment_method, |
| 553 | card, |
| 554 | invoice, |
| 555 | refund, |
| 556 | charge, |
| 557 | coupon, |
| 558 | promotion, |
| 559 | order, |
| 560 | integration, |
| 561 | customer, |
| 562 | product_group, |
| 563 | subscription, |
| 564 | } = entities; |
| 565 | |
| 566 | product.define({ |
| 567 | prices: { |
| 568 | data: [price], |
| 569 | }, |
| 570 | product_group, |
| 571 | }); |
| 572 | |
| 573 | price.define({ |
| 574 | product, |
| 575 | }); |
| 576 | |
| 577 | invoice.define({ |
| 578 | purchases: { |
| 579 | data: [purchase], |
| 580 | }, |
| 581 | charge, |
| 582 | customer, |
| 583 | subscription, |
| 584 | }); |
| 585 | |
| 586 | order.define({ |
| 587 | purchases: { |
| 588 | data: [purchase], |
| 589 | }, |
| 590 | charge, |
| 591 | customer, |
| 592 | subscription, |
| 593 | }); |
| 594 | |
| 595 | charge.define({ |
| 596 | order, |
| 597 | invoice, |
| 598 | }); |
| 599 | |
| 600 | subscription.define({ |
| 601 | current_period: invoice, |
| 602 | purchase, |
| 603 | price, |
| 604 | payment_method, |
| 605 | order, |
| 606 | customer, |
| 607 | }); |
| 608 | |
| 609 | refund.define({ |
| 610 | charge, |
| 611 | customer, |
| 612 | }); |
| 613 | |
| 614 | purchase.define({ |
| 615 | order, |
| 616 | product, |
| 617 | subscription, |
| 618 | }); |
| 619 | |
| 620 | payment_method.define({ |
| 621 | card, |
| 622 | }); |
| 623 | |
| 624 | coupon.define({ |
| 625 | promotions: { |
| 626 | data: [promotion], |
| 627 | }, |
| 628 | }); |
| 629 | |
| 630 | product_group.define({}); |
| 631 | integration.define({}); |
| 632 | |
| 633 | const normalizeEntities = (data) => { |
| 634 | if (entities?.[data?.[0]?.object]) { |
| 635 | return normalize$1(data, [entities[data?.[0]?.object]]); |
| 636 | } |
| 637 | return {}; |
| 638 | }; |
| 639 | |
| 640 | const getPricesAndProducts = async ({ ids, archived = false }) => { |
| 641 | const prices = (await apiFetch({ |
| 642 | path: addQueryArgs('surecart/v1/prices/', { |
| 643 | ids, |
| 644 | archived, |
| 645 | expand: ['product'], |
| 646 | }), |
| 647 | })); |
| 648 | return normalizePrices(prices); |
| 649 | }; |
| 650 | const normalizePrices = (prices) => { |
| 651 | const { entities } = normalizeEntities(prices); |
| 652 | return { |
| 653 | prices: entities === null || entities === void 0 ? void 0 : entities.price, |
| 654 | products: entities === null || entities === void 0 ? void 0 : entities.product, |
| 655 | }; |
| 656 | }; |
| 657 | |
| 658 | const scPriceChoiceCss = ":host {\n display: block;\n min-width: 0;\n width: 100%;\n}\n\nsc-choice-container {\n container-type: inline-size;\n}\n\n.price-choice {\n display: flex;\n align-items: center;\n justify-content: space-between;\n line-height: var(--sc-line-height-dense);\n gap: var(--sc-spacing-small);\n}\n.price-choice__name {\n color: var(--sc-price-choice-name-color, var(--sc-input-label-color));\n font-size: var(--sc-price-choice-name-size, var(--sc-input-label-font-size-medium));\n font-weight: var(--sc-price-choice-name-font-weight, var(--sc-font-weight-bold));\n text-transform: var(--sc-price-choice-text-transform, var(--sc-input-label-text-transform, none));\n display: -webkit-box;\n display: -moz-box;\n -webkit-box-orient: vertical;\n -moz-box-orient: vertical;\n -webkit-line-clamp: 3;\n -moz-box-lines: 3;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.price-choice__description {\n color: var(--sc-input-help-text-color);\n}\n.price-choice > *:not(:first-child):last-child {\n text-align: right;\n}\n.price-choice__details {\n flex: 1 0 50%;\n display: grid;\n gap: var(--sc-spacing-xxx-small);\n}\n.price-choice__trial, .price-choice__setup-fee, .price-choice__price {\n font-size: var(--sc-font-size-small);\n color: var(--sc-input-help-text-color);\n}\n.price-choice__price {\n color: var(--sc-input-label-color);\n font-weight: var(--sc-price-choice-price-font-weight, var(--sc-font-weight-normal));\n}\n\n@container (max-width: 325px) {\n .price-choice {\n flex-direction: column;\n align-items: flex-start;\n gap: var(--sc-spacing-xx-small);\n }\n .price-choice > *:not(:first-child):last-child {\n text-align: initial;\n }\n}"; |
| 659 | const ScPriceChoiceStyle0 = scPriceChoiceCss; |
| 660 | |
| 661 | const ScPriceChoice = class { |
| 662 | constructor(hostRef) { |
| 663 | registerInstance(this, hostRef); |
| 664 | this.scUpdateLineItem = createEvent(this, "scUpdateLineItem", 7); |
| 665 | this.scRemoveLineItem = createEvent(this, "scRemoveLineItem", 7); |
| 666 | this.scAddEntities = createEvent(this, "scAddEntities", 7); |
| 667 | this.priceId = undefined; |
| 668 | this.price = undefined; |
| 669 | this.product = undefined; |
| 670 | this.loading = false; |
| 671 | this.label = undefined; |
| 672 | this.showLabel = true; |
| 673 | this.showPrice = true; |
| 674 | this.showControl = true; |
| 675 | this.description = undefined; |
| 676 | this.prices = {}; |
| 677 | this.products = {}; |
| 678 | this.order = undefined; |
| 679 | this.quantity = 1; |
| 680 | this.type = undefined; |
| 681 | this.checked = false; |
| 682 | this.error = undefined; |
| 683 | this.isAdHoc = undefined; |
| 684 | this.blank = false; |
| 685 | this.errorMessage = undefined; |
| 686 | this.adHocErrorMessage = undefined; |
| 687 | } |
| 688 | /** Refetch if price changes */ |
| 689 | handlePriceIdChage() { |
| 690 | var _a; |
| 691 | if (this.price && ((_a = this.price) === null || _a === void 0 ? void 0 : _a.id) === this.priceId) |
| 692 | return; |
| 693 | this.fetchPriceWithProduct(); |
| 694 | } |
| 695 | /** Keep price up to date. */ |
| 696 | handlePricesChange() { |
| 697 | var _a, _b, _c; |
| 698 | if (!Object.keys(this.prices || {}).length || !Object.keys(this.products || {}).length) |
| 699 | return; |
| 700 | this.price = (_a = this === null || this === void 0 ? void 0 : this.prices) === null || _a === void 0 ? void 0 : _a[this.priceId]; |
| 701 | this.product = (_b = this === null || this === void 0 ? void 0 : this.products) === null || _b === void 0 ? void 0 : _b[(_c = this === null || this === void 0 ? void 0 : this.price) === null || _c === void 0 ? void 0 : _c.product]; |
| 702 | } |
| 703 | handlePriseChange() { |
| 704 | var _a; |
| 705 | this.isAdHoc = (_a = this === null || this === void 0 ? void 0 : this.price) === null || _a === void 0 ? void 0 : _a.ad_hoc; |
| 706 | } |
| 707 | handleErrorsChange() { |
| 708 | var _a; |
| 709 | const error = (((_a = this === null || this === void 0 ? void 0 : this.error) === null || _a === void 0 ? void 0 : _a.additional_errors) || []).find(error => { var _a; return ((_a = error === null || error === void 0 ? void 0 : error.data) === null || _a === void 0 ? void 0 : _a.attribute) === 'line_items.ad_hoc_amount'; }); |
| 710 | this.adHocErrorMessage = (error === null || error === void 0 ? void 0 : error.message) ? error === null || error === void 0 ? void 0 : error.message : ''; |
| 711 | } |
| 712 | handleCheckedChange() { |
| 713 | var _a; |
| 714 | if (((_a = this.price) === null || _a === void 0 ? void 0 : _a.ad_hoc) && this.choice.checked) { |
| 715 | setTimeout(() => { |
| 716 | this.adHocInput.triggerFocus(); |
| 717 | }, 50); |
| 718 | return; |
| 719 | } |
| 720 | } |
| 721 | /** Fetch on load */ |
| 722 | componentWillLoad() { |
| 723 | if (!this.price) { |
| 724 | this.fetchPriceWithProduct(); |
| 725 | } |
| 726 | } |
| 727 | /** Fetch prices and products */ |
| 728 | async fetchPriceWithProduct() { |
| 729 | if (!this.priceId) |
| 730 | return; |
| 731 | try { |
| 732 | this.loading = true; |
| 733 | const { products, prices } = await getPricesAndProducts({ |
| 734 | archived: false, |
| 735 | ids: [this.priceId], |
| 736 | }); |
| 737 | // add to central store. |
| 738 | this.scAddEntities.emit({ prices, products }); |
| 739 | } |
| 740 | catch (err) { |
| 741 | } |
| 742 | finally { |
| 743 | this.loading = false; |
| 744 | } |
| 745 | } |
| 746 | /** Is this price in the checkout session. */ |
| 747 | isInOrder() { |
| 748 | return isPriceInOrder(this.price, this.order); |
| 749 | } |
| 750 | /** Is this checked */ |
| 751 | isChecked() { |
| 752 | return this.isInOrder(); |
| 753 | } |
| 754 | onChangeAdHoc(e) { |
| 755 | this.scUpdateLineItem.emit({ price_id: this.priceId, quantity: this.quantity, ad_hoc_amount: e.target.value }); |
| 756 | } |
| 757 | getLineItem() { |
| 758 | var _a, _b; |
| 759 | return (((_b = (_a = this.order) === null || _a === void 0 ? void 0 : _a.line_items) === null || _b === void 0 ? void 0 : _b.data) || []).find(lineItem => lineItem.price.id === this.priceId); |
| 760 | } |
| 761 | /** Show we show the ad hoc price box */ |
| 762 | showAdHoc() { |
| 763 | var _a, _b; |
| 764 | if (!((_a = this.price) === null || _a === void 0 ? void 0 : _a.ad_hoc)) { |
| 765 | return false; |
| 766 | } |
| 767 | if (this.isInOrder()) { |
| 768 | return true; |
| 769 | } |
| 770 | return (_b = this === null || this === void 0 ? void 0 : this.choice) === null || _b === void 0 ? void 0 : _b.checked; |
| 771 | } |
| 772 | renderEmpty() { |
| 773 | var _a; |
| 774 | if ((_a = window === null || window === void 0 ? void 0 : window.wp) === null || _a === void 0 ? void 0 : _a.blocks) { |
| 775 | return (h("sc-alert", { type: "danger", open: true, style: { margin: '0px' } }, wp.i18n.__('This product has been archived.', 'surecart'))); |
| 776 | } |
| 777 | return h(Host, { style: { display: 'none' } }); |
| 778 | } |
| 779 | renderPrice() { |
| 780 | var _a; |
| 781 | return (h(Fragment, null, (_a = this.price) === null || _a === void 0 ? void 0 : |
| 782 | _a.display_amount, intervalString(this.price, { |
| 783 | showOnce: true, |
| 784 | abbreviate: true, |
| 785 | labels: { |
| 786 | interval: '/', |
| 787 | period: |
| 788 | /** translators: used as in time period: "for 3 months" */ |
| 789 | wp.i18n.__('for', 'surecart'), |
| 790 | }, |
| 791 | }))); |
| 792 | } |
| 793 | render() { |
| 794 | var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; |
| 795 | if (this.loading) { |
| 796 | return (h("sc-choice-container", { showControl: this.showControl, name: "loading", disabled: true }, h("div", { class: "price-choice" }, h("sc-skeleton", { style: { width: '60px', display: 'inline-block' } }), h("sc-skeleton", { style: { width: '80px', display: 'inline-block' } })))); |
| 797 | } |
| 798 | // we need an active price. |
| 799 | if (!((_a = this === null || this === void 0 ? void 0 : this.price) === null || _a === void 0 ? void 0 : _a.id) || ((_b = this.price) === null || _b === void 0 ? void 0 : _b.archived)) |
| 800 | return this.renderEmpty(); |
| 801 | // product needs to be active |
| 802 | if ((_c = this.product) === null || _c === void 0 ? void 0 : _c.archived) { |
| 803 | return this.renderEmpty(); |
| 804 | } |
| 805 | return (h("sc-choice-container", { ref: el => (this.choice = el), value: this.priceId, type: this.type, showControl: this.showControl, checked: this.isChecked() }, h("div", { class: "price-choice" }, this.showLabel && (h("div", { class: "price-choice__title" }, h("div", { class: "price-choice__name" }, this.label || ((_d = this === null || this === void 0 ? void 0 : this.price) === null || _d === void 0 ? void 0 : _d.name) || ((_e = this === null || this === void 0 ? void 0 : this.product) === null || _e === void 0 ? void 0 : _e.name)), !!this.description && h("div", { class: "price-choice__description" }, this.description))), this.showPrice && (h("div", { class: "price-choice__details" }, h("div", { class: "price-choice__price" }, ((_f = this.price) === null || _f === void 0 ? void 0 : _f.ad_hoc) ? (wp.i18n.__('Custom Amount', 'surecart')) : (h(Fragment, null, (_g = this.price) === null || _g === void 0 ? void 0 : |
| 806 | _g.display_amount, intervalString(this.price, { |
| 807 | showOnce: true, |
| 808 | abbreviate: true, |
| 809 | labels: { |
| 810 | interval: '/', |
| 811 | period: |
| 812 | /** translators: used as in time period: "for 3 months" */ |
| 813 | wp.i18n.__('for', 'surecart'), |
| 814 | }, |
| 815 | })))), !!this.price.trial_duration_days && (h("div", { class: "price-choice__trial" }, wp.i18n.sprintf(wp.i18n._n('Starting in %s day', 'Starting in %s days', this.price.trial_duration_days, 'surecart'), this.price.trial_duration_days))), !!this.price.setup_fee_enabled && ((_h = this.price) === null || _h === void 0 ? void 0 : _h.setup_fee_amount) && (h("div", { class: "price-choice__setup-fee" }, (_j = this.price) === null || _j === void 0 ? void 0 : |
| 816 | _j.setup_fee_display_amount, ' ', ((_k = this.price) === null || _k === void 0 ? void 0 : _k.setup_fee_name) || (((_l = this.price) === null || _l === void 0 ? void 0 : _l.setup_fee_amount) < 0 ? wp.i18n.__('Discount', 'surecart') : wp.i18n.__('Setup Fee', 'surecart'))))))))); |
| 817 | } |
| 818 | static get watchers() { return { |
| 819 | "priceId": ["handlePriceIdChage"], |
| 820 | "prices": ["handlePricesChange"], |
| 821 | "products": ["handlePricesChange"], |
| 822 | "price": ["handlePriseChange"], |
| 823 | "error": ["handleErrorsChange"], |
| 824 | "checked": ["handleCheckedChange"] |
| 825 | }; } |
| 826 | }; |
| 827 | openWormhole(ScPriceChoice, ['prices', 'products', 'order', 'error'], false); |
| 828 | ScPriceChoice.style = ScPriceChoiceStyle0; |
| 829 | |
| 830 | export { ScPriceChoice as sc_price_choice }; |
| 831 | |
| 832 | //# sourceMappingURL=sc-price-choice.entry.js.map |