MockProcessor-ad11752f.js
2 months ago
MockProcessor-ad11752f.js.map
2 months ago
add-query-args-49dcb630.js
1 year ago
add-query-args-49dcb630.js.map
1 year ago
address-7404695f.js
4 months ago
address-7404695f.js.map
4 months ago
animation-registry-b597d2f4.js
3 months ago
animation-registry-b597d2f4.js.map
3 months ago
app-globals-464bf4c9.js
2 months ago
app-globals-464bf4c9.js.map
2 months ago
consumer-b58230e6.js
2 months ago
consumer-b58230e6.js.map
2 months ago
currency-71fce0f0.js
1 year ago
currency-71fce0f0.js.map
1 year ago
error-66b4ae42.js
1 week ago
error-66b4ae42.js.map
1 week ago
fetch-5e8dc1d5.js
1 month ago
fetch-5e8dc1d5.js.map
1 month ago
floating-ui.dom.esm-7fad5c49.js
6 months ago
floating-ui.dom.esm-7fad5c49.js.map
6 months ago
form-data-0da9940f.js
1 year ago
form-data-0da9940f.js.map
1 year ago
functions-033a6a55.js
3 months ago
functions-033a6a55.js.map
3 months ago
geo-permission-8128c254.js
1 month ago
geo-permission-8128c254.js.map
1 month ago
getters-4e5fc4d4.js
1 week ago
getters-4e5fc4d4.js.map
1 week ago
getters-68a0d178.js
2 months ago
getters-68a0d178.js.map
2 months ago
getters-bc65a40b.js
2 months ago
getters-bc65a40b.js.map
2 months ago
getters-c3cd6c93.js
1 week ago
getters-c3cd6c93.js.map
1 week ago
getters-d68c08ed.js
2 months ago
getters-d68c08ed.js.map
2 months ago
google-5d965da2.js
1 week ago
google-5d965da2.js.map
1 week ago
google-8dbad1a6.js
1 week ago
google-8dbad1a6.js.map
1 week ago
google-maps-8b4e4fed.js
1 day ago
google-maps-8b4e4fed.js.map
1 day ago
index-7ced8198.js
2 months ago
index-7ced8198.js.map
2 months ago
index-a4a4f390.js
1 month ago
index-a4a4f390.js.map
1 month ago
index-adacfa36.js
1 year ago
index-adacfa36.js.map
1 year ago
index-be4abba1.js
2 months ago
index-be4abba1.js.map
2 months ago
index-c2d0eb49.js
1 week ago
index-c2d0eb49.js.map
1 week ago
index-c3de642f.js
2 months ago
index-c3de642f.js.map
2 months ago
index-f3933112.js
1 month ago
index-f3933112.js.map
1 month ago
index-fb76df07.js
2 years ago
index-fb76df07.js.map
2 years ago
index.cjs.js
1 week ago
index.cjs.js.map
1 month ago
inline-aa15f113.js
1 year ago
inline-aa15f113.js.map
1 year ago
lazy-2b509fa7.js
1 year ago
lazy-2b509fa7.js.map
1 year ago
library-08bc52a5.js
2 months ago
library-08bc52a5.js.map
2 months ago
loader.cjs.js
1 day ago
loader.cjs.js.map
1 year ago
media-43b85f3d.js
1 year ago
media-43b85f3d.js.map
1 year ago
mutations-463da571.js
1 week ago
mutations-463da571.js.map
1 week ago
mutations-627c79a0.js
1 week ago
mutations-627c79a0.js.map
1 week ago
mutations-98f05402.js
1 week ago
mutations-98f05402.js.map
1 week ago
mutations-d5d6ddf1.js
2 months ago
mutations-d5d6ddf1.js.map
2 months ago
page-align-5a2ab493.js
1 year ago
page-align-5a2ab493.js.map
1 year ago
price-da3cab3d.js
4 months ago
price-da3cab3d.js.map
4 months ago
pure-bd6f0a6e.js
1 year ago
pure-bd6f0a6e.js.map
1 year ago
quantity-aa458329.js
3 months ago
quantity-aa458329.js.map
3 months ago
razorpay-88fe8897.js
3 months ago
razorpay-88fe8897.js.map
3 months ago
remove-query-args-b57e8cd3.js
1 year ago
remove-query-args-b57e8cd3.js.map
1 year ago
sc-address_5.cjs.entry.js
1 day ago
sc-address_5.cjs.entry.js.map
1 day ago
sc-alert.cjs.entry.js
1 month ago
sc-alert.cjs.entry.js.map
1 year ago
sc-avatar_2.cjs.entry.js
1 week ago
sc-avatar_2.cjs.entry.js.map
1 month ago
sc-badge-notice.cjs.entry.js
1 month ago
sc-badge-notice.cjs.entry.js.map
1 year ago
sc-block-ui.cjs.entry.js
1 month ago
sc-block-ui.cjs.entry.js.map
5 months ago
sc-breadcrumb.cjs.entry.js
1 month ago
sc-breadcrumb.cjs.entry.js.map
1 year ago
sc-breadcrumbs.cjs.entry.js
1 month ago
sc-breadcrumbs.cjs.entry.js.map
1 year ago
sc-button-group.cjs.entry.js
1 month ago
sc-button-group.cjs.entry.js.map
1 year ago
sc-button_6.cjs.entry.js
1 month ago
sc-button_6.cjs.entry.js.map
1 month ago
sc-cancel-dialog_3.cjs.entry.js
1 month ago
sc-cancel-dialog_3.cjs.entry.js.map
1 month ago
sc-cancel-discount_4.cjs.entry.js
1 month ago
sc-cancel-discount_4.cjs.entry.js.map
2 months ago
sc-card_2.cjs.entry.js
1 month ago
sc-card_2.cjs.entry.js.map
4 months ago
sc-cart-button.cjs.entry.js
1 week ago
sc-cart-button.cjs.entry.js.map
1 year ago
sc-cart-form-submit.cjs.entry.js
2 months ago
sc-cart-form-submit.cjs.entry.js.map
1 year ago
sc-cart-form.cjs.entry.js
1 week ago
sc-cart-form.cjs.entry.js.map
1 month ago
sc-cart-header.cjs.entry.js
1 week ago
sc-cart-header.cjs.entry.js.map
1 year ago
sc-cart-icon.cjs.entry.js
1 week ago
sc-cart-icon.cjs.entry.js.map
1 year ago
sc-cart-loader.cjs.entry.js
1 week ago
sc-cart-loader.cjs.entry.js.map
1 year ago
sc-cart-session-provider_3.cjs.entry.js
1 day ago
sc-cart-session-provider_3.cjs.entry.js.map
1 day ago
sc-cart-submit.cjs.entry.js
2 months ago
sc-cart-submit.cjs.entry.js.map
1 year ago
sc-cart.cjs.entry.js
1 week ago
sc-cart.cjs.entry.js.map
2 months ago
sc-cc-logo_2.cjs.entry.js
1 month ago
sc-cc-logo_2.cjs.entry.js.map
1 month ago
sc-charges-list.cjs.entry.js
1 month ago
sc-charges-list.cjs.entry.js.map
2 months ago
sc-checkout-autofill-provider_11.cjs.entry.js
1 day ago
sc-checkout-autofill-provider_11.cjs.entry.js.map
1 day ago
sc-checkout-form-errors.cjs.entry.js
2 months ago
sc-checkout-form-errors.cjs.entry.js.map
1 year ago
sc-checkout-mollie-payment_3.cjs.entry.js
1 week ago
sc-checkout-mollie-payment_3.cjs.entry.js.map
2 months ago
sc-checkout-product-bundle-component-variants.cjs.entry.js
1 week ago
sc-checkout-product-bundle-component-variants.cjs.entry.js.map
1 month ago
sc-checkout-product-price-variant-selector.cjs.entry.js
1 week ago
sc-checkout-product-price-variant-selector.cjs.entry.js.map
4 weeks ago
sc-checkout.cjs.entry.js
1 week ago
sc-checkout.cjs.entry.js.map
1 month ago
sc-choice-container.cjs.entry.js
1 month ago
sc-choice-container.cjs.entry.js.map
1 year ago
sc-choice.cjs.entry.js
1 month ago
sc-choice.cjs.entry.js.map
1 year ago
sc-choices.cjs.entry.js
1 month ago
sc-choices.cjs.entry.js.map
1 year ago
sc-column_2.cjs.entry.js
1 month ago
sc-column_2.cjs.entry.js.map
1 month ago
sc-compact-address_18.cjs.entry.js
1 day ago
sc-compact-address_18.cjs.entry.js.map
1 month ago
sc-conditional-form.cjs.entry.js
1 week ago
sc-conditional-form.cjs.entry.js.map
2 months ago
sc-consumer.cjs.entry.js
2 months ago
sc-consumer.cjs.entry.js.map
1 year ago
sc-coupon-form.cjs.entry.js
1 week ago
sc-coupon-form.cjs.entry.js.map
5 months ago
sc-custom-order-price-input.cjs.entry.js
1 month ago
sc-custom-order-price-input.cjs.entry.js.map
2 months ago
sc-customer-details.cjs.entry.js
1 month ago
sc-customer-details.cjs.entry.js.map
7 months ago
sc-customer-edit.cjs.entry.js
1 month ago
sc-customer-edit.cjs.entry.js.map
2 months ago
sc-customer-email.cjs.entry.js
1 week ago
sc-customer-email.cjs.entry.js.map
1 month ago
sc-customer-firstname.cjs.entry.js
1 week ago
sc-customer-firstname.cjs.entry.js.map
2 months ago
sc-customer-lastname.cjs.entry.js
1 week ago
sc-customer-lastname.cjs.entry.js.map
2 months ago
sc-customer-name.cjs.entry.js
1 week ago
sc-customer-name.cjs.entry.js.map
2 months ago
sc-dashboard-customer-details.cjs.entry.js
1 month ago
sc-dashboard-customer-details.cjs.entry.js.map
2 months ago
sc-dashboard-downloads-list.cjs.entry.js
1 month ago
sc-dashboard-downloads-list.cjs.entry.js.map
2 months ago
sc-dialog.cjs.entry.js
1 month ago
sc-dialog.cjs.entry.js.map
5 months ago
sc-divider.cjs.entry.js
1 month ago
sc-divider.cjs.entry.js.map
1 year ago
sc-donation-choices.cjs.entry.js
2 months ago
sc-donation-choices.cjs.entry.js.map
1 year ago
sc-downloads-list.cjs.entry.js
1 month ago
sc-downloads-list.cjs.entry.js.map
1 month ago
sc-dropdown_3.cjs.entry.js
1 month ago
sc-dropdown_3.cjs.entry.js.map
6 months ago
sc-empty_3.cjs.entry.js
1 month ago
sc-empty_3.cjs.entry.js.map
4 months ago
sc-express-payment.cjs.entry.js
1 week ago
sc-express-payment.cjs.entry.js.map
3 months ago
sc-feature-demo-banner.cjs.entry.js
1 month ago
sc-feature-demo-banner.cjs.entry.js.map
1 year ago
sc-flex.cjs.entry.js
1 month ago
sc-flex.cjs.entry.js.map
1 year ago
sc-form-control_2.cjs.entry.js
1 month ago
sc-form-control_2.cjs.entry.js.map
2 months ago
sc-form-row.cjs.entry.js
1 month ago
sc-form-row.cjs.entry.js.map
1 year ago
sc-form.cjs.entry.js
1 month ago
sc-form.cjs.entry.js.map
1 year ago
sc-format-bytes.cjs.entry.js
2 months ago
sc-format-bytes.cjs.entry.js.map
1 year ago
sc-format-interval.cjs.entry.js
2 months ago
sc-format-interval.cjs.entry.js.map
1 year ago
sc-format-number.cjs.entry.js
2 months ago
sc-format-number.cjs.entry.js.map
1 year ago
sc-fulfillment-shipping-status-badge.cjs.entry.js
1 day ago
sc-fulfillment-shipping-status-badge.cjs.entry.js.map
1 day ago
sc-fulfillments.cjs.entry.js
1 day ago
sc-fulfillments.cjs.entry.js.map
1 day ago
sc-heading_2.cjs.entry.js
1 month ago
sc-heading_2.cjs.entry.js.map
1 year ago
sc-image-slider.cjs.entry.js
1 month ago
sc-image-slider.cjs.entry.js.map
1 month ago
sc-invoice-status-badge.cjs.entry.js
1 month ago
sc-invoice-status-badge.cjs.entry.js.map
4 months ago
sc-invoices-list.cjs.entry.js
1 month ago
sc-invoices-list.cjs.entry.js.map
2 months ago
sc-license.cjs.entry.js
1 month ago
sc-license.cjs.entry.js.map
2 months ago
sc-licenses-list.cjs.entry.js
1 month ago
sc-licenses-list.cjs.entry.js.map
1 month ago
sc-line-item-bump.cjs.entry.js
1 week ago
sc-line-item-bump.cjs.entry.js.map
1 year ago
sc-line-item-total.cjs.entry.js
1 week ago
sc-line-item-total.cjs.entry.js.map
6 months ago
sc-line-item.cjs.entry.js
1 month ago
sc-line-item.cjs.entry.js.map
1 year ago
sc-line-items-provider.cjs.entry.js
1 month ago
sc-line-items-provider.cjs.entry.js.map
1 year ago
sc-line-items.cjs.entry.js
1 week ago
sc-line-items.cjs.entry.js.map
1 month ago
sc-login-form.cjs.entry.js
1 month ago
sc-login-form.cjs.entry.js.map
2 months ago
sc-manual-payment-method_3.cjs.entry.js
1 month ago
sc-manual-payment-method_3.cjs.entry.js.map
3 months ago
sc-menu-divider.cjs.entry.js
1 month ago
sc-menu-divider.cjs.entry.js.map
1 year ago
sc-menu-label_2.cjs.entry.js
1 day ago
sc-menu-label_2.cjs.entry.js.map
1 day ago
sc-mollie-add-method.cjs.entry.js
1 month ago
sc-mollie-add-method.cjs.entry.js.map
2 months ago
sc-order-confirmation-customer.cjs.entry.js
2 months ago
sc-order-confirmation-customer.cjs.entry.js.map
1 year ago
sc-order-confirmation-details.cjs.entry.js
2 months ago
sc-order-confirmation-details.cjs.entry.js.map
11 months ago
sc-order-confirmation-line-items_2.cjs.entry.js
1 month ago
sc-order-confirmation-line-items_2.cjs.entry.js.map
1 month ago
sc-order-confirmation.cjs.entry.js
1 month ago
sc-order-confirmation.cjs.entry.js.map
2 months ago
sc-order-coupon-form.cjs.entry.js
1 week ago
sc-order-coupon-form.cjs.entry.js.map
2 months ago
sc-order-detail.cjs.entry.js
2 months ago
sc-order-detail.cjs.entry.js.map
1 year ago
sc-order-fulfillment-badge.cjs.entry.js
1 month ago
sc-order-fulfillment-badge.cjs.entry.js.map
4 months ago
sc-order-manual-instructions.cjs.entry.js
2 months ago
sc-order-manual-instructions.cjs.entry.js.map
1 year ago
sc-order-password.cjs.entry.js
2 months ago
sc-order-password.cjs.entry.js.map
1 year ago
sc-order-return-badge.cjs.entry.js
1 month ago
sc-order-return-badge.cjs.entry.js.map
4 months ago
sc-order-shipment-badge.cjs.entry.js
1 day ago
sc-order-shipment-badge.cjs.entry.js.map
1 day ago
sc-order-status-badge.cjs.entry.js
1 month ago
sc-order-status-badge.cjs.entry.js.map
4 months ago
sc-order-submit.cjs.entry.js
1 week ago
sc-order-submit.cjs.entry.js.map
2 months ago
sc-order-summary.cjs.entry.js
1 week ago
sc-order-summary.cjs.entry.js.map
1 month ago
sc-order.cjs.entry.js
1 month ago
sc-order.cjs.entry.js.map
1 month ago
sc-orders-list.cjs.entry.js
1 day ago
sc-orders-list.cjs.entry.js.map
1 day ago
sc-pagination.cjs.entry.js
2 months ago
sc-pagination.cjs.entry.js.map
1 year ago
sc-password-nag.cjs.entry.js
1 month ago
sc-password-nag.cjs.entry.js.map
2 months ago
sc-password.cjs.entry.js
1 month ago
sc-password.cjs.entry.js.map
1 month ago
sc-payment-method-choice_2.cjs.entry.js
1 month ago
sc-payment-method-choice_2.cjs.entry.js.map
1 year ago
sc-payment-method-details.cjs.entry.js
1 month ago
sc-payment-method-details.cjs.entry.js.map
1 year ago
sc-payment-methods-list.cjs.entry.js
1 month ago
sc-payment-methods-list.cjs.entry.js.map
2 months ago
sc-payment.cjs.entry.js
1 week ago
sc-payment.cjs.entry.js.map
3 months ago
sc-paypal-add-method.cjs.entry.js
1 month ago
sc-paypal-add-method.cjs.entry.js.map
2 months ago
sc-paypal-buttons_2.cjs.entry.js
1 week ago
sc-paypal-buttons_2.cjs.entry.js.map
2 months ago
sc-paystack-add-method.cjs.entry.js
1 month ago
sc-paystack-add-method.cjs.entry.js.map
2 months ago
sc-pill-option.cjs.entry.js
1 month ago
sc-pill-option.cjs.entry.js.map
1 year ago
sc-popover.cjs.entry.js
1 month ago
sc-popover.cjs.entry.js.map
6 months ago
sc-premium-tag.cjs.entry.js
1 month ago
sc-premium-tag.cjs.entry.js.map
1 year ago
sc-price-choice-container.cjs.entry.js
1 month ago
sc-price-choice-container.cjs.entry.js.map
1 month ago
sc-price-choice.cjs.entry.js
1 month ago
sc-price-choice.cjs.entry.js.map
2 months ago
sc-price-choices.cjs.entry.js
1 week ago
sc-price-choices.cjs.entry.js.map
1 year ago
sc-price-input.cjs.entry.js
1 month ago
sc-price-input.cjs.entry.js.map
1 year ago
sc-price-range_4.cjs.entry.js
1 month ago
sc-price-range_4.cjs.entry.js.map
1 year ago
sc-price.cjs.entry.js
2 months ago
sc-price.cjs.entry.js.map
11 months ago
sc-product-buy-button.cjs.entry.js
1 week ago
sc-product-buy-button.cjs.entry.js.map
2 months ago
sc-product-donation-amount-choice.cjs.entry.js
1 week ago
sc-product-donation-amount-choice.cjs.entry.js.map
2 months ago
sc-product-donation-choices.cjs.entry.js
1 week ago
sc-product-donation-choices.cjs.entry.js.map
2 months ago
sc-product-donation-custom-amount.cjs.entry.js
1 week ago
sc-product-donation-custom-amount.cjs.entry.js.map
2 months ago
sc-product-item-list.cjs.entry.js
1 week ago
sc-product-item-list.cjs.entry.js.map
2 months ago
sc-product-item.cjs.entry.js
1 month ago
sc-product-item.cjs.entry.js.map
1 year ago
sc-product-pills-variant-option.cjs.entry.js
1 week ago
sc-product-pills-variant-option.cjs.entry.js.map
1 year ago
sc-product-price-choices.cjs.entry.js
1 week ago
sc-product-price-choices.cjs.entry.js.map
1 year ago
sc-product-price-modal.cjs.entry.js
1 week ago
sc-product-price-modal.cjs.entry.js.map
2 months ago
sc-product-price.cjs.entry.js
1 week ago
sc-product-price.cjs.entry.js.map
2 months ago
sc-product-quantity.cjs.entry.js
1 week ago
sc-product-quantity.cjs.entry.js.map
1 year ago
sc-product-selected-price.cjs.entry.js
1 week ago
sc-product-selected-price.cjs.entry.js.map
2 months ago
sc-product-text.cjs.entry.js
1 week ago
sc-product-text.cjs.entry.js.map
1 year ago
sc-provider.cjs.entry.js
2 months ago
sc-provider.cjs.entry.js.map
1 year ago
sc-provisional-banner.cjs.entry.js
1 month ago
sc-provisional-banner.cjs.entry.js.map
11 months ago
sc-purchase-downloads-list.cjs.entry.js
1 month ago
sc-purchase-downloads-list.cjs.entry.js.map
1 month ago
sc-razorpay-add-method.cjs.entry.js
1 month ago
sc-razorpay-add-method.cjs.entry.js.map
2 months ago
sc-recurring-price-choice-container.cjs.entry.js
2 months ago
sc-recurring-price-choice-container.cjs.entry.js.map
1 year ago
sc-review-stars.cjs.entry.js
2 months ago
sc-review-stars.cjs.entry.js.map
6 months ago
sc-rich-text.cjs.entry.js
1 month ago
sc-rich-text.cjs.entry.js.map
1 month ago
sc-skeleton.cjs.entry.js
1 month ago
sc-skeleton.cjs.entry.js.map
1 year ago
sc-spacing.cjs.entry.js
1 month ago
sc-spacing.cjs.entry.js.map
1 year ago
sc-stripe-add-method.cjs.entry.js
1 month ago
sc-stripe-add-method.cjs.entry.js.map
2 months ago
sc-stripe-element.cjs.entry.js
1 week ago
sc-stripe-element.cjs.entry.js.map
2 months ago
sc-stripe-payment-element.cjs.entry.js
1 week ago
sc-stripe-payment-element.cjs.entry.js.map
2 months ago
sc-stripe-payment-request.cjs.entry.js
1 week ago
sc-stripe-payment-request.cjs.entry.js.map
2 months ago
sc-subscription-ad-hoc-confirm.cjs.entry.js
1 month ago
sc-subscription-ad-hoc-confirm.cjs.entry.js.map
6 months ago
sc-subscription-details_2.cjs.entry.js
1 month ago
sc-subscription-details_2.cjs.entry.js.map
1 month ago
sc-subscription-payment-method.cjs.entry.js
1 month ago
sc-subscription-payment-method.cjs.entry.js.map
2 months ago
sc-subscription-payment.cjs.entry.js
1 month ago
sc-subscription-payment.cjs.entry.js.map
2 months ago
sc-subscription-switch.cjs.entry.js
1 month ago
sc-subscription-switch.cjs.entry.js.map
2 months ago
sc-subscription-variation-confirm.cjs.entry.js
1 month ago
sc-subscription-variation-confirm.cjs.entry.js.map
1 year ago
sc-subscription.cjs.entry.js
1 month ago
sc-subscription.cjs.entry.js.map
1 month ago
sc-subscriptions-list.cjs.entry.js
1 month ago
sc-subscriptions-list.cjs.entry.js.map
2 months ago
sc-summary.cjs.entry.js
1 month ago
sc-summary.cjs.entry.js.map
1 year ago
sc-swap.cjs.entry.js
1 week ago
sc-swap.cjs.entry.js.map
2 months ago
sc-switch.cjs.entry.js
1 month ago
sc-switch.cjs.entry.js.map
7 months ago
sc-tab-group.cjs.entry.js
1 month ago
sc-tab-group.cjs.entry.js.map
1 year ago
sc-tab-panel.cjs.entry.js
1 month ago
sc-tab-panel.cjs.entry.js.map
1 year ago
sc-tab.cjs.entry.js
1 month ago
sc-tab.cjs.entry.js.map
1 year ago
sc-table-head.cjs.entry.js
1 month ago
sc-table-head.cjs.entry.js.map
1 year ago
sc-table_3.cjs.entry.js
1 month ago
sc-table_3.cjs.entry.js.map
10 months ago
sc-tag.cjs.entry.js
1 month ago
sc-tag.cjs.entry.js.map
4 months ago
sc-test-mode-info.cjs.entry.js
1 month ago
sc-test-mode-info.cjs.entry.js.map
6 months ago
sc-text.cjs.entry.js
1 month ago
sc-text.cjs.entry.js.map
1 year ago
sc-toggle.cjs.entry.js
1 month ago
sc-toggle.cjs.entry.js.map
1 year ago
sc-toggles.cjs.entry.js
1 month ago
sc-toggles.cjs.entry.js.map
1 year ago
sc-total.cjs.entry.js
1 week ago
sc-total.cjs.entry.js.map
1 year ago
sc-upcoming-invoice.cjs.entry.js
1 month ago
sc-upcoming-invoice.cjs.entry.js.map
2 months ago
sc-upgrade-required.cjs.entry.js
2 months ago
sc-upgrade-required.cjs.entry.js.map
1 year ago
sc-upsell-countdown-timer.cjs.entry.js
1 month ago
sc-upsell-countdown-timer.cjs.entry.js.map
1 year ago
sc-upsell-no-thanks-button.cjs.entry.js
1 week ago
sc-upsell-no-thanks-button.cjs.entry.js.map
2 months ago
sc-upsell-submit-button.cjs.entry.js
1 week ago
sc-upsell-submit-button.cjs.entry.js.map
2 months ago
sc-upsell-totals.cjs.entry.js
1 week ago
sc-upsell-totals.cjs.entry.js.map
2 months ago
sc-upsell.cjs.entry.js
1 week ago
sc-upsell.cjs.entry.js.map
2 months ago
sc-verification-code.cjs.entry.js
1 month ago
sc-verification-code.cjs.entry.js.map
2 months ago
sc-visually-hidden.cjs.entry.js
1 month ago
sc-visually-hidden.cjs.entry.js.map
1 year ago
sc-wordpress-password-edit.cjs.entry.js
1 month ago
sc-wordpress-password-edit.cjs.entry.js.map
2 months ago
sc-wordpress-user-edit.cjs.entry.js
1 month ago
sc-wordpress-user-edit.cjs.entry.js.map
2 months ago
sc-wordpress-user.cjs.entry.js
1 month ago
sc-wordpress-user.cjs.entry.js.map
1 year ago
store-01e8edc2.js
2 months ago
store-01e8edc2.js.map
2 months ago
store-401bdb4d.js
2 months ago
store-401bdb4d.js.map
2 months ago
store-9c215436.js
1 month ago
store-9c215436.js.map
1 month ago
surecart.cjs.js
1 day ago
surecart.cjs.js.map
1 year ago
tax-a4582e73.js
1 year ago
tax-a4582e73.js.map
1 year ago
universe-1db52218.js
2 months ago
universe-1db52218.js.map
2 months ago
util-a15c420c.js
2 months ago
util-a15c420c.js.map
2 months ago
utils-a9d13080.js
3 months ago
utils-a9d13080.js.map
3 months ago
verification-19455819.js
1 month ago
verification-19455819.js.map
1 month ago
watchers-08c6f04b.js
1 week ago
watchers-08c6f04b.js.map
1 week ago
watchers-517825ae.js
2 months ago
watchers-517825ae.js.map
2 months ago
watchers-a136c7bc.js
1 week ago
watchers-a136c7bc.js.map
1 week ago
watchers-b5cd03f1.js
1 week ago
watchers-b5cd03f1.js.map
1 week ago
watchers-c1bcf0a8.js
1 week ago
watchers-c1bcf0a8.js.map
1 week ago
sc-menu-label_2.cjs.entry.js
2115 lines
| 1 | 'use strict'; |
| 2 | |
| 3 | Object.defineProperty(exports, '__esModule', { value: true }); |
| 4 | |
| 5 | const index = require('./index-be4abba1.js'); |
| 6 | const formData = require('./form-data-0da9940f.js'); |
| 7 | const util = require('./util-a15c420c.js'); |
| 8 | |
| 9 | const scMenuLabelCss = ":host{display:block}.menu-label{font-family:var(--sc-font-sans);font-size:var(--sc-font-size-x-small);font-weight:var(--sc-font-weight-semibold);line-height:var(--sc-line-height-normal);letter-spacing:var(--sc-letter-spacing-normal);color:var(--sc-color-gray-500);padding:var(--sc-spacing-small) var(--sc-spacing-large);user-select:none;text-transform:uppercase}"; |
| 10 | const ScMenuLabelStyle0 = scMenuLabelCss; |
| 11 | |
| 12 | const ScMenuLabel = class { |
| 13 | constructor(hostRef) { |
| 14 | index.registerInstance(this, hostRef); |
| 15 | } |
| 16 | render() { |
| 17 | return (index.h("div", { key: 'df374e90e3b6700b7dee08d59b3bb2d95e16d269', part: "base", class: "menu-label" }, index.h("slot", { key: '7f81110eae1ed110080e4edd3fd92e350a85eef4' }))); |
| 18 | } |
| 19 | }; |
| 20 | ScMenuLabel.style = ScMenuLabelStyle0; |
| 21 | |
| 22 | /** |
| 23 | * Fuse.js v6.6.2 - Lightweight fuzzy-search (http://fusejs.io) |
| 24 | * |
| 25 | * Copyright (c) 2022 Kiro Risk (http://kiro.me) |
| 26 | * All Rights Reserved. Apache Software License 2.0 |
| 27 | * |
| 28 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 29 | */ |
| 30 | |
| 31 | function isArray(value) { |
| 32 | return !Array.isArray |
| 33 | ? getTag(value) === '[object Array]' |
| 34 | : Array.isArray(value) |
| 35 | } |
| 36 | |
| 37 | // Adapted from: https://github.com/lodash/lodash/blob/master/.internal/baseToString.js |
| 38 | const INFINITY = 1 / 0; |
| 39 | function baseToString(value) { |
| 40 | // Exit early for strings to avoid a performance hit in some environments. |
| 41 | if (typeof value == 'string') { |
| 42 | return value |
| 43 | } |
| 44 | let result = value + ''; |
| 45 | return result == '0' && 1 / value == -INFINITY ? '-0' : result |
| 46 | } |
| 47 | |
| 48 | function toString(value) { |
| 49 | return value == null ? '' : baseToString(value) |
| 50 | } |
| 51 | |
| 52 | function isString(value) { |
| 53 | return typeof value === 'string' |
| 54 | } |
| 55 | |
| 56 | function isNumber(value) { |
| 57 | return typeof value === 'number' |
| 58 | } |
| 59 | |
| 60 | // Adapted from: https://github.com/lodash/lodash/blob/master/isBoolean.js |
| 61 | function isBoolean(value) { |
| 62 | return ( |
| 63 | value === true || |
| 64 | value === false || |
| 65 | (isObjectLike(value) && getTag(value) == '[object Boolean]') |
| 66 | ) |
| 67 | } |
| 68 | |
| 69 | function isObject(value) { |
| 70 | return typeof value === 'object' |
| 71 | } |
| 72 | |
| 73 | // Checks if `value` is object-like. |
| 74 | function isObjectLike(value) { |
| 75 | return isObject(value) && value !== null |
| 76 | } |
| 77 | |
| 78 | function isDefined(value) { |
| 79 | return value !== undefined && value !== null |
| 80 | } |
| 81 | |
| 82 | function isBlank(value) { |
| 83 | return !value.trim().length |
| 84 | } |
| 85 | |
| 86 | // Gets the `toStringTag` of `value`. |
| 87 | // Adapted from: https://github.com/lodash/lodash/blob/master/.internal/getTag.js |
| 88 | function getTag(value) { |
| 89 | return value == null |
| 90 | ? value === undefined |
| 91 | ? '[object Undefined]' |
| 92 | : '[object Null]' |
| 93 | : Object.prototype.toString.call(value) |
| 94 | } |
| 95 | |
| 96 | const EXTENDED_SEARCH_UNAVAILABLE = 'Extended search is not available'; |
| 97 | |
| 98 | const INCORRECT_INDEX_TYPE = "Incorrect 'index' type"; |
| 99 | |
| 100 | const LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = (key) => |
| 101 | `Invalid value for key ${key}`; |
| 102 | |
| 103 | const PATTERN_LENGTH_TOO_LARGE = (max) => |
| 104 | `Pattern length exceeds max of ${max}.`; |
| 105 | |
| 106 | const MISSING_KEY_PROPERTY = (name) => `Missing ${name} property in key`; |
| 107 | |
| 108 | const INVALID_KEY_WEIGHT_VALUE = (key) => |
| 109 | `Property 'weight' in key '${key}' must be a positive integer`; |
| 110 | |
| 111 | const hasOwn = Object.prototype.hasOwnProperty; |
| 112 | |
| 113 | class KeyStore { |
| 114 | constructor(keys) { |
| 115 | this._keys = []; |
| 116 | this._keyMap = {}; |
| 117 | |
| 118 | let totalWeight = 0; |
| 119 | |
| 120 | keys.forEach((key) => { |
| 121 | let obj = createKey(key); |
| 122 | |
| 123 | totalWeight += obj.weight; |
| 124 | |
| 125 | this._keys.push(obj); |
| 126 | this._keyMap[obj.id] = obj; |
| 127 | |
| 128 | totalWeight += obj.weight; |
| 129 | }); |
| 130 | |
| 131 | // Normalize weights so that their sum is equal to 1 |
| 132 | this._keys.forEach((key) => { |
| 133 | key.weight /= totalWeight; |
| 134 | }); |
| 135 | } |
| 136 | get(keyId) { |
| 137 | return this._keyMap[keyId] |
| 138 | } |
| 139 | keys() { |
| 140 | return this._keys |
| 141 | } |
| 142 | toJSON() { |
| 143 | return JSON.stringify(this._keys) |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | function createKey(key) { |
| 148 | let path = null; |
| 149 | let id = null; |
| 150 | let src = null; |
| 151 | let weight = 1; |
| 152 | let getFn = null; |
| 153 | |
| 154 | if (isString(key) || isArray(key)) { |
| 155 | src = key; |
| 156 | path = createKeyPath(key); |
| 157 | id = createKeyId(key); |
| 158 | } else { |
| 159 | if (!hasOwn.call(key, 'name')) { |
| 160 | throw new Error(MISSING_KEY_PROPERTY('name')) |
| 161 | } |
| 162 | |
| 163 | const name = key.name; |
| 164 | src = name; |
| 165 | |
| 166 | if (hasOwn.call(key, 'weight')) { |
| 167 | weight = key.weight; |
| 168 | |
| 169 | if (weight <= 0) { |
| 170 | throw new Error(INVALID_KEY_WEIGHT_VALUE(name)) |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | path = createKeyPath(name); |
| 175 | id = createKeyId(name); |
| 176 | getFn = key.getFn; |
| 177 | } |
| 178 | |
| 179 | return { path, id, weight, src, getFn } |
| 180 | } |
| 181 | |
| 182 | function createKeyPath(key) { |
| 183 | return isArray(key) ? key : key.split('.') |
| 184 | } |
| 185 | |
| 186 | function createKeyId(key) { |
| 187 | return isArray(key) ? key.join('.') : key |
| 188 | } |
| 189 | |
| 190 | function get(obj, path) { |
| 191 | let list = []; |
| 192 | let arr = false; |
| 193 | |
| 194 | const deepGet = (obj, path, index) => { |
| 195 | if (!isDefined(obj)) { |
| 196 | return |
| 197 | } |
| 198 | if (!path[index]) { |
| 199 | // If there's no path left, we've arrived at the object we care about. |
| 200 | list.push(obj); |
| 201 | } else { |
| 202 | let key = path[index]; |
| 203 | |
| 204 | const value = obj[key]; |
| 205 | |
| 206 | if (!isDefined(value)) { |
| 207 | return |
| 208 | } |
| 209 | |
| 210 | // If we're at the last value in the path, and if it's a string/number/bool, |
| 211 | // add it to the list |
| 212 | if ( |
| 213 | index === path.length - 1 && |
| 214 | (isString(value) || isNumber(value) || isBoolean(value)) |
| 215 | ) { |
| 216 | list.push(toString(value)); |
| 217 | } else if (isArray(value)) { |
| 218 | arr = true; |
| 219 | // Search each item in the array. |
| 220 | for (let i = 0, len = value.length; i < len; i += 1) { |
| 221 | deepGet(value[i], path, index + 1); |
| 222 | } |
| 223 | } else if (path.length) { |
| 224 | // An object. Recurse further. |
| 225 | deepGet(value, path, index + 1); |
| 226 | } |
| 227 | } |
| 228 | }; |
| 229 | |
| 230 | // Backwards compatibility (since path used to be a string) |
| 231 | deepGet(obj, isString(path) ? path.split('.') : path, 0); |
| 232 | |
| 233 | return arr ? list : list[0] |
| 234 | } |
| 235 | |
| 236 | const MatchOptions = { |
| 237 | // Whether the matches should be included in the result set. When `true`, each record in the result |
| 238 | // set will include the indices of the matched characters. |
| 239 | // These can consequently be used for highlighting purposes. |
| 240 | includeMatches: false, |
| 241 | // When `true`, the matching function will continue to the end of a search pattern even if |
| 242 | // a perfect match has already been located in the string. |
| 243 | findAllMatches: false, |
| 244 | // Minimum number of characters that must be matched before a result is considered a match |
| 245 | minMatchCharLength: 1 |
| 246 | }; |
| 247 | |
| 248 | const BasicOptions = { |
| 249 | // When `true`, the algorithm continues searching to the end of the input even if a perfect |
| 250 | // match is found before the end of the same input. |
| 251 | isCaseSensitive: false, |
| 252 | // When true, the matching function will continue to the end of a search pattern even if |
| 253 | includeScore: false, |
| 254 | // List of properties that will be searched. This also supports nested properties. |
| 255 | keys: [], |
| 256 | // Whether to sort the result list, by score |
| 257 | shouldSort: true, |
| 258 | // Default sort function: sort by ascending score, ascending index |
| 259 | sortFn: (a, b) => |
| 260 | a.score === b.score ? (a.idx < b.idx ? -1 : 1) : a.score < b.score ? -1 : 1 |
| 261 | }; |
| 262 | |
| 263 | const FuzzyOptions = { |
| 264 | // Approximately where in the text is the pattern expected to be found? |
| 265 | location: 0, |
| 266 | // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match |
| 267 | // (of both letters and location), a threshold of '1.0' would match anything. |
| 268 | threshold: 0.6, |
| 269 | // Determines how close the match must be to the fuzzy location (specified above). |
| 270 | // An exact letter match which is 'distance' characters away from the fuzzy location |
| 271 | // would score as a complete mismatch. A distance of '0' requires the match be at |
| 272 | // the exact location specified, a threshold of '1000' would require a perfect match |
| 273 | // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold. |
| 274 | distance: 100 |
| 275 | }; |
| 276 | |
| 277 | const AdvancedOptions = { |
| 278 | // When `true`, it enables the use of unix-like search commands |
| 279 | useExtendedSearch: false, |
| 280 | // The get function to use when fetching an object's properties. |
| 281 | // The default will search nested paths *ie foo.bar.baz* |
| 282 | getFn: get, |
| 283 | // When `true`, search will ignore `location` and `distance`, so it won't matter |
| 284 | // where in the string the pattern appears. |
| 285 | // More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score |
| 286 | ignoreLocation: false, |
| 287 | // When `true`, the calculation for the relevance score (used for sorting) will |
| 288 | // ignore the field-length norm. |
| 289 | // More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm |
| 290 | ignoreFieldNorm: false, |
| 291 | // The weight to determine how much field length norm effects scoring. |
| 292 | fieldNormWeight: 1 |
| 293 | }; |
| 294 | |
| 295 | var Config = { |
| 296 | ...BasicOptions, |
| 297 | ...MatchOptions, |
| 298 | ...FuzzyOptions, |
| 299 | ...AdvancedOptions |
| 300 | }; |
| 301 | |
| 302 | const SPACE = /[^ ]+/g; |
| 303 | |
| 304 | // Field-length norm: the shorter the field, the higher the weight. |
| 305 | // Set to 3 decimals to reduce index size. |
| 306 | function norm(weight = 1, mantissa = 3) { |
| 307 | const cache = new Map(); |
| 308 | const m = Math.pow(10, mantissa); |
| 309 | |
| 310 | return { |
| 311 | get(value) { |
| 312 | const numTokens = value.match(SPACE).length; |
| 313 | |
| 314 | if (cache.has(numTokens)) { |
| 315 | return cache.get(numTokens) |
| 316 | } |
| 317 | |
| 318 | // Default function is 1/sqrt(x), weight makes that variable |
| 319 | const norm = 1 / Math.pow(numTokens, 0.5 * weight); |
| 320 | |
| 321 | // In place of `toFixed(mantissa)`, for faster computation |
| 322 | const n = parseFloat(Math.round(norm * m) / m); |
| 323 | |
| 324 | cache.set(numTokens, n); |
| 325 | |
| 326 | return n |
| 327 | }, |
| 328 | clear() { |
| 329 | cache.clear(); |
| 330 | } |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | class FuseIndex { |
| 335 | constructor({ |
| 336 | getFn = Config.getFn, |
| 337 | fieldNormWeight = Config.fieldNormWeight |
| 338 | } = {}) { |
| 339 | this.norm = norm(fieldNormWeight, 3); |
| 340 | this.getFn = getFn; |
| 341 | this.isCreated = false; |
| 342 | |
| 343 | this.setIndexRecords(); |
| 344 | } |
| 345 | setSources(docs = []) { |
| 346 | this.docs = docs; |
| 347 | } |
| 348 | setIndexRecords(records = []) { |
| 349 | this.records = records; |
| 350 | } |
| 351 | setKeys(keys = []) { |
| 352 | this.keys = keys; |
| 353 | this._keysMap = {}; |
| 354 | keys.forEach((key, idx) => { |
| 355 | this._keysMap[key.id] = idx; |
| 356 | }); |
| 357 | } |
| 358 | create() { |
| 359 | if (this.isCreated || !this.docs.length) { |
| 360 | return |
| 361 | } |
| 362 | |
| 363 | this.isCreated = true; |
| 364 | |
| 365 | // List is Array<String> |
| 366 | if (isString(this.docs[0])) { |
| 367 | this.docs.forEach((doc, docIndex) => { |
| 368 | this._addString(doc, docIndex); |
| 369 | }); |
| 370 | } else { |
| 371 | // List is Array<Object> |
| 372 | this.docs.forEach((doc, docIndex) => { |
| 373 | this._addObject(doc, docIndex); |
| 374 | }); |
| 375 | } |
| 376 | |
| 377 | this.norm.clear(); |
| 378 | } |
| 379 | // Adds a doc to the end of the index |
| 380 | add(doc) { |
| 381 | const idx = this.size(); |
| 382 | |
| 383 | if (isString(doc)) { |
| 384 | this._addString(doc, idx); |
| 385 | } else { |
| 386 | this._addObject(doc, idx); |
| 387 | } |
| 388 | } |
| 389 | // Removes the doc at the specified index of the index |
| 390 | removeAt(idx) { |
| 391 | this.records.splice(idx, 1); |
| 392 | |
| 393 | // Change ref index of every subsquent doc |
| 394 | for (let i = idx, len = this.size(); i < len; i += 1) { |
| 395 | this.records[i].i -= 1; |
| 396 | } |
| 397 | } |
| 398 | getValueForItemAtKeyId(item, keyId) { |
| 399 | return item[this._keysMap[keyId]] |
| 400 | } |
| 401 | size() { |
| 402 | return this.records.length |
| 403 | } |
| 404 | _addString(doc, docIndex) { |
| 405 | if (!isDefined(doc) || isBlank(doc)) { |
| 406 | return |
| 407 | } |
| 408 | |
| 409 | let record = { |
| 410 | v: doc, |
| 411 | i: docIndex, |
| 412 | n: this.norm.get(doc) |
| 413 | }; |
| 414 | |
| 415 | this.records.push(record); |
| 416 | } |
| 417 | _addObject(doc, docIndex) { |
| 418 | let record = { i: docIndex, $: {} }; |
| 419 | |
| 420 | // Iterate over every key (i.e, path), and fetch the value at that key |
| 421 | this.keys.forEach((key, keyIndex) => { |
| 422 | let value = key.getFn ? key.getFn(doc) : this.getFn(doc, key.path); |
| 423 | |
| 424 | if (!isDefined(value)) { |
| 425 | return |
| 426 | } |
| 427 | |
| 428 | if (isArray(value)) { |
| 429 | let subRecords = []; |
| 430 | const stack = [{ nestedArrIndex: -1, value }]; |
| 431 | |
| 432 | while (stack.length) { |
| 433 | const { nestedArrIndex, value } = stack.pop(); |
| 434 | |
| 435 | if (!isDefined(value)) { |
| 436 | continue |
| 437 | } |
| 438 | |
| 439 | if (isString(value) && !isBlank(value)) { |
| 440 | let subRecord = { |
| 441 | v: value, |
| 442 | i: nestedArrIndex, |
| 443 | n: this.norm.get(value) |
| 444 | }; |
| 445 | |
| 446 | subRecords.push(subRecord); |
| 447 | } else if (isArray(value)) { |
| 448 | value.forEach((item, k) => { |
| 449 | stack.push({ |
| 450 | nestedArrIndex: k, |
| 451 | value: item |
| 452 | }); |
| 453 | }); |
| 454 | } else ; |
| 455 | } |
| 456 | record.$[keyIndex] = subRecords; |
| 457 | } else if (isString(value) && !isBlank(value)) { |
| 458 | let subRecord = { |
| 459 | v: value, |
| 460 | n: this.norm.get(value) |
| 461 | }; |
| 462 | |
| 463 | record.$[keyIndex] = subRecord; |
| 464 | } |
| 465 | }); |
| 466 | |
| 467 | this.records.push(record); |
| 468 | } |
| 469 | toJSON() { |
| 470 | return { |
| 471 | keys: this.keys, |
| 472 | records: this.records |
| 473 | } |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | function createIndex( |
| 478 | keys, |
| 479 | docs, |
| 480 | { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {} |
| 481 | ) { |
| 482 | const myIndex = new FuseIndex({ getFn, fieldNormWeight }); |
| 483 | myIndex.setKeys(keys.map(createKey)); |
| 484 | myIndex.setSources(docs); |
| 485 | myIndex.create(); |
| 486 | return myIndex |
| 487 | } |
| 488 | |
| 489 | function parseIndex( |
| 490 | data, |
| 491 | { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {} |
| 492 | ) { |
| 493 | const { keys, records } = data; |
| 494 | const myIndex = new FuseIndex({ getFn, fieldNormWeight }); |
| 495 | myIndex.setKeys(keys); |
| 496 | myIndex.setIndexRecords(records); |
| 497 | return myIndex |
| 498 | } |
| 499 | |
| 500 | function computeScore$1( |
| 501 | pattern, |
| 502 | { |
| 503 | errors = 0, |
| 504 | currentLocation = 0, |
| 505 | expectedLocation = 0, |
| 506 | distance = Config.distance, |
| 507 | ignoreLocation = Config.ignoreLocation |
| 508 | } = {} |
| 509 | ) { |
| 510 | const accuracy = errors / pattern.length; |
| 511 | |
| 512 | if (ignoreLocation) { |
| 513 | return accuracy |
| 514 | } |
| 515 | |
| 516 | const proximity = Math.abs(expectedLocation - currentLocation); |
| 517 | |
| 518 | if (!distance) { |
| 519 | // Dodge divide by zero error. |
| 520 | return proximity ? 1.0 : accuracy |
| 521 | } |
| 522 | |
| 523 | return accuracy + proximity / distance |
| 524 | } |
| 525 | |
| 526 | function convertMaskToIndices( |
| 527 | matchmask = [], |
| 528 | minMatchCharLength = Config.minMatchCharLength |
| 529 | ) { |
| 530 | let indices = []; |
| 531 | let start = -1; |
| 532 | let end = -1; |
| 533 | let i = 0; |
| 534 | |
| 535 | for (let len = matchmask.length; i < len; i += 1) { |
| 536 | let match = matchmask[i]; |
| 537 | if (match && start === -1) { |
| 538 | start = i; |
| 539 | } else if (!match && start !== -1) { |
| 540 | end = i - 1; |
| 541 | if (end - start + 1 >= minMatchCharLength) { |
| 542 | indices.push([start, end]); |
| 543 | } |
| 544 | start = -1; |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | // (i-1 - start) + 1 => i - start |
| 549 | if (matchmask[i - 1] && i - start >= minMatchCharLength) { |
| 550 | indices.push([start, i - 1]); |
| 551 | } |
| 552 | |
| 553 | return indices |
| 554 | } |
| 555 | |
| 556 | // Machine word size |
| 557 | const MAX_BITS = 32; |
| 558 | |
| 559 | function search( |
| 560 | text, |
| 561 | pattern, |
| 562 | patternAlphabet, |
| 563 | { |
| 564 | location = Config.location, |
| 565 | distance = Config.distance, |
| 566 | threshold = Config.threshold, |
| 567 | findAllMatches = Config.findAllMatches, |
| 568 | minMatchCharLength = Config.minMatchCharLength, |
| 569 | includeMatches = Config.includeMatches, |
| 570 | ignoreLocation = Config.ignoreLocation |
| 571 | } = {} |
| 572 | ) { |
| 573 | if (pattern.length > MAX_BITS) { |
| 574 | throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS)) |
| 575 | } |
| 576 | |
| 577 | const patternLen = pattern.length; |
| 578 | // Set starting location at beginning text and initialize the alphabet. |
| 579 | const textLen = text.length; |
| 580 | // Handle the case when location > text.length |
| 581 | const expectedLocation = Math.max(0, Math.min(location, textLen)); |
| 582 | // Highest score beyond which we give up. |
| 583 | let currentThreshold = threshold; |
| 584 | // Is there a nearby exact match? (speedup) |
| 585 | let bestLocation = expectedLocation; |
| 586 | |
| 587 | // Performance: only computer matches when the minMatchCharLength > 1 |
| 588 | // OR if `includeMatches` is true. |
| 589 | const computeMatches = minMatchCharLength > 1 || includeMatches; |
| 590 | // A mask of the matches, used for building the indices |
| 591 | const matchMask = computeMatches ? Array(textLen) : []; |
| 592 | |
| 593 | let index; |
| 594 | |
| 595 | // Get all exact matches, here for speed up |
| 596 | while ((index = text.indexOf(pattern, bestLocation)) > -1) { |
| 597 | let score = computeScore$1(pattern, { |
| 598 | currentLocation: index, |
| 599 | expectedLocation, |
| 600 | distance, |
| 601 | ignoreLocation |
| 602 | }); |
| 603 | |
| 604 | currentThreshold = Math.min(score, currentThreshold); |
| 605 | bestLocation = index + patternLen; |
| 606 | |
| 607 | if (computeMatches) { |
| 608 | let i = 0; |
| 609 | while (i < patternLen) { |
| 610 | matchMask[index + i] = 1; |
| 611 | i += 1; |
| 612 | } |
| 613 | } |
| 614 | } |
| 615 | |
| 616 | // Reset the best location |
| 617 | bestLocation = -1; |
| 618 | |
| 619 | let lastBitArr = []; |
| 620 | let finalScore = 1; |
| 621 | let binMax = patternLen + textLen; |
| 622 | |
| 623 | const mask = 1 << (patternLen - 1); |
| 624 | |
| 625 | for (let i = 0; i < patternLen; i += 1) { |
| 626 | // Scan for the best match; each iteration allows for one more error. |
| 627 | // Run a binary search to determine how far from the match location we can stray |
| 628 | // at this error level. |
| 629 | let binMin = 0; |
| 630 | let binMid = binMax; |
| 631 | |
| 632 | while (binMin < binMid) { |
| 633 | const score = computeScore$1(pattern, { |
| 634 | errors: i, |
| 635 | currentLocation: expectedLocation + binMid, |
| 636 | expectedLocation, |
| 637 | distance, |
| 638 | ignoreLocation |
| 639 | }); |
| 640 | |
| 641 | if (score <= currentThreshold) { |
| 642 | binMin = binMid; |
| 643 | } else { |
| 644 | binMax = binMid; |
| 645 | } |
| 646 | |
| 647 | binMid = Math.floor((binMax - binMin) / 2 + binMin); |
| 648 | } |
| 649 | |
| 650 | // Use the result from this iteration as the maximum for the next. |
| 651 | binMax = binMid; |
| 652 | |
| 653 | let start = Math.max(1, expectedLocation - binMid + 1); |
| 654 | let finish = findAllMatches |
| 655 | ? textLen |
| 656 | : Math.min(expectedLocation + binMid, textLen) + patternLen; |
| 657 | |
| 658 | // Initialize the bit array |
| 659 | let bitArr = Array(finish + 2); |
| 660 | |
| 661 | bitArr[finish + 1] = (1 << i) - 1; |
| 662 | |
| 663 | for (let j = finish; j >= start; j -= 1) { |
| 664 | let currentLocation = j - 1; |
| 665 | let charMatch = patternAlphabet[text.charAt(currentLocation)]; |
| 666 | |
| 667 | if (computeMatches) { |
| 668 | // Speed up: quick bool to int conversion (i.e, `charMatch ? 1 : 0`) |
| 669 | matchMask[currentLocation] = +!!charMatch; |
| 670 | } |
| 671 | |
| 672 | // First pass: exact match |
| 673 | bitArr[j] = ((bitArr[j + 1] << 1) | 1) & charMatch; |
| 674 | |
| 675 | // Subsequent passes: fuzzy match |
| 676 | if (i) { |
| 677 | bitArr[j] |= |
| 678 | ((lastBitArr[j + 1] | lastBitArr[j]) << 1) | 1 | lastBitArr[j + 1]; |
| 679 | } |
| 680 | |
| 681 | if (bitArr[j] & mask) { |
| 682 | finalScore = computeScore$1(pattern, { |
| 683 | errors: i, |
| 684 | currentLocation, |
| 685 | expectedLocation, |
| 686 | distance, |
| 687 | ignoreLocation |
| 688 | }); |
| 689 | |
| 690 | // This match will almost certainly be better than any existing match. |
| 691 | // But check anyway. |
| 692 | if (finalScore <= currentThreshold) { |
| 693 | // Indeed it is |
| 694 | currentThreshold = finalScore; |
| 695 | bestLocation = currentLocation; |
| 696 | |
| 697 | // Already passed `loc`, downhill from here on in. |
| 698 | if (bestLocation <= expectedLocation) { |
| 699 | break |
| 700 | } |
| 701 | |
| 702 | // When passing `bestLocation`, don't exceed our current distance from `expectedLocation`. |
| 703 | start = Math.max(1, 2 * expectedLocation - bestLocation); |
| 704 | } |
| 705 | } |
| 706 | } |
| 707 | |
| 708 | // No hope for a (better) match at greater error levels. |
| 709 | const score = computeScore$1(pattern, { |
| 710 | errors: i + 1, |
| 711 | currentLocation: expectedLocation, |
| 712 | expectedLocation, |
| 713 | distance, |
| 714 | ignoreLocation |
| 715 | }); |
| 716 | |
| 717 | if (score > currentThreshold) { |
| 718 | break |
| 719 | } |
| 720 | |
| 721 | lastBitArr = bitArr; |
| 722 | } |
| 723 | |
| 724 | const result = { |
| 725 | isMatch: bestLocation >= 0, |
| 726 | // Count exact matches (those with a score of 0) to be "almost" exact |
| 727 | score: Math.max(0.001, finalScore) |
| 728 | }; |
| 729 | |
| 730 | if (computeMatches) { |
| 731 | const indices = convertMaskToIndices(matchMask, minMatchCharLength); |
| 732 | if (!indices.length) { |
| 733 | result.isMatch = false; |
| 734 | } else if (includeMatches) { |
| 735 | result.indices = indices; |
| 736 | } |
| 737 | } |
| 738 | |
| 739 | return result |
| 740 | } |
| 741 | |
| 742 | function createPatternAlphabet(pattern) { |
| 743 | let mask = {}; |
| 744 | |
| 745 | for (let i = 0, len = pattern.length; i < len; i += 1) { |
| 746 | const char = pattern.charAt(i); |
| 747 | mask[char] = (mask[char] || 0) | (1 << (len - i - 1)); |
| 748 | } |
| 749 | |
| 750 | return mask |
| 751 | } |
| 752 | |
| 753 | class BitapSearch { |
| 754 | constructor( |
| 755 | pattern, |
| 756 | { |
| 757 | location = Config.location, |
| 758 | threshold = Config.threshold, |
| 759 | distance = Config.distance, |
| 760 | includeMatches = Config.includeMatches, |
| 761 | findAllMatches = Config.findAllMatches, |
| 762 | minMatchCharLength = Config.minMatchCharLength, |
| 763 | isCaseSensitive = Config.isCaseSensitive, |
| 764 | ignoreLocation = Config.ignoreLocation |
| 765 | } = {} |
| 766 | ) { |
| 767 | this.options = { |
| 768 | location, |
| 769 | threshold, |
| 770 | distance, |
| 771 | includeMatches, |
| 772 | findAllMatches, |
| 773 | minMatchCharLength, |
| 774 | isCaseSensitive, |
| 775 | ignoreLocation |
| 776 | }; |
| 777 | |
| 778 | this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase(); |
| 779 | |
| 780 | this.chunks = []; |
| 781 | |
| 782 | if (!this.pattern.length) { |
| 783 | return |
| 784 | } |
| 785 | |
| 786 | const addChunk = (pattern, startIndex) => { |
| 787 | this.chunks.push({ |
| 788 | pattern, |
| 789 | alphabet: createPatternAlphabet(pattern), |
| 790 | startIndex |
| 791 | }); |
| 792 | }; |
| 793 | |
| 794 | const len = this.pattern.length; |
| 795 | |
| 796 | if (len > MAX_BITS) { |
| 797 | let i = 0; |
| 798 | const remainder = len % MAX_BITS; |
| 799 | const end = len - remainder; |
| 800 | |
| 801 | while (i < end) { |
| 802 | addChunk(this.pattern.substr(i, MAX_BITS), i); |
| 803 | i += MAX_BITS; |
| 804 | } |
| 805 | |
| 806 | if (remainder) { |
| 807 | const startIndex = len - MAX_BITS; |
| 808 | addChunk(this.pattern.substr(startIndex), startIndex); |
| 809 | } |
| 810 | } else { |
| 811 | addChunk(this.pattern, 0); |
| 812 | } |
| 813 | } |
| 814 | |
| 815 | searchIn(text) { |
| 816 | const { isCaseSensitive, includeMatches } = this.options; |
| 817 | |
| 818 | if (!isCaseSensitive) { |
| 819 | text = text.toLowerCase(); |
| 820 | } |
| 821 | |
| 822 | // Exact match |
| 823 | if (this.pattern === text) { |
| 824 | let result = { |
| 825 | isMatch: true, |
| 826 | score: 0 |
| 827 | }; |
| 828 | |
| 829 | if (includeMatches) { |
| 830 | result.indices = [[0, text.length - 1]]; |
| 831 | } |
| 832 | |
| 833 | return result |
| 834 | } |
| 835 | |
| 836 | // Otherwise, use Bitap algorithm |
| 837 | const { |
| 838 | location, |
| 839 | distance, |
| 840 | threshold, |
| 841 | findAllMatches, |
| 842 | minMatchCharLength, |
| 843 | ignoreLocation |
| 844 | } = this.options; |
| 845 | |
| 846 | let allIndices = []; |
| 847 | let totalScore = 0; |
| 848 | let hasMatches = false; |
| 849 | |
| 850 | this.chunks.forEach(({ pattern, alphabet, startIndex }) => { |
| 851 | const { isMatch, score, indices } = search(text, pattern, alphabet, { |
| 852 | location: location + startIndex, |
| 853 | distance, |
| 854 | threshold, |
| 855 | findAllMatches, |
| 856 | minMatchCharLength, |
| 857 | includeMatches, |
| 858 | ignoreLocation |
| 859 | }); |
| 860 | |
| 861 | if (isMatch) { |
| 862 | hasMatches = true; |
| 863 | } |
| 864 | |
| 865 | totalScore += score; |
| 866 | |
| 867 | if (isMatch && indices) { |
| 868 | allIndices = [...allIndices, ...indices]; |
| 869 | } |
| 870 | }); |
| 871 | |
| 872 | let result = { |
| 873 | isMatch: hasMatches, |
| 874 | score: hasMatches ? totalScore / this.chunks.length : 1 |
| 875 | }; |
| 876 | |
| 877 | if (hasMatches && includeMatches) { |
| 878 | result.indices = allIndices; |
| 879 | } |
| 880 | |
| 881 | return result |
| 882 | } |
| 883 | } |
| 884 | |
| 885 | class BaseMatch { |
| 886 | constructor(pattern) { |
| 887 | this.pattern = pattern; |
| 888 | } |
| 889 | static isMultiMatch(pattern) { |
| 890 | return getMatch(pattern, this.multiRegex) |
| 891 | } |
| 892 | static isSingleMatch(pattern) { |
| 893 | return getMatch(pattern, this.singleRegex) |
| 894 | } |
| 895 | search(/*text*/) {} |
| 896 | } |
| 897 | |
| 898 | function getMatch(pattern, exp) { |
| 899 | const matches = pattern.match(exp); |
| 900 | return matches ? matches[1] : null |
| 901 | } |
| 902 | |
| 903 | // Token: 'file |
| 904 | |
| 905 | class ExactMatch extends BaseMatch { |
| 906 | constructor(pattern) { |
| 907 | super(pattern); |
| 908 | } |
| 909 | static get type() { |
| 910 | return 'exact' |
| 911 | } |
| 912 | static get multiRegex() { |
| 913 | return /^="(.*)"$/ |
| 914 | } |
| 915 | static get singleRegex() { |
| 916 | return /^=(.*)$/ |
| 917 | } |
| 918 | search(text) { |
| 919 | const isMatch = text === this.pattern; |
| 920 | |
| 921 | return { |
| 922 | isMatch, |
| 923 | score: isMatch ? 0 : 1, |
| 924 | indices: [0, this.pattern.length - 1] |
| 925 | } |
| 926 | } |
| 927 | } |
| 928 | |
| 929 | // Token: !fire |
| 930 | |
| 931 | class InverseExactMatch extends BaseMatch { |
| 932 | constructor(pattern) { |
| 933 | super(pattern); |
| 934 | } |
| 935 | static get type() { |
| 936 | return 'inverse-exact' |
| 937 | } |
| 938 | static get multiRegex() { |
| 939 | return /^!"(.*)"$/ |
| 940 | } |
| 941 | static get singleRegex() { |
| 942 | return /^!(.*)$/ |
| 943 | } |
| 944 | search(text) { |
| 945 | const index = text.indexOf(this.pattern); |
| 946 | const isMatch = index === -1; |
| 947 | |
| 948 | return { |
| 949 | isMatch, |
| 950 | score: isMatch ? 0 : 1, |
| 951 | indices: [0, text.length - 1] |
| 952 | } |
| 953 | } |
| 954 | } |
| 955 | |
| 956 | // Token: ^file |
| 957 | |
| 958 | class PrefixExactMatch extends BaseMatch { |
| 959 | constructor(pattern) { |
| 960 | super(pattern); |
| 961 | } |
| 962 | static get type() { |
| 963 | return 'prefix-exact' |
| 964 | } |
| 965 | static get multiRegex() { |
| 966 | return /^\^"(.*)"$/ |
| 967 | } |
| 968 | static get singleRegex() { |
| 969 | return /^\^(.*)$/ |
| 970 | } |
| 971 | search(text) { |
| 972 | const isMatch = text.startsWith(this.pattern); |
| 973 | |
| 974 | return { |
| 975 | isMatch, |
| 976 | score: isMatch ? 0 : 1, |
| 977 | indices: [0, this.pattern.length - 1] |
| 978 | } |
| 979 | } |
| 980 | } |
| 981 | |
| 982 | // Token: !^fire |
| 983 | |
| 984 | class InversePrefixExactMatch extends BaseMatch { |
| 985 | constructor(pattern) { |
| 986 | super(pattern); |
| 987 | } |
| 988 | static get type() { |
| 989 | return 'inverse-prefix-exact' |
| 990 | } |
| 991 | static get multiRegex() { |
| 992 | return /^!\^"(.*)"$/ |
| 993 | } |
| 994 | static get singleRegex() { |
| 995 | return /^!\^(.*)$/ |
| 996 | } |
| 997 | search(text) { |
| 998 | const isMatch = !text.startsWith(this.pattern); |
| 999 | |
| 1000 | return { |
| 1001 | isMatch, |
| 1002 | score: isMatch ? 0 : 1, |
| 1003 | indices: [0, text.length - 1] |
| 1004 | } |
| 1005 | } |
| 1006 | } |
| 1007 | |
| 1008 | // Token: .file$ |
| 1009 | |
| 1010 | class SuffixExactMatch extends BaseMatch { |
| 1011 | constructor(pattern) { |
| 1012 | super(pattern); |
| 1013 | } |
| 1014 | static get type() { |
| 1015 | return 'suffix-exact' |
| 1016 | } |
| 1017 | static get multiRegex() { |
| 1018 | return /^"(.*)"\$$/ |
| 1019 | } |
| 1020 | static get singleRegex() { |
| 1021 | return /^(.*)\$$/ |
| 1022 | } |
| 1023 | search(text) { |
| 1024 | const isMatch = text.endsWith(this.pattern); |
| 1025 | |
| 1026 | return { |
| 1027 | isMatch, |
| 1028 | score: isMatch ? 0 : 1, |
| 1029 | indices: [text.length - this.pattern.length, text.length - 1] |
| 1030 | } |
| 1031 | } |
| 1032 | } |
| 1033 | |
| 1034 | // Token: !.file$ |
| 1035 | |
| 1036 | class InverseSuffixExactMatch extends BaseMatch { |
| 1037 | constructor(pattern) { |
| 1038 | super(pattern); |
| 1039 | } |
| 1040 | static get type() { |
| 1041 | return 'inverse-suffix-exact' |
| 1042 | } |
| 1043 | static get multiRegex() { |
| 1044 | return /^!"(.*)"\$$/ |
| 1045 | } |
| 1046 | static get singleRegex() { |
| 1047 | return /^!(.*)\$$/ |
| 1048 | } |
| 1049 | search(text) { |
| 1050 | const isMatch = !text.endsWith(this.pattern); |
| 1051 | return { |
| 1052 | isMatch, |
| 1053 | score: isMatch ? 0 : 1, |
| 1054 | indices: [0, text.length - 1] |
| 1055 | } |
| 1056 | } |
| 1057 | } |
| 1058 | |
| 1059 | class FuzzyMatch extends BaseMatch { |
| 1060 | constructor( |
| 1061 | pattern, |
| 1062 | { |
| 1063 | location = Config.location, |
| 1064 | threshold = Config.threshold, |
| 1065 | distance = Config.distance, |
| 1066 | includeMatches = Config.includeMatches, |
| 1067 | findAllMatches = Config.findAllMatches, |
| 1068 | minMatchCharLength = Config.minMatchCharLength, |
| 1069 | isCaseSensitive = Config.isCaseSensitive, |
| 1070 | ignoreLocation = Config.ignoreLocation |
| 1071 | } = {} |
| 1072 | ) { |
| 1073 | super(pattern); |
| 1074 | this._bitapSearch = new BitapSearch(pattern, { |
| 1075 | location, |
| 1076 | threshold, |
| 1077 | distance, |
| 1078 | includeMatches, |
| 1079 | findAllMatches, |
| 1080 | minMatchCharLength, |
| 1081 | isCaseSensitive, |
| 1082 | ignoreLocation |
| 1083 | }); |
| 1084 | } |
| 1085 | static get type() { |
| 1086 | return 'fuzzy' |
| 1087 | } |
| 1088 | static get multiRegex() { |
| 1089 | return /^"(.*)"$/ |
| 1090 | } |
| 1091 | static get singleRegex() { |
| 1092 | return /^(.*)$/ |
| 1093 | } |
| 1094 | search(text) { |
| 1095 | return this._bitapSearch.searchIn(text) |
| 1096 | } |
| 1097 | } |
| 1098 | |
| 1099 | // Token: 'file |
| 1100 | |
| 1101 | class IncludeMatch extends BaseMatch { |
| 1102 | constructor(pattern) { |
| 1103 | super(pattern); |
| 1104 | } |
| 1105 | static get type() { |
| 1106 | return 'include' |
| 1107 | } |
| 1108 | static get multiRegex() { |
| 1109 | return /^'"(.*)"$/ |
| 1110 | } |
| 1111 | static get singleRegex() { |
| 1112 | return /^'(.*)$/ |
| 1113 | } |
| 1114 | search(text) { |
| 1115 | let location = 0; |
| 1116 | let index; |
| 1117 | |
| 1118 | const indices = []; |
| 1119 | const patternLen = this.pattern.length; |
| 1120 | |
| 1121 | // Get all exact matches |
| 1122 | while ((index = text.indexOf(this.pattern, location)) > -1) { |
| 1123 | location = index + patternLen; |
| 1124 | indices.push([index, location - 1]); |
| 1125 | } |
| 1126 | |
| 1127 | const isMatch = !!indices.length; |
| 1128 | |
| 1129 | return { |
| 1130 | isMatch, |
| 1131 | score: isMatch ? 0 : 1, |
| 1132 | indices |
| 1133 | } |
| 1134 | } |
| 1135 | } |
| 1136 | |
| 1137 | // ❗Order is important. DO NOT CHANGE. |
| 1138 | const searchers = [ |
| 1139 | ExactMatch, |
| 1140 | IncludeMatch, |
| 1141 | PrefixExactMatch, |
| 1142 | InversePrefixExactMatch, |
| 1143 | InverseSuffixExactMatch, |
| 1144 | SuffixExactMatch, |
| 1145 | InverseExactMatch, |
| 1146 | FuzzyMatch |
| 1147 | ]; |
| 1148 | |
| 1149 | const searchersLen = searchers.length; |
| 1150 | |
| 1151 | // Regex to split by spaces, but keep anything in quotes together |
| 1152 | const SPACE_RE = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/; |
| 1153 | const OR_TOKEN = '|'; |
| 1154 | |
| 1155 | // Return a 2D array representation of the query, for simpler parsing. |
| 1156 | // Example: |
| 1157 | // "^core go$ | rb$ | py$ xy$" => [["^core", "go$"], ["rb$"], ["py$", "xy$"]] |
| 1158 | function parseQuery(pattern, options = {}) { |
| 1159 | return pattern.split(OR_TOKEN).map((item) => { |
| 1160 | let query = item |
| 1161 | .trim() |
| 1162 | .split(SPACE_RE) |
| 1163 | .filter((item) => item && !!item.trim()); |
| 1164 | |
| 1165 | let results = []; |
| 1166 | for (let i = 0, len = query.length; i < len; i += 1) { |
| 1167 | const queryItem = query[i]; |
| 1168 | |
| 1169 | // 1. Handle multiple query match (i.e, once that are quoted, like `"hello world"`) |
| 1170 | let found = false; |
| 1171 | let idx = -1; |
| 1172 | while (!found && ++idx < searchersLen) { |
| 1173 | const searcher = searchers[idx]; |
| 1174 | let token = searcher.isMultiMatch(queryItem); |
| 1175 | if (token) { |
| 1176 | results.push(new searcher(token, options)); |
| 1177 | found = true; |
| 1178 | } |
| 1179 | } |
| 1180 | |
| 1181 | if (found) { |
| 1182 | continue |
| 1183 | } |
| 1184 | |
| 1185 | // 2. Handle single query matches (i.e, once that are *not* quoted) |
| 1186 | idx = -1; |
| 1187 | while (++idx < searchersLen) { |
| 1188 | const searcher = searchers[idx]; |
| 1189 | let token = searcher.isSingleMatch(queryItem); |
| 1190 | if (token) { |
| 1191 | results.push(new searcher(token, options)); |
| 1192 | break |
| 1193 | } |
| 1194 | } |
| 1195 | } |
| 1196 | |
| 1197 | return results |
| 1198 | }) |
| 1199 | } |
| 1200 | |
| 1201 | // These extended matchers can return an array of matches, as opposed |
| 1202 | // to a singl match |
| 1203 | const MultiMatchSet = new Set([FuzzyMatch.type, IncludeMatch.type]); |
| 1204 | |
| 1205 | /** |
| 1206 | * Command-like searching |
| 1207 | * ====================== |
| 1208 | * |
| 1209 | * Given multiple search terms delimited by spaces.e.g. `^jscript .python$ ruby !java`, |
| 1210 | * search in a given text. |
| 1211 | * |
| 1212 | * Search syntax: |
| 1213 | * |
| 1214 | * | Token | Match type | Description | |
| 1215 | * | ----------- | -------------------------- | -------------------------------------- | |
| 1216 | * | `jscript` | fuzzy-match | Items that fuzzy match `jscript` | |
| 1217 | * | `=scheme` | exact-match | Items that are `scheme` | |
| 1218 | * | `'python` | include-match | Items that include `python` | |
| 1219 | * | `!ruby` | inverse-exact-match | Items that do not include `ruby` | |
| 1220 | * | `^java` | prefix-exact-match | Items that start with `java` | |
| 1221 | * | `!^earlang` | inverse-prefix-exact-match | Items that do not start with `earlang` | |
| 1222 | * | `.js$` | suffix-exact-match | Items that end with `.js` | |
| 1223 | * | `!.go$` | inverse-suffix-exact-match | Items that do not end with `.go` | |
| 1224 | * |
| 1225 | * A single pipe character acts as an OR operator. For example, the following |
| 1226 | * query matches entries that start with `core` and end with either`go`, `rb`, |
| 1227 | * or`py`. |
| 1228 | * |
| 1229 | * ``` |
| 1230 | * ^core go$ | rb$ | py$ |
| 1231 | * ``` |
| 1232 | */ |
| 1233 | class ExtendedSearch { |
| 1234 | constructor( |
| 1235 | pattern, |
| 1236 | { |
| 1237 | isCaseSensitive = Config.isCaseSensitive, |
| 1238 | includeMatches = Config.includeMatches, |
| 1239 | minMatchCharLength = Config.minMatchCharLength, |
| 1240 | ignoreLocation = Config.ignoreLocation, |
| 1241 | findAllMatches = Config.findAllMatches, |
| 1242 | location = Config.location, |
| 1243 | threshold = Config.threshold, |
| 1244 | distance = Config.distance |
| 1245 | } = {} |
| 1246 | ) { |
| 1247 | this.query = null; |
| 1248 | this.options = { |
| 1249 | isCaseSensitive, |
| 1250 | includeMatches, |
| 1251 | minMatchCharLength, |
| 1252 | findAllMatches, |
| 1253 | ignoreLocation, |
| 1254 | location, |
| 1255 | threshold, |
| 1256 | distance |
| 1257 | }; |
| 1258 | |
| 1259 | this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase(); |
| 1260 | this.query = parseQuery(this.pattern, this.options); |
| 1261 | } |
| 1262 | |
| 1263 | static condition(_, options) { |
| 1264 | return options.useExtendedSearch |
| 1265 | } |
| 1266 | |
| 1267 | searchIn(text) { |
| 1268 | const query = this.query; |
| 1269 | |
| 1270 | if (!query) { |
| 1271 | return { |
| 1272 | isMatch: false, |
| 1273 | score: 1 |
| 1274 | } |
| 1275 | } |
| 1276 | |
| 1277 | const { includeMatches, isCaseSensitive } = this.options; |
| 1278 | |
| 1279 | text = isCaseSensitive ? text : text.toLowerCase(); |
| 1280 | |
| 1281 | let numMatches = 0; |
| 1282 | let allIndices = []; |
| 1283 | let totalScore = 0; |
| 1284 | |
| 1285 | // ORs |
| 1286 | for (let i = 0, qLen = query.length; i < qLen; i += 1) { |
| 1287 | const searchers = query[i]; |
| 1288 | |
| 1289 | // Reset indices |
| 1290 | allIndices.length = 0; |
| 1291 | numMatches = 0; |
| 1292 | |
| 1293 | // ANDs |
| 1294 | for (let j = 0, pLen = searchers.length; j < pLen; j += 1) { |
| 1295 | const searcher = searchers[j]; |
| 1296 | const { isMatch, indices, score } = searcher.search(text); |
| 1297 | |
| 1298 | if (isMatch) { |
| 1299 | numMatches += 1; |
| 1300 | totalScore += score; |
| 1301 | if (includeMatches) { |
| 1302 | const type = searcher.constructor.type; |
| 1303 | if (MultiMatchSet.has(type)) { |
| 1304 | allIndices = [...allIndices, ...indices]; |
| 1305 | } else { |
| 1306 | allIndices.push(indices); |
| 1307 | } |
| 1308 | } |
| 1309 | } else { |
| 1310 | totalScore = 0; |
| 1311 | numMatches = 0; |
| 1312 | allIndices.length = 0; |
| 1313 | break |
| 1314 | } |
| 1315 | } |
| 1316 | |
| 1317 | // OR condition, so if TRUE, return |
| 1318 | if (numMatches) { |
| 1319 | let result = { |
| 1320 | isMatch: true, |
| 1321 | score: totalScore / numMatches |
| 1322 | }; |
| 1323 | |
| 1324 | if (includeMatches) { |
| 1325 | result.indices = allIndices; |
| 1326 | } |
| 1327 | |
| 1328 | return result |
| 1329 | } |
| 1330 | } |
| 1331 | |
| 1332 | // Nothing was matched |
| 1333 | return { |
| 1334 | isMatch: false, |
| 1335 | score: 1 |
| 1336 | } |
| 1337 | } |
| 1338 | } |
| 1339 | |
| 1340 | const registeredSearchers = []; |
| 1341 | |
| 1342 | function register(...args) { |
| 1343 | registeredSearchers.push(...args); |
| 1344 | } |
| 1345 | |
| 1346 | function createSearcher(pattern, options) { |
| 1347 | for (let i = 0, len = registeredSearchers.length; i < len; i += 1) { |
| 1348 | let searcherClass = registeredSearchers[i]; |
| 1349 | if (searcherClass.condition(pattern, options)) { |
| 1350 | return new searcherClass(pattern, options) |
| 1351 | } |
| 1352 | } |
| 1353 | |
| 1354 | return new BitapSearch(pattern, options) |
| 1355 | } |
| 1356 | |
| 1357 | const LogicalOperator = { |
| 1358 | AND: '$and', |
| 1359 | OR: '$or' |
| 1360 | }; |
| 1361 | |
| 1362 | const KeyType = { |
| 1363 | PATH: '$path', |
| 1364 | PATTERN: '$val' |
| 1365 | }; |
| 1366 | |
| 1367 | const isExpression = (query) => |
| 1368 | !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]); |
| 1369 | |
| 1370 | const isPath = (query) => !!query[KeyType.PATH]; |
| 1371 | |
| 1372 | const isLeaf = (query) => |
| 1373 | !isArray(query) && isObject(query) && !isExpression(query); |
| 1374 | |
| 1375 | const convertToExplicit = (query) => ({ |
| 1376 | [LogicalOperator.AND]: Object.keys(query).map((key) => ({ |
| 1377 | [key]: query[key] |
| 1378 | })) |
| 1379 | }); |
| 1380 | |
| 1381 | // When `auto` is `true`, the parse function will infer and initialize and add |
| 1382 | // the appropriate `Searcher` instance |
| 1383 | function parse(query, options, { auto = true } = {}) { |
| 1384 | const next = (query) => { |
| 1385 | let keys = Object.keys(query); |
| 1386 | |
| 1387 | const isQueryPath = isPath(query); |
| 1388 | |
| 1389 | if (!isQueryPath && keys.length > 1 && !isExpression(query)) { |
| 1390 | return next(convertToExplicit(query)) |
| 1391 | } |
| 1392 | |
| 1393 | if (isLeaf(query)) { |
| 1394 | const key = isQueryPath ? query[KeyType.PATH] : keys[0]; |
| 1395 | |
| 1396 | const pattern = isQueryPath ? query[KeyType.PATTERN] : query[key]; |
| 1397 | |
| 1398 | if (!isString(pattern)) { |
| 1399 | throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key)) |
| 1400 | } |
| 1401 | |
| 1402 | const obj = { |
| 1403 | keyId: createKeyId(key), |
| 1404 | pattern |
| 1405 | }; |
| 1406 | |
| 1407 | if (auto) { |
| 1408 | obj.searcher = createSearcher(pattern, options); |
| 1409 | } |
| 1410 | |
| 1411 | return obj |
| 1412 | } |
| 1413 | |
| 1414 | let node = { |
| 1415 | children: [], |
| 1416 | operator: keys[0] |
| 1417 | }; |
| 1418 | |
| 1419 | keys.forEach((key) => { |
| 1420 | const value = query[key]; |
| 1421 | |
| 1422 | if (isArray(value)) { |
| 1423 | value.forEach((item) => { |
| 1424 | node.children.push(next(item)); |
| 1425 | }); |
| 1426 | } |
| 1427 | }); |
| 1428 | |
| 1429 | return node |
| 1430 | }; |
| 1431 | |
| 1432 | if (!isExpression(query)) { |
| 1433 | query = convertToExplicit(query); |
| 1434 | } |
| 1435 | |
| 1436 | return next(query) |
| 1437 | } |
| 1438 | |
| 1439 | // Practical scoring function |
| 1440 | function computeScore( |
| 1441 | results, |
| 1442 | { ignoreFieldNorm = Config.ignoreFieldNorm } |
| 1443 | ) { |
| 1444 | results.forEach((result) => { |
| 1445 | let totalScore = 1; |
| 1446 | |
| 1447 | result.matches.forEach(({ key, norm, score }) => { |
| 1448 | const weight = key ? key.weight : null; |
| 1449 | |
| 1450 | totalScore *= Math.pow( |
| 1451 | score === 0 && weight ? Number.EPSILON : score, |
| 1452 | (weight || 1) * (ignoreFieldNorm ? 1 : norm) |
| 1453 | ); |
| 1454 | }); |
| 1455 | |
| 1456 | result.score = totalScore; |
| 1457 | }); |
| 1458 | } |
| 1459 | |
| 1460 | function transformMatches(result, data) { |
| 1461 | const matches = result.matches; |
| 1462 | data.matches = []; |
| 1463 | |
| 1464 | if (!isDefined(matches)) { |
| 1465 | return |
| 1466 | } |
| 1467 | |
| 1468 | matches.forEach((match) => { |
| 1469 | if (!isDefined(match.indices) || !match.indices.length) { |
| 1470 | return |
| 1471 | } |
| 1472 | |
| 1473 | const { indices, value } = match; |
| 1474 | |
| 1475 | let obj = { |
| 1476 | indices, |
| 1477 | value |
| 1478 | }; |
| 1479 | |
| 1480 | if (match.key) { |
| 1481 | obj.key = match.key.src; |
| 1482 | } |
| 1483 | |
| 1484 | if (match.idx > -1) { |
| 1485 | obj.refIndex = match.idx; |
| 1486 | } |
| 1487 | |
| 1488 | data.matches.push(obj); |
| 1489 | }); |
| 1490 | } |
| 1491 | |
| 1492 | function transformScore(result, data) { |
| 1493 | data.score = result.score; |
| 1494 | } |
| 1495 | |
| 1496 | function format( |
| 1497 | results, |
| 1498 | docs, |
| 1499 | { |
| 1500 | includeMatches = Config.includeMatches, |
| 1501 | includeScore = Config.includeScore |
| 1502 | } = {} |
| 1503 | ) { |
| 1504 | const transformers = []; |
| 1505 | |
| 1506 | if (includeMatches) transformers.push(transformMatches); |
| 1507 | if (includeScore) transformers.push(transformScore); |
| 1508 | |
| 1509 | return results.map((result) => { |
| 1510 | const { idx } = result; |
| 1511 | |
| 1512 | const data = { |
| 1513 | item: docs[idx], |
| 1514 | refIndex: idx |
| 1515 | }; |
| 1516 | |
| 1517 | if (transformers.length) { |
| 1518 | transformers.forEach((transformer) => { |
| 1519 | transformer(result, data); |
| 1520 | }); |
| 1521 | } |
| 1522 | |
| 1523 | return data |
| 1524 | }) |
| 1525 | } |
| 1526 | |
| 1527 | class Fuse { |
| 1528 | constructor(docs, options = {}, index) { |
| 1529 | this.options = { ...Config, ...options }; |
| 1530 | |
| 1531 | if ( |
| 1532 | this.options.useExtendedSearch && |
| 1533 | !true |
| 1534 | ) { |
| 1535 | throw new Error(EXTENDED_SEARCH_UNAVAILABLE) |
| 1536 | } |
| 1537 | |
| 1538 | this._keyStore = new KeyStore(this.options.keys); |
| 1539 | |
| 1540 | this.setCollection(docs, index); |
| 1541 | } |
| 1542 | |
| 1543 | setCollection(docs, index) { |
| 1544 | this._docs = docs; |
| 1545 | |
| 1546 | if (index && !(index instanceof FuseIndex)) { |
| 1547 | throw new Error(INCORRECT_INDEX_TYPE) |
| 1548 | } |
| 1549 | |
| 1550 | this._myIndex = |
| 1551 | index || |
| 1552 | createIndex(this.options.keys, this._docs, { |
| 1553 | getFn: this.options.getFn, |
| 1554 | fieldNormWeight: this.options.fieldNormWeight |
| 1555 | }); |
| 1556 | } |
| 1557 | |
| 1558 | add(doc) { |
| 1559 | if (!isDefined(doc)) { |
| 1560 | return |
| 1561 | } |
| 1562 | |
| 1563 | this._docs.push(doc); |
| 1564 | this._myIndex.add(doc); |
| 1565 | } |
| 1566 | |
| 1567 | remove(predicate = (/* doc, idx */) => false) { |
| 1568 | const results = []; |
| 1569 | |
| 1570 | for (let i = 0, len = this._docs.length; i < len; i += 1) { |
| 1571 | const doc = this._docs[i]; |
| 1572 | if (predicate(doc, i)) { |
| 1573 | this.removeAt(i); |
| 1574 | i -= 1; |
| 1575 | len -= 1; |
| 1576 | |
| 1577 | results.push(doc); |
| 1578 | } |
| 1579 | } |
| 1580 | |
| 1581 | return results |
| 1582 | } |
| 1583 | |
| 1584 | removeAt(idx) { |
| 1585 | this._docs.splice(idx, 1); |
| 1586 | this._myIndex.removeAt(idx); |
| 1587 | } |
| 1588 | |
| 1589 | getIndex() { |
| 1590 | return this._myIndex |
| 1591 | } |
| 1592 | |
| 1593 | search(query, { limit = -1 } = {}) { |
| 1594 | const { |
| 1595 | includeMatches, |
| 1596 | includeScore, |
| 1597 | shouldSort, |
| 1598 | sortFn, |
| 1599 | ignoreFieldNorm |
| 1600 | } = this.options; |
| 1601 | |
| 1602 | let results = isString(query) |
| 1603 | ? isString(this._docs[0]) |
| 1604 | ? this._searchStringList(query) |
| 1605 | : this._searchObjectList(query) |
| 1606 | : this._searchLogical(query); |
| 1607 | |
| 1608 | computeScore(results, { ignoreFieldNorm }); |
| 1609 | |
| 1610 | if (shouldSort) { |
| 1611 | results.sort(sortFn); |
| 1612 | } |
| 1613 | |
| 1614 | if (isNumber(limit) && limit > -1) { |
| 1615 | results = results.slice(0, limit); |
| 1616 | } |
| 1617 | |
| 1618 | return format(results, this._docs, { |
| 1619 | includeMatches, |
| 1620 | includeScore |
| 1621 | }) |
| 1622 | } |
| 1623 | |
| 1624 | _searchStringList(query) { |
| 1625 | const searcher = createSearcher(query, this.options); |
| 1626 | const { records } = this._myIndex; |
| 1627 | const results = []; |
| 1628 | |
| 1629 | // Iterate over every string in the index |
| 1630 | records.forEach(({ v: text, i: idx, n: norm }) => { |
| 1631 | if (!isDefined(text)) { |
| 1632 | return |
| 1633 | } |
| 1634 | |
| 1635 | const { isMatch, score, indices } = searcher.searchIn(text); |
| 1636 | |
| 1637 | if (isMatch) { |
| 1638 | results.push({ |
| 1639 | item: text, |
| 1640 | idx, |
| 1641 | matches: [{ score, value: text, norm, indices }] |
| 1642 | }); |
| 1643 | } |
| 1644 | }); |
| 1645 | |
| 1646 | return results |
| 1647 | } |
| 1648 | |
| 1649 | _searchLogical(query) { |
| 1650 | |
| 1651 | const expression = parse(query, this.options); |
| 1652 | |
| 1653 | const evaluate = (node, item, idx) => { |
| 1654 | if (!node.children) { |
| 1655 | const { keyId, searcher } = node; |
| 1656 | |
| 1657 | const matches = this._findMatches({ |
| 1658 | key: this._keyStore.get(keyId), |
| 1659 | value: this._myIndex.getValueForItemAtKeyId(item, keyId), |
| 1660 | searcher |
| 1661 | }); |
| 1662 | |
| 1663 | if (matches && matches.length) { |
| 1664 | return [ |
| 1665 | { |
| 1666 | idx, |
| 1667 | item, |
| 1668 | matches |
| 1669 | } |
| 1670 | ] |
| 1671 | } |
| 1672 | |
| 1673 | return [] |
| 1674 | } |
| 1675 | |
| 1676 | const res = []; |
| 1677 | for (let i = 0, len = node.children.length; i < len; i += 1) { |
| 1678 | const child = node.children[i]; |
| 1679 | const result = evaluate(child, item, idx); |
| 1680 | if (result.length) { |
| 1681 | res.push(...result); |
| 1682 | } else if (node.operator === LogicalOperator.AND) { |
| 1683 | return [] |
| 1684 | } |
| 1685 | } |
| 1686 | return res |
| 1687 | }; |
| 1688 | |
| 1689 | const records = this._myIndex.records; |
| 1690 | const resultMap = {}; |
| 1691 | const results = []; |
| 1692 | |
| 1693 | records.forEach(({ $: item, i: idx }) => { |
| 1694 | if (isDefined(item)) { |
| 1695 | let expResults = evaluate(expression, item, idx); |
| 1696 | |
| 1697 | if (expResults.length) { |
| 1698 | // Dedupe when adding |
| 1699 | if (!resultMap[idx]) { |
| 1700 | resultMap[idx] = { idx, item, matches: [] }; |
| 1701 | results.push(resultMap[idx]); |
| 1702 | } |
| 1703 | expResults.forEach(({ matches }) => { |
| 1704 | resultMap[idx].matches.push(...matches); |
| 1705 | }); |
| 1706 | } |
| 1707 | } |
| 1708 | }); |
| 1709 | |
| 1710 | return results |
| 1711 | } |
| 1712 | |
| 1713 | _searchObjectList(query) { |
| 1714 | const searcher = createSearcher(query, this.options); |
| 1715 | const { keys, records } = this._myIndex; |
| 1716 | const results = []; |
| 1717 | |
| 1718 | // List is Array<Object> |
| 1719 | records.forEach(({ $: item, i: idx }) => { |
| 1720 | if (!isDefined(item)) { |
| 1721 | return |
| 1722 | } |
| 1723 | |
| 1724 | let matches = []; |
| 1725 | |
| 1726 | // Iterate over every key (i.e, path), and fetch the value at that key |
| 1727 | keys.forEach((key, keyIndex) => { |
| 1728 | matches.push( |
| 1729 | ...this._findMatches({ |
| 1730 | key, |
| 1731 | value: item[keyIndex], |
| 1732 | searcher |
| 1733 | }) |
| 1734 | ); |
| 1735 | }); |
| 1736 | |
| 1737 | if (matches.length) { |
| 1738 | results.push({ |
| 1739 | idx, |
| 1740 | item, |
| 1741 | matches |
| 1742 | }); |
| 1743 | } |
| 1744 | }); |
| 1745 | |
| 1746 | return results |
| 1747 | } |
| 1748 | _findMatches({ key, value, searcher }) { |
| 1749 | if (!isDefined(value)) { |
| 1750 | return [] |
| 1751 | } |
| 1752 | |
| 1753 | let matches = []; |
| 1754 | |
| 1755 | if (isArray(value)) { |
| 1756 | value.forEach(({ v: text, i: idx, n: norm }) => { |
| 1757 | if (!isDefined(text)) { |
| 1758 | return |
| 1759 | } |
| 1760 | |
| 1761 | const { isMatch, score, indices } = searcher.searchIn(text); |
| 1762 | |
| 1763 | if (isMatch) { |
| 1764 | matches.push({ |
| 1765 | score, |
| 1766 | key, |
| 1767 | value: text, |
| 1768 | idx, |
| 1769 | norm, |
| 1770 | indices |
| 1771 | }); |
| 1772 | } |
| 1773 | }); |
| 1774 | } else { |
| 1775 | const { v: text, n: norm } = value; |
| 1776 | |
| 1777 | const { isMatch, score, indices } = searcher.searchIn(text); |
| 1778 | |
| 1779 | if (isMatch) { |
| 1780 | matches.push({ score, key, value: text, norm, indices }); |
| 1781 | } |
| 1782 | } |
| 1783 | |
| 1784 | return matches |
| 1785 | } |
| 1786 | } |
| 1787 | |
| 1788 | Fuse.version = '6.6.2'; |
| 1789 | Fuse.createIndex = createIndex; |
| 1790 | Fuse.parseIndex = parseIndex; |
| 1791 | Fuse.config = Config; |
| 1792 | |
| 1793 | { |
| 1794 | Fuse.parseQuery = parse; |
| 1795 | } |
| 1796 | |
| 1797 | { |
| 1798 | register(ExtendedSearch); |
| 1799 | } |
| 1800 | |
| 1801 | const scSelectCss = ":host{display:block;--focus-ring:0 0 0 var(--sc-focus-ring-width) var(--sc-focus-ring-color-primary)}.search{margin:var(--sc-spacing-x-small) var(--sc-spacing-x-small) 0 var(--sc-spacing-x-small)}.loading{text-align:center;margin:var(--sc-spacing-small)}.select{font-family:var(--sc-input-font-family);font-weight:var(--sc-font-weight-normal)}sc-dropdown{display:block}.trigger{overflow:hidden;box-sizing:border-box;width:100%;display:flex;align-items:center;justify-content:space-between;width:100%;border-style:solid;border-width:var(--sc-input-border-width);background-color:var(--sc-select-background-color, var(--sc-color-white));border-color:var(--sc-select-border-color, var(--sc-color-gray-300));color:var(--sc-input-color);text-decoration:none;user-select:none;white-space:nowrap;vertical-align:middle;transition: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)) border, var(--sc-input-transition, var(--sc-transition-medium)) box-shadow;cursor:inherit;box-shadow:var(--sc-shadow-small);font-size:var(--sc-button-font-size-medium);min-height:var(--sc-input-height-medium);line-height:calc(var(--sc-input-height-medium) - var(--sc-input-border-width) * 2);border-radius:var(--sc-input-border-radius-medium);padding:0 var(--sc-spacing-medium)}.trigger svg{display:block;width:1em;height:1em}.select.select--focused:not(.select--disabled) .trigger{background-color:var(--sc-input-background-color-focus);border-color:var(--sc-input-border-color-focus);box-shadow:var(--focus-ring);z-index:2}.select--disabled{cursor:not-allowed}.select--disabled sc-dropdown{opacity:0.65}.select__value{overflow:hidden;text-overflow:ellipsis}.select__empty{text-align:center;margin:var(--sc-spacing-small);color:var(--sc-color-gray-400)}.select--placeholder .trigger{color:var(--sc-input-placeholder-color)}.select__hidden-input{position:absolute;opacity:0;padding:0px;margin:0px;pointer-events:none;width:0}.select__suffix-description,.select__description{font-size:var(--sc-input-help-text-font-size-medium);opacity:0.65}.select__caret{transition:transform 0.25s ease;line-height:0}.select--is-open .select__caret{transform:rotate(180deg)}.select--squared .trigger{border-radius:0}.select--squared-top .trigger{border-top-left-radius:0;border-top-right-radius:0}.select--squared-bottom .trigger{border-bottom-left-radius:0;border-bottom-right-radius:0}.select--squared-left .trigger{border-top-left-radius:0;border-bottom-left-radius:0}.select--squared-right .trigger{border-top-right-radius:0;border-bottom-right-radius:0}.choice__icon--image{width:18px;height:18px;object-fit:contain}sc-menu-item.is-unavailable{--sc-menu-item-color:var(--sc-color-gray-500)}"; |
| 1802 | const ScSelectStyle0 = scSelectCss; |
| 1803 | |
| 1804 | let id = 0; |
| 1805 | let itemIndex = 0; |
| 1806 | let arrowFlag = ''; |
| 1807 | const ScSelectDropdown = class { |
| 1808 | constructor(hostRef) { |
| 1809 | index.registerInstance(this, hostRef); |
| 1810 | this.scSearch = index.createEvent(this, "scSearch", 7); |
| 1811 | this.scOpen = index.createEvent(this, "scOpen", 7); |
| 1812 | this.scClose = index.createEvent(this, "scClose", 7); |
| 1813 | this.scBlur = index.createEvent(this, "scBlur", 7); |
| 1814 | this.scFocus = index.createEvent(this, "scFocus", 7); |
| 1815 | this.scChange = index.createEvent(this, "scChange", 7); |
| 1816 | this.scScrollEnd = index.createEvent(this, "scScrollEnd", 7); |
| 1817 | this.inputId = `select-${++id}`; |
| 1818 | this.helpId = `select-help-text-${id}`; |
| 1819 | this.labelId = `select-label-${id}`; |
| 1820 | this.autocomplete = undefined; |
| 1821 | this.placeholder = ''; |
| 1822 | this.searchPlaceholder = ''; |
| 1823 | this.value = ''; |
| 1824 | this.choices = []; |
| 1825 | this.unselect = true; |
| 1826 | this.required = undefined; |
| 1827 | this.loading = undefined; |
| 1828 | this.search = undefined; |
| 1829 | this.closeOnSelect = true; |
| 1830 | this.name = undefined; |
| 1831 | this.help = undefined; |
| 1832 | this.label = undefined; |
| 1833 | this.size = 'medium'; |
| 1834 | this.position = 'bottom-right'; |
| 1835 | this.placement = 'bottom-start'; |
| 1836 | this.invalid = false; |
| 1837 | this.open = undefined; |
| 1838 | this.disabled = undefined; |
| 1839 | this.showParentLabel = true; |
| 1840 | this.hoist = false; |
| 1841 | this.squared = undefined; |
| 1842 | this.squaredBottom = undefined; |
| 1843 | this.squaredTop = undefined; |
| 1844 | this.squaredLeft = undefined; |
| 1845 | this.squaredRight = undefined; |
| 1846 | this.hasFocus = false; |
| 1847 | this.searchTerm = ''; |
| 1848 | this.filteredChoices = []; |
| 1849 | } |
| 1850 | /** Trigger focus on show */ |
| 1851 | handleShow() { |
| 1852 | this.open = true; |
| 1853 | setTimeout(() => { |
| 1854 | this.searchInput && this.searchInput.triggerFocus(); |
| 1855 | }, 50); |
| 1856 | } |
| 1857 | handleHide() { |
| 1858 | this.open = false; |
| 1859 | itemIndex = 0; |
| 1860 | this.scClose.emit(); |
| 1861 | } |
| 1862 | handleBlur() { |
| 1863 | this.hasFocus = false; |
| 1864 | this.scBlur.emit(); |
| 1865 | } |
| 1866 | handleFocus() { |
| 1867 | this.hasFocus = true; |
| 1868 | this.scFocus.emit(); |
| 1869 | } |
| 1870 | /** Get the display value of the item. */ |
| 1871 | displayValue() { |
| 1872 | var _a; |
| 1873 | if (!this.value) |
| 1874 | return false; |
| 1875 | let chosen = this.choices.find(choice => choice.value == this.value); |
| 1876 | let append = ''; |
| 1877 | if (!chosen) { |
| 1878 | if (this.showParentLabel) { |
| 1879 | append = (_a = this.choices.find(choice => { var _a, _b; return (_b = (_a = choice === null || choice === void 0 ? void 0 : choice.choices) === null || _a === void 0 ? void 0 : _a.some) === null || _b === void 0 ? void 0 : _b.call(_a, subChoice => subChoice.value === this.value); })) === null || _a === void 0 ? void 0 : _a.label; |
| 1880 | } |
| 1881 | const subchoices = (this.choices || []).map(choice => choice.choices).flat(); |
| 1882 | chosen = subchoices.find(choice => (choice === null || choice === void 0 ? void 0 : choice.value) == this.value); |
| 1883 | } |
| 1884 | if (chosen) { |
| 1885 | return `${append ? append + ' — ' : ''}${chosen === null || chosen === void 0 ? void 0 : chosen.label}`; |
| 1886 | } |
| 1887 | return false; |
| 1888 | } |
| 1889 | isChecked({ value, checked = false }) { |
| 1890 | if (checked) { |
| 1891 | return true; |
| 1892 | } |
| 1893 | return !!value && this.value === value; |
| 1894 | } |
| 1895 | /** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */ |
| 1896 | async setCustomValidity(message) { |
| 1897 | this.input.setCustomValidity(message); |
| 1898 | this.invalid = !this.input.checkValidity(); |
| 1899 | } |
| 1900 | async reportValidity() { |
| 1901 | return this.input.reportValidity(); |
| 1902 | } |
| 1903 | handleQuery(e) { |
| 1904 | this.searchTerm = e.target.value; |
| 1905 | this.scSearch.emit(this.searchTerm); |
| 1906 | } |
| 1907 | handleSelect(choice) { |
| 1908 | const { value } = choice; |
| 1909 | if (this.value === value && this.unselect) { |
| 1910 | this.value = ''; |
| 1911 | } |
| 1912 | else { |
| 1913 | this.value = value; |
| 1914 | } |
| 1915 | if (this.closeOnSelect) { |
| 1916 | this.searchTerm = ''; |
| 1917 | } |
| 1918 | this.scChange.emit(choice); |
| 1919 | } |
| 1920 | handleInputChange() { |
| 1921 | // Sync autofilled value to component state |
| 1922 | if (!this.input || this.input.value === this.value) |
| 1923 | return; |
| 1924 | const inputValue = this.input.value; |
| 1925 | // Match by value (code) or label (name) since Chrome may autofill either |
| 1926 | const choice = this.choices.find(c => c.value === inputValue || c.label === inputValue); |
| 1927 | if (choice) { |
| 1928 | this.value = choice.value; |
| 1929 | this.scChange.emit(choice); |
| 1930 | } |
| 1931 | } |
| 1932 | handleSearchChange() { |
| 1933 | const fuse = new Fuse(this.choices, { |
| 1934 | keys: ['value', 'label', 'choices.value', 'choices.label'], |
| 1935 | }); |
| 1936 | if (this.searchTerm) { |
| 1937 | const results = fuse.search(this.searchTerm); |
| 1938 | this.filteredChoices = results.map(result => result.item); |
| 1939 | } |
| 1940 | else { |
| 1941 | this.filteredChoices = this.choices; |
| 1942 | } |
| 1943 | } |
| 1944 | handleValueChange() { |
| 1945 | if (this.input) { |
| 1946 | this.invalid = !this.input.checkValidity(); |
| 1947 | } |
| 1948 | } |
| 1949 | handleOpenChange() { |
| 1950 | if (this.open) { |
| 1951 | this.scOpen.emit(); |
| 1952 | this.searchInput && this.searchInput.triggerFocus(); |
| 1953 | } |
| 1954 | else { |
| 1955 | this.scClose.emit(); |
| 1956 | } |
| 1957 | } |
| 1958 | handleMenuScroll(e) { |
| 1959 | const scrollTop = e.target.scrollTop; |
| 1960 | const scrollHeight = e.target.scrollHeight; |
| 1961 | const offsetHeight = e.target.offsetHeight; |
| 1962 | const contentHeight = scrollHeight - offsetHeight; |
| 1963 | if (contentHeight - scrollTop < 5) |
| 1964 | this.scScrollEnd.emit(); |
| 1965 | } |
| 1966 | componentWillLoad() { |
| 1967 | this.handleSearchChange(); |
| 1968 | } |
| 1969 | componentDidLoad() { |
| 1970 | this.formController = new formData.FormSubmitController(this.el).addFormData(); |
| 1971 | if (this.open) { |
| 1972 | this.searchInput && this.searchInput.triggerFocus(); |
| 1973 | } |
| 1974 | } |
| 1975 | getItems() { |
| 1976 | return [...this.el.shadowRoot.querySelectorAll('sc-menu-item')]; |
| 1977 | } |
| 1978 | handleKeyDown(event) { |
| 1979 | var _a, _b; |
| 1980 | event.stopPropagation(); |
| 1981 | const target = event.target; |
| 1982 | const items = this.getItems(); |
| 1983 | // Ignore key presses on tags |
| 1984 | if (target.tagName.toLowerCase() === 'sc-tag') { |
| 1985 | return; |
| 1986 | } |
| 1987 | // Tabbing out of the control closes it |
| 1988 | if (event.key === 'Tab') { |
| 1989 | if (this.open) { |
| 1990 | this.handleHide(); |
| 1991 | } |
| 1992 | return; |
| 1993 | } |
| 1994 | // Up/down opens the menu |
| 1995 | if (['ArrowDown', 'ArrowUp'].includes(event.key)) { |
| 1996 | event.preventDefault(); |
| 1997 | // Show the menu if it's not already open |
| 1998 | if (!this.open) { |
| 1999 | this.handleShow(); |
| 2000 | } |
| 2001 | // Focus on a menu item |
| 2002 | if (event.key === 'ArrowDown') { |
| 2003 | if (arrowFlag == 'up') { |
| 2004 | itemIndex = itemIndex + 2; |
| 2005 | } |
| 2006 | if (itemIndex > items.length - 1) { |
| 2007 | itemIndex = 0; |
| 2008 | } |
| 2009 | items[itemIndex].setFocus(); |
| 2010 | arrowFlag = 'down'; |
| 2011 | itemIndex++; |
| 2012 | return; |
| 2013 | } |
| 2014 | if (event.key === 'ArrowUp') { |
| 2015 | if (arrowFlag == 'down') { |
| 2016 | itemIndex = itemIndex - 2; |
| 2017 | } |
| 2018 | if (itemIndex < 0) { |
| 2019 | itemIndex = items.length - 1; |
| 2020 | } |
| 2021 | items[itemIndex].setFocus(); |
| 2022 | arrowFlag = 'up'; |
| 2023 | itemIndex--; |
| 2024 | return; |
| 2025 | } |
| 2026 | } |
| 2027 | // Close select dropdown on Esc/Escape key |
| 2028 | if (event.key === 'Escape') { |
| 2029 | if (this.open) { |
| 2030 | this.el.focus(); |
| 2031 | this.handleHide(); |
| 2032 | } |
| 2033 | return; |
| 2034 | } |
| 2035 | // Open select dropdown with Enter |
| 2036 | if (event.key === 'Enter') { |
| 2037 | if (this.open) { |
| 2038 | (_b = (_a = items[itemIndex - 1]) === null || _a === void 0 ? void 0 : _a.click) === null || _b === void 0 ? void 0 : _b.call(_a); |
| 2039 | this.handleHide(); |
| 2040 | this.el.focus(); |
| 2041 | } |
| 2042 | else { |
| 2043 | this.handleShow(); |
| 2044 | } |
| 2045 | } |
| 2046 | // don't open the menu when a CTRL/Command key is pressed |
| 2047 | if (event.ctrlKey || event.metaKey) { |
| 2048 | return; |
| 2049 | } |
| 2050 | // All other "printable" keys open the menu and initiate type to select |
| 2051 | // TODO: this is closing out the dropdown during typing events. |
| 2052 | // FIX: It must have focus as well. And it fix the random closing issue. |
| 2053 | if (!this.open && this.hasFocus && event.key.length === 1) { |
| 2054 | this.handleShow(); |
| 2055 | } |
| 2056 | } |
| 2057 | disconnectedCallback() { |
| 2058 | var _a; |
| 2059 | (_a = this.formController) === null || _a === void 0 ? void 0 : _a.removeFormData(); |
| 2060 | } |
| 2061 | renderIcon(icon) { |
| 2062 | if (util.isValidURL(icon)) { |
| 2063 | return index.h("img", { src: icon, alt: "icon", slot: "prefix", class: "choice__icon--image" }); |
| 2064 | } |
| 2065 | return index.h("sc-icon", { name: icon, slot: "prefix", class: "choice__icon" }); |
| 2066 | } |
| 2067 | renderItem(choice, index$1) { |
| 2068 | var _a; |
| 2069 | const uniqueKey = `${(choice === null || choice === void 0 ? void 0 : choice.value) || (choice === null || choice === void 0 ? void 0 : choice.label) || 'item'}-${index$1}`; |
| 2070 | if ((_a = choice === null || choice === void 0 ? void 0 : choice.choices) === null || _a === void 0 ? void 0 : _a.length) { |
| 2071 | return index.h("sc-menu-label", { key: uniqueKey }, choice === null || choice === void 0 ? void 0 : choice.label); |
| 2072 | } |
| 2073 | return (index.h("sc-menu-item", { class: { 'is-unavailable': choice === null || choice === void 0 ? void 0 : choice.unavailable }, key: uniqueKey, checked: this.isChecked(choice), value: choice === null || choice === void 0 ? void 0 : choice.value, onClick: () => !choice.disabled && this.handleSelect(choice), onKeyDown: event => { |
| 2074 | if ((event.key === 'Enter' || event.key === ' ') && !choice.disabled) { |
| 2075 | event.preventDefault(); |
| 2076 | event.stopImmediatePropagation(); |
| 2077 | this.handleSelect(choice); |
| 2078 | } |
| 2079 | }, disabled: choice.disabled, "aria-label": choice.label, "aria-selected": this.isChecked(choice) ? 'true' : 'false', role: "option" }, choice.label, !!(choice === null || choice === void 0 ? void 0 : choice.description) && index.h("div", { class: "select__description" }, choice === null || choice === void 0 ? void 0 : choice.description), index.h("div", { slot: "suffix" }, choice === null || choice === void 0 ? void 0 : |
| 2080 | choice.suffix, " ", !!(choice === null || choice === void 0 ? void 0 : choice.suffixDescription) && index.h("div", { class: "select__suffix-description" }, choice === null || choice === void 0 ? void 0 : choice.suffixDescription)), !!(choice === null || choice === void 0 ? void 0 : choice.icon) && this.renderIcon(choice.icon))); |
| 2081 | } |
| 2082 | render() { |
| 2083 | var _a; |
| 2084 | const displayValue = this.displayValue() || this.placeholder || wp.i18n.__('Select...', 'surecart'); |
| 2085 | const accessibleName = this.label ? `${this.label}, ${displayValue}` : displayValue; |
| 2086 | return (index.h(index.Host, { key: '1322dca7c7bc4aaa59df5499276e1bfc3ac9e256', tabindex: this.disabled ? -1 : 0, role: "button", "aria-haspopup": "listbox", "aria-expanded": this.open ? 'true' : 'false', "aria-label": accessibleName, onFocus: () => this.handleFocus(), onBlur: () => this.handleBlur() }, index.h("div", { key: '690433d734499028c29c18812f4018c319f8c430', part: "base", class: { |
| 2087 | 'select': true, |
| 2088 | 'select--placeholder': !this.value, |
| 2089 | 'select--focused': this.hasFocus, |
| 2090 | 'select--is-open': !!this.open, |
| 2091 | 'select--disabled': this.disabled, |
| 2092 | 'select--has-choices': !!((_a = this === null || this === void 0 ? void 0 : this.choices) === null || _a === void 0 ? void 0 : _a.length), |
| 2093 | 'select--squared': this.squared, |
| 2094 | 'select--squared-bottom': this.squaredBottom, |
| 2095 | 'select--squared-top': this.squaredTop, |
| 2096 | 'select--squared-left': this.squaredLeft, |
| 2097 | 'select--squared-right': this.squaredRight, |
| 2098 | } }, index.h("sc-form-control", { key: 'a0d0004cf7a58ead42f3cb7039919ca5ef6723e2', exportparts: "label, help-text, form-control", size: this.size, required: this.required, label: this.label, help: this.help, inputId: this.inputId, helpId: this.helpId, labelId: this.labelId, name: this.name }, index.h("input", { key: 'fcd2f1196ff9b984c2323bf5a3d6848c958566a0', class: "select__hidden-input", name: this.name, ref: el => (this.input = el), value: this.value, required: this.required, disabled: this.disabled, autocomplete: this.autocomplete, tabindex: "-1", "aria-label": this.displayValue() || this.label || this.placeholder, onBlur: () => this.handleBlur(), onFocus: () => this.handleFocus(), onChange: () => this.handleInputChange() }), index.h("sc-dropdown", { key: 'aa5802fda760c0c8b78973229d86cf66549a1283', exportparts: "trigger, panel", disabled: this.disabled, open: this.open, closeOnSelect: this.closeOnSelect, position: this.position, placement: this.placement, hoist: this.hoist, style: { '--panel-width': '100%' }, onScShow: () => this.handleShow(), onScHide: () => this.handleHide() }, index.h("slot", { key: 'd6773973ff2e7106f7a4dc5224915601f14fd47f', name: "trigger", slot: "trigger" }, index.h("div", { key: 'debc5668ad2be8c53e5bab6aa0525f6fbe5e26a4', class: "trigger", tabIndex: -1, onFocus: () => this.handleFocus(), onBlur: () => this.handleBlur() }, index.h("div", { key: '6794d8bdfe40cd6f4c728fc361231f616c14257a', class: "select__value" }, index.h("slot", { key: '6ed8690daf375bdaac251f40474c4c686775343e' }, displayValue)), index.h("sc-icon", { key: '8056458a8d2cbf7a172a81826dd87539fc946c63', exportparts: "base:caret", class: "select__caret", name: "chevron-down" }))), this.search && (index.h("sc-input", { key: '2e223342901fe17a62971cd5560dfab023c2e7eb', exportparts: "base:search__base, input:search__input, form-control:search__form-control", placeholder: this.searchPlaceholder || wp.i18n.__('Search...', 'surecart'), onScInput: e => this.handleQuery(e), class: "search", clearable: true, part: "search", value: this.searchTerm, ref: el => (this.searchInput = el), "aria-label": wp.i18n.__('Type to search', 'surecart') }, this.loading && index.h("sc-spinner", { key: 'ff9f0e58543be3fb6a0a8741c64e6b541baed82e', exportparts: "base:spinner__base", style: { '--spinner-size': '0.5em' }, slot: "suffix" }))), index.h("sc-menu", { key: '1b5557b2df51c9856ee3e4112883420b0d4b54d7', style: { maxHeight: this.open ? '210px' : '0px', overflow: 'auto' }, exportparts: "base:menu__base", onScroll: e => this.handleMenuScroll(e), "aria-multiselectable": "false" }, index.h("slot", { key: 'e21f0f74fa40cbe9adf9d1bf30c70ebfc90f6a5c', name: "prefix" }), (this.filteredChoices || []).map((choice, index) => { |
| 2099 | return [this.renderItem(choice, index), (choice.choices || []).map(choice => this.renderItem(choice, index))]; |
| 2100 | }), this.loading && (index.h("div", { key: '5a31cd0c9c7f219e6e7814edcdd3bbff17c68045', class: "loading" }, index.h("sc-spinner", { key: 'ab1fefd24c7406006ebb6399882bea837bdd8321', exportparts: "base:spinner__base" }))), !this.loading && !this.filteredChoices.length && (index.h("div", { key: '4f372f4a5e04dca82fdbb410bd2348aa1d890e7f', class: "select__empty", part: "empty" }, wp.i18n.__('Nothing Found', 'surecart'))), index.h("slot", { key: '6ab2f39af007889c3f42506aea0503ddc5c7a518', name: "suffix" }))))))); |
| 2101 | } |
| 2102 | get el() { return index.getElement(this); } |
| 2103 | static get watchers() { return { |
| 2104 | "searchTerm": ["handleSearchChange"], |
| 2105 | "choices": ["handleSearchChange"], |
| 2106 | "value": ["handleValueChange"], |
| 2107 | "open": ["handleOpenChange"] |
| 2108 | }; } |
| 2109 | }; |
| 2110 | ScSelectDropdown.style = ScSelectStyle0; |
| 2111 | |
| 2112 | exports.sc_menu_label = ScMenuLabel; |
| 2113 | exports.sc_select = ScSelectDropdown; |
| 2114 | |
| 2115 | //# sourceMappingURL=sc-menu-label_2.cjs.entry.js.map |