This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,172 @@
// Metro module 6220 (f6221).
import Record from "../../../lib/Record";
import add from "../../../_bundle/add_5671";
import { formatPrice } from "../../../utils/PriceUtils";
import { $callWithNewTarget } from "../../../_hermes/prelude";
class AvailablePlanRecord extends Record {
constructor(a0) {
super();
this.id = a0.id;
this.quantity = a0.quantity;
this.price = a0.price;
this.total = a0.total;
let addOnPlans = a0.addOnPlans;
if (addOnPlans == null) {
addOnPlans = [];
}
this.addOnPlans = addOnPlans;
}
static createFromServer(a0) {
const { id, quantity, price, total } = a0;
let add_on_plans = a0.add_on_plans;
if (add_on_plans == null) {
add_on_plans = [];
}
const prototypeOf = Object.getPrototypeOf(AvailablePlanRecord);
const r15 = Object.create(AvailablePlanRecord.prototype);
const r16 = $callWithNewTarget(prototypeOf, r15, AvailablePlanRecord);
const r17 = r16 instanceof Object ? r16 : r15;
r17.id = id;
r17.quantity = quantity;
r17.price = price;
r17.total = total;
if (add_on_plans == null) {
add_on_plans = [];
}
r17.addOnPlans = add_on_plans;
return r17;
}
getPlanQuantities() {
const map = new Map([[this.id, this.quantity]]);
for (const addOnPlan of this.addOnPlans) {
const r34 = addOnPlan;
const id = addOnPlan.id;
let r37 = map.get(addOnPlan.id);
if (r37 == null) {
r37 = 0;
}
map.set(id, r37 + r34.quantity);
}
return map;
}
matchesItems(a0) {
return (function quantitiesEqual(a0, a1) {
if (a0.size !== a1.size) {
return false;
}
for (const item of a0) {
const [r8, r28] = item;
if (a1.get(r8) === r28) {
continue;
}
return false;
}
return true;
})(this.getPlanQuantities(), (function toQuantitiesByPlanId(a0) {
const map = new Map();
for (const item of a0) {
const { planId, quantity } = item;
let r10 = map.get(planId);
if (r10 == null) {
r10 = 0;
}
map.set(planId, r10 + quantity);
}
return map;
})(a0));
}
getPriceString() {
const total = this.total;
return formatPrice(new add(total.amount).dividedBy(10 ** total.exponent).toNumber(), total.currency, {
convertToMajorUnits: false
});
}
getAddOnPrice() {
if (this.addOnPlans.length === 0) {
return null;
}
const price = this.addOnPlans[0].price;
const { currency, exponent } = price;
return {
majorUnits: new add(this.addOnPlans.reduce((acc, addOnPlan) => acc + addOnPlan.price.amount * addOnPlan.quantity, 0)).dividedBy(10 ** exponent).toNumber(),
currency
};
}
}
class CheckoutContextRecord extends Record {
constructor(a0) {
super();
let paymentSources = a0.paymentSources;
if (paymentSources == null) {
paymentSources = [];
}
this.paymentSources = paymentSources;
let storeCountry = a0.storeCountry;
if (storeCountry == null) {
storeCountry = null;
}
this.storeCountry = storeCountry;
let allowedCurrencies = a0.allowedCurrencies;
if (allowedCurrencies == null) {
allowedCurrencies = [];
}
this.allowedCurrencies = allowedCurrencies;
let availablePlans = a0.availablePlans;
if (availablePlans == null) {
availablePlans = [];
}
this.availablePlans = availablePlans;
}
static createFromOrder(a0) {
const checkout_context = a0?.checkout_context;
const r13 = checkout_context == null;
let r14 = null;
if (!r13) {
let payment_sources = checkout_context.payment_sources;
if (payment_sources == null) {
payment_sources = [];
}
let storeCountry = checkout_context.store_country != null ? checkout_context.store_country.country : null;
let allowed_currencies = checkout_context.allowed_currencies;
if (allowed_currencies == null) {
allowed_currencies = [];
}
let available_plans = checkout_context.available_plans;
if (available_plans == null) {
available_plans = [];
}
let availablePlans = available_plans.map(AvailablePlanRecord.createFromServer);
const prototypeOf = Object.getPrototypeOf(CheckoutContextRecord);
const r25 = Object.create(CheckoutContextRecord.prototype);
const r26 = $callWithNewTarget(prototypeOf, r25, CheckoutContextRecord);
if (payment_sources == null) {
payment_sources = [];
}
const r28 = r26 instanceof Object ? r26 : r25;
r28.paymentSources = payment_sources;
if (storeCountry == null) {
storeCountry = null;
}
r28.storeCountry = storeCountry;
if (allowed_currencies == null) {
allowed_currencies = [];
}
r28.allowedCurrencies = allowed_currencies;
if (availablePlans == null) {
availablePlans = [];
}
r28.availablePlans = availablePlans;
r14 = r28;
}
return r14;
}
getAvailablePlanForItems(c15593_0) {
let r7 = this.availablePlans.find((availablePlan) => availablePlan.matchesItems(c15593_0));
if (r7 == null) {
r7 = null;
}
return r7;
}
}
export default CheckoutContextRecord;
export { AvailablePlanRecord };
+136
View File
@@ -0,0 +1,136 @@
// Metro module 6219 (f6220).
import Record from "../../../lib/Record";
import { BaseInvoiceRecord } from "../../../records/InvoiceRecord";
import CheckoutContextRecord from "./CheckoutContextRecord";
import SubscriptionFacetRecord from "./SubscriptionFacetRecord";
import { $callWithNewTarget } from "../../../_hermes/prelude";
class BillingFacetRecord extends Record {
constructor(a0) {
super();
this.paymentGateway = a0.paymentGateway;
let paymentSourceId = a0.paymentSourceId;
if (paymentSourceId == null) {
paymentSourceId = null;
}
this.paymentSourceId = paymentSourceId;
let invoicePreview = a0.invoicePreview;
if (invoicePreview == null) {
invoicePreview = null;
}
this.invoicePreview = invoicePreview;
}
static createFromOrder(a0) {
const billing_facet = a0.billing_facet;
const r1 = billing_facet == null;
let r2 = null;
if (!r1) {
const payment_gateway = billing_facet.payment_gateway;
let payment_source_id = billing_facet.payment_source_id;
if (payment_source_id == null) {
payment_source_id = null;
}
let invoicePreview = BaseInvoiceRecord.createInvoiceFromOrder(a0);
const prototypeOf = Object.getPrototypeOf(BillingFacetRecord);
const r18 = Object.create(BillingFacetRecord.prototype);
const r19 = $callWithNewTarget(prototypeOf, r18, BillingFacetRecord);
const r20 = r19 instanceof Object ? r19 : r18;
r20.paymentGateway = payment_gateway;
if (payment_source_id == null) {
payment_source_id = null;
}
r20.paymentSourceId = payment_source_id;
if (invoicePreview == null) {
invoicePreview = null;
}
r20.invoicePreview = invoicePreview;
r2 = r20;
}
return r2;
}
}
class OrderRecord extends Record {
constructor(a0) {
super();
this.id = a0.id;
this.status = a0.status;
this.revision = a0.revision;
let orderLineItems = a0.orderLineItems;
if (orderLineItems == null) {
orderLineItems = [];
}
this.orderLineItems = orderLineItems;
let billingFacetRecord = a0.billingFacetRecord;
if (billingFacetRecord == null) {
billingFacetRecord = null;
}
this.billingFacetRecord = billingFacetRecord;
let externalGatewayFacet = a0.externalGatewayFacet;
if (externalGatewayFacet == null) {
externalGatewayFacet = null;
}
this.externalGatewayFacet = externalGatewayFacet;
let giftingFacet = a0.giftingFacet;
if (giftingFacet == null) {
giftingFacet = null;
}
this.giftingFacet = giftingFacet;
let subscriptionFacet = a0.subscriptionFacet;
if (subscriptionFacet == null) {
subscriptionFacet = null;
}
this.subscriptionFacet = subscriptionFacet;
let checkoutContextRecord = a0.checkoutContextRecord;
if (checkoutContextRecord == null) {
checkoutContextRecord = null;
}
this.checkoutContextRecord = checkoutContextRecord;
this.createdAt = a0.createdAt;
let unsatisfiedConstraints = a0.unsatisfiedConstraints;
if (unsatisfiedConstraints == null) {
unsatisfiedConstraints = [];
}
this.unsatisfiedConstraints = unsatisfiedConstraints;
}
static createFromServer(a0) {
const r1 = {
id: a0.id,
status: a0.status,
revision: a0.revision,
orderLineItems: a0.order_line_items,
billingFacetRecord: BillingFacetRecord.createFromOrder(a0),
externalGatewayFacet: null,
giftingFacet: null,
checkoutContextRecord: null,
createdAt: null,
unsatisfiedConstraints: null,
subscriptionFacet: null
};
let external_gateway_facet = a0.external_gateway_facet;
if (external_gateway_facet == null) {
external_gateway_facet = null;
}
r1.externalGatewayFacet = external_gateway_facet;
let gifting_facet = a0.gifting_facet;
if (gifting_facet == null) {
gifting_facet = null;
}
r1.giftingFacet = gifting_facet;
r1.checkoutContextRecord = CheckoutContextRecord.createFromOrder(a0);
r1.createdAt = a0.created_at;
let unsatisfied_constraints = a0.unsatisfied_constraints;
if (unsatisfied_constraints == null) {
unsatisfied_constraints = [];
}
r1.unsatisfiedConstraints = unsatisfied_constraints;
r1.subscriptionFacet = SubscriptionFacetRecord.createFromServer(a0.subscription_facet);
return new OrderRecord(r1);
}
getInvoicePreview() {
return this.billingFacetRecord != null ? this.billingFacetRecord.invoicePreview : null;
}
firstUnsatisfiedConstraintReasonCode() {
return this.unsatisfiedConstraints.length > 0 ? this.unsatisfiedConstraints[0].reason_code : null;
}
}
export default OrderRecord;
export { BillingFacetRecord };
@@ -0,0 +1,106 @@
// Metro module 6221 (f6222).
import Record from "../../../lib/Record";
import { $callWithNewTarget } from "../../../_hermes/prelude";
class SubscriptionFacetRecord extends Record {
constructor(a0) {
super();
let subscriptionId = a0.subscriptionId;
if (subscriptionId == null) {
subscriptionId = null;
}
this.subscriptionId = subscriptionId;
let subscriptionPreview = a0.subscriptionPreview;
if (subscriptionPreview == null) {
subscriptionPreview = null;
}
this.subscriptionPreview = subscriptionPreview;
let updateType = a0.updateType;
if (updateType == null) {
updateType = null;
}
this.updateType = updateType;
let resetBillingCycle = a0.resetBillingCycle;
if (resetBillingCycle == null) {
resetBillingCycle = false;
}
this.resetBillingCycle = resetBillingCycle;
}
static createFromServer(a0) {
const r1 = a0 == null;
let r2 = null;
if (!r1) {
let subscription_id = a0.subscription_id;
if (subscription_id == null) {
subscription_id = null;
}
const subscription_preview = a0.subscription_preview;
const r17 = subscription_preview == null;
let subscriptionPreview = null;
if (!r17) {
let subscription_trial_id = subscription_preview.subscription_trial_id;
if (subscription_trial_id == null) {
subscription_trial_id = null;
}
const renewal_info = subscription_preview.renewal_info;
const r20 = renewal_info == null;
let renewalInfo = null;
if (!r20) {
let renewal_line_items = renewal_info.renewal_line_items;
if (renewal_line_items == null) {
renewal_line_items = [];
}
renewalInfo = {
price: renewal_info.price,
currency: renewal_info.currency,
renewalLineItems: renewal_line_items.map((renewal_line_item) => ({
refOrderLineItemId: renewal_line_item.ref_order_line_item_id,
price: renewal_line_item.price
}))
};
}
let subscription_type = subscription_preview.subscription_type;
if (subscription_type == null) {
subscription_type = null;
}
subscriptionPreview = {
currency: subscription_preview.currency,
countryCode: subscription_preview.country_code,
subscriptionTrialId: subscription_trial_id,
renewalInfo,
subscriptionType: subscription_type
};
}
let update_type = a0.update_type;
if (update_type == null) {
update_type = null;
}
let reset_billing_cycle = a0.reset_billing_cycle;
if (reset_billing_cycle == null) {
reset_billing_cycle = false;
}
const prototypeOf = Object.getPrototypeOf(SubscriptionFacetRecord);
const r34 = Object.create(SubscriptionFacetRecord.prototype);
const r35 = $callWithNewTarget(prototypeOf, r34, SubscriptionFacetRecord);
if (subscription_id == null) {
subscription_id = null;
}
const r37 = r35 instanceof Object ? r35 : r34;
r37.subscriptionId = subscription_id;
if (subscriptionPreview == null) {
subscriptionPreview = null;
}
r37.subscriptionPreview = subscriptionPreview;
if (update_type == null) {
update_type = null;
}
r37.updateType = update_type;
if (reset_billing_cycle == null) {
reset_billing_cycle = false;
}
r37.resetBillingCycle = reset_billing_cycle;
r2 = r37;
}
return r2;
}
}
export default SubscriptionFacetRecord;