// Metro module 3838 (f3839). import PaymentSourceRecord from "../../records/PaymentSourceRecord"; import Module589 from "../../_bundle/Module589"; import Dispatcher from "../../Dispatcher"; let c2172_1, id, c2172_3; const handlePaymentSourceUpdate = function handlePaymentSourceUpdate({ paymentSource }) { const r4 = { ...c2172_1 }; r4[paymentSource.id] = paymentSource; c2172_1 = r4; if (paymentSource.isDefault || Object.keys(c2172_1).length === 1) { id = paymentSource.id; } }; c2172_1 = {}; id = null; c2172_3 = false; class PaymentSourceStore extends Module589.Store { static displayName = "PaymentSourceStore"; get paymentSources() { return c2172_1; } get paymentSourceIds() { return Object.keys(c2172_1); } get defaultPaymentSourceId() { return id; } get defaultPaymentSource() { return id != null ? c2172_1[id] : null; } get hasFetchedPaymentSources() { return c2172_3; } getDefaultBillingCountryCode() { const defaultPaymentSource2 = this.defaultPaymentSource; return defaultPaymentSource2 != null ? defaultPaymentSource2.paymentMethodCountry : null; } getPaymentSource(a0) { return c2172_1[a0]; } } const paymentSourceStore = new PaymentSourceStore(Dispatcher, { BILLING_PAYMENT_SOURCE_CREATE_SUCCESS: handlePaymentSourceUpdate, BILLING_PAYMENT_SOURCE_UPDATE_SUCCESS: handlePaymentSourceUpdate, BILLING_PAYMENT_SOURCE_FETCH_SUCCESS: handlePaymentSourceUpdate, BILLING_PAYMENT_SOURCES_FETCH_SUCCESS: function handlePaymentSourceFetch({ paymentSources: paymentSources2 }) { c2172_1 = {}; id = null; for (const item of paymentSources2) { c2172_1[item.id] = PaymentSourceRecord.createFromServer(item); if (item.default) { id = item.id; } } if (id == null && paymentSources2.length > 0) { id = paymentSources2[0].id; } c2172_3 = true; }, BILLING_PAYMENT_SOURCE_REMOVE_SUCCESS: function handlePaymentSourceRemove({ id: id2 }) { const r8 = { ...c2172_1 }; c2172_1 = r8; delete r8[id2]; if (id === id2) { const r14 = Object.keys(c2172_1); id = r14.length !== 0 ? r14[0] : null; } }, LOGOUT: function handleLogout() { c2172_1 = {}; id = null; c2172_3 = false; } }); export default paymentSourceStore;