PluginProbe ʕ •ᴥ•ʔ
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 4.6.4
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v4.6.4
4.7.0 4.6.6 4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.1 4.5.0 4.4.2 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.3 4.2.2 4.2.1 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.11.0 1.11.1 1.11.2 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.9.0 1.9.1 1.9.2 1.9.3 1.9.4 1.9.5 2.0.0 2.0.1 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.10.0 2.10.1 2.11.0 2.11.1 2.11.2 2.11.3 2.11.4 2.12.0 2.13.0 2.14.0 2.14.1 2.15.0 2.15.1 2.16.0 2.16.1 2.16.2 2.16.3 2.17.0 2.17.1 2.17.2 2.18.0 2.19.0 2.19.2 2.19.3 2.19.4 2.2.0 2.2.1 2.20.0 2.20.1 2.20.2 2.20.3 2.20.4 2.20.5 2.20.6 2.21.0 2.22.0 2.22.1 2.23.0 2.24.0 2.25.0 2.25.1 2.25.2 2.26.0 2.27.0 2.27.1 2.28.0 2.29.0 2.29.1 2.29.2 2.29.3 2.29.4 2.3.0 2.3.1 2.30.0 2.31.0 2.31.1 2.31.2 2.31.3 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.40.0 2.40.1 2.5.0 2.5.1 2.5.2 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.9.0 3.0.0 3.0.0-RC1 3.0.0-RC2 3.0.0-beta1 3.0.0-beta2 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.10.0 3.10.1 3.11.0 3.12.0 3.13.0 3.13.1 3.13.2 3.13.3 3.13.4 3.14.0 3.15.0 3.15.1 3.15.2 3.15.3 3.15.4 3.15.5 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.16.6 3.16.7 3.16.8 3.17.0 3.17.1 3.17.2 3.17.3 3.17.4 3.17.5 3.17.6 3.18.0 3.19.0 3.19.1 3.19.2 3.2.0 3.2.1 3.2.2 3.20.0 3.20.1 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 4.0.0 4.0.1 4.0.2 4.0.3 trunk 4.1.0 0.2.19.1 4.1.1 1.0.0 4.2.0 1.0.1 1.0.2
surecart / dist / components / esm / sc-address_5.entry.js
surecart / dist / components / esm Last commit date
MockProcessor-5c5e066a.js 2 months ago MockProcessor-5c5e066a.js.map 2 months ago add-query-args-0e2a8393.js 1 year ago add-query-args-0e2a8393.js.map 1 year ago address-b8e2e4c8.js 4 months ago address-b8e2e4c8.js.map 4 months ago animation-registry-de37bd7e.js 3 months ago animation-registry-de37bd7e.js.map 3 months ago app-globals-0eef0276.js 2 months ago app-globals-0eef0276.js.map 2 months ago consumer-f1775a76.js 2 months ago consumer-f1775a76.js.map 2 months ago currency-a0c9bff4.js 1 year ago currency-a0c9bff4.js.map 1 year ago error-c8bf8e3e.js 1 week ago error-c8bf8e3e.js.map 1 week ago fetch-cdff67be.js 1 month ago fetch-cdff67be.js.map 1 month ago floating-ui.dom.esm-8dce4ea1.js 6 months ago floating-ui.dom.esm-8dce4ea1.js.map 6 months ago form-data-76641f16.js 1 year ago form-data-76641f16.js.map 1 year ago functions-4f009ce1.js 3 months ago functions-4f009ce1.js.map 3 months ago geo-permission-62aea8ee.js 1 month ago geo-permission-62aea8ee.js.map 1 month ago getters-1049a6f8.js 2 months ago getters-1049a6f8.js.map 2 months ago getters-1477d792.js 2 months ago getters-1477d792.js.map 2 months ago getters-4bb6cc1b.js 2 months ago getters-4bb6cc1b.js.map 2 months ago getters-7090a9c1.js 1 week ago getters-7090a9c1.js.map 1 week ago getters-9cfeb0de.js 1 week ago getters-9cfeb0de.js.map 1 week ago google-52867ad8.js 1 week ago google-52867ad8.js.map 1 week ago google-e9085e27.js 1 week ago google-e9085e27.js.map 1 week ago google-maps-e8b00ffd.js 3 months ago google-maps-e8b00ffd.js.map 3 months ago index-17aac936.js 1 month ago index-17aac936.js.map 1 month ago index-18f5a1bc.js 2 months ago index-18f5a1bc.js.map 2 months ago index-25e5af33.js 2 months ago index-25e5af33.js.map 2 months ago index-824c562b.js 2 months ago index-824c562b.js.map 2 months ago index-871d88b8.js 1 year ago index-871d88b8.js.map 1 year ago index-a786f689.js 1 week ago index-a786f689.js.map 1 week ago index-c5a96d53.js 2 years ago index-c5a96d53.js.map 2 years ago index-d602bc13.js 1 month ago index-d602bc13.js.map 1 month ago index.js 1 week ago index.js.map 1 month ago inline-c012a0f9.js 1 year ago inline-c012a0f9.js.map 1 year ago lazy-deb42890.js 1 year ago lazy-deb42890.js.map 1 year ago library-1bd957d5.js 2 months ago library-1bd957d5.js.map 2 months ago loader.js 2 weeks ago loader.js.map 1 year ago media-d21119a3.js 1 year ago media-d21119a3.js.map 1 year ago mutations-7458343f.js 2 months ago mutations-7458343f.js.map 2 months ago mutations-9ffd30f4.js 1 week ago mutations-9ffd30f4.js.map 1 week ago mutations-ae7167ad.js 1 week ago mutations-ae7167ad.js.map 1 week ago mutations-b310b068.js 1 week ago mutations-b310b068.js.map 1 week ago page-align-0cdacf32.js 1 year ago page-align-0cdacf32.js.map 1 year ago price-1ff6aa07.js 4 months ago price-1ff6aa07.js.map 4 months ago pure-963214cb.js 1 year ago pure-963214cb.js.map 1 year ago quantity-5c986f3d.js 3 months ago quantity-5c986f3d.js.map 3 months ago razorpay-4c4a3d31.js 3 months ago razorpay-4c4a3d31.js.map 3 months ago remove-query-args-938c53ea.js 1 year ago remove-query-args-938c53ea.js.map 1 year ago sc-address_5.entry.js 2 weeks ago sc-address_5.entry.js.map 2 weeks ago sc-alert.entry.js 1 month ago sc-alert.entry.js.map 1 year ago sc-avatar_2.entry.js 1 week ago sc-avatar_2.entry.js.map 1 month ago sc-badge-notice.entry.js 1 month ago sc-badge-notice.entry.js.map 1 year ago sc-block-ui.entry.js 1 month ago sc-block-ui.entry.js.map 5 months ago sc-breadcrumb.entry.js 1 month ago sc-breadcrumb.entry.js.map 1 year ago sc-breadcrumbs.entry.js 1 month ago sc-breadcrumbs.entry.js.map 1 year ago sc-button-group.entry.js 1 month ago sc-button-group.entry.js.map 1 year ago sc-button_6.entry.js 1 month ago sc-button_6.entry.js.map 1 month ago sc-cancel-dialog_3.entry.js 1 month ago sc-cancel-dialog_3.entry.js.map 1 month ago sc-cancel-discount_4.entry.js 1 month ago sc-cancel-discount_4.entry.js.map 2 months ago sc-card_2.entry.js 1 month ago sc-card_2.entry.js.map 4 months ago sc-cart-button.entry.js 1 week ago sc-cart-button.entry.js.map 1 year ago sc-cart-form-submit.entry.js 2 months ago sc-cart-form-submit.entry.js.map 1 year ago sc-cart-form.entry.js 1 week ago sc-cart-form.entry.js.map 1 month ago sc-cart-header.entry.js 1 week ago sc-cart-header.entry.js.map 1 year ago sc-cart-icon.entry.js 1 week ago sc-cart-icon.entry.js.map 1 year ago sc-cart-loader.entry.js 1 week ago sc-cart-loader.entry.js.map 1 year ago sc-cart-session-provider_3.entry.js 1 week ago sc-cart-session-provider_3.entry.js.map 2 months ago sc-cart-submit.entry.js 2 months ago sc-cart-submit.entry.js.map 1 year ago sc-cart.entry.js 1 week ago sc-cart.entry.js.map 2 months ago sc-cc-logo_2.entry.js 1 month ago sc-cc-logo_2.entry.js.map 1 month ago sc-charges-list.entry.js 1 month ago sc-charges-list.entry.js.map 2 months ago sc-checkout-autofill-provider_11.entry.js 1 week ago sc-checkout-autofill-provider_11.entry.js.map 1 month ago sc-checkout-form-errors.entry.js 2 months ago sc-checkout-form-errors.entry.js.map 1 year ago sc-checkout-mollie-payment_3.entry.js 1 week ago sc-checkout-mollie-payment_3.entry.js.map 2 months ago sc-checkout-product-bundle-component-variants.entry.js 1 week ago sc-checkout-product-bundle-component-variants.entry.js.map 1 month ago sc-checkout-product-price-variant-selector.entry.js 1 week ago sc-checkout-product-price-variant-selector.entry.js.map 4 weeks ago sc-checkout.entry.js 1 week ago sc-checkout.entry.js.map 1 month ago sc-choice-container.entry.js 1 month ago sc-choice-container.entry.js.map 1 year ago sc-choice.entry.js 1 month ago sc-choice.entry.js.map 1 year ago sc-choices.entry.js 1 month ago sc-choices.entry.js.map 1 year ago sc-column_2.entry.js 1 month ago sc-column_2.entry.js.map 1 month ago sc-compact-address_18.entry.js 1 week ago sc-compact-address_18.entry.js.map 1 month ago sc-conditional-form.entry.js 1 week ago sc-conditional-form.entry.js.map 2 months ago sc-consumer.entry.js 2 months ago sc-consumer.entry.js.map 1 year ago sc-coupon-form.entry.js 1 week ago sc-coupon-form.entry.js.map 5 months ago sc-custom-order-price-input.entry.js 1 month ago sc-custom-order-price-input.entry.js.map 2 months ago sc-customer-details.entry.js 1 month ago sc-customer-details.entry.js.map 7 months ago sc-customer-edit.entry.js 1 month ago sc-customer-edit.entry.js.map 2 months ago sc-customer-email.entry.js 1 week ago sc-customer-email.entry.js.map 1 month ago sc-customer-firstname.entry.js 1 week ago sc-customer-firstname.entry.js.map 2 months ago sc-customer-lastname.entry.js 1 week ago sc-customer-lastname.entry.js.map 2 months ago sc-customer-name.entry.js 1 week ago sc-customer-name.entry.js.map 2 months ago sc-dashboard-customer-details.entry.js 1 month ago sc-dashboard-customer-details.entry.js.map 2 months ago sc-dashboard-downloads-list.entry.js 1 month ago sc-dashboard-downloads-list.entry.js.map 2 months ago sc-dialog.entry.js 1 month ago sc-dialog.entry.js.map 5 months ago sc-divider.entry.js 1 month ago sc-divider.entry.js.map 1 year ago sc-donation-choices.entry.js 2 months ago sc-donation-choices.entry.js.map 1 year ago sc-downloads-list.entry.js 1 month ago sc-downloads-list.entry.js.map 1 month ago sc-dropdown_3.entry.js 1 month ago sc-dropdown_3.entry.js.map 6 months ago sc-empty_3.entry.js 1 month ago sc-empty_3.entry.js.map 4 months ago sc-express-payment.entry.js 1 week ago sc-express-payment.entry.js.map 3 months ago sc-feature-demo-banner.entry.js 1 month ago sc-feature-demo-banner.entry.js.map 1 year ago sc-flex.entry.js 1 month ago sc-flex.entry.js.map 1 year ago sc-form-control_2.entry.js 1 month ago sc-form-control_2.entry.js.map 2 months ago sc-form-row.entry.js 1 month ago sc-form-row.entry.js.map 1 year ago sc-form.entry.js 1 month ago sc-form.entry.js.map 1 year ago sc-format-bytes.entry.js 2 months ago sc-format-bytes.entry.js.map 1 year ago sc-format-interval.entry.js 2 months ago sc-format-interval.entry.js.map 1 year ago sc-format-number.entry.js 2 months ago sc-format-number.entry.js.map 1 year ago sc-fulfillment-shipping-status-badge.entry.js 2 months ago sc-fulfillment-shipping-status-badge.entry.js.map 4 months ago sc-fulfillments.entry.js 1 month ago sc-fulfillments.entry.js.map 2 months ago sc-heading_2.entry.js 1 month ago sc-heading_2.entry.js.map 1 year ago sc-image-slider.entry.js 1 month ago sc-image-slider.entry.js.map 1 month ago sc-invoice-status-badge.entry.js 1 month ago sc-invoice-status-badge.entry.js.map 4 months ago sc-invoices-list.entry.js 1 month ago sc-invoices-list.entry.js.map 2 months ago sc-license.entry.js 1 month ago sc-license.entry.js.map 2 months ago sc-licenses-list.entry.js 1 month ago sc-licenses-list.entry.js.map 1 month ago sc-line-item-bump.entry.js 1 week ago sc-line-item-bump.entry.js.map 1 year ago sc-line-item-total.entry.js 1 week ago sc-line-item-total.entry.js.map 6 months ago sc-line-item.entry.js 1 month ago sc-line-item.entry.js.map 1 year ago sc-line-items-provider.entry.js 1 month ago sc-line-items-provider.entry.js.map 1 year ago sc-line-items.entry.js 1 week ago sc-line-items.entry.js.map 1 month ago sc-login-form.entry.js 1 month ago sc-login-form.entry.js.map 2 months ago sc-manual-payment-method_3.entry.js 1 month ago sc-manual-payment-method_3.entry.js.map 3 months ago sc-menu-divider.entry.js 1 month ago sc-menu-divider.entry.js.map 1 year ago sc-menu-label_2.entry.js 1 month ago sc-menu-label_2.entry.js.map 1 month ago sc-mollie-add-method.entry.js 1 month ago sc-mollie-add-method.entry.js.map 2 months ago sc-order-confirmation-customer.entry.js 2 months ago sc-order-confirmation-customer.entry.js.map 1 year ago sc-order-confirmation-details.entry.js 2 months ago sc-order-confirmation-details.entry.js.map 11 months ago sc-order-confirmation-line-items_2.entry.js 1 month ago sc-order-confirmation-line-items_2.entry.js.map 1 month ago sc-order-confirmation.entry.js 1 month ago sc-order-confirmation.entry.js.map 2 months ago sc-order-coupon-form.entry.js 1 week ago sc-order-coupon-form.entry.js.map 2 months ago sc-order-detail.entry.js 2 months ago sc-order-detail.entry.js.map 1 year ago sc-order-fulfillment-badge.entry.js 1 month ago sc-order-fulfillment-badge.entry.js.map 4 months ago sc-order-manual-instructions.entry.js 2 months ago sc-order-manual-instructions.entry.js.map 1 year ago sc-order-password.entry.js 2 months ago sc-order-password.entry.js.map 1 year ago sc-order-return-badge.entry.js 1 month ago sc-order-return-badge.entry.js.map 4 months ago sc-order-shipment-badge.entry.js 2 months ago sc-order-shipment-badge.entry.js.map 4 months ago sc-order-status-badge.entry.js 1 month ago sc-order-status-badge.entry.js.map 4 months ago sc-order-submit.entry.js 1 week ago sc-order-submit.entry.js.map 2 months ago sc-order-summary.entry.js 1 week ago sc-order-summary.entry.js.map 1 month ago sc-order.entry.js 1 month ago sc-order.entry.js.map 1 month ago sc-orders-list.entry.js 1 month ago sc-orders-list.entry.js.map 1 month ago sc-pagination.entry.js 2 months ago sc-pagination.entry.js.map 1 year ago sc-password-nag.entry.js 1 month ago sc-password-nag.entry.js.map 2 months ago sc-password.entry.js 1 month ago sc-password.entry.js.map 1 month ago sc-payment-method-choice_2.entry.js 1 month ago sc-payment-method-choice_2.entry.js.map 1 year ago sc-payment-method-details.entry.js 1 month ago sc-payment-method-details.entry.js.map 1 year ago sc-payment-methods-list.entry.js 1 month ago sc-payment-methods-list.entry.js.map 2 months ago sc-payment.entry.js 1 week ago sc-payment.entry.js.map 3 months ago sc-paypal-add-method.entry.js 1 month ago sc-paypal-add-method.entry.js.map 2 months ago sc-paypal-buttons_2.entry.js 1 week ago sc-paypal-buttons_2.entry.js.map 2 months ago sc-paystack-add-method.entry.js 1 month ago sc-paystack-add-method.entry.js.map 2 months ago sc-pill-option.entry.js 1 month ago sc-pill-option.entry.js.map 1 year ago sc-popover.entry.js 1 month ago sc-popover.entry.js.map 6 months ago sc-premium-tag.entry.js 1 month ago sc-premium-tag.entry.js.map 1 year ago sc-price-choice-container.entry.js 1 month ago sc-price-choice-container.entry.js.map 1 month ago sc-price-choice.entry.js 1 month ago sc-price-choice.entry.js.map 2 months ago sc-price-choices.entry.js 1 week ago sc-price-choices.entry.js.map 1 year ago sc-price-input.entry.js 1 month ago sc-price-input.entry.js.map 1 year ago sc-price-range_4.entry.js 1 month ago sc-price-range_4.entry.js.map 1 year ago sc-price.entry.js 2 months ago sc-price.entry.js.map 11 months ago sc-product-buy-button.entry.js 1 week ago sc-product-buy-button.entry.js.map 2 months ago sc-product-donation-amount-choice.entry.js 1 week ago sc-product-donation-amount-choice.entry.js.map 2 months ago sc-product-donation-choices.entry.js 1 week ago sc-product-donation-choices.entry.js.map 2 months ago sc-product-donation-custom-amount.entry.js 1 week ago sc-product-donation-custom-amount.entry.js.map 2 months ago sc-product-item-list.entry.js 1 week ago sc-product-item-list.entry.js.map 2 months ago sc-product-item.entry.js 1 month ago sc-product-item.entry.js.map 1 year ago sc-product-pills-variant-option.entry.js 1 week ago sc-product-pills-variant-option.entry.js.map 1 year ago sc-product-price-choices.entry.js 1 week ago sc-product-price-choices.entry.js.map 1 year ago sc-product-price-modal.entry.js 1 week ago sc-product-price-modal.entry.js.map 2 months ago sc-product-price.entry.js 1 week ago sc-product-price.entry.js.map 2 months ago sc-product-quantity.entry.js 1 week ago sc-product-quantity.entry.js.map 1 year ago sc-product-selected-price.entry.js 1 week ago sc-product-selected-price.entry.js.map 2 months ago sc-product-text.entry.js 1 week ago sc-product-text.entry.js.map 1 year ago sc-provider.entry.js 2 months ago sc-provider.entry.js.map 1 year ago sc-provisional-banner.entry.js 1 month ago sc-provisional-banner.entry.js.map 11 months ago sc-purchase-downloads-list.entry.js 1 month ago sc-purchase-downloads-list.entry.js.map 1 month ago sc-razorpay-add-method.entry.js 1 month ago sc-razorpay-add-method.entry.js.map 2 months ago sc-recurring-price-choice-container.entry.js 2 months ago sc-recurring-price-choice-container.entry.js.map 1 year ago sc-review-stars.entry.js 2 months ago sc-review-stars.entry.js.map 6 months ago sc-rich-text.entry.js 1 month ago sc-rich-text.entry.js.map 1 month ago sc-skeleton.entry.js 1 month ago sc-skeleton.entry.js.map 1 year ago sc-spacing.entry.js 1 month ago sc-spacing.entry.js.map 1 year ago sc-stripe-add-method.entry.js 1 month ago sc-stripe-add-method.entry.js.map 2 months ago sc-stripe-element.entry.js 1 week ago sc-stripe-element.entry.js.map 2 months ago sc-stripe-payment-element.entry.js 1 week ago sc-stripe-payment-element.entry.js.map 2 months ago sc-stripe-payment-request.entry.js 1 week ago sc-stripe-payment-request.entry.js.map 2 months ago sc-subscription-ad-hoc-confirm.entry.js 1 month ago sc-subscription-ad-hoc-confirm.entry.js.map 6 months ago sc-subscription-details_2.entry.js 1 month ago sc-subscription-details_2.entry.js.map 1 month ago sc-subscription-payment-method.entry.js 1 month ago sc-subscription-payment-method.entry.js.map 2 months ago sc-subscription-payment.entry.js 1 month ago sc-subscription-payment.entry.js.map 2 months ago sc-subscription-switch.entry.js 1 month ago sc-subscription-switch.entry.js.map 2 months ago sc-subscription-variation-confirm.entry.js 1 month ago sc-subscription-variation-confirm.entry.js.map 1 year ago sc-subscription.entry.js 1 month ago sc-subscription.entry.js.map 1 month ago sc-subscriptions-list.entry.js 1 month ago sc-subscriptions-list.entry.js.map 2 months ago sc-summary.entry.js 1 month ago sc-summary.entry.js.map 1 year ago sc-swap.entry.js 1 week ago sc-swap.entry.js.map 2 months ago sc-switch.entry.js 1 month ago sc-switch.entry.js.map 7 months ago sc-tab-group.entry.js 1 month ago sc-tab-group.entry.js.map 1 year ago sc-tab-panel.entry.js 1 month ago sc-tab-panel.entry.js.map 1 year ago sc-tab.entry.js 1 month ago sc-tab.entry.js.map 1 year ago sc-table-head.entry.js 1 month ago sc-table-head.entry.js.map 1 year ago sc-table_3.entry.js 1 month ago sc-table_3.entry.js.map 10 months ago sc-tag.entry.js 1 month ago sc-tag.entry.js.map 4 months ago sc-test-mode-info.entry.js 1 month ago sc-test-mode-info.entry.js.map 6 months ago sc-text.entry.js 1 month ago sc-text.entry.js.map 1 year ago sc-toggle.entry.js 1 month ago sc-toggle.entry.js.map 1 year ago sc-toggles.entry.js 1 month ago sc-toggles.entry.js.map 1 year ago sc-total.entry.js 1 week ago sc-total.entry.js.map 1 year ago sc-upcoming-invoice.entry.js 1 month ago sc-upcoming-invoice.entry.js.map 2 months ago sc-upgrade-required.entry.js 2 months ago sc-upgrade-required.entry.js.map 1 year ago sc-upsell-countdown-timer.entry.js 1 month ago sc-upsell-countdown-timer.entry.js.map 1 year ago sc-upsell-no-thanks-button.entry.js 1 week ago sc-upsell-no-thanks-button.entry.js.map 2 months ago sc-upsell-submit-button.entry.js 1 week ago sc-upsell-submit-button.entry.js.map 2 months ago sc-upsell-totals.entry.js 1 week ago sc-upsell-totals.entry.js.map 2 months ago sc-upsell.entry.js 1 week ago sc-upsell.entry.js.map 2 months ago sc-verification-code.entry.js 1 month ago sc-verification-code.entry.js.map 2 months ago sc-visually-hidden.entry.js 1 month ago sc-visually-hidden.entry.js.map 1 year ago sc-wordpress-password-edit.entry.js 1 month ago sc-wordpress-password-edit.entry.js.map 2 months ago sc-wordpress-user-edit.entry.js 1 month ago sc-wordpress-user-edit.entry.js.map 2 months ago sc-wordpress-user.entry.js 1 month ago sc-wordpress-user.entry.js.map 1 year ago store-289e460c.js 2 months ago store-289e460c.js.map 2 months ago store-ac90a769.js 1 month ago store-ac90a769.js.map 1 month ago store-b1758b00.js 2 months ago store-b1758b00.js.map 2 months ago surecart.js 2 weeks ago surecart.js.map 1 year ago tax-a03623ca.js 1 year ago tax-a03623ca.js.map 1 year ago universe-7bd0ac2b.js 2 months ago universe-7bd0ac2b.js.map 2 months ago util-dfbf863e.js 2 months ago util-dfbf863e.js.map 2 months ago utils-f84b2118.js 3 months ago utils-f84b2118.js.map 3 months ago verification-00df9439.js 1 month ago verification-00df9439.js.map 1 month ago watchers-2d9a1422.js 1 week ago watchers-2d9a1422.js.map 1 week ago watchers-81f32d01.js 1 week ago watchers-81f32d01.js.map 1 week ago watchers-843c3dbe.js 1 week ago watchers-843c3dbe.js.map 1 week ago watchers-c7bbc6b2.js 2 months ago watchers-c7bbc6b2.js.map 2 months ago watchers-df374a91.js 1 week ago watchers-df374a91.js.map 1 week ago
sc-address_5.entry.js
18228 lines
1 import { r as registerInstance, c as createEvent, h, a as getElement, H as Host, F as Fragment } from './index-25e5af33.js';
2 import { g as getCountryDetails, c as countryChoices, a as getCountryRegions } from './address-b8e2e4c8.js';
3 import { r as reportChildrenValidity, F as FormSubmitController } from './form-data-76641f16.js';
4 import { g as getCurrentUserCountryCode, a as getAddressLabels, t as transformPlaceDetails, b as getStreetAddress } from './google-maps-e8b00ffd.js';
5 import { c as createErrorNotice } from './mutations-7458343f.js';
6 import { i as isRtl } from './page-align-0cdacf32.js';
7 import { a as applyFilters } from './index-871d88b8.js';
8 import { s as speak } from './index-c5a96d53.js';
9 import { z as zones } from './tax-a03623ca.js';
10 import './add-query-args-0e2a8393.js';
11 import './index-18f5a1bc.js';
12
13 var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
14
15 const scAddressCss = ":host{display:block}.sc-address{display:block;position:relative}.sc-address [hidden]{display:none}.sc-address--loading{min-height:230px}.sc-address sc-skeleton{display:block;margin-bottom:1em}.sc-address__control{display:block}.sc-address__control>*{margin-bottom:var(--sc-address-column-spacing, -1px)}.sc-address__collapsible{opacity:0;pointer-events:none;position:absolute;transform:translateY(-8px);width:100%}.sc-address__collapsible>*{margin-bottom:var(--sc-address-column-spacing, -1px)}.sc-address__collapsible--expanded{opacity:1;pointer-events:auto;position:relative;transform:translateY(0);transition:opacity 0.2s ease-in, transform 0.2s ease-in;z-index:var(--sc-address-collapsible-z-index, 9)}.sc-address__collapsible:focus-within{z-index:var(--sc-address-collapsible-focus-z-index, 10)}.sc-address__columns{display:flex;flex-direction:row;align-items:center;flex-wrap:wrap;justify-content:space-between}.sc-address__columns>*{flex:1;width:50%;margin-right:var(--sc-address-column-spacing, -1px)}.sc-address__columns>*:last-child{margin-right:0}";
16 const ScAddressStyle0 = scAddressCss;
17
18 const DEFAULT_COUNTRY_FIELDS = [
19 {
20 name: 'country',
21 priority: 30,
22 label: wp.i18n.__('Country', 'surecart'),
23 },
24 {
25 name: 'name',
26 priority: 40,
27 label: wp.i18n.__('Name or Company Name', 'surecart'),
28 },
29 {
30 name: 'line_1',
31 priority: 50,
32 label: wp.i18n.__('Address', 'surecart'),
33 },
34 {
35 name: 'line_2',
36 priority: 60,
37 label: wp.i18n.__('Line 2', 'surecart'),
38 },
39 {
40 name: 'city',
41 priority: 70,
42 label: wp.i18n.__('City', 'surecart'),
43 },
44 {
45 name: 'state',
46 priority: 80,
47 label: wp.i18n.__('State / County', 'surecart'),
48 },
49 {
50 name: 'postal_code',
51 priority: 90,
52 label: wp.i18n.__('Postal Code', 'surecart'),
53 },
54 ];
55 const ScAddress = class {
56 constructor(hostRef) {
57 registerInstance(this, hostRef);
58 this.scChangeAddress = createEvent(this, "scChangeAddress", 7);
59 this.scInputAddress = createEvent(this, "scInputAddress", 7);
60 /** Names of fields that collapse when Google Maps autocomplete is active. */
61 this.collapsibleFieldNames = ['line_2', 'city', 'state', 'postal_code'];
62 this.address = {
63 country: null,
64 city: null,
65 line_1: null,
66 line_2: null,
67 postal_code: null,
68 state: null,
69 };
70 this.names = {
71 name: 'shipping_name',
72 country: 'shipping_country',
73 city: 'shipping_city',
74 line_1: 'shipping_line_1',
75 line_2: 'shipping_line_2',
76 postal_code: 'shipping_postal_code',
77 state: 'shipping_state',
78 };
79 this.loading = false;
80 this.disabled = undefined;
81 this.label = undefined;
82 this.showName = undefined;
83 this.showLine2 = undefined;
84 this.required = false;
85 this.requireName = false;
86 this.showCity = true;
87 this.showPostal = true;
88 this.showState = true;
89 this.countryDetails = null;
90 this.countryChoices = undefined;
91 }
92 /** When the state changes, we want to update city and postal fields. */
93 async handleAddressChange() {
94 var _a, _b;
95 if (!((_a = this.address) === null || _a === void 0 ? void 0 : _a.country))
96 return;
97 if (!this.countryDetails || ((_b = this.countryDetails) === null || _b === void 0 ? void 0 : _b.code) !== this.address.country) {
98 this.countryDetails = await getCountryDetails(this.address.country);
99 }
100 this.scChangeAddress.emit(this.address);
101 this.scInputAddress.emit(this.address);
102 }
103 handleNameChange() {
104 if (this.requireName) {
105 this.showName = true;
106 }
107 }
108 decodeHtmlEntities(html) {
109 var _a;
110 return ((_a = new DOMParser().parseFromString(html, 'text/html')) === null || _a === void 0 ? void 0 : _a.body.textContent) || html;
111 }
112 updateAddress(address) {
113 this.address = { ...this.address, ...address };
114 }
115 handleAddressInput(address) {
116 this.scInputAddress.emit({ ...this.address, ...address });
117 }
118 clearAddress() {
119 var _a, _b, _c;
120 // Only reset fields whose format depends on country (region list, postal code pattern).
121 // Keep line_1/line_2 — they're free text, and clearing them silently discards what the buyer already typed.
122 this.address = {
123 name: (_a = this.address) === null || _a === void 0 ? void 0 : _a.name,
124 line_1: (_b = this.address) === null || _b === void 0 ? void 0 : _b.line_1,
125 line_2: (_c = this.address) === null || _c === void 0 ? void 0 : _c.line_2,
126 country: null,
127 city: null,
128 postal_code: null,
129 state: null,
130 };
131 }
132 componentWillLoad() {
133 var _a;
134 // Start collapsed when Google Maps is active — the child component
135 // will emit show/hide events to control this going forward.
136 if ((_a = window === null || window === void 0 ? void 0 : window.scData) === null || _a === void 0 ? void 0 : _a.google_map_api_key) {
137 this.toggleAddressFieldsVisibility(false);
138 }
139 this.initCountryChoices();
140 this.handleAddressChange();
141 this.handleNameChange();
142 this.fetchUserCountry();
143 }
144 async fetchUserCountry() {
145 var _a;
146 if ((_a = this.address) === null || _a === void 0 ? void 0 : _a.country) {
147 return;
148 }
149 const countryCode = await getCurrentUserCountryCode();
150 if (countryCode) {
151 this.updateAddress({ country: countryCode });
152 }
153 }
154 async initCountryChoices() {
155 var _a, _b;
156 this.countryChoices = await countryChoices();
157 const country = ((_b = (_a = this.countryChoices) === null || _a === void 0 ? void 0 : _a.find(country => { var _a; return country.value === ((_a = this.address) === null || _a === void 0 ? void 0 : _a.country); })) === null || _b === void 0 ? void 0 : _b.value) || null;
158 this.updateAddress({ country });
159 }
160 async reportValidity() {
161 // Collapsed city/state/postal fields render as not-required (see isFieldIncluded/render) so they don't
162 // block submission while hidden. Expand them first so a required address can't be bypassed by leaving
163 // line_1 empty (fields never having shown) or clearing it after the fact.
164 if (this.required && !this.isFieldsExpanded()) {
165 this.toggleAddressFieldsVisibility(true);
166 await new Promise(resolve => requestAnimationFrame(resolve));
167 }
168 return reportChildrenValidity(this.el);
169 }
170 sortedFields() {
171 var _a, _b, _c, _d;
172 if (!this.countryDetails || !((_a = this === null || this === void 0 ? void 0 : this.address) === null || _a === void 0 ? void 0 : _a.country)) {
173 return DEFAULT_COUNTRY_FIELDS;
174 }
175 return (((_d = (_c = (_b = this === null || this === void 0 ? void 0 : this.countryDetails) === null || _b === void 0 ? void 0 : _b.address_formats) === null || _c === void 0 ? void 0 : _c.edit) === null || _d === void 0 ? void 0 : _d.match(/{{([^}]+)}}/g).map(match => match.slice(2, -2)).map(field => {
176 var _a, _b, _c;
177 return ({
178 name: field,
179 label: ((_b = (_a = this === null || this === void 0 ? void 0 : this.countryDetails) === null || _a === void 0 ? void 0 : _a.address_labels) === null || _b === void 0 ? void 0 : _b[field]) || ((_c = DEFAULT_COUNTRY_FIELDS === null || DEFAULT_COUNTRY_FIELDS === void 0 ? void 0 : DEFAULT_COUNTRY_FIELDS.find(defaultField => (defaultField === null || defaultField === void 0 ? void 0 : defaultField.name) === field)) === null || _c === void 0 ? void 0 : _c.label),
180 });
181 })) || []);
182 }
183 regions() {
184 var _a, _b, _c, _d, _e;
185 let regions = ((_b = (_a = this === null || this === void 0 ? void 0 : this.countryDetails) === null || _a === void 0 ? void 0 : _a.states) === null || _b === void 0 ? void 0 : _b.map(state => ({
186 value: state === null || state === void 0 ? void 0 : state.code,
187 label: state === null || state === void 0 ? void 0 : state.name,
188 }))) || [];
189 if ((_d = (_c = window === null || window === void 0 ? void 0 : window.wp) === null || _c === void 0 ? void 0 : _c.hooks) === null || _d === void 0 ? void 0 : _d.applyFilters) {
190 regions = window.wp.hooks.applyFilters('surecart_address_regions', regions, (_e = this === null || this === void 0 ? void 0 : this.address) === null || _e === void 0 ? void 0 : _e.country);
191 }
192 return regions;
193 }
194 toggleAddressFieldsVisibility(show) {
195 this.showCity = show;
196 this.showPostal = show;
197 this.showState = show;
198 }
199 getRoundedProps(index, length) {
200 const isFirst = index === 0;
201 const isLast = index === length - 1;
202 return {
203 squaredTop: isLast,
204 squaredBottom: isFirst,
205 squared: !isLast && !isFirst,
206 };
207 }
208 /** Whether the collapsible fields are expanded.
209 * When Google Maps is off, showCity stays at its default (true) and fields are always expanded.
210 * When Google Maps is on, the child toggles this via show/hide events. */
211 isFieldsExpanded() {
212 return this.showCity;
213 }
214 /** Whether a field should be included in the render. */
215 isFieldIncluded(field) {
216 var _a, _b, _c, _d;
217 switch (field.name) {
218 case 'name':
219 return !!this.showName;
220 case 'state':
221 return !!((_a = this === null || this === void 0 ? void 0 : this.regions()) === null || _a === void 0 ? void 0 : _a.length) && !!((_b = this === null || this === void 0 ? void 0 : this.address) === null || _b === void 0 ? void 0 : _b.country);
222 case 'line_2':
223 // When collapsed, always include so browser autocomplete can fill it (CSS hides it).
224 // When expanded, respect the showLine2 prop from settings.
225 if (!this.isFieldsExpanded())
226 return true;
227 return this.showLine2 || !!((_d = (_c = this === null || this === void 0 ? void 0 : this.address) === null || _c === void 0 ? void 0 : _c.line_2) === null || _d === void 0 ? void 0 : _d.length);
228 default:
229 return true;
230 }
231 }
232 renderField(field, roundedProps, isRequired) {
233 var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
234 switch (field.name) {
235 case 'country':
236 return (h("sc-select", { exportparts: "base:select__base, input, form-control, label, help-text, trigger, panel, caret, search__base, search__input, search__form-control, menu__base, spinner__base, empty", part: "name__input", value: (_b = (_a = this.address) === null || _a === void 0 ? void 0 : _a.country) !== null && _b !== void 0 ? _b : '', onScChange: (e) => {
237 var _a;
238 if (e.target.value === ((_a = this.address) === null || _a === void 0 ? void 0 : _a.country))
239 return;
240 this.clearAddress();
241 this.updateAddress({ country: e.target.value });
242 }, choices: this.countryChoices, autocomplete: 'country-name', placeholder: field.label, name: (_c = this.names) === null || _c === void 0 ? void 0 : _c.country, search: true, unselect: false, disabled: this.disabled, required: isRequired, "aria-label": field.label, ...roundedProps }));
243 case 'name':
244 return (h("sc-input", { exportparts: "base:input__base, input, form-control, label, help-text", value: (_e = (_d = this === null || this === void 0 ? void 0 : this.address) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : '', onScChange: (e) => this.updateAddress({ name: e.target.value || null }), onScInput: (e) => this.handleAddressInput({ name: e.target.value || null }), autocomplete: "name", placeholder: field.label, name: (_f = this.names) === null || _f === void 0 ? void 0 : _f.name, disabled: this.disabled, required: this.requireName, "aria-label": field.label, ...roundedProps }));
245 case 'line_1':
246 return (h("sc-address-suggestions", { address: this.address, names: this.names, regions: this.regions(), label: field.label, disabled: this.disabled, required: isRequired, inputProps: roundedProps, onScChangeAddress: (e) => this.updateAddress(e.detail), onScShowAddressFields: () => this.toggleAddressFieldsVisibility(true), onScHideAddressFields: () => this.toggleAddressFieldsVisibility(false) }));
247 case 'line_2':
248 return (h("sc-input", { exportparts: "base:input__base, input, form-control, label, help-text", value: (_h = (_g = this === null || this === void 0 ? void 0 : this.address) === null || _g === void 0 ? void 0 : _g.line_2) !== null && _h !== void 0 ? _h : '', onScChange: (e) => this.updateAddress({ line_2: e.target.value || null }), onScInput: (e) => this.handleAddressInput({ line_2: e.target.value || null }), autocomplete: "address-line2", placeholder: field.label, name: (_j = this.names) === null || _j === void 0 ? void 0 : _j.line_2, disabled: this.disabled, "aria-label": field.label, ...roundedProps }));
249 case 'city':
250 return (h("sc-input", { exportparts: "base:input__base, input, form-control, label, help-text", placeholder: field.label, name: (_k = this.names) === null || _k === void 0 ? void 0 : _k.city, value: (_m = (_l = this === null || this === void 0 ? void 0 : this.address) === null || _l === void 0 ? void 0 : _l.city) !== null && _m !== void 0 ? _m : '', onScChange: (e) => this.updateAddress({ city: e.target.value || null }), onScInput: (e) => this.handleAddressInput({ city: e.target.value || null }), autocomplete: 'address-level2', required: isRequired, disabled: this.disabled, "aria-label": field.label, ...roundedProps }));
251 case 'state':
252 return (h("sc-select", { exportparts: "base:select__base, input, form-control, label, help-text, trigger, panel, caret, search__base, search__input, search__form-control, menu__base, spinner__base, empty", placeholder: field.label, name: (_o = this.names) === null || _o === void 0 ? void 0 : _o.state, autocomplete: 'address-level1', value: (_q = (_p = this === null || this === void 0 ? void 0 : this.address) === null || _p === void 0 ? void 0 : _p.state) !== null && _q !== void 0 ? _q : '', onScChange: (e) => { var _a; return this.updateAddress({ state: e.target.value || ((_a = e.detail) === null || _a === void 0 ? void 0 : _a.value) || null }); }, choices: this.regions(), required: isRequired, disabled: this.disabled, search: true, "aria-label": field.label, ...roundedProps }));
253 case 'postal_code':
254 return (h("sc-input", { exportparts: "base:input__base, input, form-control, label, help-text", placeholder: field.label, name: (_r = this.names) === null || _r === void 0 ? void 0 : _r.postal_code, onScChange: (e) => this.updateAddress({ postal_code: e.target.value || null }), onScInput: (e) => this.handleAddressInput({ postal_code: e.target.value || null }), autocomplete: 'postal-code', required: isRequired, value: (_t = (_s = this === null || this === void 0 ? void 0 : this.address) === null || _s === void 0 ? void 0 : _s.postal_code) !== null && _t !== void 0 ? _t : '', disabled: this.disabled, maxlength: ((_u = this.address) === null || _u === void 0 ? void 0 : _u.country) === 'US' ? 5 : undefined, pattern: ((_v = this.countryDetails) === null || _v === void 0 ? void 0 : _v.postal_code_regex) || undefined, customValidity: ((_w = this.countryDetails) === null || _w === void 0 ? void 0 : _w.postal_code_regex) ? wp.i18n.__('Please enter a valid postal code', 'surecart') : undefined, "aria-label": field.label, ...roundedProps }));
255 default:
256 return null;
257 }
258 }
259 render() {
260 var _a;
261 const allFields = ((_a = this.sortedFields()) !== null && _a !== void 0 ? _a : []).filter(field => this.isFieldIncluded(field));
262 const isExpanded = this.isFieldsExpanded();
263 // Split fields into always-visible (country, name, line_1) and collapsible (line_2, city, state, postal_code).
264 const topFields = allFields.filter(f => !this.collapsibleFieldNames.includes(f.name));
265 const bottomFields = allFields.filter(f => this.collapsibleFieldNames.includes(f.name));
266 // Compute rounded props based on visible field count.
267 const totalForRounding = isExpanded ? allFields.length : topFields.length;
268 return (h("div", { key: 'ba1ed2067d50196cd0d6c68ee839352d2a72ce64', class: "sc-address", part: "base" }, h("sc-form-control", { key: '105400104fd116ae3500b22d0c7a24e1acda2906', label: this.label, exportparts: "label, help-text, form-control", class: "sc-address__control", required: this.required }, topFields.map((field, index) => {
269 const roundedProps = this.getRoundedProps(index, totalForRounding);
270 return this.renderField(field, roundedProps, this.required);
271 }), h("div", { key: '174f812cdc782b42d5f8266e973e8d894221f9da', class: {
272 'sc-address__collapsible': true,
273 'sc-address__collapsible--expanded': isExpanded,
274 }, "aria-hidden": !isExpanded ? 'true' : 'false' }, bottomFields.map((field, index) => {
275 const globalIndex = topFields.length + index;
276 const roundedProps = this.getRoundedProps(globalIndex, allFields.length);
277 // Don't require fields when collapsed — prevents hidden required validation errors.
278 const isRequired = this.required && isExpanded;
279 return this.renderField(field, roundedProps, isRequired);
280 }))), this.loading && h("sc-block-ui", { key: 'f69988f83c0c24371521f4db15a29808052c66b4', exportparts: "base:block-ui, content:block-ui__content" })));
281 }
282 get el() { return getElement(this); }
283 static get watchers() { return {
284 "address": ["handleAddressChange"],
285 "requireName": ["handleNameChange"]
286 }; }
287 };
288 ScAddress.style = ScAddressStyle0;
289
290 var lodash = {exports: {}};
291
292 /**
293 * @license
294 * Lodash <https://lodash.com/>
295 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
296 * Released under MIT license <https://lodash.com/license>
297 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
298 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
299 */
300
301 (function (module, exports) {
302 (function() {
303
304 /** Used as a safe reference for `undefined` in pre-ES5 environments. */
305 var undefined$1;
306
307 /** Used as the semantic version number. */
308 var VERSION = '4.17.21';
309
310 /** Used as the size to enable large array optimizations. */
311 var LARGE_ARRAY_SIZE = 200;
312
313 /** Error message constants. */
314 var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
315 FUNC_ERROR_TEXT = 'Expected a function',
316 INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
317
318 /** Used to stand-in for `undefined` hash values. */
319 var HASH_UNDEFINED = '__lodash_hash_undefined__';
320
321 /** Used as the maximum memoize cache size. */
322 var MAX_MEMOIZE_SIZE = 500;
323
324 /** Used as the internal argument placeholder. */
325 var PLACEHOLDER = '__lodash_placeholder__';
326
327 /** Used to compose bitmasks for cloning. */
328 var CLONE_DEEP_FLAG = 1,
329 CLONE_FLAT_FLAG = 2,
330 CLONE_SYMBOLS_FLAG = 4;
331
332 /** Used to compose bitmasks for value comparisons. */
333 var COMPARE_PARTIAL_FLAG = 1,
334 COMPARE_UNORDERED_FLAG = 2;
335
336 /** Used to compose bitmasks for function metadata. */
337 var WRAP_BIND_FLAG = 1,
338 WRAP_BIND_KEY_FLAG = 2,
339 WRAP_CURRY_BOUND_FLAG = 4,
340 WRAP_CURRY_FLAG = 8,
341 WRAP_CURRY_RIGHT_FLAG = 16,
342 WRAP_PARTIAL_FLAG = 32,
343 WRAP_PARTIAL_RIGHT_FLAG = 64,
344 WRAP_ARY_FLAG = 128,
345 WRAP_REARG_FLAG = 256,
346 WRAP_FLIP_FLAG = 512;
347
348 /** Used as default options for `_.truncate`. */
349 var DEFAULT_TRUNC_LENGTH = 30,
350 DEFAULT_TRUNC_OMISSION = '...';
351
352 /** Used to detect hot functions by number of calls within a span of milliseconds. */
353 var HOT_COUNT = 800,
354 HOT_SPAN = 16;
355
356 /** Used to indicate the type of lazy iteratees. */
357 var LAZY_FILTER_FLAG = 1,
358 LAZY_MAP_FLAG = 2,
359 LAZY_WHILE_FLAG = 3;
360
361 /** Used as references for various `Number` constants. */
362 var INFINITY = 1 / 0,
363 MAX_SAFE_INTEGER = 9007199254740991,
364 MAX_INTEGER = 1.7976931348623157e+308,
365 NAN = 0 / 0;
366
367 /** Used as references for the maximum length and index of an array. */
368 var MAX_ARRAY_LENGTH = 4294967295,
369 MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
370 HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
371
372 /** Used to associate wrap methods with their bit flags. */
373 var wrapFlags = [
374 ['ary', WRAP_ARY_FLAG],
375 ['bind', WRAP_BIND_FLAG],
376 ['bindKey', WRAP_BIND_KEY_FLAG],
377 ['curry', WRAP_CURRY_FLAG],
378 ['curryRight', WRAP_CURRY_RIGHT_FLAG],
379 ['flip', WRAP_FLIP_FLAG],
380 ['partial', WRAP_PARTIAL_FLAG],
381 ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
382 ['rearg', WRAP_REARG_FLAG]
383 ];
384
385 /** `Object#toString` result references. */
386 var argsTag = '[object Arguments]',
387 arrayTag = '[object Array]',
388 asyncTag = '[object AsyncFunction]',
389 boolTag = '[object Boolean]',
390 dateTag = '[object Date]',
391 domExcTag = '[object DOMException]',
392 errorTag = '[object Error]',
393 funcTag = '[object Function]',
394 genTag = '[object GeneratorFunction]',
395 mapTag = '[object Map]',
396 numberTag = '[object Number]',
397 nullTag = '[object Null]',
398 objectTag = '[object Object]',
399 promiseTag = '[object Promise]',
400 proxyTag = '[object Proxy]',
401 regexpTag = '[object RegExp]',
402 setTag = '[object Set]',
403 stringTag = '[object String]',
404 symbolTag = '[object Symbol]',
405 undefinedTag = '[object Undefined]',
406 weakMapTag = '[object WeakMap]',
407 weakSetTag = '[object WeakSet]';
408
409 var arrayBufferTag = '[object ArrayBuffer]',
410 dataViewTag = '[object DataView]',
411 float32Tag = '[object Float32Array]',
412 float64Tag = '[object Float64Array]',
413 int8Tag = '[object Int8Array]',
414 int16Tag = '[object Int16Array]',
415 int32Tag = '[object Int32Array]',
416 uint8Tag = '[object Uint8Array]',
417 uint8ClampedTag = '[object Uint8ClampedArray]',
418 uint16Tag = '[object Uint16Array]',
419 uint32Tag = '[object Uint32Array]';
420
421 /** Used to match empty string literals in compiled template source. */
422 var reEmptyStringLeading = /\b__p \+= '';/g,
423 reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
424 reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
425
426 /** Used to match HTML entities and HTML characters. */
427 var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
428 reUnescapedHtml = /[&<>"']/g,
429 reHasEscapedHtml = RegExp(reEscapedHtml.source),
430 reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
431
432 /** Used to match template delimiters. */
433 var reEscape = /<%-([\s\S]+?)%>/g,
434 reEvaluate = /<%([\s\S]+?)%>/g,
435 reInterpolate = /<%=([\s\S]+?)%>/g;
436
437 /** Used to match property names within property paths. */
438 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
439 reIsPlainProp = /^\w*$/,
440 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
441
442 /**
443 * Used to match `RegExp`
444 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
445 */
446 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
447 reHasRegExpChar = RegExp(reRegExpChar.source);
448
449 /** Used to match leading whitespace. */
450 var reTrimStart = /^\s+/;
451
452 /** Used to match a single whitespace character. */
453 var reWhitespace = /\s/;
454
455 /** Used to match wrap detail comments. */
456 var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
457 reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
458 reSplitDetails = /,? & /;
459
460 /** Used to match words composed of alphanumeric characters. */
461 var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
462
463 /**
464 * Used to validate the `validate` option in `_.template` variable.
465 *
466 * Forbids characters which could potentially change the meaning of the function argument definition:
467 * - "()," (modification of function parameters)
468 * - "=" (default value)
469 * - "[]{}" (destructuring of function parameters)
470 * - "/" (beginning of a comment)
471 * - whitespace
472 */
473 var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
474
475 /** Used to match backslashes in property paths. */
476 var reEscapeChar = /\\(\\)?/g;
477
478 /**
479 * Used to match
480 * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
481 */
482 var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
483
484 /** Used to match `RegExp` flags from their coerced string values. */
485 var reFlags = /\w*$/;
486
487 /** Used to detect bad signed hexadecimal string values. */
488 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
489
490 /** Used to detect binary string values. */
491 var reIsBinary = /^0b[01]+$/i;
492
493 /** Used to detect host constructors (Safari). */
494 var reIsHostCtor = /^\[object .+?Constructor\]$/;
495
496 /** Used to detect octal string values. */
497 var reIsOctal = /^0o[0-7]+$/i;
498
499 /** Used to detect unsigned integer values. */
500 var reIsUint = /^(?:0|[1-9]\d*)$/;
501
502 /** Used to match Latin Unicode letters (excluding mathematical operators). */
503 var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
504
505 /** Used to ensure capturing order of template delimiters. */
506 var reNoMatch = /($^)/;
507
508 /** Used to match unescaped characters in compiled string literals. */
509 var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
510
511 /** Used to compose unicode character classes. */
512 var rsAstralRange = '\\ud800-\\udfff',
513 rsComboMarksRange = '\\u0300-\\u036f',
514 reComboHalfMarksRange = '\\ufe20-\\ufe2f',
515 rsComboSymbolsRange = '\\u20d0-\\u20ff',
516 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
517 rsDingbatRange = '\\u2700-\\u27bf',
518 rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
519 rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
520 rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
521 rsPunctuationRange = '\\u2000-\\u206f',
522 rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
523 rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
524 rsVarRange = '\\ufe0e\\ufe0f',
525 rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
526
527 /** Used to compose unicode capture groups. */
528 var rsApos = "['\u2019]",
529 rsAstral = '[' + rsAstralRange + ']',
530 rsBreak = '[' + rsBreakRange + ']',
531 rsCombo = '[' + rsComboRange + ']',
532 rsDigits = '\\d+',
533 rsDingbat = '[' + rsDingbatRange + ']',
534 rsLower = '[' + rsLowerRange + ']',
535 rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
536 rsFitz = '\\ud83c[\\udffb-\\udfff]',
537 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
538 rsNonAstral = '[^' + rsAstralRange + ']',
539 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
540 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
541 rsUpper = '[' + rsUpperRange + ']',
542 rsZWJ = '\\u200d';
543
544 /** Used to compose unicode regexes. */
545 var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
546 rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
547 rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
548 rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
549 reOptMod = rsModifier + '?',
550 rsOptVar = '[' + rsVarRange + ']?',
551 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
552 rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
553 rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
554 rsSeq = rsOptVar + reOptMod + rsOptJoin,
555 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
556 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
557
558 /** Used to match apostrophes. */
559 var reApos = RegExp(rsApos, 'g');
560
561 /**
562 * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
563 * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
564 */
565 var reComboMark = RegExp(rsCombo, 'g');
566
567 /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
568 var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
569
570 /** Used to match complex or compound words. */
571 var reUnicodeWord = RegExp([
572 rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
573 rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
574 rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
575 rsUpper + '+' + rsOptContrUpper,
576 rsOrdUpper,
577 rsOrdLower,
578 rsDigits,
579 rsEmoji
580 ].join('|'), 'g');
581
582 /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
583 var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
584
585 /** Used to detect strings that need a more robust regexp to match words. */
586 var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
587
588 /** Used to assign default `context` object properties. */
589 var contextProps = [
590 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
591 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
592 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
593 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
594 '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
595 ];
596
597 /** Used to make template sourceURLs easier to identify. */
598 var templateCounter = -1;
599
600 /** Used to identify `toStringTag` values of typed arrays. */
601 var typedArrayTags = {};
602 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
603 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
604 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
605 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
606 typedArrayTags[uint32Tag] = true;
607 typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
608 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
609 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
610 typedArrayTags[errorTag] = typedArrayTags[funcTag] =
611 typedArrayTags[mapTag] = typedArrayTags[numberTag] =
612 typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
613 typedArrayTags[setTag] = typedArrayTags[stringTag] =
614 typedArrayTags[weakMapTag] = false;
615
616 /** Used to identify `toStringTag` values supported by `_.clone`. */
617 var cloneableTags = {};
618 cloneableTags[argsTag] = cloneableTags[arrayTag] =
619 cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
620 cloneableTags[boolTag] = cloneableTags[dateTag] =
621 cloneableTags[float32Tag] = cloneableTags[float64Tag] =
622 cloneableTags[int8Tag] = cloneableTags[int16Tag] =
623 cloneableTags[int32Tag] = cloneableTags[mapTag] =
624 cloneableTags[numberTag] = cloneableTags[objectTag] =
625 cloneableTags[regexpTag] = cloneableTags[setTag] =
626 cloneableTags[stringTag] = cloneableTags[symbolTag] =
627 cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
628 cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
629 cloneableTags[errorTag] = cloneableTags[funcTag] =
630 cloneableTags[weakMapTag] = false;
631
632 /** Used to map Latin Unicode letters to basic Latin letters. */
633 var deburredLetters = {
634 // Latin-1 Supplement block.
635 '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
636 '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
637 '\xc7': 'C', '\xe7': 'c',
638 '\xd0': 'D', '\xf0': 'd',
639 '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
640 '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
641 '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
642 '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
643 '\xd1': 'N', '\xf1': 'n',
644 '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
645 '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
646 '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
647 '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
648 '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
649 '\xc6': 'Ae', '\xe6': 'ae',
650 '\xde': 'Th', '\xfe': 'th',
651 '\xdf': 'ss',
652 // Latin Extended-A block.
653 '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
654 '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
655 '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
656 '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
657 '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
658 '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
659 '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
660 '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
661 '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
662 '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
663 '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
664 '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
665 '\u0134': 'J', '\u0135': 'j',
666 '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
667 '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
668 '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
669 '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
670 '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
671 '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
672 '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
673 '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
674 '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
675 '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
676 '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
677 '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
678 '\u0163': 't', '\u0165': 't', '\u0167': 't',
679 '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
680 '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
681 '\u0174': 'W', '\u0175': 'w',
682 '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
683 '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
684 '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
685 '\u0132': 'IJ', '\u0133': 'ij',
686 '\u0152': 'Oe', '\u0153': 'oe',
687 '\u0149': "'n", '\u017f': 's'
688 };
689
690 /** Used to map characters to HTML entities. */
691 var htmlEscapes = {
692 '&': '&amp;',
693 '<': '&lt;',
694 '>': '&gt;',
695 '"': '&quot;',
696 "'": '&#39;'
697 };
698
699 /** Used to map HTML entities to characters. */
700 var htmlUnescapes = {
701 '&amp;': '&',
702 '&lt;': '<',
703 '&gt;': '>',
704 '&quot;': '"',
705 '&#39;': "'"
706 };
707
708 /** Used to escape characters for inclusion in compiled string literals. */
709 var stringEscapes = {
710 '\\': '\\',
711 "'": "'",
712 '\n': 'n',
713 '\r': 'r',
714 '\u2028': 'u2028',
715 '\u2029': 'u2029'
716 };
717
718 /** Built-in method references without a dependency on `root`. */
719 var freeParseFloat = parseFloat,
720 freeParseInt = parseInt;
721
722 /** Detect free variable `global` from Node.js. */
723 var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
724
725 /** Detect free variable `self`. */
726 var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
727
728 /** Used as a reference to the global object. */
729 var root = freeGlobal || freeSelf || Function('return this')();
730
731 /** Detect free variable `exports`. */
732 var freeExports = exports && !exports.nodeType && exports;
733
734 /** Detect free variable `module`. */
735 var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
736
737 /** Detect the popular CommonJS extension `module.exports`. */
738 var moduleExports = freeModule && freeModule.exports === freeExports;
739
740 /** Detect free variable `process` from Node.js. */
741 var freeProcess = moduleExports && freeGlobal.process;
742
743 /** Used to access faster Node.js helpers. */
744 var nodeUtil = (function() {
745 try {
746 // Use `util.types` for Node.js 10+.
747 var types = freeModule && freeModule.require && freeModule.require('util').types;
748
749 if (types) {
750 return types;
751 }
752
753 // Legacy `process.binding('util')` for Node.js < 10.
754 return freeProcess && freeProcess.binding && freeProcess.binding('util');
755 } catch (e) {}
756 }());
757
758 /* Node.js helper references. */
759 var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
760 nodeIsDate = nodeUtil && nodeUtil.isDate,
761 nodeIsMap = nodeUtil && nodeUtil.isMap,
762 nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
763 nodeIsSet = nodeUtil && nodeUtil.isSet,
764 nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
765
766 /*--------------------------------------------------------------------------*/
767
768 /**
769 * A faster alternative to `Function#apply`, this function invokes `func`
770 * with the `this` binding of `thisArg` and the arguments of `args`.
771 *
772 * @private
773 * @param {Function} func The function to invoke.
774 * @param {*} thisArg The `this` binding of `func`.
775 * @param {Array} args The arguments to invoke `func` with.
776 * @returns {*} Returns the result of `func`.
777 */
778 function apply(func, thisArg, args) {
779 switch (args.length) {
780 case 0: return func.call(thisArg);
781 case 1: return func.call(thisArg, args[0]);
782 case 2: return func.call(thisArg, args[0], args[1]);
783 case 3: return func.call(thisArg, args[0], args[1], args[2]);
784 }
785 return func.apply(thisArg, args);
786 }
787
788 /**
789 * A specialized version of `baseAggregator` for arrays.
790 *
791 * @private
792 * @param {Array} [array] The array to iterate over.
793 * @param {Function} setter The function to set `accumulator` values.
794 * @param {Function} iteratee The iteratee to transform keys.
795 * @param {Object} accumulator The initial aggregated object.
796 * @returns {Function} Returns `accumulator`.
797 */
798 function arrayAggregator(array, setter, iteratee, accumulator) {
799 var index = -1,
800 length = array == null ? 0 : array.length;
801
802 while (++index < length) {
803 var value = array[index];
804 setter(accumulator, value, iteratee(value), array);
805 }
806 return accumulator;
807 }
808
809 /**
810 * A specialized version of `_.forEach` for arrays without support for
811 * iteratee shorthands.
812 *
813 * @private
814 * @param {Array} [array] The array to iterate over.
815 * @param {Function} iteratee The function invoked per iteration.
816 * @returns {Array} Returns `array`.
817 */
818 function arrayEach(array, iteratee) {
819 var index = -1,
820 length = array == null ? 0 : array.length;
821
822 while (++index < length) {
823 if (iteratee(array[index], index, array) === false) {
824 break;
825 }
826 }
827 return array;
828 }
829
830 /**
831 * A specialized version of `_.forEachRight` for arrays without support for
832 * iteratee shorthands.
833 *
834 * @private
835 * @param {Array} [array] The array to iterate over.
836 * @param {Function} iteratee The function invoked per iteration.
837 * @returns {Array} Returns `array`.
838 */
839 function arrayEachRight(array, iteratee) {
840 var length = array == null ? 0 : array.length;
841
842 while (length--) {
843 if (iteratee(array[length], length, array) === false) {
844 break;
845 }
846 }
847 return array;
848 }
849
850 /**
851 * A specialized version of `_.every` for arrays without support for
852 * iteratee shorthands.
853 *
854 * @private
855 * @param {Array} [array] The array to iterate over.
856 * @param {Function} predicate The function invoked per iteration.
857 * @returns {boolean} Returns `true` if all elements pass the predicate check,
858 * else `false`.
859 */
860 function arrayEvery(array, predicate) {
861 var index = -1,
862 length = array == null ? 0 : array.length;
863
864 while (++index < length) {
865 if (!predicate(array[index], index, array)) {
866 return false;
867 }
868 }
869 return true;
870 }
871
872 /**
873 * A specialized version of `_.filter` for arrays without support for
874 * iteratee shorthands.
875 *
876 * @private
877 * @param {Array} [array] The array to iterate over.
878 * @param {Function} predicate The function invoked per iteration.
879 * @returns {Array} Returns the new filtered array.
880 */
881 function arrayFilter(array, predicate) {
882 var index = -1,
883 length = array == null ? 0 : array.length,
884 resIndex = 0,
885 result = [];
886
887 while (++index < length) {
888 var value = array[index];
889 if (predicate(value, index, array)) {
890 result[resIndex++] = value;
891 }
892 }
893 return result;
894 }
895
896 /**
897 * A specialized version of `_.includes` for arrays without support for
898 * specifying an index to search from.
899 *
900 * @private
901 * @param {Array} [array] The array to inspect.
902 * @param {*} target The value to search for.
903 * @returns {boolean} Returns `true` if `target` is found, else `false`.
904 */
905 function arrayIncludes(array, value) {
906 var length = array == null ? 0 : array.length;
907 return !!length && baseIndexOf(array, value, 0) > -1;
908 }
909
910 /**
911 * This function is like `arrayIncludes` except that it accepts a comparator.
912 *
913 * @private
914 * @param {Array} [array] The array to inspect.
915 * @param {*} target The value to search for.
916 * @param {Function} comparator The comparator invoked per element.
917 * @returns {boolean} Returns `true` if `target` is found, else `false`.
918 */
919 function arrayIncludesWith(array, value, comparator) {
920 var index = -1,
921 length = array == null ? 0 : array.length;
922
923 while (++index < length) {
924 if (comparator(value, array[index])) {
925 return true;
926 }
927 }
928 return false;
929 }
930
931 /**
932 * A specialized version of `_.map` for arrays without support for iteratee
933 * shorthands.
934 *
935 * @private
936 * @param {Array} [array] The array to iterate over.
937 * @param {Function} iteratee The function invoked per iteration.
938 * @returns {Array} Returns the new mapped array.
939 */
940 function arrayMap(array, iteratee) {
941 var index = -1,
942 length = array == null ? 0 : array.length,
943 result = Array(length);
944
945 while (++index < length) {
946 result[index] = iteratee(array[index], index, array);
947 }
948 return result;
949 }
950
951 /**
952 * Appends the elements of `values` to `array`.
953 *
954 * @private
955 * @param {Array} array The array to modify.
956 * @param {Array} values The values to append.
957 * @returns {Array} Returns `array`.
958 */
959 function arrayPush(array, values) {
960 var index = -1,
961 length = values.length,
962 offset = array.length;
963
964 while (++index < length) {
965 array[offset + index] = values[index];
966 }
967 return array;
968 }
969
970 /**
971 * A specialized version of `_.reduce` for arrays without support for
972 * iteratee shorthands.
973 *
974 * @private
975 * @param {Array} [array] The array to iterate over.
976 * @param {Function} iteratee The function invoked per iteration.
977 * @param {*} [accumulator] The initial value.
978 * @param {boolean} [initAccum] Specify using the first element of `array` as
979 * the initial value.
980 * @returns {*} Returns the accumulated value.
981 */
982 function arrayReduce(array, iteratee, accumulator, initAccum) {
983 var index = -1,
984 length = array == null ? 0 : array.length;
985
986 if (initAccum && length) {
987 accumulator = array[++index];
988 }
989 while (++index < length) {
990 accumulator = iteratee(accumulator, array[index], index, array);
991 }
992 return accumulator;
993 }
994
995 /**
996 * A specialized version of `_.reduceRight` for arrays without support for
997 * iteratee shorthands.
998 *
999 * @private
1000 * @param {Array} [array] The array to iterate over.
1001 * @param {Function} iteratee The function invoked per iteration.
1002 * @param {*} [accumulator] The initial value.
1003 * @param {boolean} [initAccum] Specify using the last element of `array` as
1004 * the initial value.
1005 * @returns {*} Returns the accumulated value.
1006 */
1007 function arrayReduceRight(array, iteratee, accumulator, initAccum) {
1008 var length = array == null ? 0 : array.length;
1009 if (initAccum && length) {
1010 accumulator = array[--length];
1011 }
1012 while (length--) {
1013 accumulator = iteratee(accumulator, array[length], length, array);
1014 }
1015 return accumulator;
1016 }
1017
1018 /**
1019 * A specialized version of `_.some` for arrays without support for iteratee
1020 * shorthands.
1021 *
1022 * @private
1023 * @param {Array} [array] The array to iterate over.
1024 * @param {Function} predicate The function invoked per iteration.
1025 * @returns {boolean} Returns `true` if any element passes the predicate check,
1026 * else `false`.
1027 */
1028 function arraySome(array, predicate) {
1029 var index = -1,
1030 length = array == null ? 0 : array.length;
1031
1032 while (++index < length) {
1033 if (predicate(array[index], index, array)) {
1034 return true;
1035 }
1036 }
1037 return false;
1038 }
1039
1040 /**
1041 * Gets the size of an ASCII `string`.
1042 *
1043 * @private
1044 * @param {string} string The string inspect.
1045 * @returns {number} Returns the string size.
1046 */
1047 var asciiSize = baseProperty('length');
1048
1049 /**
1050 * Converts an ASCII `string` to an array.
1051 *
1052 * @private
1053 * @param {string} string The string to convert.
1054 * @returns {Array} Returns the converted array.
1055 */
1056 function asciiToArray(string) {
1057 return string.split('');
1058 }
1059
1060 /**
1061 * Splits an ASCII `string` into an array of its words.
1062 *
1063 * @private
1064 * @param {string} The string to inspect.
1065 * @returns {Array} Returns the words of `string`.
1066 */
1067 function asciiWords(string) {
1068 return string.match(reAsciiWord) || [];
1069 }
1070
1071 /**
1072 * The base implementation of methods like `_.findKey` and `_.findLastKey`,
1073 * without support for iteratee shorthands, which iterates over `collection`
1074 * using `eachFunc`.
1075 *
1076 * @private
1077 * @param {Array|Object} collection The collection to inspect.
1078 * @param {Function} predicate The function invoked per iteration.
1079 * @param {Function} eachFunc The function to iterate over `collection`.
1080 * @returns {*} Returns the found element or its key, else `undefined`.
1081 */
1082 function baseFindKey(collection, predicate, eachFunc) {
1083 var result;
1084 eachFunc(collection, function(value, key, collection) {
1085 if (predicate(value, key, collection)) {
1086 result = key;
1087 return false;
1088 }
1089 });
1090 return result;
1091 }
1092
1093 /**
1094 * The base implementation of `_.findIndex` and `_.findLastIndex` without
1095 * support for iteratee shorthands.
1096 *
1097 * @private
1098 * @param {Array} array The array to inspect.
1099 * @param {Function} predicate The function invoked per iteration.
1100 * @param {number} fromIndex The index to search from.
1101 * @param {boolean} [fromRight] Specify iterating from right to left.
1102 * @returns {number} Returns the index of the matched value, else `-1`.
1103 */
1104 function baseFindIndex(array, predicate, fromIndex, fromRight) {
1105 var length = array.length,
1106 index = fromIndex + (fromRight ? 1 : -1);
1107
1108 while ((fromRight ? index-- : ++index < length)) {
1109 if (predicate(array[index], index, array)) {
1110 return index;
1111 }
1112 }
1113 return -1;
1114 }
1115
1116 /**
1117 * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
1118 *
1119 * @private
1120 * @param {Array} array The array to inspect.
1121 * @param {*} value The value to search for.
1122 * @param {number} fromIndex The index to search from.
1123 * @returns {number} Returns the index of the matched value, else `-1`.
1124 */
1125 function baseIndexOf(array, value, fromIndex) {
1126 return value === value
1127 ? strictIndexOf(array, value, fromIndex)
1128 : baseFindIndex(array, baseIsNaN, fromIndex);
1129 }
1130
1131 /**
1132 * This function is like `baseIndexOf` except that it accepts a comparator.
1133 *
1134 * @private
1135 * @param {Array} array The array to inspect.
1136 * @param {*} value The value to search for.
1137 * @param {number} fromIndex The index to search from.
1138 * @param {Function} comparator The comparator invoked per element.
1139 * @returns {number} Returns the index of the matched value, else `-1`.
1140 */
1141 function baseIndexOfWith(array, value, fromIndex, comparator) {
1142 var index = fromIndex - 1,
1143 length = array.length;
1144
1145 while (++index < length) {
1146 if (comparator(array[index], value)) {
1147 return index;
1148 }
1149 }
1150 return -1;
1151 }
1152
1153 /**
1154 * The base implementation of `_.isNaN` without support for number objects.
1155 *
1156 * @private
1157 * @param {*} value The value to check.
1158 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
1159 */
1160 function baseIsNaN(value) {
1161 return value !== value;
1162 }
1163
1164 /**
1165 * The base implementation of `_.mean` and `_.meanBy` without support for
1166 * iteratee shorthands.
1167 *
1168 * @private
1169 * @param {Array} array The array to iterate over.
1170 * @param {Function} iteratee The function invoked per iteration.
1171 * @returns {number} Returns the mean.
1172 */
1173 function baseMean(array, iteratee) {
1174 var length = array == null ? 0 : array.length;
1175 return length ? (baseSum(array, iteratee) / length) : NAN;
1176 }
1177
1178 /**
1179 * The base implementation of `_.property` without support for deep paths.
1180 *
1181 * @private
1182 * @param {string} key The key of the property to get.
1183 * @returns {Function} Returns the new accessor function.
1184 */
1185 function baseProperty(key) {
1186 return function(object) {
1187 return object == null ? undefined$1 : object[key];
1188 };
1189 }
1190
1191 /**
1192 * The base implementation of `_.propertyOf` without support for deep paths.
1193 *
1194 * @private
1195 * @param {Object} object The object to query.
1196 * @returns {Function} Returns the new accessor function.
1197 */
1198 function basePropertyOf(object) {
1199 return function(key) {
1200 return object == null ? undefined$1 : object[key];
1201 };
1202 }
1203
1204 /**
1205 * The base implementation of `_.reduce` and `_.reduceRight`, without support
1206 * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
1207 *
1208 * @private
1209 * @param {Array|Object} collection The collection to iterate over.
1210 * @param {Function} iteratee The function invoked per iteration.
1211 * @param {*} accumulator The initial value.
1212 * @param {boolean} initAccum Specify using the first or last element of
1213 * `collection` as the initial value.
1214 * @param {Function} eachFunc The function to iterate over `collection`.
1215 * @returns {*} Returns the accumulated value.
1216 */
1217 function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
1218 eachFunc(collection, function(value, index, collection) {
1219 accumulator = initAccum
1220 ? (initAccum = false, value)
1221 : iteratee(accumulator, value, index, collection);
1222 });
1223 return accumulator;
1224 }
1225
1226 /**
1227 * The base implementation of `_.sortBy` which uses `comparer` to define the
1228 * sort order of `array` and replaces criteria objects with their corresponding
1229 * values.
1230 *
1231 * @private
1232 * @param {Array} array The array to sort.
1233 * @param {Function} comparer The function to define sort order.
1234 * @returns {Array} Returns `array`.
1235 */
1236 function baseSortBy(array, comparer) {
1237 var length = array.length;
1238
1239 array.sort(comparer);
1240 while (length--) {
1241 array[length] = array[length].value;
1242 }
1243 return array;
1244 }
1245
1246 /**
1247 * The base implementation of `_.sum` and `_.sumBy` without support for
1248 * iteratee shorthands.
1249 *
1250 * @private
1251 * @param {Array} array The array to iterate over.
1252 * @param {Function} iteratee The function invoked per iteration.
1253 * @returns {number} Returns the sum.
1254 */
1255 function baseSum(array, iteratee) {
1256 var result,
1257 index = -1,
1258 length = array.length;
1259
1260 while (++index < length) {
1261 var current = iteratee(array[index]);
1262 if (current !== undefined$1) {
1263 result = result === undefined$1 ? current : (result + current);
1264 }
1265 }
1266 return result;
1267 }
1268
1269 /**
1270 * The base implementation of `_.times` without support for iteratee shorthands
1271 * or max array length checks.
1272 *
1273 * @private
1274 * @param {number} n The number of times to invoke `iteratee`.
1275 * @param {Function} iteratee The function invoked per iteration.
1276 * @returns {Array} Returns the array of results.
1277 */
1278 function baseTimes(n, iteratee) {
1279 var index = -1,
1280 result = Array(n);
1281
1282 while (++index < n) {
1283 result[index] = iteratee(index);
1284 }
1285 return result;
1286 }
1287
1288 /**
1289 * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
1290 * of key-value pairs for `object` corresponding to the property names of `props`.
1291 *
1292 * @private
1293 * @param {Object} object The object to query.
1294 * @param {Array} props The property names to get values for.
1295 * @returns {Object} Returns the key-value pairs.
1296 */
1297 function baseToPairs(object, props) {
1298 return arrayMap(props, function(key) {
1299 return [key, object[key]];
1300 });
1301 }
1302
1303 /**
1304 * The base implementation of `_.trim`.
1305 *
1306 * @private
1307 * @param {string} string The string to trim.
1308 * @returns {string} Returns the trimmed string.
1309 */
1310 function baseTrim(string) {
1311 return string
1312 ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
1313 : string;
1314 }
1315
1316 /**
1317 * The base implementation of `_.unary` without support for storing metadata.
1318 *
1319 * @private
1320 * @param {Function} func The function to cap arguments for.
1321 * @returns {Function} Returns the new capped function.
1322 */
1323 function baseUnary(func) {
1324 return function(value) {
1325 return func(value);
1326 };
1327 }
1328
1329 /**
1330 * The base implementation of `_.values` and `_.valuesIn` which creates an
1331 * array of `object` property values corresponding to the property names
1332 * of `props`.
1333 *
1334 * @private
1335 * @param {Object} object The object to query.
1336 * @param {Array} props The property names to get values for.
1337 * @returns {Object} Returns the array of property values.
1338 */
1339 function baseValues(object, props) {
1340 return arrayMap(props, function(key) {
1341 return object[key];
1342 });
1343 }
1344
1345 /**
1346 * Checks if a `cache` value for `key` exists.
1347 *
1348 * @private
1349 * @param {Object} cache The cache to query.
1350 * @param {string} key The key of the entry to check.
1351 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1352 */
1353 function cacheHas(cache, key) {
1354 return cache.has(key);
1355 }
1356
1357 /**
1358 * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
1359 * that is not found in the character symbols.
1360 *
1361 * @private
1362 * @param {Array} strSymbols The string symbols to inspect.
1363 * @param {Array} chrSymbols The character symbols to find.
1364 * @returns {number} Returns the index of the first unmatched string symbol.
1365 */
1366 function charsStartIndex(strSymbols, chrSymbols) {
1367 var index = -1,
1368 length = strSymbols.length;
1369
1370 while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
1371 return index;
1372 }
1373
1374 /**
1375 * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
1376 * that is not found in the character symbols.
1377 *
1378 * @private
1379 * @param {Array} strSymbols The string symbols to inspect.
1380 * @param {Array} chrSymbols The character symbols to find.
1381 * @returns {number} Returns the index of the last unmatched string symbol.
1382 */
1383 function charsEndIndex(strSymbols, chrSymbols) {
1384 var index = strSymbols.length;
1385
1386 while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
1387 return index;
1388 }
1389
1390 /**
1391 * Gets the number of `placeholder` occurrences in `array`.
1392 *
1393 * @private
1394 * @param {Array} array The array to inspect.
1395 * @param {*} placeholder The placeholder to search for.
1396 * @returns {number} Returns the placeholder count.
1397 */
1398 function countHolders(array, placeholder) {
1399 var length = array.length,
1400 result = 0;
1401
1402 while (length--) {
1403 if (array[length] === placeholder) {
1404 ++result;
1405 }
1406 }
1407 return result;
1408 }
1409
1410 /**
1411 * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
1412 * letters to basic Latin letters.
1413 *
1414 * @private
1415 * @param {string} letter The matched letter to deburr.
1416 * @returns {string} Returns the deburred letter.
1417 */
1418 var deburrLetter = basePropertyOf(deburredLetters);
1419
1420 /**
1421 * Used by `_.escape` to convert characters to HTML entities.
1422 *
1423 * @private
1424 * @param {string} chr The matched character to escape.
1425 * @returns {string} Returns the escaped character.
1426 */
1427 var escapeHtmlChar = basePropertyOf(htmlEscapes);
1428
1429 /**
1430 * Used by `_.template` to escape characters for inclusion in compiled string literals.
1431 *
1432 * @private
1433 * @param {string} chr The matched character to escape.
1434 * @returns {string} Returns the escaped character.
1435 */
1436 function escapeStringChar(chr) {
1437 return '\\' + stringEscapes[chr];
1438 }
1439
1440 /**
1441 * Gets the value at `key` of `object`.
1442 *
1443 * @private
1444 * @param {Object} [object] The object to query.
1445 * @param {string} key The key of the property to get.
1446 * @returns {*} Returns the property value.
1447 */
1448 function getValue(object, key) {
1449 return object == null ? undefined$1 : object[key];
1450 }
1451
1452 /**
1453 * Checks if `string` contains Unicode symbols.
1454 *
1455 * @private
1456 * @param {string} string The string to inspect.
1457 * @returns {boolean} Returns `true` if a symbol is found, else `false`.
1458 */
1459 function hasUnicode(string) {
1460 return reHasUnicode.test(string);
1461 }
1462
1463 /**
1464 * Checks if `string` contains a word composed of Unicode symbols.
1465 *
1466 * @private
1467 * @param {string} string The string to inspect.
1468 * @returns {boolean} Returns `true` if a word is found, else `false`.
1469 */
1470 function hasUnicodeWord(string) {
1471 return reHasUnicodeWord.test(string);
1472 }
1473
1474 /**
1475 * Converts `iterator` to an array.
1476 *
1477 * @private
1478 * @param {Object} iterator The iterator to convert.
1479 * @returns {Array} Returns the converted array.
1480 */
1481 function iteratorToArray(iterator) {
1482 var data,
1483 result = [];
1484
1485 while (!(data = iterator.next()).done) {
1486 result.push(data.value);
1487 }
1488 return result;
1489 }
1490
1491 /**
1492 * Converts `map` to its key-value pairs.
1493 *
1494 * @private
1495 * @param {Object} map The map to convert.
1496 * @returns {Array} Returns the key-value pairs.
1497 */
1498 function mapToArray(map) {
1499 var index = -1,
1500 result = Array(map.size);
1501
1502 map.forEach(function(value, key) {
1503 result[++index] = [key, value];
1504 });
1505 return result;
1506 }
1507
1508 /**
1509 * Creates a unary function that invokes `func` with its argument transformed.
1510 *
1511 * @private
1512 * @param {Function} func The function to wrap.
1513 * @param {Function} transform The argument transform.
1514 * @returns {Function} Returns the new function.
1515 */
1516 function overArg(func, transform) {
1517 return function(arg) {
1518 return func(transform(arg));
1519 };
1520 }
1521
1522 /**
1523 * Replaces all `placeholder` elements in `array` with an internal placeholder
1524 * and returns an array of their indexes.
1525 *
1526 * @private
1527 * @param {Array} array The array to modify.
1528 * @param {*} placeholder The placeholder to replace.
1529 * @returns {Array} Returns the new array of placeholder indexes.
1530 */
1531 function replaceHolders(array, placeholder) {
1532 var index = -1,
1533 length = array.length,
1534 resIndex = 0,
1535 result = [];
1536
1537 while (++index < length) {
1538 var value = array[index];
1539 if (value === placeholder || value === PLACEHOLDER) {
1540 array[index] = PLACEHOLDER;
1541 result[resIndex++] = index;
1542 }
1543 }
1544 return result;
1545 }
1546
1547 /**
1548 * Converts `set` to an array of its values.
1549 *
1550 * @private
1551 * @param {Object} set The set to convert.
1552 * @returns {Array} Returns the values.
1553 */
1554 function setToArray(set) {
1555 var index = -1,
1556 result = Array(set.size);
1557
1558 set.forEach(function(value) {
1559 result[++index] = value;
1560 });
1561 return result;
1562 }
1563
1564 /**
1565 * Converts `set` to its value-value pairs.
1566 *
1567 * @private
1568 * @param {Object} set The set to convert.
1569 * @returns {Array} Returns the value-value pairs.
1570 */
1571 function setToPairs(set) {
1572 var index = -1,
1573 result = Array(set.size);
1574
1575 set.forEach(function(value) {
1576 result[++index] = [value, value];
1577 });
1578 return result;
1579 }
1580
1581 /**
1582 * A specialized version of `_.indexOf` which performs strict equality
1583 * comparisons of values, i.e. `===`.
1584 *
1585 * @private
1586 * @param {Array} array The array to inspect.
1587 * @param {*} value The value to search for.
1588 * @param {number} fromIndex The index to search from.
1589 * @returns {number} Returns the index of the matched value, else `-1`.
1590 */
1591 function strictIndexOf(array, value, fromIndex) {
1592 var index = fromIndex - 1,
1593 length = array.length;
1594
1595 while (++index < length) {
1596 if (array[index] === value) {
1597 return index;
1598 }
1599 }
1600 return -1;
1601 }
1602
1603 /**
1604 * A specialized version of `_.lastIndexOf` which performs strict equality
1605 * comparisons of values, i.e. `===`.
1606 *
1607 * @private
1608 * @param {Array} array The array to inspect.
1609 * @param {*} value The value to search for.
1610 * @param {number} fromIndex The index to search from.
1611 * @returns {number} Returns the index of the matched value, else `-1`.
1612 */
1613 function strictLastIndexOf(array, value, fromIndex) {
1614 var index = fromIndex + 1;
1615 while (index--) {
1616 if (array[index] === value) {
1617 return index;
1618 }
1619 }
1620 return index;
1621 }
1622
1623 /**
1624 * Gets the number of symbols in `string`.
1625 *
1626 * @private
1627 * @param {string} string The string to inspect.
1628 * @returns {number} Returns the string size.
1629 */
1630 function stringSize(string) {
1631 return hasUnicode(string)
1632 ? unicodeSize(string)
1633 : asciiSize(string);
1634 }
1635
1636 /**
1637 * Converts `string` to an array.
1638 *
1639 * @private
1640 * @param {string} string The string to convert.
1641 * @returns {Array} Returns the converted array.
1642 */
1643 function stringToArray(string) {
1644 return hasUnicode(string)
1645 ? unicodeToArray(string)
1646 : asciiToArray(string);
1647 }
1648
1649 /**
1650 * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
1651 * character of `string`.
1652 *
1653 * @private
1654 * @param {string} string The string to inspect.
1655 * @returns {number} Returns the index of the last non-whitespace character.
1656 */
1657 function trimmedEndIndex(string) {
1658 var index = string.length;
1659
1660 while (index-- && reWhitespace.test(string.charAt(index))) {}
1661 return index;
1662 }
1663
1664 /**
1665 * Used by `_.unescape` to convert HTML entities to characters.
1666 *
1667 * @private
1668 * @param {string} chr The matched character to unescape.
1669 * @returns {string} Returns the unescaped character.
1670 */
1671 var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
1672
1673 /**
1674 * Gets the size of a Unicode `string`.
1675 *
1676 * @private
1677 * @param {string} string The string inspect.
1678 * @returns {number} Returns the string size.
1679 */
1680 function unicodeSize(string) {
1681 var result = reUnicode.lastIndex = 0;
1682 while (reUnicode.test(string)) {
1683 ++result;
1684 }
1685 return result;
1686 }
1687
1688 /**
1689 * Converts a Unicode `string` to an array.
1690 *
1691 * @private
1692 * @param {string} string The string to convert.
1693 * @returns {Array} Returns the converted array.
1694 */
1695 function unicodeToArray(string) {
1696 return string.match(reUnicode) || [];
1697 }
1698
1699 /**
1700 * Splits a Unicode `string` into an array of its words.
1701 *
1702 * @private
1703 * @param {string} The string to inspect.
1704 * @returns {Array} Returns the words of `string`.
1705 */
1706 function unicodeWords(string) {
1707 return string.match(reUnicodeWord) || [];
1708 }
1709
1710 /*--------------------------------------------------------------------------*/
1711
1712 /**
1713 * Create a new pristine `lodash` function using the `context` object.
1714 *
1715 * @static
1716 * @memberOf _
1717 * @since 1.1.0
1718 * @category Util
1719 * @param {Object} [context=root] The context object.
1720 * @returns {Function} Returns a new `lodash` function.
1721 * @example
1722 *
1723 * _.mixin({ 'foo': _.constant('foo') });
1724 *
1725 * var lodash = _.runInContext();
1726 * lodash.mixin({ 'bar': lodash.constant('bar') });
1727 *
1728 * _.isFunction(_.foo);
1729 * // => true
1730 * _.isFunction(_.bar);
1731 * // => false
1732 *
1733 * lodash.isFunction(lodash.foo);
1734 * // => false
1735 * lodash.isFunction(lodash.bar);
1736 * // => true
1737 *
1738 * // Create a suped-up `defer` in Node.js.
1739 * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
1740 */
1741 var runInContext = (function runInContext(context) {
1742 context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
1743
1744 /** Built-in constructor references. */
1745 var Array = context.Array,
1746 Date = context.Date,
1747 Error = context.Error,
1748 Function = context.Function,
1749 Math = context.Math,
1750 Object = context.Object,
1751 RegExp = context.RegExp,
1752 String = context.String,
1753 TypeError = context.TypeError;
1754
1755 /** Used for built-in method references. */
1756 var arrayProto = Array.prototype,
1757 funcProto = Function.prototype,
1758 objectProto = Object.prototype;
1759
1760 /** Used to detect overreaching core-js shims. */
1761 var coreJsData = context['__core-js_shared__'];
1762
1763 /** Used to resolve the decompiled source of functions. */
1764 var funcToString = funcProto.toString;
1765
1766 /** Used to check objects for own properties. */
1767 var hasOwnProperty = objectProto.hasOwnProperty;
1768
1769 /** Used to generate unique IDs. */
1770 var idCounter = 0;
1771
1772 /** Used to detect methods masquerading as native. */
1773 var maskSrcKey = (function() {
1774 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
1775 return uid ? ('Symbol(src)_1.' + uid) : '';
1776 }());
1777
1778 /**
1779 * Used to resolve the
1780 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1781 * of values.
1782 */
1783 var nativeObjectToString = objectProto.toString;
1784
1785 /** Used to infer the `Object` constructor. */
1786 var objectCtorString = funcToString.call(Object);
1787
1788 /** Used to restore the original `_` reference in `_.noConflict`. */
1789 var oldDash = root._;
1790
1791 /** Used to detect if a method is native. */
1792 var reIsNative = RegExp('^' +
1793 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
1794 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
1795 );
1796
1797 /** Built-in value references. */
1798 var Buffer = moduleExports ? context.Buffer : undefined$1,
1799 Symbol = context.Symbol,
1800 Uint8Array = context.Uint8Array,
1801 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined$1,
1802 getPrototype = overArg(Object.getPrototypeOf, Object),
1803 objectCreate = Object.create,
1804 propertyIsEnumerable = objectProto.propertyIsEnumerable,
1805 splice = arrayProto.splice,
1806 spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined$1,
1807 symIterator = Symbol ? Symbol.iterator : undefined$1,
1808 symToStringTag = Symbol ? Symbol.toStringTag : undefined$1;
1809
1810 var defineProperty = (function() {
1811 try {
1812 var func = getNative(Object, 'defineProperty');
1813 func({}, '', {});
1814 return func;
1815 } catch (e) {}
1816 }());
1817
1818 /** Mocked built-ins. */
1819 var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
1820 ctxNow = Date && Date.now !== root.Date.now && Date.now,
1821 ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
1822
1823 /* Built-in method references for those with the same name as other `lodash` methods. */
1824 var nativeCeil = Math.ceil,
1825 nativeFloor = Math.floor,
1826 nativeGetSymbols = Object.getOwnPropertySymbols,
1827 nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined$1,
1828 nativeIsFinite = context.isFinite,
1829 nativeJoin = arrayProto.join,
1830 nativeKeys = overArg(Object.keys, Object),
1831 nativeMax = Math.max,
1832 nativeMin = Math.min,
1833 nativeNow = Date.now,
1834 nativeParseInt = context.parseInt,
1835 nativeRandom = Math.random,
1836 nativeReverse = arrayProto.reverse;
1837
1838 /* Built-in method references that are verified to be native. */
1839 var DataView = getNative(context, 'DataView'),
1840 Map = getNative(context, 'Map'),
1841 Promise = getNative(context, 'Promise'),
1842 Set = getNative(context, 'Set'),
1843 WeakMap = getNative(context, 'WeakMap'),
1844 nativeCreate = getNative(Object, 'create');
1845
1846 /** Used to store function metadata. */
1847 var metaMap = WeakMap && new WeakMap;
1848
1849 /** Used to lookup unminified function names. */
1850 var realNames = {};
1851
1852 /** Used to detect maps, sets, and weakmaps. */
1853 var dataViewCtorString = toSource(DataView),
1854 mapCtorString = toSource(Map),
1855 promiseCtorString = toSource(Promise),
1856 setCtorString = toSource(Set),
1857 weakMapCtorString = toSource(WeakMap);
1858
1859 /** Used to convert symbols to primitives and strings. */
1860 var symbolProto = Symbol ? Symbol.prototype : undefined$1,
1861 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined$1,
1862 symbolToString = symbolProto ? symbolProto.toString : undefined$1;
1863
1864 /*------------------------------------------------------------------------*/
1865
1866 /**
1867 * Creates a `lodash` object which wraps `value` to enable implicit method
1868 * chain sequences. Methods that operate on and return arrays, collections,
1869 * and functions can be chained together. Methods that retrieve a single value
1870 * or may return a primitive value will automatically end the chain sequence
1871 * and return the unwrapped value. Otherwise, the value must be unwrapped
1872 * with `_#value`.
1873 *
1874 * Explicit chain sequences, which must be unwrapped with `_#value`, may be
1875 * enabled using `_.chain`.
1876 *
1877 * The execution of chained methods is lazy, that is, it's deferred until
1878 * `_#value` is implicitly or explicitly called.
1879 *
1880 * Lazy evaluation allows several methods to support shortcut fusion.
1881 * Shortcut fusion is an optimization to merge iteratee calls; this avoids
1882 * the creation of intermediate arrays and can greatly reduce the number of
1883 * iteratee executions. Sections of a chain sequence qualify for shortcut
1884 * fusion if the section is applied to an array and iteratees accept only
1885 * one argument. The heuristic for whether a section qualifies for shortcut
1886 * fusion is subject to change.
1887 *
1888 * Chaining is supported in custom builds as long as the `_#value` method is
1889 * directly or indirectly included in the build.
1890 *
1891 * In addition to lodash methods, wrappers have `Array` and `String` methods.
1892 *
1893 * The wrapper `Array` methods are:
1894 * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
1895 *
1896 * The wrapper `String` methods are:
1897 * `replace` and `split`
1898 *
1899 * The wrapper methods that support shortcut fusion are:
1900 * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
1901 * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
1902 * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
1903 *
1904 * The chainable wrapper methods are:
1905 * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
1906 * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
1907 * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
1908 * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
1909 * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
1910 * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
1911 * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
1912 * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
1913 * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
1914 * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
1915 * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
1916 * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
1917 * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
1918 * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
1919 * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
1920 * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
1921 * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
1922 * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
1923 * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
1924 * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
1925 * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
1926 * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
1927 * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
1928 * `zipObject`, `zipObjectDeep`, and `zipWith`
1929 *
1930 * The wrapper methods that are **not** chainable by default are:
1931 * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
1932 * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
1933 * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
1934 * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
1935 * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
1936 * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
1937 * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
1938 * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
1939 * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
1940 * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
1941 * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
1942 * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
1943 * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
1944 * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
1945 * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
1946 * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
1947 * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
1948 * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
1949 * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
1950 * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
1951 * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
1952 * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
1953 * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
1954 * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
1955 * `upperFirst`, `value`, and `words`
1956 *
1957 * @name _
1958 * @constructor
1959 * @category Seq
1960 * @param {*} value The value to wrap in a `lodash` instance.
1961 * @returns {Object} Returns the new `lodash` wrapper instance.
1962 * @example
1963 *
1964 * function square(n) {
1965 * return n * n;
1966 * }
1967 *
1968 * var wrapped = _([1, 2, 3]);
1969 *
1970 * // Returns an unwrapped value.
1971 * wrapped.reduce(_.add);
1972 * // => 6
1973 *
1974 * // Returns a wrapped value.
1975 * var squares = wrapped.map(square);
1976 *
1977 * _.isArray(squares);
1978 * // => false
1979 *
1980 * _.isArray(squares.value());
1981 * // => true
1982 */
1983 function lodash(value) {
1984 if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
1985 if (value instanceof LodashWrapper) {
1986 return value;
1987 }
1988 if (hasOwnProperty.call(value, '__wrapped__')) {
1989 return wrapperClone(value);
1990 }
1991 }
1992 return new LodashWrapper(value);
1993 }
1994
1995 /**
1996 * The base implementation of `_.create` without support for assigning
1997 * properties to the created object.
1998 *
1999 * @private
2000 * @param {Object} proto The object to inherit from.
2001 * @returns {Object} Returns the new object.
2002 */
2003 var baseCreate = (function() {
2004 function object() {}
2005 return function(proto) {
2006 if (!isObject(proto)) {
2007 return {};
2008 }
2009 if (objectCreate) {
2010 return objectCreate(proto);
2011 }
2012 object.prototype = proto;
2013 var result = new object;
2014 object.prototype = undefined$1;
2015 return result;
2016 };
2017 }());
2018
2019 /**
2020 * The function whose prototype chain sequence wrappers inherit from.
2021 *
2022 * @private
2023 */
2024 function baseLodash() {
2025 // No operation performed.
2026 }
2027
2028 /**
2029 * The base constructor for creating `lodash` wrapper objects.
2030 *
2031 * @private
2032 * @param {*} value The value to wrap.
2033 * @param {boolean} [chainAll] Enable explicit method chain sequences.
2034 */
2035 function LodashWrapper(value, chainAll) {
2036 this.__wrapped__ = value;
2037 this.__actions__ = [];
2038 this.__chain__ = !!chainAll;
2039 this.__index__ = 0;
2040 this.__values__ = undefined$1;
2041 }
2042
2043 /**
2044 * By default, the template delimiters used by lodash are like those in
2045 * embedded Ruby (ERB) as well as ES2015 template strings. Change the
2046 * following template settings to use alternative delimiters.
2047 *
2048 * @static
2049 * @memberOf _
2050 * @type {Object}
2051 */
2052 lodash.templateSettings = {
2053
2054 /**
2055 * Used to detect `data` property values to be HTML-escaped.
2056 *
2057 * @memberOf _.templateSettings
2058 * @type {RegExp}
2059 */
2060 'escape': reEscape,
2061
2062 /**
2063 * Used to detect code to be evaluated.
2064 *
2065 * @memberOf _.templateSettings
2066 * @type {RegExp}
2067 */
2068 'evaluate': reEvaluate,
2069
2070 /**
2071 * Used to detect `data` property values to inject.
2072 *
2073 * @memberOf _.templateSettings
2074 * @type {RegExp}
2075 */
2076 'interpolate': reInterpolate,
2077
2078 /**
2079 * Used to reference the data object in the template text.
2080 *
2081 * @memberOf _.templateSettings
2082 * @type {string}
2083 */
2084 'variable': '',
2085
2086 /**
2087 * Used to import variables into the compiled template.
2088 *
2089 * @memberOf _.templateSettings
2090 * @type {Object}
2091 */
2092 'imports': {
2093
2094 /**
2095 * A reference to the `lodash` function.
2096 *
2097 * @memberOf _.templateSettings.imports
2098 * @type {Function}
2099 */
2100 '_': lodash
2101 }
2102 };
2103
2104 // Ensure wrappers are instances of `baseLodash`.
2105 lodash.prototype = baseLodash.prototype;
2106 lodash.prototype.constructor = lodash;
2107
2108 LodashWrapper.prototype = baseCreate(baseLodash.prototype);
2109 LodashWrapper.prototype.constructor = LodashWrapper;
2110
2111 /*------------------------------------------------------------------------*/
2112
2113 /**
2114 * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
2115 *
2116 * @private
2117 * @constructor
2118 * @param {*} value The value to wrap.
2119 */
2120 function LazyWrapper(value) {
2121 this.__wrapped__ = value;
2122 this.__actions__ = [];
2123 this.__dir__ = 1;
2124 this.__filtered__ = false;
2125 this.__iteratees__ = [];
2126 this.__takeCount__ = MAX_ARRAY_LENGTH;
2127 this.__views__ = [];
2128 }
2129
2130 /**
2131 * Creates a clone of the lazy wrapper object.
2132 *
2133 * @private
2134 * @name clone
2135 * @memberOf LazyWrapper
2136 * @returns {Object} Returns the cloned `LazyWrapper` object.
2137 */
2138 function lazyClone() {
2139 var result = new LazyWrapper(this.__wrapped__);
2140 result.__actions__ = copyArray(this.__actions__);
2141 result.__dir__ = this.__dir__;
2142 result.__filtered__ = this.__filtered__;
2143 result.__iteratees__ = copyArray(this.__iteratees__);
2144 result.__takeCount__ = this.__takeCount__;
2145 result.__views__ = copyArray(this.__views__);
2146 return result;
2147 }
2148
2149 /**
2150 * Reverses the direction of lazy iteration.
2151 *
2152 * @private
2153 * @name reverse
2154 * @memberOf LazyWrapper
2155 * @returns {Object} Returns the new reversed `LazyWrapper` object.
2156 */
2157 function lazyReverse() {
2158 if (this.__filtered__) {
2159 var result = new LazyWrapper(this);
2160 result.__dir__ = -1;
2161 result.__filtered__ = true;
2162 } else {
2163 result = this.clone();
2164 result.__dir__ *= -1;
2165 }
2166 return result;
2167 }
2168
2169 /**
2170 * Extracts the unwrapped value from its lazy wrapper.
2171 *
2172 * @private
2173 * @name value
2174 * @memberOf LazyWrapper
2175 * @returns {*} Returns the unwrapped value.
2176 */
2177 function lazyValue() {
2178 var array = this.__wrapped__.value(),
2179 dir = this.__dir__,
2180 isArr = isArray(array),
2181 isRight = dir < 0,
2182 arrLength = isArr ? array.length : 0,
2183 view = getView(0, arrLength, this.__views__),
2184 start = view.start,
2185 end = view.end,
2186 length = end - start,
2187 index = isRight ? end : (start - 1),
2188 iteratees = this.__iteratees__,
2189 iterLength = iteratees.length,
2190 resIndex = 0,
2191 takeCount = nativeMin(length, this.__takeCount__);
2192
2193 if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
2194 return baseWrapperValue(array, this.__actions__);
2195 }
2196 var result = [];
2197
2198 outer:
2199 while (length-- && resIndex < takeCount) {
2200 index += dir;
2201
2202 var iterIndex = -1,
2203 value = array[index];
2204
2205 while (++iterIndex < iterLength) {
2206 var data = iteratees[iterIndex],
2207 iteratee = data.iteratee,
2208 type = data.type,
2209 computed = iteratee(value);
2210
2211 if (type == LAZY_MAP_FLAG) {
2212 value = computed;
2213 } else if (!computed) {
2214 if (type == LAZY_FILTER_FLAG) {
2215 continue outer;
2216 } else {
2217 break outer;
2218 }
2219 }
2220 }
2221 result[resIndex++] = value;
2222 }
2223 return result;
2224 }
2225
2226 // Ensure `LazyWrapper` is an instance of `baseLodash`.
2227 LazyWrapper.prototype = baseCreate(baseLodash.prototype);
2228 LazyWrapper.prototype.constructor = LazyWrapper;
2229
2230 /*------------------------------------------------------------------------*/
2231
2232 /**
2233 * Creates a hash object.
2234 *
2235 * @private
2236 * @constructor
2237 * @param {Array} [entries] The key-value pairs to cache.
2238 */
2239 function Hash(entries) {
2240 var index = -1,
2241 length = entries == null ? 0 : entries.length;
2242
2243 this.clear();
2244 while (++index < length) {
2245 var entry = entries[index];
2246 this.set(entry[0], entry[1]);
2247 }
2248 }
2249
2250 /**
2251 * Removes all key-value entries from the hash.
2252 *
2253 * @private
2254 * @name clear
2255 * @memberOf Hash
2256 */
2257 function hashClear() {
2258 this.__data__ = nativeCreate ? nativeCreate(null) : {};
2259 this.size = 0;
2260 }
2261
2262 /**
2263 * Removes `key` and its value from the hash.
2264 *
2265 * @private
2266 * @name delete
2267 * @memberOf Hash
2268 * @param {Object} hash The hash to modify.
2269 * @param {string} key The key of the value to remove.
2270 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2271 */
2272 function hashDelete(key) {
2273 var result = this.has(key) && delete this.__data__[key];
2274 this.size -= result ? 1 : 0;
2275 return result;
2276 }
2277
2278 /**
2279 * Gets the hash value for `key`.
2280 *
2281 * @private
2282 * @name get
2283 * @memberOf Hash
2284 * @param {string} key The key of the value to get.
2285 * @returns {*} Returns the entry value.
2286 */
2287 function hashGet(key) {
2288 var data = this.__data__;
2289 if (nativeCreate) {
2290 var result = data[key];
2291 return result === HASH_UNDEFINED ? undefined$1 : result;
2292 }
2293 return hasOwnProperty.call(data, key) ? data[key] : undefined$1;
2294 }
2295
2296 /**
2297 * Checks if a hash value for `key` exists.
2298 *
2299 * @private
2300 * @name has
2301 * @memberOf Hash
2302 * @param {string} key The key of the entry to check.
2303 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2304 */
2305 function hashHas(key) {
2306 var data = this.__data__;
2307 return nativeCreate ? (data[key] !== undefined$1) : hasOwnProperty.call(data, key);
2308 }
2309
2310 /**
2311 * Sets the hash `key` to `value`.
2312 *
2313 * @private
2314 * @name set
2315 * @memberOf Hash
2316 * @param {string} key The key of the value to set.
2317 * @param {*} value The value to set.
2318 * @returns {Object} Returns the hash instance.
2319 */
2320 function hashSet(key, value) {
2321 var data = this.__data__;
2322 this.size += this.has(key) ? 0 : 1;
2323 data[key] = (nativeCreate && value === undefined$1) ? HASH_UNDEFINED : value;
2324 return this;
2325 }
2326
2327 // Add methods to `Hash`.
2328 Hash.prototype.clear = hashClear;
2329 Hash.prototype['delete'] = hashDelete;
2330 Hash.prototype.get = hashGet;
2331 Hash.prototype.has = hashHas;
2332 Hash.prototype.set = hashSet;
2333
2334 /*------------------------------------------------------------------------*/
2335
2336 /**
2337 * Creates an list cache object.
2338 *
2339 * @private
2340 * @constructor
2341 * @param {Array} [entries] The key-value pairs to cache.
2342 */
2343 function ListCache(entries) {
2344 var index = -1,
2345 length = entries == null ? 0 : entries.length;
2346
2347 this.clear();
2348 while (++index < length) {
2349 var entry = entries[index];
2350 this.set(entry[0], entry[1]);
2351 }
2352 }
2353
2354 /**
2355 * Removes all key-value entries from the list cache.
2356 *
2357 * @private
2358 * @name clear
2359 * @memberOf ListCache
2360 */
2361 function listCacheClear() {
2362 this.__data__ = [];
2363 this.size = 0;
2364 }
2365
2366 /**
2367 * Removes `key` and its value from the list cache.
2368 *
2369 * @private
2370 * @name delete
2371 * @memberOf ListCache
2372 * @param {string} key The key of the value to remove.
2373 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2374 */
2375 function listCacheDelete(key) {
2376 var data = this.__data__,
2377 index = assocIndexOf(data, key);
2378
2379 if (index < 0) {
2380 return false;
2381 }
2382 var lastIndex = data.length - 1;
2383 if (index == lastIndex) {
2384 data.pop();
2385 } else {
2386 splice.call(data, index, 1);
2387 }
2388 --this.size;
2389 return true;
2390 }
2391
2392 /**
2393 * Gets the list cache value for `key`.
2394 *
2395 * @private
2396 * @name get
2397 * @memberOf ListCache
2398 * @param {string} key The key of the value to get.
2399 * @returns {*} Returns the entry value.
2400 */
2401 function listCacheGet(key) {
2402 var data = this.__data__,
2403 index = assocIndexOf(data, key);
2404
2405 return index < 0 ? undefined$1 : data[index][1];
2406 }
2407
2408 /**
2409 * Checks if a list cache value for `key` exists.
2410 *
2411 * @private
2412 * @name has
2413 * @memberOf ListCache
2414 * @param {string} key The key of the entry to check.
2415 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2416 */
2417 function listCacheHas(key) {
2418 return assocIndexOf(this.__data__, key) > -1;
2419 }
2420
2421 /**
2422 * Sets the list cache `key` to `value`.
2423 *
2424 * @private
2425 * @name set
2426 * @memberOf ListCache
2427 * @param {string} key The key of the value to set.
2428 * @param {*} value The value to set.
2429 * @returns {Object} Returns the list cache instance.
2430 */
2431 function listCacheSet(key, value) {
2432 var data = this.__data__,
2433 index = assocIndexOf(data, key);
2434
2435 if (index < 0) {
2436 ++this.size;
2437 data.push([key, value]);
2438 } else {
2439 data[index][1] = value;
2440 }
2441 return this;
2442 }
2443
2444 // Add methods to `ListCache`.
2445 ListCache.prototype.clear = listCacheClear;
2446 ListCache.prototype['delete'] = listCacheDelete;
2447 ListCache.prototype.get = listCacheGet;
2448 ListCache.prototype.has = listCacheHas;
2449 ListCache.prototype.set = listCacheSet;
2450
2451 /*------------------------------------------------------------------------*/
2452
2453 /**
2454 * Creates a map cache object to store key-value pairs.
2455 *
2456 * @private
2457 * @constructor
2458 * @param {Array} [entries] The key-value pairs to cache.
2459 */
2460 function MapCache(entries) {
2461 var index = -1,
2462 length = entries == null ? 0 : entries.length;
2463
2464 this.clear();
2465 while (++index < length) {
2466 var entry = entries[index];
2467 this.set(entry[0], entry[1]);
2468 }
2469 }
2470
2471 /**
2472 * Removes all key-value entries from the map.
2473 *
2474 * @private
2475 * @name clear
2476 * @memberOf MapCache
2477 */
2478 function mapCacheClear() {
2479 this.size = 0;
2480 this.__data__ = {
2481 'hash': new Hash,
2482 'map': new (Map || ListCache),
2483 'string': new Hash
2484 };
2485 }
2486
2487 /**
2488 * Removes `key` and its value from the map.
2489 *
2490 * @private
2491 * @name delete
2492 * @memberOf MapCache
2493 * @param {string} key The key of the value to remove.
2494 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2495 */
2496 function mapCacheDelete(key) {
2497 var result = getMapData(this, key)['delete'](key);
2498 this.size -= result ? 1 : 0;
2499 return result;
2500 }
2501
2502 /**
2503 * Gets the map value for `key`.
2504 *
2505 * @private
2506 * @name get
2507 * @memberOf MapCache
2508 * @param {string} key The key of the value to get.
2509 * @returns {*} Returns the entry value.
2510 */
2511 function mapCacheGet(key) {
2512 return getMapData(this, key).get(key);
2513 }
2514
2515 /**
2516 * Checks if a map value for `key` exists.
2517 *
2518 * @private
2519 * @name has
2520 * @memberOf MapCache
2521 * @param {string} key The key of the entry to check.
2522 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2523 */
2524 function mapCacheHas(key) {
2525 return getMapData(this, key).has(key);
2526 }
2527
2528 /**
2529 * Sets the map `key` to `value`.
2530 *
2531 * @private
2532 * @name set
2533 * @memberOf MapCache
2534 * @param {string} key The key of the value to set.
2535 * @param {*} value The value to set.
2536 * @returns {Object} Returns the map cache instance.
2537 */
2538 function mapCacheSet(key, value) {
2539 var data = getMapData(this, key),
2540 size = data.size;
2541
2542 data.set(key, value);
2543 this.size += data.size == size ? 0 : 1;
2544 return this;
2545 }
2546
2547 // Add methods to `MapCache`.
2548 MapCache.prototype.clear = mapCacheClear;
2549 MapCache.prototype['delete'] = mapCacheDelete;
2550 MapCache.prototype.get = mapCacheGet;
2551 MapCache.prototype.has = mapCacheHas;
2552 MapCache.prototype.set = mapCacheSet;
2553
2554 /*------------------------------------------------------------------------*/
2555
2556 /**
2557 *
2558 * Creates an array cache object to store unique values.
2559 *
2560 * @private
2561 * @constructor
2562 * @param {Array} [values] The values to cache.
2563 */
2564 function SetCache(values) {
2565 var index = -1,
2566 length = values == null ? 0 : values.length;
2567
2568 this.__data__ = new MapCache;
2569 while (++index < length) {
2570 this.add(values[index]);
2571 }
2572 }
2573
2574 /**
2575 * Adds `value` to the array cache.
2576 *
2577 * @private
2578 * @name add
2579 * @memberOf SetCache
2580 * @alias push
2581 * @param {*} value The value to cache.
2582 * @returns {Object} Returns the cache instance.
2583 */
2584 function setCacheAdd(value) {
2585 this.__data__.set(value, HASH_UNDEFINED);
2586 return this;
2587 }
2588
2589 /**
2590 * Checks if `value` is in the array cache.
2591 *
2592 * @private
2593 * @name has
2594 * @memberOf SetCache
2595 * @param {*} value The value to search for.
2596 * @returns {number} Returns `true` if `value` is found, else `false`.
2597 */
2598 function setCacheHas(value) {
2599 return this.__data__.has(value);
2600 }
2601
2602 // Add methods to `SetCache`.
2603 SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
2604 SetCache.prototype.has = setCacheHas;
2605
2606 /*------------------------------------------------------------------------*/
2607
2608 /**
2609 * Creates a stack cache object to store key-value pairs.
2610 *
2611 * @private
2612 * @constructor
2613 * @param {Array} [entries] The key-value pairs to cache.
2614 */
2615 function Stack(entries) {
2616 var data = this.__data__ = new ListCache(entries);
2617 this.size = data.size;
2618 }
2619
2620 /**
2621 * Removes all key-value entries from the stack.
2622 *
2623 * @private
2624 * @name clear
2625 * @memberOf Stack
2626 */
2627 function stackClear() {
2628 this.__data__ = new ListCache;
2629 this.size = 0;
2630 }
2631
2632 /**
2633 * Removes `key` and its value from the stack.
2634 *
2635 * @private
2636 * @name delete
2637 * @memberOf Stack
2638 * @param {string} key The key of the value to remove.
2639 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2640 */
2641 function stackDelete(key) {
2642 var data = this.__data__,
2643 result = data['delete'](key);
2644
2645 this.size = data.size;
2646 return result;
2647 }
2648
2649 /**
2650 * Gets the stack value for `key`.
2651 *
2652 * @private
2653 * @name get
2654 * @memberOf Stack
2655 * @param {string} key The key of the value to get.
2656 * @returns {*} Returns the entry value.
2657 */
2658 function stackGet(key) {
2659 return this.__data__.get(key);
2660 }
2661
2662 /**
2663 * Checks if a stack value for `key` exists.
2664 *
2665 * @private
2666 * @name has
2667 * @memberOf Stack
2668 * @param {string} key The key of the entry to check.
2669 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2670 */
2671 function stackHas(key) {
2672 return this.__data__.has(key);
2673 }
2674
2675 /**
2676 * Sets the stack `key` to `value`.
2677 *
2678 * @private
2679 * @name set
2680 * @memberOf Stack
2681 * @param {string} key The key of the value to set.
2682 * @param {*} value The value to set.
2683 * @returns {Object} Returns the stack cache instance.
2684 */
2685 function stackSet(key, value) {
2686 var data = this.__data__;
2687 if (data instanceof ListCache) {
2688 var pairs = data.__data__;
2689 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
2690 pairs.push([key, value]);
2691 this.size = ++data.size;
2692 return this;
2693 }
2694 data = this.__data__ = new MapCache(pairs);
2695 }
2696 data.set(key, value);
2697 this.size = data.size;
2698 return this;
2699 }
2700
2701 // Add methods to `Stack`.
2702 Stack.prototype.clear = stackClear;
2703 Stack.prototype['delete'] = stackDelete;
2704 Stack.prototype.get = stackGet;
2705 Stack.prototype.has = stackHas;
2706 Stack.prototype.set = stackSet;
2707
2708 /*------------------------------------------------------------------------*/
2709
2710 /**
2711 * Creates an array of the enumerable property names of the array-like `value`.
2712 *
2713 * @private
2714 * @param {*} value The value to query.
2715 * @param {boolean} inherited Specify returning inherited property names.
2716 * @returns {Array} Returns the array of property names.
2717 */
2718 function arrayLikeKeys(value, inherited) {
2719 var isArr = isArray(value),
2720 isArg = !isArr && isArguments(value),
2721 isBuff = !isArr && !isArg && isBuffer(value),
2722 isType = !isArr && !isArg && !isBuff && isTypedArray(value),
2723 skipIndexes = isArr || isArg || isBuff || isType,
2724 result = skipIndexes ? baseTimes(value.length, String) : [],
2725 length = result.length;
2726
2727 for (var key in value) {
2728 if ((inherited || hasOwnProperty.call(value, key)) &&
2729 !(skipIndexes && (
2730 // Safari 9 has enumerable `arguments.length` in strict mode.
2731 key == 'length' ||
2732 // Node.js 0.10 has enumerable non-index properties on buffers.
2733 (isBuff && (key == 'offset' || key == 'parent')) ||
2734 // PhantomJS 2 has enumerable non-index properties on typed arrays.
2735 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
2736 // Skip index properties.
2737 isIndex(key, length)
2738 ))) {
2739 result.push(key);
2740 }
2741 }
2742 return result;
2743 }
2744
2745 /**
2746 * A specialized version of `_.sample` for arrays.
2747 *
2748 * @private
2749 * @param {Array} array The array to sample.
2750 * @returns {*} Returns the random element.
2751 */
2752 function arraySample(array) {
2753 var length = array.length;
2754 return length ? array[baseRandom(0, length - 1)] : undefined$1;
2755 }
2756
2757 /**
2758 * A specialized version of `_.sampleSize` for arrays.
2759 *
2760 * @private
2761 * @param {Array} array The array to sample.
2762 * @param {number} n The number of elements to sample.
2763 * @returns {Array} Returns the random elements.
2764 */
2765 function arraySampleSize(array, n) {
2766 return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
2767 }
2768
2769 /**
2770 * A specialized version of `_.shuffle` for arrays.
2771 *
2772 * @private
2773 * @param {Array} array The array to shuffle.
2774 * @returns {Array} Returns the new shuffled array.
2775 */
2776 function arrayShuffle(array) {
2777 return shuffleSelf(copyArray(array));
2778 }
2779
2780 /**
2781 * This function is like `assignValue` except that it doesn't assign
2782 * `undefined` values.
2783 *
2784 * @private
2785 * @param {Object} object The object to modify.
2786 * @param {string} key The key of the property to assign.
2787 * @param {*} value The value to assign.
2788 */
2789 function assignMergeValue(object, key, value) {
2790 if ((value !== undefined$1 && !eq(object[key], value)) ||
2791 (value === undefined$1 && !(key in object))) {
2792 baseAssignValue(object, key, value);
2793 }
2794 }
2795
2796 /**
2797 * Assigns `value` to `key` of `object` if the existing value is not equivalent
2798 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2799 * for equality comparisons.
2800 *
2801 * @private
2802 * @param {Object} object The object to modify.
2803 * @param {string} key The key of the property to assign.
2804 * @param {*} value The value to assign.
2805 */
2806 function assignValue(object, key, value) {
2807 var objValue = object[key];
2808 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
2809 (value === undefined$1 && !(key in object))) {
2810 baseAssignValue(object, key, value);
2811 }
2812 }
2813
2814 /**
2815 * Gets the index at which the `key` is found in `array` of key-value pairs.
2816 *
2817 * @private
2818 * @param {Array} array The array to inspect.
2819 * @param {*} key The key to search for.
2820 * @returns {number} Returns the index of the matched value, else `-1`.
2821 */
2822 function assocIndexOf(array, key) {
2823 var length = array.length;
2824 while (length--) {
2825 if (eq(array[length][0], key)) {
2826 return length;
2827 }
2828 }
2829 return -1;
2830 }
2831
2832 /**
2833 * Aggregates elements of `collection` on `accumulator` with keys transformed
2834 * by `iteratee` and values set by `setter`.
2835 *
2836 * @private
2837 * @param {Array|Object} collection The collection to iterate over.
2838 * @param {Function} setter The function to set `accumulator` values.
2839 * @param {Function} iteratee The iteratee to transform keys.
2840 * @param {Object} accumulator The initial aggregated object.
2841 * @returns {Function} Returns `accumulator`.
2842 */
2843 function baseAggregator(collection, setter, iteratee, accumulator) {
2844 baseEach(collection, function(value, key, collection) {
2845 setter(accumulator, value, iteratee(value), collection);
2846 });
2847 return accumulator;
2848 }
2849
2850 /**
2851 * The base implementation of `_.assign` without support for multiple sources
2852 * or `customizer` functions.
2853 *
2854 * @private
2855 * @param {Object} object The destination object.
2856 * @param {Object} source The source object.
2857 * @returns {Object} Returns `object`.
2858 */
2859 function baseAssign(object, source) {
2860 return object && copyObject(source, keys(source), object);
2861 }
2862
2863 /**
2864 * The base implementation of `_.assignIn` without support for multiple sources
2865 * or `customizer` functions.
2866 *
2867 * @private
2868 * @param {Object} object The destination object.
2869 * @param {Object} source The source object.
2870 * @returns {Object} Returns `object`.
2871 */
2872 function baseAssignIn(object, source) {
2873 return object && copyObject(source, keysIn(source), object);
2874 }
2875
2876 /**
2877 * The base implementation of `assignValue` and `assignMergeValue` without
2878 * value checks.
2879 *
2880 * @private
2881 * @param {Object} object The object to modify.
2882 * @param {string} key The key of the property to assign.
2883 * @param {*} value The value to assign.
2884 */
2885 function baseAssignValue(object, key, value) {
2886 if (key == '__proto__' && defineProperty) {
2887 defineProperty(object, key, {
2888 'configurable': true,
2889 'enumerable': true,
2890 'value': value,
2891 'writable': true
2892 });
2893 } else {
2894 object[key] = value;
2895 }
2896 }
2897
2898 /**
2899 * The base implementation of `_.at` without support for individual paths.
2900 *
2901 * @private
2902 * @param {Object} object The object to iterate over.
2903 * @param {string[]} paths The property paths to pick.
2904 * @returns {Array} Returns the picked elements.
2905 */
2906 function baseAt(object, paths) {
2907 var index = -1,
2908 length = paths.length,
2909 result = Array(length),
2910 skip = object == null;
2911
2912 while (++index < length) {
2913 result[index] = skip ? undefined$1 : get(object, paths[index]);
2914 }
2915 return result;
2916 }
2917
2918 /**
2919 * The base implementation of `_.clamp` which doesn't coerce arguments.
2920 *
2921 * @private
2922 * @param {number} number The number to clamp.
2923 * @param {number} [lower] The lower bound.
2924 * @param {number} upper The upper bound.
2925 * @returns {number} Returns the clamped number.
2926 */
2927 function baseClamp(number, lower, upper) {
2928 if (number === number) {
2929 if (upper !== undefined$1) {
2930 number = number <= upper ? number : upper;
2931 }
2932 if (lower !== undefined$1) {
2933 number = number >= lower ? number : lower;
2934 }
2935 }
2936 return number;
2937 }
2938
2939 /**
2940 * The base implementation of `_.clone` and `_.cloneDeep` which tracks
2941 * traversed objects.
2942 *
2943 * @private
2944 * @param {*} value The value to clone.
2945 * @param {boolean} bitmask The bitmask flags.
2946 * 1 - Deep clone
2947 * 2 - Flatten inherited properties
2948 * 4 - Clone symbols
2949 * @param {Function} [customizer] The function to customize cloning.
2950 * @param {string} [key] The key of `value`.
2951 * @param {Object} [object] The parent object of `value`.
2952 * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
2953 * @returns {*} Returns the cloned value.
2954 */
2955 function baseClone(value, bitmask, customizer, key, object, stack) {
2956 var result,
2957 isDeep = bitmask & CLONE_DEEP_FLAG,
2958 isFlat = bitmask & CLONE_FLAT_FLAG,
2959 isFull = bitmask & CLONE_SYMBOLS_FLAG;
2960
2961 if (customizer) {
2962 result = object ? customizer(value, key, object, stack) : customizer(value);
2963 }
2964 if (result !== undefined$1) {
2965 return result;
2966 }
2967 if (!isObject(value)) {
2968 return value;
2969 }
2970 var isArr = isArray(value);
2971 if (isArr) {
2972 result = initCloneArray(value);
2973 if (!isDeep) {
2974 return copyArray(value, result);
2975 }
2976 } else {
2977 var tag = getTag(value),
2978 isFunc = tag == funcTag || tag == genTag;
2979
2980 if (isBuffer(value)) {
2981 return cloneBuffer(value, isDeep);
2982 }
2983 if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
2984 result = (isFlat || isFunc) ? {} : initCloneObject(value);
2985 if (!isDeep) {
2986 return isFlat
2987 ? copySymbolsIn(value, baseAssignIn(result, value))
2988 : copySymbols(value, baseAssign(result, value));
2989 }
2990 } else {
2991 if (!cloneableTags[tag]) {
2992 return object ? value : {};
2993 }
2994 result = initCloneByTag(value, tag, isDeep);
2995 }
2996 }
2997 // Check for circular references and return its corresponding clone.
2998 stack || (stack = new Stack);
2999 var stacked = stack.get(value);
3000 if (stacked) {
3001 return stacked;
3002 }
3003 stack.set(value, result);
3004
3005 if (isSet(value)) {
3006 value.forEach(function(subValue) {
3007 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
3008 });
3009 } else if (isMap(value)) {
3010 value.forEach(function(subValue, key) {
3011 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
3012 });
3013 }
3014
3015 var keysFunc = isFull
3016 ? (isFlat ? getAllKeysIn : getAllKeys)
3017 : (isFlat ? keysIn : keys);
3018
3019 var props = isArr ? undefined$1 : keysFunc(value);
3020 arrayEach(props || value, function(subValue, key) {
3021 if (props) {
3022 key = subValue;
3023 subValue = value[key];
3024 }
3025 // Recursively populate clone (susceptible to call stack limits).
3026 assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
3027 });
3028 return result;
3029 }
3030
3031 /**
3032 * The base implementation of `_.conforms` which doesn't clone `source`.
3033 *
3034 * @private
3035 * @param {Object} source The object of property predicates to conform to.
3036 * @returns {Function} Returns the new spec function.
3037 */
3038 function baseConforms(source) {
3039 var props = keys(source);
3040 return function(object) {
3041 return baseConformsTo(object, source, props);
3042 };
3043 }
3044
3045 /**
3046 * The base implementation of `_.conformsTo` which accepts `props` to check.
3047 *
3048 * @private
3049 * @param {Object} object The object to inspect.
3050 * @param {Object} source The object of property predicates to conform to.
3051 * @returns {boolean} Returns `true` if `object` conforms, else `false`.
3052 */
3053 function baseConformsTo(object, source, props) {
3054 var length = props.length;
3055 if (object == null) {
3056 return !length;
3057 }
3058 object = Object(object);
3059 while (length--) {
3060 var key = props[length],
3061 predicate = source[key],
3062 value = object[key];
3063
3064 if ((value === undefined$1 && !(key in object)) || !predicate(value)) {
3065 return false;
3066 }
3067 }
3068 return true;
3069 }
3070
3071 /**
3072 * The base implementation of `_.delay` and `_.defer` which accepts `args`
3073 * to provide to `func`.
3074 *
3075 * @private
3076 * @param {Function} func The function to delay.
3077 * @param {number} wait The number of milliseconds to delay invocation.
3078 * @param {Array} args The arguments to provide to `func`.
3079 * @returns {number|Object} Returns the timer id or timeout object.
3080 */
3081 function baseDelay(func, wait, args) {
3082 if (typeof func != 'function') {
3083 throw new TypeError(FUNC_ERROR_TEXT);
3084 }
3085 return setTimeout(function() { func.apply(undefined$1, args); }, wait);
3086 }
3087
3088 /**
3089 * The base implementation of methods like `_.difference` without support
3090 * for excluding multiple arrays or iteratee shorthands.
3091 *
3092 * @private
3093 * @param {Array} array The array to inspect.
3094 * @param {Array} values The values to exclude.
3095 * @param {Function} [iteratee] The iteratee invoked per element.
3096 * @param {Function} [comparator] The comparator invoked per element.
3097 * @returns {Array} Returns the new array of filtered values.
3098 */
3099 function baseDifference(array, values, iteratee, comparator) {
3100 var index = -1,
3101 includes = arrayIncludes,
3102 isCommon = true,
3103 length = array.length,
3104 result = [],
3105 valuesLength = values.length;
3106
3107 if (!length) {
3108 return result;
3109 }
3110 if (iteratee) {
3111 values = arrayMap(values, baseUnary(iteratee));
3112 }
3113 if (comparator) {
3114 includes = arrayIncludesWith;
3115 isCommon = false;
3116 }
3117 else if (values.length >= LARGE_ARRAY_SIZE) {
3118 includes = cacheHas;
3119 isCommon = false;
3120 values = new SetCache(values);
3121 }
3122 outer:
3123 while (++index < length) {
3124 var value = array[index],
3125 computed = iteratee == null ? value : iteratee(value);
3126
3127 value = (comparator || value !== 0) ? value : 0;
3128 if (isCommon && computed === computed) {
3129 var valuesIndex = valuesLength;
3130 while (valuesIndex--) {
3131 if (values[valuesIndex] === computed) {
3132 continue outer;
3133 }
3134 }
3135 result.push(value);
3136 }
3137 else if (!includes(values, computed, comparator)) {
3138 result.push(value);
3139 }
3140 }
3141 return result;
3142 }
3143
3144 /**
3145 * The base implementation of `_.forEach` without support for iteratee shorthands.
3146 *
3147 * @private
3148 * @param {Array|Object} collection The collection to iterate over.
3149 * @param {Function} iteratee The function invoked per iteration.
3150 * @returns {Array|Object} Returns `collection`.
3151 */
3152 var baseEach = createBaseEach(baseForOwn);
3153
3154 /**
3155 * The base implementation of `_.forEachRight` without support for iteratee shorthands.
3156 *
3157 * @private
3158 * @param {Array|Object} collection The collection to iterate over.
3159 * @param {Function} iteratee The function invoked per iteration.
3160 * @returns {Array|Object} Returns `collection`.
3161 */
3162 var baseEachRight = createBaseEach(baseForOwnRight, true);
3163
3164 /**
3165 * The base implementation of `_.every` without support for iteratee shorthands.
3166 *
3167 * @private
3168 * @param {Array|Object} collection The collection to iterate over.
3169 * @param {Function} predicate The function invoked per iteration.
3170 * @returns {boolean} Returns `true` if all elements pass the predicate check,
3171 * else `false`
3172 */
3173 function baseEvery(collection, predicate) {
3174 var result = true;
3175 baseEach(collection, function(value, index, collection) {
3176 result = !!predicate(value, index, collection);
3177 return result;
3178 });
3179 return result;
3180 }
3181
3182 /**
3183 * The base implementation of methods like `_.max` and `_.min` which accepts a
3184 * `comparator` to determine the extremum value.
3185 *
3186 * @private
3187 * @param {Array} array The array to iterate over.
3188 * @param {Function} iteratee The iteratee invoked per iteration.
3189 * @param {Function} comparator The comparator used to compare values.
3190 * @returns {*} Returns the extremum value.
3191 */
3192 function baseExtremum(array, iteratee, comparator) {
3193 var index = -1,
3194 length = array.length;
3195
3196 while (++index < length) {
3197 var value = array[index],
3198 current = iteratee(value);
3199
3200 if (current != null && (computed === undefined$1
3201 ? (current === current && !isSymbol(current))
3202 : comparator(current, computed)
3203 )) {
3204 var computed = current,
3205 result = value;
3206 }
3207 }
3208 return result;
3209 }
3210
3211 /**
3212 * The base implementation of `_.fill` without an iteratee call guard.
3213 *
3214 * @private
3215 * @param {Array} array The array to fill.
3216 * @param {*} value The value to fill `array` with.
3217 * @param {number} [start=0] The start position.
3218 * @param {number} [end=array.length] The end position.
3219 * @returns {Array} Returns `array`.
3220 */
3221 function baseFill(array, value, start, end) {
3222 var length = array.length;
3223
3224 start = toInteger(start);
3225 if (start < 0) {
3226 start = -start > length ? 0 : (length + start);
3227 }
3228 end = (end === undefined$1 || end > length) ? length : toInteger(end);
3229 if (end < 0) {
3230 end += length;
3231 }
3232 end = start > end ? 0 : toLength(end);
3233 while (start < end) {
3234 array[start++] = value;
3235 }
3236 return array;
3237 }
3238
3239 /**
3240 * The base implementation of `_.filter` without support for iteratee shorthands.
3241 *
3242 * @private
3243 * @param {Array|Object} collection The collection to iterate over.
3244 * @param {Function} predicate The function invoked per iteration.
3245 * @returns {Array} Returns the new filtered array.
3246 */
3247 function baseFilter(collection, predicate) {
3248 var result = [];
3249 baseEach(collection, function(value, index, collection) {
3250 if (predicate(value, index, collection)) {
3251 result.push(value);
3252 }
3253 });
3254 return result;
3255 }
3256
3257 /**
3258 * The base implementation of `_.flatten` with support for restricting flattening.
3259 *
3260 * @private
3261 * @param {Array} array The array to flatten.
3262 * @param {number} depth The maximum recursion depth.
3263 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
3264 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
3265 * @param {Array} [result=[]] The initial result value.
3266 * @returns {Array} Returns the new flattened array.
3267 */
3268 function baseFlatten(array, depth, predicate, isStrict, result) {
3269 var index = -1,
3270 length = array.length;
3271
3272 predicate || (predicate = isFlattenable);
3273 result || (result = []);
3274
3275 while (++index < length) {
3276 var value = array[index];
3277 if (depth > 0 && predicate(value)) {
3278 if (depth > 1) {
3279 // Recursively flatten arrays (susceptible to call stack limits).
3280 baseFlatten(value, depth - 1, predicate, isStrict, result);
3281 } else {
3282 arrayPush(result, value);
3283 }
3284 } else if (!isStrict) {
3285 result[result.length] = value;
3286 }
3287 }
3288 return result;
3289 }
3290
3291 /**
3292 * The base implementation of `baseForOwn` which iterates over `object`
3293 * properties returned by `keysFunc` and invokes `iteratee` for each property.
3294 * Iteratee functions may exit iteration early by explicitly returning `false`.
3295 *
3296 * @private
3297 * @param {Object} object The object to iterate over.
3298 * @param {Function} iteratee The function invoked per iteration.
3299 * @param {Function} keysFunc The function to get the keys of `object`.
3300 * @returns {Object} Returns `object`.
3301 */
3302 var baseFor = createBaseFor();
3303
3304 /**
3305 * This function is like `baseFor` except that it iterates over properties
3306 * in the opposite order.
3307 *
3308 * @private
3309 * @param {Object} object The object to iterate over.
3310 * @param {Function} iteratee The function invoked per iteration.
3311 * @param {Function} keysFunc The function to get the keys of `object`.
3312 * @returns {Object} Returns `object`.
3313 */
3314 var baseForRight = createBaseFor(true);
3315
3316 /**
3317 * The base implementation of `_.forOwn` without support for iteratee shorthands.
3318 *
3319 * @private
3320 * @param {Object} object The object to iterate over.
3321 * @param {Function} iteratee The function invoked per iteration.
3322 * @returns {Object} Returns `object`.
3323 */
3324 function baseForOwn(object, iteratee) {
3325 return object && baseFor(object, iteratee, keys);
3326 }
3327
3328 /**
3329 * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
3330 *
3331 * @private
3332 * @param {Object} object The object to iterate over.
3333 * @param {Function} iteratee The function invoked per iteration.
3334 * @returns {Object} Returns `object`.
3335 */
3336 function baseForOwnRight(object, iteratee) {
3337 return object && baseForRight(object, iteratee, keys);
3338 }
3339
3340 /**
3341 * The base implementation of `_.functions` which creates an array of
3342 * `object` function property names filtered from `props`.
3343 *
3344 * @private
3345 * @param {Object} object The object to inspect.
3346 * @param {Array} props The property names to filter.
3347 * @returns {Array} Returns the function names.
3348 */
3349 function baseFunctions(object, props) {
3350 return arrayFilter(props, function(key) {
3351 return isFunction(object[key]);
3352 });
3353 }
3354
3355 /**
3356 * The base implementation of `_.get` without support for default values.
3357 *
3358 * @private
3359 * @param {Object} object The object to query.
3360 * @param {Array|string} path The path of the property to get.
3361 * @returns {*} Returns the resolved value.
3362 */
3363 function baseGet(object, path) {
3364 path = castPath(path, object);
3365
3366 var index = 0,
3367 length = path.length;
3368
3369 while (object != null && index < length) {
3370 object = object[toKey(path[index++])];
3371 }
3372 return (index && index == length) ? object : undefined$1;
3373 }
3374
3375 /**
3376 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
3377 * `keysFunc` and `symbolsFunc` to get the enumerable property names and
3378 * symbols of `object`.
3379 *
3380 * @private
3381 * @param {Object} object The object to query.
3382 * @param {Function} keysFunc The function to get the keys of `object`.
3383 * @param {Function} symbolsFunc The function to get the symbols of `object`.
3384 * @returns {Array} Returns the array of property names and symbols.
3385 */
3386 function baseGetAllKeys(object, keysFunc, symbolsFunc) {
3387 var result = keysFunc(object);
3388 return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
3389 }
3390
3391 /**
3392 * The base implementation of `getTag` without fallbacks for buggy environments.
3393 *
3394 * @private
3395 * @param {*} value The value to query.
3396 * @returns {string} Returns the `toStringTag`.
3397 */
3398 function baseGetTag(value) {
3399 if (value == null) {
3400 return value === undefined$1 ? undefinedTag : nullTag;
3401 }
3402 return (symToStringTag && symToStringTag in Object(value))
3403 ? getRawTag(value)
3404 : objectToString(value);
3405 }
3406
3407 /**
3408 * The base implementation of `_.gt` which doesn't coerce arguments.
3409 *
3410 * @private
3411 * @param {*} value The value to compare.
3412 * @param {*} other The other value to compare.
3413 * @returns {boolean} Returns `true` if `value` is greater than `other`,
3414 * else `false`.
3415 */
3416 function baseGt(value, other) {
3417 return value > other;
3418 }
3419
3420 /**
3421 * The base implementation of `_.has` without support for deep paths.
3422 *
3423 * @private
3424 * @param {Object} [object] The object to query.
3425 * @param {Array|string} key The key to check.
3426 * @returns {boolean} Returns `true` if `key` exists, else `false`.
3427 */
3428 function baseHas(object, key) {
3429 return object != null && hasOwnProperty.call(object, key);
3430 }
3431
3432 /**
3433 * The base implementation of `_.hasIn` without support for deep paths.
3434 *
3435 * @private
3436 * @param {Object} [object] The object to query.
3437 * @param {Array|string} key The key to check.
3438 * @returns {boolean} Returns `true` if `key` exists, else `false`.
3439 */
3440 function baseHasIn(object, key) {
3441 return object != null && key in Object(object);
3442 }
3443
3444 /**
3445 * The base implementation of `_.inRange` which doesn't coerce arguments.
3446 *
3447 * @private
3448 * @param {number} number The number to check.
3449 * @param {number} start The start of the range.
3450 * @param {number} end The end of the range.
3451 * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
3452 */
3453 function baseInRange(number, start, end) {
3454 return number >= nativeMin(start, end) && number < nativeMax(start, end);
3455 }
3456
3457 /**
3458 * The base implementation of methods like `_.intersection`, without support
3459 * for iteratee shorthands, that accepts an array of arrays to inspect.
3460 *
3461 * @private
3462 * @param {Array} arrays The arrays to inspect.
3463 * @param {Function} [iteratee] The iteratee invoked per element.
3464 * @param {Function} [comparator] The comparator invoked per element.
3465 * @returns {Array} Returns the new array of shared values.
3466 */
3467 function baseIntersection(arrays, iteratee, comparator) {
3468 var includes = comparator ? arrayIncludesWith : arrayIncludes,
3469 length = arrays[0].length,
3470 othLength = arrays.length,
3471 othIndex = othLength,
3472 caches = Array(othLength),
3473 maxLength = Infinity,
3474 result = [];
3475
3476 while (othIndex--) {
3477 var array = arrays[othIndex];
3478 if (othIndex && iteratee) {
3479 array = arrayMap(array, baseUnary(iteratee));
3480 }
3481 maxLength = nativeMin(array.length, maxLength);
3482 caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
3483 ? new SetCache(othIndex && array)
3484 : undefined$1;
3485 }
3486 array = arrays[0];
3487
3488 var index = -1,
3489 seen = caches[0];
3490
3491 outer:
3492 while (++index < length && result.length < maxLength) {
3493 var value = array[index],
3494 computed = iteratee ? iteratee(value) : value;
3495
3496 value = (comparator || value !== 0) ? value : 0;
3497 if (!(seen
3498 ? cacheHas(seen, computed)
3499 : includes(result, computed, comparator)
3500 )) {
3501 othIndex = othLength;
3502 while (--othIndex) {
3503 var cache = caches[othIndex];
3504 if (!(cache
3505 ? cacheHas(cache, computed)
3506 : includes(arrays[othIndex], computed, comparator))
3507 ) {
3508 continue outer;
3509 }
3510 }
3511 if (seen) {
3512 seen.push(computed);
3513 }
3514 result.push(value);
3515 }
3516 }
3517 return result;
3518 }
3519
3520 /**
3521 * The base implementation of `_.invert` and `_.invertBy` which inverts
3522 * `object` with values transformed by `iteratee` and set by `setter`.
3523 *
3524 * @private
3525 * @param {Object} object The object to iterate over.
3526 * @param {Function} setter The function to set `accumulator` values.
3527 * @param {Function} iteratee The iteratee to transform values.
3528 * @param {Object} accumulator The initial inverted object.
3529 * @returns {Function} Returns `accumulator`.
3530 */
3531 function baseInverter(object, setter, iteratee, accumulator) {
3532 baseForOwn(object, function(value, key, object) {
3533 setter(accumulator, iteratee(value), key, object);
3534 });
3535 return accumulator;
3536 }
3537
3538 /**
3539 * The base implementation of `_.invoke` without support for individual
3540 * method arguments.
3541 *
3542 * @private
3543 * @param {Object} object The object to query.
3544 * @param {Array|string} path The path of the method to invoke.
3545 * @param {Array} args The arguments to invoke the method with.
3546 * @returns {*} Returns the result of the invoked method.
3547 */
3548 function baseInvoke(object, path, args) {
3549 path = castPath(path, object);
3550 object = parent(object, path);
3551 var func = object == null ? object : object[toKey(last(path))];
3552 return func == null ? undefined$1 : apply(func, object, args);
3553 }
3554
3555 /**
3556 * The base implementation of `_.isArguments`.
3557 *
3558 * @private
3559 * @param {*} value The value to check.
3560 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
3561 */
3562 function baseIsArguments(value) {
3563 return isObjectLike(value) && baseGetTag(value) == argsTag;
3564 }
3565
3566 /**
3567 * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
3568 *
3569 * @private
3570 * @param {*} value The value to check.
3571 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
3572 */
3573 function baseIsArrayBuffer(value) {
3574 return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
3575 }
3576
3577 /**
3578 * The base implementation of `_.isDate` without Node.js optimizations.
3579 *
3580 * @private
3581 * @param {*} value The value to check.
3582 * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
3583 */
3584 function baseIsDate(value) {
3585 return isObjectLike(value) && baseGetTag(value) == dateTag;
3586 }
3587
3588 /**
3589 * The base implementation of `_.isEqual` which supports partial comparisons
3590 * and tracks traversed objects.
3591 *
3592 * @private
3593 * @param {*} value The value to compare.
3594 * @param {*} other The other value to compare.
3595 * @param {boolean} bitmask The bitmask flags.
3596 * 1 - Unordered comparison
3597 * 2 - Partial comparison
3598 * @param {Function} [customizer] The function to customize comparisons.
3599 * @param {Object} [stack] Tracks traversed `value` and `other` objects.
3600 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
3601 */
3602 function baseIsEqual(value, other, bitmask, customizer, stack) {
3603 if (value === other) {
3604 return true;
3605 }
3606 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
3607 return value !== value && other !== other;
3608 }
3609 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
3610 }
3611
3612 /**
3613 * A specialized version of `baseIsEqual` for arrays and objects which performs
3614 * deep comparisons and tracks traversed objects enabling objects with circular
3615 * references to be compared.
3616 *
3617 * @private
3618 * @param {Object} object The object to compare.
3619 * @param {Object} other The other object to compare.
3620 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
3621 * @param {Function} customizer The function to customize comparisons.
3622 * @param {Function} equalFunc The function to determine equivalents of values.
3623 * @param {Object} [stack] Tracks traversed `object` and `other` objects.
3624 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
3625 */
3626 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
3627 var objIsArr = isArray(object),
3628 othIsArr = isArray(other),
3629 objTag = objIsArr ? arrayTag : getTag(object),
3630 othTag = othIsArr ? arrayTag : getTag(other);
3631
3632 objTag = objTag == argsTag ? objectTag : objTag;
3633 othTag = othTag == argsTag ? objectTag : othTag;
3634
3635 var objIsObj = objTag == objectTag,
3636 othIsObj = othTag == objectTag,
3637 isSameTag = objTag == othTag;
3638
3639 if (isSameTag && isBuffer(object)) {
3640 if (!isBuffer(other)) {
3641 return false;
3642 }
3643 objIsArr = true;
3644 objIsObj = false;
3645 }
3646 if (isSameTag && !objIsObj) {
3647 stack || (stack = new Stack);
3648 return (objIsArr || isTypedArray(object))
3649 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
3650 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
3651 }
3652 if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
3653 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
3654 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
3655
3656 if (objIsWrapped || othIsWrapped) {
3657 var objUnwrapped = objIsWrapped ? object.value() : object,
3658 othUnwrapped = othIsWrapped ? other.value() : other;
3659
3660 stack || (stack = new Stack);
3661 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
3662 }
3663 }
3664 if (!isSameTag) {
3665 return false;
3666 }
3667 stack || (stack = new Stack);
3668 return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
3669 }
3670
3671 /**
3672 * The base implementation of `_.isMap` without Node.js optimizations.
3673 *
3674 * @private
3675 * @param {*} value The value to check.
3676 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
3677 */
3678 function baseIsMap(value) {
3679 return isObjectLike(value) && getTag(value) == mapTag;
3680 }
3681
3682 /**
3683 * The base implementation of `_.isMatch` without support for iteratee shorthands.
3684 *
3685 * @private
3686 * @param {Object} object The object to inspect.
3687 * @param {Object} source The object of property values to match.
3688 * @param {Array} matchData The property names, values, and compare flags to match.
3689 * @param {Function} [customizer] The function to customize comparisons.
3690 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
3691 */
3692 function baseIsMatch(object, source, matchData, customizer) {
3693 var index = matchData.length,
3694 length = index,
3695 noCustomizer = !customizer;
3696
3697 if (object == null) {
3698 return !length;
3699 }
3700 object = Object(object);
3701 while (index--) {
3702 var data = matchData[index];
3703 if ((noCustomizer && data[2])
3704 ? data[1] !== object[data[0]]
3705 : !(data[0] in object)
3706 ) {
3707 return false;
3708 }
3709 }
3710 while (++index < length) {
3711 data = matchData[index];
3712 var key = data[0],
3713 objValue = object[key],
3714 srcValue = data[1];
3715
3716 if (noCustomizer && data[2]) {
3717 if (objValue === undefined$1 && !(key in object)) {
3718 return false;
3719 }
3720 } else {
3721 var stack = new Stack;
3722 if (customizer) {
3723 var result = customizer(objValue, srcValue, key, object, source, stack);
3724 }
3725 if (!(result === undefined$1
3726 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
3727 : result
3728 )) {
3729 return false;
3730 }
3731 }
3732 }
3733 return true;
3734 }
3735
3736 /**
3737 * The base implementation of `_.isNative` without bad shim checks.
3738 *
3739 * @private
3740 * @param {*} value The value to check.
3741 * @returns {boolean} Returns `true` if `value` is a native function,
3742 * else `false`.
3743 */
3744 function baseIsNative(value) {
3745 if (!isObject(value) || isMasked(value)) {
3746 return false;
3747 }
3748 var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
3749 return pattern.test(toSource(value));
3750 }
3751
3752 /**
3753 * The base implementation of `_.isRegExp` without Node.js optimizations.
3754 *
3755 * @private
3756 * @param {*} value The value to check.
3757 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
3758 */
3759 function baseIsRegExp(value) {
3760 return isObjectLike(value) && baseGetTag(value) == regexpTag;
3761 }
3762
3763 /**
3764 * The base implementation of `_.isSet` without Node.js optimizations.
3765 *
3766 * @private
3767 * @param {*} value The value to check.
3768 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
3769 */
3770 function baseIsSet(value) {
3771 return isObjectLike(value) && getTag(value) == setTag;
3772 }
3773
3774 /**
3775 * The base implementation of `_.isTypedArray` without Node.js optimizations.
3776 *
3777 * @private
3778 * @param {*} value The value to check.
3779 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
3780 */
3781 function baseIsTypedArray(value) {
3782 return isObjectLike(value) &&
3783 isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
3784 }
3785
3786 /**
3787 * The base implementation of `_.iteratee`.
3788 *
3789 * @private
3790 * @param {*} [value=_.identity] The value to convert to an iteratee.
3791 * @returns {Function} Returns the iteratee.
3792 */
3793 function baseIteratee(value) {
3794 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
3795 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
3796 if (typeof value == 'function') {
3797 return value;
3798 }
3799 if (value == null) {
3800 return identity;
3801 }
3802 if (typeof value == 'object') {
3803 return isArray(value)
3804 ? baseMatchesProperty(value[0], value[1])
3805 : baseMatches(value);
3806 }
3807 return property(value);
3808 }
3809
3810 /**
3811 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
3812 *
3813 * @private
3814 * @param {Object} object The object to query.
3815 * @returns {Array} Returns the array of property names.
3816 */
3817 function baseKeys(object) {
3818 if (!isPrototype(object)) {
3819 return nativeKeys(object);
3820 }
3821 var result = [];
3822 for (var key in Object(object)) {
3823 if (hasOwnProperty.call(object, key) && key != 'constructor') {
3824 result.push(key);
3825 }
3826 }
3827 return result;
3828 }
3829
3830 /**
3831 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
3832 *
3833 * @private
3834 * @param {Object} object The object to query.
3835 * @returns {Array} Returns the array of property names.
3836 */
3837 function baseKeysIn(object) {
3838 if (!isObject(object)) {
3839 return nativeKeysIn(object);
3840 }
3841 var isProto = isPrototype(object),
3842 result = [];
3843
3844 for (var key in object) {
3845 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
3846 result.push(key);
3847 }
3848 }
3849 return result;
3850 }
3851
3852 /**
3853 * The base implementation of `_.lt` which doesn't coerce arguments.
3854 *
3855 * @private
3856 * @param {*} value The value to compare.
3857 * @param {*} other The other value to compare.
3858 * @returns {boolean} Returns `true` if `value` is less than `other`,
3859 * else `false`.
3860 */
3861 function baseLt(value, other) {
3862 return value < other;
3863 }
3864
3865 /**
3866 * The base implementation of `_.map` without support for iteratee shorthands.
3867 *
3868 * @private
3869 * @param {Array|Object} collection The collection to iterate over.
3870 * @param {Function} iteratee The function invoked per iteration.
3871 * @returns {Array} Returns the new mapped array.
3872 */
3873 function baseMap(collection, iteratee) {
3874 var index = -1,
3875 result = isArrayLike(collection) ? Array(collection.length) : [];
3876
3877 baseEach(collection, function(value, key, collection) {
3878 result[++index] = iteratee(value, key, collection);
3879 });
3880 return result;
3881 }
3882
3883 /**
3884 * The base implementation of `_.matches` which doesn't clone `source`.
3885 *
3886 * @private
3887 * @param {Object} source The object of property values to match.
3888 * @returns {Function} Returns the new spec function.
3889 */
3890 function baseMatches(source) {
3891 var matchData = getMatchData(source);
3892 if (matchData.length == 1 && matchData[0][2]) {
3893 return matchesStrictComparable(matchData[0][0], matchData[0][1]);
3894 }
3895 return function(object) {
3896 return object === source || baseIsMatch(object, source, matchData);
3897 };
3898 }
3899
3900 /**
3901 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
3902 *
3903 * @private
3904 * @param {string} path The path of the property to get.
3905 * @param {*} srcValue The value to match.
3906 * @returns {Function} Returns the new spec function.
3907 */
3908 function baseMatchesProperty(path, srcValue) {
3909 if (isKey(path) && isStrictComparable(srcValue)) {
3910 return matchesStrictComparable(toKey(path), srcValue);
3911 }
3912 return function(object) {
3913 var objValue = get(object, path);
3914 return (objValue === undefined$1 && objValue === srcValue)
3915 ? hasIn(object, path)
3916 : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
3917 };
3918 }
3919
3920 /**
3921 * The base implementation of `_.merge` without support for multiple sources.
3922 *
3923 * @private
3924 * @param {Object} object The destination object.
3925 * @param {Object} source The source object.
3926 * @param {number} srcIndex The index of `source`.
3927 * @param {Function} [customizer] The function to customize merged values.
3928 * @param {Object} [stack] Tracks traversed source values and their merged
3929 * counterparts.
3930 */
3931 function baseMerge(object, source, srcIndex, customizer, stack) {
3932 if (object === source) {
3933 return;
3934 }
3935 baseFor(source, function(srcValue, key) {
3936 stack || (stack = new Stack);
3937 if (isObject(srcValue)) {
3938 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
3939 }
3940 else {
3941 var newValue = customizer
3942 ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
3943 : undefined$1;
3944
3945 if (newValue === undefined$1) {
3946 newValue = srcValue;
3947 }
3948 assignMergeValue(object, key, newValue);
3949 }
3950 }, keysIn);
3951 }
3952
3953 /**
3954 * A specialized version of `baseMerge` for arrays and objects which performs
3955 * deep merges and tracks traversed objects enabling objects with circular
3956 * references to be merged.
3957 *
3958 * @private
3959 * @param {Object} object The destination object.
3960 * @param {Object} source The source object.
3961 * @param {string} key The key of the value to merge.
3962 * @param {number} srcIndex The index of `source`.
3963 * @param {Function} mergeFunc The function to merge values.
3964 * @param {Function} [customizer] The function to customize assigned values.
3965 * @param {Object} [stack] Tracks traversed source values and their merged
3966 * counterparts.
3967 */
3968 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
3969 var objValue = safeGet(object, key),
3970 srcValue = safeGet(source, key),
3971 stacked = stack.get(srcValue);
3972
3973 if (stacked) {
3974 assignMergeValue(object, key, stacked);
3975 return;
3976 }
3977 var newValue = customizer
3978 ? customizer(objValue, srcValue, (key + ''), object, source, stack)
3979 : undefined$1;
3980
3981 var isCommon = newValue === undefined$1;
3982
3983 if (isCommon) {
3984 var isArr = isArray(srcValue),
3985 isBuff = !isArr && isBuffer(srcValue),
3986 isTyped = !isArr && !isBuff && isTypedArray(srcValue);
3987
3988 newValue = srcValue;
3989 if (isArr || isBuff || isTyped) {
3990 if (isArray(objValue)) {
3991 newValue = objValue;
3992 }
3993 else if (isArrayLikeObject(objValue)) {
3994 newValue = copyArray(objValue);
3995 }
3996 else if (isBuff) {
3997 isCommon = false;
3998 newValue = cloneBuffer(srcValue, true);
3999 }
4000 else if (isTyped) {
4001 isCommon = false;
4002 newValue = cloneTypedArray(srcValue, true);
4003 }
4004 else {
4005 newValue = [];
4006 }
4007 }
4008 else if (isPlainObject(srcValue) || isArguments(srcValue)) {
4009 newValue = objValue;
4010 if (isArguments(objValue)) {
4011 newValue = toPlainObject(objValue);
4012 }
4013 else if (!isObject(objValue) || isFunction(objValue)) {
4014 newValue = initCloneObject(srcValue);
4015 }
4016 }
4017 else {
4018 isCommon = false;
4019 }
4020 }
4021 if (isCommon) {
4022 // Recursively merge objects and arrays (susceptible to call stack limits).
4023 stack.set(srcValue, newValue);
4024 mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
4025 stack['delete'](srcValue);
4026 }
4027 assignMergeValue(object, key, newValue);
4028 }
4029
4030 /**
4031 * The base implementation of `_.nth` which doesn't coerce arguments.
4032 *
4033 * @private
4034 * @param {Array} array The array to query.
4035 * @param {number} n The index of the element to return.
4036 * @returns {*} Returns the nth element of `array`.
4037 */
4038 function baseNth(array, n) {
4039 var length = array.length;
4040 if (!length) {
4041 return;
4042 }
4043 n += n < 0 ? length : 0;
4044 return isIndex(n, length) ? array[n] : undefined$1;
4045 }
4046
4047 /**
4048 * The base implementation of `_.orderBy` without param guards.
4049 *
4050 * @private
4051 * @param {Array|Object} collection The collection to iterate over.
4052 * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
4053 * @param {string[]} orders The sort orders of `iteratees`.
4054 * @returns {Array} Returns the new sorted array.
4055 */
4056 function baseOrderBy(collection, iteratees, orders) {
4057 if (iteratees.length) {
4058 iteratees = arrayMap(iteratees, function(iteratee) {
4059 if (isArray(iteratee)) {
4060 return function(value) {
4061 return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
4062 }
4063 }
4064 return iteratee;
4065 });
4066 } else {
4067 iteratees = [identity];
4068 }
4069
4070 var index = -1;
4071 iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
4072
4073 var result = baseMap(collection, function(value, key, collection) {
4074 var criteria = arrayMap(iteratees, function(iteratee) {
4075 return iteratee(value);
4076 });
4077 return { 'criteria': criteria, 'index': ++index, 'value': value };
4078 });
4079
4080 return baseSortBy(result, function(object, other) {
4081 return compareMultiple(object, other, orders);
4082 });
4083 }
4084
4085 /**
4086 * The base implementation of `_.pick` without support for individual
4087 * property identifiers.
4088 *
4089 * @private
4090 * @param {Object} object The source object.
4091 * @param {string[]} paths The property paths to pick.
4092 * @returns {Object} Returns the new object.
4093 */
4094 function basePick(object, paths) {
4095 return basePickBy(object, paths, function(value, path) {
4096 return hasIn(object, path);
4097 });
4098 }
4099
4100 /**
4101 * The base implementation of `_.pickBy` without support for iteratee shorthands.
4102 *
4103 * @private
4104 * @param {Object} object The source object.
4105 * @param {string[]} paths The property paths to pick.
4106 * @param {Function} predicate The function invoked per property.
4107 * @returns {Object} Returns the new object.
4108 */
4109 function basePickBy(object, paths, predicate) {
4110 var index = -1,
4111 length = paths.length,
4112 result = {};
4113
4114 while (++index < length) {
4115 var path = paths[index],
4116 value = baseGet(object, path);
4117
4118 if (predicate(value, path)) {
4119 baseSet(result, castPath(path, object), value);
4120 }
4121 }
4122 return result;
4123 }
4124
4125 /**
4126 * A specialized version of `baseProperty` which supports deep paths.
4127 *
4128 * @private
4129 * @param {Array|string} path The path of the property to get.
4130 * @returns {Function} Returns the new accessor function.
4131 */
4132 function basePropertyDeep(path) {
4133 return function(object) {
4134 return baseGet(object, path);
4135 };
4136 }
4137
4138 /**
4139 * The base implementation of `_.pullAllBy` without support for iteratee
4140 * shorthands.
4141 *
4142 * @private
4143 * @param {Array} array The array to modify.
4144 * @param {Array} values The values to remove.
4145 * @param {Function} [iteratee] The iteratee invoked per element.
4146 * @param {Function} [comparator] The comparator invoked per element.
4147 * @returns {Array} Returns `array`.
4148 */
4149 function basePullAll(array, values, iteratee, comparator) {
4150 var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
4151 index = -1,
4152 length = values.length,
4153 seen = array;
4154
4155 if (array === values) {
4156 values = copyArray(values);
4157 }
4158 if (iteratee) {
4159 seen = arrayMap(array, baseUnary(iteratee));
4160 }
4161 while (++index < length) {
4162 var fromIndex = 0,
4163 value = values[index],
4164 computed = iteratee ? iteratee(value) : value;
4165
4166 while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
4167 if (seen !== array) {
4168 splice.call(seen, fromIndex, 1);
4169 }
4170 splice.call(array, fromIndex, 1);
4171 }
4172 }
4173 return array;
4174 }
4175
4176 /**
4177 * The base implementation of `_.pullAt` without support for individual
4178 * indexes or capturing the removed elements.
4179 *
4180 * @private
4181 * @param {Array} array The array to modify.
4182 * @param {number[]} indexes The indexes of elements to remove.
4183 * @returns {Array} Returns `array`.
4184 */
4185 function basePullAt(array, indexes) {
4186 var length = array ? indexes.length : 0,
4187 lastIndex = length - 1;
4188
4189 while (length--) {
4190 var index = indexes[length];
4191 if (length == lastIndex || index !== previous) {
4192 var previous = index;
4193 if (isIndex(index)) {
4194 splice.call(array, index, 1);
4195 } else {
4196 baseUnset(array, index);
4197 }
4198 }
4199 }
4200 return array;
4201 }
4202
4203 /**
4204 * The base implementation of `_.random` without support for returning
4205 * floating-point numbers.
4206 *
4207 * @private
4208 * @param {number} lower The lower bound.
4209 * @param {number} upper The upper bound.
4210 * @returns {number} Returns the random number.
4211 */
4212 function baseRandom(lower, upper) {
4213 return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
4214 }
4215
4216 /**
4217 * The base implementation of `_.range` and `_.rangeRight` which doesn't
4218 * coerce arguments.
4219 *
4220 * @private
4221 * @param {number} start The start of the range.
4222 * @param {number} end The end of the range.
4223 * @param {number} step The value to increment or decrement by.
4224 * @param {boolean} [fromRight] Specify iterating from right to left.
4225 * @returns {Array} Returns the range of numbers.
4226 */
4227 function baseRange(start, end, step, fromRight) {
4228 var index = -1,
4229 length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
4230 result = Array(length);
4231
4232 while (length--) {
4233 result[fromRight ? length : ++index] = start;
4234 start += step;
4235 }
4236 return result;
4237 }
4238
4239 /**
4240 * The base implementation of `_.repeat` which doesn't coerce arguments.
4241 *
4242 * @private
4243 * @param {string} string The string to repeat.
4244 * @param {number} n The number of times to repeat the string.
4245 * @returns {string} Returns the repeated string.
4246 */
4247 function baseRepeat(string, n) {
4248 var result = '';
4249 if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
4250 return result;
4251 }
4252 // Leverage the exponentiation by squaring algorithm for a faster repeat.
4253 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
4254 do {
4255 if (n % 2) {
4256 result += string;
4257 }
4258 n = nativeFloor(n / 2);
4259 if (n) {
4260 string += string;
4261 }
4262 } while (n);
4263
4264 return result;
4265 }
4266
4267 /**
4268 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
4269 *
4270 * @private
4271 * @param {Function} func The function to apply a rest parameter to.
4272 * @param {number} [start=func.length-1] The start position of the rest parameter.
4273 * @returns {Function} Returns the new function.
4274 */
4275 function baseRest(func, start) {
4276 return setToString(overRest(func, start, identity), func + '');
4277 }
4278
4279 /**
4280 * The base implementation of `_.sample`.
4281 *
4282 * @private
4283 * @param {Array|Object} collection The collection to sample.
4284 * @returns {*} Returns the random element.
4285 */
4286 function baseSample(collection) {
4287 return arraySample(values(collection));
4288 }
4289
4290 /**
4291 * The base implementation of `_.sampleSize` without param guards.
4292 *
4293 * @private
4294 * @param {Array|Object} collection The collection to sample.
4295 * @param {number} n The number of elements to sample.
4296 * @returns {Array} Returns the random elements.
4297 */
4298 function baseSampleSize(collection, n) {
4299 var array = values(collection);
4300 return shuffleSelf(array, baseClamp(n, 0, array.length));
4301 }
4302
4303 /**
4304 * The base implementation of `_.set`.
4305 *
4306 * @private
4307 * @param {Object} object The object to modify.
4308 * @param {Array|string} path The path of the property to set.
4309 * @param {*} value The value to set.
4310 * @param {Function} [customizer] The function to customize path creation.
4311 * @returns {Object} Returns `object`.
4312 */
4313 function baseSet(object, path, value, customizer) {
4314 if (!isObject(object)) {
4315 return object;
4316 }
4317 path = castPath(path, object);
4318
4319 var index = -1,
4320 length = path.length,
4321 lastIndex = length - 1,
4322 nested = object;
4323
4324 while (nested != null && ++index < length) {
4325 var key = toKey(path[index]),
4326 newValue = value;
4327
4328 if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
4329 return object;
4330 }
4331
4332 if (index != lastIndex) {
4333 var objValue = nested[key];
4334 newValue = customizer ? customizer(objValue, key, nested) : undefined$1;
4335 if (newValue === undefined$1) {
4336 newValue = isObject(objValue)
4337 ? objValue
4338 : (isIndex(path[index + 1]) ? [] : {});
4339 }
4340 }
4341 assignValue(nested, key, newValue);
4342 nested = nested[key];
4343 }
4344 return object;
4345 }
4346
4347 /**
4348 * The base implementation of `setData` without support for hot loop shorting.
4349 *
4350 * @private
4351 * @param {Function} func The function to associate metadata with.
4352 * @param {*} data The metadata.
4353 * @returns {Function} Returns `func`.
4354 */
4355 var baseSetData = !metaMap ? identity : function(func, data) {
4356 metaMap.set(func, data);
4357 return func;
4358 };
4359
4360 /**
4361 * The base implementation of `setToString` without support for hot loop shorting.
4362 *
4363 * @private
4364 * @param {Function} func The function to modify.
4365 * @param {Function} string The `toString` result.
4366 * @returns {Function} Returns `func`.
4367 */
4368 var baseSetToString = !defineProperty ? identity : function(func, string) {
4369 return defineProperty(func, 'toString', {
4370 'configurable': true,
4371 'enumerable': false,
4372 'value': constant(string),
4373 'writable': true
4374 });
4375 };
4376
4377 /**
4378 * The base implementation of `_.shuffle`.
4379 *
4380 * @private
4381 * @param {Array|Object} collection The collection to shuffle.
4382 * @returns {Array} Returns the new shuffled array.
4383 */
4384 function baseShuffle(collection) {
4385 return shuffleSelf(values(collection));
4386 }
4387
4388 /**
4389 * The base implementation of `_.slice` without an iteratee call guard.
4390 *
4391 * @private
4392 * @param {Array} array The array to slice.
4393 * @param {number} [start=0] The start position.
4394 * @param {number} [end=array.length] The end position.
4395 * @returns {Array} Returns the slice of `array`.
4396 */
4397 function baseSlice(array, start, end) {
4398 var index = -1,
4399 length = array.length;
4400
4401 if (start < 0) {
4402 start = -start > length ? 0 : (length + start);
4403 }
4404 end = end > length ? length : end;
4405 if (end < 0) {
4406 end += length;
4407 }
4408 length = start > end ? 0 : ((end - start) >>> 0);
4409 start >>>= 0;
4410
4411 var result = Array(length);
4412 while (++index < length) {
4413 result[index] = array[index + start];
4414 }
4415 return result;
4416 }
4417
4418 /**
4419 * The base implementation of `_.some` without support for iteratee shorthands.
4420 *
4421 * @private
4422 * @param {Array|Object} collection The collection to iterate over.
4423 * @param {Function} predicate The function invoked per iteration.
4424 * @returns {boolean} Returns `true` if any element passes the predicate check,
4425 * else `false`.
4426 */
4427 function baseSome(collection, predicate) {
4428 var result;
4429
4430 baseEach(collection, function(value, index, collection) {
4431 result = predicate(value, index, collection);
4432 return !result;
4433 });
4434 return !!result;
4435 }
4436
4437 /**
4438 * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
4439 * performs a binary search of `array` to determine the index at which `value`
4440 * should be inserted into `array` in order to maintain its sort order.
4441 *
4442 * @private
4443 * @param {Array} array The sorted array to inspect.
4444 * @param {*} value The value to evaluate.
4445 * @param {boolean} [retHighest] Specify returning the highest qualified index.
4446 * @returns {number} Returns the index at which `value` should be inserted
4447 * into `array`.
4448 */
4449 function baseSortedIndex(array, value, retHighest) {
4450 var low = 0,
4451 high = array == null ? low : array.length;
4452
4453 if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
4454 while (low < high) {
4455 var mid = (low + high) >>> 1,
4456 computed = array[mid];
4457
4458 if (computed !== null && !isSymbol(computed) &&
4459 (retHighest ? (computed <= value) : (computed < value))) {
4460 low = mid + 1;
4461 } else {
4462 high = mid;
4463 }
4464 }
4465 return high;
4466 }
4467 return baseSortedIndexBy(array, value, identity, retHighest);
4468 }
4469
4470 /**
4471 * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
4472 * which invokes `iteratee` for `value` and each element of `array` to compute
4473 * their sort ranking. The iteratee is invoked with one argument; (value).
4474 *
4475 * @private
4476 * @param {Array} array The sorted array to inspect.
4477 * @param {*} value The value to evaluate.
4478 * @param {Function} iteratee The iteratee invoked per element.
4479 * @param {boolean} [retHighest] Specify returning the highest qualified index.
4480 * @returns {number} Returns the index at which `value` should be inserted
4481 * into `array`.
4482 */
4483 function baseSortedIndexBy(array, value, iteratee, retHighest) {
4484 var low = 0,
4485 high = array == null ? 0 : array.length;
4486 if (high === 0) {
4487 return 0;
4488 }
4489
4490 value = iteratee(value);
4491 var valIsNaN = value !== value,
4492 valIsNull = value === null,
4493 valIsSymbol = isSymbol(value),
4494 valIsUndefined = value === undefined$1;
4495
4496 while (low < high) {
4497 var mid = nativeFloor((low + high) / 2),
4498 computed = iteratee(array[mid]),
4499 othIsDefined = computed !== undefined$1,
4500 othIsNull = computed === null,
4501 othIsReflexive = computed === computed,
4502 othIsSymbol = isSymbol(computed);
4503
4504 if (valIsNaN) {
4505 var setLow = retHighest || othIsReflexive;
4506 } else if (valIsUndefined) {
4507 setLow = othIsReflexive && (retHighest || othIsDefined);
4508 } else if (valIsNull) {
4509 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
4510 } else if (valIsSymbol) {
4511 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
4512 } else if (othIsNull || othIsSymbol) {
4513 setLow = false;
4514 } else {
4515 setLow = retHighest ? (computed <= value) : (computed < value);
4516 }
4517 if (setLow) {
4518 low = mid + 1;
4519 } else {
4520 high = mid;
4521 }
4522 }
4523 return nativeMin(high, MAX_ARRAY_INDEX);
4524 }
4525
4526 /**
4527 * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
4528 * support for iteratee shorthands.
4529 *
4530 * @private
4531 * @param {Array} array The array to inspect.
4532 * @param {Function} [iteratee] The iteratee invoked per element.
4533 * @returns {Array} Returns the new duplicate free array.
4534 */
4535 function baseSortedUniq(array, iteratee) {
4536 var index = -1,
4537 length = array.length,
4538 resIndex = 0,
4539 result = [];
4540
4541 while (++index < length) {
4542 var value = array[index],
4543 computed = iteratee ? iteratee(value) : value;
4544
4545 if (!index || !eq(computed, seen)) {
4546 var seen = computed;
4547 result[resIndex++] = value === 0 ? 0 : value;
4548 }
4549 }
4550 return result;
4551 }
4552
4553 /**
4554 * The base implementation of `_.toNumber` which doesn't ensure correct
4555 * conversions of binary, hexadecimal, or octal string values.
4556 *
4557 * @private
4558 * @param {*} value The value to process.
4559 * @returns {number} Returns the number.
4560 */
4561 function baseToNumber(value) {
4562 if (typeof value == 'number') {
4563 return value;
4564 }
4565 if (isSymbol(value)) {
4566 return NAN;
4567 }
4568 return +value;
4569 }
4570
4571 /**
4572 * The base implementation of `_.toString` which doesn't convert nullish
4573 * values to empty strings.
4574 *
4575 * @private
4576 * @param {*} value The value to process.
4577 * @returns {string} Returns the string.
4578 */
4579 function baseToString(value) {
4580 // Exit early for strings to avoid a performance hit in some environments.
4581 if (typeof value == 'string') {
4582 return value;
4583 }
4584 if (isArray(value)) {
4585 // Recursively convert values (susceptible to call stack limits).
4586 return arrayMap(value, baseToString) + '';
4587 }
4588 if (isSymbol(value)) {
4589 return symbolToString ? symbolToString.call(value) : '';
4590 }
4591 var result = (value + '');
4592 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
4593 }
4594
4595 /**
4596 * The base implementation of `_.uniqBy` without support for iteratee shorthands.
4597 *
4598 * @private
4599 * @param {Array} array The array to inspect.
4600 * @param {Function} [iteratee] The iteratee invoked per element.
4601 * @param {Function} [comparator] The comparator invoked per element.
4602 * @returns {Array} Returns the new duplicate free array.
4603 */
4604 function baseUniq(array, iteratee, comparator) {
4605 var index = -1,
4606 includes = arrayIncludes,
4607 length = array.length,
4608 isCommon = true,
4609 result = [],
4610 seen = result;
4611
4612 if (comparator) {
4613 isCommon = false;
4614 includes = arrayIncludesWith;
4615 }
4616 else if (length >= LARGE_ARRAY_SIZE) {
4617 var set = iteratee ? null : createSet(array);
4618 if (set) {
4619 return setToArray(set);
4620 }
4621 isCommon = false;
4622 includes = cacheHas;
4623 seen = new SetCache;
4624 }
4625 else {
4626 seen = iteratee ? [] : result;
4627 }
4628 outer:
4629 while (++index < length) {
4630 var value = array[index],
4631 computed = iteratee ? iteratee(value) : value;
4632
4633 value = (comparator || value !== 0) ? value : 0;
4634 if (isCommon && computed === computed) {
4635 var seenIndex = seen.length;
4636 while (seenIndex--) {
4637 if (seen[seenIndex] === computed) {
4638 continue outer;
4639 }
4640 }
4641 if (iteratee) {
4642 seen.push(computed);
4643 }
4644 result.push(value);
4645 }
4646 else if (!includes(seen, computed, comparator)) {
4647 if (seen !== result) {
4648 seen.push(computed);
4649 }
4650 result.push(value);
4651 }
4652 }
4653 return result;
4654 }
4655
4656 /**
4657 * The base implementation of `_.unset`.
4658 *
4659 * @private
4660 * @param {Object} object The object to modify.
4661 * @param {Array|string} path The property path to unset.
4662 * @returns {boolean} Returns `true` if the property is deleted, else `false`.
4663 */
4664 function baseUnset(object, path) {
4665 path = castPath(path, object);
4666 object = parent(object, path);
4667 return object == null || delete object[toKey(last(path))];
4668 }
4669
4670 /**
4671 * The base implementation of `_.update`.
4672 *
4673 * @private
4674 * @param {Object} object The object to modify.
4675 * @param {Array|string} path The path of the property to update.
4676 * @param {Function} updater The function to produce the updated value.
4677 * @param {Function} [customizer] The function to customize path creation.
4678 * @returns {Object} Returns `object`.
4679 */
4680 function baseUpdate(object, path, updater, customizer) {
4681 return baseSet(object, path, updater(baseGet(object, path)), customizer);
4682 }
4683
4684 /**
4685 * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
4686 * without support for iteratee shorthands.
4687 *
4688 * @private
4689 * @param {Array} array The array to query.
4690 * @param {Function} predicate The function invoked per iteration.
4691 * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
4692 * @param {boolean} [fromRight] Specify iterating from right to left.
4693 * @returns {Array} Returns the slice of `array`.
4694 */
4695 function baseWhile(array, predicate, isDrop, fromRight) {
4696 var length = array.length,
4697 index = fromRight ? length : -1;
4698
4699 while ((fromRight ? index-- : ++index < length) &&
4700 predicate(array[index], index, array)) {}
4701
4702 return isDrop
4703 ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
4704 : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
4705 }
4706
4707 /**
4708 * The base implementation of `wrapperValue` which returns the result of
4709 * performing a sequence of actions on the unwrapped `value`, where each
4710 * successive action is supplied the return value of the previous.
4711 *
4712 * @private
4713 * @param {*} value The unwrapped value.
4714 * @param {Array} actions Actions to perform to resolve the unwrapped value.
4715 * @returns {*} Returns the resolved value.
4716 */
4717 function baseWrapperValue(value, actions) {
4718 var result = value;
4719 if (result instanceof LazyWrapper) {
4720 result = result.value();
4721 }
4722 return arrayReduce(actions, function(result, action) {
4723 return action.func.apply(action.thisArg, arrayPush([result], action.args));
4724 }, result);
4725 }
4726
4727 /**
4728 * The base implementation of methods like `_.xor`, without support for
4729 * iteratee shorthands, that accepts an array of arrays to inspect.
4730 *
4731 * @private
4732 * @param {Array} arrays The arrays to inspect.
4733 * @param {Function} [iteratee] The iteratee invoked per element.
4734 * @param {Function} [comparator] The comparator invoked per element.
4735 * @returns {Array} Returns the new array of values.
4736 */
4737 function baseXor(arrays, iteratee, comparator) {
4738 var length = arrays.length;
4739 if (length < 2) {
4740 return length ? baseUniq(arrays[0]) : [];
4741 }
4742 var index = -1,
4743 result = Array(length);
4744
4745 while (++index < length) {
4746 var array = arrays[index],
4747 othIndex = -1;
4748
4749 while (++othIndex < length) {
4750 if (othIndex != index) {
4751 result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
4752 }
4753 }
4754 }
4755 return baseUniq(baseFlatten(result, 1), iteratee, comparator);
4756 }
4757
4758 /**
4759 * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
4760 *
4761 * @private
4762 * @param {Array} props The property identifiers.
4763 * @param {Array} values The property values.
4764 * @param {Function} assignFunc The function to assign values.
4765 * @returns {Object} Returns the new object.
4766 */
4767 function baseZipObject(props, values, assignFunc) {
4768 var index = -1,
4769 length = props.length,
4770 valsLength = values.length,
4771 result = {};
4772
4773 while (++index < length) {
4774 var value = index < valsLength ? values[index] : undefined$1;
4775 assignFunc(result, props[index], value);
4776 }
4777 return result;
4778 }
4779
4780 /**
4781 * Casts `value` to an empty array if it's not an array like object.
4782 *
4783 * @private
4784 * @param {*} value The value to inspect.
4785 * @returns {Array|Object} Returns the cast array-like object.
4786 */
4787 function castArrayLikeObject(value) {
4788 return isArrayLikeObject(value) ? value : [];
4789 }
4790
4791 /**
4792 * Casts `value` to `identity` if it's not a function.
4793 *
4794 * @private
4795 * @param {*} value The value to inspect.
4796 * @returns {Function} Returns cast function.
4797 */
4798 function castFunction(value) {
4799 return typeof value == 'function' ? value : identity;
4800 }
4801
4802 /**
4803 * Casts `value` to a path array if it's not one.
4804 *
4805 * @private
4806 * @param {*} value The value to inspect.
4807 * @param {Object} [object] The object to query keys on.
4808 * @returns {Array} Returns the cast property path array.
4809 */
4810 function castPath(value, object) {
4811 if (isArray(value)) {
4812 return value;
4813 }
4814 return isKey(value, object) ? [value] : stringToPath(toString(value));
4815 }
4816
4817 /**
4818 * A `baseRest` alias which can be replaced with `identity` by module
4819 * replacement plugins.
4820 *
4821 * @private
4822 * @type {Function}
4823 * @param {Function} func The function to apply a rest parameter to.
4824 * @returns {Function} Returns the new function.
4825 */
4826 var castRest = baseRest;
4827
4828 /**
4829 * Casts `array` to a slice if it's needed.
4830 *
4831 * @private
4832 * @param {Array} array The array to inspect.
4833 * @param {number} start The start position.
4834 * @param {number} [end=array.length] The end position.
4835 * @returns {Array} Returns the cast slice.
4836 */
4837 function castSlice(array, start, end) {
4838 var length = array.length;
4839 end = end === undefined$1 ? length : end;
4840 return (!start && end >= length) ? array : baseSlice(array, start, end);
4841 }
4842
4843 /**
4844 * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
4845 *
4846 * @private
4847 * @param {number|Object} id The timer id or timeout object of the timer to clear.
4848 */
4849 var clearTimeout = ctxClearTimeout || function(id) {
4850 return root.clearTimeout(id);
4851 };
4852
4853 /**
4854 * Creates a clone of `buffer`.
4855 *
4856 * @private
4857 * @param {Buffer} buffer The buffer to clone.
4858 * @param {boolean} [isDeep] Specify a deep clone.
4859 * @returns {Buffer} Returns the cloned buffer.
4860 */
4861 function cloneBuffer(buffer, isDeep) {
4862 if (isDeep) {
4863 return buffer.slice();
4864 }
4865 var length = buffer.length,
4866 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
4867
4868 buffer.copy(result);
4869 return result;
4870 }
4871
4872 /**
4873 * Creates a clone of `arrayBuffer`.
4874 *
4875 * @private
4876 * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
4877 * @returns {ArrayBuffer} Returns the cloned array buffer.
4878 */
4879 function cloneArrayBuffer(arrayBuffer) {
4880 var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
4881 new Uint8Array(result).set(new Uint8Array(arrayBuffer));
4882 return result;
4883 }
4884
4885 /**
4886 * Creates a clone of `dataView`.
4887 *
4888 * @private
4889 * @param {Object} dataView The data view to clone.
4890 * @param {boolean} [isDeep] Specify a deep clone.
4891 * @returns {Object} Returns the cloned data view.
4892 */
4893 function cloneDataView(dataView, isDeep) {
4894 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
4895 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
4896 }
4897
4898 /**
4899 * Creates a clone of `regexp`.
4900 *
4901 * @private
4902 * @param {Object} regexp The regexp to clone.
4903 * @returns {Object} Returns the cloned regexp.
4904 */
4905 function cloneRegExp(regexp) {
4906 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
4907 result.lastIndex = regexp.lastIndex;
4908 return result;
4909 }
4910
4911 /**
4912 * Creates a clone of the `symbol` object.
4913 *
4914 * @private
4915 * @param {Object} symbol The symbol object to clone.
4916 * @returns {Object} Returns the cloned symbol object.
4917 */
4918 function cloneSymbol(symbol) {
4919 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
4920 }
4921
4922 /**
4923 * Creates a clone of `typedArray`.
4924 *
4925 * @private
4926 * @param {Object} typedArray The typed array to clone.
4927 * @param {boolean} [isDeep] Specify a deep clone.
4928 * @returns {Object} Returns the cloned typed array.
4929 */
4930 function cloneTypedArray(typedArray, isDeep) {
4931 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
4932 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
4933 }
4934
4935 /**
4936 * Compares values to sort them in ascending order.
4937 *
4938 * @private
4939 * @param {*} value The value to compare.
4940 * @param {*} other The other value to compare.
4941 * @returns {number} Returns the sort order indicator for `value`.
4942 */
4943 function compareAscending(value, other) {
4944 if (value !== other) {
4945 var valIsDefined = value !== undefined$1,
4946 valIsNull = value === null,
4947 valIsReflexive = value === value,
4948 valIsSymbol = isSymbol(value);
4949
4950 var othIsDefined = other !== undefined$1,
4951 othIsNull = other === null,
4952 othIsReflexive = other === other,
4953 othIsSymbol = isSymbol(other);
4954
4955 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
4956 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
4957 (valIsNull && othIsDefined && othIsReflexive) ||
4958 (!valIsDefined && othIsReflexive) ||
4959 !valIsReflexive) {
4960 return 1;
4961 }
4962 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
4963 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
4964 (othIsNull && valIsDefined && valIsReflexive) ||
4965 (!othIsDefined && valIsReflexive) ||
4966 !othIsReflexive) {
4967 return -1;
4968 }
4969 }
4970 return 0;
4971 }
4972
4973 /**
4974 * Used by `_.orderBy` to compare multiple properties of a value to another
4975 * and stable sort them.
4976 *
4977 * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
4978 * specify an order of "desc" for descending or "asc" for ascending sort order
4979 * of corresponding values.
4980 *
4981 * @private
4982 * @param {Object} object The object to compare.
4983 * @param {Object} other The other object to compare.
4984 * @param {boolean[]|string[]} orders The order to sort by for each property.
4985 * @returns {number} Returns the sort order indicator for `object`.
4986 */
4987 function compareMultiple(object, other, orders) {
4988 var index = -1,
4989 objCriteria = object.criteria,
4990 othCriteria = other.criteria,
4991 length = objCriteria.length,
4992 ordersLength = orders.length;
4993
4994 while (++index < length) {
4995 var result = compareAscending(objCriteria[index], othCriteria[index]);
4996 if (result) {
4997 if (index >= ordersLength) {
4998 return result;
4999 }
5000 var order = orders[index];
5001 return result * (order == 'desc' ? -1 : 1);
5002 }
5003 }
5004 // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
5005 // that causes it, under certain circumstances, to provide the same value for
5006 // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
5007 // for more details.
5008 //
5009 // This also ensures a stable sort in V8 and other engines.
5010 // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
5011 return object.index - other.index;
5012 }
5013
5014 /**
5015 * Creates an array that is the composition of partially applied arguments,
5016 * placeholders, and provided arguments into a single array of arguments.
5017 *
5018 * @private
5019 * @param {Array} args The provided arguments.
5020 * @param {Array} partials The arguments to prepend to those provided.
5021 * @param {Array} holders The `partials` placeholder indexes.
5022 * @params {boolean} [isCurried] Specify composing for a curried function.
5023 * @returns {Array} Returns the new array of composed arguments.
5024 */
5025 function composeArgs(args, partials, holders, isCurried) {
5026 var argsIndex = -1,
5027 argsLength = args.length,
5028 holdersLength = holders.length,
5029 leftIndex = -1,
5030 leftLength = partials.length,
5031 rangeLength = nativeMax(argsLength - holdersLength, 0),
5032 result = Array(leftLength + rangeLength),
5033 isUncurried = !isCurried;
5034
5035 while (++leftIndex < leftLength) {
5036 result[leftIndex] = partials[leftIndex];
5037 }
5038 while (++argsIndex < holdersLength) {
5039 if (isUncurried || argsIndex < argsLength) {
5040 result[holders[argsIndex]] = args[argsIndex];
5041 }
5042 }
5043 while (rangeLength--) {
5044 result[leftIndex++] = args[argsIndex++];
5045 }
5046 return result;
5047 }
5048
5049 /**
5050 * This function is like `composeArgs` except that the arguments composition
5051 * is tailored for `_.partialRight`.
5052 *
5053 * @private
5054 * @param {Array} args The provided arguments.
5055 * @param {Array} partials The arguments to append to those provided.
5056 * @param {Array} holders The `partials` placeholder indexes.
5057 * @params {boolean} [isCurried] Specify composing for a curried function.
5058 * @returns {Array} Returns the new array of composed arguments.
5059 */
5060 function composeArgsRight(args, partials, holders, isCurried) {
5061 var argsIndex = -1,
5062 argsLength = args.length,
5063 holdersIndex = -1,
5064 holdersLength = holders.length,
5065 rightIndex = -1,
5066 rightLength = partials.length,
5067 rangeLength = nativeMax(argsLength - holdersLength, 0),
5068 result = Array(rangeLength + rightLength),
5069 isUncurried = !isCurried;
5070
5071 while (++argsIndex < rangeLength) {
5072 result[argsIndex] = args[argsIndex];
5073 }
5074 var offset = argsIndex;
5075 while (++rightIndex < rightLength) {
5076 result[offset + rightIndex] = partials[rightIndex];
5077 }
5078 while (++holdersIndex < holdersLength) {
5079 if (isUncurried || argsIndex < argsLength) {
5080 result[offset + holders[holdersIndex]] = args[argsIndex++];
5081 }
5082 }
5083 return result;
5084 }
5085
5086 /**
5087 * Copies the values of `source` to `array`.
5088 *
5089 * @private
5090 * @param {Array} source The array to copy values from.
5091 * @param {Array} [array=[]] The array to copy values to.
5092 * @returns {Array} Returns `array`.
5093 */
5094 function copyArray(source, array) {
5095 var index = -1,
5096 length = source.length;
5097
5098 array || (array = Array(length));
5099 while (++index < length) {
5100 array[index] = source[index];
5101 }
5102 return array;
5103 }
5104
5105 /**
5106 * Copies properties of `source` to `object`.
5107 *
5108 * @private
5109 * @param {Object} source The object to copy properties from.
5110 * @param {Array} props The property identifiers to copy.
5111 * @param {Object} [object={}] The object to copy properties to.
5112 * @param {Function} [customizer] The function to customize copied values.
5113 * @returns {Object} Returns `object`.
5114 */
5115 function copyObject(source, props, object, customizer) {
5116 var isNew = !object;
5117 object || (object = {});
5118
5119 var index = -1,
5120 length = props.length;
5121
5122 while (++index < length) {
5123 var key = props[index];
5124
5125 var newValue = customizer
5126 ? customizer(object[key], source[key], key, object, source)
5127 : undefined$1;
5128
5129 if (newValue === undefined$1) {
5130 newValue = source[key];
5131 }
5132 if (isNew) {
5133 baseAssignValue(object, key, newValue);
5134 } else {
5135 assignValue(object, key, newValue);
5136 }
5137 }
5138 return object;
5139 }
5140
5141 /**
5142 * Copies own symbols of `source` to `object`.
5143 *
5144 * @private
5145 * @param {Object} source The object to copy symbols from.
5146 * @param {Object} [object={}] The object to copy symbols to.
5147 * @returns {Object} Returns `object`.
5148 */
5149 function copySymbols(source, object) {
5150 return copyObject(source, getSymbols(source), object);
5151 }
5152
5153 /**
5154 * Copies own and inherited symbols of `source` to `object`.
5155 *
5156 * @private
5157 * @param {Object} source The object to copy symbols from.
5158 * @param {Object} [object={}] The object to copy symbols to.
5159 * @returns {Object} Returns `object`.
5160 */
5161 function copySymbolsIn(source, object) {
5162 return copyObject(source, getSymbolsIn(source), object);
5163 }
5164
5165 /**
5166 * Creates a function like `_.groupBy`.
5167 *
5168 * @private
5169 * @param {Function} setter The function to set accumulator values.
5170 * @param {Function} [initializer] The accumulator object initializer.
5171 * @returns {Function} Returns the new aggregator function.
5172 */
5173 function createAggregator(setter, initializer) {
5174 return function(collection, iteratee) {
5175 var func = isArray(collection) ? arrayAggregator : baseAggregator,
5176 accumulator = initializer ? initializer() : {};
5177
5178 return func(collection, setter, getIteratee(iteratee, 2), accumulator);
5179 };
5180 }
5181
5182 /**
5183 * Creates a function like `_.assign`.
5184 *
5185 * @private
5186 * @param {Function} assigner The function to assign values.
5187 * @returns {Function} Returns the new assigner function.
5188 */
5189 function createAssigner(assigner) {
5190 return baseRest(function(object, sources) {
5191 var index = -1,
5192 length = sources.length,
5193 customizer = length > 1 ? sources[length - 1] : undefined$1,
5194 guard = length > 2 ? sources[2] : undefined$1;
5195
5196 customizer = (assigner.length > 3 && typeof customizer == 'function')
5197 ? (length--, customizer)
5198 : undefined$1;
5199
5200 if (guard && isIterateeCall(sources[0], sources[1], guard)) {
5201 customizer = length < 3 ? undefined$1 : customizer;
5202 length = 1;
5203 }
5204 object = Object(object);
5205 while (++index < length) {
5206 var source = sources[index];
5207 if (source) {
5208 assigner(object, source, index, customizer);
5209 }
5210 }
5211 return object;
5212 });
5213 }
5214
5215 /**
5216 * Creates a `baseEach` or `baseEachRight` function.
5217 *
5218 * @private
5219 * @param {Function} eachFunc The function to iterate over a collection.
5220 * @param {boolean} [fromRight] Specify iterating from right to left.
5221 * @returns {Function} Returns the new base function.
5222 */
5223 function createBaseEach(eachFunc, fromRight) {
5224 return function(collection, iteratee) {
5225 if (collection == null) {
5226 return collection;
5227 }
5228 if (!isArrayLike(collection)) {
5229 return eachFunc(collection, iteratee);
5230 }
5231 var length = collection.length,
5232 index = fromRight ? length : -1,
5233 iterable = Object(collection);
5234
5235 while ((fromRight ? index-- : ++index < length)) {
5236 if (iteratee(iterable[index], index, iterable) === false) {
5237 break;
5238 }
5239 }
5240 return collection;
5241 };
5242 }
5243
5244 /**
5245 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
5246 *
5247 * @private
5248 * @param {boolean} [fromRight] Specify iterating from right to left.
5249 * @returns {Function} Returns the new base function.
5250 */
5251 function createBaseFor(fromRight) {
5252 return function(object, iteratee, keysFunc) {
5253 var index = -1,
5254 iterable = Object(object),
5255 props = keysFunc(object),
5256 length = props.length;
5257
5258 while (length--) {
5259 var key = props[fromRight ? length : ++index];
5260 if (iteratee(iterable[key], key, iterable) === false) {
5261 break;
5262 }
5263 }
5264 return object;
5265 };
5266 }
5267
5268 /**
5269 * Creates a function that wraps `func` to invoke it with the optional `this`
5270 * binding of `thisArg`.
5271 *
5272 * @private
5273 * @param {Function} func The function to wrap.
5274 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5275 * @param {*} [thisArg] The `this` binding of `func`.
5276 * @returns {Function} Returns the new wrapped function.
5277 */
5278 function createBind(func, bitmask, thisArg) {
5279 var isBind = bitmask & WRAP_BIND_FLAG,
5280 Ctor = createCtor(func);
5281
5282 function wrapper() {
5283 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5284 return fn.apply(isBind ? thisArg : this, arguments);
5285 }
5286 return wrapper;
5287 }
5288
5289 /**
5290 * Creates a function like `_.lowerFirst`.
5291 *
5292 * @private
5293 * @param {string} methodName The name of the `String` case method to use.
5294 * @returns {Function} Returns the new case function.
5295 */
5296 function createCaseFirst(methodName) {
5297 return function(string) {
5298 string = toString(string);
5299
5300 var strSymbols = hasUnicode(string)
5301 ? stringToArray(string)
5302 : undefined$1;
5303
5304 var chr = strSymbols
5305 ? strSymbols[0]
5306 : string.charAt(0);
5307
5308 var trailing = strSymbols
5309 ? castSlice(strSymbols, 1).join('')
5310 : string.slice(1);
5311
5312 return chr[methodName]() + trailing;
5313 };
5314 }
5315
5316 /**
5317 * Creates a function like `_.camelCase`.
5318 *
5319 * @private
5320 * @param {Function} callback The function to combine each word.
5321 * @returns {Function} Returns the new compounder function.
5322 */
5323 function createCompounder(callback) {
5324 return function(string) {
5325 return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
5326 };
5327 }
5328
5329 /**
5330 * Creates a function that produces an instance of `Ctor` regardless of
5331 * whether it was invoked as part of a `new` expression or by `call` or `apply`.
5332 *
5333 * @private
5334 * @param {Function} Ctor The constructor to wrap.
5335 * @returns {Function} Returns the new wrapped function.
5336 */
5337 function createCtor(Ctor) {
5338 return function() {
5339 // Use a `switch` statement to work with class constructors. See
5340 // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
5341 // for more details.
5342 var args = arguments;
5343 switch (args.length) {
5344 case 0: return new Ctor;
5345 case 1: return new Ctor(args[0]);
5346 case 2: return new Ctor(args[0], args[1]);
5347 case 3: return new Ctor(args[0], args[1], args[2]);
5348 case 4: return new Ctor(args[0], args[1], args[2], args[3]);
5349 case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
5350 case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
5351 case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
5352 }
5353 var thisBinding = baseCreate(Ctor.prototype),
5354 result = Ctor.apply(thisBinding, args);
5355
5356 // Mimic the constructor's `return` behavior.
5357 // See https://es5.github.io/#x13.2.2 for more details.
5358 return isObject(result) ? result : thisBinding;
5359 };
5360 }
5361
5362 /**
5363 * Creates a function that wraps `func` to enable currying.
5364 *
5365 * @private
5366 * @param {Function} func The function to wrap.
5367 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5368 * @param {number} arity The arity of `func`.
5369 * @returns {Function} Returns the new wrapped function.
5370 */
5371 function createCurry(func, bitmask, arity) {
5372 var Ctor = createCtor(func);
5373
5374 function wrapper() {
5375 var length = arguments.length,
5376 args = Array(length),
5377 index = length,
5378 placeholder = getHolder(wrapper);
5379
5380 while (index--) {
5381 args[index] = arguments[index];
5382 }
5383 var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
5384 ? []
5385 : replaceHolders(args, placeholder);
5386
5387 length -= holders.length;
5388 if (length < arity) {
5389 return createRecurry(
5390 func, bitmask, createHybrid, wrapper.placeholder, undefined$1,
5391 args, holders, undefined$1, undefined$1, arity - length);
5392 }
5393 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5394 return apply(fn, this, args);
5395 }
5396 return wrapper;
5397 }
5398
5399 /**
5400 * Creates a `_.find` or `_.findLast` function.
5401 *
5402 * @private
5403 * @param {Function} findIndexFunc The function to find the collection index.
5404 * @returns {Function} Returns the new find function.
5405 */
5406 function createFind(findIndexFunc) {
5407 return function(collection, predicate, fromIndex) {
5408 var iterable = Object(collection);
5409 if (!isArrayLike(collection)) {
5410 var iteratee = getIteratee(predicate, 3);
5411 collection = keys(collection);
5412 predicate = function(key) { return iteratee(iterable[key], key, iterable); };
5413 }
5414 var index = findIndexFunc(collection, predicate, fromIndex);
5415 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined$1;
5416 };
5417 }
5418
5419 /**
5420 * Creates a `_.flow` or `_.flowRight` function.
5421 *
5422 * @private
5423 * @param {boolean} [fromRight] Specify iterating from right to left.
5424 * @returns {Function} Returns the new flow function.
5425 */
5426 function createFlow(fromRight) {
5427 return flatRest(function(funcs) {
5428 var length = funcs.length,
5429 index = length,
5430 prereq = LodashWrapper.prototype.thru;
5431
5432 if (fromRight) {
5433 funcs.reverse();
5434 }
5435 while (index--) {
5436 var func = funcs[index];
5437 if (typeof func != 'function') {
5438 throw new TypeError(FUNC_ERROR_TEXT);
5439 }
5440 if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
5441 var wrapper = new LodashWrapper([], true);
5442 }
5443 }
5444 index = wrapper ? index : length;
5445 while (++index < length) {
5446 func = funcs[index];
5447
5448 var funcName = getFuncName(func),
5449 data = funcName == 'wrapper' ? getData(func) : undefined$1;
5450
5451 if (data && isLaziable(data[0]) &&
5452 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
5453 !data[4].length && data[9] == 1
5454 ) {
5455 wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
5456 } else {
5457 wrapper = (func.length == 1 && isLaziable(func))
5458 ? wrapper[funcName]()
5459 : wrapper.thru(func);
5460 }
5461 }
5462 return function() {
5463 var args = arguments,
5464 value = args[0];
5465
5466 if (wrapper && args.length == 1 && isArray(value)) {
5467 return wrapper.plant(value).value();
5468 }
5469 var index = 0,
5470 result = length ? funcs[index].apply(this, args) : value;
5471
5472 while (++index < length) {
5473 result = funcs[index].call(this, result);
5474 }
5475 return result;
5476 };
5477 });
5478 }
5479
5480 /**
5481 * Creates a function that wraps `func` to invoke it with optional `this`
5482 * binding of `thisArg`, partial application, and currying.
5483 *
5484 * @private
5485 * @param {Function|string} func The function or method name to wrap.
5486 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5487 * @param {*} [thisArg] The `this` binding of `func`.
5488 * @param {Array} [partials] The arguments to prepend to those provided to
5489 * the new function.
5490 * @param {Array} [holders] The `partials` placeholder indexes.
5491 * @param {Array} [partialsRight] The arguments to append to those provided
5492 * to the new function.
5493 * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
5494 * @param {Array} [argPos] The argument positions of the new function.
5495 * @param {number} [ary] The arity cap of `func`.
5496 * @param {number} [arity] The arity of `func`.
5497 * @returns {Function} Returns the new wrapped function.
5498 */
5499 function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
5500 var isAry = bitmask & WRAP_ARY_FLAG,
5501 isBind = bitmask & WRAP_BIND_FLAG,
5502 isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
5503 isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
5504 isFlip = bitmask & WRAP_FLIP_FLAG,
5505 Ctor = isBindKey ? undefined$1 : createCtor(func);
5506
5507 function wrapper() {
5508 var length = arguments.length,
5509 args = Array(length),
5510 index = length;
5511
5512 while (index--) {
5513 args[index] = arguments[index];
5514 }
5515 if (isCurried) {
5516 var placeholder = getHolder(wrapper),
5517 holdersCount = countHolders(args, placeholder);
5518 }
5519 if (partials) {
5520 args = composeArgs(args, partials, holders, isCurried);
5521 }
5522 if (partialsRight) {
5523 args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
5524 }
5525 length -= holdersCount;
5526 if (isCurried && length < arity) {
5527 var newHolders = replaceHolders(args, placeholder);
5528 return createRecurry(
5529 func, bitmask, createHybrid, wrapper.placeholder, thisArg,
5530 args, newHolders, argPos, ary, arity - length
5531 );
5532 }
5533 var thisBinding = isBind ? thisArg : this,
5534 fn = isBindKey ? thisBinding[func] : func;
5535
5536 length = args.length;
5537 if (argPos) {
5538 args = reorder(args, argPos);
5539 } else if (isFlip && length > 1) {
5540 args.reverse();
5541 }
5542 if (isAry && ary < length) {
5543 args.length = ary;
5544 }
5545 if (this && this !== root && this instanceof wrapper) {
5546 fn = Ctor || createCtor(fn);
5547 }
5548 return fn.apply(thisBinding, args);
5549 }
5550 return wrapper;
5551 }
5552
5553 /**
5554 * Creates a function like `_.invertBy`.
5555 *
5556 * @private
5557 * @param {Function} setter The function to set accumulator values.
5558 * @param {Function} toIteratee The function to resolve iteratees.
5559 * @returns {Function} Returns the new inverter function.
5560 */
5561 function createInverter(setter, toIteratee) {
5562 return function(object, iteratee) {
5563 return baseInverter(object, setter, toIteratee(iteratee), {});
5564 };
5565 }
5566
5567 /**
5568 * Creates a function that performs a mathematical operation on two values.
5569 *
5570 * @private
5571 * @param {Function} operator The function to perform the operation.
5572 * @param {number} [defaultValue] The value used for `undefined` arguments.
5573 * @returns {Function} Returns the new mathematical operation function.
5574 */
5575 function createMathOperation(operator, defaultValue) {
5576 return function(value, other) {
5577 var result;
5578 if (value === undefined$1 && other === undefined$1) {
5579 return defaultValue;
5580 }
5581 if (value !== undefined$1) {
5582 result = value;
5583 }
5584 if (other !== undefined$1) {
5585 if (result === undefined$1) {
5586 return other;
5587 }
5588 if (typeof value == 'string' || typeof other == 'string') {
5589 value = baseToString(value);
5590 other = baseToString(other);
5591 } else {
5592 value = baseToNumber(value);
5593 other = baseToNumber(other);
5594 }
5595 result = operator(value, other);
5596 }
5597 return result;
5598 };
5599 }
5600
5601 /**
5602 * Creates a function like `_.over`.
5603 *
5604 * @private
5605 * @param {Function} arrayFunc The function to iterate over iteratees.
5606 * @returns {Function} Returns the new over function.
5607 */
5608 function createOver(arrayFunc) {
5609 return flatRest(function(iteratees) {
5610 iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
5611 return baseRest(function(args) {
5612 var thisArg = this;
5613 return arrayFunc(iteratees, function(iteratee) {
5614 return apply(iteratee, thisArg, args);
5615 });
5616 });
5617 });
5618 }
5619
5620 /**
5621 * Creates the padding for `string` based on `length`. The `chars` string
5622 * is truncated if the number of characters exceeds `length`.
5623 *
5624 * @private
5625 * @param {number} length The padding length.
5626 * @param {string} [chars=' '] The string used as padding.
5627 * @returns {string} Returns the padding for `string`.
5628 */
5629 function createPadding(length, chars) {
5630 chars = chars === undefined$1 ? ' ' : baseToString(chars);
5631
5632 var charsLength = chars.length;
5633 if (charsLength < 2) {
5634 return charsLength ? baseRepeat(chars, length) : chars;
5635 }
5636 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
5637 return hasUnicode(chars)
5638 ? castSlice(stringToArray(result), 0, length).join('')
5639 : result.slice(0, length);
5640 }
5641
5642 /**
5643 * Creates a function that wraps `func` to invoke it with the `this` binding
5644 * of `thisArg` and `partials` prepended to the arguments it receives.
5645 *
5646 * @private
5647 * @param {Function} func The function to wrap.
5648 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5649 * @param {*} thisArg The `this` binding of `func`.
5650 * @param {Array} partials The arguments to prepend to those provided to
5651 * the new function.
5652 * @returns {Function} Returns the new wrapped function.
5653 */
5654 function createPartial(func, bitmask, thisArg, partials) {
5655 var isBind = bitmask & WRAP_BIND_FLAG,
5656 Ctor = createCtor(func);
5657
5658 function wrapper() {
5659 var argsIndex = -1,
5660 argsLength = arguments.length,
5661 leftIndex = -1,
5662 leftLength = partials.length,
5663 args = Array(leftLength + argsLength),
5664 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5665
5666 while (++leftIndex < leftLength) {
5667 args[leftIndex] = partials[leftIndex];
5668 }
5669 while (argsLength--) {
5670 args[leftIndex++] = arguments[++argsIndex];
5671 }
5672 return apply(fn, isBind ? thisArg : this, args);
5673 }
5674 return wrapper;
5675 }
5676
5677 /**
5678 * Creates a `_.range` or `_.rangeRight` function.
5679 *
5680 * @private
5681 * @param {boolean} [fromRight] Specify iterating from right to left.
5682 * @returns {Function} Returns the new range function.
5683 */
5684 function createRange(fromRight) {
5685 return function(start, end, step) {
5686 if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
5687 end = step = undefined$1;
5688 }
5689 // Ensure the sign of `-0` is preserved.
5690 start = toFinite(start);
5691 if (end === undefined$1) {
5692 end = start;
5693 start = 0;
5694 } else {
5695 end = toFinite(end);
5696 }
5697 step = step === undefined$1 ? (start < end ? 1 : -1) : toFinite(step);
5698 return baseRange(start, end, step, fromRight);
5699 };
5700 }
5701
5702 /**
5703 * Creates a function that performs a relational operation on two values.
5704 *
5705 * @private
5706 * @param {Function} operator The function to perform the operation.
5707 * @returns {Function} Returns the new relational operation function.
5708 */
5709 function createRelationalOperation(operator) {
5710 return function(value, other) {
5711 if (!(typeof value == 'string' && typeof other == 'string')) {
5712 value = toNumber(value);
5713 other = toNumber(other);
5714 }
5715 return operator(value, other);
5716 };
5717 }
5718
5719 /**
5720 * Creates a function that wraps `func` to continue currying.
5721 *
5722 * @private
5723 * @param {Function} func The function to wrap.
5724 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5725 * @param {Function} wrapFunc The function to create the `func` wrapper.
5726 * @param {*} placeholder The placeholder value.
5727 * @param {*} [thisArg] The `this` binding of `func`.
5728 * @param {Array} [partials] The arguments to prepend to those provided to
5729 * the new function.
5730 * @param {Array} [holders] The `partials` placeholder indexes.
5731 * @param {Array} [argPos] The argument positions of the new function.
5732 * @param {number} [ary] The arity cap of `func`.
5733 * @param {number} [arity] The arity of `func`.
5734 * @returns {Function} Returns the new wrapped function.
5735 */
5736 function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
5737 var isCurry = bitmask & WRAP_CURRY_FLAG,
5738 newHolders = isCurry ? holders : undefined$1,
5739 newHoldersRight = isCurry ? undefined$1 : holders,
5740 newPartials = isCurry ? partials : undefined$1,
5741 newPartialsRight = isCurry ? undefined$1 : partials;
5742
5743 bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
5744 bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
5745
5746 if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
5747 bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
5748 }
5749 var newData = [
5750 func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
5751 newHoldersRight, argPos, ary, arity
5752 ];
5753
5754 var result = wrapFunc.apply(undefined$1, newData);
5755 if (isLaziable(func)) {
5756 setData(result, newData);
5757 }
5758 result.placeholder = placeholder;
5759 return setWrapToString(result, func, bitmask);
5760 }
5761
5762 /**
5763 * Creates a function like `_.round`.
5764 *
5765 * @private
5766 * @param {string} methodName The name of the `Math` method to use when rounding.
5767 * @returns {Function} Returns the new round function.
5768 */
5769 function createRound(methodName) {
5770 var func = Math[methodName];
5771 return function(number, precision) {
5772 number = toNumber(number);
5773 precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
5774 if (precision && nativeIsFinite(number)) {
5775 // Shift with exponential notation to avoid floating-point issues.
5776 // See [MDN](https://mdn.io/round#Examples) for more details.
5777 var pair = (toString(number) + 'e').split('e'),
5778 value = func(pair[0] + 'e' + (+pair[1] + precision));
5779
5780 pair = (toString(value) + 'e').split('e');
5781 return +(pair[0] + 'e' + (+pair[1] - precision));
5782 }
5783 return func(number);
5784 };
5785 }
5786
5787 /**
5788 * Creates a set object of `values`.
5789 *
5790 * @private
5791 * @param {Array} values The values to add to the set.
5792 * @returns {Object} Returns the new set.
5793 */
5794 var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
5795 return new Set(values);
5796 };
5797
5798 /**
5799 * Creates a `_.toPairs` or `_.toPairsIn` function.
5800 *
5801 * @private
5802 * @param {Function} keysFunc The function to get the keys of a given object.
5803 * @returns {Function} Returns the new pairs function.
5804 */
5805 function createToPairs(keysFunc) {
5806 return function(object) {
5807 var tag = getTag(object);
5808 if (tag == mapTag) {
5809 return mapToArray(object);
5810 }
5811 if (tag == setTag) {
5812 return setToPairs(object);
5813 }
5814 return baseToPairs(object, keysFunc(object));
5815 };
5816 }
5817
5818 /**
5819 * Creates a function that either curries or invokes `func` with optional
5820 * `this` binding and partially applied arguments.
5821 *
5822 * @private
5823 * @param {Function|string} func The function or method name to wrap.
5824 * @param {number} bitmask The bitmask flags.
5825 * 1 - `_.bind`
5826 * 2 - `_.bindKey`
5827 * 4 - `_.curry` or `_.curryRight` of a bound function
5828 * 8 - `_.curry`
5829 * 16 - `_.curryRight`
5830 * 32 - `_.partial`
5831 * 64 - `_.partialRight`
5832 * 128 - `_.rearg`
5833 * 256 - `_.ary`
5834 * 512 - `_.flip`
5835 * @param {*} [thisArg] The `this` binding of `func`.
5836 * @param {Array} [partials] The arguments to be partially applied.
5837 * @param {Array} [holders] The `partials` placeholder indexes.
5838 * @param {Array} [argPos] The argument positions of the new function.
5839 * @param {number} [ary] The arity cap of `func`.
5840 * @param {number} [arity] The arity of `func`.
5841 * @returns {Function} Returns the new wrapped function.
5842 */
5843 function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
5844 var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
5845 if (!isBindKey && typeof func != 'function') {
5846 throw new TypeError(FUNC_ERROR_TEXT);
5847 }
5848 var length = partials ? partials.length : 0;
5849 if (!length) {
5850 bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
5851 partials = holders = undefined$1;
5852 }
5853 ary = ary === undefined$1 ? ary : nativeMax(toInteger(ary), 0);
5854 arity = arity === undefined$1 ? arity : toInteger(arity);
5855 length -= holders ? holders.length : 0;
5856
5857 if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
5858 var partialsRight = partials,
5859 holdersRight = holders;
5860
5861 partials = holders = undefined$1;
5862 }
5863 var data = isBindKey ? undefined$1 : getData(func);
5864
5865 var newData = [
5866 func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
5867 argPos, ary, arity
5868 ];
5869
5870 if (data) {
5871 mergeData(newData, data);
5872 }
5873 func = newData[0];
5874 bitmask = newData[1];
5875 thisArg = newData[2];
5876 partials = newData[3];
5877 holders = newData[4];
5878 arity = newData[9] = newData[9] === undefined$1
5879 ? (isBindKey ? 0 : func.length)
5880 : nativeMax(newData[9] - length, 0);
5881
5882 if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
5883 bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
5884 }
5885 if (!bitmask || bitmask == WRAP_BIND_FLAG) {
5886 var result = createBind(func, bitmask, thisArg);
5887 } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
5888 result = createCurry(func, bitmask, arity);
5889 } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
5890 result = createPartial(func, bitmask, thisArg, partials);
5891 } else {
5892 result = createHybrid.apply(undefined$1, newData);
5893 }
5894 var setter = data ? baseSetData : setData;
5895 return setWrapToString(setter(result, newData), func, bitmask);
5896 }
5897
5898 /**
5899 * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
5900 * of source objects to the destination object for all destination properties
5901 * that resolve to `undefined`.
5902 *
5903 * @private
5904 * @param {*} objValue The destination value.
5905 * @param {*} srcValue The source value.
5906 * @param {string} key The key of the property to assign.
5907 * @param {Object} object The parent object of `objValue`.
5908 * @returns {*} Returns the value to assign.
5909 */
5910 function customDefaultsAssignIn(objValue, srcValue, key, object) {
5911 if (objValue === undefined$1 ||
5912 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
5913 return srcValue;
5914 }
5915 return objValue;
5916 }
5917
5918 /**
5919 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
5920 * objects into destination objects that are passed thru.
5921 *
5922 * @private
5923 * @param {*} objValue The destination value.
5924 * @param {*} srcValue The source value.
5925 * @param {string} key The key of the property to merge.
5926 * @param {Object} object The parent object of `objValue`.
5927 * @param {Object} source The parent object of `srcValue`.
5928 * @param {Object} [stack] Tracks traversed source values and their merged
5929 * counterparts.
5930 * @returns {*} Returns the value to assign.
5931 */
5932 function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
5933 if (isObject(objValue) && isObject(srcValue)) {
5934 // Recursively merge objects and arrays (susceptible to call stack limits).
5935 stack.set(srcValue, objValue);
5936 baseMerge(objValue, srcValue, undefined$1, customDefaultsMerge, stack);
5937 stack['delete'](srcValue);
5938 }
5939 return objValue;
5940 }
5941
5942 /**
5943 * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
5944 * objects.
5945 *
5946 * @private
5947 * @param {*} value The value to inspect.
5948 * @param {string} key The key of the property to inspect.
5949 * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
5950 */
5951 function customOmitClone(value) {
5952 return isPlainObject(value) ? undefined$1 : value;
5953 }
5954
5955 /**
5956 * A specialized version of `baseIsEqualDeep` for arrays with support for
5957 * partial deep comparisons.
5958 *
5959 * @private
5960 * @param {Array} array The array to compare.
5961 * @param {Array} other The other array to compare.
5962 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
5963 * @param {Function} customizer The function to customize comparisons.
5964 * @param {Function} equalFunc The function to determine equivalents of values.
5965 * @param {Object} stack Tracks traversed `array` and `other` objects.
5966 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
5967 */
5968 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
5969 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
5970 arrLength = array.length,
5971 othLength = other.length;
5972
5973 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
5974 return false;
5975 }
5976 // Check that cyclic values are equal.
5977 var arrStacked = stack.get(array);
5978 var othStacked = stack.get(other);
5979 if (arrStacked && othStacked) {
5980 return arrStacked == other && othStacked == array;
5981 }
5982 var index = -1,
5983 result = true,
5984 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined$1;
5985
5986 stack.set(array, other);
5987 stack.set(other, array);
5988
5989 // Ignore non-index properties.
5990 while (++index < arrLength) {
5991 var arrValue = array[index],
5992 othValue = other[index];
5993
5994 if (customizer) {
5995 var compared = isPartial
5996 ? customizer(othValue, arrValue, index, other, array, stack)
5997 : customizer(arrValue, othValue, index, array, other, stack);
5998 }
5999 if (compared !== undefined$1) {
6000 if (compared) {
6001 continue;
6002 }
6003 result = false;
6004 break;
6005 }
6006 // Recursively compare arrays (susceptible to call stack limits).
6007 if (seen) {
6008 if (!arraySome(other, function(othValue, othIndex) {
6009 if (!cacheHas(seen, othIndex) &&
6010 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
6011 return seen.push(othIndex);
6012 }
6013 })) {
6014 result = false;
6015 break;
6016 }
6017 } else if (!(
6018 arrValue === othValue ||
6019 equalFunc(arrValue, othValue, bitmask, customizer, stack)
6020 )) {
6021 result = false;
6022 break;
6023 }
6024 }
6025 stack['delete'](array);
6026 stack['delete'](other);
6027 return result;
6028 }
6029
6030 /**
6031 * A specialized version of `baseIsEqualDeep` for comparing objects of
6032 * the same `toStringTag`.
6033 *
6034 * **Note:** This function only supports comparing values with tags of
6035 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
6036 *
6037 * @private
6038 * @param {Object} object The object to compare.
6039 * @param {Object} other The other object to compare.
6040 * @param {string} tag The `toStringTag` of the objects to compare.
6041 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
6042 * @param {Function} customizer The function to customize comparisons.
6043 * @param {Function} equalFunc The function to determine equivalents of values.
6044 * @param {Object} stack Tracks traversed `object` and `other` objects.
6045 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
6046 */
6047 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
6048 switch (tag) {
6049 case dataViewTag:
6050 if ((object.byteLength != other.byteLength) ||
6051 (object.byteOffset != other.byteOffset)) {
6052 return false;
6053 }
6054 object = object.buffer;
6055 other = other.buffer;
6056
6057 case arrayBufferTag:
6058 if ((object.byteLength != other.byteLength) ||
6059 !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
6060 return false;
6061 }
6062 return true;
6063
6064 case boolTag:
6065 case dateTag:
6066 case numberTag:
6067 // Coerce booleans to `1` or `0` and dates to milliseconds.
6068 // Invalid dates are coerced to `NaN`.
6069 return eq(+object, +other);
6070
6071 case errorTag:
6072 return object.name == other.name && object.message == other.message;
6073
6074 case regexpTag:
6075 case stringTag:
6076 // Coerce regexes to strings and treat strings, primitives and objects,
6077 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
6078 // for more details.
6079 return object == (other + '');
6080
6081 case mapTag:
6082 var convert = mapToArray;
6083
6084 case setTag:
6085 var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
6086 convert || (convert = setToArray);
6087
6088 if (object.size != other.size && !isPartial) {
6089 return false;
6090 }
6091 // Assume cyclic values are equal.
6092 var stacked = stack.get(object);
6093 if (stacked) {
6094 return stacked == other;
6095 }
6096 bitmask |= COMPARE_UNORDERED_FLAG;
6097
6098 // Recursively compare objects (susceptible to call stack limits).
6099 stack.set(object, other);
6100 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
6101 stack['delete'](object);
6102 return result;
6103
6104 case symbolTag:
6105 if (symbolValueOf) {
6106 return symbolValueOf.call(object) == symbolValueOf.call(other);
6107 }
6108 }
6109 return false;
6110 }
6111
6112 /**
6113 * A specialized version of `baseIsEqualDeep` for objects with support for
6114 * partial deep comparisons.
6115 *
6116 * @private
6117 * @param {Object} object The object to compare.
6118 * @param {Object} other The other object to compare.
6119 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
6120 * @param {Function} customizer The function to customize comparisons.
6121 * @param {Function} equalFunc The function to determine equivalents of values.
6122 * @param {Object} stack Tracks traversed `object` and `other` objects.
6123 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
6124 */
6125 function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
6126 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
6127 objProps = getAllKeys(object),
6128 objLength = objProps.length,
6129 othProps = getAllKeys(other),
6130 othLength = othProps.length;
6131
6132 if (objLength != othLength && !isPartial) {
6133 return false;
6134 }
6135 var index = objLength;
6136 while (index--) {
6137 var key = objProps[index];
6138 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
6139 return false;
6140 }
6141 }
6142 // Check that cyclic values are equal.
6143 var objStacked = stack.get(object);
6144 var othStacked = stack.get(other);
6145 if (objStacked && othStacked) {
6146 return objStacked == other && othStacked == object;
6147 }
6148 var result = true;
6149 stack.set(object, other);
6150 stack.set(other, object);
6151
6152 var skipCtor = isPartial;
6153 while (++index < objLength) {
6154 key = objProps[index];
6155 var objValue = object[key],
6156 othValue = other[key];
6157
6158 if (customizer) {
6159 var compared = isPartial
6160 ? customizer(othValue, objValue, key, other, object, stack)
6161 : customizer(objValue, othValue, key, object, other, stack);
6162 }
6163 // Recursively compare objects (susceptible to call stack limits).
6164 if (!(compared === undefined$1
6165 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
6166 : compared
6167 )) {
6168 result = false;
6169 break;
6170 }
6171 skipCtor || (skipCtor = key == 'constructor');
6172 }
6173 if (result && !skipCtor) {
6174 var objCtor = object.constructor,
6175 othCtor = other.constructor;
6176
6177 // Non `Object` object instances with different constructors are not equal.
6178 if (objCtor != othCtor &&
6179 ('constructor' in object && 'constructor' in other) &&
6180 !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
6181 typeof othCtor == 'function' && othCtor instanceof othCtor)) {
6182 result = false;
6183 }
6184 }
6185 stack['delete'](object);
6186 stack['delete'](other);
6187 return result;
6188 }
6189
6190 /**
6191 * A specialized version of `baseRest` which flattens the rest array.
6192 *
6193 * @private
6194 * @param {Function} func The function to apply a rest parameter to.
6195 * @returns {Function} Returns the new function.
6196 */
6197 function flatRest(func) {
6198 return setToString(overRest(func, undefined$1, flatten), func + '');
6199 }
6200
6201 /**
6202 * Creates an array of own enumerable property names and symbols of `object`.
6203 *
6204 * @private
6205 * @param {Object} object The object to query.
6206 * @returns {Array} Returns the array of property names and symbols.
6207 */
6208 function getAllKeys(object) {
6209 return baseGetAllKeys(object, keys, getSymbols);
6210 }
6211
6212 /**
6213 * Creates an array of own and inherited enumerable property names and
6214 * symbols of `object`.
6215 *
6216 * @private
6217 * @param {Object} object The object to query.
6218 * @returns {Array} Returns the array of property names and symbols.
6219 */
6220 function getAllKeysIn(object) {
6221 return baseGetAllKeys(object, keysIn, getSymbolsIn);
6222 }
6223
6224 /**
6225 * Gets metadata for `func`.
6226 *
6227 * @private
6228 * @param {Function} func The function to query.
6229 * @returns {*} Returns the metadata for `func`.
6230 */
6231 var getData = !metaMap ? noop : function(func) {
6232 return metaMap.get(func);
6233 };
6234
6235 /**
6236 * Gets the name of `func`.
6237 *
6238 * @private
6239 * @param {Function} func The function to query.
6240 * @returns {string} Returns the function name.
6241 */
6242 function getFuncName(func) {
6243 var result = (func.name + ''),
6244 array = realNames[result],
6245 length = hasOwnProperty.call(realNames, result) ? array.length : 0;
6246
6247 while (length--) {
6248 var data = array[length],
6249 otherFunc = data.func;
6250 if (otherFunc == null || otherFunc == func) {
6251 return data.name;
6252 }
6253 }
6254 return result;
6255 }
6256
6257 /**
6258 * Gets the argument placeholder value for `func`.
6259 *
6260 * @private
6261 * @param {Function} func The function to inspect.
6262 * @returns {*} Returns the placeholder value.
6263 */
6264 function getHolder(func) {
6265 var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
6266 return object.placeholder;
6267 }
6268
6269 /**
6270 * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
6271 * this function returns the custom method, otherwise it returns `baseIteratee`.
6272 * If arguments are provided, the chosen function is invoked with them and
6273 * its result is returned.
6274 *
6275 * @private
6276 * @param {*} [value] The value to convert to an iteratee.
6277 * @param {number} [arity] The arity of the created iteratee.
6278 * @returns {Function} Returns the chosen function or its result.
6279 */
6280 function getIteratee() {
6281 var result = lodash.iteratee || iteratee;
6282 result = result === iteratee ? baseIteratee : result;
6283 return arguments.length ? result(arguments[0], arguments[1]) : result;
6284 }
6285
6286 /**
6287 * Gets the data for `map`.
6288 *
6289 * @private
6290 * @param {Object} map The map to query.
6291 * @param {string} key The reference key.
6292 * @returns {*} Returns the map data.
6293 */
6294 function getMapData(map, key) {
6295 var data = map.__data__;
6296 return isKeyable(key)
6297 ? data[typeof key == 'string' ? 'string' : 'hash']
6298 : data.map;
6299 }
6300
6301 /**
6302 * Gets the property names, values, and compare flags of `object`.
6303 *
6304 * @private
6305 * @param {Object} object The object to query.
6306 * @returns {Array} Returns the match data of `object`.
6307 */
6308 function getMatchData(object) {
6309 var result = keys(object),
6310 length = result.length;
6311
6312 while (length--) {
6313 var key = result[length],
6314 value = object[key];
6315
6316 result[length] = [key, value, isStrictComparable(value)];
6317 }
6318 return result;
6319 }
6320
6321 /**
6322 * Gets the native function at `key` of `object`.
6323 *
6324 * @private
6325 * @param {Object} object The object to query.
6326 * @param {string} key The key of the method to get.
6327 * @returns {*} Returns the function if it's native, else `undefined`.
6328 */
6329 function getNative(object, key) {
6330 var value = getValue(object, key);
6331 return baseIsNative(value) ? value : undefined$1;
6332 }
6333
6334 /**
6335 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
6336 *
6337 * @private
6338 * @param {*} value The value to query.
6339 * @returns {string} Returns the raw `toStringTag`.
6340 */
6341 function getRawTag(value) {
6342 var isOwn = hasOwnProperty.call(value, symToStringTag),
6343 tag = value[symToStringTag];
6344
6345 try {
6346 value[symToStringTag] = undefined$1;
6347 var unmasked = true;
6348 } catch (e) {}
6349
6350 var result = nativeObjectToString.call(value);
6351 if (unmasked) {
6352 if (isOwn) {
6353 value[symToStringTag] = tag;
6354 } else {
6355 delete value[symToStringTag];
6356 }
6357 }
6358 return result;
6359 }
6360
6361 /**
6362 * Creates an array of the own enumerable symbols of `object`.
6363 *
6364 * @private
6365 * @param {Object} object The object to query.
6366 * @returns {Array} Returns the array of symbols.
6367 */
6368 var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
6369 if (object == null) {
6370 return [];
6371 }
6372 object = Object(object);
6373 return arrayFilter(nativeGetSymbols(object), function(symbol) {
6374 return propertyIsEnumerable.call(object, symbol);
6375 });
6376 };
6377
6378 /**
6379 * Creates an array of the own and inherited enumerable symbols of `object`.
6380 *
6381 * @private
6382 * @param {Object} object The object to query.
6383 * @returns {Array} Returns the array of symbols.
6384 */
6385 var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
6386 var result = [];
6387 while (object) {
6388 arrayPush(result, getSymbols(object));
6389 object = getPrototype(object);
6390 }
6391 return result;
6392 };
6393
6394 /**
6395 * Gets the `toStringTag` of `value`.
6396 *
6397 * @private
6398 * @param {*} value The value to query.
6399 * @returns {string} Returns the `toStringTag`.
6400 */
6401 var getTag = baseGetTag;
6402
6403 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
6404 if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
6405 (Map && getTag(new Map) != mapTag) ||
6406 (Promise && getTag(Promise.resolve()) != promiseTag) ||
6407 (Set && getTag(new Set) != setTag) ||
6408 (WeakMap && getTag(new WeakMap) != weakMapTag)) {
6409 getTag = function(value) {
6410 var result = baseGetTag(value),
6411 Ctor = result == objectTag ? value.constructor : undefined$1,
6412 ctorString = Ctor ? toSource(Ctor) : '';
6413
6414 if (ctorString) {
6415 switch (ctorString) {
6416 case dataViewCtorString: return dataViewTag;
6417 case mapCtorString: return mapTag;
6418 case promiseCtorString: return promiseTag;
6419 case setCtorString: return setTag;
6420 case weakMapCtorString: return weakMapTag;
6421 }
6422 }
6423 return result;
6424 };
6425 }
6426
6427 /**
6428 * Gets the view, applying any `transforms` to the `start` and `end` positions.
6429 *
6430 * @private
6431 * @param {number} start The start of the view.
6432 * @param {number} end The end of the view.
6433 * @param {Array} transforms The transformations to apply to the view.
6434 * @returns {Object} Returns an object containing the `start` and `end`
6435 * positions of the view.
6436 */
6437 function getView(start, end, transforms) {
6438 var index = -1,
6439 length = transforms.length;
6440
6441 while (++index < length) {
6442 var data = transforms[index],
6443 size = data.size;
6444
6445 switch (data.type) {
6446 case 'drop': start += size; break;
6447 case 'dropRight': end -= size; break;
6448 case 'take': end = nativeMin(end, start + size); break;
6449 case 'takeRight': start = nativeMax(start, end - size); break;
6450 }
6451 }
6452 return { 'start': start, 'end': end };
6453 }
6454
6455 /**
6456 * Extracts wrapper details from the `source` body comment.
6457 *
6458 * @private
6459 * @param {string} source The source to inspect.
6460 * @returns {Array} Returns the wrapper details.
6461 */
6462 function getWrapDetails(source) {
6463 var match = source.match(reWrapDetails);
6464 return match ? match[1].split(reSplitDetails) : [];
6465 }
6466
6467 /**
6468 * Checks if `path` exists on `object`.
6469 *
6470 * @private
6471 * @param {Object} object The object to query.
6472 * @param {Array|string} path The path to check.
6473 * @param {Function} hasFunc The function to check properties.
6474 * @returns {boolean} Returns `true` if `path` exists, else `false`.
6475 */
6476 function hasPath(object, path, hasFunc) {
6477 path = castPath(path, object);
6478
6479 var index = -1,
6480 length = path.length,
6481 result = false;
6482
6483 while (++index < length) {
6484 var key = toKey(path[index]);
6485 if (!(result = object != null && hasFunc(object, key))) {
6486 break;
6487 }
6488 object = object[key];
6489 }
6490 if (result || ++index != length) {
6491 return result;
6492 }
6493 length = object == null ? 0 : object.length;
6494 return !!length && isLength(length) && isIndex(key, length) &&
6495 (isArray(object) || isArguments(object));
6496 }
6497
6498 /**
6499 * Initializes an array clone.
6500 *
6501 * @private
6502 * @param {Array} array The array to clone.
6503 * @returns {Array} Returns the initialized clone.
6504 */
6505 function initCloneArray(array) {
6506 var length = array.length,
6507 result = new array.constructor(length);
6508
6509 // Add properties assigned by `RegExp#exec`.
6510 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
6511 result.index = array.index;
6512 result.input = array.input;
6513 }
6514 return result;
6515 }
6516
6517 /**
6518 * Initializes an object clone.
6519 *
6520 * @private
6521 * @param {Object} object The object to clone.
6522 * @returns {Object} Returns the initialized clone.
6523 */
6524 function initCloneObject(object) {
6525 return (typeof object.constructor == 'function' && !isPrototype(object))
6526 ? baseCreate(getPrototype(object))
6527 : {};
6528 }
6529
6530 /**
6531 * Initializes an object clone based on its `toStringTag`.
6532 *
6533 * **Note:** This function only supports cloning values with tags of
6534 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
6535 *
6536 * @private
6537 * @param {Object} object The object to clone.
6538 * @param {string} tag The `toStringTag` of the object to clone.
6539 * @param {boolean} [isDeep] Specify a deep clone.
6540 * @returns {Object} Returns the initialized clone.
6541 */
6542 function initCloneByTag(object, tag, isDeep) {
6543 var Ctor = object.constructor;
6544 switch (tag) {
6545 case arrayBufferTag:
6546 return cloneArrayBuffer(object);
6547
6548 case boolTag:
6549 case dateTag:
6550 return new Ctor(+object);
6551
6552 case dataViewTag:
6553 return cloneDataView(object, isDeep);
6554
6555 case float32Tag: case float64Tag:
6556 case int8Tag: case int16Tag: case int32Tag:
6557 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
6558 return cloneTypedArray(object, isDeep);
6559
6560 case mapTag:
6561 return new Ctor;
6562
6563 case numberTag:
6564 case stringTag:
6565 return new Ctor(object);
6566
6567 case regexpTag:
6568 return cloneRegExp(object);
6569
6570 case setTag:
6571 return new Ctor;
6572
6573 case symbolTag:
6574 return cloneSymbol(object);
6575 }
6576 }
6577
6578 /**
6579 * Inserts wrapper `details` in a comment at the top of the `source` body.
6580 *
6581 * @private
6582 * @param {string} source The source to modify.
6583 * @returns {Array} details The details to insert.
6584 * @returns {string} Returns the modified source.
6585 */
6586 function insertWrapDetails(source, details) {
6587 var length = details.length;
6588 if (!length) {
6589 return source;
6590 }
6591 var lastIndex = length - 1;
6592 details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
6593 details = details.join(length > 2 ? ', ' : ' ');
6594 return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
6595 }
6596
6597 /**
6598 * Checks if `value` is a flattenable `arguments` object or array.
6599 *
6600 * @private
6601 * @param {*} value The value to check.
6602 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
6603 */
6604 function isFlattenable(value) {
6605 return isArray(value) || isArguments(value) ||
6606 !!(spreadableSymbol && value && value[spreadableSymbol]);
6607 }
6608
6609 /**
6610 * Checks if `value` is a valid array-like index.
6611 *
6612 * @private
6613 * @param {*} value The value to check.
6614 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
6615 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
6616 */
6617 function isIndex(value, length) {
6618 var type = typeof value;
6619 length = length == null ? MAX_SAFE_INTEGER : length;
6620
6621 return !!length &&
6622 (type == 'number' ||
6623 (type != 'symbol' && reIsUint.test(value))) &&
6624 (value > -1 && value % 1 == 0 && value < length);
6625 }
6626
6627 /**
6628 * Checks if the given arguments are from an iteratee call.
6629 *
6630 * @private
6631 * @param {*} value The potential iteratee value argument.
6632 * @param {*} index The potential iteratee index or key argument.
6633 * @param {*} object The potential iteratee object argument.
6634 * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
6635 * else `false`.
6636 */
6637 function isIterateeCall(value, index, object) {
6638 if (!isObject(object)) {
6639 return false;
6640 }
6641 var type = typeof index;
6642 if (type == 'number'
6643 ? (isArrayLike(object) && isIndex(index, object.length))
6644 : (type == 'string' && index in object)
6645 ) {
6646 return eq(object[index], value);
6647 }
6648 return false;
6649 }
6650
6651 /**
6652 * Checks if `value` is a property name and not a property path.
6653 *
6654 * @private
6655 * @param {*} value The value to check.
6656 * @param {Object} [object] The object to query keys on.
6657 * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
6658 */
6659 function isKey(value, object) {
6660 if (isArray(value)) {
6661 return false;
6662 }
6663 var type = typeof value;
6664 if (type == 'number' || type == 'symbol' || type == 'boolean' ||
6665 value == null || isSymbol(value)) {
6666 return true;
6667 }
6668 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
6669 (object != null && value in Object(object));
6670 }
6671
6672 /**
6673 * Checks if `value` is suitable for use as unique object key.
6674 *
6675 * @private
6676 * @param {*} value The value to check.
6677 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
6678 */
6679 function isKeyable(value) {
6680 var type = typeof value;
6681 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
6682 ? (value !== '__proto__')
6683 : (value === null);
6684 }
6685
6686 /**
6687 * Checks if `func` has a lazy counterpart.
6688 *
6689 * @private
6690 * @param {Function} func The function to check.
6691 * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
6692 * else `false`.
6693 */
6694 function isLaziable(func) {
6695 var funcName = getFuncName(func),
6696 other = lodash[funcName];
6697
6698 if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
6699 return false;
6700 }
6701 if (func === other) {
6702 return true;
6703 }
6704 var data = getData(other);
6705 return !!data && func === data[0];
6706 }
6707
6708 /**
6709 * Checks if `func` has its source masked.
6710 *
6711 * @private
6712 * @param {Function} func The function to check.
6713 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
6714 */
6715 function isMasked(func) {
6716 return !!maskSrcKey && (maskSrcKey in func);
6717 }
6718
6719 /**
6720 * Checks if `func` is capable of being masked.
6721 *
6722 * @private
6723 * @param {*} value The value to check.
6724 * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
6725 */
6726 var isMaskable = coreJsData ? isFunction : stubFalse;
6727
6728 /**
6729 * Checks if `value` is likely a prototype object.
6730 *
6731 * @private
6732 * @param {*} value The value to check.
6733 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
6734 */
6735 function isPrototype(value) {
6736 var Ctor = value && value.constructor,
6737 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
6738
6739 return value === proto;
6740 }
6741
6742 /**
6743 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
6744 *
6745 * @private
6746 * @param {*} value The value to check.
6747 * @returns {boolean} Returns `true` if `value` if suitable for strict
6748 * equality comparisons, else `false`.
6749 */
6750 function isStrictComparable(value) {
6751 return value === value && !isObject(value);
6752 }
6753
6754 /**
6755 * A specialized version of `matchesProperty` for source values suitable
6756 * for strict equality comparisons, i.e. `===`.
6757 *
6758 * @private
6759 * @param {string} key The key of the property to get.
6760 * @param {*} srcValue The value to match.
6761 * @returns {Function} Returns the new spec function.
6762 */
6763 function matchesStrictComparable(key, srcValue) {
6764 return function(object) {
6765 if (object == null) {
6766 return false;
6767 }
6768 return object[key] === srcValue &&
6769 (srcValue !== undefined$1 || (key in Object(object)));
6770 };
6771 }
6772
6773 /**
6774 * A specialized version of `_.memoize` which clears the memoized function's
6775 * cache when it exceeds `MAX_MEMOIZE_SIZE`.
6776 *
6777 * @private
6778 * @param {Function} func The function to have its output memoized.
6779 * @returns {Function} Returns the new memoized function.
6780 */
6781 function memoizeCapped(func) {
6782 var result = memoize(func, function(key) {
6783 if (cache.size === MAX_MEMOIZE_SIZE) {
6784 cache.clear();
6785 }
6786 return key;
6787 });
6788
6789 var cache = result.cache;
6790 return result;
6791 }
6792
6793 /**
6794 * Merges the function metadata of `source` into `data`.
6795 *
6796 * Merging metadata reduces the number of wrappers used to invoke a function.
6797 * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
6798 * may be applied regardless of execution order. Methods like `_.ary` and
6799 * `_.rearg` modify function arguments, making the order in which they are
6800 * executed important, preventing the merging of metadata. However, we make
6801 * an exception for a safe combined case where curried functions have `_.ary`
6802 * and or `_.rearg` applied.
6803 *
6804 * @private
6805 * @param {Array} data The destination metadata.
6806 * @param {Array} source The source metadata.
6807 * @returns {Array} Returns `data`.
6808 */
6809 function mergeData(data, source) {
6810 var bitmask = data[1],
6811 srcBitmask = source[1],
6812 newBitmask = bitmask | srcBitmask,
6813 isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
6814
6815 var isCombo =
6816 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
6817 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
6818 ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
6819
6820 // Exit early if metadata can't be merged.
6821 if (!(isCommon || isCombo)) {
6822 return data;
6823 }
6824 // Use source `thisArg` if available.
6825 if (srcBitmask & WRAP_BIND_FLAG) {
6826 data[2] = source[2];
6827 // Set when currying a bound function.
6828 newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
6829 }
6830 // Compose partial arguments.
6831 var value = source[3];
6832 if (value) {
6833 var partials = data[3];
6834 data[3] = partials ? composeArgs(partials, value, source[4]) : value;
6835 data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
6836 }
6837 // Compose partial right arguments.
6838 value = source[5];
6839 if (value) {
6840 partials = data[5];
6841 data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
6842 data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
6843 }
6844 // Use source `argPos` if available.
6845 value = source[7];
6846 if (value) {
6847 data[7] = value;
6848 }
6849 // Use source `ary` if it's smaller.
6850 if (srcBitmask & WRAP_ARY_FLAG) {
6851 data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
6852 }
6853 // Use source `arity` if one is not provided.
6854 if (data[9] == null) {
6855 data[9] = source[9];
6856 }
6857 // Use source `func` and merge bitmasks.
6858 data[0] = source[0];
6859 data[1] = newBitmask;
6860
6861 return data;
6862 }
6863
6864 /**
6865 * This function is like
6866 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
6867 * except that it includes inherited enumerable properties.
6868 *
6869 * @private
6870 * @param {Object} object The object to query.
6871 * @returns {Array} Returns the array of property names.
6872 */
6873 function nativeKeysIn(object) {
6874 var result = [];
6875 if (object != null) {
6876 for (var key in Object(object)) {
6877 result.push(key);
6878 }
6879 }
6880 return result;
6881 }
6882
6883 /**
6884 * Converts `value` to a string using `Object.prototype.toString`.
6885 *
6886 * @private
6887 * @param {*} value The value to convert.
6888 * @returns {string} Returns the converted string.
6889 */
6890 function objectToString(value) {
6891 return nativeObjectToString.call(value);
6892 }
6893
6894 /**
6895 * A specialized version of `baseRest` which transforms the rest array.
6896 *
6897 * @private
6898 * @param {Function} func The function to apply a rest parameter to.
6899 * @param {number} [start=func.length-1] The start position of the rest parameter.
6900 * @param {Function} transform The rest array transform.
6901 * @returns {Function} Returns the new function.
6902 */
6903 function overRest(func, start, transform) {
6904 start = nativeMax(start === undefined$1 ? (func.length - 1) : start, 0);
6905 return function() {
6906 var args = arguments,
6907 index = -1,
6908 length = nativeMax(args.length - start, 0),
6909 array = Array(length);
6910
6911 while (++index < length) {
6912 array[index] = args[start + index];
6913 }
6914 index = -1;
6915 var otherArgs = Array(start + 1);
6916 while (++index < start) {
6917 otherArgs[index] = args[index];
6918 }
6919 otherArgs[start] = transform(array);
6920 return apply(func, this, otherArgs);
6921 };
6922 }
6923
6924 /**
6925 * Gets the parent value at `path` of `object`.
6926 *
6927 * @private
6928 * @param {Object} object The object to query.
6929 * @param {Array} path The path to get the parent value of.
6930 * @returns {*} Returns the parent value.
6931 */
6932 function parent(object, path) {
6933 return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
6934 }
6935
6936 /**
6937 * Reorder `array` according to the specified indexes where the element at
6938 * the first index is assigned as the first element, the element at
6939 * the second index is assigned as the second element, and so on.
6940 *
6941 * @private
6942 * @param {Array} array The array to reorder.
6943 * @param {Array} indexes The arranged array indexes.
6944 * @returns {Array} Returns `array`.
6945 */
6946 function reorder(array, indexes) {
6947 var arrLength = array.length,
6948 length = nativeMin(indexes.length, arrLength),
6949 oldArray = copyArray(array);
6950
6951 while (length--) {
6952 var index = indexes[length];
6953 array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined$1;
6954 }
6955 return array;
6956 }
6957
6958 /**
6959 * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
6960 *
6961 * @private
6962 * @param {Object} object The object to query.
6963 * @param {string} key The key of the property to get.
6964 * @returns {*} Returns the property value.
6965 */
6966 function safeGet(object, key) {
6967 if (key === 'constructor' && typeof object[key] === 'function') {
6968 return;
6969 }
6970
6971 if (key == '__proto__') {
6972 return;
6973 }
6974
6975 return object[key];
6976 }
6977
6978 /**
6979 * Sets metadata for `func`.
6980 *
6981 * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
6982 * period of time, it will trip its breaker and transition to an identity
6983 * function to avoid garbage collection pauses in V8. See
6984 * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
6985 * for more details.
6986 *
6987 * @private
6988 * @param {Function} func The function to associate metadata with.
6989 * @param {*} data The metadata.
6990 * @returns {Function} Returns `func`.
6991 */
6992 var setData = shortOut(baseSetData);
6993
6994 /**
6995 * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
6996 *
6997 * @private
6998 * @param {Function} func The function to delay.
6999 * @param {number} wait The number of milliseconds to delay invocation.
7000 * @returns {number|Object} Returns the timer id or timeout object.
7001 */
7002 var setTimeout = ctxSetTimeout || function(func, wait) {
7003 return root.setTimeout(func, wait);
7004 };
7005
7006 /**
7007 * Sets the `toString` method of `func` to return `string`.
7008 *
7009 * @private
7010 * @param {Function} func The function to modify.
7011 * @param {Function} string The `toString` result.
7012 * @returns {Function} Returns `func`.
7013 */
7014 var setToString = shortOut(baseSetToString);
7015
7016 /**
7017 * Sets the `toString` method of `wrapper` to mimic the source of `reference`
7018 * with wrapper details in a comment at the top of the source body.
7019 *
7020 * @private
7021 * @param {Function} wrapper The function to modify.
7022 * @param {Function} reference The reference function.
7023 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
7024 * @returns {Function} Returns `wrapper`.
7025 */
7026 function setWrapToString(wrapper, reference, bitmask) {
7027 var source = (reference + '');
7028 return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
7029 }
7030
7031 /**
7032 * Creates a function that'll short out and invoke `identity` instead
7033 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
7034 * milliseconds.
7035 *
7036 * @private
7037 * @param {Function} func The function to restrict.
7038 * @returns {Function} Returns the new shortable function.
7039 */
7040 function shortOut(func) {
7041 var count = 0,
7042 lastCalled = 0;
7043
7044 return function() {
7045 var stamp = nativeNow(),
7046 remaining = HOT_SPAN - (stamp - lastCalled);
7047
7048 lastCalled = stamp;
7049 if (remaining > 0) {
7050 if (++count >= HOT_COUNT) {
7051 return arguments[0];
7052 }
7053 } else {
7054 count = 0;
7055 }
7056 return func.apply(undefined$1, arguments);
7057 };
7058 }
7059
7060 /**
7061 * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
7062 *
7063 * @private
7064 * @param {Array} array The array to shuffle.
7065 * @param {number} [size=array.length] The size of `array`.
7066 * @returns {Array} Returns `array`.
7067 */
7068 function shuffleSelf(array, size) {
7069 var index = -1,
7070 length = array.length,
7071 lastIndex = length - 1;
7072
7073 size = size === undefined$1 ? length : size;
7074 while (++index < size) {
7075 var rand = baseRandom(index, lastIndex),
7076 value = array[rand];
7077
7078 array[rand] = array[index];
7079 array[index] = value;
7080 }
7081 array.length = size;
7082 return array;
7083 }
7084
7085 /**
7086 * Converts `string` to a property path array.
7087 *
7088 * @private
7089 * @param {string} string The string to convert.
7090 * @returns {Array} Returns the property path array.
7091 */
7092 var stringToPath = memoizeCapped(function(string) {
7093 var result = [];
7094 if (string.charCodeAt(0) === 46 /* . */) {
7095 result.push('');
7096 }
7097 string.replace(rePropName, function(match, number, quote, subString) {
7098 result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
7099 });
7100 return result;
7101 });
7102
7103 /**
7104 * Converts `value` to a string key if it's not a string or symbol.
7105 *
7106 * @private
7107 * @param {*} value The value to inspect.
7108 * @returns {string|symbol} Returns the key.
7109 */
7110 function toKey(value) {
7111 if (typeof value == 'string' || isSymbol(value)) {
7112 return value;
7113 }
7114 var result = (value + '');
7115 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
7116 }
7117
7118 /**
7119 * Converts `func` to its source code.
7120 *
7121 * @private
7122 * @param {Function} func The function to convert.
7123 * @returns {string} Returns the source code.
7124 */
7125 function toSource(func) {
7126 if (func != null) {
7127 try {
7128 return funcToString.call(func);
7129 } catch (e) {}
7130 try {
7131 return (func + '');
7132 } catch (e) {}
7133 }
7134 return '';
7135 }
7136
7137 /**
7138 * Updates wrapper `details` based on `bitmask` flags.
7139 *
7140 * @private
7141 * @returns {Array} details The details to modify.
7142 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
7143 * @returns {Array} Returns `details`.
7144 */
7145 function updateWrapDetails(details, bitmask) {
7146 arrayEach(wrapFlags, function(pair) {
7147 var value = '_.' + pair[0];
7148 if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
7149 details.push(value);
7150 }
7151 });
7152 return details.sort();
7153 }
7154
7155 /**
7156 * Creates a clone of `wrapper`.
7157 *
7158 * @private
7159 * @param {Object} wrapper The wrapper to clone.
7160 * @returns {Object} Returns the cloned wrapper.
7161 */
7162 function wrapperClone(wrapper) {
7163 if (wrapper instanceof LazyWrapper) {
7164 return wrapper.clone();
7165 }
7166 var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
7167 result.__actions__ = copyArray(wrapper.__actions__);
7168 result.__index__ = wrapper.__index__;
7169 result.__values__ = wrapper.__values__;
7170 return result;
7171 }
7172
7173 /*------------------------------------------------------------------------*/
7174
7175 /**
7176 * Creates an array of elements split into groups the length of `size`.
7177 * If `array` can't be split evenly, the final chunk will be the remaining
7178 * elements.
7179 *
7180 * @static
7181 * @memberOf _
7182 * @since 3.0.0
7183 * @category Array
7184 * @param {Array} array The array to process.
7185 * @param {number} [size=1] The length of each chunk
7186 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
7187 * @returns {Array} Returns the new array of chunks.
7188 * @example
7189 *
7190 * _.chunk(['a', 'b', 'c', 'd'], 2);
7191 * // => [['a', 'b'], ['c', 'd']]
7192 *
7193 * _.chunk(['a', 'b', 'c', 'd'], 3);
7194 * // => [['a', 'b', 'c'], ['d']]
7195 */
7196 function chunk(array, size, guard) {
7197 if ((guard ? isIterateeCall(array, size, guard) : size === undefined$1)) {
7198 size = 1;
7199 } else {
7200 size = nativeMax(toInteger(size), 0);
7201 }
7202 var length = array == null ? 0 : array.length;
7203 if (!length || size < 1) {
7204 return [];
7205 }
7206 var index = 0,
7207 resIndex = 0,
7208 result = Array(nativeCeil(length / size));
7209
7210 while (index < length) {
7211 result[resIndex++] = baseSlice(array, index, (index += size));
7212 }
7213 return result;
7214 }
7215
7216 /**
7217 * Creates an array with all falsey values removed. The values `false`, `null`,
7218 * `0`, `""`, `undefined`, and `NaN` are falsey.
7219 *
7220 * @static
7221 * @memberOf _
7222 * @since 0.1.0
7223 * @category Array
7224 * @param {Array} array The array to compact.
7225 * @returns {Array} Returns the new array of filtered values.
7226 * @example
7227 *
7228 * _.compact([0, 1, false, 2, '', 3]);
7229 * // => [1, 2, 3]
7230 */
7231 function compact(array) {
7232 var index = -1,
7233 length = array == null ? 0 : array.length,
7234 resIndex = 0,
7235 result = [];
7236
7237 while (++index < length) {
7238 var value = array[index];
7239 if (value) {
7240 result[resIndex++] = value;
7241 }
7242 }
7243 return result;
7244 }
7245
7246 /**
7247 * Creates a new array concatenating `array` with any additional arrays
7248 * and/or values.
7249 *
7250 * @static
7251 * @memberOf _
7252 * @since 4.0.0
7253 * @category Array
7254 * @param {Array} array The array to concatenate.
7255 * @param {...*} [values] The values to concatenate.
7256 * @returns {Array} Returns the new concatenated array.
7257 * @example
7258 *
7259 * var array = [1];
7260 * var other = _.concat(array, 2, [3], [[4]]);
7261 *
7262 * console.log(other);
7263 * // => [1, 2, 3, [4]]
7264 *
7265 * console.log(array);
7266 * // => [1]
7267 */
7268 function concat() {
7269 var length = arguments.length;
7270 if (!length) {
7271 return [];
7272 }
7273 var args = Array(length - 1),
7274 array = arguments[0],
7275 index = length;
7276
7277 while (index--) {
7278 args[index - 1] = arguments[index];
7279 }
7280 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
7281 }
7282
7283 /**
7284 * Creates an array of `array` values not included in the other given arrays
7285 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7286 * for equality comparisons. The order and references of result values are
7287 * determined by the first array.
7288 *
7289 * **Note:** Unlike `_.pullAll`, this method returns a new array.
7290 *
7291 * @static
7292 * @memberOf _
7293 * @since 0.1.0
7294 * @category Array
7295 * @param {Array} array The array to inspect.
7296 * @param {...Array} [values] The values to exclude.
7297 * @returns {Array} Returns the new array of filtered values.
7298 * @see _.without, _.xor
7299 * @example
7300 *
7301 * _.difference([2, 1], [2, 3]);
7302 * // => [1]
7303 */
7304 var difference = baseRest(function(array, values) {
7305 return isArrayLikeObject(array)
7306 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
7307 : [];
7308 });
7309
7310 /**
7311 * This method is like `_.difference` except that it accepts `iteratee` which
7312 * is invoked for each element of `array` and `values` to generate the criterion
7313 * by which they're compared. The order and references of result values are
7314 * determined by the first array. The iteratee is invoked with one argument:
7315 * (value).
7316 *
7317 * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
7318 *
7319 * @static
7320 * @memberOf _
7321 * @since 4.0.0
7322 * @category Array
7323 * @param {Array} array The array to inspect.
7324 * @param {...Array} [values] The values to exclude.
7325 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7326 * @returns {Array} Returns the new array of filtered values.
7327 * @example
7328 *
7329 * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
7330 * // => [1.2]
7331 *
7332 * // The `_.property` iteratee shorthand.
7333 * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
7334 * // => [{ 'x': 2 }]
7335 */
7336 var differenceBy = baseRest(function(array, values) {
7337 var iteratee = last(values);
7338 if (isArrayLikeObject(iteratee)) {
7339 iteratee = undefined$1;
7340 }
7341 return isArrayLikeObject(array)
7342 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
7343 : [];
7344 });
7345
7346 /**
7347 * This method is like `_.difference` except that it accepts `comparator`
7348 * which is invoked to compare elements of `array` to `values`. The order and
7349 * references of result values are determined by the first array. The comparator
7350 * is invoked with two arguments: (arrVal, othVal).
7351 *
7352 * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
7353 *
7354 * @static
7355 * @memberOf _
7356 * @since 4.0.0
7357 * @category Array
7358 * @param {Array} array The array to inspect.
7359 * @param {...Array} [values] The values to exclude.
7360 * @param {Function} [comparator] The comparator invoked per element.
7361 * @returns {Array} Returns the new array of filtered values.
7362 * @example
7363 *
7364 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
7365 *
7366 * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
7367 * // => [{ 'x': 2, 'y': 1 }]
7368 */
7369 var differenceWith = baseRest(function(array, values) {
7370 var comparator = last(values);
7371 if (isArrayLikeObject(comparator)) {
7372 comparator = undefined$1;
7373 }
7374 return isArrayLikeObject(array)
7375 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined$1, comparator)
7376 : [];
7377 });
7378
7379 /**
7380 * Creates a slice of `array` with `n` elements dropped from the beginning.
7381 *
7382 * @static
7383 * @memberOf _
7384 * @since 0.5.0
7385 * @category Array
7386 * @param {Array} array The array to query.
7387 * @param {number} [n=1] The number of elements to drop.
7388 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
7389 * @returns {Array} Returns the slice of `array`.
7390 * @example
7391 *
7392 * _.drop([1, 2, 3]);
7393 * // => [2, 3]
7394 *
7395 * _.drop([1, 2, 3], 2);
7396 * // => [3]
7397 *
7398 * _.drop([1, 2, 3], 5);
7399 * // => []
7400 *
7401 * _.drop([1, 2, 3], 0);
7402 * // => [1, 2, 3]
7403 */
7404 function drop(array, n, guard) {
7405 var length = array == null ? 0 : array.length;
7406 if (!length) {
7407 return [];
7408 }
7409 n = (guard || n === undefined$1) ? 1 : toInteger(n);
7410 return baseSlice(array, n < 0 ? 0 : n, length);
7411 }
7412
7413 /**
7414 * Creates a slice of `array` with `n` elements dropped from the end.
7415 *
7416 * @static
7417 * @memberOf _
7418 * @since 3.0.0
7419 * @category Array
7420 * @param {Array} array The array to query.
7421 * @param {number} [n=1] The number of elements to drop.
7422 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
7423 * @returns {Array} Returns the slice of `array`.
7424 * @example
7425 *
7426 * _.dropRight([1, 2, 3]);
7427 * // => [1, 2]
7428 *
7429 * _.dropRight([1, 2, 3], 2);
7430 * // => [1]
7431 *
7432 * _.dropRight([1, 2, 3], 5);
7433 * // => []
7434 *
7435 * _.dropRight([1, 2, 3], 0);
7436 * // => [1, 2, 3]
7437 */
7438 function dropRight(array, n, guard) {
7439 var length = array == null ? 0 : array.length;
7440 if (!length) {
7441 return [];
7442 }
7443 n = (guard || n === undefined$1) ? 1 : toInteger(n);
7444 n = length - n;
7445 return baseSlice(array, 0, n < 0 ? 0 : n);
7446 }
7447
7448 /**
7449 * Creates a slice of `array` excluding elements dropped from the end.
7450 * Elements are dropped until `predicate` returns falsey. The predicate is
7451 * invoked with three arguments: (value, index, array).
7452 *
7453 * @static
7454 * @memberOf _
7455 * @since 3.0.0
7456 * @category Array
7457 * @param {Array} array The array to query.
7458 * @param {Function} [predicate=_.identity] The function invoked per iteration.
7459 * @returns {Array} Returns the slice of `array`.
7460 * @example
7461 *
7462 * var users = [
7463 * { 'user': 'barney', 'active': true },
7464 * { 'user': 'fred', 'active': false },
7465 * { 'user': 'pebbles', 'active': false }
7466 * ];
7467 *
7468 * _.dropRightWhile(users, function(o) { return !o.active; });
7469 * // => objects for ['barney']
7470 *
7471 * // The `_.matches` iteratee shorthand.
7472 * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
7473 * // => objects for ['barney', 'fred']
7474 *
7475 * // The `_.matchesProperty` iteratee shorthand.
7476 * _.dropRightWhile(users, ['active', false]);
7477 * // => objects for ['barney']
7478 *
7479 * // The `_.property` iteratee shorthand.
7480 * _.dropRightWhile(users, 'active');
7481 * // => objects for ['barney', 'fred', 'pebbles']
7482 */
7483 function dropRightWhile(array, predicate) {
7484 return (array && array.length)
7485 ? baseWhile(array, getIteratee(predicate, 3), true, true)
7486 : [];
7487 }
7488
7489 /**
7490 * Creates a slice of `array` excluding elements dropped from the beginning.
7491 * Elements are dropped until `predicate` returns falsey. The predicate is
7492 * invoked with three arguments: (value, index, array).
7493 *
7494 * @static
7495 * @memberOf _
7496 * @since 3.0.0
7497 * @category Array
7498 * @param {Array} array The array to query.
7499 * @param {Function} [predicate=_.identity] The function invoked per iteration.
7500 * @returns {Array} Returns the slice of `array`.
7501 * @example
7502 *
7503 * var users = [
7504 * { 'user': 'barney', 'active': false },
7505 * { 'user': 'fred', 'active': false },
7506 * { 'user': 'pebbles', 'active': true }
7507 * ];
7508 *
7509 * _.dropWhile(users, function(o) { return !o.active; });
7510 * // => objects for ['pebbles']
7511 *
7512 * // The `_.matches` iteratee shorthand.
7513 * _.dropWhile(users, { 'user': 'barney', 'active': false });
7514 * // => objects for ['fred', 'pebbles']
7515 *
7516 * // The `_.matchesProperty` iteratee shorthand.
7517 * _.dropWhile(users, ['active', false]);
7518 * // => objects for ['pebbles']
7519 *
7520 * // The `_.property` iteratee shorthand.
7521 * _.dropWhile(users, 'active');
7522 * // => objects for ['barney', 'fred', 'pebbles']
7523 */
7524 function dropWhile(array, predicate) {
7525 return (array && array.length)
7526 ? baseWhile(array, getIteratee(predicate, 3), true)
7527 : [];
7528 }
7529
7530 /**
7531 * Fills elements of `array` with `value` from `start` up to, but not
7532 * including, `end`.
7533 *
7534 * **Note:** This method mutates `array`.
7535 *
7536 * @static
7537 * @memberOf _
7538 * @since 3.2.0
7539 * @category Array
7540 * @param {Array} array The array to fill.
7541 * @param {*} value The value to fill `array` with.
7542 * @param {number} [start=0] The start position.
7543 * @param {number} [end=array.length] The end position.
7544 * @returns {Array} Returns `array`.
7545 * @example
7546 *
7547 * var array = [1, 2, 3];
7548 *
7549 * _.fill(array, 'a');
7550 * console.log(array);
7551 * // => ['a', 'a', 'a']
7552 *
7553 * _.fill(Array(3), 2);
7554 * // => [2, 2, 2]
7555 *
7556 * _.fill([4, 6, 8, 10], '*', 1, 3);
7557 * // => [4, '*', '*', 10]
7558 */
7559 function fill(array, value, start, end) {
7560 var length = array == null ? 0 : array.length;
7561 if (!length) {
7562 return [];
7563 }
7564 if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
7565 start = 0;
7566 end = length;
7567 }
7568 return baseFill(array, value, start, end);
7569 }
7570
7571 /**
7572 * This method is like `_.find` except that it returns the index of the first
7573 * element `predicate` returns truthy for instead of the element itself.
7574 *
7575 * @static
7576 * @memberOf _
7577 * @since 1.1.0
7578 * @category Array
7579 * @param {Array} array The array to inspect.
7580 * @param {Function} [predicate=_.identity] The function invoked per iteration.
7581 * @param {number} [fromIndex=0] The index to search from.
7582 * @returns {number} Returns the index of the found element, else `-1`.
7583 * @example
7584 *
7585 * var users = [
7586 * { 'user': 'barney', 'active': false },
7587 * { 'user': 'fred', 'active': false },
7588 * { 'user': 'pebbles', 'active': true }
7589 * ];
7590 *
7591 * _.findIndex(users, function(o) { return o.user == 'barney'; });
7592 * // => 0
7593 *
7594 * // The `_.matches` iteratee shorthand.
7595 * _.findIndex(users, { 'user': 'fred', 'active': false });
7596 * // => 1
7597 *
7598 * // The `_.matchesProperty` iteratee shorthand.
7599 * _.findIndex(users, ['active', false]);
7600 * // => 0
7601 *
7602 * // The `_.property` iteratee shorthand.
7603 * _.findIndex(users, 'active');
7604 * // => 2
7605 */
7606 function findIndex(array, predicate, fromIndex) {
7607 var length = array == null ? 0 : array.length;
7608 if (!length) {
7609 return -1;
7610 }
7611 var index = fromIndex == null ? 0 : toInteger(fromIndex);
7612 if (index < 0) {
7613 index = nativeMax(length + index, 0);
7614 }
7615 return baseFindIndex(array, getIteratee(predicate, 3), index);
7616 }
7617
7618 /**
7619 * This method is like `_.findIndex` except that it iterates over elements
7620 * of `collection` from right to left.
7621 *
7622 * @static
7623 * @memberOf _
7624 * @since 2.0.0
7625 * @category Array
7626 * @param {Array} array The array to inspect.
7627 * @param {Function} [predicate=_.identity] The function invoked per iteration.
7628 * @param {number} [fromIndex=array.length-1] The index to search from.
7629 * @returns {number} Returns the index of the found element, else `-1`.
7630 * @example
7631 *
7632 * var users = [
7633 * { 'user': 'barney', 'active': true },
7634 * { 'user': 'fred', 'active': false },
7635 * { 'user': 'pebbles', 'active': false }
7636 * ];
7637 *
7638 * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
7639 * // => 2
7640 *
7641 * // The `_.matches` iteratee shorthand.
7642 * _.findLastIndex(users, { 'user': 'barney', 'active': true });
7643 * // => 0
7644 *
7645 * // The `_.matchesProperty` iteratee shorthand.
7646 * _.findLastIndex(users, ['active', false]);
7647 * // => 2
7648 *
7649 * // The `_.property` iteratee shorthand.
7650 * _.findLastIndex(users, 'active');
7651 * // => 0
7652 */
7653 function findLastIndex(array, predicate, fromIndex) {
7654 var length = array == null ? 0 : array.length;
7655 if (!length) {
7656 return -1;
7657 }
7658 var index = length - 1;
7659 if (fromIndex !== undefined$1) {
7660 index = toInteger(fromIndex);
7661 index = fromIndex < 0
7662 ? nativeMax(length + index, 0)
7663 : nativeMin(index, length - 1);
7664 }
7665 return baseFindIndex(array, getIteratee(predicate, 3), index, true);
7666 }
7667
7668 /**
7669 * Flattens `array` a single level deep.
7670 *
7671 * @static
7672 * @memberOf _
7673 * @since 0.1.0
7674 * @category Array
7675 * @param {Array} array The array to flatten.
7676 * @returns {Array} Returns the new flattened array.
7677 * @example
7678 *
7679 * _.flatten([1, [2, [3, [4]], 5]]);
7680 * // => [1, 2, [3, [4]], 5]
7681 */
7682 function flatten(array) {
7683 var length = array == null ? 0 : array.length;
7684 return length ? baseFlatten(array, 1) : [];
7685 }
7686
7687 /**
7688 * Recursively flattens `array`.
7689 *
7690 * @static
7691 * @memberOf _
7692 * @since 3.0.0
7693 * @category Array
7694 * @param {Array} array The array to flatten.
7695 * @returns {Array} Returns the new flattened array.
7696 * @example
7697 *
7698 * _.flattenDeep([1, [2, [3, [4]], 5]]);
7699 * // => [1, 2, 3, 4, 5]
7700 */
7701 function flattenDeep(array) {
7702 var length = array == null ? 0 : array.length;
7703 return length ? baseFlatten(array, INFINITY) : [];
7704 }
7705
7706 /**
7707 * Recursively flatten `array` up to `depth` times.
7708 *
7709 * @static
7710 * @memberOf _
7711 * @since 4.4.0
7712 * @category Array
7713 * @param {Array} array The array to flatten.
7714 * @param {number} [depth=1] The maximum recursion depth.
7715 * @returns {Array} Returns the new flattened array.
7716 * @example
7717 *
7718 * var array = [1, [2, [3, [4]], 5]];
7719 *
7720 * _.flattenDepth(array, 1);
7721 * // => [1, 2, [3, [4]], 5]
7722 *
7723 * _.flattenDepth(array, 2);
7724 * // => [1, 2, 3, [4], 5]
7725 */
7726 function flattenDepth(array, depth) {
7727 var length = array == null ? 0 : array.length;
7728 if (!length) {
7729 return [];
7730 }
7731 depth = depth === undefined$1 ? 1 : toInteger(depth);
7732 return baseFlatten(array, depth);
7733 }
7734
7735 /**
7736 * The inverse of `_.toPairs`; this method returns an object composed
7737 * from key-value `pairs`.
7738 *
7739 * @static
7740 * @memberOf _
7741 * @since 4.0.0
7742 * @category Array
7743 * @param {Array} pairs The key-value pairs.
7744 * @returns {Object} Returns the new object.
7745 * @example
7746 *
7747 * _.fromPairs([['a', 1], ['b', 2]]);
7748 * // => { 'a': 1, 'b': 2 }
7749 */
7750 function fromPairs(pairs) {
7751 var index = -1,
7752 length = pairs == null ? 0 : pairs.length,
7753 result = {};
7754
7755 while (++index < length) {
7756 var pair = pairs[index];
7757 result[pair[0]] = pair[1];
7758 }
7759 return result;
7760 }
7761
7762 /**
7763 * Gets the first element of `array`.
7764 *
7765 * @static
7766 * @memberOf _
7767 * @since 0.1.0
7768 * @alias first
7769 * @category Array
7770 * @param {Array} array The array to query.
7771 * @returns {*} Returns the first element of `array`.
7772 * @example
7773 *
7774 * _.head([1, 2, 3]);
7775 * // => 1
7776 *
7777 * _.head([]);
7778 * // => undefined
7779 */
7780 function head(array) {
7781 return (array && array.length) ? array[0] : undefined$1;
7782 }
7783
7784 /**
7785 * Gets the index at which the first occurrence of `value` is found in `array`
7786 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7787 * for equality comparisons. If `fromIndex` is negative, it's used as the
7788 * offset from the end of `array`.
7789 *
7790 * @static
7791 * @memberOf _
7792 * @since 0.1.0
7793 * @category Array
7794 * @param {Array} array The array to inspect.
7795 * @param {*} value The value to search for.
7796 * @param {number} [fromIndex=0] The index to search from.
7797 * @returns {number} Returns the index of the matched value, else `-1`.
7798 * @example
7799 *
7800 * _.indexOf([1, 2, 1, 2], 2);
7801 * // => 1
7802 *
7803 * // Search from the `fromIndex`.
7804 * _.indexOf([1, 2, 1, 2], 2, 2);
7805 * // => 3
7806 */
7807 function indexOf(array, value, fromIndex) {
7808 var length = array == null ? 0 : array.length;
7809 if (!length) {
7810 return -1;
7811 }
7812 var index = fromIndex == null ? 0 : toInteger(fromIndex);
7813 if (index < 0) {
7814 index = nativeMax(length + index, 0);
7815 }
7816 return baseIndexOf(array, value, index);
7817 }
7818
7819 /**
7820 * Gets all but the last element of `array`.
7821 *
7822 * @static
7823 * @memberOf _
7824 * @since 0.1.0
7825 * @category Array
7826 * @param {Array} array The array to query.
7827 * @returns {Array} Returns the slice of `array`.
7828 * @example
7829 *
7830 * _.initial([1, 2, 3]);
7831 * // => [1, 2]
7832 */
7833 function initial(array) {
7834 var length = array == null ? 0 : array.length;
7835 return length ? baseSlice(array, 0, -1) : [];
7836 }
7837
7838 /**
7839 * Creates an array of unique values that are included in all given arrays
7840 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7841 * for equality comparisons. The order and references of result values are
7842 * determined by the first array.
7843 *
7844 * @static
7845 * @memberOf _
7846 * @since 0.1.0
7847 * @category Array
7848 * @param {...Array} [arrays] The arrays to inspect.
7849 * @returns {Array} Returns the new array of intersecting values.
7850 * @example
7851 *
7852 * _.intersection([2, 1], [2, 3]);
7853 * // => [2]
7854 */
7855 var intersection = baseRest(function(arrays) {
7856 var mapped = arrayMap(arrays, castArrayLikeObject);
7857 return (mapped.length && mapped[0] === arrays[0])
7858 ? baseIntersection(mapped)
7859 : [];
7860 });
7861
7862 /**
7863 * This method is like `_.intersection` except that it accepts `iteratee`
7864 * which is invoked for each element of each `arrays` to generate the criterion
7865 * by which they're compared. The order and references of result values are
7866 * determined by the first array. The iteratee is invoked with one argument:
7867 * (value).
7868 *
7869 * @static
7870 * @memberOf _
7871 * @since 4.0.0
7872 * @category Array
7873 * @param {...Array} [arrays] The arrays to inspect.
7874 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7875 * @returns {Array} Returns the new array of intersecting values.
7876 * @example
7877 *
7878 * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
7879 * // => [2.1]
7880 *
7881 * // The `_.property` iteratee shorthand.
7882 * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
7883 * // => [{ 'x': 1 }]
7884 */
7885 var intersectionBy = baseRest(function(arrays) {
7886 var iteratee = last(arrays),
7887 mapped = arrayMap(arrays, castArrayLikeObject);
7888
7889 if (iteratee === last(mapped)) {
7890 iteratee = undefined$1;
7891 } else {
7892 mapped.pop();
7893 }
7894 return (mapped.length && mapped[0] === arrays[0])
7895 ? baseIntersection(mapped, getIteratee(iteratee, 2))
7896 : [];
7897 });
7898
7899 /**
7900 * This method is like `_.intersection` except that it accepts `comparator`
7901 * which is invoked to compare elements of `arrays`. The order and references
7902 * of result values are determined by the first array. The comparator is
7903 * invoked with two arguments: (arrVal, othVal).
7904 *
7905 * @static
7906 * @memberOf _
7907 * @since 4.0.0
7908 * @category Array
7909 * @param {...Array} [arrays] The arrays to inspect.
7910 * @param {Function} [comparator] The comparator invoked per element.
7911 * @returns {Array} Returns the new array of intersecting values.
7912 * @example
7913 *
7914 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
7915 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
7916 *
7917 * _.intersectionWith(objects, others, _.isEqual);
7918 * // => [{ 'x': 1, 'y': 2 }]
7919 */
7920 var intersectionWith = baseRest(function(arrays) {
7921 var comparator = last(arrays),
7922 mapped = arrayMap(arrays, castArrayLikeObject);
7923
7924 comparator = typeof comparator == 'function' ? comparator : undefined$1;
7925 if (comparator) {
7926 mapped.pop();
7927 }
7928 return (mapped.length && mapped[0] === arrays[0])
7929 ? baseIntersection(mapped, undefined$1, comparator)
7930 : [];
7931 });
7932
7933 /**
7934 * Converts all elements in `array` into a string separated by `separator`.
7935 *
7936 * @static
7937 * @memberOf _
7938 * @since 4.0.0
7939 * @category Array
7940 * @param {Array} array The array to convert.
7941 * @param {string} [separator=','] The element separator.
7942 * @returns {string} Returns the joined string.
7943 * @example
7944 *
7945 * _.join(['a', 'b', 'c'], '~');
7946 * // => 'a~b~c'
7947 */
7948 function join(array, separator) {
7949 return array == null ? '' : nativeJoin.call(array, separator);
7950 }
7951
7952 /**
7953 * Gets the last element of `array`.
7954 *
7955 * @static
7956 * @memberOf _
7957 * @since 0.1.0
7958 * @category Array
7959 * @param {Array} array The array to query.
7960 * @returns {*} Returns the last element of `array`.
7961 * @example
7962 *
7963 * _.last([1, 2, 3]);
7964 * // => 3
7965 */
7966 function last(array) {
7967 var length = array == null ? 0 : array.length;
7968 return length ? array[length - 1] : undefined$1;
7969 }
7970
7971 /**
7972 * This method is like `_.indexOf` except that it iterates over elements of
7973 * `array` from right to left.
7974 *
7975 * @static
7976 * @memberOf _
7977 * @since 0.1.0
7978 * @category Array
7979 * @param {Array} array The array to inspect.
7980 * @param {*} value The value to search for.
7981 * @param {number} [fromIndex=array.length-1] The index to search from.
7982 * @returns {number} Returns the index of the matched value, else `-1`.
7983 * @example
7984 *
7985 * _.lastIndexOf([1, 2, 1, 2], 2);
7986 * // => 3
7987 *
7988 * // Search from the `fromIndex`.
7989 * _.lastIndexOf([1, 2, 1, 2], 2, 2);
7990 * // => 1
7991 */
7992 function lastIndexOf(array, value, fromIndex) {
7993 var length = array == null ? 0 : array.length;
7994 if (!length) {
7995 return -1;
7996 }
7997 var index = length;
7998 if (fromIndex !== undefined$1) {
7999 index = toInteger(fromIndex);
8000 index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
8001 }
8002 return value === value
8003 ? strictLastIndexOf(array, value, index)
8004 : baseFindIndex(array, baseIsNaN, index, true);
8005 }
8006
8007 /**
8008 * Gets the element at index `n` of `array`. If `n` is negative, the nth
8009 * element from the end is returned.
8010 *
8011 * @static
8012 * @memberOf _
8013 * @since 4.11.0
8014 * @category Array
8015 * @param {Array} array The array to query.
8016 * @param {number} [n=0] The index of the element to return.
8017 * @returns {*} Returns the nth element of `array`.
8018 * @example
8019 *
8020 * var array = ['a', 'b', 'c', 'd'];
8021 *
8022 * _.nth(array, 1);
8023 * // => 'b'
8024 *
8025 * _.nth(array, -2);
8026 * // => 'c';
8027 */
8028 function nth(array, n) {
8029 return (array && array.length) ? baseNth(array, toInteger(n)) : undefined$1;
8030 }
8031
8032 /**
8033 * Removes all given values from `array` using
8034 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8035 * for equality comparisons.
8036 *
8037 * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
8038 * to remove elements from an array by predicate.
8039 *
8040 * @static
8041 * @memberOf _
8042 * @since 2.0.0
8043 * @category Array
8044 * @param {Array} array The array to modify.
8045 * @param {...*} [values] The values to remove.
8046 * @returns {Array} Returns `array`.
8047 * @example
8048 *
8049 * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
8050 *
8051 * _.pull(array, 'a', 'c');
8052 * console.log(array);
8053 * // => ['b', 'b']
8054 */
8055 var pull = baseRest(pullAll);
8056
8057 /**
8058 * This method is like `_.pull` except that it accepts an array of values to remove.
8059 *
8060 * **Note:** Unlike `_.difference`, this method mutates `array`.
8061 *
8062 * @static
8063 * @memberOf _
8064 * @since 4.0.0
8065 * @category Array
8066 * @param {Array} array The array to modify.
8067 * @param {Array} values The values to remove.
8068 * @returns {Array} Returns `array`.
8069 * @example
8070 *
8071 * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
8072 *
8073 * _.pullAll(array, ['a', 'c']);
8074 * console.log(array);
8075 * // => ['b', 'b']
8076 */
8077 function pullAll(array, values) {
8078 return (array && array.length && values && values.length)
8079 ? basePullAll(array, values)
8080 : array;
8081 }
8082
8083 /**
8084 * This method is like `_.pullAll` except that it accepts `iteratee` which is
8085 * invoked for each element of `array` and `values` to generate the criterion
8086 * by which they're compared. The iteratee is invoked with one argument: (value).
8087 *
8088 * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
8089 *
8090 * @static
8091 * @memberOf _
8092 * @since 4.0.0
8093 * @category Array
8094 * @param {Array} array The array to modify.
8095 * @param {Array} values The values to remove.
8096 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8097 * @returns {Array} Returns `array`.
8098 * @example
8099 *
8100 * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
8101 *
8102 * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
8103 * console.log(array);
8104 * // => [{ 'x': 2 }]
8105 */
8106 function pullAllBy(array, values, iteratee) {
8107 return (array && array.length && values && values.length)
8108 ? basePullAll(array, values, getIteratee(iteratee, 2))
8109 : array;
8110 }
8111
8112 /**
8113 * This method is like `_.pullAll` except that it accepts `comparator` which
8114 * is invoked to compare elements of `array` to `values`. The comparator is
8115 * invoked with two arguments: (arrVal, othVal).
8116 *
8117 * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
8118 *
8119 * @static
8120 * @memberOf _
8121 * @since 4.6.0
8122 * @category Array
8123 * @param {Array} array The array to modify.
8124 * @param {Array} values The values to remove.
8125 * @param {Function} [comparator] The comparator invoked per element.
8126 * @returns {Array} Returns `array`.
8127 * @example
8128 *
8129 * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
8130 *
8131 * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
8132 * console.log(array);
8133 * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
8134 */
8135 function pullAllWith(array, values, comparator) {
8136 return (array && array.length && values && values.length)
8137 ? basePullAll(array, values, undefined$1, comparator)
8138 : array;
8139 }
8140
8141 /**
8142 * Removes elements from `array` corresponding to `indexes` and returns an
8143 * array of removed elements.
8144 *
8145 * **Note:** Unlike `_.at`, this method mutates `array`.
8146 *
8147 * @static
8148 * @memberOf _
8149 * @since 3.0.0
8150 * @category Array
8151 * @param {Array} array The array to modify.
8152 * @param {...(number|number[])} [indexes] The indexes of elements to remove.
8153 * @returns {Array} Returns the new array of removed elements.
8154 * @example
8155 *
8156 * var array = ['a', 'b', 'c', 'd'];
8157 * var pulled = _.pullAt(array, [1, 3]);
8158 *
8159 * console.log(array);
8160 * // => ['a', 'c']
8161 *
8162 * console.log(pulled);
8163 * // => ['b', 'd']
8164 */
8165 var pullAt = flatRest(function(array, indexes) {
8166 var length = array == null ? 0 : array.length,
8167 result = baseAt(array, indexes);
8168
8169 basePullAt(array, arrayMap(indexes, function(index) {
8170 return isIndex(index, length) ? +index : index;
8171 }).sort(compareAscending));
8172
8173 return result;
8174 });
8175
8176 /**
8177 * Removes all elements from `array` that `predicate` returns truthy for
8178 * and returns an array of the removed elements. The predicate is invoked
8179 * with three arguments: (value, index, array).
8180 *
8181 * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
8182 * to pull elements from an array by value.
8183 *
8184 * @static
8185 * @memberOf _
8186 * @since 2.0.0
8187 * @category Array
8188 * @param {Array} array The array to modify.
8189 * @param {Function} [predicate=_.identity] The function invoked per iteration.
8190 * @returns {Array} Returns the new array of removed elements.
8191 * @example
8192 *
8193 * var array = [1, 2, 3, 4];
8194 * var evens = _.remove(array, function(n) {
8195 * return n % 2 == 0;
8196 * });
8197 *
8198 * console.log(array);
8199 * // => [1, 3]
8200 *
8201 * console.log(evens);
8202 * // => [2, 4]
8203 */
8204 function remove(array, predicate) {
8205 var result = [];
8206 if (!(array && array.length)) {
8207 return result;
8208 }
8209 var index = -1,
8210 indexes = [],
8211 length = array.length;
8212
8213 predicate = getIteratee(predicate, 3);
8214 while (++index < length) {
8215 var value = array[index];
8216 if (predicate(value, index, array)) {
8217 result.push(value);
8218 indexes.push(index);
8219 }
8220 }
8221 basePullAt(array, indexes);
8222 return result;
8223 }
8224
8225 /**
8226 * Reverses `array` so that the first element becomes the last, the second
8227 * element becomes the second to last, and so on.
8228 *
8229 * **Note:** This method mutates `array` and is based on
8230 * [`Array#reverse`](https://mdn.io/Array/reverse).
8231 *
8232 * @static
8233 * @memberOf _
8234 * @since 4.0.0
8235 * @category Array
8236 * @param {Array} array The array to modify.
8237 * @returns {Array} Returns `array`.
8238 * @example
8239 *
8240 * var array = [1, 2, 3];
8241 *
8242 * _.reverse(array);
8243 * // => [3, 2, 1]
8244 *
8245 * console.log(array);
8246 * // => [3, 2, 1]
8247 */
8248 function reverse(array) {
8249 return array == null ? array : nativeReverse.call(array);
8250 }
8251
8252 /**
8253 * Creates a slice of `array` from `start` up to, but not including, `end`.
8254 *
8255 * **Note:** This method is used instead of
8256 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
8257 * returned.
8258 *
8259 * @static
8260 * @memberOf _
8261 * @since 3.0.0
8262 * @category Array
8263 * @param {Array} array The array to slice.
8264 * @param {number} [start=0] The start position.
8265 * @param {number} [end=array.length] The end position.
8266 * @returns {Array} Returns the slice of `array`.
8267 */
8268 function slice(array, start, end) {
8269 var length = array == null ? 0 : array.length;
8270 if (!length) {
8271 return [];
8272 }
8273 if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
8274 start = 0;
8275 end = length;
8276 }
8277 else {
8278 start = start == null ? 0 : toInteger(start);
8279 end = end === undefined$1 ? length : toInteger(end);
8280 }
8281 return baseSlice(array, start, end);
8282 }
8283
8284 /**
8285 * Uses a binary search to determine the lowest index at which `value`
8286 * should be inserted into `array` in order to maintain its sort order.
8287 *
8288 * @static
8289 * @memberOf _
8290 * @since 0.1.0
8291 * @category Array
8292 * @param {Array} array The sorted array to inspect.
8293 * @param {*} value The value to evaluate.
8294 * @returns {number} Returns the index at which `value` should be inserted
8295 * into `array`.
8296 * @example
8297 *
8298 * _.sortedIndex([30, 50], 40);
8299 * // => 1
8300 */
8301 function sortedIndex(array, value) {
8302 return baseSortedIndex(array, value);
8303 }
8304
8305 /**
8306 * This method is like `_.sortedIndex` except that it accepts `iteratee`
8307 * which is invoked for `value` and each element of `array` to compute their
8308 * sort ranking. The iteratee is invoked with one argument: (value).
8309 *
8310 * @static
8311 * @memberOf _
8312 * @since 4.0.0
8313 * @category Array
8314 * @param {Array} array The sorted array to inspect.
8315 * @param {*} value The value to evaluate.
8316 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8317 * @returns {number} Returns the index at which `value` should be inserted
8318 * into `array`.
8319 * @example
8320 *
8321 * var objects = [{ 'x': 4 }, { 'x': 5 }];
8322 *
8323 * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
8324 * // => 0
8325 *
8326 * // The `_.property` iteratee shorthand.
8327 * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
8328 * // => 0
8329 */
8330 function sortedIndexBy(array, value, iteratee) {
8331 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
8332 }
8333
8334 /**
8335 * This method is like `_.indexOf` except that it performs a binary
8336 * search on a sorted `array`.
8337 *
8338 * @static
8339 * @memberOf _
8340 * @since 4.0.0
8341 * @category Array
8342 * @param {Array} array The array to inspect.
8343 * @param {*} value The value to search for.
8344 * @returns {number} Returns the index of the matched value, else `-1`.
8345 * @example
8346 *
8347 * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
8348 * // => 1
8349 */
8350 function sortedIndexOf(array, value) {
8351 var length = array == null ? 0 : array.length;
8352 if (length) {
8353 var index = baseSortedIndex(array, value);
8354 if (index < length && eq(array[index], value)) {
8355 return index;
8356 }
8357 }
8358 return -1;
8359 }
8360
8361 /**
8362 * This method is like `_.sortedIndex` except that it returns the highest
8363 * index at which `value` should be inserted into `array` in order to
8364 * maintain its sort order.
8365 *
8366 * @static
8367 * @memberOf _
8368 * @since 3.0.0
8369 * @category Array
8370 * @param {Array} array The sorted array to inspect.
8371 * @param {*} value The value to evaluate.
8372 * @returns {number} Returns the index at which `value` should be inserted
8373 * into `array`.
8374 * @example
8375 *
8376 * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
8377 * // => 4
8378 */
8379 function sortedLastIndex(array, value) {
8380 return baseSortedIndex(array, value, true);
8381 }
8382
8383 /**
8384 * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
8385 * which is invoked for `value` and each element of `array` to compute their
8386 * sort ranking. The iteratee is invoked with one argument: (value).
8387 *
8388 * @static
8389 * @memberOf _
8390 * @since 4.0.0
8391 * @category Array
8392 * @param {Array} array The sorted array to inspect.
8393 * @param {*} value The value to evaluate.
8394 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8395 * @returns {number} Returns the index at which `value` should be inserted
8396 * into `array`.
8397 * @example
8398 *
8399 * var objects = [{ 'x': 4 }, { 'x': 5 }];
8400 *
8401 * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
8402 * // => 1
8403 *
8404 * // The `_.property` iteratee shorthand.
8405 * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
8406 * // => 1
8407 */
8408 function sortedLastIndexBy(array, value, iteratee) {
8409 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
8410 }
8411
8412 /**
8413 * This method is like `_.lastIndexOf` except that it performs a binary
8414 * search on a sorted `array`.
8415 *
8416 * @static
8417 * @memberOf _
8418 * @since 4.0.0
8419 * @category Array
8420 * @param {Array} array The array to inspect.
8421 * @param {*} value The value to search for.
8422 * @returns {number} Returns the index of the matched value, else `-1`.
8423 * @example
8424 *
8425 * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
8426 * // => 3
8427 */
8428 function sortedLastIndexOf(array, value) {
8429 var length = array == null ? 0 : array.length;
8430 if (length) {
8431 var index = baseSortedIndex(array, value, true) - 1;
8432 if (eq(array[index], value)) {
8433 return index;
8434 }
8435 }
8436 return -1;
8437 }
8438
8439 /**
8440 * This method is like `_.uniq` except that it's designed and optimized
8441 * for sorted arrays.
8442 *
8443 * @static
8444 * @memberOf _
8445 * @since 4.0.0
8446 * @category Array
8447 * @param {Array} array The array to inspect.
8448 * @returns {Array} Returns the new duplicate free array.
8449 * @example
8450 *
8451 * _.sortedUniq([1, 1, 2]);
8452 * // => [1, 2]
8453 */
8454 function sortedUniq(array) {
8455 return (array && array.length)
8456 ? baseSortedUniq(array)
8457 : [];
8458 }
8459
8460 /**
8461 * This method is like `_.uniqBy` except that it's designed and optimized
8462 * for sorted arrays.
8463 *
8464 * @static
8465 * @memberOf _
8466 * @since 4.0.0
8467 * @category Array
8468 * @param {Array} array The array to inspect.
8469 * @param {Function} [iteratee] The iteratee invoked per element.
8470 * @returns {Array} Returns the new duplicate free array.
8471 * @example
8472 *
8473 * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
8474 * // => [1.1, 2.3]
8475 */
8476 function sortedUniqBy(array, iteratee) {
8477 return (array && array.length)
8478 ? baseSortedUniq(array, getIteratee(iteratee, 2))
8479 : [];
8480 }
8481
8482 /**
8483 * Gets all but the first element of `array`.
8484 *
8485 * @static
8486 * @memberOf _
8487 * @since 4.0.0
8488 * @category Array
8489 * @param {Array} array The array to query.
8490 * @returns {Array} Returns the slice of `array`.
8491 * @example
8492 *
8493 * _.tail([1, 2, 3]);
8494 * // => [2, 3]
8495 */
8496 function tail(array) {
8497 var length = array == null ? 0 : array.length;
8498 return length ? baseSlice(array, 1, length) : [];
8499 }
8500
8501 /**
8502 * Creates a slice of `array` with `n` elements taken from the beginning.
8503 *
8504 * @static
8505 * @memberOf _
8506 * @since 0.1.0
8507 * @category Array
8508 * @param {Array} array The array to query.
8509 * @param {number} [n=1] The number of elements to take.
8510 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
8511 * @returns {Array} Returns the slice of `array`.
8512 * @example
8513 *
8514 * _.take([1, 2, 3]);
8515 * // => [1]
8516 *
8517 * _.take([1, 2, 3], 2);
8518 * // => [1, 2]
8519 *
8520 * _.take([1, 2, 3], 5);
8521 * // => [1, 2, 3]
8522 *
8523 * _.take([1, 2, 3], 0);
8524 * // => []
8525 */
8526 function take(array, n, guard) {
8527 if (!(array && array.length)) {
8528 return [];
8529 }
8530 n = (guard || n === undefined$1) ? 1 : toInteger(n);
8531 return baseSlice(array, 0, n < 0 ? 0 : n);
8532 }
8533
8534 /**
8535 * Creates a slice of `array` with `n` elements taken from the end.
8536 *
8537 * @static
8538 * @memberOf _
8539 * @since 3.0.0
8540 * @category Array
8541 * @param {Array} array The array to query.
8542 * @param {number} [n=1] The number of elements to take.
8543 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
8544 * @returns {Array} Returns the slice of `array`.
8545 * @example
8546 *
8547 * _.takeRight([1, 2, 3]);
8548 * // => [3]
8549 *
8550 * _.takeRight([1, 2, 3], 2);
8551 * // => [2, 3]
8552 *
8553 * _.takeRight([1, 2, 3], 5);
8554 * // => [1, 2, 3]
8555 *
8556 * _.takeRight([1, 2, 3], 0);
8557 * // => []
8558 */
8559 function takeRight(array, n, guard) {
8560 var length = array == null ? 0 : array.length;
8561 if (!length) {
8562 return [];
8563 }
8564 n = (guard || n === undefined$1) ? 1 : toInteger(n);
8565 n = length - n;
8566 return baseSlice(array, n < 0 ? 0 : n, length);
8567 }
8568
8569 /**
8570 * Creates a slice of `array` with elements taken from the end. Elements are
8571 * taken until `predicate` returns falsey. The predicate is invoked with
8572 * three arguments: (value, index, array).
8573 *
8574 * @static
8575 * @memberOf _
8576 * @since 3.0.0
8577 * @category Array
8578 * @param {Array} array The array to query.
8579 * @param {Function} [predicate=_.identity] The function invoked per iteration.
8580 * @returns {Array} Returns the slice of `array`.
8581 * @example
8582 *
8583 * var users = [
8584 * { 'user': 'barney', 'active': true },
8585 * { 'user': 'fred', 'active': false },
8586 * { 'user': 'pebbles', 'active': false }
8587 * ];
8588 *
8589 * _.takeRightWhile(users, function(o) { return !o.active; });
8590 * // => objects for ['fred', 'pebbles']
8591 *
8592 * // The `_.matches` iteratee shorthand.
8593 * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
8594 * // => objects for ['pebbles']
8595 *
8596 * // The `_.matchesProperty` iteratee shorthand.
8597 * _.takeRightWhile(users, ['active', false]);
8598 * // => objects for ['fred', 'pebbles']
8599 *
8600 * // The `_.property` iteratee shorthand.
8601 * _.takeRightWhile(users, 'active');
8602 * // => []
8603 */
8604 function takeRightWhile(array, predicate) {
8605 return (array && array.length)
8606 ? baseWhile(array, getIteratee(predicate, 3), false, true)
8607 : [];
8608 }
8609
8610 /**
8611 * Creates a slice of `array` with elements taken from the beginning. Elements
8612 * are taken until `predicate` returns falsey. The predicate is invoked with
8613 * three arguments: (value, index, array).
8614 *
8615 * @static
8616 * @memberOf _
8617 * @since 3.0.0
8618 * @category Array
8619 * @param {Array} array The array to query.
8620 * @param {Function} [predicate=_.identity] The function invoked per iteration.
8621 * @returns {Array} Returns the slice of `array`.
8622 * @example
8623 *
8624 * var users = [
8625 * { 'user': 'barney', 'active': false },
8626 * { 'user': 'fred', 'active': false },
8627 * { 'user': 'pebbles', 'active': true }
8628 * ];
8629 *
8630 * _.takeWhile(users, function(o) { return !o.active; });
8631 * // => objects for ['barney', 'fred']
8632 *
8633 * // The `_.matches` iteratee shorthand.
8634 * _.takeWhile(users, { 'user': 'barney', 'active': false });
8635 * // => objects for ['barney']
8636 *
8637 * // The `_.matchesProperty` iteratee shorthand.
8638 * _.takeWhile(users, ['active', false]);
8639 * // => objects for ['barney', 'fred']
8640 *
8641 * // The `_.property` iteratee shorthand.
8642 * _.takeWhile(users, 'active');
8643 * // => []
8644 */
8645 function takeWhile(array, predicate) {
8646 return (array && array.length)
8647 ? baseWhile(array, getIteratee(predicate, 3))
8648 : [];
8649 }
8650
8651 /**
8652 * Creates an array of unique values, in order, from all given arrays using
8653 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8654 * for equality comparisons.
8655 *
8656 * @static
8657 * @memberOf _
8658 * @since 0.1.0
8659 * @category Array
8660 * @param {...Array} [arrays] The arrays to inspect.
8661 * @returns {Array} Returns the new array of combined values.
8662 * @example
8663 *
8664 * _.union([2], [1, 2]);
8665 * // => [2, 1]
8666 */
8667 var union = baseRest(function(arrays) {
8668 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
8669 });
8670
8671 /**
8672 * This method is like `_.union` except that it accepts `iteratee` which is
8673 * invoked for each element of each `arrays` to generate the criterion by
8674 * which uniqueness is computed. Result values are chosen from the first
8675 * array in which the value occurs. The iteratee is invoked with one argument:
8676 * (value).
8677 *
8678 * @static
8679 * @memberOf _
8680 * @since 4.0.0
8681 * @category Array
8682 * @param {...Array} [arrays] The arrays to inspect.
8683 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8684 * @returns {Array} Returns the new array of combined values.
8685 * @example
8686 *
8687 * _.unionBy([2.1], [1.2, 2.3], Math.floor);
8688 * // => [2.1, 1.2]
8689 *
8690 * // The `_.property` iteratee shorthand.
8691 * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
8692 * // => [{ 'x': 1 }, { 'x': 2 }]
8693 */
8694 var unionBy = baseRest(function(arrays) {
8695 var iteratee = last(arrays);
8696 if (isArrayLikeObject(iteratee)) {
8697 iteratee = undefined$1;
8698 }
8699 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
8700 });
8701
8702 /**
8703 * This method is like `_.union` except that it accepts `comparator` which
8704 * is invoked to compare elements of `arrays`. Result values are chosen from
8705 * the first array in which the value occurs. The comparator is invoked
8706 * with two arguments: (arrVal, othVal).
8707 *
8708 * @static
8709 * @memberOf _
8710 * @since 4.0.0
8711 * @category Array
8712 * @param {...Array} [arrays] The arrays to inspect.
8713 * @param {Function} [comparator] The comparator invoked per element.
8714 * @returns {Array} Returns the new array of combined values.
8715 * @example
8716 *
8717 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
8718 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
8719 *
8720 * _.unionWith(objects, others, _.isEqual);
8721 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
8722 */
8723 var unionWith = baseRest(function(arrays) {
8724 var comparator = last(arrays);
8725 comparator = typeof comparator == 'function' ? comparator : undefined$1;
8726 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined$1, comparator);
8727 });
8728
8729 /**
8730 * Creates a duplicate-free version of an array, using
8731 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8732 * for equality comparisons, in which only the first occurrence of each element
8733 * is kept. The order of result values is determined by the order they occur
8734 * in the array.
8735 *
8736 * @static
8737 * @memberOf _
8738 * @since 0.1.0
8739 * @category Array
8740 * @param {Array} array The array to inspect.
8741 * @returns {Array} Returns the new duplicate free array.
8742 * @example
8743 *
8744 * _.uniq([2, 1, 2]);
8745 * // => [2, 1]
8746 */
8747 function uniq(array) {
8748 return (array && array.length) ? baseUniq(array) : [];
8749 }
8750
8751 /**
8752 * This method is like `_.uniq` except that it accepts `iteratee` which is
8753 * invoked for each element in `array` to generate the criterion by which
8754 * uniqueness is computed. The order of result values is determined by the
8755 * order they occur in the array. The iteratee is invoked with one argument:
8756 * (value).
8757 *
8758 * @static
8759 * @memberOf _
8760 * @since 4.0.0
8761 * @category Array
8762 * @param {Array} array The array to inspect.
8763 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8764 * @returns {Array} Returns the new duplicate free array.
8765 * @example
8766 *
8767 * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
8768 * // => [2.1, 1.2]
8769 *
8770 * // The `_.property` iteratee shorthand.
8771 * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
8772 * // => [{ 'x': 1 }, { 'x': 2 }]
8773 */
8774 function uniqBy(array, iteratee) {
8775 return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
8776 }
8777
8778 /**
8779 * This method is like `_.uniq` except that it accepts `comparator` which
8780 * is invoked to compare elements of `array`. The order of result values is
8781 * determined by the order they occur in the array.The comparator is invoked
8782 * with two arguments: (arrVal, othVal).
8783 *
8784 * @static
8785 * @memberOf _
8786 * @since 4.0.0
8787 * @category Array
8788 * @param {Array} array The array to inspect.
8789 * @param {Function} [comparator] The comparator invoked per element.
8790 * @returns {Array} Returns the new duplicate free array.
8791 * @example
8792 *
8793 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
8794 *
8795 * _.uniqWith(objects, _.isEqual);
8796 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
8797 */
8798 function uniqWith(array, comparator) {
8799 comparator = typeof comparator == 'function' ? comparator : undefined$1;
8800 return (array && array.length) ? baseUniq(array, undefined$1, comparator) : [];
8801 }
8802
8803 /**
8804 * This method is like `_.zip` except that it accepts an array of grouped
8805 * elements and creates an array regrouping the elements to their pre-zip
8806 * configuration.
8807 *
8808 * @static
8809 * @memberOf _
8810 * @since 1.2.0
8811 * @category Array
8812 * @param {Array} array The array of grouped elements to process.
8813 * @returns {Array} Returns the new array of regrouped elements.
8814 * @example
8815 *
8816 * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
8817 * // => [['a', 1, true], ['b', 2, false]]
8818 *
8819 * _.unzip(zipped);
8820 * // => [['a', 'b'], [1, 2], [true, false]]
8821 */
8822 function unzip(array) {
8823 if (!(array && array.length)) {
8824 return [];
8825 }
8826 var length = 0;
8827 array = arrayFilter(array, function(group) {
8828 if (isArrayLikeObject(group)) {
8829 length = nativeMax(group.length, length);
8830 return true;
8831 }
8832 });
8833 return baseTimes(length, function(index) {
8834 return arrayMap(array, baseProperty(index));
8835 });
8836 }
8837
8838 /**
8839 * This method is like `_.unzip` except that it accepts `iteratee` to specify
8840 * how regrouped values should be combined. The iteratee is invoked with the
8841 * elements of each group: (...group).
8842 *
8843 * @static
8844 * @memberOf _
8845 * @since 3.8.0
8846 * @category Array
8847 * @param {Array} array The array of grouped elements to process.
8848 * @param {Function} [iteratee=_.identity] The function to combine
8849 * regrouped values.
8850 * @returns {Array} Returns the new array of regrouped elements.
8851 * @example
8852 *
8853 * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
8854 * // => [[1, 10, 100], [2, 20, 200]]
8855 *
8856 * _.unzipWith(zipped, _.add);
8857 * // => [3, 30, 300]
8858 */
8859 function unzipWith(array, iteratee) {
8860 if (!(array && array.length)) {
8861 return [];
8862 }
8863 var result = unzip(array);
8864 if (iteratee == null) {
8865 return result;
8866 }
8867 return arrayMap(result, function(group) {
8868 return apply(iteratee, undefined$1, group);
8869 });
8870 }
8871
8872 /**
8873 * Creates an array excluding all given values using
8874 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8875 * for equality comparisons.
8876 *
8877 * **Note:** Unlike `_.pull`, this method returns a new array.
8878 *
8879 * @static
8880 * @memberOf _
8881 * @since 0.1.0
8882 * @category Array
8883 * @param {Array} array The array to inspect.
8884 * @param {...*} [values] The values to exclude.
8885 * @returns {Array} Returns the new array of filtered values.
8886 * @see _.difference, _.xor
8887 * @example
8888 *
8889 * _.without([2, 1, 2, 3], 1, 2);
8890 * // => [3]
8891 */
8892 var without = baseRest(function(array, values) {
8893 return isArrayLikeObject(array)
8894 ? baseDifference(array, values)
8895 : [];
8896 });
8897
8898 /**
8899 * Creates an array of unique values that is the
8900 * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
8901 * of the given arrays. The order of result values is determined by the order
8902 * they occur in the arrays.
8903 *
8904 * @static
8905 * @memberOf _
8906 * @since 2.4.0
8907 * @category Array
8908 * @param {...Array} [arrays] The arrays to inspect.
8909 * @returns {Array} Returns the new array of filtered values.
8910 * @see _.difference, _.without
8911 * @example
8912 *
8913 * _.xor([2, 1], [2, 3]);
8914 * // => [1, 3]
8915 */
8916 var xor = baseRest(function(arrays) {
8917 return baseXor(arrayFilter(arrays, isArrayLikeObject));
8918 });
8919
8920 /**
8921 * This method is like `_.xor` except that it accepts `iteratee` which is
8922 * invoked for each element of each `arrays` to generate the criterion by
8923 * which by which they're compared. The order of result values is determined
8924 * by the order they occur in the arrays. The iteratee is invoked with one
8925 * argument: (value).
8926 *
8927 * @static
8928 * @memberOf _
8929 * @since 4.0.0
8930 * @category Array
8931 * @param {...Array} [arrays] The arrays to inspect.
8932 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8933 * @returns {Array} Returns the new array of filtered values.
8934 * @example
8935 *
8936 * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
8937 * // => [1.2, 3.4]
8938 *
8939 * // The `_.property` iteratee shorthand.
8940 * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
8941 * // => [{ 'x': 2 }]
8942 */
8943 var xorBy = baseRest(function(arrays) {
8944 var iteratee = last(arrays);
8945 if (isArrayLikeObject(iteratee)) {
8946 iteratee = undefined$1;
8947 }
8948 return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
8949 });
8950
8951 /**
8952 * This method is like `_.xor` except that it accepts `comparator` which is
8953 * invoked to compare elements of `arrays`. The order of result values is
8954 * determined by the order they occur in the arrays. The comparator is invoked
8955 * with two arguments: (arrVal, othVal).
8956 *
8957 * @static
8958 * @memberOf _
8959 * @since 4.0.0
8960 * @category Array
8961 * @param {...Array} [arrays] The arrays to inspect.
8962 * @param {Function} [comparator] The comparator invoked per element.
8963 * @returns {Array} Returns the new array of filtered values.
8964 * @example
8965 *
8966 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
8967 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
8968 *
8969 * _.xorWith(objects, others, _.isEqual);
8970 * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
8971 */
8972 var xorWith = baseRest(function(arrays) {
8973 var comparator = last(arrays);
8974 comparator = typeof comparator == 'function' ? comparator : undefined$1;
8975 return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined$1, comparator);
8976 });
8977
8978 /**
8979 * Creates an array of grouped elements, the first of which contains the
8980 * first elements of the given arrays, the second of which contains the
8981 * second elements of the given arrays, and so on.
8982 *
8983 * @static
8984 * @memberOf _
8985 * @since 0.1.0
8986 * @category Array
8987 * @param {...Array} [arrays] The arrays to process.
8988 * @returns {Array} Returns the new array of grouped elements.
8989 * @example
8990 *
8991 * _.zip(['a', 'b'], [1, 2], [true, false]);
8992 * // => [['a', 1, true], ['b', 2, false]]
8993 */
8994 var zip = baseRest(unzip);
8995
8996 /**
8997 * This method is like `_.fromPairs` except that it accepts two arrays,
8998 * one of property identifiers and one of corresponding values.
8999 *
9000 * @static
9001 * @memberOf _
9002 * @since 0.4.0
9003 * @category Array
9004 * @param {Array} [props=[]] The property identifiers.
9005 * @param {Array} [values=[]] The property values.
9006 * @returns {Object} Returns the new object.
9007 * @example
9008 *
9009 * _.zipObject(['a', 'b'], [1, 2]);
9010 * // => { 'a': 1, 'b': 2 }
9011 */
9012 function zipObject(props, values) {
9013 return baseZipObject(props || [], values || [], assignValue);
9014 }
9015
9016 /**
9017 * This method is like `_.zipObject` except that it supports property paths.
9018 *
9019 * @static
9020 * @memberOf _
9021 * @since 4.1.0
9022 * @category Array
9023 * @param {Array} [props=[]] The property identifiers.
9024 * @param {Array} [values=[]] The property values.
9025 * @returns {Object} Returns the new object.
9026 * @example
9027 *
9028 * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
9029 * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
9030 */
9031 function zipObjectDeep(props, values) {
9032 return baseZipObject(props || [], values || [], baseSet);
9033 }
9034
9035 /**
9036 * This method is like `_.zip` except that it accepts `iteratee` to specify
9037 * how grouped values should be combined. The iteratee is invoked with the
9038 * elements of each group: (...group).
9039 *
9040 * @static
9041 * @memberOf _
9042 * @since 3.8.0
9043 * @category Array
9044 * @param {...Array} [arrays] The arrays to process.
9045 * @param {Function} [iteratee=_.identity] The function to combine
9046 * grouped values.
9047 * @returns {Array} Returns the new array of grouped elements.
9048 * @example
9049 *
9050 * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
9051 * return a + b + c;
9052 * });
9053 * // => [111, 222]
9054 */
9055 var zipWith = baseRest(function(arrays) {
9056 var length = arrays.length,
9057 iteratee = length > 1 ? arrays[length - 1] : undefined$1;
9058
9059 iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined$1;
9060 return unzipWith(arrays, iteratee);
9061 });
9062
9063 /*------------------------------------------------------------------------*/
9064
9065 /**
9066 * Creates a `lodash` wrapper instance that wraps `value` with explicit method
9067 * chain sequences enabled. The result of such sequences must be unwrapped
9068 * with `_#value`.
9069 *
9070 * @static
9071 * @memberOf _
9072 * @since 1.3.0
9073 * @category Seq
9074 * @param {*} value The value to wrap.
9075 * @returns {Object} Returns the new `lodash` wrapper instance.
9076 * @example
9077 *
9078 * var users = [
9079 * { 'user': 'barney', 'age': 36 },
9080 * { 'user': 'fred', 'age': 40 },
9081 * { 'user': 'pebbles', 'age': 1 }
9082 * ];
9083 *
9084 * var youngest = _
9085 * .chain(users)
9086 * .sortBy('age')
9087 * .map(function(o) {
9088 * return o.user + ' is ' + o.age;
9089 * })
9090 * .head()
9091 * .value();
9092 * // => 'pebbles is 1'
9093 */
9094 function chain(value) {
9095 var result = lodash(value);
9096 result.__chain__ = true;
9097 return result;
9098 }
9099
9100 /**
9101 * This method invokes `interceptor` and returns `value`. The interceptor
9102 * is invoked with one argument; (value). The purpose of this method is to
9103 * "tap into" a method chain sequence in order to modify intermediate results.
9104 *
9105 * @static
9106 * @memberOf _
9107 * @since 0.1.0
9108 * @category Seq
9109 * @param {*} value The value to provide to `interceptor`.
9110 * @param {Function} interceptor The function to invoke.
9111 * @returns {*} Returns `value`.
9112 * @example
9113 *
9114 * _([1, 2, 3])
9115 * .tap(function(array) {
9116 * // Mutate input array.
9117 * array.pop();
9118 * })
9119 * .reverse()
9120 * .value();
9121 * // => [2, 1]
9122 */
9123 function tap(value, interceptor) {
9124 interceptor(value);
9125 return value;
9126 }
9127
9128 /**
9129 * This method is like `_.tap` except that it returns the result of `interceptor`.
9130 * The purpose of this method is to "pass thru" values replacing intermediate
9131 * results in a method chain sequence.
9132 *
9133 * @static
9134 * @memberOf _
9135 * @since 3.0.0
9136 * @category Seq
9137 * @param {*} value The value to provide to `interceptor`.
9138 * @param {Function} interceptor The function to invoke.
9139 * @returns {*} Returns the result of `interceptor`.
9140 * @example
9141 *
9142 * _(' abc ')
9143 * .chain()
9144 * .trim()
9145 * .thru(function(value) {
9146 * return [value];
9147 * })
9148 * .value();
9149 * // => ['abc']
9150 */
9151 function thru(value, interceptor) {
9152 return interceptor(value);
9153 }
9154
9155 /**
9156 * This method is the wrapper version of `_.at`.
9157 *
9158 * @name at
9159 * @memberOf _
9160 * @since 1.0.0
9161 * @category Seq
9162 * @param {...(string|string[])} [paths] The property paths to pick.
9163 * @returns {Object} Returns the new `lodash` wrapper instance.
9164 * @example
9165 *
9166 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
9167 *
9168 * _(object).at(['a[0].b.c', 'a[1]']).value();
9169 * // => [3, 4]
9170 */
9171 var wrapperAt = flatRest(function(paths) {
9172 var length = paths.length,
9173 start = length ? paths[0] : 0,
9174 value = this.__wrapped__,
9175 interceptor = function(object) { return baseAt(object, paths); };
9176
9177 if (length > 1 || this.__actions__.length ||
9178 !(value instanceof LazyWrapper) || !isIndex(start)) {
9179 return this.thru(interceptor);
9180 }
9181 value = value.slice(start, +start + (length ? 1 : 0));
9182 value.__actions__.push({
9183 'func': thru,
9184 'args': [interceptor],
9185 'thisArg': undefined$1
9186 });
9187 return new LodashWrapper(value, this.__chain__).thru(function(array) {
9188 if (length && !array.length) {
9189 array.push(undefined$1);
9190 }
9191 return array;
9192 });
9193 });
9194
9195 /**
9196 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
9197 *
9198 * @name chain
9199 * @memberOf _
9200 * @since 0.1.0
9201 * @category Seq
9202 * @returns {Object} Returns the new `lodash` wrapper instance.
9203 * @example
9204 *
9205 * var users = [
9206 * { 'user': 'barney', 'age': 36 },
9207 * { 'user': 'fred', 'age': 40 }
9208 * ];
9209 *
9210 * // A sequence without explicit chaining.
9211 * _(users).head();
9212 * // => { 'user': 'barney', 'age': 36 }
9213 *
9214 * // A sequence with explicit chaining.
9215 * _(users)
9216 * .chain()
9217 * .head()
9218 * .pick('user')
9219 * .value();
9220 * // => { 'user': 'barney' }
9221 */
9222 function wrapperChain() {
9223 return chain(this);
9224 }
9225
9226 /**
9227 * Executes the chain sequence and returns the wrapped result.
9228 *
9229 * @name commit
9230 * @memberOf _
9231 * @since 3.2.0
9232 * @category Seq
9233 * @returns {Object} Returns the new `lodash` wrapper instance.
9234 * @example
9235 *
9236 * var array = [1, 2];
9237 * var wrapped = _(array).push(3);
9238 *
9239 * console.log(array);
9240 * // => [1, 2]
9241 *
9242 * wrapped = wrapped.commit();
9243 * console.log(array);
9244 * // => [1, 2, 3]
9245 *
9246 * wrapped.last();
9247 * // => 3
9248 *
9249 * console.log(array);
9250 * // => [1, 2, 3]
9251 */
9252 function wrapperCommit() {
9253 return new LodashWrapper(this.value(), this.__chain__);
9254 }
9255
9256 /**
9257 * Gets the next value on a wrapped object following the
9258 * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
9259 *
9260 * @name next
9261 * @memberOf _
9262 * @since 4.0.0
9263 * @category Seq
9264 * @returns {Object} Returns the next iterator value.
9265 * @example
9266 *
9267 * var wrapped = _([1, 2]);
9268 *
9269 * wrapped.next();
9270 * // => { 'done': false, 'value': 1 }
9271 *
9272 * wrapped.next();
9273 * // => { 'done': false, 'value': 2 }
9274 *
9275 * wrapped.next();
9276 * // => { 'done': true, 'value': undefined }
9277 */
9278 function wrapperNext() {
9279 if (this.__values__ === undefined$1) {
9280 this.__values__ = toArray(this.value());
9281 }
9282 var done = this.__index__ >= this.__values__.length,
9283 value = done ? undefined$1 : this.__values__[this.__index__++];
9284
9285 return { 'done': done, 'value': value };
9286 }
9287
9288 /**
9289 * Enables the wrapper to be iterable.
9290 *
9291 * @name Symbol.iterator
9292 * @memberOf _
9293 * @since 4.0.0
9294 * @category Seq
9295 * @returns {Object} Returns the wrapper object.
9296 * @example
9297 *
9298 * var wrapped = _([1, 2]);
9299 *
9300 * wrapped[Symbol.iterator]() === wrapped;
9301 * // => true
9302 *
9303 * Array.from(wrapped);
9304 * // => [1, 2]
9305 */
9306 function wrapperToIterator() {
9307 return this;
9308 }
9309
9310 /**
9311 * Creates a clone of the chain sequence planting `value` as the wrapped value.
9312 *
9313 * @name plant
9314 * @memberOf _
9315 * @since 3.2.0
9316 * @category Seq
9317 * @param {*} value The value to plant.
9318 * @returns {Object} Returns the new `lodash` wrapper instance.
9319 * @example
9320 *
9321 * function square(n) {
9322 * return n * n;
9323 * }
9324 *
9325 * var wrapped = _([1, 2]).map(square);
9326 * var other = wrapped.plant([3, 4]);
9327 *
9328 * other.value();
9329 * // => [9, 16]
9330 *
9331 * wrapped.value();
9332 * // => [1, 4]
9333 */
9334 function wrapperPlant(value) {
9335 var result,
9336 parent = this;
9337
9338 while (parent instanceof baseLodash) {
9339 var clone = wrapperClone(parent);
9340 clone.__index__ = 0;
9341 clone.__values__ = undefined$1;
9342 if (result) {
9343 previous.__wrapped__ = clone;
9344 } else {
9345 result = clone;
9346 }
9347 var previous = clone;
9348 parent = parent.__wrapped__;
9349 }
9350 previous.__wrapped__ = value;
9351 return result;
9352 }
9353
9354 /**
9355 * This method is the wrapper version of `_.reverse`.
9356 *
9357 * **Note:** This method mutates the wrapped array.
9358 *
9359 * @name reverse
9360 * @memberOf _
9361 * @since 0.1.0
9362 * @category Seq
9363 * @returns {Object} Returns the new `lodash` wrapper instance.
9364 * @example
9365 *
9366 * var array = [1, 2, 3];
9367 *
9368 * _(array).reverse().value()
9369 * // => [3, 2, 1]
9370 *
9371 * console.log(array);
9372 * // => [3, 2, 1]
9373 */
9374 function wrapperReverse() {
9375 var value = this.__wrapped__;
9376 if (value instanceof LazyWrapper) {
9377 var wrapped = value;
9378 if (this.__actions__.length) {
9379 wrapped = new LazyWrapper(this);
9380 }
9381 wrapped = wrapped.reverse();
9382 wrapped.__actions__.push({
9383 'func': thru,
9384 'args': [reverse],
9385 'thisArg': undefined$1
9386 });
9387 return new LodashWrapper(wrapped, this.__chain__);
9388 }
9389 return this.thru(reverse);
9390 }
9391
9392 /**
9393 * Executes the chain sequence to resolve the unwrapped value.
9394 *
9395 * @name value
9396 * @memberOf _
9397 * @since 0.1.0
9398 * @alias toJSON, valueOf
9399 * @category Seq
9400 * @returns {*} Returns the resolved unwrapped value.
9401 * @example
9402 *
9403 * _([1, 2, 3]).value();
9404 * // => [1, 2, 3]
9405 */
9406 function wrapperValue() {
9407 return baseWrapperValue(this.__wrapped__, this.__actions__);
9408 }
9409
9410 /*------------------------------------------------------------------------*/
9411
9412 /**
9413 * Creates an object composed of keys generated from the results of running
9414 * each element of `collection` thru `iteratee`. The corresponding value of
9415 * each key is the number of times the key was returned by `iteratee`. The
9416 * iteratee is invoked with one argument: (value).
9417 *
9418 * @static
9419 * @memberOf _
9420 * @since 0.5.0
9421 * @category Collection
9422 * @param {Array|Object} collection The collection to iterate over.
9423 * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9424 * @returns {Object} Returns the composed aggregate object.
9425 * @example
9426 *
9427 * _.countBy([6.1, 4.2, 6.3], Math.floor);
9428 * // => { '4': 1, '6': 2 }
9429 *
9430 * // The `_.property` iteratee shorthand.
9431 * _.countBy(['one', 'two', 'three'], 'length');
9432 * // => { '3': 2, '5': 1 }
9433 */
9434 var countBy = createAggregator(function(result, value, key) {
9435 if (hasOwnProperty.call(result, key)) {
9436 ++result[key];
9437 } else {
9438 baseAssignValue(result, key, 1);
9439 }
9440 });
9441
9442 /**
9443 * Checks if `predicate` returns truthy for **all** elements of `collection`.
9444 * Iteration is stopped once `predicate` returns falsey. The predicate is
9445 * invoked with three arguments: (value, index|key, collection).
9446 *
9447 * **Note:** This method returns `true` for
9448 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
9449 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
9450 * elements of empty collections.
9451 *
9452 * @static
9453 * @memberOf _
9454 * @since 0.1.0
9455 * @category Collection
9456 * @param {Array|Object} collection The collection to iterate over.
9457 * @param {Function} [predicate=_.identity] The function invoked per iteration.
9458 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9459 * @returns {boolean} Returns `true` if all elements pass the predicate check,
9460 * else `false`.
9461 * @example
9462 *
9463 * _.every([true, 1, null, 'yes'], Boolean);
9464 * // => false
9465 *
9466 * var users = [
9467 * { 'user': 'barney', 'age': 36, 'active': false },
9468 * { 'user': 'fred', 'age': 40, 'active': false }
9469 * ];
9470 *
9471 * // The `_.matches` iteratee shorthand.
9472 * _.every(users, { 'user': 'barney', 'active': false });
9473 * // => false
9474 *
9475 * // The `_.matchesProperty` iteratee shorthand.
9476 * _.every(users, ['active', false]);
9477 * // => true
9478 *
9479 * // The `_.property` iteratee shorthand.
9480 * _.every(users, 'active');
9481 * // => false
9482 */
9483 function every(collection, predicate, guard) {
9484 var func = isArray(collection) ? arrayEvery : baseEvery;
9485 if (guard && isIterateeCall(collection, predicate, guard)) {
9486 predicate = undefined$1;
9487 }
9488 return func(collection, getIteratee(predicate, 3));
9489 }
9490
9491 /**
9492 * Iterates over elements of `collection`, returning an array of all elements
9493 * `predicate` returns truthy for. The predicate is invoked with three
9494 * arguments: (value, index|key, collection).
9495 *
9496 * **Note:** Unlike `_.remove`, this method returns a new array.
9497 *
9498 * @static
9499 * @memberOf _
9500 * @since 0.1.0
9501 * @category Collection
9502 * @param {Array|Object} collection The collection to iterate over.
9503 * @param {Function} [predicate=_.identity] The function invoked per iteration.
9504 * @returns {Array} Returns the new filtered array.
9505 * @see _.reject
9506 * @example
9507 *
9508 * var users = [
9509 * { 'user': 'barney', 'age': 36, 'active': true },
9510 * { 'user': 'fred', 'age': 40, 'active': false }
9511 * ];
9512 *
9513 * _.filter(users, function(o) { return !o.active; });
9514 * // => objects for ['fred']
9515 *
9516 * // The `_.matches` iteratee shorthand.
9517 * _.filter(users, { 'age': 36, 'active': true });
9518 * // => objects for ['barney']
9519 *
9520 * // The `_.matchesProperty` iteratee shorthand.
9521 * _.filter(users, ['active', false]);
9522 * // => objects for ['fred']
9523 *
9524 * // The `_.property` iteratee shorthand.
9525 * _.filter(users, 'active');
9526 * // => objects for ['barney']
9527 *
9528 * // Combining several predicates using `_.overEvery` or `_.overSome`.
9529 * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]]));
9530 * // => objects for ['fred', 'barney']
9531 */
9532 function filter(collection, predicate) {
9533 var func = isArray(collection) ? arrayFilter : baseFilter;
9534 return func(collection, getIteratee(predicate, 3));
9535 }
9536
9537 /**
9538 * Iterates over elements of `collection`, returning the first element
9539 * `predicate` returns truthy for. The predicate is invoked with three
9540 * arguments: (value, index|key, collection).
9541 *
9542 * @static
9543 * @memberOf _
9544 * @since 0.1.0
9545 * @category Collection
9546 * @param {Array|Object} collection The collection to inspect.
9547 * @param {Function} [predicate=_.identity] The function invoked per iteration.
9548 * @param {number} [fromIndex=0] The index to search from.
9549 * @returns {*} Returns the matched element, else `undefined`.
9550 * @example
9551 *
9552 * var users = [
9553 * { 'user': 'barney', 'age': 36, 'active': true },
9554 * { 'user': 'fred', 'age': 40, 'active': false },
9555 * { 'user': 'pebbles', 'age': 1, 'active': true }
9556 * ];
9557 *
9558 * _.find(users, function(o) { return o.age < 40; });
9559 * // => object for 'barney'
9560 *
9561 * // The `_.matches` iteratee shorthand.
9562 * _.find(users, { 'age': 1, 'active': true });
9563 * // => object for 'pebbles'
9564 *
9565 * // The `_.matchesProperty` iteratee shorthand.
9566 * _.find(users, ['active', false]);
9567 * // => object for 'fred'
9568 *
9569 * // The `_.property` iteratee shorthand.
9570 * _.find(users, 'active');
9571 * // => object for 'barney'
9572 */
9573 var find = createFind(findIndex);
9574
9575 /**
9576 * This method is like `_.find` except that it iterates over elements of
9577 * `collection` from right to left.
9578 *
9579 * @static
9580 * @memberOf _
9581 * @since 2.0.0
9582 * @category Collection
9583 * @param {Array|Object} collection The collection to inspect.
9584 * @param {Function} [predicate=_.identity] The function invoked per iteration.
9585 * @param {number} [fromIndex=collection.length-1] The index to search from.
9586 * @returns {*} Returns the matched element, else `undefined`.
9587 * @example
9588 *
9589 * _.findLast([1, 2, 3, 4], function(n) {
9590 * return n % 2 == 1;
9591 * });
9592 * // => 3
9593 */
9594 var findLast = createFind(findLastIndex);
9595
9596 /**
9597 * Creates a flattened array of values by running each element in `collection`
9598 * thru `iteratee` and flattening the mapped results. The iteratee is invoked
9599 * with three arguments: (value, index|key, collection).
9600 *
9601 * @static
9602 * @memberOf _
9603 * @since 4.0.0
9604 * @category Collection
9605 * @param {Array|Object} collection The collection to iterate over.
9606 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9607 * @returns {Array} Returns the new flattened array.
9608 * @example
9609 *
9610 * function duplicate(n) {
9611 * return [n, n];
9612 * }
9613 *
9614 * _.flatMap([1, 2], duplicate);
9615 * // => [1, 1, 2, 2]
9616 */
9617 function flatMap(collection, iteratee) {
9618 return baseFlatten(map(collection, iteratee), 1);
9619 }
9620
9621 /**
9622 * This method is like `_.flatMap` except that it recursively flattens the
9623 * mapped results.
9624 *
9625 * @static
9626 * @memberOf _
9627 * @since 4.7.0
9628 * @category Collection
9629 * @param {Array|Object} collection The collection to iterate over.
9630 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9631 * @returns {Array} Returns the new flattened array.
9632 * @example
9633 *
9634 * function duplicate(n) {
9635 * return [[[n, n]]];
9636 * }
9637 *
9638 * _.flatMapDeep([1, 2], duplicate);
9639 * // => [1, 1, 2, 2]
9640 */
9641 function flatMapDeep(collection, iteratee) {
9642 return baseFlatten(map(collection, iteratee), INFINITY);
9643 }
9644
9645 /**
9646 * This method is like `_.flatMap` except that it recursively flattens the
9647 * mapped results up to `depth` times.
9648 *
9649 * @static
9650 * @memberOf _
9651 * @since 4.7.0
9652 * @category Collection
9653 * @param {Array|Object} collection The collection to iterate over.
9654 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9655 * @param {number} [depth=1] The maximum recursion depth.
9656 * @returns {Array} Returns the new flattened array.
9657 * @example
9658 *
9659 * function duplicate(n) {
9660 * return [[[n, n]]];
9661 * }
9662 *
9663 * _.flatMapDepth([1, 2], duplicate, 2);
9664 * // => [[1, 1], [2, 2]]
9665 */
9666 function flatMapDepth(collection, iteratee, depth) {
9667 depth = depth === undefined$1 ? 1 : toInteger(depth);
9668 return baseFlatten(map(collection, iteratee), depth);
9669 }
9670
9671 /**
9672 * Iterates over elements of `collection` and invokes `iteratee` for each element.
9673 * The iteratee is invoked with three arguments: (value, index|key, collection).
9674 * Iteratee functions may exit iteration early by explicitly returning `false`.
9675 *
9676 * **Note:** As with other "Collections" methods, objects with a "length"
9677 * property are iterated like arrays. To avoid this behavior use `_.forIn`
9678 * or `_.forOwn` for object iteration.
9679 *
9680 * @static
9681 * @memberOf _
9682 * @since 0.1.0
9683 * @alias each
9684 * @category Collection
9685 * @param {Array|Object} collection The collection to iterate over.
9686 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9687 * @returns {Array|Object} Returns `collection`.
9688 * @see _.forEachRight
9689 * @example
9690 *
9691 * _.forEach([1, 2], function(value) {
9692 * console.log(value);
9693 * });
9694 * // => Logs `1` then `2`.
9695 *
9696 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
9697 * console.log(key);
9698 * });
9699 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
9700 */
9701 function forEach(collection, iteratee) {
9702 var func = isArray(collection) ? arrayEach : baseEach;
9703 return func(collection, getIteratee(iteratee, 3));
9704 }
9705
9706 /**
9707 * This method is like `_.forEach` except that it iterates over elements of
9708 * `collection` from right to left.
9709 *
9710 * @static
9711 * @memberOf _
9712 * @since 2.0.0
9713 * @alias eachRight
9714 * @category Collection
9715 * @param {Array|Object} collection The collection to iterate over.
9716 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9717 * @returns {Array|Object} Returns `collection`.
9718 * @see _.forEach
9719 * @example
9720 *
9721 * _.forEachRight([1, 2], function(value) {
9722 * console.log(value);
9723 * });
9724 * // => Logs `2` then `1`.
9725 */
9726 function forEachRight(collection, iteratee) {
9727 var func = isArray(collection) ? arrayEachRight : baseEachRight;
9728 return func(collection, getIteratee(iteratee, 3));
9729 }
9730
9731 /**
9732 * Creates an object composed of keys generated from the results of running
9733 * each element of `collection` thru `iteratee`. The order of grouped values
9734 * is determined by the order they occur in `collection`. The corresponding
9735 * value of each key is an array of elements responsible for generating the
9736 * key. The iteratee is invoked with one argument: (value).
9737 *
9738 * @static
9739 * @memberOf _
9740 * @since 0.1.0
9741 * @category Collection
9742 * @param {Array|Object} collection The collection to iterate over.
9743 * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9744 * @returns {Object} Returns the composed aggregate object.
9745 * @example
9746 *
9747 * _.groupBy([6.1, 4.2, 6.3], Math.floor);
9748 * // => { '4': [4.2], '6': [6.1, 6.3] }
9749 *
9750 * // The `_.property` iteratee shorthand.
9751 * _.groupBy(['one', 'two', 'three'], 'length');
9752 * // => { '3': ['one', 'two'], '5': ['three'] }
9753 */
9754 var groupBy = createAggregator(function(result, value, key) {
9755 if (hasOwnProperty.call(result, key)) {
9756 result[key].push(value);
9757 } else {
9758 baseAssignValue(result, key, [value]);
9759 }
9760 });
9761
9762 /**
9763 * Checks if `value` is in `collection`. If `collection` is a string, it's
9764 * checked for a substring of `value`, otherwise
9765 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
9766 * is used for equality comparisons. If `fromIndex` is negative, it's used as
9767 * the offset from the end of `collection`.
9768 *
9769 * @static
9770 * @memberOf _
9771 * @since 0.1.0
9772 * @category Collection
9773 * @param {Array|Object|string} collection The collection to inspect.
9774 * @param {*} value The value to search for.
9775 * @param {number} [fromIndex=0] The index to search from.
9776 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
9777 * @returns {boolean} Returns `true` if `value` is found, else `false`.
9778 * @example
9779 *
9780 * _.includes([1, 2, 3], 1);
9781 * // => true
9782 *
9783 * _.includes([1, 2, 3], 1, 2);
9784 * // => false
9785 *
9786 * _.includes({ 'a': 1, 'b': 2 }, 1);
9787 * // => true
9788 *
9789 * _.includes('abcd', 'bc');
9790 * // => true
9791 */
9792 function includes(collection, value, fromIndex, guard) {
9793 collection = isArrayLike(collection) ? collection : values(collection);
9794 fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
9795
9796 var length = collection.length;
9797 if (fromIndex < 0) {
9798 fromIndex = nativeMax(length + fromIndex, 0);
9799 }
9800 return isString(collection)
9801 ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
9802 : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
9803 }
9804
9805 /**
9806 * Invokes the method at `path` of each element in `collection`, returning
9807 * an array of the results of each invoked method. Any additional arguments
9808 * are provided to each invoked method. If `path` is a function, it's invoked
9809 * for, and `this` bound to, each element in `collection`.
9810 *
9811 * @static
9812 * @memberOf _
9813 * @since 4.0.0
9814 * @category Collection
9815 * @param {Array|Object} collection The collection to iterate over.
9816 * @param {Array|Function|string} path The path of the method to invoke or
9817 * the function invoked per iteration.
9818 * @param {...*} [args] The arguments to invoke each method with.
9819 * @returns {Array} Returns the array of results.
9820 * @example
9821 *
9822 * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
9823 * // => [[1, 5, 7], [1, 2, 3]]
9824 *
9825 * _.invokeMap([123, 456], String.prototype.split, '');
9826 * // => [['1', '2', '3'], ['4', '5', '6']]
9827 */
9828 var invokeMap = baseRest(function(collection, path, args) {
9829 var index = -1,
9830 isFunc = typeof path == 'function',
9831 result = isArrayLike(collection) ? Array(collection.length) : [];
9832
9833 baseEach(collection, function(value) {
9834 result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
9835 });
9836 return result;
9837 });
9838
9839 /**
9840 * Creates an object composed of keys generated from the results of running
9841 * each element of `collection` thru `iteratee`. The corresponding value of
9842 * each key is the last element responsible for generating the key. The
9843 * iteratee is invoked with one argument: (value).
9844 *
9845 * @static
9846 * @memberOf _
9847 * @since 4.0.0
9848 * @category Collection
9849 * @param {Array|Object} collection The collection to iterate over.
9850 * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9851 * @returns {Object} Returns the composed aggregate object.
9852 * @example
9853 *
9854 * var array = [
9855 * { 'dir': 'left', 'code': 97 },
9856 * { 'dir': 'right', 'code': 100 }
9857 * ];
9858 *
9859 * _.keyBy(array, function(o) {
9860 * return String.fromCharCode(o.code);
9861 * });
9862 * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
9863 *
9864 * _.keyBy(array, 'dir');
9865 * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
9866 */
9867 var keyBy = createAggregator(function(result, value, key) {
9868 baseAssignValue(result, key, value);
9869 });
9870
9871 /**
9872 * Creates an array of values by running each element in `collection` thru
9873 * `iteratee`. The iteratee is invoked with three arguments:
9874 * (value, index|key, collection).
9875 *
9876 * Many lodash methods are guarded to work as iteratees for methods like
9877 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
9878 *
9879 * The guarded methods are:
9880 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
9881 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
9882 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
9883 * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
9884 *
9885 * @static
9886 * @memberOf _
9887 * @since 0.1.0
9888 * @category Collection
9889 * @param {Array|Object} collection The collection to iterate over.
9890 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9891 * @returns {Array} Returns the new mapped array.
9892 * @example
9893 *
9894 * function square(n) {
9895 * return n * n;
9896 * }
9897 *
9898 * _.map([4, 8], square);
9899 * // => [16, 64]
9900 *
9901 * _.map({ 'a': 4, 'b': 8 }, square);
9902 * // => [16, 64] (iteration order is not guaranteed)
9903 *
9904 * var users = [
9905 * { 'user': 'barney' },
9906 * { 'user': 'fred' }
9907 * ];
9908 *
9909 * // The `_.property` iteratee shorthand.
9910 * _.map(users, 'user');
9911 * // => ['barney', 'fred']
9912 */
9913 function map(collection, iteratee) {
9914 var func = isArray(collection) ? arrayMap : baseMap;
9915 return func(collection, getIteratee(iteratee, 3));
9916 }
9917
9918 /**
9919 * This method is like `_.sortBy` except that it allows specifying the sort
9920 * orders of the iteratees to sort by. If `orders` is unspecified, all values
9921 * are sorted in ascending order. Otherwise, specify an order of "desc" for
9922 * descending or "asc" for ascending sort order of corresponding values.
9923 *
9924 * @static
9925 * @memberOf _
9926 * @since 4.0.0
9927 * @category Collection
9928 * @param {Array|Object} collection The collection to iterate over.
9929 * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
9930 * The iteratees to sort by.
9931 * @param {string[]} [orders] The sort orders of `iteratees`.
9932 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
9933 * @returns {Array} Returns the new sorted array.
9934 * @example
9935 *
9936 * var users = [
9937 * { 'user': 'fred', 'age': 48 },
9938 * { 'user': 'barney', 'age': 34 },
9939 * { 'user': 'fred', 'age': 40 },
9940 * { 'user': 'barney', 'age': 36 }
9941 * ];
9942 *
9943 * // Sort by `user` in ascending order and by `age` in descending order.
9944 * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
9945 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
9946 */
9947 function orderBy(collection, iteratees, orders, guard) {
9948 if (collection == null) {
9949 return [];
9950 }
9951 if (!isArray(iteratees)) {
9952 iteratees = iteratees == null ? [] : [iteratees];
9953 }
9954 orders = guard ? undefined$1 : orders;
9955 if (!isArray(orders)) {
9956 orders = orders == null ? [] : [orders];
9957 }
9958 return baseOrderBy(collection, iteratees, orders);
9959 }
9960
9961 /**
9962 * Creates an array of elements split into two groups, the first of which
9963 * contains elements `predicate` returns truthy for, the second of which
9964 * contains elements `predicate` returns falsey for. The predicate is
9965 * invoked with one argument: (value).
9966 *
9967 * @static
9968 * @memberOf _
9969 * @since 3.0.0
9970 * @category Collection
9971 * @param {Array|Object} collection The collection to iterate over.
9972 * @param {Function} [predicate=_.identity] The function invoked per iteration.
9973 * @returns {Array} Returns the array of grouped elements.
9974 * @example
9975 *
9976 * var users = [
9977 * { 'user': 'barney', 'age': 36, 'active': false },
9978 * { 'user': 'fred', 'age': 40, 'active': true },
9979 * { 'user': 'pebbles', 'age': 1, 'active': false }
9980 * ];
9981 *
9982 * _.partition(users, function(o) { return o.active; });
9983 * // => objects for [['fred'], ['barney', 'pebbles']]
9984 *
9985 * // The `_.matches` iteratee shorthand.
9986 * _.partition(users, { 'age': 1, 'active': false });
9987 * // => objects for [['pebbles'], ['barney', 'fred']]
9988 *
9989 * // The `_.matchesProperty` iteratee shorthand.
9990 * _.partition(users, ['active', false]);
9991 * // => objects for [['barney', 'pebbles'], ['fred']]
9992 *
9993 * // The `_.property` iteratee shorthand.
9994 * _.partition(users, 'active');
9995 * // => objects for [['fred'], ['barney', 'pebbles']]
9996 */
9997 var partition = createAggregator(function(result, value, key) {
9998 result[key ? 0 : 1].push(value);
9999 }, function() { return [[], []]; });
10000
10001 /**
10002 * Reduces `collection` to a value which is the accumulated result of running
10003 * each element in `collection` thru `iteratee`, where each successive
10004 * invocation is supplied the return value of the previous. If `accumulator`
10005 * is not given, the first element of `collection` is used as the initial
10006 * value. The iteratee is invoked with four arguments:
10007 * (accumulator, value, index|key, collection).
10008 *
10009 * Many lodash methods are guarded to work as iteratees for methods like
10010 * `_.reduce`, `_.reduceRight`, and `_.transform`.
10011 *
10012 * The guarded methods are:
10013 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
10014 * and `sortBy`
10015 *
10016 * @static
10017 * @memberOf _
10018 * @since 0.1.0
10019 * @category Collection
10020 * @param {Array|Object} collection The collection to iterate over.
10021 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
10022 * @param {*} [accumulator] The initial value.
10023 * @returns {*} Returns the accumulated value.
10024 * @see _.reduceRight
10025 * @example
10026 *
10027 * _.reduce([1, 2], function(sum, n) {
10028 * return sum + n;
10029 * }, 0);
10030 * // => 3
10031 *
10032 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
10033 * (result[value] || (result[value] = [])).push(key);
10034 * return result;
10035 * }, {});
10036 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
10037 */
10038 function reduce(collection, iteratee, accumulator) {
10039 var func = isArray(collection) ? arrayReduce : baseReduce,
10040 initAccum = arguments.length < 3;
10041
10042 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
10043 }
10044
10045 /**
10046 * This method is like `_.reduce` except that it iterates over elements of
10047 * `collection` from right to left.
10048 *
10049 * @static
10050 * @memberOf _
10051 * @since 0.1.0
10052 * @category Collection
10053 * @param {Array|Object} collection The collection to iterate over.
10054 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
10055 * @param {*} [accumulator] The initial value.
10056 * @returns {*} Returns the accumulated value.
10057 * @see _.reduce
10058 * @example
10059 *
10060 * var array = [[0, 1], [2, 3], [4, 5]];
10061 *
10062 * _.reduceRight(array, function(flattened, other) {
10063 * return flattened.concat(other);
10064 * }, []);
10065 * // => [4, 5, 2, 3, 0, 1]
10066 */
10067 function reduceRight(collection, iteratee, accumulator) {
10068 var func = isArray(collection) ? arrayReduceRight : baseReduce,
10069 initAccum = arguments.length < 3;
10070
10071 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
10072 }
10073
10074 /**
10075 * The opposite of `_.filter`; this method returns the elements of `collection`
10076 * that `predicate` does **not** return truthy for.
10077 *
10078 * @static
10079 * @memberOf _
10080 * @since 0.1.0
10081 * @category Collection
10082 * @param {Array|Object} collection The collection to iterate over.
10083 * @param {Function} [predicate=_.identity] The function invoked per iteration.
10084 * @returns {Array} Returns the new filtered array.
10085 * @see _.filter
10086 * @example
10087 *
10088 * var users = [
10089 * { 'user': 'barney', 'age': 36, 'active': false },
10090 * { 'user': 'fred', 'age': 40, 'active': true }
10091 * ];
10092 *
10093 * _.reject(users, function(o) { return !o.active; });
10094 * // => objects for ['fred']
10095 *
10096 * // The `_.matches` iteratee shorthand.
10097 * _.reject(users, { 'age': 40, 'active': true });
10098 * // => objects for ['barney']
10099 *
10100 * // The `_.matchesProperty` iteratee shorthand.
10101 * _.reject(users, ['active', false]);
10102 * // => objects for ['fred']
10103 *
10104 * // The `_.property` iteratee shorthand.
10105 * _.reject(users, 'active');
10106 * // => objects for ['barney']
10107 */
10108 function reject(collection, predicate) {
10109 var func = isArray(collection) ? arrayFilter : baseFilter;
10110 return func(collection, negate(getIteratee(predicate, 3)));
10111 }
10112
10113 /**
10114 * Gets a random element from `collection`.
10115 *
10116 * @static
10117 * @memberOf _
10118 * @since 2.0.0
10119 * @category Collection
10120 * @param {Array|Object} collection The collection to sample.
10121 * @returns {*} Returns the random element.
10122 * @example
10123 *
10124 * _.sample([1, 2, 3, 4]);
10125 * // => 2
10126 */
10127 function sample(collection) {
10128 var func = isArray(collection) ? arraySample : baseSample;
10129 return func(collection);
10130 }
10131
10132 /**
10133 * Gets `n` random elements at unique keys from `collection` up to the
10134 * size of `collection`.
10135 *
10136 * @static
10137 * @memberOf _
10138 * @since 4.0.0
10139 * @category Collection
10140 * @param {Array|Object} collection The collection to sample.
10141 * @param {number} [n=1] The number of elements to sample.
10142 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10143 * @returns {Array} Returns the random elements.
10144 * @example
10145 *
10146 * _.sampleSize([1, 2, 3], 2);
10147 * // => [3, 1]
10148 *
10149 * _.sampleSize([1, 2, 3], 4);
10150 * // => [2, 3, 1]
10151 */
10152 function sampleSize(collection, n, guard) {
10153 if ((guard ? isIterateeCall(collection, n, guard) : n === undefined$1)) {
10154 n = 1;
10155 } else {
10156 n = toInteger(n);
10157 }
10158 var func = isArray(collection) ? arraySampleSize : baseSampleSize;
10159 return func(collection, n);
10160 }
10161
10162 /**
10163 * Creates an array of shuffled values, using a version of the
10164 * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
10165 *
10166 * @static
10167 * @memberOf _
10168 * @since 0.1.0
10169 * @category Collection
10170 * @param {Array|Object} collection The collection to shuffle.
10171 * @returns {Array} Returns the new shuffled array.
10172 * @example
10173 *
10174 * _.shuffle([1, 2, 3, 4]);
10175 * // => [4, 1, 3, 2]
10176 */
10177 function shuffle(collection) {
10178 var func = isArray(collection) ? arrayShuffle : baseShuffle;
10179 return func(collection);
10180 }
10181
10182 /**
10183 * Gets the size of `collection` by returning its length for array-like
10184 * values or the number of own enumerable string keyed properties for objects.
10185 *
10186 * @static
10187 * @memberOf _
10188 * @since 0.1.0
10189 * @category Collection
10190 * @param {Array|Object|string} collection The collection to inspect.
10191 * @returns {number} Returns the collection size.
10192 * @example
10193 *
10194 * _.size([1, 2, 3]);
10195 * // => 3
10196 *
10197 * _.size({ 'a': 1, 'b': 2 });
10198 * // => 2
10199 *
10200 * _.size('pebbles');
10201 * // => 7
10202 */
10203 function size(collection) {
10204 if (collection == null) {
10205 return 0;
10206 }
10207 if (isArrayLike(collection)) {
10208 return isString(collection) ? stringSize(collection) : collection.length;
10209 }
10210 var tag = getTag(collection);
10211 if (tag == mapTag || tag == setTag) {
10212 return collection.size;
10213 }
10214 return baseKeys(collection).length;
10215 }
10216
10217 /**
10218 * Checks if `predicate` returns truthy for **any** element of `collection`.
10219 * Iteration is stopped once `predicate` returns truthy. The predicate is
10220 * invoked with three arguments: (value, index|key, collection).
10221 *
10222 * @static
10223 * @memberOf _
10224 * @since 0.1.0
10225 * @category Collection
10226 * @param {Array|Object} collection The collection to iterate over.
10227 * @param {Function} [predicate=_.identity] The function invoked per iteration.
10228 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10229 * @returns {boolean} Returns `true` if any element passes the predicate check,
10230 * else `false`.
10231 * @example
10232 *
10233 * _.some([null, 0, 'yes', false], Boolean);
10234 * // => true
10235 *
10236 * var users = [
10237 * { 'user': 'barney', 'active': true },
10238 * { 'user': 'fred', 'active': false }
10239 * ];
10240 *
10241 * // The `_.matches` iteratee shorthand.
10242 * _.some(users, { 'user': 'barney', 'active': false });
10243 * // => false
10244 *
10245 * // The `_.matchesProperty` iteratee shorthand.
10246 * _.some(users, ['active', false]);
10247 * // => true
10248 *
10249 * // The `_.property` iteratee shorthand.
10250 * _.some(users, 'active');
10251 * // => true
10252 */
10253 function some(collection, predicate, guard) {
10254 var func = isArray(collection) ? arraySome : baseSome;
10255 if (guard && isIterateeCall(collection, predicate, guard)) {
10256 predicate = undefined$1;
10257 }
10258 return func(collection, getIteratee(predicate, 3));
10259 }
10260
10261 /**
10262 * Creates an array of elements, sorted in ascending order by the results of
10263 * running each element in a collection thru each iteratee. This method
10264 * performs a stable sort, that is, it preserves the original sort order of
10265 * equal elements. The iteratees are invoked with one argument: (value).
10266 *
10267 * @static
10268 * @memberOf _
10269 * @since 0.1.0
10270 * @category Collection
10271 * @param {Array|Object} collection The collection to iterate over.
10272 * @param {...(Function|Function[])} [iteratees=[_.identity]]
10273 * The iteratees to sort by.
10274 * @returns {Array} Returns the new sorted array.
10275 * @example
10276 *
10277 * var users = [
10278 * { 'user': 'fred', 'age': 48 },
10279 * { 'user': 'barney', 'age': 36 },
10280 * { 'user': 'fred', 'age': 30 },
10281 * { 'user': 'barney', 'age': 34 }
10282 * ];
10283 *
10284 * _.sortBy(users, [function(o) { return o.user; }]);
10285 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]]
10286 *
10287 * _.sortBy(users, ['user', 'age']);
10288 * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
10289 */
10290 var sortBy = baseRest(function(collection, iteratees) {
10291 if (collection == null) {
10292 return [];
10293 }
10294 var length = iteratees.length;
10295 if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
10296 iteratees = [];
10297 } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
10298 iteratees = [iteratees[0]];
10299 }
10300 return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
10301 });
10302
10303 /*------------------------------------------------------------------------*/
10304
10305 /**
10306 * Gets the timestamp of the number of milliseconds that have elapsed since
10307 * the Unix epoch (1 January 1970 00:00:00 UTC).
10308 *
10309 * @static
10310 * @memberOf _
10311 * @since 2.4.0
10312 * @category Date
10313 * @returns {number} Returns the timestamp.
10314 * @example
10315 *
10316 * _.defer(function(stamp) {
10317 * console.log(_.now() - stamp);
10318 * }, _.now());
10319 * // => Logs the number of milliseconds it took for the deferred invocation.
10320 */
10321 var now = ctxNow || function() {
10322 return root.Date.now();
10323 };
10324
10325 /*------------------------------------------------------------------------*/
10326
10327 /**
10328 * The opposite of `_.before`; this method creates a function that invokes
10329 * `func` once it's called `n` or more times.
10330 *
10331 * @static
10332 * @memberOf _
10333 * @since 0.1.0
10334 * @category Function
10335 * @param {number} n The number of calls before `func` is invoked.
10336 * @param {Function} func The function to restrict.
10337 * @returns {Function} Returns the new restricted function.
10338 * @example
10339 *
10340 * var saves = ['profile', 'settings'];
10341 *
10342 * var done = _.after(saves.length, function() {
10343 * console.log('done saving!');
10344 * });
10345 *
10346 * _.forEach(saves, function(type) {
10347 * asyncSave({ 'type': type, 'complete': done });
10348 * });
10349 * // => Logs 'done saving!' after the two async saves have completed.
10350 */
10351 function after(n, func) {
10352 if (typeof func != 'function') {
10353 throw new TypeError(FUNC_ERROR_TEXT);
10354 }
10355 n = toInteger(n);
10356 return function() {
10357 if (--n < 1) {
10358 return func.apply(this, arguments);
10359 }
10360 };
10361 }
10362
10363 /**
10364 * Creates a function that invokes `func`, with up to `n` arguments,
10365 * ignoring any additional arguments.
10366 *
10367 * @static
10368 * @memberOf _
10369 * @since 3.0.0
10370 * @category Function
10371 * @param {Function} func The function to cap arguments for.
10372 * @param {number} [n=func.length] The arity cap.
10373 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10374 * @returns {Function} Returns the new capped function.
10375 * @example
10376 *
10377 * _.map(['6', '8', '10'], _.ary(parseInt, 1));
10378 * // => [6, 8, 10]
10379 */
10380 function ary(func, n, guard) {
10381 n = guard ? undefined$1 : n;
10382 n = (func && n == null) ? func.length : n;
10383 return createWrap(func, WRAP_ARY_FLAG, undefined$1, undefined$1, undefined$1, undefined$1, n);
10384 }
10385
10386 /**
10387 * Creates a function that invokes `func`, with the `this` binding and arguments
10388 * of the created function, while it's called less than `n` times. Subsequent
10389 * calls to the created function return the result of the last `func` invocation.
10390 *
10391 * @static
10392 * @memberOf _
10393 * @since 3.0.0
10394 * @category Function
10395 * @param {number} n The number of calls at which `func` is no longer invoked.
10396 * @param {Function} func The function to restrict.
10397 * @returns {Function} Returns the new restricted function.
10398 * @example
10399 *
10400 * jQuery(element).on('click', _.before(5, addContactToList));
10401 * // => Allows adding up to 4 contacts to the list.
10402 */
10403 function before(n, func) {
10404 var result;
10405 if (typeof func != 'function') {
10406 throw new TypeError(FUNC_ERROR_TEXT);
10407 }
10408 n = toInteger(n);
10409 return function() {
10410 if (--n > 0) {
10411 result = func.apply(this, arguments);
10412 }
10413 if (n <= 1) {
10414 func = undefined$1;
10415 }
10416 return result;
10417 };
10418 }
10419
10420 /**
10421 * Creates a function that invokes `func` with the `this` binding of `thisArg`
10422 * and `partials` prepended to the arguments it receives.
10423 *
10424 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
10425 * may be used as a placeholder for partially applied arguments.
10426 *
10427 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
10428 * property of bound functions.
10429 *
10430 * @static
10431 * @memberOf _
10432 * @since 0.1.0
10433 * @category Function
10434 * @param {Function} func The function to bind.
10435 * @param {*} thisArg The `this` binding of `func`.
10436 * @param {...*} [partials] The arguments to be partially applied.
10437 * @returns {Function} Returns the new bound function.
10438 * @example
10439 *
10440 * function greet(greeting, punctuation) {
10441 * return greeting + ' ' + this.user + punctuation;
10442 * }
10443 *
10444 * var object = { 'user': 'fred' };
10445 *
10446 * var bound = _.bind(greet, object, 'hi');
10447 * bound('!');
10448 * // => 'hi fred!'
10449 *
10450 * // Bound with placeholders.
10451 * var bound = _.bind(greet, object, _, '!');
10452 * bound('hi');
10453 * // => 'hi fred!'
10454 */
10455 var bind = baseRest(function(func, thisArg, partials) {
10456 var bitmask = WRAP_BIND_FLAG;
10457 if (partials.length) {
10458 var holders = replaceHolders(partials, getHolder(bind));
10459 bitmask |= WRAP_PARTIAL_FLAG;
10460 }
10461 return createWrap(func, bitmask, thisArg, partials, holders);
10462 });
10463
10464 /**
10465 * Creates a function that invokes the method at `object[key]` with `partials`
10466 * prepended to the arguments it receives.
10467 *
10468 * This method differs from `_.bind` by allowing bound functions to reference
10469 * methods that may be redefined or don't yet exist. See
10470 * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
10471 * for more details.
10472 *
10473 * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
10474 * builds, may be used as a placeholder for partially applied arguments.
10475 *
10476 * @static
10477 * @memberOf _
10478 * @since 0.10.0
10479 * @category Function
10480 * @param {Object} object The object to invoke the method on.
10481 * @param {string} key The key of the method.
10482 * @param {...*} [partials] The arguments to be partially applied.
10483 * @returns {Function} Returns the new bound function.
10484 * @example
10485 *
10486 * var object = {
10487 * 'user': 'fred',
10488 * 'greet': function(greeting, punctuation) {
10489 * return greeting + ' ' + this.user + punctuation;
10490 * }
10491 * };
10492 *
10493 * var bound = _.bindKey(object, 'greet', 'hi');
10494 * bound('!');
10495 * // => 'hi fred!'
10496 *
10497 * object.greet = function(greeting, punctuation) {
10498 * return greeting + 'ya ' + this.user + punctuation;
10499 * };
10500 *
10501 * bound('!');
10502 * // => 'hiya fred!'
10503 *
10504 * // Bound with placeholders.
10505 * var bound = _.bindKey(object, 'greet', _, '!');
10506 * bound('hi');
10507 * // => 'hiya fred!'
10508 */
10509 var bindKey = baseRest(function(object, key, partials) {
10510 var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
10511 if (partials.length) {
10512 var holders = replaceHolders(partials, getHolder(bindKey));
10513 bitmask |= WRAP_PARTIAL_FLAG;
10514 }
10515 return createWrap(key, bitmask, object, partials, holders);
10516 });
10517
10518 /**
10519 * Creates a function that accepts arguments of `func` and either invokes
10520 * `func` returning its result, if at least `arity` number of arguments have
10521 * been provided, or returns a function that accepts the remaining `func`
10522 * arguments, and so on. The arity of `func` may be specified if `func.length`
10523 * is not sufficient.
10524 *
10525 * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
10526 * may be used as a placeholder for provided arguments.
10527 *
10528 * **Note:** This method doesn't set the "length" property of curried functions.
10529 *
10530 * @static
10531 * @memberOf _
10532 * @since 2.0.0
10533 * @category Function
10534 * @param {Function} func The function to curry.
10535 * @param {number} [arity=func.length] The arity of `func`.
10536 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10537 * @returns {Function} Returns the new curried function.
10538 * @example
10539 *
10540 * var abc = function(a, b, c) {
10541 * return [a, b, c];
10542 * };
10543 *
10544 * var curried = _.curry(abc);
10545 *
10546 * curried(1)(2)(3);
10547 * // => [1, 2, 3]
10548 *
10549 * curried(1, 2)(3);
10550 * // => [1, 2, 3]
10551 *
10552 * curried(1, 2, 3);
10553 * // => [1, 2, 3]
10554 *
10555 * // Curried with placeholders.
10556 * curried(1)(_, 3)(2);
10557 * // => [1, 2, 3]
10558 */
10559 function curry(func, arity, guard) {
10560 arity = guard ? undefined$1 : arity;
10561 var result = createWrap(func, WRAP_CURRY_FLAG, undefined$1, undefined$1, undefined$1, undefined$1, undefined$1, arity);
10562 result.placeholder = curry.placeholder;
10563 return result;
10564 }
10565
10566 /**
10567 * This method is like `_.curry` except that arguments are applied to `func`
10568 * in the manner of `_.partialRight` instead of `_.partial`.
10569 *
10570 * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
10571 * builds, may be used as a placeholder for provided arguments.
10572 *
10573 * **Note:** This method doesn't set the "length" property of curried functions.
10574 *
10575 * @static
10576 * @memberOf _
10577 * @since 3.0.0
10578 * @category Function
10579 * @param {Function} func The function to curry.
10580 * @param {number} [arity=func.length] The arity of `func`.
10581 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10582 * @returns {Function} Returns the new curried function.
10583 * @example
10584 *
10585 * var abc = function(a, b, c) {
10586 * return [a, b, c];
10587 * };
10588 *
10589 * var curried = _.curryRight(abc);
10590 *
10591 * curried(3)(2)(1);
10592 * // => [1, 2, 3]
10593 *
10594 * curried(2, 3)(1);
10595 * // => [1, 2, 3]
10596 *
10597 * curried(1, 2, 3);
10598 * // => [1, 2, 3]
10599 *
10600 * // Curried with placeholders.
10601 * curried(3)(1, _)(2);
10602 * // => [1, 2, 3]
10603 */
10604 function curryRight(func, arity, guard) {
10605 arity = guard ? undefined$1 : arity;
10606 var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined$1, undefined$1, undefined$1, undefined$1, undefined$1, arity);
10607 result.placeholder = curryRight.placeholder;
10608 return result;
10609 }
10610
10611 /**
10612 * Creates a debounced function that delays invoking `func` until after `wait`
10613 * milliseconds have elapsed since the last time the debounced function was
10614 * invoked. The debounced function comes with a `cancel` method to cancel
10615 * delayed `func` invocations and a `flush` method to immediately invoke them.
10616 * Provide `options` to indicate whether `func` should be invoked on the
10617 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
10618 * with the last arguments provided to the debounced function. Subsequent
10619 * calls to the debounced function return the result of the last `func`
10620 * invocation.
10621 *
10622 * **Note:** If `leading` and `trailing` options are `true`, `func` is
10623 * invoked on the trailing edge of the timeout only if the debounced function
10624 * is invoked more than once during the `wait` timeout.
10625 *
10626 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
10627 * until to the next tick, similar to `setTimeout` with a timeout of `0`.
10628 *
10629 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
10630 * for details over the differences between `_.debounce` and `_.throttle`.
10631 *
10632 * @static
10633 * @memberOf _
10634 * @since 0.1.0
10635 * @category Function
10636 * @param {Function} func The function to debounce.
10637 * @param {number} [wait=0] The number of milliseconds to delay.
10638 * @param {Object} [options={}] The options object.
10639 * @param {boolean} [options.leading=false]
10640 * Specify invoking on the leading edge of the timeout.
10641 * @param {number} [options.maxWait]
10642 * The maximum time `func` is allowed to be delayed before it's invoked.
10643 * @param {boolean} [options.trailing=true]
10644 * Specify invoking on the trailing edge of the timeout.
10645 * @returns {Function} Returns the new debounced function.
10646 * @example
10647 *
10648 * // Avoid costly calculations while the window size is in flux.
10649 * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
10650 *
10651 * // Invoke `sendMail` when clicked, debouncing subsequent calls.
10652 * jQuery(element).on('click', _.debounce(sendMail, 300, {
10653 * 'leading': true,
10654 * 'trailing': false
10655 * }));
10656 *
10657 * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
10658 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
10659 * var source = new EventSource('/stream');
10660 * jQuery(source).on('message', debounced);
10661 *
10662 * // Cancel the trailing debounced invocation.
10663 * jQuery(window).on('popstate', debounced.cancel);
10664 */
10665 function debounce(func, wait, options) {
10666 var lastArgs,
10667 lastThis,
10668 maxWait,
10669 result,
10670 timerId,
10671 lastCallTime,
10672 lastInvokeTime = 0,
10673 leading = false,
10674 maxing = false,
10675 trailing = true;
10676
10677 if (typeof func != 'function') {
10678 throw new TypeError(FUNC_ERROR_TEXT);
10679 }
10680 wait = toNumber(wait) || 0;
10681 if (isObject(options)) {
10682 leading = !!options.leading;
10683 maxing = 'maxWait' in options;
10684 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
10685 trailing = 'trailing' in options ? !!options.trailing : trailing;
10686 }
10687
10688 function invokeFunc(time) {
10689 var args = lastArgs,
10690 thisArg = lastThis;
10691
10692 lastArgs = lastThis = undefined$1;
10693 lastInvokeTime = time;
10694 result = func.apply(thisArg, args);
10695 return result;
10696 }
10697
10698 function leadingEdge(time) {
10699 // Reset any `maxWait` timer.
10700 lastInvokeTime = time;
10701 // Start the timer for the trailing edge.
10702 timerId = setTimeout(timerExpired, wait);
10703 // Invoke the leading edge.
10704 return leading ? invokeFunc(time) : result;
10705 }
10706
10707 function remainingWait(time) {
10708 var timeSinceLastCall = time - lastCallTime,
10709 timeSinceLastInvoke = time - lastInvokeTime,
10710 timeWaiting = wait - timeSinceLastCall;
10711
10712 return maxing
10713 ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
10714 : timeWaiting;
10715 }
10716
10717 function shouldInvoke(time) {
10718 var timeSinceLastCall = time - lastCallTime,
10719 timeSinceLastInvoke = time - lastInvokeTime;
10720
10721 // Either this is the first call, activity has stopped and we're at the
10722 // trailing edge, the system time has gone backwards and we're treating
10723 // it as the trailing edge, or we've hit the `maxWait` limit.
10724 return (lastCallTime === undefined$1 || (timeSinceLastCall >= wait) ||
10725 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
10726 }
10727
10728 function timerExpired() {
10729 var time = now();
10730 if (shouldInvoke(time)) {
10731 return trailingEdge(time);
10732 }
10733 // Restart the timer.
10734 timerId = setTimeout(timerExpired, remainingWait(time));
10735 }
10736
10737 function trailingEdge(time) {
10738 timerId = undefined$1;
10739
10740 // Only invoke if we have `lastArgs` which means `func` has been
10741 // debounced at least once.
10742 if (trailing && lastArgs) {
10743 return invokeFunc(time);
10744 }
10745 lastArgs = lastThis = undefined$1;
10746 return result;
10747 }
10748
10749 function cancel() {
10750 if (timerId !== undefined$1) {
10751 clearTimeout(timerId);
10752 }
10753 lastInvokeTime = 0;
10754 lastArgs = lastCallTime = lastThis = timerId = undefined$1;
10755 }
10756
10757 function flush() {
10758 return timerId === undefined$1 ? result : trailingEdge(now());
10759 }
10760
10761 function debounced() {
10762 var time = now(),
10763 isInvoking = shouldInvoke(time);
10764
10765 lastArgs = arguments;
10766 lastThis = this;
10767 lastCallTime = time;
10768
10769 if (isInvoking) {
10770 if (timerId === undefined$1) {
10771 return leadingEdge(lastCallTime);
10772 }
10773 if (maxing) {
10774 // Handle invocations in a tight loop.
10775 clearTimeout(timerId);
10776 timerId = setTimeout(timerExpired, wait);
10777 return invokeFunc(lastCallTime);
10778 }
10779 }
10780 if (timerId === undefined$1) {
10781 timerId = setTimeout(timerExpired, wait);
10782 }
10783 return result;
10784 }
10785 debounced.cancel = cancel;
10786 debounced.flush = flush;
10787 return debounced;
10788 }
10789
10790 /**
10791 * Defers invoking the `func` until the current call stack has cleared. Any
10792 * additional arguments are provided to `func` when it's invoked.
10793 *
10794 * @static
10795 * @memberOf _
10796 * @since 0.1.0
10797 * @category Function
10798 * @param {Function} func The function to defer.
10799 * @param {...*} [args] The arguments to invoke `func` with.
10800 * @returns {number} Returns the timer id.
10801 * @example
10802 *
10803 * _.defer(function(text) {
10804 * console.log(text);
10805 * }, 'deferred');
10806 * // => Logs 'deferred' after one millisecond.
10807 */
10808 var defer = baseRest(function(func, args) {
10809 return baseDelay(func, 1, args);
10810 });
10811
10812 /**
10813 * Invokes `func` after `wait` milliseconds. Any additional arguments are
10814 * provided to `func` when it's invoked.
10815 *
10816 * @static
10817 * @memberOf _
10818 * @since 0.1.0
10819 * @category Function
10820 * @param {Function} func The function to delay.
10821 * @param {number} wait The number of milliseconds to delay invocation.
10822 * @param {...*} [args] The arguments to invoke `func` with.
10823 * @returns {number} Returns the timer id.
10824 * @example
10825 *
10826 * _.delay(function(text) {
10827 * console.log(text);
10828 * }, 1000, 'later');
10829 * // => Logs 'later' after one second.
10830 */
10831 var delay = baseRest(function(func, wait, args) {
10832 return baseDelay(func, toNumber(wait) || 0, args);
10833 });
10834
10835 /**
10836 * Creates a function that invokes `func` with arguments reversed.
10837 *
10838 * @static
10839 * @memberOf _
10840 * @since 4.0.0
10841 * @category Function
10842 * @param {Function} func The function to flip arguments for.
10843 * @returns {Function} Returns the new flipped function.
10844 * @example
10845 *
10846 * var flipped = _.flip(function() {
10847 * return _.toArray(arguments);
10848 * });
10849 *
10850 * flipped('a', 'b', 'c', 'd');
10851 * // => ['d', 'c', 'b', 'a']
10852 */
10853 function flip(func) {
10854 return createWrap(func, WRAP_FLIP_FLAG);
10855 }
10856
10857 /**
10858 * Creates a function that memoizes the result of `func`. If `resolver` is
10859 * provided, it determines the cache key for storing the result based on the
10860 * arguments provided to the memoized function. By default, the first argument
10861 * provided to the memoized function is used as the map cache key. The `func`
10862 * is invoked with the `this` binding of the memoized function.
10863 *
10864 * **Note:** The cache is exposed as the `cache` property on the memoized
10865 * function. Its creation may be customized by replacing the `_.memoize.Cache`
10866 * constructor with one whose instances implement the
10867 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
10868 * method interface of `clear`, `delete`, `get`, `has`, and `set`.
10869 *
10870 * @static
10871 * @memberOf _
10872 * @since 0.1.0
10873 * @category Function
10874 * @param {Function} func The function to have its output memoized.
10875 * @param {Function} [resolver] The function to resolve the cache key.
10876 * @returns {Function} Returns the new memoized function.
10877 * @example
10878 *
10879 * var object = { 'a': 1, 'b': 2 };
10880 * var other = { 'c': 3, 'd': 4 };
10881 *
10882 * var values = _.memoize(_.values);
10883 * values(object);
10884 * // => [1, 2]
10885 *
10886 * values(other);
10887 * // => [3, 4]
10888 *
10889 * object.a = 2;
10890 * values(object);
10891 * // => [1, 2]
10892 *
10893 * // Modify the result cache.
10894 * values.cache.set(object, ['a', 'b']);
10895 * values(object);
10896 * // => ['a', 'b']
10897 *
10898 * // Replace `_.memoize.Cache`.
10899 * _.memoize.Cache = WeakMap;
10900 */
10901 function memoize(func, resolver) {
10902 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
10903 throw new TypeError(FUNC_ERROR_TEXT);
10904 }
10905 var memoized = function() {
10906 var args = arguments,
10907 key = resolver ? resolver.apply(this, args) : args[0],
10908 cache = memoized.cache;
10909
10910 if (cache.has(key)) {
10911 return cache.get(key);
10912 }
10913 var result = func.apply(this, args);
10914 memoized.cache = cache.set(key, result) || cache;
10915 return result;
10916 };
10917 memoized.cache = new (memoize.Cache || MapCache);
10918 return memoized;
10919 }
10920
10921 // Expose `MapCache`.
10922 memoize.Cache = MapCache;
10923
10924 /**
10925 * Creates a function that negates the result of the predicate `func`. The
10926 * `func` predicate is invoked with the `this` binding and arguments of the
10927 * created function.
10928 *
10929 * @static
10930 * @memberOf _
10931 * @since 3.0.0
10932 * @category Function
10933 * @param {Function} predicate The predicate to negate.
10934 * @returns {Function} Returns the new negated function.
10935 * @example
10936 *
10937 * function isEven(n) {
10938 * return n % 2 == 0;
10939 * }
10940 *
10941 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
10942 * // => [1, 3, 5]
10943 */
10944 function negate(predicate) {
10945 if (typeof predicate != 'function') {
10946 throw new TypeError(FUNC_ERROR_TEXT);
10947 }
10948 return function() {
10949 var args = arguments;
10950 switch (args.length) {
10951 case 0: return !predicate.call(this);
10952 case 1: return !predicate.call(this, args[0]);
10953 case 2: return !predicate.call(this, args[0], args[1]);
10954 case 3: return !predicate.call(this, args[0], args[1], args[2]);
10955 }
10956 return !predicate.apply(this, args);
10957 };
10958 }
10959
10960 /**
10961 * Creates a function that is restricted to invoking `func` once. Repeat calls
10962 * to the function return the value of the first invocation. The `func` is
10963 * invoked with the `this` binding and arguments of the created function.
10964 *
10965 * @static
10966 * @memberOf _
10967 * @since 0.1.0
10968 * @category Function
10969 * @param {Function} func The function to restrict.
10970 * @returns {Function} Returns the new restricted function.
10971 * @example
10972 *
10973 * var initialize = _.once(createApplication);
10974 * initialize();
10975 * initialize();
10976 * // => `createApplication` is invoked once
10977 */
10978 function once(func) {
10979 return before(2, func);
10980 }
10981
10982 /**
10983 * Creates a function that invokes `func` with its arguments transformed.
10984 *
10985 * @static
10986 * @since 4.0.0
10987 * @memberOf _
10988 * @category Function
10989 * @param {Function} func The function to wrap.
10990 * @param {...(Function|Function[])} [transforms=[_.identity]]
10991 * The argument transforms.
10992 * @returns {Function} Returns the new function.
10993 * @example
10994 *
10995 * function doubled(n) {
10996 * return n * 2;
10997 * }
10998 *
10999 * function square(n) {
11000 * return n * n;
11001 * }
11002 *
11003 * var func = _.overArgs(function(x, y) {
11004 * return [x, y];
11005 * }, [square, doubled]);
11006 *
11007 * func(9, 3);
11008 * // => [81, 6]
11009 *
11010 * func(10, 5);
11011 * // => [100, 10]
11012 */
11013 var overArgs = castRest(function(func, transforms) {
11014 transforms = (transforms.length == 1 && isArray(transforms[0]))
11015 ? arrayMap(transforms[0], baseUnary(getIteratee()))
11016 : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
11017
11018 var funcsLength = transforms.length;
11019 return baseRest(function(args) {
11020 var index = -1,
11021 length = nativeMin(args.length, funcsLength);
11022
11023 while (++index < length) {
11024 args[index] = transforms[index].call(this, args[index]);
11025 }
11026 return apply(func, this, args);
11027 });
11028 });
11029
11030 /**
11031 * Creates a function that invokes `func` with `partials` prepended to the
11032 * arguments it receives. This method is like `_.bind` except it does **not**
11033 * alter the `this` binding.
11034 *
11035 * The `_.partial.placeholder` value, which defaults to `_` in monolithic
11036 * builds, may be used as a placeholder for partially applied arguments.
11037 *
11038 * **Note:** This method doesn't set the "length" property of partially
11039 * applied functions.
11040 *
11041 * @static
11042 * @memberOf _
11043 * @since 0.2.0
11044 * @category Function
11045 * @param {Function} func The function to partially apply arguments to.
11046 * @param {...*} [partials] The arguments to be partially applied.
11047 * @returns {Function} Returns the new partially applied function.
11048 * @example
11049 *
11050 * function greet(greeting, name) {
11051 * return greeting + ' ' + name;
11052 * }
11053 *
11054 * var sayHelloTo = _.partial(greet, 'hello');
11055 * sayHelloTo('fred');
11056 * // => 'hello fred'
11057 *
11058 * // Partially applied with placeholders.
11059 * var greetFred = _.partial(greet, _, 'fred');
11060 * greetFred('hi');
11061 * // => 'hi fred'
11062 */
11063 var partial = baseRest(function(func, partials) {
11064 var holders = replaceHolders(partials, getHolder(partial));
11065 return createWrap(func, WRAP_PARTIAL_FLAG, undefined$1, partials, holders);
11066 });
11067
11068 /**
11069 * This method is like `_.partial` except that partially applied arguments
11070 * are appended to the arguments it receives.
11071 *
11072 * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
11073 * builds, may be used as a placeholder for partially applied arguments.
11074 *
11075 * **Note:** This method doesn't set the "length" property of partially
11076 * applied functions.
11077 *
11078 * @static
11079 * @memberOf _
11080 * @since 1.0.0
11081 * @category Function
11082 * @param {Function} func The function to partially apply arguments to.
11083 * @param {...*} [partials] The arguments to be partially applied.
11084 * @returns {Function} Returns the new partially applied function.
11085 * @example
11086 *
11087 * function greet(greeting, name) {
11088 * return greeting + ' ' + name;
11089 * }
11090 *
11091 * var greetFred = _.partialRight(greet, 'fred');
11092 * greetFred('hi');
11093 * // => 'hi fred'
11094 *
11095 * // Partially applied with placeholders.
11096 * var sayHelloTo = _.partialRight(greet, 'hello', _);
11097 * sayHelloTo('fred');
11098 * // => 'hello fred'
11099 */
11100 var partialRight = baseRest(function(func, partials) {
11101 var holders = replaceHolders(partials, getHolder(partialRight));
11102 return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined$1, partials, holders);
11103 });
11104
11105 /**
11106 * Creates a function that invokes `func` with arguments arranged according
11107 * to the specified `indexes` where the argument value at the first index is
11108 * provided as the first argument, the argument value at the second index is
11109 * provided as the second argument, and so on.
11110 *
11111 * @static
11112 * @memberOf _
11113 * @since 3.0.0
11114 * @category Function
11115 * @param {Function} func The function to rearrange arguments for.
11116 * @param {...(number|number[])} indexes The arranged argument indexes.
11117 * @returns {Function} Returns the new function.
11118 * @example
11119 *
11120 * var rearged = _.rearg(function(a, b, c) {
11121 * return [a, b, c];
11122 * }, [2, 0, 1]);
11123 *
11124 * rearged('b', 'c', 'a')
11125 * // => ['a', 'b', 'c']
11126 */
11127 var rearg = flatRest(function(func, indexes) {
11128 return createWrap(func, WRAP_REARG_FLAG, undefined$1, undefined$1, undefined$1, indexes);
11129 });
11130
11131 /**
11132 * Creates a function that invokes `func` with the `this` binding of the
11133 * created function and arguments from `start` and beyond provided as
11134 * an array.
11135 *
11136 * **Note:** This method is based on the
11137 * [rest parameter](https://mdn.io/rest_parameters).
11138 *
11139 * @static
11140 * @memberOf _
11141 * @since 4.0.0
11142 * @category Function
11143 * @param {Function} func The function to apply a rest parameter to.
11144 * @param {number} [start=func.length-1] The start position of the rest parameter.
11145 * @returns {Function} Returns the new function.
11146 * @example
11147 *
11148 * var say = _.rest(function(what, names) {
11149 * return what + ' ' + _.initial(names).join(', ') +
11150 * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
11151 * });
11152 *
11153 * say('hello', 'fred', 'barney', 'pebbles');
11154 * // => 'hello fred, barney, & pebbles'
11155 */
11156 function rest(func, start) {
11157 if (typeof func != 'function') {
11158 throw new TypeError(FUNC_ERROR_TEXT);
11159 }
11160 start = start === undefined$1 ? start : toInteger(start);
11161 return baseRest(func, start);
11162 }
11163
11164 /**
11165 * Creates a function that invokes `func` with the `this` binding of the
11166 * create function and an array of arguments much like
11167 * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
11168 *
11169 * **Note:** This method is based on the
11170 * [spread operator](https://mdn.io/spread_operator).
11171 *
11172 * @static
11173 * @memberOf _
11174 * @since 3.2.0
11175 * @category Function
11176 * @param {Function} func The function to spread arguments over.
11177 * @param {number} [start=0] The start position of the spread.
11178 * @returns {Function} Returns the new function.
11179 * @example
11180 *
11181 * var say = _.spread(function(who, what) {
11182 * return who + ' says ' + what;
11183 * });
11184 *
11185 * say(['fred', 'hello']);
11186 * // => 'fred says hello'
11187 *
11188 * var numbers = Promise.all([
11189 * Promise.resolve(40),
11190 * Promise.resolve(36)
11191 * ]);
11192 *
11193 * numbers.then(_.spread(function(x, y) {
11194 * return x + y;
11195 * }));
11196 * // => a Promise of 76
11197 */
11198 function spread(func, start) {
11199 if (typeof func != 'function') {
11200 throw new TypeError(FUNC_ERROR_TEXT);
11201 }
11202 start = start == null ? 0 : nativeMax(toInteger(start), 0);
11203 return baseRest(function(args) {
11204 var array = args[start],
11205 otherArgs = castSlice(args, 0, start);
11206
11207 if (array) {
11208 arrayPush(otherArgs, array);
11209 }
11210 return apply(func, this, otherArgs);
11211 });
11212 }
11213
11214 /**
11215 * Creates a throttled function that only invokes `func` at most once per
11216 * every `wait` milliseconds. The throttled function comes with a `cancel`
11217 * method to cancel delayed `func` invocations and a `flush` method to
11218 * immediately invoke them. Provide `options` to indicate whether `func`
11219 * should be invoked on the leading and/or trailing edge of the `wait`
11220 * timeout. The `func` is invoked with the last arguments provided to the
11221 * throttled function. Subsequent calls to the throttled function return the
11222 * result of the last `func` invocation.
11223 *
11224 * **Note:** If `leading` and `trailing` options are `true`, `func` is
11225 * invoked on the trailing edge of the timeout only if the throttled function
11226 * is invoked more than once during the `wait` timeout.
11227 *
11228 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
11229 * until to the next tick, similar to `setTimeout` with a timeout of `0`.
11230 *
11231 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
11232 * for details over the differences between `_.throttle` and `_.debounce`.
11233 *
11234 * @static
11235 * @memberOf _
11236 * @since 0.1.0
11237 * @category Function
11238 * @param {Function} func The function to throttle.
11239 * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
11240 * @param {Object} [options={}] The options object.
11241 * @param {boolean} [options.leading=true]
11242 * Specify invoking on the leading edge of the timeout.
11243 * @param {boolean} [options.trailing=true]
11244 * Specify invoking on the trailing edge of the timeout.
11245 * @returns {Function} Returns the new throttled function.
11246 * @example
11247 *
11248 * // Avoid excessively updating the position while scrolling.
11249 * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
11250 *
11251 * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
11252 * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
11253 * jQuery(element).on('click', throttled);
11254 *
11255 * // Cancel the trailing throttled invocation.
11256 * jQuery(window).on('popstate', throttled.cancel);
11257 */
11258 function throttle(func, wait, options) {
11259 var leading = true,
11260 trailing = true;
11261
11262 if (typeof func != 'function') {
11263 throw new TypeError(FUNC_ERROR_TEXT);
11264 }
11265 if (isObject(options)) {
11266 leading = 'leading' in options ? !!options.leading : leading;
11267 trailing = 'trailing' in options ? !!options.trailing : trailing;
11268 }
11269 return debounce(func, wait, {
11270 'leading': leading,
11271 'maxWait': wait,
11272 'trailing': trailing
11273 });
11274 }
11275
11276 /**
11277 * Creates a function that accepts up to one argument, ignoring any
11278 * additional arguments.
11279 *
11280 * @static
11281 * @memberOf _
11282 * @since 4.0.0
11283 * @category Function
11284 * @param {Function} func The function to cap arguments for.
11285 * @returns {Function} Returns the new capped function.
11286 * @example
11287 *
11288 * _.map(['6', '8', '10'], _.unary(parseInt));
11289 * // => [6, 8, 10]
11290 */
11291 function unary(func) {
11292 return ary(func, 1);
11293 }
11294
11295 /**
11296 * Creates a function that provides `value` to `wrapper` as its first
11297 * argument. Any additional arguments provided to the function are appended
11298 * to those provided to the `wrapper`. The wrapper is invoked with the `this`
11299 * binding of the created function.
11300 *
11301 * @static
11302 * @memberOf _
11303 * @since 0.1.0
11304 * @category Function
11305 * @param {*} value The value to wrap.
11306 * @param {Function} [wrapper=identity] The wrapper function.
11307 * @returns {Function} Returns the new function.
11308 * @example
11309 *
11310 * var p = _.wrap(_.escape, function(func, text) {
11311 * return '<p>' + func(text) + '</p>';
11312 * });
11313 *
11314 * p('fred, barney, & pebbles');
11315 * // => '<p>fred, barney, &amp; pebbles</p>'
11316 */
11317 function wrap(value, wrapper) {
11318 return partial(castFunction(wrapper), value);
11319 }
11320
11321 /*------------------------------------------------------------------------*/
11322
11323 /**
11324 * Casts `value` as an array if it's not one.
11325 *
11326 * @static
11327 * @memberOf _
11328 * @since 4.4.0
11329 * @category Lang
11330 * @param {*} value The value to inspect.
11331 * @returns {Array} Returns the cast array.
11332 * @example
11333 *
11334 * _.castArray(1);
11335 * // => [1]
11336 *
11337 * _.castArray({ 'a': 1 });
11338 * // => [{ 'a': 1 }]
11339 *
11340 * _.castArray('abc');
11341 * // => ['abc']
11342 *
11343 * _.castArray(null);
11344 * // => [null]
11345 *
11346 * _.castArray(undefined);
11347 * // => [undefined]
11348 *
11349 * _.castArray();
11350 * // => []
11351 *
11352 * var array = [1, 2, 3];
11353 * console.log(_.castArray(array) === array);
11354 * // => true
11355 */
11356 function castArray() {
11357 if (!arguments.length) {
11358 return [];
11359 }
11360 var value = arguments[0];
11361 return isArray(value) ? value : [value];
11362 }
11363
11364 /**
11365 * Creates a shallow clone of `value`.
11366 *
11367 * **Note:** This method is loosely based on the
11368 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
11369 * and supports cloning arrays, array buffers, booleans, date objects, maps,
11370 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
11371 * arrays. The own enumerable properties of `arguments` objects are cloned
11372 * as plain objects. An empty object is returned for uncloneable values such
11373 * as error objects, functions, DOM nodes, and WeakMaps.
11374 *
11375 * @static
11376 * @memberOf _
11377 * @since 0.1.0
11378 * @category Lang
11379 * @param {*} value The value to clone.
11380 * @returns {*} Returns the cloned value.
11381 * @see _.cloneDeep
11382 * @example
11383 *
11384 * var objects = [{ 'a': 1 }, { 'b': 2 }];
11385 *
11386 * var shallow = _.clone(objects);
11387 * console.log(shallow[0] === objects[0]);
11388 * // => true
11389 */
11390 function clone(value) {
11391 return baseClone(value, CLONE_SYMBOLS_FLAG);
11392 }
11393
11394 /**
11395 * This method is like `_.clone` except that it accepts `customizer` which
11396 * is invoked to produce the cloned value. If `customizer` returns `undefined`,
11397 * cloning is handled by the method instead. The `customizer` is invoked with
11398 * up to four arguments; (value [, index|key, object, stack]).
11399 *
11400 * @static
11401 * @memberOf _
11402 * @since 4.0.0
11403 * @category Lang
11404 * @param {*} value The value to clone.
11405 * @param {Function} [customizer] The function to customize cloning.
11406 * @returns {*} Returns the cloned value.
11407 * @see _.cloneDeepWith
11408 * @example
11409 *
11410 * function customizer(value) {
11411 * if (_.isElement(value)) {
11412 * return value.cloneNode(false);
11413 * }
11414 * }
11415 *
11416 * var el = _.cloneWith(document.body, customizer);
11417 *
11418 * console.log(el === document.body);
11419 * // => false
11420 * console.log(el.nodeName);
11421 * // => 'BODY'
11422 * console.log(el.childNodes.length);
11423 * // => 0
11424 */
11425 function cloneWith(value, customizer) {
11426 customizer = typeof customizer == 'function' ? customizer : undefined$1;
11427 return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
11428 }
11429
11430 /**
11431 * This method is like `_.clone` except that it recursively clones `value`.
11432 *
11433 * @static
11434 * @memberOf _
11435 * @since 1.0.0
11436 * @category Lang
11437 * @param {*} value The value to recursively clone.
11438 * @returns {*} Returns the deep cloned value.
11439 * @see _.clone
11440 * @example
11441 *
11442 * var objects = [{ 'a': 1 }, { 'b': 2 }];
11443 *
11444 * var deep = _.cloneDeep(objects);
11445 * console.log(deep[0] === objects[0]);
11446 * // => false
11447 */
11448 function cloneDeep(value) {
11449 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
11450 }
11451
11452 /**
11453 * This method is like `_.cloneWith` except that it recursively clones `value`.
11454 *
11455 * @static
11456 * @memberOf _
11457 * @since 4.0.0
11458 * @category Lang
11459 * @param {*} value The value to recursively clone.
11460 * @param {Function} [customizer] The function to customize cloning.
11461 * @returns {*} Returns the deep cloned value.
11462 * @see _.cloneWith
11463 * @example
11464 *
11465 * function customizer(value) {
11466 * if (_.isElement(value)) {
11467 * return value.cloneNode(true);
11468 * }
11469 * }
11470 *
11471 * var el = _.cloneDeepWith(document.body, customizer);
11472 *
11473 * console.log(el === document.body);
11474 * // => false
11475 * console.log(el.nodeName);
11476 * // => 'BODY'
11477 * console.log(el.childNodes.length);
11478 * // => 20
11479 */
11480 function cloneDeepWith(value, customizer) {
11481 customizer = typeof customizer == 'function' ? customizer : undefined$1;
11482 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
11483 }
11484
11485 /**
11486 * Checks if `object` conforms to `source` by invoking the predicate
11487 * properties of `source` with the corresponding property values of `object`.
11488 *
11489 * **Note:** This method is equivalent to `_.conforms` when `source` is
11490 * partially applied.
11491 *
11492 * @static
11493 * @memberOf _
11494 * @since 4.14.0
11495 * @category Lang
11496 * @param {Object} object The object to inspect.
11497 * @param {Object} source The object of property predicates to conform to.
11498 * @returns {boolean} Returns `true` if `object` conforms, else `false`.
11499 * @example
11500 *
11501 * var object = { 'a': 1, 'b': 2 };
11502 *
11503 * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
11504 * // => true
11505 *
11506 * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
11507 * // => false
11508 */
11509 function conformsTo(object, source) {
11510 return source == null || baseConformsTo(object, source, keys(source));
11511 }
11512
11513 /**
11514 * Performs a
11515 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
11516 * comparison between two values to determine if they are equivalent.
11517 *
11518 * @static
11519 * @memberOf _
11520 * @since 4.0.0
11521 * @category Lang
11522 * @param {*} value The value to compare.
11523 * @param {*} other The other value to compare.
11524 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11525 * @example
11526 *
11527 * var object = { 'a': 1 };
11528 * var other = { 'a': 1 };
11529 *
11530 * _.eq(object, object);
11531 * // => true
11532 *
11533 * _.eq(object, other);
11534 * // => false
11535 *
11536 * _.eq('a', 'a');
11537 * // => true
11538 *
11539 * _.eq('a', Object('a'));
11540 * // => false
11541 *
11542 * _.eq(NaN, NaN);
11543 * // => true
11544 */
11545 function eq(value, other) {
11546 return value === other || (value !== value && other !== other);
11547 }
11548
11549 /**
11550 * Checks if `value` is greater than `other`.
11551 *
11552 * @static
11553 * @memberOf _
11554 * @since 3.9.0
11555 * @category Lang
11556 * @param {*} value The value to compare.
11557 * @param {*} other The other value to compare.
11558 * @returns {boolean} Returns `true` if `value` is greater than `other`,
11559 * else `false`.
11560 * @see _.lt
11561 * @example
11562 *
11563 * _.gt(3, 1);
11564 * // => true
11565 *
11566 * _.gt(3, 3);
11567 * // => false
11568 *
11569 * _.gt(1, 3);
11570 * // => false
11571 */
11572 var gt = createRelationalOperation(baseGt);
11573
11574 /**
11575 * Checks if `value` is greater than or equal to `other`.
11576 *
11577 * @static
11578 * @memberOf _
11579 * @since 3.9.0
11580 * @category Lang
11581 * @param {*} value The value to compare.
11582 * @param {*} other The other value to compare.
11583 * @returns {boolean} Returns `true` if `value` is greater than or equal to
11584 * `other`, else `false`.
11585 * @see _.lte
11586 * @example
11587 *
11588 * _.gte(3, 1);
11589 * // => true
11590 *
11591 * _.gte(3, 3);
11592 * // => true
11593 *
11594 * _.gte(1, 3);
11595 * // => false
11596 */
11597 var gte = createRelationalOperation(function(value, other) {
11598 return value >= other;
11599 });
11600
11601 /**
11602 * Checks if `value` is likely an `arguments` object.
11603 *
11604 * @static
11605 * @memberOf _
11606 * @since 0.1.0
11607 * @category Lang
11608 * @param {*} value The value to check.
11609 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
11610 * else `false`.
11611 * @example
11612 *
11613 * _.isArguments(function() { return arguments; }());
11614 * // => true
11615 *
11616 * _.isArguments([1, 2, 3]);
11617 * // => false
11618 */
11619 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
11620 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
11621 !propertyIsEnumerable.call(value, 'callee');
11622 };
11623
11624 /**
11625 * Checks if `value` is classified as an `Array` object.
11626 *
11627 * @static
11628 * @memberOf _
11629 * @since 0.1.0
11630 * @category Lang
11631 * @param {*} value The value to check.
11632 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
11633 * @example
11634 *
11635 * _.isArray([1, 2, 3]);
11636 * // => true
11637 *
11638 * _.isArray(document.body.children);
11639 * // => false
11640 *
11641 * _.isArray('abc');
11642 * // => false
11643 *
11644 * _.isArray(_.noop);
11645 * // => false
11646 */
11647 var isArray = Array.isArray;
11648
11649 /**
11650 * Checks if `value` is classified as an `ArrayBuffer` object.
11651 *
11652 * @static
11653 * @memberOf _
11654 * @since 4.3.0
11655 * @category Lang
11656 * @param {*} value The value to check.
11657 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
11658 * @example
11659 *
11660 * _.isArrayBuffer(new ArrayBuffer(2));
11661 * // => true
11662 *
11663 * _.isArrayBuffer(new Array(2));
11664 * // => false
11665 */
11666 var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
11667
11668 /**
11669 * Checks if `value` is array-like. A value is considered array-like if it's
11670 * not a function and has a `value.length` that's an integer greater than or
11671 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
11672 *
11673 * @static
11674 * @memberOf _
11675 * @since 4.0.0
11676 * @category Lang
11677 * @param {*} value The value to check.
11678 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
11679 * @example
11680 *
11681 * _.isArrayLike([1, 2, 3]);
11682 * // => true
11683 *
11684 * _.isArrayLike(document.body.children);
11685 * // => true
11686 *
11687 * _.isArrayLike('abc');
11688 * // => true
11689 *
11690 * _.isArrayLike(_.noop);
11691 * // => false
11692 */
11693 function isArrayLike(value) {
11694 return value != null && isLength(value.length) && !isFunction(value);
11695 }
11696
11697 /**
11698 * This method is like `_.isArrayLike` except that it also checks if `value`
11699 * is an object.
11700 *
11701 * @static
11702 * @memberOf _
11703 * @since 4.0.0
11704 * @category Lang
11705 * @param {*} value The value to check.
11706 * @returns {boolean} Returns `true` if `value` is an array-like object,
11707 * else `false`.
11708 * @example
11709 *
11710 * _.isArrayLikeObject([1, 2, 3]);
11711 * // => true
11712 *
11713 * _.isArrayLikeObject(document.body.children);
11714 * // => true
11715 *
11716 * _.isArrayLikeObject('abc');
11717 * // => false
11718 *
11719 * _.isArrayLikeObject(_.noop);
11720 * // => false
11721 */
11722 function isArrayLikeObject(value) {
11723 return isObjectLike(value) && isArrayLike(value);
11724 }
11725
11726 /**
11727 * Checks if `value` is classified as a boolean primitive or object.
11728 *
11729 * @static
11730 * @memberOf _
11731 * @since 0.1.0
11732 * @category Lang
11733 * @param {*} value The value to check.
11734 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
11735 * @example
11736 *
11737 * _.isBoolean(false);
11738 * // => true
11739 *
11740 * _.isBoolean(null);
11741 * // => false
11742 */
11743 function isBoolean(value) {
11744 return value === true || value === false ||
11745 (isObjectLike(value) && baseGetTag(value) == boolTag);
11746 }
11747
11748 /**
11749 * Checks if `value` is a buffer.
11750 *
11751 * @static
11752 * @memberOf _
11753 * @since 4.3.0
11754 * @category Lang
11755 * @param {*} value The value to check.
11756 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
11757 * @example
11758 *
11759 * _.isBuffer(new Buffer(2));
11760 * // => true
11761 *
11762 * _.isBuffer(new Uint8Array(2));
11763 * // => false
11764 */
11765 var isBuffer = nativeIsBuffer || stubFalse;
11766
11767 /**
11768 * Checks if `value` is classified as a `Date` object.
11769 *
11770 * @static
11771 * @memberOf _
11772 * @since 0.1.0
11773 * @category Lang
11774 * @param {*} value The value to check.
11775 * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
11776 * @example
11777 *
11778 * _.isDate(new Date);
11779 * // => true
11780 *
11781 * _.isDate('Mon April 23 2012');
11782 * // => false
11783 */
11784 var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
11785
11786 /**
11787 * Checks if `value` is likely a DOM element.
11788 *
11789 * @static
11790 * @memberOf _
11791 * @since 0.1.0
11792 * @category Lang
11793 * @param {*} value The value to check.
11794 * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
11795 * @example
11796 *
11797 * _.isElement(document.body);
11798 * // => true
11799 *
11800 * _.isElement('<body>');
11801 * // => false
11802 */
11803 function isElement(value) {
11804 return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
11805 }
11806
11807 /**
11808 * Checks if `value` is an empty object, collection, map, or set.
11809 *
11810 * Objects are considered empty if they have no own enumerable string keyed
11811 * properties.
11812 *
11813 * Array-like values such as `arguments` objects, arrays, buffers, strings, or
11814 * jQuery-like collections are considered empty if they have a `length` of `0`.
11815 * Similarly, maps and sets are considered empty if they have a `size` of `0`.
11816 *
11817 * @static
11818 * @memberOf _
11819 * @since 0.1.0
11820 * @category Lang
11821 * @param {*} value The value to check.
11822 * @returns {boolean} Returns `true` if `value` is empty, else `false`.
11823 * @example
11824 *
11825 * _.isEmpty(null);
11826 * // => true
11827 *
11828 * _.isEmpty(true);
11829 * // => true
11830 *
11831 * _.isEmpty(1);
11832 * // => true
11833 *
11834 * _.isEmpty([1, 2, 3]);
11835 * // => false
11836 *
11837 * _.isEmpty({ 'a': 1 });
11838 * // => false
11839 */
11840 function isEmpty(value) {
11841 if (value == null) {
11842 return true;
11843 }
11844 if (isArrayLike(value) &&
11845 (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
11846 isBuffer(value) || isTypedArray(value) || isArguments(value))) {
11847 return !value.length;
11848 }
11849 var tag = getTag(value);
11850 if (tag == mapTag || tag == setTag) {
11851 return !value.size;
11852 }
11853 if (isPrototype(value)) {
11854 return !baseKeys(value).length;
11855 }
11856 for (var key in value) {
11857 if (hasOwnProperty.call(value, key)) {
11858 return false;
11859 }
11860 }
11861 return true;
11862 }
11863
11864 /**
11865 * Performs a deep comparison between two values to determine if they are
11866 * equivalent.
11867 *
11868 * **Note:** This method supports comparing arrays, array buffers, booleans,
11869 * date objects, error objects, maps, numbers, `Object` objects, regexes,
11870 * sets, strings, symbols, and typed arrays. `Object` objects are compared
11871 * by their own, not inherited, enumerable properties. Functions and DOM
11872 * nodes are compared by strict equality, i.e. `===`.
11873 *
11874 * @static
11875 * @memberOf _
11876 * @since 0.1.0
11877 * @category Lang
11878 * @param {*} value The value to compare.
11879 * @param {*} other The other value to compare.
11880 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11881 * @example
11882 *
11883 * var object = { 'a': 1 };
11884 * var other = { 'a': 1 };
11885 *
11886 * _.isEqual(object, other);
11887 * // => true
11888 *
11889 * object === other;
11890 * // => false
11891 */
11892 function isEqual(value, other) {
11893 return baseIsEqual(value, other);
11894 }
11895
11896 /**
11897 * This method is like `_.isEqual` except that it accepts `customizer` which
11898 * is invoked to compare values. If `customizer` returns `undefined`, comparisons
11899 * are handled by the method instead. The `customizer` is invoked with up to
11900 * six arguments: (objValue, othValue [, index|key, object, other, stack]).
11901 *
11902 * @static
11903 * @memberOf _
11904 * @since 4.0.0
11905 * @category Lang
11906 * @param {*} value The value to compare.
11907 * @param {*} other The other value to compare.
11908 * @param {Function} [customizer] The function to customize comparisons.
11909 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11910 * @example
11911 *
11912 * function isGreeting(value) {
11913 * return /^h(?:i|ello)$/.test(value);
11914 * }
11915 *
11916 * function customizer(objValue, othValue) {
11917 * if (isGreeting(objValue) && isGreeting(othValue)) {
11918 * return true;
11919 * }
11920 * }
11921 *
11922 * var array = ['hello', 'goodbye'];
11923 * var other = ['hi', 'goodbye'];
11924 *
11925 * _.isEqualWith(array, other, customizer);
11926 * // => true
11927 */
11928 function isEqualWith(value, other, customizer) {
11929 customizer = typeof customizer == 'function' ? customizer : undefined$1;
11930 var result = customizer ? customizer(value, other) : undefined$1;
11931 return result === undefined$1 ? baseIsEqual(value, other, undefined$1, customizer) : !!result;
11932 }
11933
11934 /**
11935 * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
11936 * `SyntaxError`, `TypeError`, or `URIError` object.
11937 *
11938 * @static
11939 * @memberOf _
11940 * @since 3.0.0
11941 * @category Lang
11942 * @param {*} value The value to check.
11943 * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
11944 * @example
11945 *
11946 * _.isError(new Error);
11947 * // => true
11948 *
11949 * _.isError(Error);
11950 * // => false
11951 */
11952 function isError(value) {
11953 if (!isObjectLike(value)) {
11954 return false;
11955 }
11956 var tag = baseGetTag(value);
11957 return tag == errorTag || tag == domExcTag ||
11958 (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
11959 }
11960
11961 /**
11962 * Checks if `value` is a finite primitive number.
11963 *
11964 * **Note:** This method is based on
11965 * [`Number.isFinite`](https://mdn.io/Number/isFinite).
11966 *
11967 * @static
11968 * @memberOf _
11969 * @since 0.1.0
11970 * @category Lang
11971 * @param {*} value The value to check.
11972 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
11973 * @example
11974 *
11975 * _.isFinite(3);
11976 * // => true
11977 *
11978 * _.isFinite(Number.MIN_VALUE);
11979 * // => true
11980 *
11981 * _.isFinite(Infinity);
11982 * // => false
11983 *
11984 * _.isFinite('3');
11985 * // => false
11986 */
11987 function isFinite(value) {
11988 return typeof value == 'number' && nativeIsFinite(value);
11989 }
11990
11991 /**
11992 * Checks if `value` is classified as a `Function` object.
11993 *
11994 * @static
11995 * @memberOf _
11996 * @since 0.1.0
11997 * @category Lang
11998 * @param {*} value The value to check.
11999 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
12000 * @example
12001 *
12002 * _.isFunction(_);
12003 * // => true
12004 *
12005 * _.isFunction(/abc/);
12006 * // => false
12007 */
12008 function isFunction(value) {
12009 if (!isObject(value)) {
12010 return false;
12011 }
12012 // The use of `Object#toString` avoids issues with the `typeof` operator
12013 // in Safari 9 which returns 'object' for typed arrays and other constructors.
12014 var tag = baseGetTag(value);
12015 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
12016 }
12017
12018 /**
12019 * Checks if `value` is an integer.
12020 *
12021 * **Note:** This method is based on
12022 * [`Number.isInteger`](https://mdn.io/Number/isInteger).
12023 *
12024 * @static
12025 * @memberOf _
12026 * @since 4.0.0
12027 * @category Lang
12028 * @param {*} value The value to check.
12029 * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
12030 * @example
12031 *
12032 * _.isInteger(3);
12033 * // => true
12034 *
12035 * _.isInteger(Number.MIN_VALUE);
12036 * // => false
12037 *
12038 * _.isInteger(Infinity);
12039 * // => false
12040 *
12041 * _.isInteger('3');
12042 * // => false
12043 */
12044 function isInteger(value) {
12045 return typeof value == 'number' && value == toInteger(value);
12046 }
12047
12048 /**
12049 * Checks if `value` is a valid array-like length.
12050 *
12051 * **Note:** This method is loosely based on
12052 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
12053 *
12054 * @static
12055 * @memberOf _
12056 * @since 4.0.0
12057 * @category Lang
12058 * @param {*} value The value to check.
12059 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
12060 * @example
12061 *
12062 * _.isLength(3);
12063 * // => true
12064 *
12065 * _.isLength(Number.MIN_VALUE);
12066 * // => false
12067 *
12068 * _.isLength(Infinity);
12069 * // => false
12070 *
12071 * _.isLength('3');
12072 * // => false
12073 */
12074 function isLength(value) {
12075 return typeof value == 'number' &&
12076 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
12077 }
12078
12079 /**
12080 * Checks if `value` is the
12081 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
12082 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
12083 *
12084 * @static
12085 * @memberOf _
12086 * @since 0.1.0
12087 * @category Lang
12088 * @param {*} value The value to check.
12089 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
12090 * @example
12091 *
12092 * _.isObject({});
12093 * // => true
12094 *
12095 * _.isObject([1, 2, 3]);
12096 * // => true
12097 *
12098 * _.isObject(_.noop);
12099 * // => true
12100 *
12101 * _.isObject(null);
12102 * // => false
12103 */
12104 function isObject(value) {
12105 var type = typeof value;
12106 return value != null && (type == 'object' || type == 'function');
12107 }
12108
12109 /**
12110 * Checks if `value` is object-like. A value is object-like if it's not `null`
12111 * and has a `typeof` result of "object".
12112 *
12113 * @static
12114 * @memberOf _
12115 * @since 4.0.0
12116 * @category Lang
12117 * @param {*} value The value to check.
12118 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
12119 * @example
12120 *
12121 * _.isObjectLike({});
12122 * // => true
12123 *
12124 * _.isObjectLike([1, 2, 3]);
12125 * // => true
12126 *
12127 * _.isObjectLike(_.noop);
12128 * // => false
12129 *
12130 * _.isObjectLike(null);
12131 * // => false
12132 */
12133 function isObjectLike(value) {
12134 return value != null && typeof value == 'object';
12135 }
12136
12137 /**
12138 * Checks if `value` is classified as a `Map` object.
12139 *
12140 * @static
12141 * @memberOf _
12142 * @since 4.3.0
12143 * @category Lang
12144 * @param {*} value The value to check.
12145 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
12146 * @example
12147 *
12148 * _.isMap(new Map);
12149 * // => true
12150 *
12151 * _.isMap(new WeakMap);
12152 * // => false
12153 */
12154 var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
12155
12156 /**
12157 * Performs a partial deep comparison between `object` and `source` to
12158 * determine if `object` contains equivalent property values.
12159 *
12160 * **Note:** This method is equivalent to `_.matches` when `source` is
12161 * partially applied.
12162 *
12163 * Partial comparisons will match empty array and empty object `source`
12164 * values against any array or object value, respectively. See `_.isEqual`
12165 * for a list of supported value comparisons.
12166 *
12167 * @static
12168 * @memberOf _
12169 * @since 3.0.0
12170 * @category Lang
12171 * @param {Object} object The object to inspect.
12172 * @param {Object} source The object of property values to match.
12173 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
12174 * @example
12175 *
12176 * var object = { 'a': 1, 'b': 2 };
12177 *
12178 * _.isMatch(object, { 'b': 2 });
12179 * // => true
12180 *
12181 * _.isMatch(object, { 'b': 1 });
12182 * // => false
12183 */
12184 function isMatch(object, source) {
12185 return object === source || baseIsMatch(object, source, getMatchData(source));
12186 }
12187
12188 /**
12189 * This method is like `_.isMatch` except that it accepts `customizer` which
12190 * is invoked to compare values. If `customizer` returns `undefined`, comparisons
12191 * are handled by the method instead. The `customizer` is invoked with five
12192 * arguments: (objValue, srcValue, index|key, object, source).
12193 *
12194 * @static
12195 * @memberOf _
12196 * @since 4.0.0
12197 * @category Lang
12198 * @param {Object} object The object to inspect.
12199 * @param {Object} source The object of property values to match.
12200 * @param {Function} [customizer] The function to customize comparisons.
12201 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
12202 * @example
12203 *
12204 * function isGreeting(value) {
12205 * return /^h(?:i|ello)$/.test(value);
12206 * }
12207 *
12208 * function customizer(objValue, srcValue) {
12209 * if (isGreeting(objValue) && isGreeting(srcValue)) {
12210 * return true;
12211 * }
12212 * }
12213 *
12214 * var object = { 'greeting': 'hello' };
12215 * var source = { 'greeting': 'hi' };
12216 *
12217 * _.isMatchWith(object, source, customizer);
12218 * // => true
12219 */
12220 function isMatchWith(object, source, customizer) {
12221 customizer = typeof customizer == 'function' ? customizer : undefined$1;
12222 return baseIsMatch(object, source, getMatchData(source), customizer);
12223 }
12224
12225 /**
12226 * Checks if `value` is `NaN`.
12227 *
12228 * **Note:** This method is based on
12229 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
12230 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
12231 * `undefined` and other non-number values.
12232 *
12233 * @static
12234 * @memberOf _
12235 * @since 0.1.0
12236 * @category Lang
12237 * @param {*} value The value to check.
12238 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
12239 * @example
12240 *
12241 * _.isNaN(NaN);
12242 * // => true
12243 *
12244 * _.isNaN(new Number(NaN));
12245 * // => true
12246 *
12247 * isNaN(undefined);
12248 * // => true
12249 *
12250 * _.isNaN(undefined);
12251 * // => false
12252 */
12253 function isNaN(value) {
12254 // An `NaN` primitive is the only value that is not equal to itself.
12255 // Perform the `toStringTag` check first to avoid errors with some
12256 // ActiveX objects in IE.
12257 return isNumber(value) && value != +value;
12258 }
12259
12260 /**
12261 * Checks if `value` is a pristine native function.
12262 *
12263 * **Note:** This method can't reliably detect native functions in the presence
12264 * of the core-js package because core-js circumvents this kind of detection.
12265 * Despite multiple requests, the core-js maintainer has made it clear: any
12266 * attempt to fix the detection will be obstructed. As a result, we're left
12267 * with little choice but to throw an error. Unfortunately, this also affects
12268 * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
12269 * which rely on core-js.
12270 *
12271 * @static
12272 * @memberOf _
12273 * @since 3.0.0
12274 * @category Lang
12275 * @param {*} value The value to check.
12276 * @returns {boolean} Returns `true` if `value` is a native function,
12277 * else `false`.
12278 * @example
12279 *
12280 * _.isNative(Array.prototype.push);
12281 * // => true
12282 *
12283 * _.isNative(_);
12284 * // => false
12285 */
12286 function isNative(value) {
12287 if (isMaskable(value)) {
12288 throw new Error(CORE_ERROR_TEXT);
12289 }
12290 return baseIsNative(value);
12291 }
12292
12293 /**
12294 * Checks if `value` is `null`.
12295 *
12296 * @static
12297 * @memberOf _
12298 * @since 0.1.0
12299 * @category Lang
12300 * @param {*} value The value to check.
12301 * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
12302 * @example
12303 *
12304 * _.isNull(null);
12305 * // => true
12306 *
12307 * _.isNull(void 0);
12308 * // => false
12309 */
12310 function isNull(value) {
12311 return value === null;
12312 }
12313
12314 /**
12315 * Checks if `value` is `null` or `undefined`.
12316 *
12317 * @static
12318 * @memberOf _
12319 * @since 4.0.0
12320 * @category Lang
12321 * @param {*} value The value to check.
12322 * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
12323 * @example
12324 *
12325 * _.isNil(null);
12326 * // => true
12327 *
12328 * _.isNil(void 0);
12329 * // => true
12330 *
12331 * _.isNil(NaN);
12332 * // => false
12333 */
12334 function isNil(value) {
12335 return value == null;
12336 }
12337
12338 /**
12339 * Checks if `value` is classified as a `Number` primitive or object.
12340 *
12341 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
12342 * classified as numbers, use the `_.isFinite` method.
12343 *
12344 * @static
12345 * @memberOf _
12346 * @since 0.1.0
12347 * @category Lang
12348 * @param {*} value The value to check.
12349 * @returns {boolean} Returns `true` if `value` is a number, else `false`.
12350 * @example
12351 *
12352 * _.isNumber(3);
12353 * // => true
12354 *
12355 * _.isNumber(Number.MIN_VALUE);
12356 * // => true
12357 *
12358 * _.isNumber(Infinity);
12359 * // => true
12360 *
12361 * _.isNumber('3');
12362 * // => false
12363 */
12364 function isNumber(value) {
12365 return typeof value == 'number' ||
12366 (isObjectLike(value) && baseGetTag(value) == numberTag);
12367 }
12368
12369 /**
12370 * Checks if `value` is a plain object, that is, an object created by the
12371 * `Object` constructor or one with a `[[Prototype]]` of `null`.
12372 *
12373 * @static
12374 * @memberOf _
12375 * @since 0.8.0
12376 * @category Lang
12377 * @param {*} value The value to check.
12378 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
12379 * @example
12380 *
12381 * function Foo() {
12382 * this.a = 1;
12383 * }
12384 *
12385 * _.isPlainObject(new Foo);
12386 * // => false
12387 *
12388 * _.isPlainObject([1, 2, 3]);
12389 * // => false
12390 *
12391 * _.isPlainObject({ 'x': 0, 'y': 0 });
12392 * // => true
12393 *
12394 * _.isPlainObject(Object.create(null));
12395 * // => true
12396 */
12397 function isPlainObject(value) {
12398 if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
12399 return false;
12400 }
12401 var proto = getPrototype(value);
12402 if (proto === null) {
12403 return true;
12404 }
12405 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
12406 return typeof Ctor == 'function' && Ctor instanceof Ctor &&
12407 funcToString.call(Ctor) == objectCtorString;
12408 }
12409
12410 /**
12411 * Checks if `value` is classified as a `RegExp` object.
12412 *
12413 * @static
12414 * @memberOf _
12415 * @since 0.1.0
12416 * @category Lang
12417 * @param {*} value The value to check.
12418 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
12419 * @example
12420 *
12421 * _.isRegExp(/abc/);
12422 * // => true
12423 *
12424 * _.isRegExp('/abc/');
12425 * // => false
12426 */
12427 var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
12428
12429 /**
12430 * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
12431 * double precision number which isn't the result of a rounded unsafe integer.
12432 *
12433 * **Note:** This method is based on
12434 * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
12435 *
12436 * @static
12437 * @memberOf _
12438 * @since 4.0.0
12439 * @category Lang
12440 * @param {*} value The value to check.
12441 * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
12442 * @example
12443 *
12444 * _.isSafeInteger(3);
12445 * // => true
12446 *
12447 * _.isSafeInteger(Number.MIN_VALUE);
12448 * // => false
12449 *
12450 * _.isSafeInteger(Infinity);
12451 * // => false
12452 *
12453 * _.isSafeInteger('3');
12454 * // => false
12455 */
12456 function isSafeInteger(value) {
12457 return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
12458 }
12459
12460 /**
12461 * Checks if `value` is classified as a `Set` object.
12462 *
12463 * @static
12464 * @memberOf _
12465 * @since 4.3.0
12466 * @category Lang
12467 * @param {*} value The value to check.
12468 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
12469 * @example
12470 *
12471 * _.isSet(new Set);
12472 * // => true
12473 *
12474 * _.isSet(new WeakSet);
12475 * // => false
12476 */
12477 var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
12478
12479 /**
12480 * Checks if `value` is classified as a `String` primitive or object.
12481 *
12482 * @static
12483 * @since 0.1.0
12484 * @memberOf _
12485 * @category Lang
12486 * @param {*} value The value to check.
12487 * @returns {boolean} Returns `true` if `value` is a string, else `false`.
12488 * @example
12489 *
12490 * _.isString('abc');
12491 * // => true
12492 *
12493 * _.isString(1);
12494 * // => false
12495 */
12496 function isString(value) {
12497 return typeof value == 'string' ||
12498 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
12499 }
12500
12501 /**
12502 * Checks if `value` is classified as a `Symbol` primitive or object.
12503 *
12504 * @static
12505 * @memberOf _
12506 * @since 4.0.0
12507 * @category Lang
12508 * @param {*} value The value to check.
12509 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
12510 * @example
12511 *
12512 * _.isSymbol(Symbol.iterator);
12513 * // => true
12514 *
12515 * _.isSymbol('abc');
12516 * // => false
12517 */
12518 function isSymbol(value) {
12519 return typeof value == 'symbol' ||
12520 (isObjectLike(value) && baseGetTag(value) == symbolTag);
12521 }
12522
12523 /**
12524 * Checks if `value` is classified as a typed array.
12525 *
12526 * @static
12527 * @memberOf _
12528 * @since 3.0.0
12529 * @category Lang
12530 * @param {*} value The value to check.
12531 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
12532 * @example
12533 *
12534 * _.isTypedArray(new Uint8Array);
12535 * // => true
12536 *
12537 * _.isTypedArray([]);
12538 * // => false
12539 */
12540 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
12541
12542 /**
12543 * Checks if `value` is `undefined`.
12544 *
12545 * @static
12546 * @since 0.1.0
12547 * @memberOf _
12548 * @category Lang
12549 * @param {*} value The value to check.
12550 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
12551 * @example
12552 *
12553 * _.isUndefined(void 0);
12554 * // => true
12555 *
12556 * _.isUndefined(null);
12557 * // => false
12558 */
12559 function isUndefined(value) {
12560 return value === undefined$1;
12561 }
12562
12563 /**
12564 * Checks if `value` is classified as a `WeakMap` object.
12565 *
12566 * @static
12567 * @memberOf _
12568 * @since 4.3.0
12569 * @category Lang
12570 * @param {*} value The value to check.
12571 * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
12572 * @example
12573 *
12574 * _.isWeakMap(new WeakMap);
12575 * // => true
12576 *
12577 * _.isWeakMap(new Map);
12578 * // => false
12579 */
12580 function isWeakMap(value) {
12581 return isObjectLike(value) && getTag(value) == weakMapTag;
12582 }
12583
12584 /**
12585 * Checks if `value` is classified as a `WeakSet` object.
12586 *
12587 * @static
12588 * @memberOf _
12589 * @since 4.3.0
12590 * @category Lang
12591 * @param {*} value The value to check.
12592 * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
12593 * @example
12594 *
12595 * _.isWeakSet(new WeakSet);
12596 * // => true
12597 *
12598 * _.isWeakSet(new Set);
12599 * // => false
12600 */
12601 function isWeakSet(value) {
12602 return isObjectLike(value) && baseGetTag(value) == weakSetTag;
12603 }
12604
12605 /**
12606 * Checks if `value` is less than `other`.
12607 *
12608 * @static
12609 * @memberOf _
12610 * @since 3.9.0
12611 * @category Lang
12612 * @param {*} value The value to compare.
12613 * @param {*} other The other value to compare.
12614 * @returns {boolean} Returns `true` if `value` is less than `other`,
12615 * else `false`.
12616 * @see _.gt
12617 * @example
12618 *
12619 * _.lt(1, 3);
12620 * // => true
12621 *
12622 * _.lt(3, 3);
12623 * // => false
12624 *
12625 * _.lt(3, 1);
12626 * // => false
12627 */
12628 var lt = createRelationalOperation(baseLt);
12629
12630 /**
12631 * Checks if `value` is less than or equal to `other`.
12632 *
12633 * @static
12634 * @memberOf _
12635 * @since 3.9.0
12636 * @category Lang
12637 * @param {*} value The value to compare.
12638 * @param {*} other The other value to compare.
12639 * @returns {boolean} Returns `true` if `value` is less than or equal to
12640 * `other`, else `false`.
12641 * @see _.gte
12642 * @example
12643 *
12644 * _.lte(1, 3);
12645 * // => true
12646 *
12647 * _.lte(3, 3);
12648 * // => true
12649 *
12650 * _.lte(3, 1);
12651 * // => false
12652 */
12653 var lte = createRelationalOperation(function(value, other) {
12654 return value <= other;
12655 });
12656
12657 /**
12658 * Converts `value` to an array.
12659 *
12660 * @static
12661 * @since 0.1.0
12662 * @memberOf _
12663 * @category Lang
12664 * @param {*} value The value to convert.
12665 * @returns {Array} Returns the converted array.
12666 * @example
12667 *
12668 * _.toArray({ 'a': 1, 'b': 2 });
12669 * // => [1, 2]
12670 *
12671 * _.toArray('abc');
12672 * // => ['a', 'b', 'c']
12673 *
12674 * _.toArray(1);
12675 * // => []
12676 *
12677 * _.toArray(null);
12678 * // => []
12679 */
12680 function toArray(value) {
12681 if (!value) {
12682 return [];
12683 }
12684 if (isArrayLike(value)) {
12685 return isString(value) ? stringToArray(value) : copyArray(value);
12686 }
12687 if (symIterator && value[symIterator]) {
12688 return iteratorToArray(value[symIterator]());
12689 }
12690 var tag = getTag(value),
12691 func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
12692
12693 return func(value);
12694 }
12695
12696 /**
12697 * Converts `value` to a finite number.
12698 *
12699 * @static
12700 * @memberOf _
12701 * @since 4.12.0
12702 * @category Lang
12703 * @param {*} value The value to convert.
12704 * @returns {number} Returns the converted number.
12705 * @example
12706 *
12707 * _.toFinite(3.2);
12708 * // => 3.2
12709 *
12710 * _.toFinite(Number.MIN_VALUE);
12711 * // => 5e-324
12712 *
12713 * _.toFinite(Infinity);
12714 * // => 1.7976931348623157e+308
12715 *
12716 * _.toFinite('3.2');
12717 * // => 3.2
12718 */
12719 function toFinite(value) {
12720 if (!value) {
12721 return value === 0 ? value : 0;
12722 }
12723 value = toNumber(value);
12724 if (value === INFINITY || value === -INFINITY) {
12725 var sign = (value < 0 ? -1 : 1);
12726 return sign * MAX_INTEGER;
12727 }
12728 return value === value ? value : 0;
12729 }
12730
12731 /**
12732 * Converts `value` to an integer.
12733 *
12734 * **Note:** This method is loosely based on
12735 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
12736 *
12737 * @static
12738 * @memberOf _
12739 * @since 4.0.0
12740 * @category Lang
12741 * @param {*} value The value to convert.
12742 * @returns {number} Returns the converted integer.
12743 * @example
12744 *
12745 * _.toInteger(3.2);
12746 * // => 3
12747 *
12748 * _.toInteger(Number.MIN_VALUE);
12749 * // => 0
12750 *
12751 * _.toInteger(Infinity);
12752 * // => 1.7976931348623157e+308
12753 *
12754 * _.toInteger('3.2');
12755 * // => 3
12756 */
12757 function toInteger(value) {
12758 var result = toFinite(value),
12759 remainder = result % 1;
12760
12761 return result === result ? (remainder ? result - remainder : result) : 0;
12762 }
12763
12764 /**
12765 * Converts `value` to an integer suitable for use as the length of an
12766 * array-like object.
12767 *
12768 * **Note:** This method is based on
12769 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
12770 *
12771 * @static
12772 * @memberOf _
12773 * @since 4.0.0
12774 * @category Lang
12775 * @param {*} value The value to convert.
12776 * @returns {number} Returns the converted integer.
12777 * @example
12778 *
12779 * _.toLength(3.2);
12780 * // => 3
12781 *
12782 * _.toLength(Number.MIN_VALUE);
12783 * // => 0
12784 *
12785 * _.toLength(Infinity);
12786 * // => 4294967295
12787 *
12788 * _.toLength('3.2');
12789 * // => 3
12790 */
12791 function toLength(value) {
12792 return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
12793 }
12794
12795 /**
12796 * Converts `value` to a number.
12797 *
12798 * @static
12799 * @memberOf _
12800 * @since 4.0.0
12801 * @category Lang
12802 * @param {*} value The value to process.
12803 * @returns {number} Returns the number.
12804 * @example
12805 *
12806 * _.toNumber(3.2);
12807 * // => 3.2
12808 *
12809 * _.toNumber(Number.MIN_VALUE);
12810 * // => 5e-324
12811 *
12812 * _.toNumber(Infinity);
12813 * // => Infinity
12814 *
12815 * _.toNumber('3.2');
12816 * // => 3.2
12817 */
12818 function toNumber(value) {
12819 if (typeof value == 'number') {
12820 return value;
12821 }
12822 if (isSymbol(value)) {
12823 return NAN;
12824 }
12825 if (isObject(value)) {
12826 var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
12827 value = isObject(other) ? (other + '') : other;
12828 }
12829 if (typeof value != 'string') {
12830 return value === 0 ? value : +value;
12831 }
12832 value = baseTrim(value);
12833 var isBinary = reIsBinary.test(value);
12834 return (isBinary || reIsOctal.test(value))
12835 ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
12836 : (reIsBadHex.test(value) ? NAN : +value);
12837 }
12838
12839 /**
12840 * Converts `value` to a plain object flattening inherited enumerable string
12841 * keyed properties of `value` to own properties of the plain object.
12842 *
12843 * @static
12844 * @memberOf _
12845 * @since 3.0.0
12846 * @category Lang
12847 * @param {*} value The value to convert.
12848 * @returns {Object} Returns the converted plain object.
12849 * @example
12850 *
12851 * function Foo() {
12852 * this.b = 2;
12853 * }
12854 *
12855 * Foo.prototype.c = 3;
12856 *
12857 * _.assign({ 'a': 1 }, new Foo);
12858 * // => { 'a': 1, 'b': 2 }
12859 *
12860 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
12861 * // => { 'a': 1, 'b': 2, 'c': 3 }
12862 */
12863 function toPlainObject(value) {
12864 return copyObject(value, keysIn(value));
12865 }
12866
12867 /**
12868 * Converts `value` to a safe integer. A safe integer can be compared and
12869 * represented correctly.
12870 *
12871 * @static
12872 * @memberOf _
12873 * @since 4.0.0
12874 * @category Lang
12875 * @param {*} value The value to convert.
12876 * @returns {number} Returns the converted integer.
12877 * @example
12878 *
12879 * _.toSafeInteger(3.2);
12880 * // => 3
12881 *
12882 * _.toSafeInteger(Number.MIN_VALUE);
12883 * // => 0
12884 *
12885 * _.toSafeInteger(Infinity);
12886 * // => 9007199254740991
12887 *
12888 * _.toSafeInteger('3.2');
12889 * // => 3
12890 */
12891 function toSafeInteger(value) {
12892 return value
12893 ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
12894 : (value === 0 ? value : 0);
12895 }
12896
12897 /**
12898 * Converts `value` to a string. An empty string is returned for `null`
12899 * and `undefined` values. The sign of `-0` is preserved.
12900 *
12901 * @static
12902 * @memberOf _
12903 * @since 4.0.0
12904 * @category Lang
12905 * @param {*} value The value to convert.
12906 * @returns {string} Returns the converted string.
12907 * @example
12908 *
12909 * _.toString(null);
12910 * // => ''
12911 *
12912 * _.toString(-0);
12913 * // => '-0'
12914 *
12915 * _.toString([1, 2, 3]);
12916 * // => '1,2,3'
12917 */
12918 function toString(value) {
12919 return value == null ? '' : baseToString(value);
12920 }
12921
12922 /*------------------------------------------------------------------------*/
12923
12924 /**
12925 * Assigns own enumerable string keyed properties of source objects to the
12926 * destination object. Source objects are applied from left to right.
12927 * Subsequent sources overwrite property assignments of previous sources.
12928 *
12929 * **Note:** This method mutates `object` and is loosely based on
12930 * [`Object.assign`](https://mdn.io/Object/assign).
12931 *
12932 * @static
12933 * @memberOf _
12934 * @since 0.10.0
12935 * @category Object
12936 * @param {Object} object The destination object.
12937 * @param {...Object} [sources] The source objects.
12938 * @returns {Object} Returns `object`.
12939 * @see _.assignIn
12940 * @example
12941 *
12942 * function Foo() {
12943 * this.a = 1;
12944 * }
12945 *
12946 * function Bar() {
12947 * this.c = 3;
12948 * }
12949 *
12950 * Foo.prototype.b = 2;
12951 * Bar.prototype.d = 4;
12952 *
12953 * _.assign({ 'a': 0 }, new Foo, new Bar);
12954 * // => { 'a': 1, 'c': 3 }
12955 */
12956 var assign = createAssigner(function(object, source) {
12957 if (isPrototype(source) || isArrayLike(source)) {
12958 copyObject(source, keys(source), object);
12959 return;
12960 }
12961 for (var key in source) {
12962 if (hasOwnProperty.call(source, key)) {
12963 assignValue(object, key, source[key]);
12964 }
12965 }
12966 });
12967
12968 /**
12969 * This method is like `_.assign` except that it iterates over own and
12970 * inherited source properties.
12971 *
12972 * **Note:** This method mutates `object`.
12973 *
12974 * @static
12975 * @memberOf _
12976 * @since 4.0.0
12977 * @alias extend
12978 * @category Object
12979 * @param {Object} object The destination object.
12980 * @param {...Object} [sources] The source objects.
12981 * @returns {Object} Returns `object`.
12982 * @see _.assign
12983 * @example
12984 *
12985 * function Foo() {
12986 * this.a = 1;
12987 * }
12988 *
12989 * function Bar() {
12990 * this.c = 3;
12991 * }
12992 *
12993 * Foo.prototype.b = 2;
12994 * Bar.prototype.d = 4;
12995 *
12996 * _.assignIn({ 'a': 0 }, new Foo, new Bar);
12997 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
12998 */
12999 var assignIn = createAssigner(function(object, source) {
13000 copyObject(source, keysIn(source), object);
13001 });
13002
13003 /**
13004 * This method is like `_.assignIn` except that it accepts `customizer`
13005 * which is invoked to produce the assigned values. If `customizer` returns
13006 * `undefined`, assignment is handled by the method instead. The `customizer`
13007 * is invoked with five arguments: (objValue, srcValue, key, object, source).
13008 *
13009 * **Note:** This method mutates `object`.
13010 *
13011 * @static
13012 * @memberOf _
13013 * @since 4.0.0
13014 * @alias extendWith
13015 * @category Object
13016 * @param {Object} object The destination object.
13017 * @param {...Object} sources The source objects.
13018 * @param {Function} [customizer] The function to customize assigned values.
13019 * @returns {Object} Returns `object`.
13020 * @see _.assignWith
13021 * @example
13022 *
13023 * function customizer(objValue, srcValue) {
13024 * return _.isUndefined(objValue) ? srcValue : objValue;
13025 * }
13026 *
13027 * var defaults = _.partialRight(_.assignInWith, customizer);
13028 *
13029 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
13030 * // => { 'a': 1, 'b': 2 }
13031 */
13032 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
13033 copyObject(source, keysIn(source), object, customizer);
13034 });
13035
13036 /**
13037 * This method is like `_.assign` except that it accepts `customizer`
13038 * which is invoked to produce the assigned values. If `customizer` returns
13039 * `undefined`, assignment is handled by the method instead. The `customizer`
13040 * is invoked with five arguments: (objValue, srcValue, key, object, source).
13041 *
13042 * **Note:** This method mutates `object`.
13043 *
13044 * @static
13045 * @memberOf _
13046 * @since 4.0.0
13047 * @category Object
13048 * @param {Object} object The destination object.
13049 * @param {...Object} sources The source objects.
13050 * @param {Function} [customizer] The function to customize assigned values.
13051 * @returns {Object} Returns `object`.
13052 * @see _.assignInWith
13053 * @example
13054 *
13055 * function customizer(objValue, srcValue) {
13056 * return _.isUndefined(objValue) ? srcValue : objValue;
13057 * }
13058 *
13059 * var defaults = _.partialRight(_.assignWith, customizer);
13060 *
13061 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
13062 * // => { 'a': 1, 'b': 2 }
13063 */
13064 var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
13065 copyObject(source, keys(source), object, customizer);
13066 });
13067
13068 /**
13069 * Creates an array of values corresponding to `paths` of `object`.
13070 *
13071 * @static
13072 * @memberOf _
13073 * @since 1.0.0
13074 * @category Object
13075 * @param {Object} object The object to iterate over.
13076 * @param {...(string|string[])} [paths] The property paths to pick.
13077 * @returns {Array} Returns the picked values.
13078 * @example
13079 *
13080 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
13081 *
13082 * _.at(object, ['a[0].b.c', 'a[1]']);
13083 * // => [3, 4]
13084 */
13085 var at = flatRest(baseAt);
13086
13087 /**
13088 * Creates an object that inherits from the `prototype` object. If a
13089 * `properties` object is given, its own enumerable string keyed properties
13090 * are assigned to the created object.
13091 *
13092 * @static
13093 * @memberOf _
13094 * @since 2.3.0
13095 * @category Object
13096 * @param {Object} prototype The object to inherit from.
13097 * @param {Object} [properties] The properties to assign to the object.
13098 * @returns {Object} Returns the new object.
13099 * @example
13100 *
13101 * function Shape() {
13102 * this.x = 0;
13103 * this.y = 0;
13104 * }
13105 *
13106 * function Circle() {
13107 * Shape.call(this);
13108 * }
13109 *
13110 * Circle.prototype = _.create(Shape.prototype, {
13111 * 'constructor': Circle
13112 * });
13113 *
13114 * var circle = new Circle;
13115 * circle instanceof Circle;
13116 * // => true
13117 *
13118 * circle instanceof Shape;
13119 * // => true
13120 */
13121 function create(prototype, properties) {
13122 var result = baseCreate(prototype);
13123 return properties == null ? result : baseAssign(result, properties);
13124 }
13125
13126 /**
13127 * Assigns own and inherited enumerable string keyed properties of source
13128 * objects to the destination object for all destination properties that
13129 * resolve to `undefined`. Source objects are applied from left to right.
13130 * Once a property is set, additional values of the same property are ignored.
13131 *
13132 * **Note:** This method mutates `object`.
13133 *
13134 * @static
13135 * @since 0.1.0
13136 * @memberOf _
13137 * @category Object
13138 * @param {Object} object The destination object.
13139 * @param {...Object} [sources] The source objects.
13140 * @returns {Object} Returns `object`.
13141 * @see _.defaultsDeep
13142 * @example
13143 *
13144 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
13145 * // => { 'a': 1, 'b': 2 }
13146 */
13147 var defaults = baseRest(function(object, sources) {
13148 object = Object(object);
13149
13150 var index = -1;
13151 var length = sources.length;
13152 var guard = length > 2 ? sources[2] : undefined$1;
13153
13154 if (guard && isIterateeCall(sources[0], sources[1], guard)) {
13155 length = 1;
13156 }
13157
13158 while (++index < length) {
13159 var source = sources[index];
13160 var props = keysIn(source);
13161 var propsIndex = -1;
13162 var propsLength = props.length;
13163
13164 while (++propsIndex < propsLength) {
13165 var key = props[propsIndex];
13166 var value = object[key];
13167
13168 if (value === undefined$1 ||
13169 (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
13170 object[key] = source[key];
13171 }
13172 }
13173 }
13174
13175 return object;
13176 });
13177
13178 /**
13179 * This method is like `_.defaults` except that it recursively assigns
13180 * default properties.
13181 *
13182 * **Note:** This method mutates `object`.
13183 *
13184 * @static
13185 * @memberOf _
13186 * @since 3.10.0
13187 * @category Object
13188 * @param {Object} object The destination object.
13189 * @param {...Object} [sources] The source objects.
13190 * @returns {Object} Returns `object`.
13191 * @see _.defaults
13192 * @example
13193 *
13194 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
13195 * // => { 'a': { 'b': 2, 'c': 3 } }
13196 */
13197 var defaultsDeep = baseRest(function(args) {
13198 args.push(undefined$1, customDefaultsMerge);
13199 return apply(mergeWith, undefined$1, args);
13200 });
13201
13202 /**
13203 * This method is like `_.find` except that it returns the key of the first
13204 * element `predicate` returns truthy for instead of the element itself.
13205 *
13206 * @static
13207 * @memberOf _
13208 * @since 1.1.0
13209 * @category Object
13210 * @param {Object} object The object to inspect.
13211 * @param {Function} [predicate=_.identity] The function invoked per iteration.
13212 * @returns {string|undefined} Returns the key of the matched element,
13213 * else `undefined`.
13214 * @example
13215 *
13216 * var users = {
13217 * 'barney': { 'age': 36, 'active': true },
13218 * 'fred': { 'age': 40, 'active': false },
13219 * 'pebbles': { 'age': 1, 'active': true }
13220 * };
13221 *
13222 * _.findKey(users, function(o) { return o.age < 40; });
13223 * // => 'barney' (iteration order is not guaranteed)
13224 *
13225 * // The `_.matches` iteratee shorthand.
13226 * _.findKey(users, { 'age': 1, 'active': true });
13227 * // => 'pebbles'
13228 *
13229 * // The `_.matchesProperty` iteratee shorthand.
13230 * _.findKey(users, ['active', false]);
13231 * // => 'fred'
13232 *
13233 * // The `_.property` iteratee shorthand.
13234 * _.findKey(users, 'active');
13235 * // => 'barney'
13236 */
13237 function findKey(object, predicate) {
13238 return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
13239 }
13240
13241 /**
13242 * This method is like `_.findKey` except that it iterates over elements of
13243 * a collection in the opposite order.
13244 *
13245 * @static
13246 * @memberOf _
13247 * @since 2.0.0
13248 * @category Object
13249 * @param {Object} object The object to inspect.
13250 * @param {Function} [predicate=_.identity] The function invoked per iteration.
13251 * @returns {string|undefined} Returns the key of the matched element,
13252 * else `undefined`.
13253 * @example
13254 *
13255 * var users = {
13256 * 'barney': { 'age': 36, 'active': true },
13257 * 'fred': { 'age': 40, 'active': false },
13258 * 'pebbles': { 'age': 1, 'active': true }
13259 * };
13260 *
13261 * _.findLastKey(users, function(o) { return o.age < 40; });
13262 * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
13263 *
13264 * // The `_.matches` iteratee shorthand.
13265 * _.findLastKey(users, { 'age': 36, 'active': true });
13266 * // => 'barney'
13267 *
13268 * // The `_.matchesProperty` iteratee shorthand.
13269 * _.findLastKey(users, ['active', false]);
13270 * // => 'fred'
13271 *
13272 * // The `_.property` iteratee shorthand.
13273 * _.findLastKey(users, 'active');
13274 * // => 'pebbles'
13275 */
13276 function findLastKey(object, predicate) {
13277 return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
13278 }
13279
13280 /**
13281 * Iterates over own and inherited enumerable string keyed properties of an
13282 * object and invokes `iteratee` for each property. The iteratee is invoked
13283 * with three arguments: (value, key, object). Iteratee functions may exit
13284 * iteration early by explicitly returning `false`.
13285 *
13286 * @static
13287 * @memberOf _
13288 * @since 0.3.0
13289 * @category Object
13290 * @param {Object} object The object to iterate over.
13291 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13292 * @returns {Object} Returns `object`.
13293 * @see _.forInRight
13294 * @example
13295 *
13296 * function Foo() {
13297 * this.a = 1;
13298 * this.b = 2;
13299 * }
13300 *
13301 * Foo.prototype.c = 3;
13302 *
13303 * _.forIn(new Foo, function(value, key) {
13304 * console.log(key);
13305 * });
13306 * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
13307 */
13308 function forIn(object, iteratee) {
13309 return object == null
13310 ? object
13311 : baseFor(object, getIteratee(iteratee, 3), keysIn);
13312 }
13313
13314 /**
13315 * This method is like `_.forIn` except that it iterates over properties of
13316 * `object` in the opposite order.
13317 *
13318 * @static
13319 * @memberOf _
13320 * @since 2.0.0
13321 * @category Object
13322 * @param {Object} object The object to iterate over.
13323 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13324 * @returns {Object} Returns `object`.
13325 * @see _.forIn
13326 * @example
13327 *
13328 * function Foo() {
13329 * this.a = 1;
13330 * this.b = 2;
13331 * }
13332 *
13333 * Foo.prototype.c = 3;
13334 *
13335 * _.forInRight(new Foo, function(value, key) {
13336 * console.log(key);
13337 * });
13338 * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
13339 */
13340 function forInRight(object, iteratee) {
13341 return object == null
13342 ? object
13343 : baseForRight(object, getIteratee(iteratee, 3), keysIn);
13344 }
13345
13346 /**
13347 * Iterates over own enumerable string keyed properties of an object and
13348 * invokes `iteratee` for each property. The iteratee is invoked with three
13349 * arguments: (value, key, object). Iteratee functions may exit iteration
13350 * early by explicitly returning `false`.
13351 *
13352 * @static
13353 * @memberOf _
13354 * @since 0.3.0
13355 * @category Object
13356 * @param {Object} object The object to iterate over.
13357 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13358 * @returns {Object} Returns `object`.
13359 * @see _.forOwnRight
13360 * @example
13361 *
13362 * function Foo() {
13363 * this.a = 1;
13364 * this.b = 2;
13365 * }
13366 *
13367 * Foo.prototype.c = 3;
13368 *
13369 * _.forOwn(new Foo, function(value, key) {
13370 * console.log(key);
13371 * });
13372 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
13373 */
13374 function forOwn(object, iteratee) {
13375 return object && baseForOwn(object, getIteratee(iteratee, 3));
13376 }
13377
13378 /**
13379 * This method is like `_.forOwn` except that it iterates over properties of
13380 * `object` in the opposite order.
13381 *
13382 * @static
13383 * @memberOf _
13384 * @since 2.0.0
13385 * @category Object
13386 * @param {Object} object The object to iterate over.
13387 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13388 * @returns {Object} Returns `object`.
13389 * @see _.forOwn
13390 * @example
13391 *
13392 * function Foo() {
13393 * this.a = 1;
13394 * this.b = 2;
13395 * }
13396 *
13397 * Foo.prototype.c = 3;
13398 *
13399 * _.forOwnRight(new Foo, function(value, key) {
13400 * console.log(key);
13401 * });
13402 * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
13403 */
13404 function forOwnRight(object, iteratee) {
13405 return object && baseForOwnRight(object, getIteratee(iteratee, 3));
13406 }
13407
13408 /**
13409 * Creates an array of function property names from own enumerable properties
13410 * of `object`.
13411 *
13412 * @static
13413 * @since 0.1.0
13414 * @memberOf _
13415 * @category Object
13416 * @param {Object} object The object to inspect.
13417 * @returns {Array} Returns the function names.
13418 * @see _.functionsIn
13419 * @example
13420 *
13421 * function Foo() {
13422 * this.a = _.constant('a');
13423 * this.b = _.constant('b');
13424 * }
13425 *
13426 * Foo.prototype.c = _.constant('c');
13427 *
13428 * _.functions(new Foo);
13429 * // => ['a', 'b']
13430 */
13431 function functions(object) {
13432 return object == null ? [] : baseFunctions(object, keys(object));
13433 }
13434
13435 /**
13436 * Creates an array of function property names from own and inherited
13437 * enumerable properties of `object`.
13438 *
13439 * @static
13440 * @memberOf _
13441 * @since 4.0.0
13442 * @category Object
13443 * @param {Object} object The object to inspect.
13444 * @returns {Array} Returns the function names.
13445 * @see _.functions
13446 * @example
13447 *
13448 * function Foo() {
13449 * this.a = _.constant('a');
13450 * this.b = _.constant('b');
13451 * }
13452 *
13453 * Foo.prototype.c = _.constant('c');
13454 *
13455 * _.functionsIn(new Foo);
13456 * // => ['a', 'b', 'c']
13457 */
13458 function functionsIn(object) {
13459 return object == null ? [] : baseFunctions(object, keysIn(object));
13460 }
13461
13462 /**
13463 * Gets the value at `path` of `object`. If the resolved value is
13464 * `undefined`, the `defaultValue` is returned in its place.
13465 *
13466 * @static
13467 * @memberOf _
13468 * @since 3.7.0
13469 * @category Object
13470 * @param {Object} object The object to query.
13471 * @param {Array|string} path The path of the property to get.
13472 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
13473 * @returns {*} Returns the resolved value.
13474 * @example
13475 *
13476 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13477 *
13478 * _.get(object, 'a[0].b.c');
13479 * // => 3
13480 *
13481 * _.get(object, ['a', '0', 'b', 'c']);
13482 * // => 3
13483 *
13484 * _.get(object, 'a.b.c', 'default');
13485 * // => 'default'
13486 */
13487 function get(object, path, defaultValue) {
13488 var result = object == null ? undefined$1 : baseGet(object, path);
13489 return result === undefined$1 ? defaultValue : result;
13490 }
13491
13492 /**
13493 * Checks if `path` is a direct property of `object`.
13494 *
13495 * @static
13496 * @since 0.1.0
13497 * @memberOf _
13498 * @category Object
13499 * @param {Object} object The object to query.
13500 * @param {Array|string} path The path to check.
13501 * @returns {boolean} Returns `true` if `path` exists, else `false`.
13502 * @example
13503 *
13504 * var object = { 'a': { 'b': 2 } };
13505 * var other = _.create({ 'a': _.create({ 'b': 2 }) });
13506 *
13507 * _.has(object, 'a');
13508 * // => true
13509 *
13510 * _.has(object, 'a.b');
13511 * // => true
13512 *
13513 * _.has(object, ['a', 'b']);
13514 * // => true
13515 *
13516 * _.has(other, 'a');
13517 * // => false
13518 */
13519 function has(object, path) {
13520 return object != null && hasPath(object, path, baseHas);
13521 }
13522
13523 /**
13524 * Checks if `path` is a direct or inherited property of `object`.
13525 *
13526 * @static
13527 * @memberOf _
13528 * @since 4.0.0
13529 * @category Object
13530 * @param {Object} object The object to query.
13531 * @param {Array|string} path The path to check.
13532 * @returns {boolean} Returns `true` if `path` exists, else `false`.
13533 * @example
13534 *
13535 * var object = _.create({ 'a': _.create({ 'b': 2 }) });
13536 *
13537 * _.hasIn(object, 'a');
13538 * // => true
13539 *
13540 * _.hasIn(object, 'a.b');
13541 * // => true
13542 *
13543 * _.hasIn(object, ['a', 'b']);
13544 * // => true
13545 *
13546 * _.hasIn(object, 'b');
13547 * // => false
13548 */
13549 function hasIn(object, path) {
13550 return object != null && hasPath(object, path, baseHasIn);
13551 }
13552
13553 /**
13554 * Creates an object composed of the inverted keys and values of `object`.
13555 * If `object` contains duplicate values, subsequent values overwrite
13556 * property assignments of previous values.
13557 *
13558 * @static
13559 * @memberOf _
13560 * @since 0.7.0
13561 * @category Object
13562 * @param {Object} object The object to invert.
13563 * @returns {Object} Returns the new inverted object.
13564 * @example
13565 *
13566 * var object = { 'a': 1, 'b': 2, 'c': 1 };
13567 *
13568 * _.invert(object);
13569 * // => { '1': 'c', '2': 'b' }
13570 */
13571 var invert = createInverter(function(result, value, key) {
13572 if (value != null &&
13573 typeof value.toString != 'function') {
13574 value = nativeObjectToString.call(value);
13575 }
13576
13577 result[value] = key;
13578 }, constant(identity));
13579
13580 /**
13581 * This method is like `_.invert` except that the inverted object is generated
13582 * from the results of running each element of `object` thru `iteratee`. The
13583 * corresponding inverted value of each inverted key is an array of keys
13584 * responsible for generating the inverted value. The iteratee is invoked
13585 * with one argument: (value).
13586 *
13587 * @static
13588 * @memberOf _
13589 * @since 4.1.0
13590 * @category Object
13591 * @param {Object} object The object to invert.
13592 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
13593 * @returns {Object} Returns the new inverted object.
13594 * @example
13595 *
13596 * var object = { 'a': 1, 'b': 2, 'c': 1 };
13597 *
13598 * _.invertBy(object);
13599 * // => { '1': ['a', 'c'], '2': ['b'] }
13600 *
13601 * _.invertBy(object, function(value) {
13602 * return 'group' + value;
13603 * });
13604 * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
13605 */
13606 var invertBy = createInverter(function(result, value, key) {
13607 if (value != null &&
13608 typeof value.toString != 'function') {
13609 value = nativeObjectToString.call(value);
13610 }
13611
13612 if (hasOwnProperty.call(result, value)) {
13613 result[value].push(key);
13614 } else {
13615 result[value] = [key];
13616 }
13617 }, getIteratee);
13618
13619 /**
13620 * Invokes the method at `path` of `object`.
13621 *
13622 * @static
13623 * @memberOf _
13624 * @since 4.0.0
13625 * @category Object
13626 * @param {Object} object The object to query.
13627 * @param {Array|string} path The path of the method to invoke.
13628 * @param {...*} [args] The arguments to invoke the method with.
13629 * @returns {*} Returns the result of the invoked method.
13630 * @example
13631 *
13632 * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
13633 *
13634 * _.invoke(object, 'a[0].b.c.slice', 1, 3);
13635 * // => [2, 3]
13636 */
13637 var invoke = baseRest(baseInvoke);
13638
13639 /**
13640 * Creates an array of the own enumerable property names of `object`.
13641 *
13642 * **Note:** Non-object values are coerced to objects. See the
13643 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
13644 * for more details.
13645 *
13646 * @static
13647 * @since 0.1.0
13648 * @memberOf _
13649 * @category Object
13650 * @param {Object} object The object to query.
13651 * @returns {Array} Returns the array of property names.
13652 * @example
13653 *
13654 * function Foo() {
13655 * this.a = 1;
13656 * this.b = 2;
13657 * }
13658 *
13659 * Foo.prototype.c = 3;
13660 *
13661 * _.keys(new Foo);
13662 * // => ['a', 'b'] (iteration order is not guaranteed)
13663 *
13664 * _.keys('hi');
13665 * // => ['0', '1']
13666 */
13667 function keys(object) {
13668 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
13669 }
13670
13671 /**
13672 * Creates an array of the own and inherited enumerable property names of `object`.
13673 *
13674 * **Note:** Non-object values are coerced to objects.
13675 *
13676 * @static
13677 * @memberOf _
13678 * @since 3.0.0
13679 * @category Object
13680 * @param {Object} object The object to query.
13681 * @returns {Array} Returns the array of property names.
13682 * @example
13683 *
13684 * function Foo() {
13685 * this.a = 1;
13686 * this.b = 2;
13687 * }
13688 *
13689 * Foo.prototype.c = 3;
13690 *
13691 * _.keysIn(new Foo);
13692 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
13693 */
13694 function keysIn(object) {
13695 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
13696 }
13697
13698 /**
13699 * The opposite of `_.mapValues`; this method creates an object with the
13700 * same values as `object` and keys generated by running each own enumerable
13701 * string keyed property of `object` thru `iteratee`. The iteratee is invoked
13702 * with three arguments: (value, key, object).
13703 *
13704 * @static
13705 * @memberOf _
13706 * @since 3.8.0
13707 * @category Object
13708 * @param {Object} object The object to iterate over.
13709 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13710 * @returns {Object} Returns the new mapped object.
13711 * @see _.mapValues
13712 * @example
13713 *
13714 * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
13715 * return key + value;
13716 * });
13717 * // => { 'a1': 1, 'b2': 2 }
13718 */
13719 function mapKeys(object, iteratee) {
13720 var result = {};
13721 iteratee = getIteratee(iteratee, 3);
13722
13723 baseForOwn(object, function(value, key, object) {
13724 baseAssignValue(result, iteratee(value, key, object), value);
13725 });
13726 return result;
13727 }
13728
13729 /**
13730 * Creates an object with the same keys as `object` and values generated
13731 * by running each own enumerable string keyed property of `object` thru
13732 * `iteratee`. The iteratee is invoked with three arguments:
13733 * (value, key, object).
13734 *
13735 * @static
13736 * @memberOf _
13737 * @since 2.4.0
13738 * @category Object
13739 * @param {Object} object The object to iterate over.
13740 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13741 * @returns {Object} Returns the new mapped object.
13742 * @see _.mapKeys
13743 * @example
13744 *
13745 * var users = {
13746 * 'fred': { 'user': 'fred', 'age': 40 },
13747 * 'pebbles': { 'user': 'pebbles', 'age': 1 }
13748 * };
13749 *
13750 * _.mapValues(users, function(o) { return o.age; });
13751 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
13752 *
13753 * // The `_.property` iteratee shorthand.
13754 * _.mapValues(users, 'age');
13755 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
13756 */
13757 function mapValues(object, iteratee) {
13758 var result = {};
13759 iteratee = getIteratee(iteratee, 3);
13760
13761 baseForOwn(object, function(value, key, object) {
13762 baseAssignValue(result, key, iteratee(value, key, object));
13763 });
13764 return result;
13765 }
13766
13767 /**
13768 * This method is like `_.assign` except that it recursively merges own and
13769 * inherited enumerable string keyed properties of source objects into the
13770 * destination object. Source properties that resolve to `undefined` are
13771 * skipped if a destination value exists. Array and plain object properties
13772 * are merged recursively. Other objects and value types are overridden by
13773 * assignment. Source objects are applied from left to right. Subsequent
13774 * sources overwrite property assignments of previous sources.
13775 *
13776 * **Note:** This method mutates `object`.
13777 *
13778 * @static
13779 * @memberOf _
13780 * @since 0.5.0
13781 * @category Object
13782 * @param {Object} object The destination object.
13783 * @param {...Object} [sources] The source objects.
13784 * @returns {Object} Returns `object`.
13785 * @example
13786 *
13787 * var object = {
13788 * 'a': [{ 'b': 2 }, { 'd': 4 }]
13789 * };
13790 *
13791 * var other = {
13792 * 'a': [{ 'c': 3 }, { 'e': 5 }]
13793 * };
13794 *
13795 * _.merge(object, other);
13796 * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
13797 */
13798 var merge = createAssigner(function(object, source, srcIndex) {
13799 baseMerge(object, source, srcIndex);
13800 });
13801
13802 /**
13803 * This method is like `_.merge` except that it accepts `customizer` which
13804 * is invoked to produce the merged values of the destination and source
13805 * properties. If `customizer` returns `undefined`, merging is handled by the
13806 * method instead. The `customizer` is invoked with six arguments:
13807 * (objValue, srcValue, key, object, source, stack).
13808 *
13809 * **Note:** This method mutates `object`.
13810 *
13811 * @static
13812 * @memberOf _
13813 * @since 4.0.0
13814 * @category Object
13815 * @param {Object} object The destination object.
13816 * @param {...Object} sources The source objects.
13817 * @param {Function} customizer The function to customize assigned values.
13818 * @returns {Object} Returns `object`.
13819 * @example
13820 *
13821 * function customizer(objValue, srcValue) {
13822 * if (_.isArray(objValue)) {
13823 * return objValue.concat(srcValue);
13824 * }
13825 * }
13826 *
13827 * var object = { 'a': [1], 'b': [2] };
13828 * var other = { 'a': [3], 'b': [4] };
13829 *
13830 * _.mergeWith(object, other, customizer);
13831 * // => { 'a': [1, 3], 'b': [2, 4] }
13832 */
13833 var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
13834 baseMerge(object, source, srcIndex, customizer);
13835 });
13836
13837 /**
13838 * The opposite of `_.pick`; this method creates an object composed of the
13839 * own and inherited enumerable property paths of `object` that are not omitted.
13840 *
13841 * **Note:** This method is considerably slower than `_.pick`.
13842 *
13843 * @static
13844 * @since 0.1.0
13845 * @memberOf _
13846 * @category Object
13847 * @param {Object} object The source object.
13848 * @param {...(string|string[])} [paths] The property paths to omit.
13849 * @returns {Object} Returns the new object.
13850 * @example
13851 *
13852 * var object = { 'a': 1, 'b': '2', 'c': 3 };
13853 *
13854 * _.omit(object, ['a', 'c']);
13855 * // => { 'b': '2' }
13856 */
13857 var omit = flatRest(function(object, paths) {
13858 var result = {};
13859 if (object == null) {
13860 return result;
13861 }
13862 var isDeep = false;
13863 paths = arrayMap(paths, function(path) {
13864 path = castPath(path, object);
13865 isDeep || (isDeep = path.length > 1);
13866 return path;
13867 });
13868 copyObject(object, getAllKeysIn(object), result);
13869 if (isDeep) {
13870 result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
13871 }
13872 var length = paths.length;
13873 while (length--) {
13874 baseUnset(result, paths[length]);
13875 }
13876 return result;
13877 });
13878
13879 /**
13880 * The opposite of `_.pickBy`; this method creates an object composed of
13881 * the own and inherited enumerable string keyed properties of `object` that
13882 * `predicate` doesn't return truthy for. The predicate is invoked with two
13883 * arguments: (value, key).
13884 *
13885 * @static
13886 * @memberOf _
13887 * @since 4.0.0
13888 * @category Object
13889 * @param {Object} object The source object.
13890 * @param {Function} [predicate=_.identity] The function invoked per property.
13891 * @returns {Object} Returns the new object.
13892 * @example
13893 *
13894 * var object = { 'a': 1, 'b': '2', 'c': 3 };
13895 *
13896 * _.omitBy(object, _.isNumber);
13897 * // => { 'b': '2' }
13898 */
13899 function omitBy(object, predicate) {
13900 return pickBy(object, negate(getIteratee(predicate)));
13901 }
13902
13903 /**
13904 * Creates an object composed of the picked `object` properties.
13905 *
13906 * @static
13907 * @since 0.1.0
13908 * @memberOf _
13909 * @category Object
13910 * @param {Object} object The source object.
13911 * @param {...(string|string[])} [paths] The property paths to pick.
13912 * @returns {Object} Returns the new object.
13913 * @example
13914 *
13915 * var object = { 'a': 1, 'b': '2', 'c': 3 };
13916 *
13917 * _.pick(object, ['a', 'c']);
13918 * // => { 'a': 1, 'c': 3 }
13919 */
13920 var pick = flatRest(function(object, paths) {
13921 return object == null ? {} : basePick(object, paths);
13922 });
13923
13924 /**
13925 * Creates an object composed of the `object` properties `predicate` returns
13926 * truthy for. The predicate is invoked with two arguments: (value, key).
13927 *
13928 * @static
13929 * @memberOf _
13930 * @since 4.0.0
13931 * @category Object
13932 * @param {Object} object The source object.
13933 * @param {Function} [predicate=_.identity] The function invoked per property.
13934 * @returns {Object} Returns the new object.
13935 * @example
13936 *
13937 * var object = { 'a': 1, 'b': '2', 'c': 3 };
13938 *
13939 * _.pickBy(object, _.isNumber);
13940 * // => { 'a': 1, 'c': 3 }
13941 */
13942 function pickBy(object, predicate) {
13943 if (object == null) {
13944 return {};
13945 }
13946 var props = arrayMap(getAllKeysIn(object), function(prop) {
13947 return [prop];
13948 });
13949 predicate = getIteratee(predicate);
13950 return basePickBy(object, props, function(value, path) {
13951 return predicate(value, path[0]);
13952 });
13953 }
13954
13955 /**
13956 * This method is like `_.get` except that if the resolved value is a
13957 * function it's invoked with the `this` binding of its parent object and
13958 * its result is returned.
13959 *
13960 * @static
13961 * @since 0.1.0
13962 * @memberOf _
13963 * @category Object
13964 * @param {Object} object The object to query.
13965 * @param {Array|string} path The path of the property to resolve.
13966 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
13967 * @returns {*} Returns the resolved value.
13968 * @example
13969 *
13970 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
13971 *
13972 * _.result(object, 'a[0].b.c1');
13973 * // => 3
13974 *
13975 * _.result(object, 'a[0].b.c2');
13976 * // => 4
13977 *
13978 * _.result(object, 'a[0].b.c3', 'default');
13979 * // => 'default'
13980 *
13981 * _.result(object, 'a[0].b.c3', _.constant('default'));
13982 * // => 'default'
13983 */
13984 function result(object, path, defaultValue) {
13985 path = castPath(path, object);
13986
13987 var index = -1,
13988 length = path.length;
13989
13990 // Ensure the loop is entered when path is empty.
13991 if (!length) {
13992 length = 1;
13993 object = undefined$1;
13994 }
13995 while (++index < length) {
13996 var value = object == null ? undefined$1 : object[toKey(path[index])];
13997 if (value === undefined$1) {
13998 index = length;
13999 value = defaultValue;
14000 }
14001 object = isFunction(value) ? value.call(object) : value;
14002 }
14003 return object;
14004 }
14005
14006 /**
14007 * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
14008 * it's created. Arrays are created for missing index properties while objects
14009 * are created for all other missing properties. Use `_.setWith` to customize
14010 * `path` creation.
14011 *
14012 * **Note:** This method mutates `object`.
14013 *
14014 * @static
14015 * @memberOf _
14016 * @since 3.7.0
14017 * @category Object
14018 * @param {Object} object The object to modify.
14019 * @param {Array|string} path The path of the property to set.
14020 * @param {*} value The value to set.
14021 * @returns {Object} Returns `object`.
14022 * @example
14023 *
14024 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
14025 *
14026 * _.set(object, 'a[0].b.c', 4);
14027 * console.log(object.a[0].b.c);
14028 * // => 4
14029 *
14030 * _.set(object, ['x', '0', 'y', 'z'], 5);
14031 * console.log(object.x[0].y.z);
14032 * // => 5
14033 */
14034 function set(object, path, value) {
14035 return object == null ? object : baseSet(object, path, value);
14036 }
14037
14038 /**
14039 * This method is like `_.set` except that it accepts `customizer` which is
14040 * invoked to produce the objects of `path`. If `customizer` returns `undefined`
14041 * path creation is handled by the method instead. The `customizer` is invoked
14042 * with three arguments: (nsValue, key, nsObject).
14043 *
14044 * **Note:** This method mutates `object`.
14045 *
14046 * @static
14047 * @memberOf _
14048 * @since 4.0.0
14049 * @category Object
14050 * @param {Object} object The object to modify.
14051 * @param {Array|string} path The path of the property to set.
14052 * @param {*} value The value to set.
14053 * @param {Function} [customizer] The function to customize assigned values.
14054 * @returns {Object} Returns `object`.
14055 * @example
14056 *
14057 * var object = {};
14058 *
14059 * _.setWith(object, '[0][1]', 'a', Object);
14060 * // => { '0': { '1': 'a' } }
14061 */
14062 function setWith(object, path, value, customizer) {
14063 customizer = typeof customizer == 'function' ? customizer : undefined$1;
14064 return object == null ? object : baseSet(object, path, value, customizer);
14065 }
14066
14067 /**
14068 * Creates an array of own enumerable string keyed-value pairs for `object`
14069 * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
14070 * entries are returned.
14071 *
14072 * @static
14073 * @memberOf _
14074 * @since 4.0.0
14075 * @alias entries
14076 * @category Object
14077 * @param {Object} object The object to query.
14078 * @returns {Array} Returns the key-value pairs.
14079 * @example
14080 *
14081 * function Foo() {
14082 * this.a = 1;
14083 * this.b = 2;
14084 * }
14085 *
14086 * Foo.prototype.c = 3;
14087 *
14088 * _.toPairs(new Foo);
14089 * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
14090 */
14091 var toPairs = createToPairs(keys);
14092
14093 /**
14094 * Creates an array of own and inherited enumerable string keyed-value pairs
14095 * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
14096 * or set, its entries are returned.
14097 *
14098 * @static
14099 * @memberOf _
14100 * @since 4.0.0
14101 * @alias entriesIn
14102 * @category Object
14103 * @param {Object} object The object to query.
14104 * @returns {Array} Returns the key-value pairs.
14105 * @example
14106 *
14107 * function Foo() {
14108 * this.a = 1;
14109 * this.b = 2;
14110 * }
14111 *
14112 * Foo.prototype.c = 3;
14113 *
14114 * _.toPairsIn(new Foo);
14115 * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
14116 */
14117 var toPairsIn = createToPairs(keysIn);
14118
14119 /**
14120 * An alternative to `_.reduce`; this method transforms `object` to a new
14121 * `accumulator` object which is the result of running each of its own
14122 * enumerable string keyed properties thru `iteratee`, with each invocation
14123 * potentially mutating the `accumulator` object. If `accumulator` is not
14124 * provided, a new object with the same `[[Prototype]]` will be used. The
14125 * iteratee is invoked with four arguments: (accumulator, value, key, object).
14126 * Iteratee functions may exit iteration early by explicitly returning `false`.
14127 *
14128 * @static
14129 * @memberOf _
14130 * @since 1.3.0
14131 * @category Object
14132 * @param {Object} object The object to iterate over.
14133 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
14134 * @param {*} [accumulator] The custom accumulator value.
14135 * @returns {*} Returns the accumulated value.
14136 * @example
14137 *
14138 * _.transform([2, 3, 4], function(result, n) {
14139 * result.push(n *= n);
14140 * return n % 2 == 0;
14141 * }, []);
14142 * // => [4, 9]
14143 *
14144 * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
14145 * (result[value] || (result[value] = [])).push(key);
14146 * }, {});
14147 * // => { '1': ['a', 'c'], '2': ['b'] }
14148 */
14149 function transform(object, iteratee, accumulator) {
14150 var isArr = isArray(object),
14151 isArrLike = isArr || isBuffer(object) || isTypedArray(object);
14152
14153 iteratee = getIteratee(iteratee, 4);
14154 if (accumulator == null) {
14155 var Ctor = object && object.constructor;
14156 if (isArrLike) {
14157 accumulator = isArr ? new Ctor : [];
14158 }
14159 else if (isObject(object)) {
14160 accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
14161 }
14162 else {
14163 accumulator = {};
14164 }
14165 }
14166 (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
14167 return iteratee(accumulator, value, index, object);
14168 });
14169 return accumulator;
14170 }
14171
14172 /**
14173 * Removes the property at `path` of `object`.
14174 *
14175 * **Note:** This method mutates `object`.
14176 *
14177 * @static
14178 * @memberOf _
14179 * @since 4.0.0
14180 * @category Object
14181 * @param {Object} object The object to modify.
14182 * @param {Array|string} path The path of the property to unset.
14183 * @returns {boolean} Returns `true` if the property is deleted, else `false`.
14184 * @example
14185 *
14186 * var object = { 'a': [{ 'b': { 'c': 7 } }] };
14187 * _.unset(object, 'a[0].b.c');
14188 * // => true
14189 *
14190 * console.log(object);
14191 * // => { 'a': [{ 'b': {} }] };
14192 *
14193 * _.unset(object, ['a', '0', 'b', 'c']);
14194 * // => true
14195 *
14196 * console.log(object);
14197 * // => { 'a': [{ 'b': {} }] };
14198 */
14199 function unset(object, path) {
14200 return object == null ? true : baseUnset(object, path);
14201 }
14202
14203 /**
14204 * This method is like `_.set` except that accepts `updater` to produce the
14205 * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
14206 * is invoked with one argument: (value).
14207 *
14208 * **Note:** This method mutates `object`.
14209 *
14210 * @static
14211 * @memberOf _
14212 * @since 4.6.0
14213 * @category Object
14214 * @param {Object} object The object to modify.
14215 * @param {Array|string} path The path of the property to set.
14216 * @param {Function} updater The function to produce the updated value.
14217 * @returns {Object} Returns `object`.
14218 * @example
14219 *
14220 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
14221 *
14222 * _.update(object, 'a[0].b.c', function(n) { return n * n; });
14223 * console.log(object.a[0].b.c);
14224 * // => 9
14225 *
14226 * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
14227 * console.log(object.x[0].y.z);
14228 * // => 0
14229 */
14230 function update(object, path, updater) {
14231 return object == null ? object : baseUpdate(object, path, castFunction(updater));
14232 }
14233
14234 /**
14235 * This method is like `_.update` except that it accepts `customizer` which is
14236 * invoked to produce the objects of `path`. If `customizer` returns `undefined`
14237 * path creation is handled by the method instead. The `customizer` is invoked
14238 * with three arguments: (nsValue, key, nsObject).
14239 *
14240 * **Note:** This method mutates `object`.
14241 *
14242 * @static
14243 * @memberOf _
14244 * @since 4.6.0
14245 * @category Object
14246 * @param {Object} object The object to modify.
14247 * @param {Array|string} path The path of the property to set.
14248 * @param {Function} updater The function to produce the updated value.
14249 * @param {Function} [customizer] The function to customize assigned values.
14250 * @returns {Object} Returns `object`.
14251 * @example
14252 *
14253 * var object = {};
14254 *
14255 * _.updateWith(object, '[0][1]', _.constant('a'), Object);
14256 * // => { '0': { '1': 'a' } }
14257 */
14258 function updateWith(object, path, updater, customizer) {
14259 customizer = typeof customizer == 'function' ? customizer : undefined$1;
14260 return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
14261 }
14262
14263 /**
14264 * Creates an array of the own enumerable string keyed property values of `object`.
14265 *
14266 * **Note:** Non-object values are coerced to objects.
14267 *
14268 * @static
14269 * @since 0.1.0
14270 * @memberOf _
14271 * @category Object
14272 * @param {Object} object The object to query.
14273 * @returns {Array} Returns the array of property values.
14274 * @example
14275 *
14276 * function Foo() {
14277 * this.a = 1;
14278 * this.b = 2;
14279 * }
14280 *
14281 * Foo.prototype.c = 3;
14282 *
14283 * _.values(new Foo);
14284 * // => [1, 2] (iteration order is not guaranteed)
14285 *
14286 * _.values('hi');
14287 * // => ['h', 'i']
14288 */
14289 function values(object) {
14290 return object == null ? [] : baseValues(object, keys(object));
14291 }
14292
14293 /**
14294 * Creates an array of the own and inherited enumerable string keyed property
14295 * values of `object`.
14296 *
14297 * **Note:** Non-object values are coerced to objects.
14298 *
14299 * @static
14300 * @memberOf _
14301 * @since 3.0.0
14302 * @category Object
14303 * @param {Object} object The object to query.
14304 * @returns {Array} Returns the array of property values.
14305 * @example
14306 *
14307 * function Foo() {
14308 * this.a = 1;
14309 * this.b = 2;
14310 * }
14311 *
14312 * Foo.prototype.c = 3;
14313 *
14314 * _.valuesIn(new Foo);
14315 * // => [1, 2, 3] (iteration order is not guaranteed)
14316 */
14317 function valuesIn(object) {
14318 return object == null ? [] : baseValues(object, keysIn(object));
14319 }
14320
14321 /*------------------------------------------------------------------------*/
14322
14323 /**
14324 * Clamps `number` within the inclusive `lower` and `upper` bounds.
14325 *
14326 * @static
14327 * @memberOf _
14328 * @since 4.0.0
14329 * @category Number
14330 * @param {number} number The number to clamp.
14331 * @param {number} [lower] The lower bound.
14332 * @param {number} upper The upper bound.
14333 * @returns {number} Returns the clamped number.
14334 * @example
14335 *
14336 * _.clamp(-10, -5, 5);
14337 * // => -5
14338 *
14339 * _.clamp(10, -5, 5);
14340 * // => 5
14341 */
14342 function clamp(number, lower, upper) {
14343 if (upper === undefined$1) {
14344 upper = lower;
14345 lower = undefined$1;
14346 }
14347 if (upper !== undefined$1) {
14348 upper = toNumber(upper);
14349 upper = upper === upper ? upper : 0;
14350 }
14351 if (lower !== undefined$1) {
14352 lower = toNumber(lower);
14353 lower = lower === lower ? lower : 0;
14354 }
14355 return baseClamp(toNumber(number), lower, upper);
14356 }
14357
14358 /**
14359 * Checks if `n` is between `start` and up to, but not including, `end`. If
14360 * `end` is not specified, it's set to `start` with `start` then set to `0`.
14361 * If `start` is greater than `end` the params are swapped to support
14362 * negative ranges.
14363 *
14364 * @static
14365 * @memberOf _
14366 * @since 3.3.0
14367 * @category Number
14368 * @param {number} number The number to check.
14369 * @param {number} [start=0] The start of the range.
14370 * @param {number} end The end of the range.
14371 * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
14372 * @see _.range, _.rangeRight
14373 * @example
14374 *
14375 * _.inRange(3, 2, 4);
14376 * // => true
14377 *
14378 * _.inRange(4, 8);
14379 * // => true
14380 *
14381 * _.inRange(4, 2);
14382 * // => false
14383 *
14384 * _.inRange(2, 2);
14385 * // => false
14386 *
14387 * _.inRange(1.2, 2);
14388 * // => true
14389 *
14390 * _.inRange(5.2, 4);
14391 * // => false
14392 *
14393 * _.inRange(-3, -2, -6);
14394 * // => true
14395 */
14396 function inRange(number, start, end) {
14397 start = toFinite(start);
14398 if (end === undefined$1) {
14399 end = start;
14400 start = 0;
14401 } else {
14402 end = toFinite(end);
14403 }
14404 number = toNumber(number);
14405 return baseInRange(number, start, end);
14406 }
14407
14408 /**
14409 * Produces a random number between the inclusive `lower` and `upper` bounds.
14410 * If only one argument is provided a number between `0` and the given number
14411 * is returned. If `floating` is `true`, or either `lower` or `upper` are
14412 * floats, a floating-point number is returned instead of an integer.
14413 *
14414 * **Note:** JavaScript follows the IEEE-754 standard for resolving
14415 * floating-point values which can produce unexpected results.
14416 *
14417 * @static
14418 * @memberOf _
14419 * @since 0.7.0
14420 * @category Number
14421 * @param {number} [lower=0] The lower bound.
14422 * @param {number} [upper=1] The upper bound.
14423 * @param {boolean} [floating] Specify returning a floating-point number.
14424 * @returns {number} Returns the random number.
14425 * @example
14426 *
14427 * _.random(0, 5);
14428 * // => an integer between 0 and 5
14429 *
14430 * _.random(5);
14431 * // => also an integer between 0 and 5
14432 *
14433 * _.random(5, true);
14434 * // => a floating-point number between 0 and 5
14435 *
14436 * _.random(1.2, 5.2);
14437 * // => a floating-point number between 1.2 and 5.2
14438 */
14439 function random(lower, upper, floating) {
14440 if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
14441 upper = floating = undefined$1;
14442 }
14443 if (floating === undefined$1) {
14444 if (typeof upper == 'boolean') {
14445 floating = upper;
14446 upper = undefined$1;
14447 }
14448 else if (typeof lower == 'boolean') {
14449 floating = lower;
14450 lower = undefined$1;
14451 }
14452 }
14453 if (lower === undefined$1 && upper === undefined$1) {
14454 lower = 0;
14455 upper = 1;
14456 }
14457 else {
14458 lower = toFinite(lower);
14459 if (upper === undefined$1) {
14460 upper = lower;
14461 lower = 0;
14462 } else {
14463 upper = toFinite(upper);
14464 }
14465 }
14466 if (lower > upper) {
14467 var temp = lower;
14468 lower = upper;
14469 upper = temp;
14470 }
14471 if (floating || lower % 1 || upper % 1) {
14472 var rand = nativeRandom();
14473 return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
14474 }
14475 return baseRandom(lower, upper);
14476 }
14477
14478 /*------------------------------------------------------------------------*/
14479
14480 /**
14481 * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
14482 *
14483 * @static
14484 * @memberOf _
14485 * @since 3.0.0
14486 * @category String
14487 * @param {string} [string=''] The string to convert.
14488 * @returns {string} Returns the camel cased string.
14489 * @example
14490 *
14491 * _.camelCase('Foo Bar');
14492 * // => 'fooBar'
14493 *
14494 * _.camelCase('--foo-bar--');
14495 * // => 'fooBar'
14496 *
14497 * _.camelCase('__FOO_BAR__');
14498 * // => 'fooBar'
14499 */
14500 var camelCase = createCompounder(function(result, word, index) {
14501 word = word.toLowerCase();
14502 return result + (index ? capitalize(word) : word);
14503 });
14504
14505 /**
14506 * Converts the first character of `string` to upper case and the remaining
14507 * to lower case.
14508 *
14509 * @static
14510 * @memberOf _
14511 * @since 3.0.0
14512 * @category String
14513 * @param {string} [string=''] The string to capitalize.
14514 * @returns {string} Returns the capitalized string.
14515 * @example
14516 *
14517 * _.capitalize('FRED');
14518 * // => 'Fred'
14519 */
14520 function capitalize(string) {
14521 return upperFirst(toString(string).toLowerCase());
14522 }
14523
14524 /**
14525 * Deburrs `string` by converting
14526 * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
14527 * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
14528 * letters to basic Latin letters and removing
14529 * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
14530 *
14531 * @static
14532 * @memberOf _
14533 * @since 3.0.0
14534 * @category String
14535 * @param {string} [string=''] The string to deburr.
14536 * @returns {string} Returns the deburred string.
14537 * @example
14538 *
14539 * _.deburr('déjà vu');
14540 * // => 'deja vu'
14541 */
14542 function deburr(string) {
14543 string = toString(string);
14544 return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
14545 }
14546
14547 /**
14548 * Checks if `string` ends with the given target string.
14549 *
14550 * @static
14551 * @memberOf _
14552 * @since 3.0.0
14553 * @category String
14554 * @param {string} [string=''] The string to inspect.
14555 * @param {string} [target] The string to search for.
14556 * @param {number} [position=string.length] The position to search up to.
14557 * @returns {boolean} Returns `true` if `string` ends with `target`,
14558 * else `false`.
14559 * @example
14560 *
14561 * _.endsWith('abc', 'c');
14562 * // => true
14563 *
14564 * _.endsWith('abc', 'b');
14565 * // => false
14566 *
14567 * _.endsWith('abc', 'b', 2);
14568 * // => true
14569 */
14570 function endsWith(string, target, position) {
14571 string = toString(string);
14572 target = baseToString(target);
14573
14574 var length = string.length;
14575 position = position === undefined$1
14576 ? length
14577 : baseClamp(toInteger(position), 0, length);
14578
14579 var end = position;
14580 position -= target.length;
14581 return position >= 0 && string.slice(position, end) == target;
14582 }
14583
14584 /**
14585 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
14586 * corresponding HTML entities.
14587 *
14588 * **Note:** No other characters are escaped. To escape additional
14589 * characters use a third-party library like [_he_](https://mths.be/he).
14590 *
14591 * Though the ">" character is escaped for symmetry, characters like
14592 * ">" and "/" don't need escaping in HTML and have no special meaning
14593 * unless they're part of a tag or unquoted attribute value. See
14594 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
14595 * (under "semi-related fun fact") for more details.
14596 *
14597 * When working with HTML you should always
14598 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
14599 * XSS vectors.
14600 *
14601 * @static
14602 * @since 0.1.0
14603 * @memberOf _
14604 * @category String
14605 * @param {string} [string=''] The string to escape.
14606 * @returns {string} Returns the escaped string.
14607 * @example
14608 *
14609 * _.escape('fred, barney, & pebbles');
14610 * // => 'fred, barney, &amp; pebbles'
14611 */
14612 function escape(string) {
14613 string = toString(string);
14614 return (string && reHasUnescapedHtml.test(string))
14615 ? string.replace(reUnescapedHtml, escapeHtmlChar)
14616 : string;
14617 }
14618
14619 /**
14620 * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
14621 * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
14622 *
14623 * @static
14624 * @memberOf _
14625 * @since 3.0.0
14626 * @category String
14627 * @param {string} [string=''] The string to escape.
14628 * @returns {string} Returns the escaped string.
14629 * @example
14630 *
14631 * _.escapeRegExp('[lodash](https://lodash.com/)');
14632 * // => '\[lodash\]\(https://lodash\.com/\)'
14633 */
14634 function escapeRegExp(string) {
14635 string = toString(string);
14636 return (string && reHasRegExpChar.test(string))
14637 ? string.replace(reRegExpChar, '\\$&')
14638 : string;
14639 }
14640
14641 /**
14642 * Converts `string` to
14643 * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
14644 *
14645 * @static
14646 * @memberOf _
14647 * @since 3.0.0
14648 * @category String
14649 * @param {string} [string=''] The string to convert.
14650 * @returns {string} Returns the kebab cased string.
14651 * @example
14652 *
14653 * _.kebabCase('Foo Bar');
14654 * // => 'foo-bar'
14655 *
14656 * _.kebabCase('fooBar');
14657 * // => 'foo-bar'
14658 *
14659 * _.kebabCase('__FOO_BAR__');
14660 * // => 'foo-bar'
14661 */
14662 var kebabCase = createCompounder(function(result, word, index) {
14663 return result + (index ? '-' : '') + word.toLowerCase();
14664 });
14665
14666 /**
14667 * Converts `string`, as space separated words, to lower case.
14668 *
14669 * @static
14670 * @memberOf _
14671 * @since 4.0.0
14672 * @category String
14673 * @param {string} [string=''] The string to convert.
14674 * @returns {string} Returns the lower cased string.
14675 * @example
14676 *
14677 * _.lowerCase('--Foo-Bar--');
14678 * // => 'foo bar'
14679 *
14680 * _.lowerCase('fooBar');
14681 * // => 'foo bar'
14682 *
14683 * _.lowerCase('__FOO_BAR__');
14684 * // => 'foo bar'
14685 */
14686 var lowerCase = createCompounder(function(result, word, index) {
14687 return result + (index ? ' ' : '') + word.toLowerCase();
14688 });
14689
14690 /**
14691 * Converts the first character of `string` to lower case.
14692 *
14693 * @static
14694 * @memberOf _
14695 * @since 4.0.0
14696 * @category String
14697 * @param {string} [string=''] The string to convert.
14698 * @returns {string} Returns the converted string.
14699 * @example
14700 *
14701 * _.lowerFirst('Fred');
14702 * // => 'fred'
14703 *
14704 * _.lowerFirst('FRED');
14705 * // => 'fRED'
14706 */
14707 var lowerFirst = createCaseFirst('toLowerCase');
14708
14709 /**
14710 * Pads `string` on the left and right sides if it's shorter than `length`.
14711 * Padding characters are truncated if they can't be evenly divided by `length`.
14712 *
14713 * @static
14714 * @memberOf _
14715 * @since 3.0.0
14716 * @category String
14717 * @param {string} [string=''] The string to pad.
14718 * @param {number} [length=0] The padding length.
14719 * @param {string} [chars=' '] The string used as padding.
14720 * @returns {string} Returns the padded string.
14721 * @example
14722 *
14723 * _.pad('abc', 8);
14724 * // => ' abc '
14725 *
14726 * _.pad('abc', 8, '_-');
14727 * // => '_-abc_-_'
14728 *
14729 * _.pad('abc', 3);
14730 * // => 'abc'
14731 */
14732 function pad(string, length, chars) {
14733 string = toString(string);
14734 length = toInteger(length);
14735
14736 var strLength = length ? stringSize(string) : 0;
14737 if (!length || strLength >= length) {
14738 return string;
14739 }
14740 var mid = (length - strLength) / 2;
14741 return (
14742 createPadding(nativeFloor(mid), chars) +
14743 string +
14744 createPadding(nativeCeil(mid), chars)
14745 );
14746 }
14747
14748 /**
14749 * Pads `string` on the right side if it's shorter than `length`. Padding
14750 * characters are truncated if they exceed `length`.
14751 *
14752 * @static
14753 * @memberOf _
14754 * @since 4.0.0
14755 * @category String
14756 * @param {string} [string=''] The string to pad.
14757 * @param {number} [length=0] The padding length.
14758 * @param {string} [chars=' '] The string used as padding.
14759 * @returns {string} Returns the padded string.
14760 * @example
14761 *
14762 * _.padEnd('abc', 6);
14763 * // => 'abc '
14764 *
14765 * _.padEnd('abc', 6, '_-');
14766 * // => 'abc_-_'
14767 *
14768 * _.padEnd('abc', 3);
14769 * // => 'abc'
14770 */
14771 function padEnd(string, length, chars) {
14772 string = toString(string);
14773 length = toInteger(length);
14774
14775 var strLength = length ? stringSize(string) : 0;
14776 return (length && strLength < length)
14777 ? (string + createPadding(length - strLength, chars))
14778 : string;
14779 }
14780
14781 /**
14782 * Pads `string` on the left side if it's shorter than `length`. Padding
14783 * characters are truncated if they exceed `length`.
14784 *
14785 * @static
14786 * @memberOf _
14787 * @since 4.0.0
14788 * @category String
14789 * @param {string} [string=''] The string to pad.
14790 * @param {number} [length=0] The padding length.
14791 * @param {string} [chars=' '] The string used as padding.
14792 * @returns {string} Returns the padded string.
14793 * @example
14794 *
14795 * _.padStart('abc', 6);
14796 * // => ' abc'
14797 *
14798 * _.padStart('abc', 6, '_-');
14799 * // => '_-_abc'
14800 *
14801 * _.padStart('abc', 3);
14802 * // => 'abc'
14803 */
14804 function padStart(string, length, chars) {
14805 string = toString(string);
14806 length = toInteger(length);
14807
14808 var strLength = length ? stringSize(string) : 0;
14809 return (length && strLength < length)
14810 ? (createPadding(length - strLength, chars) + string)
14811 : string;
14812 }
14813
14814 /**
14815 * Converts `string` to an integer of the specified radix. If `radix` is
14816 * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
14817 * hexadecimal, in which case a `radix` of `16` is used.
14818 *
14819 * **Note:** This method aligns with the
14820 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
14821 *
14822 * @static
14823 * @memberOf _
14824 * @since 1.1.0
14825 * @category String
14826 * @param {string} string The string to convert.
14827 * @param {number} [radix=10] The radix to interpret `value` by.
14828 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14829 * @returns {number} Returns the converted integer.
14830 * @example
14831 *
14832 * _.parseInt('08');
14833 * // => 8
14834 *
14835 * _.map(['6', '08', '10'], _.parseInt);
14836 * // => [6, 8, 10]
14837 */
14838 function parseInt(string, radix, guard) {
14839 if (guard || radix == null) {
14840 radix = 0;
14841 } else if (radix) {
14842 radix = +radix;
14843 }
14844 return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
14845 }
14846
14847 /**
14848 * Repeats the given string `n` times.
14849 *
14850 * @static
14851 * @memberOf _
14852 * @since 3.0.0
14853 * @category String
14854 * @param {string} [string=''] The string to repeat.
14855 * @param {number} [n=1] The number of times to repeat the string.
14856 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14857 * @returns {string} Returns the repeated string.
14858 * @example
14859 *
14860 * _.repeat('*', 3);
14861 * // => '***'
14862 *
14863 * _.repeat('abc', 2);
14864 * // => 'abcabc'
14865 *
14866 * _.repeat('abc', 0);
14867 * // => ''
14868 */
14869 function repeat(string, n, guard) {
14870 if ((guard ? isIterateeCall(string, n, guard) : n === undefined$1)) {
14871 n = 1;
14872 } else {
14873 n = toInteger(n);
14874 }
14875 return baseRepeat(toString(string), n);
14876 }
14877
14878 /**
14879 * Replaces matches for `pattern` in `string` with `replacement`.
14880 *
14881 * **Note:** This method is based on
14882 * [`String#replace`](https://mdn.io/String/replace).
14883 *
14884 * @static
14885 * @memberOf _
14886 * @since 4.0.0
14887 * @category String
14888 * @param {string} [string=''] The string to modify.
14889 * @param {RegExp|string} pattern The pattern to replace.
14890 * @param {Function|string} replacement The match replacement.
14891 * @returns {string} Returns the modified string.
14892 * @example
14893 *
14894 * _.replace('Hi Fred', 'Fred', 'Barney');
14895 * // => 'Hi Barney'
14896 */
14897 function replace() {
14898 var args = arguments,
14899 string = toString(args[0]);
14900
14901 return args.length < 3 ? string : string.replace(args[1], args[2]);
14902 }
14903
14904 /**
14905 * Converts `string` to
14906 * [snake case](https://en.wikipedia.org/wiki/Snake_case).
14907 *
14908 * @static
14909 * @memberOf _
14910 * @since 3.0.0
14911 * @category String
14912 * @param {string} [string=''] The string to convert.
14913 * @returns {string} Returns the snake cased string.
14914 * @example
14915 *
14916 * _.snakeCase('Foo Bar');
14917 * // => 'foo_bar'
14918 *
14919 * _.snakeCase('fooBar');
14920 * // => 'foo_bar'
14921 *
14922 * _.snakeCase('--FOO-BAR--');
14923 * // => 'foo_bar'
14924 */
14925 var snakeCase = createCompounder(function(result, word, index) {
14926 return result + (index ? '_' : '') + word.toLowerCase();
14927 });
14928
14929 /**
14930 * Splits `string` by `separator`.
14931 *
14932 * **Note:** This method is based on
14933 * [`String#split`](https://mdn.io/String/split).
14934 *
14935 * @static
14936 * @memberOf _
14937 * @since 4.0.0
14938 * @category String
14939 * @param {string} [string=''] The string to split.
14940 * @param {RegExp|string} separator The separator pattern to split by.
14941 * @param {number} [limit] The length to truncate results to.
14942 * @returns {Array} Returns the string segments.
14943 * @example
14944 *
14945 * _.split('a-b-c', '-', 2);
14946 * // => ['a', 'b']
14947 */
14948 function split(string, separator, limit) {
14949 if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
14950 separator = limit = undefined$1;
14951 }
14952 limit = limit === undefined$1 ? MAX_ARRAY_LENGTH : limit >>> 0;
14953 if (!limit) {
14954 return [];
14955 }
14956 string = toString(string);
14957 if (string && (
14958 typeof separator == 'string' ||
14959 (separator != null && !isRegExp(separator))
14960 )) {
14961 separator = baseToString(separator);
14962 if (!separator && hasUnicode(string)) {
14963 return castSlice(stringToArray(string), 0, limit);
14964 }
14965 }
14966 return string.split(separator, limit);
14967 }
14968
14969 /**
14970 * Converts `string` to
14971 * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
14972 *
14973 * @static
14974 * @memberOf _
14975 * @since 3.1.0
14976 * @category String
14977 * @param {string} [string=''] The string to convert.
14978 * @returns {string} Returns the start cased string.
14979 * @example
14980 *
14981 * _.startCase('--foo-bar--');
14982 * // => 'Foo Bar'
14983 *
14984 * _.startCase('fooBar');
14985 * // => 'Foo Bar'
14986 *
14987 * _.startCase('__FOO_BAR__');
14988 * // => 'FOO BAR'
14989 */
14990 var startCase = createCompounder(function(result, word, index) {
14991 return result + (index ? ' ' : '') + upperFirst(word);
14992 });
14993
14994 /**
14995 * Checks if `string` starts with the given target string.
14996 *
14997 * @static
14998 * @memberOf _
14999 * @since 3.0.0
15000 * @category String
15001 * @param {string} [string=''] The string to inspect.
15002 * @param {string} [target] The string to search for.
15003 * @param {number} [position=0] The position to search from.
15004 * @returns {boolean} Returns `true` if `string` starts with `target`,
15005 * else `false`.
15006 * @example
15007 *
15008 * _.startsWith('abc', 'a');
15009 * // => true
15010 *
15011 * _.startsWith('abc', 'b');
15012 * // => false
15013 *
15014 * _.startsWith('abc', 'b', 1);
15015 * // => true
15016 */
15017 function startsWith(string, target, position) {
15018 string = toString(string);
15019 position = position == null
15020 ? 0
15021 : baseClamp(toInteger(position), 0, string.length);
15022
15023 target = baseToString(target);
15024 return string.slice(position, position + target.length) == target;
15025 }
15026
15027 /**
15028 * Creates a compiled template function that can interpolate data properties
15029 * in "interpolate" delimiters, HTML-escape interpolated data properties in
15030 * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
15031 * properties may be accessed as free variables in the template. If a setting
15032 * object is given, it takes precedence over `_.templateSettings` values.
15033 *
15034 * **Note:** In the development build `_.template` utilizes
15035 * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
15036 * for easier debugging.
15037 *
15038 * For more information on precompiling templates see
15039 * [lodash's custom builds documentation](https://lodash.com/custom-builds).
15040 *
15041 * For more information on Chrome extension sandboxes see
15042 * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
15043 *
15044 * @static
15045 * @since 0.1.0
15046 * @memberOf _
15047 * @category String
15048 * @param {string} [string=''] The template string.
15049 * @param {Object} [options={}] The options object.
15050 * @param {RegExp} [options.escape=_.templateSettings.escape]
15051 * The HTML "escape" delimiter.
15052 * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
15053 * The "evaluate" delimiter.
15054 * @param {Object} [options.imports=_.templateSettings.imports]
15055 * An object to import into the template as free variables.
15056 * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
15057 * The "interpolate" delimiter.
15058 * @param {string} [options.sourceURL='lodash.templateSources[n]']
15059 * The sourceURL of the compiled template.
15060 * @param {string} [options.variable='obj']
15061 * The data object variable name.
15062 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
15063 * @returns {Function} Returns the compiled template function.
15064 * @example
15065 *
15066 * // Use the "interpolate" delimiter to create a compiled template.
15067 * var compiled = _.template('hello <%= user %>!');
15068 * compiled({ 'user': 'fred' });
15069 * // => 'hello fred!'
15070 *
15071 * // Use the HTML "escape" delimiter to escape data property values.
15072 * var compiled = _.template('<b><%- value %></b>');
15073 * compiled({ 'value': '<script>' });
15074 * // => '<b>&lt;script&gt;</b>'
15075 *
15076 * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
15077 * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
15078 * compiled({ 'users': ['fred', 'barney'] });
15079 * // => '<li>fred</li><li>barney</li>'
15080 *
15081 * // Use the internal `print` function in "evaluate" delimiters.
15082 * var compiled = _.template('<% print("hello " + user); %>!');
15083 * compiled({ 'user': 'barney' });
15084 * // => 'hello barney!'
15085 *
15086 * // Use the ES template literal delimiter as an "interpolate" delimiter.
15087 * // Disable support by replacing the "interpolate" delimiter.
15088 * var compiled = _.template('hello ${ user }!');
15089 * compiled({ 'user': 'pebbles' });
15090 * // => 'hello pebbles!'
15091 *
15092 * // Use backslashes to treat delimiters as plain text.
15093 * var compiled = _.template('<%= "\\<%- value %\\>" %>');
15094 * compiled({ 'value': 'ignored' });
15095 * // => '<%- value %>'
15096 *
15097 * // Use the `imports` option to import `jQuery` as `jq`.
15098 * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
15099 * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
15100 * compiled({ 'users': ['fred', 'barney'] });
15101 * // => '<li>fred</li><li>barney</li>'
15102 *
15103 * // Use the `sourceURL` option to specify a custom sourceURL for the template.
15104 * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
15105 * compiled(data);
15106 * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
15107 *
15108 * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
15109 * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
15110 * compiled.source;
15111 * // => function(data) {
15112 * // var __t, __p = '';
15113 * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
15114 * // return __p;
15115 * // }
15116 *
15117 * // Use custom template delimiters.
15118 * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
15119 * var compiled = _.template('hello {{ user }}!');
15120 * compiled({ 'user': 'mustache' });
15121 * // => 'hello mustache!'
15122 *
15123 * // Use the `source` property to inline compiled templates for meaningful
15124 * // line numbers in error messages and stack traces.
15125 * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
15126 * var JST = {\
15127 * "main": ' + _.template(mainText).source + '\
15128 * };\
15129 * ');
15130 */
15131 function template(string, options, guard) {
15132 // Based on John Resig's `tmpl` implementation
15133 // (http://ejohn.org/blog/javascript-micro-templating/)
15134 // and Laura Doktorova's doT.js (https://github.com/olado/doT).
15135 var settings = lodash.templateSettings;
15136
15137 if (guard && isIterateeCall(string, options, guard)) {
15138 options = undefined$1;
15139 }
15140 string = toString(string);
15141 options = assignInWith({}, options, settings, customDefaultsAssignIn);
15142
15143 var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
15144 importsKeys = keys(imports),
15145 importsValues = baseValues(imports, importsKeys);
15146
15147 var isEscaping,
15148 isEvaluating,
15149 index = 0,
15150 interpolate = options.interpolate || reNoMatch,
15151 source = "__p += '";
15152
15153 // Compile the regexp to match each delimiter.
15154 var reDelimiters = RegExp(
15155 (options.escape || reNoMatch).source + '|' +
15156 interpolate.source + '|' +
15157 (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
15158 (options.evaluate || reNoMatch).source + '|$'
15159 , 'g');
15160
15161 // Use a sourceURL for easier debugging.
15162 // The sourceURL gets injected into the source that's eval-ed, so be careful
15163 // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in
15164 // and escape the comment, thus injecting code that gets evaled.
15165 var sourceURL = '//# sourceURL=' +
15166 (hasOwnProperty.call(options, 'sourceURL')
15167 ? (options.sourceURL + '').replace(/\s/g, ' ')
15168 : ('lodash.templateSources[' + (++templateCounter) + ']')
15169 ) + '\n';
15170
15171 string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
15172 interpolateValue || (interpolateValue = esTemplateValue);
15173
15174 // Escape characters that can't be included in string literals.
15175 source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
15176
15177 // Replace delimiters with snippets.
15178 if (escapeValue) {
15179 isEscaping = true;
15180 source += "' +\n__e(" + escapeValue + ") +\n'";
15181 }
15182 if (evaluateValue) {
15183 isEvaluating = true;
15184 source += "';\n" + evaluateValue + ";\n__p += '";
15185 }
15186 if (interpolateValue) {
15187 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
15188 }
15189 index = offset + match.length;
15190
15191 // The JS engine embedded in Adobe products needs `match` returned in
15192 // order to produce the correct `offset` value.
15193 return match;
15194 });
15195
15196 source += "';\n";
15197
15198 // If `variable` is not specified wrap a with-statement around the generated
15199 // code to add the data object to the top of the scope chain.
15200 var variable = hasOwnProperty.call(options, 'variable') && options.variable;
15201 if (!variable) {
15202 source = 'with (obj) {\n' + source + '\n}\n';
15203 }
15204 // Throw an error if a forbidden character was found in `variable`, to prevent
15205 // potential command injection attacks.
15206 else if (reForbiddenIdentifierChars.test(variable)) {
15207 throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);
15208 }
15209
15210 // Cleanup code by stripping empty strings.
15211 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
15212 .replace(reEmptyStringMiddle, '$1')
15213 .replace(reEmptyStringTrailing, '$1;');
15214
15215 // Frame code as the function body.
15216 source = 'function(' + (variable || 'obj') + ') {\n' +
15217 (variable
15218 ? ''
15219 : 'obj || (obj = {});\n'
15220 ) +
15221 "var __t, __p = ''" +
15222 (isEscaping
15223 ? ', __e = _.escape'
15224 : ''
15225 ) +
15226 (isEvaluating
15227 ? ', __j = Array.prototype.join;\n' +
15228 "function print() { __p += __j.call(arguments, '') }\n"
15229 : ';\n'
15230 ) +
15231 source +
15232 'return __p\n}';
15233
15234 var result = attempt(function() {
15235 return Function(importsKeys, sourceURL + 'return ' + source)
15236 .apply(undefined$1, importsValues);
15237 });
15238
15239 // Provide the compiled function's source by its `toString` method or
15240 // the `source` property as a convenience for inlining compiled templates.
15241 result.source = source;
15242 if (isError(result)) {
15243 throw result;
15244 }
15245 return result;
15246 }
15247
15248 /**
15249 * Converts `string`, as a whole, to lower case just like
15250 * [String#toLowerCase](https://mdn.io/toLowerCase).
15251 *
15252 * @static
15253 * @memberOf _
15254 * @since 4.0.0
15255 * @category String
15256 * @param {string} [string=''] The string to convert.
15257 * @returns {string} Returns the lower cased string.
15258 * @example
15259 *
15260 * _.toLower('--Foo-Bar--');
15261 * // => '--foo-bar--'
15262 *
15263 * _.toLower('fooBar');
15264 * // => 'foobar'
15265 *
15266 * _.toLower('__FOO_BAR__');
15267 * // => '__foo_bar__'
15268 */
15269 function toLower(value) {
15270 return toString(value).toLowerCase();
15271 }
15272
15273 /**
15274 * Converts `string`, as a whole, to upper case just like
15275 * [String#toUpperCase](https://mdn.io/toUpperCase).
15276 *
15277 * @static
15278 * @memberOf _
15279 * @since 4.0.0
15280 * @category String
15281 * @param {string} [string=''] The string to convert.
15282 * @returns {string} Returns the upper cased string.
15283 * @example
15284 *
15285 * _.toUpper('--foo-bar--');
15286 * // => '--FOO-BAR--'
15287 *
15288 * _.toUpper('fooBar');
15289 * // => 'FOOBAR'
15290 *
15291 * _.toUpper('__foo_bar__');
15292 * // => '__FOO_BAR__'
15293 */
15294 function toUpper(value) {
15295 return toString(value).toUpperCase();
15296 }
15297
15298 /**
15299 * Removes leading and trailing whitespace or specified characters from `string`.
15300 *
15301 * @static
15302 * @memberOf _
15303 * @since 3.0.0
15304 * @category String
15305 * @param {string} [string=''] The string to trim.
15306 * @param {string} [chars=whitespace] The characters to trim.
15307 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
15308 * @returns {string} Returns the trimmed string.
15309 * @example
15310 *
15311 * _.trim(' abc ');
15312 * // => 'abc'
15313 *
15314 * _.trim('-_-abc-_-', '_-');
15315 * // => 'abc'
15316 *
15317 * _.map([' foo ', ' bar '], _.trim);
15318 * // => ['foo', 'bar']
15319 */
15320 function trim(string, chars, guard) {
15321 string = toString(string);
15322 if (string && (guard || chars === undefined$1)) {
15323 return baseTrim(string);
15324 }
15325 if (!string || !(chars = baseToString(chars))) {
15326 return string;
15327 }
15328 var strSymbols = stringToArray(string),
15329 chrSymbols = stringToArray(chars),
15330 start = charsStartIndex(strSymbols, chrSymbols),
15331 end = charsEndIndex(strSymbols, chrSymbols) + 1;
15332
15333 return castSlice(strSymbols, start, end).join('');
15334 }
15335
15336 /**
15337 * Removes trailing whitespace or specified characters from `string`.
15338 *
15339 * @static
15340 * @memberOf _
15341 * @since 4.0.0
15342 * @category String
15343 * @param {string} [string=''] The string to trim.
15344 * @param {string} [chars=whitespace] The characters to trim.
15345 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
15346 * @returns {string} Returns the trimmed string.
15347 * @example
15348 *
15349 * _.trimEnd(' abc ');
15350 * // => ' abc'
15351 *
15352 * _.trimEnd('-_-abc-_-', '_-');
15353 * // => '-_-abc'
15354 */
15355 function trimEnd(string, chars, guard) {
15356 string = toString(string);
15357 if (string && (guard || chars === undefined$1)) {
15358 return string.slice(0, trimmedEndIndex(string) + 1);
15359 }
15360 if (!string || !(chars = baseToString(chars))) {
15361 return string;
15362 }
15363 var strSymbols = stringToArray(string),
15364 end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
15365
15366 return castSlice(strSymbols, 0, end).join('');
15367 }
15368
15369 /**
15370 * Removes leading whitespace or specified characters from `string`.
15371 *
15372 * @static
15373 * @memberOf _
15374 * @since 4.0.0
15375 * @category String
15376 * @param {string} [string=''] The string to trim.
15377 * @param {string} [chars=whitespace] The characters to trim.
15378 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
15379 * @returns {string} Returns the trimmed string.
15380 * @example
15381 *
15382 * _.trimStart(' abc ');
15383 * // => 'abc '
15384 *
15385 * _.trimStart('-_-abc-_-', '_-');
15386 * // => 'abc-_-'
15387 */
15388 function trimStart(string, chars, guard) {
15389 string = toString(string);
15390 if (string && (guard || chars === undefined$1)) {
15391 return string.replace(reTrimStart, '');
15392 }
15393 if (!string || !(chars = baseToString(chars))) {
15394 return string;
15395 }
15396 var strSymbols = stringToArray(string),
15397 start = charsStartIndex(strSymbols, stringToArray(chars));
15398
15399 return castSlice(strSymbols, start).join('');
15400 }
15401
15402 /**
15403 * Truncates `string` if it's longer than the given maximum string length.
15404 * The last characters of the truncated string are replaced with the omission
15405 * string which defaults to "...".
15406 *
15407 * @static
15408 * @memberOf _
15409 * @since 4.0.0
15410 * @category String
15411 * @param {string} [string=''] The string to truncate.
15412 * @param {Object} [options={}] The options object.
15413 * @param {number} [options.length=30] The maximum string length.
15414 * @param {string} [options.omission='...'] The string to indicate text is omitted.
15415 * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
15416 * @returns {string} Returns the truncated string.
15417 * @example
15418 *
15419 * _.truncate('hi-diddly-ho there, neighborino');
15420 * // => 'hi-diddly-ho there, neighbo...'
15421 *
15422 * _.truncate('hi-diddly-ho there, neighborino', {
15423 * 'length': 24,
15424 * 'separator': ' '
15425 * });
15426 * // => 'hi-diddly-ho there,...'
15427 *
15428 * _.truncate('hi-diddly-ho there, neighborino', {
15429 * 'length': 24,
15430 * 'separator': /,? +/
15431 * });
15432 * // => 'hi-diddly-ho there...'
15433 *
15434 * _.truncate('hi-diddly-ho there, neighborino', {
15435 * 'omission': ' [...]'
15436 * });
15437 * // => 'hi-diddly-ho there, neig [...]'
15438 */
15439 function truncate(string, options) {
15440 var length = DEFAULT_TRUNC_LENGTH,
15441 omission = DEFAULT_TRUNC_OMISSION;
15442
15443 if (isObject(options)) {
15444 var separator = 'separator' in options ? options.separator : separator;
15445 length = 'length' in options ? toInteger(options.length) : length;
15446 omission = 'omission' in options ? baseToString(options.omission) : omission;
15447 }
15448 string = toString(string);
15449
15450 var strLength = string.length;
15451 if (hasUnicode(string)) {
15452 var strSymbols = stringToArray(string);
15453 strLength = strSymbols.length;
15454 }
15455 if (length >= strLength) {
15456 return string;
15457 }
15458 var end = length - stringSize(omission);
15459 if (end < 1) {
15460 return omission;
15461 }
15462 var result = strSymbols
15463 ? castSlice(strSymbols, 0, end).join('')
15464 : string.slice(0, end);
15465
15466 if (separator === undefined$1) {
15467 return result + omission;
15468 }
15469 if (strSymbols) {
15470 end += (result.length - end);
15471 }
15472 if (isRegExp(separator)) {
15473 if (string.slice(end).search(separator)) {
15474 var match,
15475 substring = result;
15476
15477 if (!separator.global) {
15478 separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
15479 }
15480 separator.lastIndex = 0;
15481 while ((match = separator.exec(substring))) {
15482 var newEnd = match.index;
15483 }
15484 result = result.slice(0, newEnd === undefined$1 ? end : newEnd);
15485 }
15486 } else if (string.indexOf(baseToString(separator), end) != end) {
15487 var index = result.lastIndexOf(separator);
15488 if (index > -1) {
15489 result = result.slice(0, index);
15490 }
15491 }
15492 return result + omission;
15493 }
15494
15495 /**
15496 * The inverse of `_.escape`; this method converts the HTML entities
15497 * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
15498 * their corresponding characters.
15499 *
15500 * **Note:** No other HTML entities are unescaped. To unescape additional
15501 * HTML entities use a third-party library like [_he_](https://mths.be/he).
15502 *
15503 * @static
15504 * @memberOf _
15505 * @since 0.6.0
15506 * @category String
15507 * @param {string} [string=''] The string to unescape.
15508 * @returns {string} Returns the unescaped string.
15509 * @example
15510 *
15511 * _.unescape('fred, barney, &amp; pebbles');
15512 * // => 'fred, barney, & pebbles'
15513 */
15514 function unescape(string) {
15515 string = toString(string);
15516 return (string && reHasEscapedHtml.test(string))
15517 ? string.replace(reEscapedHtml, unescapeHtmlChar)
15518 : string;
15519 }
15520
15521 /**
15522 * Converts `string`, as space separated words, to upper case.
15523 *
15524 * @static
15525 * @memberOf _
15526 * @since 4.0.0
15527 * @category String
15528 * @param {string} [string=''] The string to convert.
15529 * @returns {string} Returns the upper cased string.
15530 * @example
15531 *
15532 * _.upperCase('--foo-bar');
15533 * // => 'FOO BAR'
15534 *
15535 * _.upperCase('fooBar');
15536 * // => 'FOO BAR'
15537 *
15538 * _.upperCase('__foo_bar__');
15539 * // => 'FOO BAR'
15540 */
15541 var upperCase = createCompounder(function(result, word, index) {
15542 return result + (index ? ' ' : '') + word.toUpperCase();
15543 });
15544
15545 /**
15546 * Converts the first character of `string` to upper case.
15547 *
15548 * @static
15549 * @memberOf _
15550 * @since 4.0.0
15551 * @category String
15552 * @param {string} [string=''] The string to convert.
15553 * @returns {string} Returns the converted string.
15554 * @example
15555 *
15556 * _.upperFirst('fred');
15557 * // => 'Fred'
15558 *
15559 * _.upperFirst('FRED');
15560 * // => 'FRED'
15561 */
15562 var upperFirst = createCaseFirst('toUpperCase');
15563
15564 /**
15565 * Splits `string` into an array of its words.
15566 *
15567 * @static
15568 * @memberOf _
15569 * @since 3.0.0
15570 * @category String
15571 * @param {string} [string=''] The string to inspect.
15572 * @param {RegExp|string} [pattern] The pattern to match words.
15573 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
15574 * @returns {Array} Returns the words of `string`.
15575 * @example
15576 *
15577 * _.words('fred, barney, & pebbles');
15578 * // => ['fred', 'barney', 'pebbles']
15579 *
15580 * _.words('fred, barney, & pebbles', /[^, ]+/g);
15581 * // => ['fred', 'barney', '&', 'pebbles']
15582 */
15583 function words(string, pattern, guard) {
15584 string = toString(string);
15585 pattern = guard ? undefined$1 : pattern;
15586
15587 if (pattern === undefined$1) {
15588 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
15589 }
15590 return string.match(pattern) || [];
15591 }
15592
15593 /*------------------------------------------------------------------------*/
15594
15595 /**
15596 * Attempts to invoke `func`, returning either the result or the caught error
15597 * object. Any additional arguments are provided to `func` when it's invoked.
15598 *
15599 * @static
15600 * @memberOf _
15601 * @since 3.0.0
15602 * @category Util
15603 * @param {Function} func The function to attempt.
15604 * @param {...*} [args] The arguments to invoke `func` with.
15605 * @returns {*} Returns the `func` result or error object.
15606 * @example
15607 *
15608 * // Avoid throwing errors for invalid selectors.
15609 * var elements = _.attempt(function(selector) {
15610 * return document.querySelectorAll(selector);
15611 * }, '>_>');
15612 *
15613 * if (_.isError(elements)) {
15614 * elements = [];
15615 * }
15616 */
15617 var attempt = baseRest(function(func, args) {
15618 try {
15619 return apply(func, undefined$1, args);
15620 } catch (e) {
15621 return isError(e) ? e : new Error(e);
15622 }
15623 });
15624
15625 /**
15626 * Binds methods of an object to the object itself, overwriting the existing
15627 * method.
15628 *
15629 * **Note:** This method doesn't set the "length" property of bound functions.
15630 *
15631 * @static
15632 * @since 0.1.0
15633 * @memberOf _
15634 * @category Util
15635 * @param {Object} object The object to bind and assign the bound methods to.
15636 * @param {...(string|string[])} methodNames The object method names to bind.
15637 * @returns {Object} Returns `object`.
15638 * @example
15639 *
15640 * var view = {
15641 * 'label': 'docs',
15642 * 'click': function() {
15643 * console.log('clicked ' + this.label);
15644 * }
15645 * };
15646 *
15647 * _.bindAll(view, ['click']);
15648 * jQuery(element).on('click', view.click);
15649 * // => Logs 'clicked docs' when clicked.
15650 */
15651 var bindAll = flatRest(function(object, methodNames) {
15652 arrayEach(methodNames, function(key) {
15653 key = toKey(key);
15654 baseAssignValue(object, key, bind(object[key], object));
15655 });
15656 return object;
15657 });
15658
15659 /**
15660 * Creates a function that iterates over `pairs` and invokes the corresponding
15661 * function of the first predicate to return truthy. The predicate-function
15662 * pairs are invoked with the `this` binding and arguments of the created
15663 * function.
15664 *
15665 * @static
15666 * @memberOf _
15667 * @since 4.0.0
15668 * @category Util
15669 * @param {Array} pairs The predicate-function pairs.
15670 * @returns {Function} Returns the new composite function.
15671 * @example
15672 *
15673 * var func = _.cond([
15674 * [_.matches({ 'a': 1 }), _.constant('matches A')],
15675 * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
15676 * [_.stubTrue, _.constant('no match')]
15677 * ]);
15678 *
15679 * func({ 'a': 1, 'b': 2 });
15680 * // => 'matches A'
15681 *
15682 * func({ 'a': 0, 'b': 1 });
15683 * // => 'matches B'
15684 *
15685 * func({ 'a': '1', 'b': '2' });
15686 * // => 'no match'
15687 */
15688 function cond(pairs) {
15689 var length = pairs == null ? 0 : pairs.length,
15690 toIteratee = getIteratee();
15691
15692 pairs = !length ? [] : arrayMap(pairs, function(pair) {
15693 if (typeof pair[1] != 'function') {
15694 throw new TypeError(FUNC_ERROR_TEXT);
15695 }
15696 return [toIteratee(pair[0]), pair[1]];
15697 });
15698
15699 return baseRest(function(args) {
15700 var index = -1;
15701 while (++index < length) {
15702 var pair = pairs[index];
15703 if (apply(pair[0], this, args)) {
15704 return apply(pair[1], this, args);
15705 }
15706 }
15707 });
15708 }
15709
15710 /**
15711 * Creates a function that invokes the predicate properties of `source` with
15712 * the corresponding property values of a given object, returning `true` if
15713 * all predicates return truthy, else `false`.
15714 *
15715 * **Note:** The created function is equivalent to `_.conformsTo` with
15716 * `source` partially applied.
15717 *
15718 * @static
15719 * @memberOf _
15720 * @since 4.0.0
15721 * @category Util
15722 * @param {Object} source The object of property predicates to conform to.
15723 * @returns {Function} Returns the new spec function.
15724 * @example
15725 *
15726 * var objects = [
15727 * { 'a': 2, 'b': 1 },
15728 * { 'a': 1, 'b': 2 }
15729 * ];
15730 *
15731 * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
15732 * // => [{ 'a': 1, 'b': 2 }]
15733 */
15734 function conforms(source) {
15735 return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
15736 }
15737
15738 /**
15739 * Creates a function that returns `value`.
15740 *
15741 * @static
15742 * @memberOf _
15743 * @since 2.4.0
15744 * @category Util
15745 * @param {*} value The value to return from the new function.
15746 * @returns {Function} Returns the new constant function.
15747 * @example
15748 *
15749 * var objects = _.times(2, _.constant({ 'a': 1 }));
15750 *
15751 * console.log(objects);
15752 * // => [{ 'a': 1 }, { 'a': 1 }]
15753 *
15754 * console.log(objects[0] === objects[1]);
15755 * // => true
15756 */
15757 function constant(value) {
15758 return function() {
15759 return value;
15760 };
15761 }
15762
15763 /**
15764 * Checks `value` to determine whether a default value should be returned in
15765 * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
15766 * or `undefined`.
15767 *
15768 * @static
15769 * @memberOf _
15770 * @since 4.14.0
15771 * @category Util
15772 * @param {*} value The value to check.
15773 * @param {*} defaultValue The default value.
15774 * @returns {*} Returns the resolved value.
15775 * @example
15776 *
15777 * _.defaultTo(1, 10);
15778 * // => 1
15779 *
15780 * _.defaultTo(undefined, 10);
15781 * // => 10
15782 */
15783 function defaultTo(value, defaultValue) {
15784 return (value == null || value !== value) ? defaultValue : value;
15785 }
15786
15787 /**
15788 * Creates a function that returns the result of invoking the given functions
15789 * with the `this` binding of the created function, where each successive
15790 * invocation is supplied the return value of the previous.
15791 *
15792 * @static
15793 * @memberOf _
15794 * @since 3.0.0
15795 * @category Util
15796 * @param {...(Function|Function[])} [funcs] The functions to invoke.
15797 * @returns {Function} Returns the new composite function.
15798 * @see _.flowRight
15799 * @example
15800 *
15801 * function square(n) {
15802 * return n * n;
15803 * }
15804 *
15805 * var addSquare = _.flow([_.add, square]);
15806 * addSquare(1, 2);
15807 * // => 9
15808 */
15809 var flow = createFlow();
15810
15811 /**
15812 * This method is like `_.flow` except that it creates a function that
15813 * invokes the given functions from right to left.
15814 *
15815 * @static
15816 * @since 3.0.0
15817 * @memberOf _
15818 * @category Util
15819 * @param {...(Function|Function[])} [funcs] The functions to invoke.
15820 * @returns {Function} Returns the new composite function.
15821 * @see _.flow
15822 * @example
15823 *
15824 * function square(n) {
15825 * return n * n;
15826 * }
15827 *
15828 * var addSquare = _.flowRight([square, _.add]);
15829 * addSquare(1, 2);
15830 * // => 9
15831 */
15832 var flowRight = createFlow(true);
15833
15834 /**
15835 * This method returns the first argument it receives.
15836 *
15837 * @static
15838 * @since 0.1.0
15839 * @memberOf _
15840 * @category Util
15841 * @param {*} value Any value.
15842 * @returns {*} Returns `value`.
15843 * @example
15844 *
15845 * var object = { 'a': 1 };
15846 *
15847 * console.log(_.identity(object) === object);
15848 * // => true
15849 */
15850 function identity(value) {
15851 return value;
15852 }
15853
15854 /**
15855 * Creates a function that invokes `func` with the arguments of the created
15856 * function. If `func` is a property name, the created function returns the
15857 * property value for a given element. If `func` is an array or object, the
15858 * created function returns `true` for elements that contain the equivalent
15859 * source properties, otherwise it returns `false`.
15860 *
15861 * @static
15862 * @since 4.0.0
15863 * @memberOf _
15864 * @category Util
15865 * @param {*} [func=_.identity] The value to convert to a callback.
15866 * @returns {Function} Returns the callback.
15867 * @example
15868 *
15869 * var users = [
15870 * { 'user': 'barney', 'age': 36, 'active': true },
15871 * { 'user': 'fred', 'age': 40, 'active': false }
15872 * ];
15873 *
15874 * // The `_.matches` iteratee shorthand.
15875 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
15876 * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
15877 *
15878 * // The `_.matchesProperty` iteratee shorthand.
15879 * _.filter(users, _.iteratee(['user', 'fred']));
15880 * // => [{ 'user': 'fred', 'age': 40 }]
15881 *
15882 * // The `_.property` iteratee shorthand.
15883 * _.map(users, _.iteratee('user'));
15884 * // => ['barney', 'fred']
15885 *
15886 * // Create custom iteratee shorthands.
15887 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
15888 * return !_.isRegExp(func) ? iteratee(func) : function(string) {
15889 * return func.test(string);
15890 * };
15891 * });
15892 *
15893 * _.filter(['abc', 'def'], /ef/);
15894 * // => ['def']
15895 */
15896 function iteratee(func) {
15897 return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
15898 }
15899
15900 /**
15901 * Creates a function that performs a partial deep comparison between a given
15902 * object and `source`, returning `true` if the given object has equivalent
15903 * property values, else `false`.
15904 *
15905 * **Note:** The created function is equivalent to `_.isMatch` with `source`
15906 * partially applied.
15907 *
15908 * Partial comparisons will match empty array and empty object `source`
15909 * values against any array or object value, respectively. See `_.isEqual`
15910 * for a list of supported value comparisons.
15911 *
15912 * **Note:** Multiple values can be checked by combining several matchers
15913 * using `_.overSome`
15914 *
15915 * @static
15916 * @memberOf _
15917 * @since 3.0.0
15918 * @category Util
15919 * @param {Object} source The object of property values to match.
15920 * @returns {Function} Returns the new spec function.
15921 * @example
15922 *
15923 * var objects = [
15924 * { 'a': 1, 'b': 2, 'c': 3 },
15925 * { 'a': 4, 'b': 5, 'c': 6 }
15926 * ];
15927 *
15928 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
15929 * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
15930 *
15931 * // Checking for several possible values
15932 * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })]));
15933 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
15934 */
15935 function matches(source) {
15936 return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
15937 }
15938
15939 /**
15940 * Creates a function that performs a partial deep comparison between the
15941 * value at `path` of a given object to `srcValue`, returning `true` if the
15942 * object value is equivalent, else `false`.
15943 *
15944 * **Note:** Partial comparisons will match empty array and empty object
15945 * `srcValue` values against any array or object value, respectively. See
15946 * `_.isEqual` for a list of supported value comparisons.
15947 *
15948 * **Note:** Multiple values can be checked by combining several matchers
15949 * using `_.overSome`
15950 *
15951 * @static
15952 * @memberOf _
15953 * @since 3.2.0
15954 * @category Util
15955 * @param {Array|string} path The path of the property to get.
15956 * @param {*} srcValue The value to match.
15957 * @returns {Function} Returns the new spec function.
15958 * @example
15959 *
15960 * var objects = [
15961 * { 'a': 1, 'b': 2, 'c': 3 },
15962 * { 'a': 4, 'b': 5, 'c': 6 }
15963 * ];
15964 *
15965 * _.find(objects, _.matchesProperty('a', 4));
15966 * // => { 'a': 4, 'b': 5, 'c': 6 }
15967 *
15968 * // Checking for several possible values
15969 * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)]));
15970 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
15971 */
15972 function matchesProperty(path, srcValue) {
15973 return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
15974 }
15975
15976 /**
15977 * Creates a function that invokes the method at `path` of a given object.
15978 * Any additional arguments are provided to the invoked method.
15979 *
15980 * @static
15981 * @memberOf _
15982 * @since 3.7.0
15983 * @category Util
15984 * @param {Array|string} path The path of the method to invoke.
15985 * @param {...*} [args] The arguments to invoke the method with.
15986 * @returns {Function} Returns the new invoker function.
15987 * @example
15988 *
15989 * var objects = [
15990 * { 'a': { 'b': _.constant(2) } },
15991 * { 'a': { 'b': _.constant(1) } }
15992 * ];
15993 *
15994 * _.map(objects, _.method('a.b'));
15995 * // => [2, 1]
15996 *
15997 * _.map(objects, _.method(['a', 'b']));
15998 * // => [2, 1]
15999 */
16000 var method = baseRest(function(path, args) {
16001 return function(object) {
16002 return baseInvoke(object, path, args);
16003 };
16004 });
16005
16006 /**
16007 * The opposite of `_.method`; this method creates a function that invokes
16008 * the method at a given path of `object`. Any additional arguments are
16009 * provided to the invoked method.
16010 *
16011 * @static
16012 * @memberOf _
16013 * @since 3.7.0
16014 * @category Util
16015 * @param {Object} object The object to query.
16016 * @param {...*} [args] The arguments to invoke the method with.
16017 * @returns {Function} Returns the new invoker function.
16018 * @example
16019 *
16020 * var array = _.times(3, _.constant),
16021 * object = { 'a': array, 'b': array, 'c': array };
16022 *
16023 * _.map(['a[2]', 'c[0]'], _.methodOf(object));
16024 * // => [2, 0]
16025 *
16026 * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
16027 * // => [2, 0]
16028 */
16029 var methodOf = baseRest(function(object, args) {
16030 return function(path) {
16031 return baseInvoke(object, path, args);
16032 };
16033 });
16034
16035 /**
16036 * Adds all own enumerable string keyed function properties of a source
16037 * object to the destination object. If `object` is a function, then methods
16038 * are added to its prototype as well.
16039 *
16040 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
16041 * avoid conflicts caused by modifying the original.
16042 *
16043 * @static
16044 * @since 0.1.0
16045 * @memberOf _
16046 * @category Util
16047 * @param {Function|Object} [object=lodash] The destination object.
16048 * @param {Object} source The object of functions to add.
16049 * @param {Object} [options={}] The options object.
16050 * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
16051 * @returns {Function|Object} Returns `object`.
16052 * @example
16053 *
16054 * function vowels(string) {
16055 * return _.filter(string, function(v) {
16056 * return /[aeiou]/i.test(v);
16057 * });
16058 * }
16059 *
16060 * _.mixin({ 'vowels': vowels });
16061 * _.vowels('fred');
16062 * // => ['e']
16063 *
16064 * _('fred').vowels().value();
16065 * // => ['e']
16066 *
16067 * _.mixin({ 'vowels': vowels }, { 'chain': false });
16068 * _('fred').vowels();
16069 * // => ['e']
16070 */
16071 function mixin(object, source, options) {
16072 var props = keys(source),
16073 methodNames = baseFunctions(source, props);
16074
16075 if (options == null &&
16076 !(isObject(source) && (methodNames.length || !props.length))) {
16077 options = source;
16078 source = object;
16079 object = this;
16080 methodNames = baseFunctions(source, keys(source));
16081 }
16082 var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
16083 isFunc = isFunction(object);
16084
16085 arrayEach(methodNames, function(methodName) {
16086 var func = source[methodName];
16087 object[methodName] = func;
16088 if (isFunc) {
16089 object.prototype[methodName] = function() {
16090 var chainAll = this.__chain__;
16091 if (chain || chainAll) {
16092 var result = object(this.__wrapped__),
16093 actions = result.__actions__ = copyArray(this.__actions__);
16094
16095 actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
16096 result.__chain__ = chainAll;
16097 return result;
16098 }
16099 return func.apply(object, arrayPush([this.value()], arguments));
16100 };
16101 }
16102 });
16103
16104 return object;
16105 }
16106
16107 /**
16108 * Reverts the `_` variable to its previous value and returns a reference to
16109 * the `lodash` function.
16110 *
16111 * @static
16112 * @since 0.1.0
16113 * @memberOf _
16114 * @category Util
16115 * @returns {Function} Returns the `lodash` function.
16116 * @example
16117 *
16118 * var lodash = _.noConflict();
16119 */
16120 function noConflict() {
16121 if (root._ === this) {
16122 root._ = oldDash;
16123 }
16124 return this;
16125 }
16126
16127 /**
16128 * This method returns `undefined`.
16129 *
16130 * @static
16131 * @memberOf _
16132 * @since 2.3.0
16133 * @category Util
16134 * @example
16135 *
16136 * _.times(2, _.noop);
16137 * // => [undefined, undefined]
16138 */
16139 function noop() {
16140 // No operation performed.
16141 }
16142
16143 /**
16144 * Creates a function that gets the argument at index `n`. If `n` is negative,
16145 * the nth argument from the end is returned.
16146 *
16147 * @static
16148 * @memberOf _
16149 * @since 4.0.0
16150 * @category Util
16151 * @param {number} [n=0] The index of the argument to return.
16152 * @returns {Function} Returns the new pass-thru function.
16153 * @example
16154 *
16155 * var func = _.nthArg(1);
16156 * func('a', 'b', 'c', 'd');
16157 * // => 'b'
16158 *
16159 * var func = _.nthArg(-2);
16160 * func('a', 'b', 'c', 'd');
16161 * // => 'c'
16162 */
16163 function nthArg(n) {
16164 n = toInteger(n);
16165 return baseRest(function(args) {
16166 return baseNth(args, n);
16167 });
16168 }
16169
16170 /**
16171 * Creates a function that invokes `iteratees` with the arguments it receives
16172 * and returns their results.
16173 *
16174 * @static
16175 * @memberOf _
16176 * @since 4.0.0
16177 * @category Util
16178 * @param {...(Function|Function[])} [iteratees=[_.identity]]
16179 * The iteratees to invoke.
16180 * @returns {Function} Returns the new function.
16181 * @example
16182 *
16183 * var func = _.over([Math.max, Math.min]);
16184 *
16185 * func(1, 2, 3, 4);
16186 * // => [4, 1]
16187 */
16188 var over = createOver(arrayMap);
16189
16190 /**
16191 * Creates a function that checks if **all** of the `predicates` return
16192 * truthy when invoked with the arguments it receives.
16193 *
16194 * Following shorthands are possible for providing predicates.
16195 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
16196 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
16197 *
16198 * @static
16199 * @memberOf _
16200 * @since 4.0.0
16201 * @category Util
16202 * @param {...(Function|Function[])} [predicates=[_.identity]]
16203 * The predicates to check.
16204 * @returns {Function} Returns the new function.
16205 * @example
16206 *
16207 * var func = _.overEvery([Boolean, isFinite]);
16208 *
16209 * func('1');
16210 * // => true
16211 *
16212 * func(null);
16213 * // => false
16214 *
16215 * func(NaN);
16216 * // => false
16217 */
16218 var overEvery = createOver(arrayEvery);
16219
16220 /**
16221 * Creates a function that checks if **any** of the `predicates` return
16222 * truthy when invoked with the arguments it receives.
16223 *
16224 * Following shorthands are possible for providing predicates.
16225 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
16226 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
16227 *
16228 * @static
16229 * @memberOf _
16230 * @since 4.0.0
16231 * @category Util
16232 * @param {...(Function|Function[])} [predicates=[_.identity]]
16233 * The predicates to check.
16234 * @returns {Function} Returns the new function.
16235 * @example
16236 *
16237 * var func = _.overSome([Boolean, isFinite]);
16238 *
16239 * func('1');
16240 * // => true
16241 *
16242 * func(null);
16243 * // => true
16244 *
16245 * func(NaN);
16246 * // => false
16247 *
16248 * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }])
16249 * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]])
16250 */
16251 var overSome = createOver(arraySome);
16252
16253 /**
16254 * Creates a function that returns the value at `path` of a given object.
16255 *
16256 * @static
16257 * @memberOf _
16258 * @since 2.4.0
16259 * @category Util
16260 * @param {Array|string} path The path of the property to get.
16261 * @returns {Function} Returns the new accessor function.
16262 * @example
16263 *
16264 * var objects = [
16265 * { 'a': { 'b': 2 } },
16266 * { 'a': { 'b': 1 } }
16267 * ];
16268 *
16269 * _.map(objects, _.property('a.b'));
16270 * // => [2, 1]
16271 *
16272 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
16273 * // => [1, 2]
16274 */
16275 function property(path) {
16276 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
16277 }
16278
16279 /**
16280 * The opposite of `_.property`; this method creates a function that returns
16281 * the value at a given path of `object`.
16282 *
16283 * @static
16284 * @memberOf _
16285 * @since 3.0.0
16286 * @category Util
16287 * @param {Object} object The object to query.
16288 * @returns {Function} Returns the new accessor function.
16289 * @example
16290 *
16291 * var array = [0, 1, 2],
16292 * object = { 'a': array, 'b': array, 'c': array };
16293 *
16294 * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
16295 * // => [2, 0]
16296 *
16297 * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
16298 * // => [2, 0]
16299 */
16300 function propertyOf(object) {
16301 return function(path) {
16302 return object == null ? undefined$1 : baseGet(object, path);
16303 };
16304 }
16305
16306 /**
16307 * Creates an array of numbers (positive and/or negative) progressing from
16308 * `start` up to, but not including, `end`. A step of `-1` is used if a negative
16309 * `start` is specified without an `end` or `step`. If `end` is not specified,
16310 * it's set to `start` with `start` then set to `0`.
16311 *
16312 * **Note:** JavaScript follows the IEEE-754 standard for resolving
16313 * floating-point values which can produce unexpected results.
16314 *
16315 * @static
16316 * @since 0.1.0
16317 * @memberOf _
16318 * @category Util
16319 * @param {number} [start=0] The start of the range.
16320 * @param {number} end The end of the range.
16321 * @param {number} [step=1] The value to increment or decrement by.
16322 * @returns {Array} Returns the range of numbers.
16323 * @see _.inRange, _.rangeRight
16324 * @example
16325 *
16326 * _.range(4);
16327 * // => [0, 1, 2, 3]
16328 *
16329 * _.range(-4);
16330 * // => [0, -1, -2, -3]
16331 *
16332 * _.range(1, 5);
16333 * // => [1, 2, 3, 4]
16334 *
16335 * _.range(0, 20, 5);
16336 * // => [0, 5, 10, 15]
16337 *
16338 * _.range(0, -4, -1);
16339 * // => [0, -1, -2, -3]
16340 *
16341 * _.range(1, 4, 0);
16342 * // => [1, 1, 1]
16343 *
16344 * _.range(0);
16345 * // => []
16346 */
16347 var range = createRange();
16348
16349 /**
16350 * This method is like `_.range` except that it populates values in
16351 * descending order.
16352 *
16353 * @static
16354 * @memberOf _
16355 * @since 4.0.0
16356 * @category Util
16357 * @param {number} [start=0] The start of the range.
16358 * @param {number} end The end of the range.
16359 * @param {number} [step=1] The value to increment or decrement by.
16360 * @returns {Array} Returns the range of numbers.
16361 * @see _.inRange, _.range
16362 * @example
16363 *
16364 * _.rangeRight(4);
16365 * // => [3, 2, 1, 0]
16366 *
16367 * _.rangeRight(-4);
16368 * // => [-3, -2, -1, 0]
16369 *
16370 * _.rangeRight(1, 5);
16371 * // => [4, 3, 2, 1]
16372 *
16373 * _.rangeRight(0, 20, 5);
16374 * // => [15, 10, 5, 0]
16375 *
16376 * _.rangeRight(0, -4, -1);
16377 * // => [-3, -2, -1, 0]
16378 *
16379 * _.rangeRight(1, 4, 0);
16380 * // => [1, 1, 1]
16381 *
16382 * _.rangeRight(0);
16383 * // => []
16384 */
16385 var rangeRight = createRange(true);
16386
16387 /**
16388 * This method returns a new empty array.
16389 *
16390 * @static
16391 * @memberOf _
16392 * @since 4.13.0
16393 * @category Util
16394 * @returns {Array} Returns the new empty array.
16395 * @example
16396 *
16397 * var arrays = _.times(2, _.stubArray);
16398 *
16399 * console.log(arrays);
16400 * // => [[], []]
16401 *
16402 * console.log(arrays[0] === arrays[1]);
16403 * // => false
16404 */
16405 function stubArray() {
16406 return [];
16407 }
16408
16409 /**
16410 * This method returns `false`.
16411 *
16412 * @static
16413 * @memberOf _
16414 * @since 4.13.0
16415 * @category Util
16416 * @returns {boolean} Returns `false`.
16417 * @example
16418 *
16419 * _.times(2, _.stubFalse);
16420 * // => [false, false]
16421 */
16422 function stubFalse() {
16423 return false;
16424 }
16425
16426 /**
16427 * This method returns a new empty object.
16428 *
16429 * @static
16430 * @memberOf _
16431 * @since 4.13.0
16432 * @category Util
16433 * @returns {Object} Returns the new empty object.
16434 * @example
16435 *
16436 * var objects = _.times(2, _.stubObject);
16437 *
16438 * console.log(objects);
16439 * // => [{}, {}]
16440 *
16441 * console.log(objects[0] === objects[1]);
16442 * // => false
16443 */
16444 function stubObject() {
16445 return {};
16446 }
16447
16448 /**
16449 * This method returns an empty string.
16450 *
16451 * @static
16452 * @memberOf _
16453 * @since 4.13.0
16454 * @category Util
16455 * @returns {string} Returns the empty string.
16456 * @example
16457 *
16458 * _.times(2, _.stubString);
16459 * // => ['', '']
16460 */
16461 function stubString() {
16462 return '';
16463 }
16464
16465 /**
16466 * This method returns `true`.
16467 *
16468 * @static
16469 * @memberOf _
16470 * @since 4.13.0
16471 * @category Util
16472 * @returns {boolean} Returns `true`.
16473 * @example
16474 *
16475 * _.times(2, _.stubTrue);
16476 * // => [true, true]
16477 */
16478 function stubTrue() {
16479 return true;
16480 }
16481
16482 /**
16483 * Invokes the iteratee `n` times, returning an array of the results of
16484 * each invocation. The iteratee is invoked with one argument; (index).
16485 *
16486 * @static
16487 * @since 0.1.0
16488 * @memberOf _
16489 * @category Util
16490 * @param {number} n The number of times to invoke `iteratee`.
16491 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
16492 * @returns {Array} Returns the array of results.
16493 * @example
16494 *
16495 * _.times(3, String);
16496 * // => ['0', '1', '2']
16497 *
16498 * _.times(4, _.constant(0));
16499 * // => [0, 0, 0, 0]
16500 */
16501 function times(n, iteratee) {
16502 n = toInteger(n);
16503 if (n < 1 || n > MAX_SAFE_INTEGER) {
16504 return [];
16505 }
16506 var index = MAX_ARRAY_LENGTH,
16507 length = nativeMin(n, MAX_ARRAY_LENGTH);
16508
16509 iteratee = getIteratee(iteratee);
16510 n -= MAX_ARRAY_LENGTH;
16511
16512 var result = baseTimes(length, iteratee);
16513 while (++index < n) {
16514 iteratee(index);
16515 }
16516 return result;
16517 }
16518
16519 /**
16520 * Converts `value` to a property path array.
16521 *
16522 * @static
16523 * @memberOf _
16524 * @since 4.0.0
16525 * @category Util
16526 * @param {*} value The value to convert.
16527 * @returns {Array} Returns the new property path array.
16528 * @example
16529 *
16530 * _.toPath('a.b.c');
16531 * // => ['a', 'b', 'c']
16532 *
16533 * _.toPath('a[0].b.c');
16534 * // => ['a', '0', 'b', 'c']
16535 */
16536 function toPath(value) {
16537 if (isArray(value)) {
16538 return arrayMap(value, toKey);
16539 }
16540 return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
16541 }
16542
16543 /**
16544 * Generates a unique ID. If `prefix` is given, the ID is appended to it.
16545 *
16546 * @static
16547 * @since 0.1.0
16548 * @memberOf _
16549 * @category Util
16550 * @param {string} [prefix=''] The value to prefix the ID with.
16551 * @returns {string} Returns the unique ID.
16552 * @example
16553 *
16554 * _.uniqueId('contact_');
16555 * // => 'contact_104'
16556 *
16557 * _.uniqueId();
16558 * // => '105'
16559 */
16560 function uniqueId(prefix) {
16561 var id = ++idCounter;
16562 return toString(prefix) + id;
16563 }
16564
16565 /*------------------------------------------------------------------------*/
16566
16567 /**
16568 * Adds two numbers.
16569 *
16570 * @static
16571 * @memberOf _
16572 * @since 3.4.0
16573 * @category Math
16574 * @param {number} augend The first number in an addition.
16575 * @param {number} addend The second number in an addition.
16576 * @returns {number} Returns the total.
16577 * @example
16578 *
16579 * _.add(6, 4);
16580 * // => 10
16581 */
16582 var add = createMathOperation(function(augend, addend) {
16583 return augend + addend;
16584 }, 0);
16585
16586 /**
16587 * Computes `number` rounded up to `precision`.
16588 *
16589 * @static
16590 * @memberOf _
16591 * @since 3.10.0
16592 * @category Math
16593 * @param {number} number The number to round up.
16594 * @param {number} [precision=0] The precision to round up to.
16595 * @returns {number} Returns the rounded up number.
16596 * @example
16597 *
16598 * _.ceil(4.006);
16599 * // => 5
16600 *
16601 * _.ceil(6.004, 2);
16602 * // => 6.01
16603 *
16604 * _.ceil(6040, -2);
16605 * // => 6100
16606 */
16607 var ceil = createRound('ceil');
16608
16609 /**
16610 * Divide two numbers.
16611 *
16612 * @static
16613 * @memberOf _
16614 * @since 4.7.0
16615 * @category Math
16616 * @param {number} dividend The first number in a division.
16617 * @param {number} divisor The second number in a division.
16618 * @returns {number} Returns the quotient.
16619 * @example
16620 *
16621 * _.divide(6, 4);
16622 * // => 1.5
16623 */
16624 var divide = createMathOperation(function(dividend, divisor) {
16625 return dividend / divisor;
16626 }, 1);
16627
16628 /**
16629 * Computes `number` rounded down to `precision`.
16630 *
16631 * @static
16632 * @memberOf _
16633 * @since 3.10.0
16634 * @category Math
16635 * @param {number} number The number to round down.
16636 * @param {number} [precision=0] The precision to round down to.
16637 * @returns {number} Returns the rounded down number.
16638 * @example
16639 *
16640 * _.floor(4.006);
16641 * // => 4
16642 *
16643 * _.floor(0.046, 2);
16644 * // => 0.04
16645 *
16646 * _.floor(4060, -2);
16647 * // => 4000
16648 */
16649 var floor = createRound('floor');
16650
16651 /**
16652 * Computes the maximum value of `array`. If `array` is empty or falsey,
16653 * `undefined` is returned.
16654 *
16655 * @static
16656 * @since 0.1.0
16657 * @memberOf _
16658 * @category Math
16659 * @param {Array} array The array to iterate over.
16660 * @returns {*} Returns the maximum value.
16661 * @example
16662 *
16663 * _.max([4, 2, 8, 6]);
16664 * // => 8
16665 *
16666 * _.max([]);
16667 * // => undefined
16668 */
16669 function max(array) {
16670 return (array && array.length)
16671 ? baseExtremum(array, identity, baseGt)
16672 : undefined$1;
16673 }
16674
16675 /**
16676 * This method is like `_.max` except that it accepts `iteratee` which is
16677 * invoked for each element in `array` to generate the criterion by which
16678 * the value is ranked. The iteratee is invoked with one argument: (value).
16679 *
16680 * @static
16681 * @memberOf _
16682 * @since 4.0.0
16683 * @category Math
16684 * @param {Array} array The array to iterate over.
16685 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16686 * @returns {*} Returns the maximum value.
16687 * @example
16688 *
16689 * var objects = [{ 'n': 1 }, { 'n': 2 }];
16690 *
16691 * _.maxBy(objects, function(o) { return o.n; });
16692 * // => { 'n': 2 }
16693 *
16694 * // The `_.property` iteratee shorthand.
16695 * _.maxBy(objects, 'n');
16696 * // => { 'n': 2 }
16697 */
16698 function maxBy(array, iteratee) {
16699 return (array && array.length)
16700 ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
16701 : undefined$1;
16702 }
16703
16704 /**
16705 * Computes the mean of the values in `array`.
16706 *
16707 * @static
16708 * @memberOf _
16709 * @since 4.0.0
16710 * @category Math
16711 * @param {Array} array The array to iterate over.
16712 * @returns {number} Returns the mean.
16713 * @example
16714 *
16715 * _.mean([4, 2, 8, 6]);
16716 * // => 5
16717 */
16718 function mean(array) {
16719 return baseMean(array, identity);
16720 }
16721
16722 /**
16723 * This method is like `_.mean` except that it accepts `iteratee` which is
16724 * invoked for each element in `array` to generate the value to be averaged.
16725 * The iteratee is invoked with one argument: (value).
16726 *
16727 * @static
16728 * @memberOf _
16729 * @since 4.7.0
16730 * @category Math
16731 * @param {Array} array The array to iterate over.
16732 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16733 * @returns {number} Returns the mean.
16734 * @example
16735 *
16736 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
16737 *
16738 * _.meanBy(objects, function(o) { return o.n; });
16739 * // => 5
16740 *
16741 * // The `_.property` iteratee shorthand.
16742 * _.meanBy(objects, 'n');
16743 * // => 5
16744 */
16745 function meanBy(array, iteratee) {
16746 return baseMean(array, getIteratee(iteratee, 2));
16747 }
16748
16749 /**
16750 * Computes the minimum value of `array`. If `array` is empty or falsey,
16751 * `undefined` is returned.
16752 *
16753 * @static
16754 * @since 0.1.0
16755 * @memberOf _
16756 * @category Math
16757 * @param {Array} array The array to iterate over.
16758 * @returns {*} Returns the minimum value.
16759 * @example
16760 *
16761 * _.min([4, 2, 8, 6]);
16762 * // => 2
16763 *
16764 * _.min([]);
16765 * // => undefined
16766 */
16767 function min(array) {
16768 return (array && array.length)
16769 ? baseExtremum(array, identity, baseLt)
16770 : undefined$1;
16771 }
16772
16773 /**
16774 * This method is like `_.min` except that it accepts `iteratee` which is
16775 * invoked for each element in `array` to generate the criterion by which
16776 * the value is ranked. The iteratee is invoked with one argument: (value).
16777 *
16778 * @static
16779 * @memberOf _
16780 * @since 4.0.0
16781 * @category Math
16782 * @param {Array} array The array to iterate over.
16783 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16784 * @returns {*} Returns the minimum value.
16785 * @example
16786 *
16787 * var objects = [{ 'n': 1 }, { 'n': 2 }];
16788 *
16789 * _.minBy(objects, function(o) { return o.n; });
16790 * // => { 'n': 1 }
16791 *
16792 * // The `_.property` iteratee shorthand.
16793 * _.minBy(objects, 'n');
16794 * // => { 'n': 1 }
16795 */
16796 function minBy(array, iteratee) {
16797 return (array && array.length)
16798 ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
16799 : undefined$1;
16800 }
16801
16802 /**
16803 * Multiply two numbers.
16804 *
16805 * @static
16806 * @memberOf _
16807 * @since 4.7.0
16808 * @category Math
16809 * @param {number} multiplier The first number in a multiplication.
16810 * @param {number} multiplicand The second number in a multiplication.
16811 * @returns {number} Returns the product.
16812 * @example
16813 *
16814 * _.multiply(6, 4);
16815 * // => 24
16816 */
16817 var multiply = createMathOperation(function(multiplier, multiplicand) {
16818 return multiplier * multiplicand;
16819 }, 1);
16820
16821 /**
16822 * Computes `number` rounded to `precision`.
16823 *
16824 * @static
16825 * @memberOf _
16826 * @since 3.10.0
16827 * @category Math
16828 * @param {number} number The number to round.
16829 * @param {number} [precision=0] The precision to round to.
16830 * @returns {number} Returns the rounded number.
16831 * @example
16832 *
16833 * _.round(4.006);
16834 * // => 4
16835 *
16836 * _.round(4.006, 2);
16837 * // => 4.01
16838 *
16839 * _.round(4060, -2);
16840 * // => 4100
16841 */
16842 var round = createRound('round');
16843
16844 /**
16845 * Subtract two numbers.
16846 *
16847 * @static
16848 * @memberOf _
16849 * @since 4.0.0
16850 * @category Math
16851 * @param {number} minuend The first number in a subtraction.
16852 * @param {number} subtrahend The second number in a subtraction.
16853 * @returns {number} Returns the difference.
16854 * @example
16855 *
16856 * _.subtract(6, 4);
16857 * // => 2
16858 */
16859 var subtract = createMathOperation(function(minuend, subtrahend) {
16860 return minuend - subtrahend;
16861 }, 0);
16862
16863 /**
16864 * Computes the sum of the values in `array`.
16865 *
16866 * @static
16867 * @memberOf _
16868 * @since 3.4.0
16869 * @category Math
16870 * @param {Array} array The array to iterate over.
16871 * @returns {number} Returns the sum.
16872 * @example
16873 *
16874 * _.sum([4, 2, 8, 6]);
16875 * // => 20
16876 */
16877 function sum(array) {
16878 return (array && array.length)
16879 ? baseSum(array, identity)
16880 : 0;
16881 }
16882
16883 /**
16884 * This method is like `_.sum` except that it accepts `iteratee` which is
16885 * invoked for each element in `array` to generate the value to be summed.
16886 * The iteratee is invoked with one argument: (value).
16887 *
16888 * @static
16889 * @memberOf _
16890 * @since 4.0.0
16891 * @category Math
16892 * @param {Array} array The array to iterate over.
16893 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16894 * @returns {number} Returns the sum.
16895 * @example
16896 *
16897 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
16898 *
16899 * _.sumBy(objects, function(o) { return o.n; });
16900 * // => 20
16901 *
16902 * // The `_.property` iteratee shorthand.
16903 * _.sumBy(objects, 'n');
16904 * // => 20
16905 */
16906 function sumBy(array, iteratee) {
16907 return (array && array.length)
16908 ? baseSum(array, getIteratee(iteratee, 2))
16909 : 0;
16910 }
16911
16912 /*------------------------------------------------------------------------*/
16913
16914 // Add methods that return wrapped values in chain sequences.
16915 lodash.after = after;
16916 lodash.ary = ary;
16917 lodash.assign = assign;
16918 lodash.assignIn = assignIn;
16919 lodash.assignInWith = assignInWith;
16920 lodash.assignWith = assignWith;
16921 lodash.at = at;
16922 lodash.before = before;
16923 lodash.bind = bind;
16924 lodash.bindAll = bindAll;
16925 lodash.bindKey = bindKey;
16926 lodash.castArray = castArray;
16927 lodash.chain = chain;
16928 lodash.chunk = chunk;
16929 lodash.compact = compact;
16930 lodash.concat = concat;
16931 lodash.cond = cond;
16932 lodash.conforms = conforms;
16933 lodash.constant = constant;
16934 lodash.countBy = countBy;
16935 lodash.create = create;
16936 lodash.curry = curry;
16937 lodash.curryRight = curryRight;
16938 lodash.debounce = debounce;
16939 lodash.defaults = defaults;
16940 lodash.defaultsDeep = defaultsDeep;
16941 lodash.defer = defer;
16942 lodash.delay = delay;
16943 lodash.difference = difference;
16944 lodash.differenceBy = differenceBy;
16945 lodash.differenceWith = differenceWith;
16946 lodash.drop = drop;
16947 lodash.dropRight = dropRight;
16948 lodash.dropRightWhile = dropRightWhile;
16949 lodash.dropWhile = dropWhile;
16950 lodash.fill = fill;
16951 lodash.filter = filter;
16952 lodash.flatMap = flatMap;
16953 lodash.flatMapDeep = flatMapDeep;
16954 lodash.flatMapDepth = flatMapDepth;
16955 lodash.flatten = flatten;
16956 lodash.flattenDeep = flattenDeep;
16957 lodash.flattenDepth = flattenDepth;
16958 lodash.flip = flip;
16959 lodash.flow = flow;
16960 lodash.flowRight = flowRight;
16961 lodash.fromPairs = fromPairs;
16962 lodash.functions = functions;
16963 lodash.functionsIn = functionsIn;
16964 lodash.groupBy = groupBy;
16965 lodash.initial = initial;
16966 lodash.intersection = intersection;
16967 lodash.intersectionBy = intersectionBy;
16968 lodash.intersectionWith = intersectionWith;
16969 lodash.invert = invert;
16970 lodash.invertBy = invertBy;
16971 lodash.invokeMap = invokeMap;
16972 lodash.iteratee = iteratee;
16973 lodash.keyBy = keyBy;
16974 lodash.keys = keys;
16975 lodash.keysIn = keysIn;
16976 lodash.map = map;
16977 lodash.mapKeys = mapKeys;
16978 lodash.mapValues = mapValues;
16979 lodash.matches = matches;
16980 lodash.matchesProperty = matchesProperty;
16981 lodash.memoize = memoize;
16982 lodash.merge = merge;
16983 lodash.mergeWith = mergeWith;
16984 lodash.method = method;
16985 lodash.methodOf = methodOf;
16986 lodash.mixin = mixin;
16987 lodash.negate = negate;
16988 lodash.nthArg = nthArg;
16989 lodash.omit = omit;
16990 lodash.omitBy = omitBy;
16991 lodash.once = once;
16992 lodash.orderBy = orderBy;
16993 lodash.over = over;
16994 lodash.overArgs = overArgs;
16995 lodash.overEvery = overEvery;
16996 lodash.overSome = overSome;
16997 lodash.partial = partial;
16998 lodash.partialRight = partialRight;
16999 lodash.partition = partition;
17000 lodash.pick = pick;
17001 lodash.pickBy = pickBy;
17002 lodash.property = property;
17003 lodash.propertyOf = propertyOf;
17004 lodash.pull = pull;
17005 lodash.pullAll = pullAll;
17006 lodash.pullAllBy = pullAllBy;
17007 lodash.pullAllWith = pullAllWith;
17008 lodash.pullAt = pullAt;
17009 lodash.range = range;
17010 lodash.rangeRight = rangeRight;
17011 lodash.rearg = rearg;
17012 lodash.reject = reject;
17013 lodash.remove = remove;
17014 lodash.rest = rest;
17015 lodash.reverse = reverse;
17016 lodash.sampleSize = sampleSize;
17017 lodash.set = set;
17018 lodash.setWith = setWith;
17019 lodash.shuffle = shuffle;
17020 lodash.slice = slice;
17021 lodash.sortBy = sortBy;
17022 lodash.sortedUniq = sortedUniq;
17023 lodash.sortedUniqBy = sortedUniqBy;
17024 lodash.split = split;
17025 lodash.spread = spread;
17026 lodash.tail = tail;
17027 lodash.take = take;
17028 lodash.takeRight = takeRight;
17029 lodash.takeRightWhile = takeRightWhile;
17030 lodash.takeWhile = takeWhile;
17031 lodash.tap = tap;
17032 lodash.throttle = throttle;
17033 lodash.thru = thru;
17034 lodash.toArray = toArray;
17035 lodash.toPairs = toPairs;
17036 lodash.toPairsIn = toPairsIn;
17037 lodash.toPath = toPath;
17038 lodash.toPlainObject = toPlainObject;
17039 lodash.transform = transform;
17040 lodash.unary = unary;
17041 lodash.union = union;
17042 lodash.unionBy = unionBy;
17043 lodash.unionWith = unionWith;
17044 lodash.uniq = uniq;
17045 lodash.uniqBy = uniqBy;
17046 lodash.uniqWith = uniqWith;
17047 lodash.unset = unset;
17048 lodash.unzip = unzip;
17049 lodash.unzipWith = unzipWith;
17050 lodash.update = update;
17051 lodash.updateWith = updateWith;
17052 lodash.values = values;
17053 lodash.valuesIn = valuesIn;
17054 lodash.without = without;
17055 lodash.words = words;
17056 lodash.wrap = wrap;
17057 lodash.xor = xor;
17058 lodash.xorBy = xorBy;
17059 lodash.xorWith = xorWith;
17060 lodash.zip = zip;
17061 lodash.zipObject = zipObject;
17062 lodash.zipObjectDeep = zipObjectDeep;
17063 lodash.zipWith = zipWith;
17064
17065 // Add aliases.
17066 lodash.entries = toPairs;
17067 lodash.entriesIn = toPairsIn;
17068 lodash.extend = assignIn;
17069 lodash.extendWith = assignInWith;
17070
17071 // Add methods to `lodash.prototype`.
17072 mixin(lodash, lodash);
17073
17074 /*------------------------------------------------------------------------*/
17075
17076 // Add methods that return unwrapped values in chain sequences.
17077 lodash.add = add;
17078 lodash.attempt = attempt;
17079 lodash.camelCase = camelCase;
17080 lodash.capitalize = capitalize;
17081 lodash.ceil = ceil;
17082 lodash.clamp = clamp;
17083 lodash.clone = clone;
17084 lodash.cloneDeep = cloneDeep;
17085 lodash.cloneDeepWith = cloneDeepWith;
17086 lodash.cloneWith = cloneWith;
17087 lodash.conformsTo = conformsTo;
17088 lodash.deburr = deburr;
17089 lodash.defaultTo = defaultTo;
17090 lodash.divide = divide;
17091 lodash.endsWith = endsWith;
17092 lodash.eq = eq;
17093 lodash.escape = escape;
17094 lodash.escapeRegExp = escapeRegExp;
17095 lodash.every = every;
17096 lodash.find = find;
17097 lodash.findIndex = findIndex;
17098 lodash.findKey = findKey;
17099 lodash.findLast = findLast;
17100 lodash.findLastIndex = findLastIndex;
17101 lodash.findLastKey = findLastKey;
17102 lodash.floor = floor;
17103 lodash.forEach = forEach;
17104 lodash.forEachRight = forEachRight;
17105 lodash.forIn = forIn;
17106 lodash.forInRight = forInRight;
17107 lodash.forOwn = forOwn;
17108 lodash.forOwnRight = forOwnRight;
17109 lodash.get = get;
17110 lodash.gt = gt;
17111 lodash.gte = gte;
17112 lodash.has = has;
17113 lodash.hasIn = hasIn;
17114 lodash.head = head;
17115 lodash.identity = identity;
17116 lodash.includes = includes;
17117 lodash.indexOf = indexOf;
17118 lodash.inRange = inRange;
17119 lodash.invoke = invoke;
17120 lodash.isArguments = isArguments;
17121 lodash.isArray = isArray;
17122 lodash.isArrayBuffer = isArrayBuffer;
17123 lodash.isArrayLike = isArrayLike;
17124 lodash.isArrayLikeObject = isArrayLikeObject;
17125 lodash.isBoolean = isBoolean;
17126 lodash.isBuffer = isBuffer;
17127 lodash.isDate = isDate;
17128 lodash.isElement = isElement;
17129 lodash.isEmpty = isEmpty;
17130 lodash.isEqual = isEqual;
17131 lodash.isEqualWith = isEqualWith;
17132 lodash.isError = isError;
17133 lodash.isFinite = isFinite;
17134 lodash.isFunction = isFunction;
17135 lodash.isInteger = isInteger;
17136 lodash.isLength = isLength;
17137 lodash.isMap = isMap;
17138 lodash.isMatch = isMatch;
17139 lodash.isMatchWith = isMatchWith;
17140 lodash.isNaN = isNaN;
17141 lodash.isNative = isNative;
17142 lodash.isNil = isNil;
17143 lodash.isNull = isNull;
17144 lodash.isNumber = isNumber;
17145 lodash.isObject = isObject;
17146 lodash.isObjectLike = isObjectLike;
17147 lodash.isPlainObject = isPlainObject;
17148 lodash.isRegExp = isRegExp;
17149 lodash.isSafeInteger = isSafeInteger;
17150 lodash.isSet = isSet;
17151 lodash.isString = isString;
17152 lodash.isSymbol = isSymbol;
17153 lodash.isTypedArray = isTypedArray;
17154 lodash.isUndefined = isUndefined;
17155 lodash.isWeakMap = isWeakMap;
17156 lodash.isWeakSet = isWeakSet;
17157 lodash.join = join;
17158 lodash.kebabCase = kebabCase;
17159 lodash.last = last;
17160 lodash.lastIndexOf = lastIndexOf;
17161 lodash.lowerCase = lowerCase;
17162 lodash.lowerFirst = lowerFirst;
17163 lodash.lt = lt;
17164 lodash.lte = lte;
17165 lodash.max = max;
17166 lodash.maxBy = maxBy;
17167 lodash.mean = mean;
17168 lodash.meanBy = meanBy;
17169 lodash.min = min;
17170 lodash.minBy = minBy;
17171 lodash.stubArray = stubArray;
17172 lodash.stubFalse = stubFalse;
17173 lodash.stubObject = stubObject;
17174 lodash.stubString = stubString;
17175 lodash.stubTrue = stubTrue;
17176 lodash.multiply = multiply;
17177 lodash.nth = nth;
17178 lodash.noConflict = noConflict;
17179 lodash.noop = noop;
17180 lodash.now = now;
17181 lodash.pad = pad;
17182 lodash.padEnd = padEnd;
17183 lodash.padStart = padStart;
17184 lodash.parseInt = parseInt;
17185 lodash.random = random;
17186 lodash.reduce = reduce;
17187 lodash.reduceRight = reduceRight;
17188 lodash.repeat = repeat;
17189 lodash.replace = replace;
17190 lodash.result = result;
17191 lodash.round = round;
17192 lodash.runInContext = runInContext;
17193 lodash.sample = sample;
17194 lodash.size = size;
17195 lodash.snakeCase = snakeCase;
17196 lodash.some = some;
17197 lodash.sortedIndex = sortedIndex;
17198 lodash.sortedIndexBy = sortedIndexBy;
17199 lodash.sortedIndexOf = sortedIndexOf;
17200 lodash.sortedLastIndex = sortedLastIndex;
17201 lodash.sortedLastIndexBy = sortedLastIndexBy;
17202 lodash.sortedLastIndexOf = sortedLastIndexOf;
17203 lodash.startCase = startCase;
17204 lodash.startsWith = startsWith;
17205 lodash.subtract = subtract;
17206 lodash.sum = sum;
17207 lodash.sumBy = sumBy;
17208 lodash.template = template;
17209 lodash.times = times;
17210 lodash.toFinite = toFinite;
17211 lodash.toInteger = toInteger;
17212 lodash.toLength = toLength;
17213 lodash.toLower = toLower;
17214 lodash.toNumber = toNumber;
17215 lodash.toSafeInteger = toSafeInteger;
17216 lodash.toString = toString;
17217 lodash.toUpper = toUpper;
17218 lodash.trim = trim;
17219 lodash.trimEnd = trimEnd;
17220 lodash.trimStart = trimStart;
17221 lodash.truncate = truncate;
17222 lodash.unescape = unescape;
17223 lodash.uniqueId = uniqueId;
17224 lodash.upperCase = upperCase;
17225 lodash.upperFirst = upperFirst;
17226
17227 // Add aliases.
17228 lodash.each = forEach;
17229 lodash.eachRight = forEachRight;
17230 lodash.first = head;
17231
17232 mixin(lodash, (function() {
17233 var source = {};
17234 baseForOwn(lodash, function(func, methodName) {
17235 if (!hasOwnProperty.call(lodash.prototype, methodName)) {
17236 source[methodName] = func;
17237 }
17238 });
17239 return source;
17240 }()), { 'chain': false });
17241
17242 /*------------------------------------------------------------------------*/
17243
17244 /**
17245 * The semantic version number.
17246 *
17247 * @static
17248 * @memberOf _
17249 * @type {string}
17250 */
17251 lodash.VERSION = VERSION;
17252
17253 // Assign default placeholders.
17254 arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
17255 lodash[methodName].placeholder = lodash;
17256 });
17257
17258 // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
17259 arrayEach(['drop', 'take'], function(methodName, index) {
17260 LazyWrapper.prototype[methodName] = function(n) {
17261 n = n === undefined$1 ? 1 : nativeMax(toInteger(n), 0);
17262
17263 var result = (this.__filtered__ && !index)
17264 ? new LazyWrapper(this)
17265 : this.clone();
17266
17267 if (result.__filtered__) {
17268 result.__takeCount__ = nativeMin(n, result.__takeCount__);
17269 } else {
17270 result.__views__.push({
17271 'size': nativeMin(n, MAX_ARRAY_LENGTH),
17272 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
17273 });
17274 }
17275 return result;
17276 };
17277
17278 LazyWrapper.prototype[methodName + 'Right'] = function(n) {
17279 return this.reverse()[methodName](n).reverse();
17280 };
17281 });
17282
17283 // Add `LazyWrapper` methods that accept an `iteratee` value.
17284 arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
17285 var type = index + 1,
17286 isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
17287
17288 LazyWrapper.prototype[methodName] = function(iteratee) {
17289 var result = this.clone();
17290 result.__iteratees__.push({
17291 'iteratee': getIteratee(iteratee, 3),
17292 'type': type
17293 });
17294 result.__filtered__ = result.__filtered__ || isFilter;
17295 return result;
17296 };
17297 });
17298
17299 // Add `LazyWrapper` methods for `_.head` and `_.last`.
17300 arrayEach(['head', 'last'], function(methodName, index) {
17301 var takeName = 'take' + (index ? 'Right' : '');
17302
17303 LazyWrapper.prototype[methodName] = function() {
17304 return this[takeName](1).value()[0];
17305 };
17306 });
17307
17308 // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
17309 arrayEach(['initial', 'tail'], function(methodName, index) {
17310 var dropName = 'drop' + (index ? '' : 'Right');
17311
17312 LazyWrapper.prototype[methodName] = function() {
17313 return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
17314 };
17315 });
17316
17317 LazyWrapper.prototype.compact = function() {
17318 return this.filter(identity);
17319 };
17320
17321 LazyWrapper.prototype.find = function(predicate) {
17322 return this.filter(predicate).head();
17323 };
17324
17325 LazyWrapper.prototype.findLast = function(predicate) {
17326 return this.reverse().find(predicate);
17327 };
17328
17329 LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
17330 if (typeof path == 'function') {
17331 return new LazyWrapper(this);
17332 }
17333 return this.map(function(value) {
17334 return baseInvoke(value, path, args);
17335 });
17336 });
17337
17338 LazyWrapper.prototype.reject = function(predicate) {
17339 return this.filter(negate(getIteratee(predicate)));
17340 };
17341
17342 LazyWrapper.prototype.slice = function(start, end) {
17343 start = toInteger(start);
17344
17345 var result = this;
17346 if (result.__filtered__ && (start > 0 || end < 0)) {
17347 return new LazyWrapper(result);
17348 }
17349 if (start < 0) {
17350 result = result.takeRight(-start);
17351 } else if (start) {
17352 result = result.drop(start);
17353 }
17354 if (end !== undefined$1) {
17355 end = toInteger(end);
17356 result = end < 0 ? result.dropRight(-end) : result.take(end - start);
17357 }
17358 return result;
17359 };
17360
17361 LazyWrapper.prototype.takeRightWhile = function(predicate) {
17362 return this.reverse().takeWhile(predicate).reverse();
17363 };
17364
17365 LazyWrapper.prototype.toArray = function() {
17366 return this.take(MAX_ARRAY_LENGTH);
17367 };
17368
17369 // Add `LazyWrapper` methods to `lodash.prototype`.
17370 baseForOwn(LazyWrapper.prototype, function(func, methodName) {
17371 var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
17372 isTaker = /^(?:head|last)$/.test(methodName),
17373 lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
17374 retUnwrapped = isTaker || /^find/.test(methodName);
17375
17376 if (!lodashFunc) {
17377 return;
17378 }
17379 lodash.prototype[methodName] = function() {
17380 var value = this.__wrapped__,
17381 args = isTaker ? [1] : arguments,
17382 isLazy = value instanceof LazyWrapper,
17383 iteratee = args[0],
17384 useLazy = isLazy || isArray(value);
17385
17386 var interceptor = function(value) {
17387 var result = lodashFunc.apply(lodash, arrayPush([value], args));
17388 return (isTaker && chainAll) ? result[0] : result;
17389 };
17390
17391 if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
17392 // Avoid lazy use if the iteratee has a "length" value other than `1`.
17393 isLazy = useLazy = false;
17394 }
17395 var chainAll = this.__chain__,
17396 isHybrid = !!this.__actions__.length,
17397 isUnwrapped = retUnwrapped && !chainAll,
17398 onlyLazy = isLazy && !isHybrid;
17399
17400 if (!retUnwrapped && useLazy) {
17401 value = onlyLazy ? value : new LazyWrapper(this);
17402 var result = func.apply(value, args);
17403 result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined$1 });
17404 return new LodashWrapper(result, chainAll);
17405 }
17406 if (isUnwrapped && onlyLazy) {
17407 return func.apply(this, args);
17408 }
17409 result = this.thru(interceptor);
17410 return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
17411 };
17412 });
17413
17414 // Add `Array` methods to `lodash.prototype`.
17415 arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
17416 var func = arrayProto[methodName],
17417 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
17418 retUnwrapped = /^(?:pop|shift)$/.test(methodName);
17419
17420 lodash.prototype[methodName] = function() {
17421 var args = arguments;
17422 if (retUnwrapped && !this.__chain__) {
17423 var value = this.value();
17424 return func.apply(isArray(value) ? value : [], args);
17425 }
17426 return this[chainName](function(value) {
17427 return func.apply(isArray(value) ? value : [], args);
17428 });
17429 };
17430 });
17431
17432 // Map minified method names to their real names.
17433 baseForOwn(LazyWrapper.prototype, function(func, methodName) {
17434 var lodashFunc = lodash[methodName];
17435 if (lodashFunc) {
17436 var key = lodashFunc.name + '';
17437 if (!hasOwnProperty.call(realNames, key)) {
17438 realNames[key] = [];
17439 }
17440 realNames[key].push({ 'name': methodName, 'func': lodashFunc });
17441 }
17442 });
17443
17444 realNames[createHybrid(undefined$1, WRAP_BIND_KEY_FLAG).name] = [{
17445 'name': 'wrapper',
17446 'func': undefined$1
17447 }];
17448
17449 // Add methods to `LazyWrapper`.
17450 LazyWrapper.prototype.clone = lazyClone;
17451 LazyWrapper.prototype.reverse = lazyReverse;
17452 LazyWrapper.prototype.value = lazyValue;
17453
17454 // Add chain sequence methods to the `lodash` wrapper.
17455 lodash.prototype.at = wrapperAt;
17456 lodash.prototype.chain = wrapperChain;
17457 lodash.prototype.commit = wrapperCommit;
17458 lodash.prototype.next = wrapperNext;
17459 lodash.prototype.plant = wrapperPlant;
17460 lodash.prototype.reverse = wrapperReverse;
17461 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
17462
17463 // Add lazy aliases.
17464 lodash.prototype.first = lodash.prototype.head;
17465
17466 if (symIterator) {
17467 lodash.prototype[symIterator] = wrapperToIterator;
17468 }
17469 return lodash;
17470 });
17471
17472 /*--------------------------------------------------------------------------*/
17473
17474 // Export lodash.
17475 var _ = runInContext();
17476
17477 // Some AMD build optimizers, like r.js, check for condition patterns like:
17478 if (freeModule) {
17479 // Export for Node.js.
17480 (freeModule.exports = _)._ = _;
17481 // Export for CommonJS support.
17482 freeExports._ = _;
17483 }
17484 else {
17485 // Export to the global object.
17486 root._ = _;
17487 }
17488 }.call(commonjsGlobal));
17489 }(lodash, lodash.exports));
17490
17491 const HTML_ESCAPE_MAP = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' };
17492 const escapeHtml = (s) => s.replace(/[&<>"']/g, c => HTML_ESCAPE_MAP[c]);
17493 const escapeRegex = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
17494 /**
17495 * Highlights the matching parts of a text based on a query.
17496 */
17497 function highlightMatch(text, query) {
17498 if (!text || !query) {
17499 return escapeHtml(text || '');
17500 }
17501 const safeText = escapeHtml(text);
17502 const words = query
17503 .split(/\s+/)
17504 .filter(word => word)
17505 .map(escapeRegex);
17506 if (words.length === 0) {
17507 return safeText;
17508 }
17509 try {
17510 const regex = new RegExp(`(${words.join('|')})`, 'gi');
17511 return safeText.replace(regex, '<strong>$1</strong>');
17512 }
17513 catch (error) {
17514 return safeText;
17515 }
17516 }
17517 /**
17518 * Fetches address suggestions from the Google Maps API.
17519 */
17520 async function fetchAddressSuggestions(input, country, regions, signal) {
17521 var _a, _b;
17522 const response = await fetch('https://places.googleapis.com/v1/places:searchText', {
17523 method: 'POST',
17524 headers: {
17525 'Content-Type': 'application/json',
17526 'X-Goog-Api-Key': (_a = window === null || window === void 0 ? void 0 : window.scData) === null || _a === void 0 ? void 0 : _a.google_map_api_key,
17527 'X-Goog-FieldMask': 'places.id,places.displayName,places.types,places.primaryType,places.primaryTypeDisplayName,places.addressComponents',
17528 },
17529 body: JSON.stringify({
17530 textQuery: input,
17531 pageSize: 5,
17532 regionCode: country,
17533 }),
17534 signal,
17535 });
17536 const addressResponse = await response.json();
17537 if ((_b = addressResponse === null || addressResponse === void 0 ? void 0 : addressResponse.error) === null || _b === void 0 ? void 0 : _b.message) {
17538 throw new Error(addressResponse.error.message);
17539 }
17540 return ((addressResponse === null || addressResponse === void 0 ? void 0 : addressResponse.places) || []).map((place) => {
17541 var _a, _b, _c, _d;
17542 const { city, state, country } = getAddressLabels((place === null || place === void 0 ? void 0 : place.addressComponents) || [], regions);
17543 return {
17544 displayName: (_b = (_a = place === null || place === void 0 ? void 0 : place.displayName) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : input,
17545 fullDisplayName: [(_d = (_c = place === null || place === void 0 ? void 0 : place.displayName) === null || _c === void 0 ? void 0 : _c.text) !== null && _d !== void 0 ? _d : input, city, state, country].filter(Boolean).join(', '),
17546 placeId: place === null || place === void 0 ? void 0 : place.id,
17547 addressComponents: (place === null || place === void 0 ? void 0 : place.addressComponents) || null,
17548 };
17549 });
17550 }
17551 /**
17552 * Returns a full replacement address — preserves recipient name only, does not merge with the
17553 * previous address. Merging would leak stale line_2/city/postal_code when the new place omits them.
17554 */
17555 function buildReplacementAddressFromPlace(place, regions, previousName) {
17556 var _a, _b, _c, _d, _e, _f;
17557 if (!((_a = place === null || place === void 0 ? void 0 : place.addressComponents) === null || _a === void 0 ? void 0 : _a.length)) {
17558 throw new Error('Place details not found.');
17559 }
17560 const placeDetails = transformPlaceDetails(place.addressComponents, regions);
17561 const line1 = getStreetAddress(place.addressComponents) || place.displayName || '';
17562 return {
17563 name: previousName !== null && previousName !== void 0 ? previousName : null,
17564 line_1: line1,
17565 line_2: (_b = placeDetails.line_2) !== null && _b !== void 0 ? _b : null,
17566 city: (_c = placeDetails.city) !== null && _c !== void 0 ? _c : null,
17567 state: (_d = placeDetails.state) !== null && _d !== void 0 ? _d : null,
17568 postal_code: (_e = placeDetails.postal_code) !== null && _e !== void 0 ? _e : null,
17569 country: (_f = placeDetails.country) !== null && _f !== void 0 ? _f : null,
17570 };
17571 }
17572 /**
17573 * Fetches place details from the Google Maps API.
17574 */
17575 async function fetchPlaceDetails(placeId, addressSuggestions, address, regions) {
17576 var _a;
17577 const place = addressSuggestions.find((suggestion) => suggestion.placeId === placeId);
17578 if (!(place === null || place === void 0 ? void 0 : place.addressComponents)) {
17579 throw new Error('Place details not found.');
17580 }
17581 const { addressComponents } = place;
17582 const country = ((_a = addressComponents.find(component => { var _a; return (_a = component.types) === null || _a === void 0 ? void 0 : _a.includes('country'); })) === null || _a === void 0 ? void 0 : _a.shortText) || null;
17583 const updatedRegions = (address === null || address === void 0 ? void 0 : address.country) !== country ? await getCountryRegions(country) : regions;
17584 return {
17585 updatedAddress: buildReplacementAddressFromPlace(place, updatedRegions, address.name),
17586 updatedRegions,
17587 };
17588 }
17589
17590 const scAddressSuggestionsCss = ":host{position:relative;display:block}sc-input{margin-bottom:var(--sc-address-column-spacing, -1px)}.sc-address__suggestions{position:absolute;right:0px;z-index:var(--sc-address-suggestion-z-index, 11);background:var(--sc-panel-background-color);box-shadow:0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);max-height:var(--sc-panel-height, 350px);width:100%;border:solid 1px var(--sc-panel-border-color);border-radius:var(--sc-border-radius-medium);opacity:0;visibility:hidden;transform:translateY(2px);transition:opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;display:flex;flex-direction:column;min-height:0;overflow:hidden}.sc-address__suggestions--visible{opacity:1;visibility:visible;transform:translateY(0)}.sc-address__suggestions--body{display:flex;flex-direction:column;flex:1 1 auto;min-height:0;max-height:100%;overflow:hidden}.sc-address__suggestions--scroll{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden}.sc-address__suggestions--footer{flex-shrink:0;padding:10px 20px;font-size:var(--sc-font-size-small);border-top:solid 1px var(--sc-color-gray-200);background-color:var(--sc-panel-background-color)}.sc-address__suggestions--footer button{background:none;border:none;color:var(--sc-color-gray-600);font-size:var(--sc-font-size-small);padding:0;cursor:pointer}.sc-address__suggestions--footer button:hover{text-decoration:underline}.sc-address__suggestions--footer button:focus-visible{outline:2px solid var(--sc-focus-ring-color, var(--sc-color-primary));outline-offset:2px}.sc-address__suggestions--list{list-style:none;padding:0;margin:0}.sc-address__suggestions--item{padding:10px 20px;cursor:pointer;font-family:var(--sc-font-sans);font-size:var(--sc-font-size-medium);font-weight:var(--sc-font-weight-normal);color:var(--color);background-color:var(--sc-panel-background-color);transition:background-color 0.2s ease}.sc-address__suggestions--item:hover,.sc-address__suggestions--item.focused{background-color:var(--sc-color-gray-100);color:var(--sc-color-primary)}.sc-address__suggestions--item:active{background-color:var(--sc-color-primary-light);color:var(--sc-color-primary)}.sc-address__suggestions--item:focus-visible{outline:2px solid var(--sc-focus-ring-color, var(--sc-color-primary));outline-offset:-2px}.sc-address__suggestions--item:focus:not(:focus-visible){outline:none}.sc-address__suggestions--item--no-select{cursor:auto}.sc-address__suggestions--item--no-select:hover,.sc-address__suggestions--item--no-select.focused,.sc-address__suggestions--item--no-select:active{background-color:var(--sc-panel-background-color);outline:none}.sc-address__suggestions--item--no-result{color:var(--sc-color-gray-600)}.sc-address__suggestions--item--powered-by{font-size:var(--sc-font-size-small);color:var(--sc-color-gray-600);display:flex;align-items:center;justify-content:space-between;text-align:center;padding:0 0 0 20px;margin-top:1px}.sc-address__suggestions--item--powered-by a{color:var(--sc-color-gray-600);text-decoration:none}.sc-address__suggestions--item--powered-by a span{font-weight:var(--sc-font-weight-bold)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}";
17591 const ScAddressSuggestionsStyle0 = scAddressSuggestionsCss;
17592
17593 const ScAddressSuggestions = class {
17594 constructor(hostRef) {
17595 registerInstance(this, hostRef);
17596 this.scChangeAddress = createEvent(this, "scChangeAddress", 7);
17597 this.scShowAddressFields = createEvent(this, "scShowAddressFields", 7);
17598 this.scHideAddressFields = createEvent(this, "scHideAddressFields", 7);
17599 var _a;
17600 /** Tracks whether the local value was set by user input / browser autofill and hasn't been synced to the address prop yet. */
17601 this.hasUnsyncedLocalValue = false;
17602 // Use Lodash debounce for fetchAddressSuggestions.
17603 this.debouncedFetchAddressSuggestions = lodash.exports.debounce(async (input) => {
17604 var _a, _b;
17605 (_a = this.abortController) === null || _a === void 0 ? void 0 : _a.abort();
17606 this.abortController = new AbortController();
17607 try {
17608 this.loading = true;
17609 this.addressSuggestions = await fetchAddressSuggestions(input, (_b = this.address) === null || _b === void 0 ? void 0 : _b.country, this.regions, this.abortController.signal);
17610 }
17611 catch (error) {
17612 if ((error === null || error === void 0 ? void 0 : error.name) === 'AbortError')
17613 return;
17614 createErrorNotice({
17615 message: wp.i18n.sprintf(wp.i18n.__('Google Map Error: %s', 'surecart'), error.message),
17616 });
17617 this.showSuggestions = false;
17618 this.addressSuggestions = [];
17619 }
17620 finally {
17621 this.loading = false;
17622 }
17623 }, 300);
17624 this.address = {
17625 country: null,
17626 city: null,
17627 line_1: null,
17628 line_2: null,
17629 postal_code: null,
17630 state: null,
17631 };
17632 this.names = {
17633 name: 'shipping_name',
17634 country: 'shipping_country',
17635 city: 'shipping_city',
17636 line_1: 'shipping_line_1',
17637 line_2: 'shipping_line_2',
17638 postal_code: 'shipping_postal_code',
17639 state: 'shipping_state',
17640 };
17641 this.label = wp.i18n.__('Address', 'surecart');
17642 this.inputProps = {};
17643 this.disabled = false;
17644 this.required = true;
17645 this.value = ((_a = this.address) === null || _a === void 0 ? void 0 : _a.line_1) || '';
17646 this.regions = [];
17647 this.addressSuggestions = [];
17648 this.showSuggestions = false;
17649 this.loading = false;
17650 this.focusedIndex = -1;
17651 }
17652 /** Delegates to the inner sc-input so this field participates in form validation
17653 * (it was previously skipped entirely, allowing required addresses through empty). */
17654 async reportValidity() {
17655 return this.input ? this.input.reportValidity() : true;
17656 }
17657 /** Whether Google Maps autocomplete is active. */
17658 isGoogleMapsActive() {
17659 var _a;
17660 return !!((_a = window === null || window === void 0 ? void 0 : window.scData) === null || _a === void 0 ? void 0 : _a.google_map_api_key);
17661 }
17662 handleValueChange(newValue) {
17663 var _a;
17664 // Only fetch suggestions for user input, not prop syncs.
17665 if (!this.hasUnsyncedLocalValue)
17666 return;
17667 if (!((_a = this.address) === null || _a === void 0 ? void 0 : _a.country))
17668 return;
17669 if (newValue && this.showSuggestions) {
17670 this.debouncedFetchAddressSuggestions(newValue);
17671 }
17672 }
17673 /** Close the suggestions list and cancel in-flight fetch. */
17674 closeSuggestionsDropdown() {
17675 var _a;
17676 this.showSuggestions = false;
17677 this.addressSuggestions = [];
17678 this.focusedIndex = -1;
17679 this.debouncedFetchAddressSuggestions.cancel();
17680 (_a = this.abortController) === null || _a === void 0 ? void 0 : _a.abort();
17681 }
17682 handleAddressChange() {
17683 var _a;
17684 if (!((_a = this.address) === null || _a === void 0 ? void 0 : _a.country))
17685 return;
17686 if (this.showSuggestions) {
17687 this.closeSuggestionsDropdown();
17688 }
17689 // Only preserve the local value if it was set by user input / browser
17690 // autofill and hasn't been synced to the address prop yet.
17691 // Otherwise always sync from the address prop (e.g. country change clears fields).
17692 if (this.hasUnsyncedLocalValue && !this.address.line_1) ;
17693 else {
17694 // Set flag before value so the @Watch('value') sees it correctly.
17695 this.hasUnsyncedLocalValue = false;
17696 this.value = this.address.line_1 || '';
17697 }
17698 this.updateFieldVisibility();
17699 }
17700 /** Emit an address update to the parent, merging changes with current address. */
17701 emitAddressUpdate(changes) {
17702 this.scChangeAddress.emit({
17703 ...this.address,
17704 ...changes,
17705 });
17706 }
17707 /** Select a suggestion by place ID — used by both click and keyboard. */
17708 async selectSuggestion(placeId) {
17709 var _a;
17710 // Cancel any queued/in-flight suggestions fetch so a stale response can't overwrite state after we close.
17711 this.debouncedFetchAddressSuggestions.cancel();
17712 (_a = this.abortController) === null || _a === void 0 ? void 0 : _a.abort();
17713 try {
17714 const { updatedAddress, updatedRegions } = await fetchPlaceDetails(placeId, this.addressSuggestions, this.address, this.regions);
17715 this.regions = updatedRegions;
17716 this.closeSuggestionsDropdown();
17717 this.scChangeAddress.emit(updatedAddress);
17718 this.scShowAddressFields.emit();
17719 }
17720 catch (error) {
17721 createErrorNotice({
17722 message: wp.i18n.sprintf(wp.i18n.__('Google Map Error: %s', 'surecart'), error.message),
17723 });
17724 }
17725 }
17726 handleInputChange(e) {
17727 var _a, _b;
17728 if (this.isGoogleMapsActive()) {
17729 this.showSuggestions = true;
17730 }
17731 // Must set before assigning value — the @Watch('value') handler reads this flag synchronously.
17732 this.hasUnsyncedLocalValue = !!((_a = e.target) === null || _a === void 0 ? void 0 : _a.value);
17733 this.value = (_b = e.target) === null || _b === void 0 ? void 0 : _b.value;
17734 }
17735 /** Sync the input value back to the parent address on change events (blur, browser autofill). */
17736 handleInputValueChange(e) {
17737 var _a, _b;
17738 const newValue = (_a = e.target) === null || _a === void 0 ? void 0 : _a.value;
17739 if (newValue && newValue !== ((_b = this.address) === null || _b === void 0 ? void 0 : _b.line_1)) {
17740 this.hasUnsyncedLocalValue = false;
17741 this.closeSuggestionsDropdown();
17742 this.emitAddressUpdate({ line_1: newValue });
17743 }
17744 }
17745 handleKeyDown(event) {
17746 if (!this.addressSuggestions.length)
17747 return;
17748 switch (event.key) {
17749 case 'ArrowDown':
17750 event.preventDefault();
17751 this.focusedIndex = (this.focusedIndex + 1) % this.addressSuggestions.length;
17752 break;
17753 case 'ArrowUp':
17754 event.preventDefault();
17755 this.focusedIndex = (this.focusedIndex - 1 + this.addressSuggestions.length) % this.addressSuggestions.length;
17756 break;
17757 case 'Enter':
17758 event.preventDefault();
17759 if (this.focusedIndex >= 0) {
17760 this.selectSuggestion(this.addressSuggestions[this.focusedIndex].placeId);
17761 }
17762 break;
17763 case 'Escape':
17764 this.showSuggestions = false;
17765 this.addressSuggestions = [];
17766 break;
17767 }
17768 }
17769 manualAddress() {
17770 this.showSuggestions = false;
17771 this.scShowAddressFields.emit();
17772 if (this.value) {
17773 this.emitAddressUpdate({ line_1: this.value });
17774 }
17775 }
17776 handleOutsideClick(evt) {
17777 if (!this.showSuggestions)
17778 return;
17779 const path = evt.composedPath();
17780 if (!path.some(item => item === this.el)) {
17781 this.showSuggestions = false;
17782 if (this.value) {
17783 this.scShowAddressFields.emit();
17784 this.emitAddressUpdate({ line_1: this.value });
17785 }
17786 }
17787 }
17788 componentWillLoad() {
17789 this.boundHandleOutsideClick = evt => this.handleOutsideClick(evt);
17790 this.boundHandleKeyDown = evt => this.handleKeyDown(evt);
17791 this.handleAddressChange();
17792 document.addEventListener('mousedown', this.boundHandleOutsideClick);
17793 }
17794 componentDidLoad() {
17795 this.el.addEventListener('keydown', this.boundHandleKeyDown);
17796 this.updateFieldVisibility();
17797 }
17798 disconnectedCallback() {
17799 var _a;
17800 document.removeEventListener('mousedown', this.boundHandleOutsideClick);
17801 this.el.removeEventListener('keydown', this.boundHandleKeyDown);
17802 this.debouncedFetchAddressSuggestions.cancel();
17803 (_a = this.abortController) === null || _a === void 0 ? void 0 : _a.abort();
17804 }
17805 /** Tell the parent whether to show or hide the collapsible address fields. */
17806 updateFieldVisibility() {
17807 var _a;
17808 if (!this.isGoogleMapsActive())
17809 return; // Not our concern — parent shows all fields.
17810 const hasValue = ((_a = this.address) === null || _a === void 0 ? void 0 : _a.line_1) || (this.hasUnsyncedLocalValue && this.value);
17811 if (hasValue) {
17812 this.scShowAddressFields.emit();
17813 }
17814 else {
17815 this.scHideAddressFields.emit();
17816 }
17817 }
17818 getActiveDescendantId() {
17819 return this.focusedIndex >= 0 ? `suggestion-${this.focusedIndex}` : undefined;
17820 }
17821 getSuggestionsStatusText() {
17822 if (!this.showSuggestions || !this.value)
17823 return '';
17824 if (this.loading)
17825 return wp.i18n.__('Loading suggestions...', 'surecart');
17826 if (this.addressSuggestions.length === 0)
17827 return wp.i18n.__('No suggestions found', 'surecart');
17828 // Announce the focused suggestion for screen readers.
17829 if (this.focusedIndex >= 0 && this.addressSuggestions[this.focusedIndex]) {
17830 return wp.i18n.sprintf(
17831 /* translators: 1: suggestion text, 2: current position, 3: total suggestions */
17832 wp.i18n.__('%1$s, %2$d of %3$d. Press Enter to select.', 'surecart'), this.addressSuggestions[this.focusedIndex].fullDisplayName, this.focusedIndex + 1, this.addressSuggestions.length);
17833 }
17834 return wp.i18n.sprintf(wp.i18n.__('%d suggestions available', 'surecart'), this.addressSuggestions.length);
17835 }
17836 isSuggestionsVisible() {
17837 return this.showSuggestions && !!this.value;
17838 }
17839 renderAddressSuggestions() {
17840 if (!this.isSuggestionsVisible()) {
17841 return null;
17842 }
17843 return (h("div", { class: "sc-address__suggestions--body" }, h("div", { class: "sc-address__suggestions--scroll" }, h("ul", { class: "sc-address__suggestions--list", part: "suggestions-list", role: "listbox", id: "address-suggestions-listbox" }, h("li", { class: "sc-address__suggestions--item sc-address__suggestions--item--no-select sc-address__suggestions--item--powered-by", part: "suggestion-item powered-by", role: "presentation", tabindex: "-1" }, h("span", null, wp.i18n.__('Suggestions powered by ', 'surecart'), h("a", { href: "https://policies.google.com/privacy", target: "_blank", rel: "noopener noreferrer", "aria-label": wp.i18n.__('Google Privacy Policy (opens in new tab)', 'surecart') }, h("span", null, wp.i18n.__('Google', 'surecart')))), h("sc-button", { type: "text", onMouseDown: e => e.preventDefault(), onClick: () => {
17844 this.showSuggestions = false;
17845 this.addressSuggestions = [];
17846 }, "aria-label": wp.i18n.__('Close suggestions', 'surecart') }, h("sc-icon", { name: "x", style: { color: 'var(--sc-color-gray-500)' } }))), this.loading && this.addressSuggestions.length === 0 && (h("li", { class: "sc-address__suggestions--item sc-address__suggestions--item--no-select sc-address__suggestions--item--no-result", part: "suggestion-item no-result", role: "presentation", tabindex: "-1" }, wp.i18n.__('Loading...', 'surecart'))), !this.loading && this.addressSuggestions.length === 0 && (h("li", { class: "sc-address__suggestions--item sc-address__suggestions--item--no-select sc-address__suggestions--item--no-result", part: "suggestion-item no-result", role: "presentation", tabindex: "-1" }, wp.i18n.__('No results found', 'surecart'))), this.addressSuggestions.map((suggestion, index) => (h("li", { id: `suggestion-${index}`, class: {
17847 'sc-address__suggestions--item': true,
17848 'focused': this.focusedIndex === index,
17849 }, part: "suggestion-item", role: "option", "aria-selected": this.focusedIndex === index ? 'true' : 'false', "aria-label": wp.i18n.sprintf(wp.i18n.__('Select suggestion %s', 'surecart'), suggestion.fullDisplayName), tabindex: "-1", onMouseDown: e => e.preventDefault(), onClick: () => this.selectSuggestion(suggestion === null || suggestion === void 0 ? void 0 : suggestion.placeId), innerHTML: highlightMatch(suggestion.fullDisplayName, this.value), onMouseEnter: () => (this.focusedIndex = index), onMouseLeave: () => (this.focusedIndex = -1) }))))), h("div", { class: "sc-address__suggestions--footer", part: "suggestion-item manually", role: "presentation" }, h("button", { type: "button", onMouseDown: e => e.preventDefault(), onClick: () => this.manualAddress(), "aria-label": wp.i18n.__('Enter address manually instead of using suggestions', 'surecart') }, wp.i18n.__('Enter address manually', 'surecart')))));
17850 }
17851 render() {
17852 var _a;
17853 const suggestionsVisible = this.isSuggestionsVisible();
17854 return (h("div", { key: '1ff94aef717e1fb513130a32fa530eddded295f7', part: "base" }, this.isGoogleMapsActive() && h("span", { key: '5905584c70c9bdde8376c119a33573aa1e42a163', class: "sr-only" }, wp.i18n.__('Start typing to see address suggestions, or select one to auto-fill your address.', 'surecart')), h("sc-input", { key: 'b715600146e9f91adb2a0c097ab47f86abb39444', ref: el => (this.input = el), exportparts: "base:input__base, input, form-control, label, help-text", value: this === null || this === void 0 ? void 0 : this.value, onScInput: (e) => this.handleInputChange(e), onScChange: (e) => this.handleInputValueChange(e), autocomplete: "address-line1", placeholder: this.label, "aria-label": this.label, "aria-expanded": suggestionsVisible ? 'true' : 'false', "aria-controls": suggestionsVisible ? 'address-suggestions-listbox' : undefined, "aria-activedescendant": this.getActiveDescendantId(), role: "combobox", name: (_a = this.names) === null || _a === void 0 ? void 0 : _a.line_1, disabled: this.disabled, required: this.required, ...this.inputProps }), h("div", { key: '8eb415af53dd065ffe54a380c2a43a87bd2c1422', role: "status", "aria-live": "polite", "aria-atomic": "true", class: "sr-only" }, this.getSuggestionsStatusText()), h("div", { key: '95d98b9e38f5d00e147c12370383b76efac0b879', class: {
17855 'sc-address__suggestions': true,
17856 'sc-address__suggestions--visible': suggestionsVisible,
17857 }, part: "suggestions", "aria-hidden": !suggestionsVisible ? 'true' : 'false' }, this.renderAddressSuggestions())));
17858 }
17859 get el() { return getElement(this); }
17860 static get watchers() { return {
17861 "value": ["handleValueChange"],
17862 "address": ["handleAddressChange"]
17863 }; }
17864 };
17865 ScAddressSuggestions.style = ScAddressSuggestionsStyle0;
17866
17867 const scCheckboxCss = ":host{display:block}.checkbox{display:flex;font-family:var(--sc-input-font-family);font-size:var(--sc-input-font-size-medium);font-weight:var(--sc-input-font-weight);color:var(--sc-input-color);vertical-align:middle;cursor:pointer}.checkbox__control{flex:0 0 auto;position:relative;display:inline-flex;align-items:center;justify-content:center;width:var(--sc-checkbox-size);height:var(--sc-checkbox-size);border:solid var(--sc-input-border-width) var(--sc-input-border-color);border-radius:2px;background-color:var(--sc-input-background-color);color:var(--sc-color-white);transition:var(--sc-input-transition, var(--sc-transition-medium)) border-color, var(--sc-input-transition, var(--sc-transition-medium)) opacity, var(--sc-input-transition, var(--sc-transition-medium)) background-color, var(--sc-input-transition, var(--sc-transition-medium)) color, var(--sc-input-transition, var(--sc-transition-medium)) box-shadow}.checkbox__control input[type=checkbox]{position:absolute;opacity:0;padding:0;margin:0;pointer-events:none}.checkbox__control .checkbox__icon{display:inline-flex;width:var(--sc-checkbox-size);height:var(--sc-checkbox-size)}.checkbox__control .checkbox__icon svg{width:100%;height:100%}.checkbox:not(.checkbox--checked):not(.checkbox--disabled) .checkbox__control:hover{border-color:var(--sc-input-border-color-hover);background-color:var(--sc-input-background-color-hover)}.checkbox.checkbox--focused:not(.checkbox--checked):not(.checkbox--disabled) .checkbox__control{border-color:var(--sc-input-border-color-focus);background-color:var(--sc-input-background-color-focus);box-shadow:0 0 0 var(--sc-focus-ring-width) var(--sc-focus-ring-color-primary)}.checkbox--checked .checkbox__control,.checkbox--indeterminate .checkbox__control{border-color:var(--sc-color-primary-500);background-color:var(--sc-color-primary-500)}.checkbox.checkbox--checked:not(.checkbox--disabled) .checkbox__control:hover,.checkbox.checkbox--indeterminate:not(.checkbox--disabled) .checkbox__control:hover{opacity:0.8}.checkbox.checkbox--checked:not(.checkbox--disabled).checkbox--focused .checkbox__control,.checkbox.checkbox--indeterminate:not(.checkbox--disabled).checkbox--focused .checkbox__control{border-color:var(--sc-color-white);background-color:var(--sc-color-primary-500);box-shadow:0 0 0 var(--sc-focus-ring-width) var(--sc-focus-ring-color-primary)}.checkbox--disabled{opacity:0.5;cursor:not-allowed}.checkbox__label{line-height:var(--sc-checkbox-size);margin-top:var(--sc-input-border-width);margin-left:0.5em;flex:1}.checkbox--is-required .checkbox__label:after{content:\" *\";color:var(--sc-color-danger-500)}::slotted(*){display:inline-block}.checkbox--is-rtl .checkbox__label{margin-left:0;margin-right:0.5em}";
17868 const ScCheckboxStyle0 = scCheckboxCss;
17869
17870 let id$1 = 0;
17871 const ScCheckbox = class {
17872 constructor(hostRef) {
17873 registerInstance(this, hostRef);
17874 this.scBlur = createEvent(this, "scBlur", 7);
17875 this.scChange = createEvent(this, "scChange", 7);
17876 this.scFocus = createEvent(this, "scFocus", 7);
17877 this.inputId = `checkbox-${++id$1}`;
17878 this.labelId = `checkbox-label-${id$1}`;
17879 this.hasFocus = false;
17880 this.name = undefined;
17881 this.value = undefined;
17882 this.disabled = false;
17883 this.edit = false;
17884 this.required = false;
17885 this.checked = false;
17886 this.indeterminate = false;
17887 this.invalid = false;
17888 }
17889 firstUpdated() {
17890 this.input.indeterminate = this.indeterminate;
17891 }
17892 /** Simulates a click on the checkbox. */
17893 async triggerClick() {
17894 return this.input.click();
17895 }
17896 /** Sets focus on the checkbox. */
17897 async triggerFocus(options) {
17898 return this.input.focus(options);
17899 }
17900 /** Removes focus from the checkbox. */
17901 async triggerBlur() {
17902 return this.input.blur();
17903 }
17904 /** Checks for validity and shows the browser's validation message if the control is invalid. */
17905 async reportValidity() {
17906 this.invalid = !this.input.checkValidity();
17907 return this.input.reportValidity();
17908 }
17909 /** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */
17910 setCustomValidity(message) {
17911 this.input.setCustomValidity(message);
17912 this.invalid = !this.input.checkValidity();
17913 }
17914 handleClick() {
17915 this.checked = !this.checked;
17916 this.indeterminate = false;
17917 }
17918 handleBlur() {
17919 this.hasFocus = false;
17920 this.scBlur.emit();
17921 }
17922 handleFocus() {
17923 this.hasFocus = true;
17924 this.scFocus.emit();
17925 }
17926 handleLabelMouseDown() {
17927 // Prevent clicks on the label from briefly blurring the input
17928 // event.preventDefault();
17929 this.input.focus();
17930 }
17931 handleStateChange() {
17932 this.input.checked = this.checked;
17933 this.input.indeterminate = this.indeterminate;
17934 this.scChange.emit();
17935 }
17936 componentDidLoad() {
17937 this.formController = new FormSubmitController(this.el, {
17938 value: (control) => (control.checked ? control.value : undefined),
17939 }).addFormData();
17940 }
17941 disconnectedCallback() {
17942 var _a;
17943 (_a = this.formController) === null || _a === void 0 ? void 0 : _a.removeFormData();
17944 }
17945 render() {
17946 const Tag = this.edit ? 'div' : 'label';
17947 return (h(Tag, { key: '4150edb283e831f750474b12cdfb0276c9d16052', part: "base", class: {
17948 'checkbox': true,
17949 'checkbox--is-required': this.required,
17950 'checkbox--checked': this.checked,
17951 'checkbox--disabled': this.disabled,
17952 'checkbox--focused': this.hasFocus,
17953 'checkbox--indeterminate': this.indeterminate,
17954 'checkbox--is-rtl': isRtl()
17955 }, htmlFor: this.inputId, onMouseDown: () => this.handleLabelMouseDown() }, h("span", { key: '629e75c2cbb9720f1ca3802e38af6fa830ad485b', part: "control", class: "checkbox__control" }, this.checked ? (h("span", { part: "checked-icon", class: "checkbox__icon" }, h("svg", { viewBox: "0 0 16 16" }, h("g", { stroke: "none", "stroke-width": "1", fill: "none", "fill-rule": "evenodd", "stroke-linecap": "round" }, h("g", { stroke: "currentColor", "stroke-width": "2" }, h("g", { transform: "translate(3.428571, 3.428571)" }, h("path", { d: "M0,5.71428571 L3.42857143,9.14285714" }), h("path", { d: "M9.14285714,0 L3.42857143,9.14285714" }))))))) : (''), !this.checked && this.indeterminate ? (h("span", { part: "indeterminate-icon", class: "checkbox__icon" }, h("svg", { viewBox: "0 0 16 16" }, h("g", { stroke: "none", "stroke-width": "1", fill: "none", "fill-rule": "evenodd", "stroke-linecap": "round" }, h("g", { stroke: "currentColor", "stroke-width": "2" }, h("g", { transform: "translate(2.285714, 6.857143)" }, h("path", { d: "M10.2857143,1.14285714 L1.14285714,1.14285714" }))))))) : (''), h("input", { key: '186de1dba380ae19fba5f988a6c22a25a28799c2', id: this.inputId, ref: el => (this.input = el), type: "checkbox", name: this.name, value: this.value, checked: this.checked, disabled: this.disabled, required: this.required, role: "checkbox", "aria-checked": this.checked ? 'true' : 'false', "aria-labelledby": this.labelId, onClick: () => this.handleClick(), onBlur: () => this.handleBlur(), onFocus: () => this.handleFocus() })), h("span", { key: '23ac93389a713543ceaefcefd55b12d291a77896', part: "label", id: this.labelId, class: "checkbox__label" }, h("slot", { key: '530548fc007560d0c303a62f57dc0d52835523b5' }))));
17956 }
17957 get el() { return getElement(this); }
17958 static get watchers() { return {
17959 "checked": ["handleStateChange"],
17960 "indeterminate": ["handleStateChange"]
17961 }; }
17962 };
17963 ScCheckbox.style = ScCheckboxStyle0;
17964
17965 const scPhoneInputCss = ":host{--focus-ring:0 0 0 var(--sc-focus-ring-width) var(--sc-focus-ring-color-primary);display:block;position:relative}:host([invalid]) .input,:host([invalid]) .input:hover:not(.input--disabled),:host([invalid]) .input--focused:not(.input--disabled){border-color:var(--sc-input-border-color-invalid);box-shadow:0 0 0 var(--sc-focus-ring-width) var(--sc-input-border-color-invalid)}.input__control[type=number]{-moz-appearance:textfield}.input__control::-webkit-outer-spin-button,.input__control::-webkit-inner-spin-button{-webkit-appearance:none}.input{flex:1 1 auto;display:inline-flex;align-items:center;justify-content:start;position:relative;width:100%;box-sizing:border-box;font-family:var(--sc-input-font-family);font-weight:var(--sc-input-font-weight);letter-spacing:var(--sc-input-letter-spacing);background-color:var(--sc-input-background-color);border:solid 1px var(--sc-input-border-color, var(--sc-input-border));vertical-align:middle;box-shadow:var(--sc-input-box-shadow);transition:var(--sc-transition-fast) color, var(--sc-transition-fast) border, var(--sc-transition-fast) box-shadow;cursor:text}.input:hover:not(.input--disabled){background-color:var(--sc-input-background-color-hover);border-color:var(--sc-input-border-color-hover);z-index:7}.input:hover:not(.input--disabled) .input__control{color:var(--sc-input-color-hover)}.input.input--focused:not(.input--disabled){background-color:var(--sc-input-background-color-focus);border-color:var(--sc-input-border-color-focus);box-shadow:var(--focus-ring);z-index:8}.input.input--focused:not(.input--disabled) .input__control{color:var(--sc-input-color-focus)}.input.input--disabled{background-color:var(--sc-input-background-color-disabled);border-color:var(--sc-input-border-color-disabled);opacity:0.5;cursor:not-allowed}.input.input--disabled .input__control{color:var(--sc-input-color-disabled)}.input.input--disabled .input__control::placeholder{color:var(--sc-input-placeholder-color-disabled)}.input__control{flex:1 1 auto;font-family:inherit;font-size:inherit;font-weight:inherit;min-width:0;height:100%;color:var(--sc-input-color);border:none;background:none;box-shadow:none;padding:0;margin:0;cursor:inherit;-webkit-appearance:none}.input__control::-webkit-search-decoration,.input__control::-webkit-search-cancel-button,.input__control::-webkit-search-results-button,.input__control::-webkit-search-results-decoration{-webkit-appearance:none}.input__control:-webkit-autofill,.input__control:-webkit-autofill:hover,.input__control:-webkit-autofill:focus,.input__control:-webkit-autofill:active{box-shadow:0 0 0 var(--sc-input-height-large) var(--sc-input-background-color-hover) inset !important;-webkit-text-fill-color:var(--sc-input-color)}.input__control::placeholder{color:var(--sc-input-placeholder-color);user-select:none}.input__control:focus{outline:none}.input__prefix,.input__suffix{display:inline-flex;flex:0 0 auto;align-items:center;color:var(--sc-input-color);cursor:default}.input__prefix ::slotted(sc-icon),.input__suffix ::slotted(sc-icon){color:var(--sc-input-icon-color)}.input--small{border-radius:var(--sc-input-border-radius-small);font-size:var(--sc-input-font-size-small);height:var(--sc-input-height-small)}.input--small .input__control{height:calc(var(--sc-input-height-small) - var(--sc-input-border-width) * 2);padding:0 var(--sc-input-spacing-small)}.input--small .input__clear,.input--small .input__password-toggle{margin-right:var(--sc-input-spacing-small)}.input--small .input__prefix ::slotted(*){margin-left:var(--sc-input-spacing-small)}.input--small .input__suffix ::slotted(*){margin-right:var(--sc-input-spacing-small)}.input--small .input__suffix ::slotted(sc-dropdown){margin:0}.input--medium{border-radius:var(--sc-input-border-radius-medium);font-size:var(--sc-input-font-size-medium);height:var(--sc-input-height-medium)}.input--medium .input__control{height:calc(var(--sc-input-height-medium) - var(--sc-input-border-width) * 2);padding:0 var(--sc-input-spacing-medium)}.input--medium .input__clear,.input--medium .input__password-toggle{margin-right:var(--sc-input-spacing-medium)}.input--medium .input__prefix ::slotted(*){margin-left:var(--sc-input-spacing-medium) !important}.input--medium .input__suffix ::slotted(:not(sc-button[size=medium])){margin-right:var(--sc-input-spacing-medium) !important}.input--medium .input__suffix ::slotted(sc-tag){margin-right:var(--sc-input-spacing-small) !important}.input--medium .input__suffix ::slotted(sc-dropdown){margin:3px}.input--large{border-radius:var(--sc-input-border-radius-large);font-size:var(--sc-input-font-size-large);height:var(--sc-input-height-large)}.input--large .input__control{height:calc(var(--sc-input-height-large) - var(--sc-input-border-width) * 2);padding:0 var(--sc-input-spacing-large)}.input--large .input__clear,.input--large .input__password-toggle{margin-right:var(--sc-input-spacing-large)}.input--large .input__prefix ::slotted(*){margin-left:var(--sc-input-spacing-large)}.input--large .input__suffix ::slotted(*){margin-right:var(--sc-input-spacing-large)}.input--large .input__suffix ::slotted(sc-dropdown){margin:3px}.input--pill.input--small{border-radius:var(--sc-input-height-small)}.input--pill.input--medium{border-radius:var(--sc-input-height-medium)}.input--pill.input--large{border-radius:var(--sc-input-height-large)}.input__clear,.input__password-toggle{display:inline-flex;align-items:center;font-size:inherit;color:var(--sc-input-icon-color);border:none;background:none;padding:0;transition:var(--sc-transition-fast) color;cursor:pointer}.input__clear:hover,.input__password-toggle:hover{color:var(--sc-input-icon-color-hover)}.input__clear:focus,.input__password-toggle:focus{outline:none}.input--empty .input__clear{visibility:hidden}.input--squared{border-radius:0}.input--squared-top{border-top-left-radius:0;border-top-right-radius:0}.input--squared-bottom{border-bottom-left-radius:0;border-bottom-right-radius:0}.input--squared-left{border-top-left-radius:0;border-bottom-left-radius:0}.input--squared-right{border-top-right-radius:0;border-bottom-right-radius:0}";
17966 const ScPhoneInputStyle0 = scPhoneInputCss;
17967
17968 let id = 0;
17969 const ScPhoneInput = class {
17970 constructor(hostRef) {
17971 registerInstance(this, hostRef);
17972 this.scChange = createEvent(this, "scChange", 7);
17973 this.scClear = createEvent(this, "scClear", 7);
17974 this.scInput = createEvent(this, "scInput", 7);
17975 this.scFocus = createEvent(this, "scFocus", 7);
17976 this.scBlur = createEvent(this, "scBlur", 7);
17977 this.inputId = `phone-input-${++id}`;
17978 this.helpId = `phone-input-help-text-${id}`;
17979 this.labelId = `phone-input-label-${id}`;
17980 this.squared = undefined;
17981 this.squaredBottom = undefined;
17982 this.squaredTop = undefined;
17983 this.squaredLeft = undefined;
17984 this.squaredRight = undefined;
17985 this.hidden = false;
17986 this.size = 'medium';
17987 this.name = undefined;
17988 this.value = '';
17989 this.pill = false;
17990 this.label = undefined;
17991 this.showLabel = true;
17992 this.help = '';
17993 this.clearable = false;
17994 this.togglePassword = false;
17995 this.placeholder = undefined;
17996 this.disabled = false;
17997 this.readonly = false;
17998 this.minlength = undefined;
17999 this.maxlength = undefined;
18000 this.min = undefined;
18001 this.max = undefined;
18002 this.step = undefined;
18003 this.pattern = '[-s#0-9_+/().]*';
18004 this.required = false;
18005 this.invalid = false;
18006 this.autocorrect = undefined;
18007 this.autocomplete = undefined;
18008 this.autofocus = undefined;
18009 this.spellcheck = undefined;
18010 this.hasFocus = undefined;
18011 }
18012 async reportValidity() {
18013 return this.input.reportValidity();
18014 }
18015 /** Sets focus on the input. */
18016 async triggerFocus(options) {
18017 return this.input.focus(options);
18018 }
18019 /** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */
18020 async setCustomValidity(message) {
18021 this.input.setCustomValidity(message);
18022 this.invalid = !this.input.checkValidity();
18023 }
18024 /** Removes focus from the input. */
18025 async triggerBlur() {
18026 return this.input.blur();
18027 }
18028 /** Selects all the text in the input. */
18029 select() {
18030 return this.input.select();
18031 }
18032 handleBlur() {
18033 this.hasFocus = false;
18034 this.scBlur.emit();
18035 }
18036 handleFocus() {
18037 this.hasFocus = true;
18038 this.scFocus.emit();
18039 }
18040 handleChange() {
18041 this.value = this.input.value;
18042 this.scChange.emit();
18043 }
18044 handleInput() {
18045 this.value = this.input.value.replace(/\s/g, '');
18046 this.input.value = this.value;
18047 this.scInput.emit();
18048 }
18049 handleClearClick(event) {
18050 this.value = '';
18051 this.scClear.emit();
18052 this.scInput.emit();
18053 this.scChange.emit();
18054 this.input.focus();
18055 event.stopPropagation();
18056 }
18057 handleFocusChange() {
18058 setTimeout(() => {
18059 this.hasFocus && this.input ? this.input.focus() : this.input.blur();
18060 }, 0);
18061 }
18062 handleValueChange() {
18063 if (this.input) {
18064 this.invalid = !this.input.checkValidity();
18065 }
18066 }
18067 componentDidLoad() {
18068 this.formController = new FormSubmitController(this.el).addFormData();
18069 this.handleFocusChange();
18070 }
18071 disconnectedCallback() {
18072 var _a;
18073 (_a = this.formController) === null || _a === void 0 ? void 0 : _a.removeFormData();
18074 }
18075 render() {
18076 var _a;
18077 return (h(Host, { key: 'ee181e5674d4af8704aa44ad8df596f9c9401fe6', hidden: this.hidden }, h("sc-form-control", { key: '23d9a4ed3ab3b884e34ca96f1fa781e17dd85847', exportparts: "label, help-text, form-control", size: this.size, required: this.required, label: this.label, showLabel: this.showLabel, help: this.help, inputId: this.inputId, helpId: this.helpId, labelId: this.labelId, name: this.name, "aria-label": this.label }, h("slot", { key: '5a8f53c96d843e11188ee0de228b40874a715883', name: "label-end", slot: "label-end" }), h("div", { key: '2b7796abfbf2f80a58414d9e243c18f85900210d', part: "base", class: {
18078 'input': true,
18079 // Sizes
18080 'input--small': this.size === 'small',
18081 'input--medium': this.size === 'medium',
18082 'input--large': this.size === 'large',
18083 // States
18084 'input--focused': this.hasFocus,
18085 'input--invalid': this.invalid,
18086 'input--disabled': this.disabled,
18087 'input--squared': this.squared,
18088 'input--squared-bottom': this.squaredBottom,
18089 'input--squared-top': this.squaredTop,
18090 'input--squared-left': this.squaredLeft,
18091 'input--squared-right': this.squaredRight,
18092 } }, h("span", { key: '1bcbdfadb96b1e038dfdbdcd1615a04a08e08633', part: "prefix", class: "input__prefix" }, h("slot", { key: 'ea0fb2abef291e46bff35cb0d684fa384023c02d', name: "prefix" })), h("slot", { key: 'f29984bd7bbf496ed9902ac70c3185059b2857f7' }, h("input", { key: '96bfd1235b8c5adf33c5285228e79ef01cd37e16', part: "input", id: this.inputId, class: "input__control", ref: el => (this.input = el), type: "tel", name: this.name, disabled: this.disabled, readonly: this.readonly, required: this.required, placeholder: this.placeholder, minlength: this.minlength, maxlength: this.maxlength, min: this.min, max: this.max, step: this.step,
18093 // TODO: Test These below
18094 autocomplete: 'tel', autocorrect: this.autocorrect, autofocus: this.autofocus, spellcheck: this.spellcheck, pattern: applyFilters('surecart/sc-phone-input/pattern', this.pattern), inputmode: 'numeric', "aria-label": this.label, "aria-labelledby": this.label, "aria-invalid": this.invalid ? true : false, value: this.value, onChange: () => this.handleChange(), onInput: () => this.handleInput(), onFocus: () => this.handleFocus(), onBlur: () => this.handleBlur() })), h("span", { key: 'c8d1a6811bb4572fbdd427a13a3523be9359cbfb', part: "suffix", class: "input__suffix" }, h("slot", { key: '66d398512676426b076f004b8eda694d9f704201', name: "suffix" })), this.clearable && ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) > 0 && (h("button", { key: 'b515a09cdcc0b666c23d05ac43ae3820928826c2', part: "clear-button", class: "input__clear", type: "button", onClick: e => this.handleClearClick(e), tabindex: "-1" }, h("slot", { key: 'f88f92ef50b60e67a40a1c8ff24ed395187dbed3', name: "clear-icon" }, h("svg", { key: '3b15d9b37d3e5ab89a10e535c775bffcb762bec1', xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "feather feather-x" }, h("line", { key: '2e0405784350f8eb76b02b2f05d05d4d92e3e97a', x1: "18", y1: "6", x2: "6", y2: "18" }), h("line", { key: '2db415644f456ee94b40ef87faefa98e289db4b3', x1: "6", y1: "6", x2: "18", y2: "18" })))))))));
18095 }
18096 get el() { return getElement(this); }
18097 static get watchers() { return {
18098 "hasFocus": ["handleFocusChange"],
18099 "value": ["handleValueChange"]
18100 }; }
18101 };
18102 ScPhoneInput.style = ScPhoneInputStyle0;
18103
18104 const scTaxIdInputCss = ":host{display:block;z-index:3;position:relative}";
18105 const ScTaxIdInputStyle0 = scTaxIdInputCss;
18106
18107 const ScTaxIdInput = class {
18108 constructor(hostRef) {
18109 registerInstance(this, hostRef);
18110 this.scChange = createEvent(this, "scChange", 7);
18111 this.scInput = createEvent(this, "scInput", 7);
18112 this.scInputType = createEvent(this, "scInputType", 7);
18113 this.scSetState = createEvent(this, "scSetState", 7);
18114 this.country = undefined;
18115 this.show = false;
18116 this.type = 'other';
18117 this.number = null;
18118 this.status = 'unknown';
18119 this.loading = undefined;
18120 this.help = undefined;
18121 this.otherLabel = wp.i18n.__('Tax ID', 'surecart');
18122 this.caGstLabel = wp.i18n.__('GST Number', 'surecart');
18123 this.auAbnLabel = wp.i18n.__('ABN Number', 'surecart');
18124 this.gbVatLabel = wp.i18n.__('UK VAT', 'surecart');
18125 this.euVatLabel = wp.i18n.__('EU VAT', 'surecart');
18126 this.taxIdTypes = [];
18127 this.required = false;
18128 }
18129 async reportValidity() {
18130 return this.input.reportValidity();
18131 }
18132 onLabelChange() {
18133 zones.ca_gst.label = this.caGstLabel || zones.ca_gst.label;
18134 zones.au_abn.label = this.auAbnLabel || zones.au_abn.label;
18135 zones.gb_vat.label = this.gbVatLabel || zones.gb_vat.label;
18136 zones.eu_vat.label = this.euVatLabel || zones.eu_vat.label;
18137 zones.other.label = this.otherLabel || zones.other.label;
18138 }
18139 componentWillLoad() {
18140 this.onLabelChange();
18141 }
18142 renderStatus() {
18143 if (this.status === 'valid') {
18144 return h("sc-icon", { name: "check", slot: "prefix", style: { color: 'var(--sc-color-success-500)' } });
18145 }
18146 if (this.status === 'invalid') {
18147 return h("sc-icon", { name: "x", slot: "prefix", style: { color: 'var(--sc-color-danger-500)' } });
18148 }
18149 }
18150 filteredZones() {
18151 if (!!this.taxIdTypes.length) {
18152 return Object.keys(zones)
18153 .filter(name => this.taxIdTypes.includes(name))
18154 .reduce((obj, key) => {
18155 obj[key] = zones[key];
18156 return obj;
18157 }, {});
18158 }
18159 return zones;
18160 }
18161 onTaxIdTypesChange() {
18162 // If there is no other type, set the first one as default type.
18163 if (!!this.taxIdTypes.length) {
18164 this.type = !this.taxIdTypes.includes('other') ? this.taxIdTypes[0] : 'other';
18165 }
18166 }
18167 getZoneLabel() {
18168 var _a, _b;
18169 const filteredZones = this.filteredZones() || {};
18170 // Get the label of the current type or the other type.
18171 // If there is no other type, get the first one.
18172 return ((_a = filteredZones === null || filteredZones === void 0 ? void 0 : filteredZones[(this === null || this === void 0 ? void 0 : this.type) || 'other']) === null || _a === void 0 ? void 0 : _a.label) || ((_b = filteredZones === null || filteredZones === void 0 ? void 0 : filteredZones[Object.keys(filteredZones)[0]]) === null || _b === void 0 ? void 0 : _b.label);
18173 }
18174 render() {
18175 var _a, _b, _c, _d, _e;
18176 return (h(Fragment, { key: '9420f8158a6ede3cd3b264ffc75d427479bb4e46' }, h("sc-input", { key: 'dab5b64c9c2c75e52f15dabe1cae04dcee7925a6', name: "tax_identifier.number_type", required: this.required, value: this.type, style: { display: 'none' } }), h("sc-input", { key: '94f37db2d89d991458d8f0e83a005ad69bb02e56', ref: el => (this.input = el), label: this.getZoneLabel(), "aria-label": wp.i18n.__('Tax ID', 'surecart'), placeholder: wp.i18n.__('Enter Tax ID', 'surecart'), name: "tax_identifier.number", value: this.number, onScInput: (e) => {
18177 e.stopImmediatePropagation();
18178 this.scInput.emit({
18179 number: e.target.value,
18180 number_type: this.type || 'other',
18181 });
18182 }, onScChange: (e) => {
18183 e.stopImmediatePropagation();
18184 this.scChange.emit({
18185 number: e.target.value,
18186 number_type: this.type || 'other',
18187 });
18188 }, help: this.help, required: this.required }, this.loading && this.type === 'eu_vat' ? h("sc-spinner", { slot: "prefix", style: { '--spinner-size': '10px' } }) : this.renderStatus(), ((_a = Object.keys(this.filteredZones() || {})) === null || _a === void 0 ? void 0 : _a.length) === 1 ? (h("span", { slot: "suffix" }, (_c = (_b = Object.values(this.filteredZones() || {})) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c['label_small'])) : (h("sc-dropdown", { slot: "suffix", position: "bottom-right", role: "select", "aria-multiselectable": "false", "aria-label": wp.i18n.__('Select number type', 'surecart') }, h("sc-button", { type: "text", slot: "trigger", caret: true, loading: false, style: { color: 'var(--sc-input-label-color)' }, tabindex: "0" }, (_e = (_d = this.filteredZones()) === null || _d === void 0 ? void 0 : _d[(this === null || this === void 0 ? void 0 : this.type) || 'other']) === null || _e === void 0 ? void 0 : _e.label_small), h("sc-menu", null, Object.keys(this.filteredZones() || {}).map(name => (h("sc-menu-item", { role: "option", onClick: () => {
18189 this.scInput.emit({
18190 number: this.number,
18191 number_type: name,
18192 });
18193 this.scChange.emit({
18194 number: this.number,
18195 number_type: name,
18196 });
18197 this.type = name;
18198 }, onKeyDown: e => {
18199 var _a;
18200 if (e.key === 'Enter') {
18201 this.scInput.emit({
18202 number: this.number,
18203 number_type: name,
18204 });
18205 this.scChange.emit({
18206 number: this.number,
18207 number_type: name,
18208 });
18209 this.type = name;
18210 (_a = this.input) === null || _a === void 0 ? void 0 : _a.triggerFocus();
18211 speak(wp.i18n.sprintf(wp.i18n.__('%s selected', 'surecart'), zones[name].label_small, 'assertive'));
18212 }
18213 }, checked: this.type === name, "aria-selected": this.type === name ? 'true' : 'false', "aria-label": zones[name].label_small }, zones[name].label_small)))))))));
18214 }
18215 static get watchers() { return {
18216 "otherLabel": ["onLabelChange"],
18217 "caGstLabel": ["onLabelChange"],
18218 "auAbnLabel": ["onLabelChange"],
18219 "gbVatLabel": ["onLabelChange"],
18220 "euVatLabel": ["onLabelChange"],
18221 "taxIdTypes": ["onTaxIdTypesChange"]
18222 }; }
18223 };
18224 ScTaxIdInput.style = ScTaxIdInputStyle0;
18225
18226 export { ScAddress as sc_address, ScAddressSuggestions as sc_address_suggestions, ScCheckbox as sc_checkbox, ScPhoneInput as sc_phone_input, ScTaxIdInput as sc_tax_id_input };
18227
18228 //# sourceMappingURL=sc-address_5.entry.js.map