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,103 @@
// Metro module 6214 (f6215).
import Record from "../../../lib/Record";
import * as _PremiumConstants from "../../premium/PremiumConstants";
import { $callWithNewTarget } from "../../../_hermes/prelude";
const { SubscriptionIntervalTypes, DiscountUserUsageLimitIntervalTypes } = _PremiumConstants;
const r20 = {};
r20[DiscountUserUsageLimitIntervalTypes.DAY] = SubscriptionIntervalTypes.DAY;
r20[DiscountUserUsageLimitIntervalTypes.WEEK] = SubscriptionIntervalTypes.DAY;
r20[DiscountUserUsageLimitIntervalTypes.MONTH] = SubscriptionIntervalTypes.MONTH;
r20[DiscountUserUsageLimitIntervalTypes.YEAR] = SubscriptionIntervalTypes.YEAR;
let c3942_0 = r20;
class UserDiscountOfferRecord extends Record {
constructor(a0) {
super();
this.id = a0.id;
this.discountId = a0.discountId;
this.discount = a0.discount;
this.userId = a0.userId;
let appliedAt = a0.appliedAt;
if (appliedAt == null) {
appliedAt = null;
}
this.appliedAt = appliedAt;
let deletedAt = a0.deletedAt;
if (deletedAt == null) {
deletedAt = null;
}
this.deletedAt = deletedAt;
let expiresAt = a0.expiresAt;
if (expiresAt == null) {
expiresAt = null;
}
this.expiresAt = expiresAt;
}
static createFromServer(a0) {
const { id, discount_id } = a0;
const discount = {
id: a0.discount.id,
planIds: a0.discount.plan_ids,
userUsageLimitInterval: a0.discount.user_usage_limit_interval,
userUsageLimitIntervalCount: a0.discount.user_usage_limit_interval_count,
userUsageLimit: a0.discount.user_usage_limit,
amount: a0.discount.amount
};
const user_id = a0.user_id;
let appliedAt = a0.applied_at != null ? new Date(a0.applied_at) : null;
let deletedAt = a0.deleted_at != null ? new Date(a0.deleted_at) : null;
let expiresAt = a0.expires_at != null ? new Date(a0.expires_at) : null;
const prototypeOf = Object.getPrototypeOf(UserDiscountOfferRecord);
const r52 = Object.create(UserDiscountOfferRecord.prototype);
const r54 = $callWithNewTarget(prototypeOf, r52, UserDiscountOfferRecord);
const r55 = r54 instanceof Object ? r54 : r52;
r55.id = id;
r55.discountId = discount_id;
r55.discount = discount;
r55.userId = user_id;
if (appliedAt == null) {
appliedAt = null;
}
r55.appliedAt = appliedAt;
if (deletedAt == null) {
deletedAt = null;
}
r55.deletedAt = deletedAt;
if (expiresAt == null) {
expiresAt = null;
}
r55.expiresAt = expiresAt;
return r55;
}
hasExpired() {
return this.expiresAt != null && Date.now() > this.expiresAt.getTime();
}
isApplied() {
return this.appliedAt != null;
}
isDeleted() {
return this.deletedAt != null;
}
hasAcknowledged() {
return this.expiresAt != null;
}
getFullIntervalCount() {
return this.discount == null ? 0 : this.discount.userUsageLimit;
}
getDiscountInterval() {
return this.discount.userUsageLimitInterval;
}
getApplicableSubscriptionInterval() {
return c3942_0[this.getDiscountInterval()];
}
getIsMultiIntervalDiscount() {
return this.getFullIntervalCount() > 1;
}
getApproximateDiscountAmountOff(a0) {
if (this.discount?.amount == null) {
return null;
}
const r9 = parseFloat(this.discount.amount);
return Number.isNaN(r9) ? null : Math.round(a0 * (1 - r9 / 100));
}
}
export default UserDiscountOfferRecord;