@schematichq/schematic-components 2.11.0 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/schematic-components.cjs.js +219 -60
- package/dist/schematic-components.d.ts +102 -0
- package/dist/schematic-components.esm.js +219 -60
- package/package.json +6 -6
|
@@ -5094,6 +5094,7 @@ var en_default = {
|
|
|
5094
5094
|
Loading: "Loading",
|
|
5095
5095
|
"Manage plan": "Manage plan",
|
|
5096
5096
|
"Monthly total": "Monthly total",
|
|
5097
|
+
"Quarterly total": "Quarterly total",
|
|
5097
5098
|
Next: "Next",
|
|
5098
5099
|
"No invoices created yet": "No invoices created yet",
|
|
5099
5100
|
"No limit": "No limit",
|
|
@@ -5126,6 +5127,8 @@ var en_default = {
|
|
|
5126
5127
|
"Save payment method": "Save payment method",
|
|
5127
5128
|
"Save with yearly billing": "Save up to {{percent}}% with yearly billing",
|
|
5128
5129
|
"Saving with yearly billing": "You are saving {{percent}}% with yearly billing",
|
|
5130
|
+
"Save with quarterly billing": "Save up to {{percent}}% with quarterly billing",
|
|
5131
|
+
"Saving with quarterly billing": "You are saving {{percent}}% with quarterly billing",
|
|
5129
5132
|
"See all": "See all",
|
|
5130
5133
|
"See balance details": "See balance details",
|
|
5131
5134
|
"See less": "See less",
|
|
@@ -5199,6 +5202,7 @@ var en_default = {
|
|
|
5199
5202
|
"$X/Y units/period": "{{cost}}/{{size}} {{units}}/{{period}}",
|
|
5200
5203
|
day: "day",
|
|
5201
5204
|
month: "month",
|
|
5205
|
+
quarter: "quarter",
|
|
5202
5206
|
year: "year",
|
|
5203
5207
|
"one time": "one time",
|
|
5204
5208
|
"billing period": "billing period",
|
|
@@ -5207,6 +5211,7 @@ var en_default = {
|
|
|
5207
5211
|
use: "use",
|
|
5208
5212
|
used: "used",
|
|
5209
5213
|
"month, billed yearly": "month, billed yearly",
|
|
5214
|
+
"month, billed quarterly": "month, billed quarterly",
|
|
5210
5215
|
purchased: "purchased {{date}}",
|
|
5211
5216
|
usage: {
|
|
5212
5217
|
limited: "{{amount}} of {{allocation}} used",
|
|
@@ -7937,6 +7942,7 @@ function BillingProductPriceResponseDataFromJSONTyped(json, ignoreDiscriminator)
|
|
|
7937
7942
|
currency: json["currency"],
|
|
7938
7943
|
id: json["id"],
|
|
7939
7944
|
interval: BillingProductPriceIntervalFromJSON(json["interval"]),
|
|
7945
|
+
intervalCount: json["interval_count"],
|
|
7940
7946
|
isActive: json["is_active"],
|
|
7941
7947
|
meterId: json["meter_id"] == null ? void 0 : json["meter_id"],
|
|
7942
7948
|
nickname: json["nickname"] == null ? void 0 : json["nickname"],
|
|
@@ -7982,6 +7988,7 @@ function BillingPriceViewFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
7982
7988
|
currency: json["currency"],
|
|
7983
7989
|
id: json["id"],
|
|
7984
7990
|
interval: BillingProductPriceIntervalFromJSON(json["interval"]),
|
|
7991
|
+
intervalCount: json["interval_count"],
|
|
7985
7992
|
isActive: json["is_active"],
|
|
7986
7993
|
meterEventName: json["meter_event_name"] == null ? void 0 : json["meter_event_name"],
|
|
7987
7994
|
meterEventPayloadKey: json["meter_event_payload_key"] == null ? void 0 : json["meter_event_payload_key"],
|
|
@@ -8105,6 +8112,7 @@ function BillingPriceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8105
8112
|
externalPriceId: json["external_price_id"],
|
|
8106
8113
|
id: json["id"],
|
|
8107
8114
|
interval: BillingProductPriceIntervalFromJSON(json["interval"]),
|
|
8115
|
+
intervalCount: json["interval_count"],
|
|
8108
8116
|
nickname: json["nickname"] == null ? void 0 : json["nickname"],
|
|
8109
8117
|
price: json["price"],
|
|
8110
8118
|
priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
|
|
@@ -8393,6 +8401,7 @@ function BillingProductForSubscriptionResponseDataFromJSONTyped(json, ignoreDisc
|
|
|
8393
8401
|
externalId: json["external_id"],
|
|
8394
8402
|
id: json["id"],
|
|
8395
8403
|
interval: json["interval"],
|
|
8404
|
+
intervalCount: json["interval_count"] == null ? void 0 : json["interval_count"],
|
|
8396
8405
|
meterId: json["meter_id"] == null ? void 0 : json["meter_id"],
|
|
8397
8406
|
name: json["name"],
|
|
8398
8407
|
packageSize: json["package_size"],
|
|
@@ -9383,6 +9392,7 @@ function EntitlementCurrencyPricesResponseDataFromJSONTyped(json, ignoreDiscrimi
|
|
|
9383
9392
|
return {
|
|
9384
9393
|
currency: json["currency"],
|
|
9385
9394
|
monthlyPrice: json["monthly_price"] == null ? void 0 : BillingPriceViewFromJSON(json["monthly_price"]),
|
|
9395
|
+
quarterlyPrice: json["quarterly_price"] == null ? void 0 : BillingPriceViewFromJSON(json["quarterly_price"]),
|
|
9386
9396
|
yearlyPrice: json["yearly_price"] == null ? void 0 : BillingPriceViewFromJSON(json["yearly_price"])
|
|
9387
9397
|
};
|
|
9388
9398
|
}
|
|
@@ -9463,6 +9473,7 @@ function PlanEntitlementResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
9463
9473
|
featureId: json["feature_id"],
|
|
9464
9474
|
id: json["id"],
|
|
9465
9475
|
meteredMonthlyPrice: json["metered_monthly_price"] == null ? void 0 : BillingPriceViewFromJSON(json["metered_monthly_price"]),
|
|
9476
|
+
meteredQuarterlyPrice: json["metered_quarterly_price"] == null ? void 0 : BillingPriceViewFromJSON(json["metered_quarterly_price"]),
|
|
9466
9477
|
meteredYearlyPrice: json["metered_yearly_price"] == null ? void 0 : BillingPriceViewFromJSON(json["metered_yearly_price"]),
|
|
9467
9478
|
metricPeriod: json["metric_period"] == null ? void 0 : MetricPeriodFromJSON(json["metric_period"]),
|
|
9468
9479
|
metricPeriodMonthReset: json["metric_period_month_reset"] == null ? void 0 : MetricPeriodMonthResetFromJSON(json["metric_period_month_reset"]),
|
|
@@ -9737,6 +9748,7 @@ function PlanCurrencyPricesResponseDataFromJSONTyped(json, ignoreDiscriminator)
|
|
|
9737
9748
|
currency: json["currency"],
|
|
9738
9749
|
monthlyPrice: json["monthly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON(json["monthly_price"]),
|
|
9739
9750
|
oneTimePrice: json["one_time_price"] == null ? void 0 : BillingPriceResponseDataFromJSON(json["one_time_price"]),
|
|
9751
|
+
quarterlyPrice: json["quarterly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON(json["quarterly_price"]),
|
|
9740
9752
|
yearlyPrice: json["yearly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON(json["yearly_price"])
|
|
9741
9753
|
};
|
|
9742
9754
|
}
|
|
@@ -9854,6 +9866,7 @@ function FeatureUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
9854
9866
|
plan: json["plan"] == null ? void 0 : PlanResponseDataFromJSON(json["plan"]),
|
|
9855
9867
|
planEntitlement: json["plan_entitlement"] == null ? void 0 : PlanEntitlementResponseDataFromJSON(json["plan_entitlement"]),
|
|
9856
9868
|
priceBehavior: json["price_behavior"] == null ? void 0 : EntitlementPriceBehaviorFromJSON(json["price_behavior"]),
|
|
9869
|
+
quarterlyUsageBasedPrice: json["quarterly_usage_based_price"] == null ? void 0 : BillingPriceViewFromJSON(json["quarterly_usage_based_price"]),
|
|
9857
9870
|
softLimit: json["soft_limit"] == null ? void 0 : json["soft_limit"],
|
|
9858
9871
|
usage: json["usage"] == null ? void 0 : json["usage"],
|
|
9859
9872
|
yearlyUsageBasedPrice: json["yearly_usage_based_price"] == null ? void 0 : BillingPriceViewFromJSON(json["yearly_usage_based_price"])
|
|
@@ -9912,6 +9925,7 @@ function CompanyPlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
9912
9925
|
name: json["name"],
|
|
9913
9926
|
oneTimePrice: json["one_time_price"] == null ? void 0 : BillingPriceResponseDataFromJSON(json["one_time_price"]),
|
|
9914
9927
|
planType: PlanTypeFromJSON(json["plan_type"]),
|
|
9928
|
+
quarterlyPrice: json["quarterly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON(json["quarterly_price"]),
|
|
9915
9929
|
trialDays: json["trial_days"] == null ? void 0 : json["trial_days"],
|
|
9916
9930
|
updatedAt: new Date(json["updated_at"]),
|
|
9917
9931
|
usageViolations: json["usage_violations"].map(
|
|
@@ -10068,6 +10082,7 @@ function PlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
10068
10082
|
name: json["name"],
|
|
10069
10083
|
oneTimePrice: json["one_time_price"] == null ? void 0 : BillingPriceResponseDataFromJSON(json["one_time_price"]),
|
|
10070
10084
|
planType: PlanTypeFromJSON(json["plan_type"]),
|
|
10085
|
+
quarterlyPrice: json["quarterly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON(json["quarterly_price"]),
|
|
10071
10086
|
trialDays: json["trial_days"] == null ? void 0 : json["trial_days"],
|
|
10072
10087
|
updatedAt: new Date(json["updated_at"]),
|
|
10073
10088
|
versions: json["versions"].map(
|
|
@@ -10172,6 +10187,7 @@ function UsageBasedEntitlementResponseDataFromJSONTyped(json, ignoreDiscriminato
|
|
|
10172
10187
|
metricPeriodMonthReset: json["metric_period_month_reset"] == null ? void 0 : MetricPeriodMonthResetFromJSON(json["metric_period_month_reset"]),
|
|
10173
10188
|
monthlyUsageBasedPrice: json["monthly_usage_based_price"] == null ? void 0 : BillingPriceViewFromJSON(json["monthly_usage_based_price"]),
|
|
10174
10189
|
priceBehavior: json["price_behavior"] == null ? void 0 : EntitlementPriceBehaviorFromJSON(json["price_behavior"]),
|
|
10190
|
+
quarterlyUsageBasedPrice: json["quarterly_usage_based_price"] == null ? void 0 : BillingPriceViewFromJSON(json["quarterly_usage_based_price"]),
|
|
10175
10191
|
valueBool: json["value_bool"] == null ? void 0 : json["value_bool"],
|
|
10176
10192
|
valueNumeric: json["value_numeric"] == null ? void 0 : json["value_numeric"],
|
|
10177
10193
|
valueType: EntitlementValueTypeFromJSON(json["value_type"]),
|
|
@@ -11321,6 +11337,7 @@ function BillingPriceResponseDataFromJSONTyped9(json, ignoreDiscriminator) {
|
|
|
11321
11337
|
externalPriceId: json["external_price_id"],
|
|
11322
11338
|
id: json["id"],
|
|
11323
11339
|
interval: BillingProductPriceIntervalFromJSON2(json["interval"]),
|
|
11340
|
+
intervalCount: json["interval_count"],
|
|
11324
11341
|
nickname: json["nickname"] == null ? void 0 : json["nickname"],
|
|
11325
11342
|
price: json["price"],
|
|
11326
11343
|
priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
|
|
@@ -11456,6 +11473,7 @@ function BillingPriceViewFromJSONTyped9(json, ignoreDiscriminator) {
|
|
|
11456
11473
|
currency: json["currency"],
|
|
11457
11474
|
id: json["id"],
|
|
11458
11475
|
interval: BillingProductPriceIntervalFromJSON2(json["interval"]),
|
|
11476
|
+
intervalCount: json["interval_count"],
|
|
11459
11477
|
isActive: json["is_active"],
|
|
11460
11478
|
meterEventName: json["meter_event_name"] == null ? void 0 : json["meter_event_name"],
|
|
11461
11479
|
meterEventPayloadKey: json["meter_event_payload_key"] == null ? void 0 : json["meter_event_payload_key"],
|
|
@@ -11743,6 +11761,7 @@ function EntitlementCurrencyPricesResponseDataFromJSONTyped3(json, ignoreDiscrim
|
|
|
11743
11761
|
return {
|
|
11744
11762
|
currency: json["currency"],
|
|
11745
11763
|
monthlyPrice: json["monthly_price"] == null ? void 0 : BillingPriceViewFromJSON2(json["monthly_price"]),
|
|
11764
|
+
quarterlyPrice: json["quarterly_price"] == null ? void 0 : BillingPriceViewFromJSON2(json["quarterly_price"]),
|
|
11746
11765
|
yearlyPrice: json["yearly_price"] == null ? void 0 : BillingPriceViewFromJSON2(json["yearly_price"])
|
|
11747
11766
|
};
|
|
11748
11767
|
}
|
|
@@ -12090,6 +12109,7 @@ function PlanEntitlementResponseDataFromJSONTyped5(json, ignoreDiscriminator) {
|
|
|
12090
12109
|
featureId: json["feature_id"],
|
|
12091
12110
|
id: json["id"],
|
|
12092
12111
|
meteredMonthlyPrice: json["metered_monthly_price"] == null ? void 0 : BillingPriceViewFromJSON2(json["metered_monthly_price"]),
|
|
12112
|
+
meteredQuarterlyPrice: json["metered_quarterly_price"] == null ? void 0 : BillingPriceViewFromJSON2(json["metered_quarterly_price"]),
|
|
12093
12113
|
meteredYearlyPrice: json["metered_yearly_price"] == null ? void 0 : BillingPriceViewFromJSON2(json["metered_yearly_price"]),
|
|
12094
12114
|
metricPeriod: json["metric_period"] == null ? void 0 : MetricPeriodFromJSON2(json["metric_period"]),
|
|
12095
12115
|
metricPeriodMonthReset: json["metric_period_month_reset"] == null ? void 0 : MetricPeriodMonthResetFromJSON2(json["metric_period_month_reset"]),
|
|
@@ -12167,6 +12187,7 @@ function PlanCurrencyPricesResponseDataFromJSONTyped5(json, ignoreDiscriminator)
|
|
|
12167
12187
|
currency: json["currency"],
|
|
12168
12188
|
monthlyPrice: json["monthly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON2(json["monthly_price"]),
|
|
12169
12189
|
oneTimePrice: json["one_time_price"] == null ? void 0 : BillingPriceResponseDataFromJSON2(json["one_time_price"]),
|
|
12190
|
+
quarterlyPrice: json["quarterly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON2(json["quarterly_price"]),
|
|
12170
12191
|
yearlyPrice: json["yearly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON2(json["yearly_price"])
|
|
12171
12192
|
};
|
|
12172
12193
|
}
|
|
@@ -12251,6 +12272,7 @@ function PlanViewPublicResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
12251
12272
|
name: json["name"],
|
|
12252
12273
|
oneTimePrice: json["one_time_price"] == null ? void 0 : BillingPriceResponseDataFromJSON2(json["one_time_price"]),
|
|
12253
12274
|
planType: PlanTypeFromJSON2(json["plan_type"]),
|
|
12275
|
+
quarterlyPrice: json["quarterly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON2(json["quarterly_price"]),
|
|
12254
12276
|
trialDays: json["trial_days"] == null ? void 0 : json["trial_days"],
|
|
12255
12277
|
updatedAt: new Date(json["updated_at"]),
|
|
12256
12278
|
versions: json["versions"].map(
|
|
@@ -12338,6 +12360,24 @@ var ComponentspublicApi = class extends BaseAPI2 {
|
|
|
12338
12360
|
};
|
|
12339
12361
|
|
|
12340
12362
|
// src/utils/api/billing.ts
|
|
12363
|
+
function derivePeriod(interval, intervalCount) {
|
|
12364
|
+
if (!interval) {
|
|
12365
|
+
return void 0;
|
|
12366
|
+
}
|
|
12367
|
+
if (interval === "month" && intervalCount === 3) {
|
|
12368
|
+
return "quarter";
|
|
12369
|
+
}
|
|
12370
|
+
return interval;
|
|
12371
|
+
}
|
|
12372
|
+
function getSubscriptionPeriod(billingSubscription) {
|
|
12373
|
+
if (!billingSubscription) {
|
|
12374
|
+
return void 0;
|
|
12375
|
+
}
|
|
12376
|
+
const product = billingSubscription.products?.find(
|
|
12377
|
+
(p3) => p3.interval && p3.interval !== "one-time"
|
|
12378
|
+
);
|
|
12379
|
+
return derivePeriod(product?.interval, product?.intervalCount) ?? derivePeriod(billingSubscription.interval);
|
|
12380
|
+
}
|
|
12341
12381
|
var ChargeType = {
|
|
12342
12382
|
oneTime: "one_time",
|
|
12343
12383
|
recurring: "recurring",
|
|
@@ -12347,19 +12387,32 @@ function getPriceValue(billingPrice) {
|
|
|
12347
12387
|
const price = typeof billingPrice.priceDecimal === "string" ? Number(billingPrice.priceDecimal) : billingPrice.price;
|
|
12348
12388
|
return price;
|
|
12349
12389
|
}
|
|
12390
|
+
function selectPriceForPeriod(source, period) {
|
|
12391
|
+
switch (period) {
|
|
12392
|
+
case "year":
|
|
12393
|
+
return source.yearlyPrice;
|
|
12394
|
+
case "quarter":
|
|
12395
|
+
return source.quarterlyPrice;
|
|
12396
|
+
default:
|
|
12397
|
+
return source.monthlyPrice;
|
|
12398
|
+
}
|
|
12399
|
+
}
|
|
12400
|
+
function selectAvailablePrice(source) {
|
|
12401
|
+
return source.monthlyPrice ?? source.quarterlyPrice ?? source.yearlyPrice;
|
|
12402
|
+
}
|
|
12350
12403
|
function getPlanPrice(plan, period = "month", options = { useSelectedPeriod: true }, currency) {
|
|
12351
12404
|
if (currency && plan.currencyPrices?.length) {
|
|
12352
12405
|
const currencyPrice = plan.currencyPrices.find(
|
|
12353
12406
|
(cp) => cp.currency.toLowerCase() === currency.toLowerCase()
|
|
12354
12407
|
);
|
|
12355
12408
|
if (currencyPrice) {
|
|
12356
|
-
const billingPrice2 = options.useSelectedPeriod ?
|
|
12409
|
+
const billingPrice2 = options.useSelectedPeriod ? selectPriceForPeriod(currencyPrice, period) : selectAvailablePrice(currencyPrice);
|
|
12357
12410
|
if (billingPrice2) {
|
|
12358
12411
|
return { ...billingPrice2, price: getPriceValue(billingPrice2) };
|
|
12359
12412
|
}
|
|
12360
12413
|
}
|
|
12361
12414
|
}
|
|
12362
|
-
const billingPrice = options.useSelectedPeriod ?
|
|
12415
|
+
const billingPrice = options.useSelectedPeriod ? selectPriceForPeriod(plan, period) : selectAvailablePrice(plan);
|
|
12363
12416
|
if (billingPrice) {
|
|
12364
12417
|
return { ...billingPrice, price: getPriceValue(billingPrice) };
|
|
12365
12418
|
}
|
|
@@ -12370,13 +12423,13 @@ function getAddOnPrice(addOn, period = "month", currency) {
|
|
|
12370
12423
|
(cp) => cp.currency.toLowerCase() === currency.toLowerCase()
|
|
12371
12424
|
);
|
|
12372
12425
|
if (currencyPrice) {
|
|
12373
|
-
const billingPrice2 = addOn.chargeType === ChargeType.oneTime ? currencyPrice.oneTimePrice :
|
|
12426
|
+
const billingPrice2 = addOn.chargeType === ChargeType.oneTime ? currencyPrice.oneTimePrice : selectPriceForPeriod(currencyPrice, period);
|
|
12374
12427
|
if (billingPrice2) {
|
|
12375
12428
|
return { ...billingPrice2, price: getPriceValue(billingPrice2) };
|
|
12376
12429
|
}
|
|
12377
12430
|
}
|
|
12378
12431
|
}
|
|
12379
|
-
const billingPrice = addOn.chargeType === ChargeType.oneTime ? addOn.oneTimePrice :
|
|
12432
|
+
const billingPrice = addOn.chargeType === ChargeType.oneTime ? addOn.oneTimePrice : selectPriceForPeriod(addOn, period);
|
|
12380
12433
|
if (billingPrice) {
|
|
12381
12434
|
return { ...billingPrice, price: getPriceValue(billingPrice) };
|
|
12382
12435
|
}
|
|
@@ -12400,14 +12453,28 @@ function getEntitlementPrice(entitlement, period = "month", currency) {
|
|
|
12400
12453
|
(cp) => cp.currency.toLowerCase() === currency.toLowerCase()
|
|
12401
12454
|
);
|
|
12402
12455
|
if (currencyPrice) {
|
|
12403
|
-
source =
|
|
12456
|
+
source = selectPriceForPeriod(currencyPrice, period);
|
|
12404
12457
|
}
|
|
12405
12458
|
}
|
|
12406
12459
|
if (!source) {
|
|
12407
12460
|
if ("valueType" in entitlement) {
|
|
12408
|
-
source =
|
|
12461
|
+
source = selectPriceForPeriod(
|
|
12462
|
+
{
|
|
12463
|
+
monthlyPrice: entitlement.meteredMonthlyPrice,
|
|
12464
|
+
quarterlyPrice: entitlement.meteredQuarterlyPrice,
|
|
12465
|
+
yearlyPrice: entitlement.meteredYearlyPrice
|
|
12466
|
+
},
|
|
12467
|
+
period
|
|
12468
|
+
);
|
|
12409
12469
|
} else if ("entitlementType" in entitlement) {
|
|
12410
|
-
source =
|
|
12470
|
+
source = selectPriceForPeriod(
|
|
12471
|
+
{
|
|
12472
|
+
monthlyPrice: entitlement.monthlyUsageBasedPrice,
|
|
12473
|
+
quarterlyPrice: entitlement.quarterlyUsageBasedPrice,
|
|
12474
|
+
yearlyPrice: entitlement.yearlyUsageBasedPrice
|
|
12475
|
+
},
|
|
12476
|
+
period
|
|
12477
|
+
);
|
|
12411
12478
|
}
|
|
12412
12479
|
}
|
|
12413
12480
|
if (source) {
|
|
@@ -12459,7 +12526,15 @@ function calculateTieredCost(quantity, priceTiers, tiersMode) {
|
|
|
12459
12526
|
return cost;
|
|
12460
12527
|
}
|
|
12461
12528
|
function getEntitlementCost(entitlement, period = "month", currency) {
|
|
12462
|
-
const
|
|
12529
|
+
const resolvedPeriod = period ?? "month";
|
|
12530
|
+
const source = currency ? getEntitlementPrice(entitlement, resolvedPeriod, currency) : selectPriceForPeriod(
|
|
12531
|
+
{
|
|
12532
|
+
monthlyPrice: entitlement.monthlyUsageBasedPrice,
|
|
12533
|
+
quarterlyPrice: entitlement.quarterlyUsageBasedPrice,
|
|
12534
|
+
yearlyPrice: entitlement.yearlyUsageBasedPrice
|
|
12535
|
+
},
|
|
12536
|
+
resolvedPeriod
|
|
12537
|
+
);
|
|
12463
12538
|
if (source) {
|
|
12464
12539
|
const billingPrice = { ...source };
|
|
12465
12540
|
if (entitlement.priceBehavior === EntitlementPriceBehavior.PayInAdvance && typeof entitlement.allocation === "number" && entitlement.allocation > 0) {
|
|
@@ -12720,7 +12795,7 @@ function getMetricPeriodName(entitlement) {
|
|
|
12720
12795
|
return name;
|
|
12721
12796
|
}
|
|
12722
12797
|
function getUsageDetails(entitlement, period, currency) {
|
|
12723
|
-
const billingPrice = currency ? getEntitlementPrice(entitlement, period ?? "month", currency) : period === "year" ? entitlement.yearlyUsageBasedPrice : period === "month" ? entitlement.monthlyUsageBasedPrice : void 0;
|
|
12798
|
+
const billingPrice = currency ? getEntitlementPrice(entitlement, period ?? "month", currency) : period === "year" ? entitlement.yearlyUsageBasedPrice : period === "quarter" ? entitlement.quarterlyUsageBasedPrice : period === "month" ? entitlement.monthlyUsageBasedPrice : void 0;
|
|
12724
12799
|
let limit;
|
|
12725
12800
|
if ((!entitlement.priceBehavior || entitlement.priceBehavior === EntitlementPriceBehavior.PayInAdvance) && typeof entitlement.allocation === "number") {
|
|
12726
12801
|
limit = entitlement.allocation;
|
|
@@ -12782,7 +12857,7 @@ function getCreditBasedEntitlementLimit(entitlement, credits) {
|
|
|
12782
12857
|
}
|
|
12783
12858
|
function extractCurrentUsageBasedEntitlements(features = [], planPeriod) {
|
|
12784
12859
|
return features.reduce((acc, entitlement) => {
|
|
12785
|
-
if (entitlement.priceBehavior && (planPeriod === "month" && entitlement.monthlyUsageBasedPrice || planPeriod === "year" && entitlement.yearlyUsageBasedPrice)) {
|
|
12860
|
+
if (entitlement.priceBehavior && (planPeriod === "month" && entitlement.monthlyUsageBasedPrice || planPeriod === "quarter" && entitlement.quarterlyUsageBasedPrice || planPeriod === "year" && entitlement.yearlyUsageBasedPrice)) {
|
|
12786
12861
|
const allocation = entitlement.allocation || 0;
|
|
12787
12862
|
const usage = entitlement.usage || 0;
|
|
12788
12863
|
const quantity = allocation ?? usage;
|
|
@@ -13304,6 +13379,8 @@ function shortenPeriod(period) {
|
|
|
13304
13379
|
switch (period) {
|
|
13305
13380
|
case "month":
|
|
13306
13381
|
return "mo";
|
|
13382
|
+
case "quarter":
|
|
13383
|
+
return "qtr";
|
|
13307
13384
|
case "year":
|
|
13308
13385
|
return "yr";
|
|
13309
13386
|
}
|
|
@@ -13691,7 +13768,7 @@ var reducer = (state, action) => {
|
|
|
13691
13768
|
// src/context/EmbedProvider.tsx
|
|
13692
13769
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
13693
13770
|
var getCustomHeaders = (sessionId) => ({
|
|
13694
|
-
"X-Schematic-Components-Version": "2.
|
|
13771
|
+
"X-Schematic-Components-Version": "2.12.0",
|
|
13695
13772
|
"X-Schematic-Session-ID": sessionId
|
|
13696
13773
|
});
|
|
13697
13774
|
var normalizeCurrencyFilter = (filter2) => {
|
|
@@ -14227,6 +14304,9 @@ function useAvailablePlans(activePeriod, options = { useSelectedPeriod: true })
|
|
|
14227
14304
|
if ((data?.activePlans || []).some((plan) => plan.monthlyPrice) || (data?.activeAddOns || []).some((addOn) => addOn.monthlyPrice)) {
|
|
14228
14305
|
periods.push("month");
|
|
14229
14306
|
}
|
|
14307
|
+
if ((data?.activePlans || []).some((plan) => plan.quarterlyPrice) || (data?.activeAddOns || []).some((addOn) => addOn.quarterlyPrice)) {
|
|
14308
|
+
periods.push("quarter");
|
|
14309
|
+
}
|
|
14230
14310
|
if ((data?.activePlans || []).some((plan) => plan.yearlyPrice) || (data?.activeAddOns || []).some((addOn) => addOn.yearlyPrice)) {
|
|
14231
14311
|
periods.push("year");
|
|
14232
14312
|
}
|
|
@@ -14236,9 +14316,9 @@ function useAvailablePlans(activePeriod, options = { useSelectedPeriod: true })
|
|
|
14236
14316
|
(plans) => {
|
|
14237
14317
|
const activePlans = settings.mode === "edit" ? plans.slice() : plans.filter((plan) => {
|
|
14238
14318
|
if (options.useSelectedPeriod) {
|
|
14239
|
-
return activePeriod === "month" && plan.monthlyPrice || activePeriod === "year" && plan.yearlyPrice || plan.chargeType === ChargeType.oneTime;
|
|
14319
|
+
return activePeriod === "month" && plan.monthlyPrice || activePeriod === "quarter" && plan.quarterlyPrice || activePeriod === "year" && plan.yearlyPrice || plan.chargeType === ChargeType.oneTime;
|
|
14240
14320
|
}
|
|
14241
|
-
return plan.monthlyPrice || plan.yearlyPrice || plan.chargeType === ChargeType.oneTime;
|
|
14321
|
+
return plan.monthlyPrice || plan.quarterlyPrice || plan.yearlyPrice || plan.chargeType === ChargeType.oneTime;
|
|
14242
14322
|
});
|
|
14243
14323
|
return activePlans.map((plan) => ({ ...plan, isSelected: false }));
|
|
14244
14324
|
},
|
|
@@ -16215,7 +16295,7 @@ var Plan = ({
|
|
|
16215
16295
|
$gap: "1rem",
|
|
16216
16296
|
$flexGrow: 1,
|
|
16217
16297
|
children: plans.map((plan, planIndex) => {
|
|
16218
|
-
const planPeriod = showPeriodToggle ? period : plan.
|
|
16298
|
+
const planPeriod = showPeriodToggle ? period : plan.monthlyPrice ? BillingProductPriceInterval.Month : plan.quarterlyPrice ? "quarter" : plan.yearlyPrice ? BillingProductPriceInterval.Year : BillingProductPriceInterval.Month;
|
|
16219
16299
|
const { price: planPrice, currency: planCurrency } = getPlanPrice(
|
|
16220
16300
|
plan,
|
|
16221
16301
|
planPeriod,
|
|
@@ -16274,6 +16354,9 @@ var Plan = ({
|
|
|
16274
16354
|
children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig.priceText : t3("Custom price") : isUsageBasedPlan ? t3("Usage-based") : isFreePlan && showZeroPriceAsFree ? t3("Free") : showAsMonthlyPrices && planPeriod === BillingProductPriceInterval.Year ? formatCurrency((planPrice ?? 0) / 12, {
|
|
16275
16355
|
currency: planCurrency,
|
|
16276
16356
|
testSignificantDigits: false
|
|
16357
|
+
}) : showAsMonthlyPrices && planPeriod === "quarter" ? formatCurrency((planPrice ?? 0) / 3, {
|
|
16358
|
+
currency: planCurrency,
|
|
16359
|
+
testSignificantDigits: false
|
|
16277
16360
|
}) : formatCurrency(planPrice ?? 0, planCurrency)
|
|
16278
16361
|
}
|
|
16279
16362
|
),
|
|
@@ -16284,7 +16367,7 @@ var Plan = ({
|
|
|
16284
16367
|
$size: 16 / 30 * settings.theme.typography.heading2.fontSize,
|
|
16285
16368
|
children: [
|
|
16286
16369
|
"/",
|
|
16287
|
-
showAsMonthlyPrices && planPeriod === BillingProductPriceInterval.Year ? t3("month, billed yearly") : t3(planPeriod)
|
|
16370
|
+
showAsMonthlyPrices && planPeriod === BillingProductPriceInterval.Year ? t3("month, billed yearly") : showAsMonthlyPrices && planPeriod === "quarter" ? t3("month, billed quarterly") : t3(planPeriod)
|
|
16288
16371
|
]
|
|
16289
16372
|
}
|
|
16290
16373
|
)
|
|
@@ -16820,7 +16903,7 @@ var AddOns = ({
|
|
|
16820
16903
|
const { t: t3 } = useTranslation();
|
|
16821
16904
|
const { settings } = useEmbed();
|
|
16822
16905
|
const isLightBackground = useIsLightBackground();
|
|
16823
|
-
const periodKey = period === "year" ? "yearlyPrice" : "monthlyPrice";
|
|
16906
|
+
const periodKey = period === "year" ? "yearlyPrice" : period === "quarter" ? "quarterlyPrice" : "monthlyPrice";
|
|
16824
16907
|
const cardPadding = settings.theme.card.padding / TEXT_BASE_SIZE;
|
|
16825
16908
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
16826
16909
|
Box,
|
|
@@ -17293,9 +17376,9 @@ var Navigation = ({
|
|
|
17293
17376
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
17294
17377
|
var createActiveUsageBasedEntitlementsReducer = (entitlements, period) => (acc, entitlement) => {
|
|
17295
17378
|
const hasCurrencyPrice = entitlement.currencyPrices?.some(
|
|
17296
|
-
(cp) => period === "month" && cp.monthlyPrice || period === "year" && cp.yearlyPrice
|
|
17379
|
+
(cp) => period === "month" && cp.monthlyPrice || period === "quarter" && cp.quarterlyPrice || period === "year" && cp.yearlyPrice
|
|
17297
17380
|
);
|
|
17298
|
-
if (entitlement.priceBehavior && (period === "month" && entitlement.meteredMonthlyPrice || period === "year" && entitlement.meteredYearlyPrice || hasCurrencyPrice)) {
|
|
17381
|
+
if (entitlement.priceBehavior && (period === "month" && entitlement.meteredMonthlyPrice || period === "quarter" && entitlement.meteredQuarterlyPrice || period === "year" && entitlement.meteredYearlyPrice || hasCurrencyPrice)) {
|
|
17299
17382
|
const featureUsage = entitlements.find(
|
|
17300
17383
|
(usage2) => usage2.feature?.id === entitlement.feature?.id
|
|
17301
17384
|
);
|
|
@@ -17355,15 +17438,16 @@ var CheckoutDialog = ({ top }) => {
|
|
|
17355
17438
|
[data?.featureUsage?.features]
|
|
17356
17439
|
);
|
|
17357
17440
|
const getValidatedPeriod = () => {
|
|
17358
|
-
const requestedPeriod = checkoutState?.period || data?.company?.plan?.planPeriod || "month";
|
|
17441
|
+
const requestedPeriod = checkoutState?.period || getSubscriptionPeriod(data?.company?.billingSubscription) || data?.company?.plan?.planPeriod || "month";
|
|
17359
17442
|
if (checkoutState?.planId) {
|
|
17360
17443
|
const requestedPlan = data?.activePlans?.find(
|
|
17361
17444
|
(plan) => plan.id === checkoutState.planId
|
|
17362
17445
|
);
|
|
17363
17446
|
if (requestedPlan) {
|
|
17364
|
-
const planSupportsRequestedPeriod = requestedPeriod === "month" && requestedPlan.monthlyPrice || requestedPeriod === "year" && requestedPlan.yearlyPrice;
|
|
17447
|
+
const planSupportsRequestedPeriod = requestedPeriod === "month" && requestedPlan.monthlyPrice || requestedPeriod === "quarter" && requestedPlan.quarterlyPrice || requestedPeriod === "year" && requestedPlan.yearlyPrice;
|
|
17365
17448
|
if (!planSupportsRequestedPeriod) {
|
|
17366
17449
|
if (requestedPlan.yearlyPrice) return "year";
|
|
17450
|
+
if (requestedPlan.quarterlyPrice) return "quarter";
|
|
17367
17451
|
if (requestedPlan.monthlyPrice) return "month";
|
|
17368
17452
|
}
|
|
17369
17453
|
}
|
|
@@ -17680,7 +17764,7 @@ var CheckoutDialog = ({ top }) => {
|
|
|
17680
17764
|
{ useSelectedPeriod: true },
|
|
17681
17765
|
resolvedCurrency
|
|
17682
17766
|
) : void 0;
|
|
17683
|
-
const planPriceId = currencyPrice?.id ?? (period === "year" ? plan?.yearlyPrice?.id : plan?.monthlyPrice?.id);
|
|
17767
|
+
const planPriceId = currencyPrice?.id ?? (period === "year" ? plan?.yearlyPrice?.id : period === "quarter" ? plan?.quarterlyPrice?.id : plan?.monthlyPrice?.id);
|
|
17684
17768
|
const code = typeof updates.promoCode !== "undefined" ? updates.promoCode : promoCode;
|
|
17685
17769
|
const skipTrial = !(updates.shouldTrial ?? shouldTrial);
|
|
17686
17770
|
if (!plan || !planPriceId) {
|
|
@@ -17806,7 +17890,7 @@ var CheckoutDialog = ({ top }) => {
|
|
|
17806
17890
|
const selectPlan = (0, import_react36.useCallback)(
|
|
17807
17891
|
(updates) => {
|
|
17808
17892
|
const plan = updates.plan;
|
|
17809
|
-
const period = showPeriodToggle ? updates.period || planPeriod : plan.
|
|
17893
|
+
const period = showPeriodToggle ? updates.period || planPeriod : plan.monthlyPrice ? BillingProductPriceInterval.Month : plan.quarterlyPrice ? "quarter" : plan.yearlyPrice ? BillingProductPriceInterval.Year : BillingProductPriceInterval.Month;
|
|
17810
17894
|
const updatedUsageBasedEntitlements = plan.entitlements.reduce(
|
|
17811
17895
|
createActiveUsageBasedEntitlementsReducer(featureUsage, period),
|
|
17812
17896
|
[]
|
|
@@ -17864,12 +17948,60 @@ var CheckoutDialog = ({ top }) => {
|
|
|
17864
17948
|
);
|
|
17865
17949
|
const changePlanPeriod = (0, import_react36.useCallback)(
|
|
17866
17950
|
(period) => {
|
|
17867
|
-
if (period
|
|
17868
|
-
|
|
17869
|
-
handlePreviewCheckout({ period });
|
|
17951
|
+
if (period === planPeriod) {
|
|
17952
|
+
return;
|
|
17870
17953
|
}
|
|
17954
|
+
setPlanPeriod(period);
|
|
17955
|
+
const updatedUsageBasedEntitlements = (selectedPlan?.entitlements || []).reduce(
|
|
17956
|
+
createActiveUsageBasedEntitlementsReducer(featureUsage, period),
|
|
17957
|
+
[...[]]
|
|
17958
|
+
);
|
|
17959
|
+
setUsageBasedEntitlements(
|
|
17960
|
+
(prev2) => updatedUsageBasedEntitlements.map((updated) => {
|
|
17961
|
+
const current = prev2.find(
|
|
17962
|
+
({ featureId }) => featureId === updated.featureId
|
|
17963
|
+
);
|
|
17964
|
+
if (typeof current?.quantity === "number") {
|
|
17965
|
+
return { ...updated, quantity: current.quantity };
|
|
17966
|
+
}
|
|
17967
|
+
return updated;
|
|
17968
|
+
})
|
|
17969
|
+
);
|
|
17970
|
+
const updatedAddOnUsageBasedEntitlements = addOns.filter((addOn) => addOn.isSelected).flatMap(
|
|
17971
|
+
(addOn) => addOn.entitlements.reduce(
|
|
17972
|
+
createActiveUsageBasedEntitlementsReducer(featureUsage, period),
|
|
17973
|
+
[]
|
|
17974
|
+
)
|
|
17975
|
+
);
|
|
17976
|
+
setAddOnUsageBasedEntitlements(
|
|
17977
|
+
(prev2) => updatedAddOnUsageBasedEntitlements.map((updated) => {
|
|
17978
|
+
const current = prev2.find(
|
|
17979
|
+
({ featureId }) => featureId === updated.featureId
|
|
17980
|
+
);
|
|
17981
|
+
if (typeof current?.quantity === "number") {
|
|
17982
|
+
return { ...updated, quantity: current.quantity };
|
|
17983
|
+
}
|
|
17984
|
+
return updated;
|
|
17985
|
+
})
|
|
17986
|
+
);
|
|
17987
|
+
handlePreviewCheckout({
|
|
17988
|
+
period,
|
|
17989
|
+
payInAdvanceEntitlements: updatedUsageBasedEntitlements.filter(
|
|
17990
|
+
({ priceBehavior }) => priceBehavior === EntitlementPriceBehavior.PayInAdvance
|
|
17991
|
+
),
|
|
17992
|
+
addOnPayInAdvanceEntitlements: updatedAddOnUsageBasedEntitlements.filter(
|
|
17993
|
+
({ priceBehavior }) => priceBehavior === EntitlementPriceBehavior.PayInAdvance
|
|
17994
|
+
)
|
|
17995
|
+
});
|
|
17871
17996
|
},
|
|
17872
|
-
[
|
|
17997
|
+
[
|
|
17998
|
+
planPeriod,
|
|
17999
|
+
selectedPlan?.entitlements,
|
|
18000
|
+
featureUsage,
|
|
18001
|
+
addOns,
|
|
18002
|
+
setPlanPeriod,
|
|
18003
|
+
handlePreviewCheckout
|
|
18004
|
+
]
|
|
17873
18005
|
);
|
|
17874
18006
|
const toggleAddOn = (0, import_react36.useCallback)(
|
|
17875
18007
|
(id) => {
|
|
@@ -18769,6 +18901,10 @@ var PaymentForm = ({ onConfirm, financeData }) => {
|
|
|
18769
18901
|
// src/components/shared/period-toggle/PeriodToggle.tsx
|
|
18770
18902
|
var import_react39 = require("react");
|
|
18771
18903
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
18904
|
+
var PERIOD_MONTH_COUNT = {
|
|
18905
|
+
year: 12,
|
|
18906
|
+
quarter: 3
|
|
18907
|
+
};
|
|
18772
18908
|
var PeriodToggle = ({
|
|
18773
18909
|
portal,
|
|
18774
18910
|
options,
|
|
@@ -18779,14 +18915,23 @@ var PeriodToggle = ({
|
|
|
18779
18915
|
const { t: t3 } = useTranslation();
|
|
18780
18916
|
const { settings } = useEmbed();
|
|
18781
18917
|
const isLightBackground = useIsLightBackground();
|
|
18782
|
-
const
|
|
18783
|
-
|
|
18784
|
-
|
|
18785
|
-
|
|
18786
|
-
|
|
18787
|
-
|
|
18788
|
-
|
|
18918
|
+
const savingsByPeriod = (0, import_react39.useMemo)(() => {
|
|
18919
|
+
const result = {};
|
|
18920
|
+
if (!selectedPlan) {
|
|
18921
|
+
return result;
|
|
18922
|
+
}
|
|
18923
|
+
const monthlyPrice = getPlanPrice(selectedPlan, "month")?.price ?? 0;
|
|
18924
|
+
if (monthlyPrice <= 0) {
|
|
18925
|
+
return result;
|
|
18789
18926
|
}
|
|
18927
|
+
for (const [period, months] of Object.entries(PERIOD_MONTH_COUNT)) {
|
|
18928
|
+
const periodPrice = getPlanPrice(selectedPlan, period)?.price ?? 0;
|
|
18929
|
+
if (periodPrice > 0) {
|
|
18930
|
+
const baseline = monthlyPrice * months;
|
|
18931
|
+
result[period] = Math.round((baseline - periodPrice) / baseline * 1e4) / 100;
|
|
18932
|
+
}
|
|
18933
|
+
}
|
|
18934
|
+
return result;
|
|
18790
18935
|
}, [selectedPlan]);
|
|
18791
18936
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
18792
18937
|
Flex,
|
|
@@ -18840,17 +18985,21 @@ var PeriodToggle = ({
|
|
|
18840
18985
|
},
|
|
18841
18986
|
option
|
|
18842
18987
|
);
|
|
18843
|
-
|
|
18988
|
+
const savingsPercentage = savingsByPeriod[option];
|
|
18989
|
+
if (typeof savingsPercentage === "number") {
|
|
18990
|
+
const isOptionYear = option === "year";
|
|
18844
18991
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
18845
18992
|
Tooltip,
|
|
18846
18993
|
{
|
|
18847
18994
|
portal,
|
|
18848
18995
|
trigger: element,
|
|
18849
|
-
content: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Text, { $size: 11, $leading: "none", children: selectedOption ===
|
|
18850
|
-
|
|
18851
|
-
|
|
18852
|
-
|
|
18853
|
-
|
|
18996
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Text, { $size: 11, $leading: "none", children: selectedOption === option ? t3(
|
|
18997
|
+
isOptionYear ? "Saving with yearly billing" : "Saving with quarterly billing",
|
|
18998
|
+
{ percent: savingsPercentage }
|
|
18999
|
+
) : t3(
|
|
19000
|
+
isOptionYear ? "Save with yearly billing" : "Save with quarterly billing",
|
|
19001
|
+
{ percent: savingsPercentage }
|
|
19002
|
+
) }),
|
|
18854
19003
|
$flexGrow: 1,
|
|
18855
19004
|
$flexBasis: "50%"
|
|
18856
19005
|
},
|
|
@@ -19796,7 +19945,7 @@ var SubscriptionSidebar = (0, import_react43.forwardRef)(
|
|
|
19796
19945
|
{ useSelectedPeriod: true },
|
|
19797
19946
|
currency
|
|
19798
19947
|
) : void 0;
|
|
19799
|
-
const planPriceId = currencyPrice?.id ?? (planPeriod === "year" ? selectedPlan?.yearlyPrice : selectedPlan?.monthlyPrice)?.id;
|
|
19948
|
+
const planPriceId = currencyPrice?.id ?? (planPeriod === "year" ? selectedPlan?.yearlyPrice : planPeriod === "quarter" ? selectedPlan?.quarterlyPrice : selectedPlan?.monthlyPrice)?.id;
|
|
19800
19949
|
try {
|
|
19801
19950
|
if (!planId || !planPriceId) {
|
|
19802
19951
|
throw new Error(t3("Selected plan or associated price is missing."));
|
|
@@ -20090,7 +20239,9 @@ var SubscriptionSidebar = (0, import_react43.forwardRef)(
|
|
|
20090
20239
|
),
|
|
20091
20240
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("sub", { children: [
|
|
20092
20241
|
"/",
|
|
20093
|
-
shortenPeriod(
|
|
20242
|
+
shortenPeriod(
|
|
20243
|
+
getSubscriptionPeriod(billingSubscription) || currentPlan.planPeriod || planPeriod
|
|
20244
|
+
)
|
|
20094
20245
|
] })
|
|
20095
20246
|
] }) })
|
|
20096
20247
|
]
|
|
@@ -20473,7 +20624,7 @@ var SubscriptionSidebar = (0, import_react43.forwardRef)(
|
|
|
20473
20624
|
$gap: "1rem",
|
|
20474
20625
|
children: [
|
|
20475
20626
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Box, { $opacity: "0.625", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(Text, { children: [
|
|
20476
|
-
planPeriod === "year" ? t3("Yearly total") : t3("Monthly total"),
|
|
20627
|
+
planPeriod === "year" ? t3("Yearly total") : planPeriod === "quarter" ? t3("Quarterly total") : t3("Monthly total"),
|
|
20477
20628
|
":"
|
|
20478
20629
|
] }) }),
|
|
20479
20630
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Box, { $whiteSpace: "nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(Text, { children: [
|
|
@@ -20657,7 +20808,7 @@ var UnsubscribeDialog = ({ top }) => {
|
|
|
20657
20808
|
const { planPeriod, currentPlan, currentAddOns, featureUsage, cancelDate } = (0, import_react45.useMemo)(() => {
|
|
20658
20809
|
const cancelDate2 = data?.subscription?.cancelAt || data?.upcomingInvoice?.dueDate;
|
|
20659
20810
|
return {
|
|
20660
|
-
planPeriod: data?.company?.plan?.planPeriod || "month",
|
|
20811
|
+
planPeriod: getSubscriptionPeriod(data?.company?.billingSubscription) || data?.company?.plan?.planPeriod || "month",
|
|
20661
20812
|
currentPlan: data?.company?.plan,
|
|
20662
20813
|
currentAddOns: data?.company?.addOns || [],
|
|
20663
20814
|
featureUsage: data?.featureUsage,
|
|
@@ -20665,6 +20816,7 @@ var UnsubscribeDialog = ({ top }) => {
|
|
|
20665
20816
|
};
|
|
20666
20817
|
}, [
|
|
20667
20818
|
data?.company?.addOns,
|
|
20819
|
+
data?.company?.billingSubscription,
|
|
20668
20820
|
data?.company?.plan,
|
|
20669
20821
|
data?.featureUsage,
|
|
20670
20822
|
data?.subscription?.cancelAt,
|
|
@@ -21090,7 +21242,7 @@ var UsageDetails = ({ entitlement, layout }) => {
|
|
|
21090
21242
|
} = entitlement;
|
|
21091
21243
|
const { t: t3 } = useTranslation();
|
|
21092
21244
|
const { data } = useEmbed();
|
|
21093
|
-
const period = data?.company?.plan?.planPeriod
|
|
21245
|
+
const period = getSubscriptionPeriod(data?.company?.billingSubscription) ?? data?.company?.plan?.planPeriod ?? void 0;
|
|
21094
21246
|
const showCredits = data?.displaySettings?.showCredits ?? true;
|
|
21095
21247
|
const {
|
|
21096
21248
|
price,
|
|
@@ -21967,7 +22119,7 @@ var MeteredFeatures = (0, import_react51.forwardRef)(({ className, ...rest }, re
|
|
|
21967
22119
|
if (!shouldShowFeatures) {
|
|
21968
22120
|
return null;
|
|
21969
22121
|
}
|
|
21970
|
-
const period = typeof data?.company?.plan?.planPeriod === "string" ? data.company?.plan?.planPeriod : void 0;
|
|
22122
|
+
const period = getSubscriptionPeriod(data?.company?.billingSubscription) ?? (typeof data?.company?.plan?.planPeriod === "string" ? data.company?.plan?.planPeriod : void 0);
|
|
21971
22123
|
const canCheckout = data?.capabilities?.checkout ?? false;
|
|
21972
22124
|
const showCredits = data?.displaySettings?.showCredits ?? true;
|
|
21973
22125
|
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Container2, { ref, className, children: [
|
|
@@ -22559,7 +22711,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
|
22559
22711
|
}
|
|
22560
22712
|
stripe._registerWrapper({
|
|
22561
22713
|
name: "stripe-js",
|
|
22562
|
-
version: "9.
|
|
22714
|
+
version: "9.6.0",
|
|
22563
22715
|
startTime
|
|
22564
22716
|
});
|
|
22565
22717
|
};
|
|
@@ -22637,7 +22789,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
|
|
|
22637
22789
|
var version = runtimeVersionToUrlVersion(maybeStripe.version);
|
|
22638
22790
|
var expectedVersion = RELEASE_TRAIN;
|
|
22639
22791
|
if (isTestKey && version !== expectedVersion) {
|
|
22640
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.
|
|
22792
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.6.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
22641
22793
|
}
|
|
22642
22794
|
var stripe = maybeStripe.apply(void 0, args);
|
|
22643
22795
|
registerWrapper(stripe, startTime);
|
|
@@ -23020,7 +23172,8 @@ var import_react56 = require("react");
|
|
|
23020
23172
|
|
|
23021
23173
|
// src/components/elements/plan-manager/AddOn.tsx
|
|
23022
23174
|
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
23023
|
-
var AddOn = ({ addOn, currency, layout }) => {
|
|
23175
|
+
var AddOn = ({ addOn, currency, period, layout }) => {
|
|
23176
|
+
const resolvedPeriod = addOn.planPeriod === "one-time" ? addOn.planPeriod : period ?? addOn.planPeriod;
|
|
23024
23177
|
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
23025
23178
|
Flex,
|
|
23026
23179
|
{
|
|
@@ -23030,9 +23183,9 @@ var AddOn = ({ addOn, currency, layout }) => {
|
|
|
23030
23183
|
$gap: "1rem",
|
|
23031
23184
|
children: [
|
|
23032
23185
|
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Text, { display: layout.addOns.fontStyle, children: addOn.name }),
|
|
23033
|
-
typeof addOn.planPrice === "number" &&
|
|
23186
|
+
typeof addOn.planPrice === "number" && resolvedPeriod && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Text, { children: [
|
|
23034
23187
|
formatCurrency(addOn.planPrice, currency),
|
|
23035
|
-
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("sub", { children:
|
|
23188
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("sub", { children: resolvedPeriod === "one-time" ? shortenPeriod(resolvedPeriod) : `/${shortenPeriod(resolvedPeriod)}` })
|
|
23036
23189
|
] })
|
|
23037
23190
|
]
|
|
23038
23191
|
}
|
|
@@ -23284,7 +23437,7 @@ var PlanManager = (0, import_react56.forwardRef)(({ children, className, portal,
|
|
|
23284
23437
|
willSubscriptionCancel,
|
|
23285
23438
|
isTrialSubscription
|
|
23286
23439
|
} = (0, import_react56.useMemo)(() => {
|
|
23287
|
-
const subscriptionInterval2 = billingSubscription?.interval;
|
|
23440
|
+
const subscriptionInterval2 = getSubscriptionPeriod(billingSubscription) ?? billingSubscription?.interval;
|
|
23288
23441
|
const subscriptionCurrency2 = billingSubscription?.currency;
|
|
23289
23442
|
const isTrialSubscription2 = billingSubscription?.status === "trialing";
|
|
23290
23443
|
const willSubscriptionCancel2 = typeof billingSubscription?.cancelAt === "number" && billingSubscription?.cancelAtPeriodEnd === true;
|
|
@@ -23295,6 +23448,7 @@ var PlanManager = (0, import_react56.forwardRef)(({ children, className, portal,
|
|
|
23295
23448
|
willSubscriptionCancel: willSubscriptionCancel2
|
|
23296
23449
|
};
|
|
23297
23450
|
}, [billingSubscription]);
|
|
23451
|
+
const currentPlanPeriod = getSubscriptionPeriod(billingSubscription) ?? currentPlan?.planPeriod ?? void 0;
|
|
23298
23452
|
const { isFreePlan, isUsageBasedPlan } = (0, import_react56.useMemo)(() => {
|
|
23299
23453
|
const isFreePlan2 = currentPlan?.planPrice === 0;
|
|
23300
23454
|
const isUsageBasedPlan2 = isFreePlan2 && usageBasedEntitlements.length > 0;
|
|
@@ -23463,9 +23617,9 @@ var PlanManager = (0, import_react56.forwardRef)(({ children, className, portal,
|
|
|
23463
23617
|
)
|
|
23464
23618
|
}
|
|
23465
23619
|
),
|
|
23466
|
-
!isFreePlan &&
|
|
23620
|
+
!isFreePlan && currentPlanPeriod && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Text, { display: props.header.price.fontStyle, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("sub", { children: [
|
|
23467
23621
|
"/",
|
|
23468
|
-
shortenPeriod(
|
|
23622
|
+
shortenPeriod(currentPlanPeriod)
|
|
23469
23623
|
] }) })
|
|
23470
23624
|
] })
|
|
23471
23625
|
]
|
|
@@ -23485,6 +23639,7 @@ var PlanManager = (0, import_react56.forwardRef)(({ children, className, portal,
|
|
|
23485
23639
|
{
|
|
23486
23640
|
addOn,
|
|
23487
23641
|
currency: subscriptionCurrency,
|
|
23642
|
+
period: currentPlanPeriod,
|
|
23488
23643
|
layout: props
|
|
23489
23644
|
},
|
|
23490
23645
|
addOnIndex
|
|
@@ -23504,7 +23659,7 @@ var PlanManager = (0, import_react56.forwardRef)(({ children, className, portal,
|
|
|
23504
23659
|
UsageDetails2,
|
|
23505
23660
|
{
|
|
23506
23661
|
entitlement,
|
|
23507
|
-
period:
|
|
23662
|
+
period: currentPlanPeriod || "month",
|
|
23508
23663
|
currency: subscriptionCurrency,
|
|
23509
23664
|
showCredits,
|
|
23510
23665
|
layout: props
|
|
@@ -23828,7 +23983,8 @@ var AddOn2 = ({
|
|
|
23828
23983
|
};
|
|
23829
23984
|
}, [data?.capabilities?.checkout, data?.company?.addOns, data?.component]);
|
|
23830
23985
|
const cardPadding = settings.theme.card.padding / TEXT_BASE_SIZE;
|
|
23831
|
-
const
|
|
23986
|
+
const currentAddOnPeriod = getSubscriptionPeriod(data?.company?.billingSubscription) ?? currentAddOns.find((currentAddOn) => currentAddOn.id === addOn.id)?.planPeriod;
|
|
23987
|
+
const isActiveAddOn = addOn.current && selectedPeriod === currentAddOnPeriod;
|
|
23832
23988
|
const { price: addOnPrice, currency: addOnCurrency } = getAddOnPrice(addOn, selectedPeriod, currency) || {};
|
|
23833
23989
|
const displayableEntitlements = addOn.entitlements?.filter(
|
|
23834
23990
|
(entitlement) => entitlement.valueType === "unlimited" || entitlement.priceBehavior && entitlement.priceBehavior !== EntitlementPriceBehavior.CreditBurndown
|
|
@@ -24288,7 +24444,7 @@ var Plan2 = ({
|
|
|
24288
24444
|
};
|
|
24289
24445
|
const cardPadding = settings.theme.card.padding / TEXT_BASE_SIZE;
|
|
24290
24446
|
const isStandalone = typeof data?.component === "undefined";
|
|
24291
|
-
const currentPeriod = data?.company?.plan?.planPeriod || "month";
|
|
24447
|
+
const currentPeriod = getSubscriptionPeriod(data?.company?.billingSubscription) || data?.company?.plan?.planPeriod || "month";
|
|
24292
24448
|
const canCheckout = isStandalone || (data?.capabilities?.checkout ?? true);
|
|
24293
24449
|
const isTrialSubscription = data?.company?.billingSubscription?.status === "trialing";
|
|
24294
24450
|
const showCredits = data?.displaySettings?.showCredits ?? true;
|
|
@@ -24358,10 +24514,13 @@ var Plan2 = ({
|
|
|
24358
24514
|
plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig.priceText : t3("Custom price") : isUsageBasedPlan ? t3("Usage-based") : isFreePlan && showZeroPriceAsFree ? t3("Free") : showAsMonthlyPrices && selectedPeriod === BillingProductPriceInterval.Year ? formatCurrency((planPrice ?? 0) / 12, {
|
|
24359
24515
|
currency: planCurrency,
|
|
24360
24516
|
testSignificantDigits: false
|
|
24517
|
+
}) : showAsMonthlyPrices && selectedPeriod === "quarter" ? formatCurrency((planPrice ?? 0) / 3, {
|
|
24518
|
+
currency: planCurrency,
|
|
24519
|
+
testSignificantDigits: false
|
|
24361
24520
|
}) : formatCurrency(planPrice ?? 0, planCurrency),
|
|
24362
24521
|
!plan.custom && !isFreePlan && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("sub", { children: [
|
|
24363
24522
|
"/",
|
|
24364
|
-
showAsMonthlyPrices && selectedPeriod === BillingProductPriceInterval.Year ? t3("month, billed yearly") : t3(selectedPeriod)
|
|
24523
|
+
showAsMonthlyPrices && selectedPeriod === BillingProductPriceInterval.Year ? t3("month, billed yearly") : showAsMonthlyPrices && selectedPeriod === "quarter" ? t3("month, billed quarterly") : t3(selectedPeriod)
|
|
24365
24524
|
] })
|
|
24366
24525
|
]
|
|
24367
24526
|
}
|
|
@@ -24664,7 +24823,7 @@ var PricingTable = (0, import_react59.forwardRef)(({ className, ...rest }, ref)
|
|
|
24664
24823
|
[]
|
|
24665
24824
|
);
|
|
24666
24825
|
const [selectedPeriod, setSelectedPeriod] = (0, import_react59.useState)(
|
|
24667
|
-
() => data?.company?.plan?.planPeriod || "month"
|
|
24826
|
+
() => getSubscriptionPeriod(data?.company?.billingSubscription) || data?.company?.plan?.planPeriod || "month"
|
|
24668
24827
|
);
|
|
24669
24828
|
const { currencies, invalidFilterEntries } = useAvailableCurrenciesWithInvalid();
|
|
24670
24829
|
const [selectedCurrency, setSelectedCurrency] = (0, import_react59.useState)(
|
|
@@ -24800,7 +24959,7 @@ var PricingTable = (0, import_react59.forwardRef)(({ className, ...rest }, ref)
|
|
|
24800
24959
|
$margin: 0,
|
|
24801
24960
|
$listStyle: "none",
|
|
24802
24961
|
children: plans.map((plan, index, self2) => {
|
|
24803
|
-
const planPeriod = showPeriodToggle ? selectedPeriod : plan.
|
|
24962
|
+
const planPeriod = showPeriodToggle ? selectedPeriod : plan.monthlyPrice ? BillingProductPriceInterval.Month : plan.quarterlyPrice ? "quarter" : plan.yearlyPrice ? BillingProductPriceInterval.Year : BillingProductPriceInterval.Month;
|
|
24804
24963
|
return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
24805
24964
|
Plan2,
|
|
24806
24965
|
{
|
|
@@ -24852,7 +25011,7 @@ var PricingTable = (0, import_react59.forwardRef)(({ className, ...rest }, ref)
|
|
|
24852
25011
|
$margin: 0,
|
|
24853
25012
|
$listStyle: "none",
|
|
24854
25013
|
children: addOns.map((addOn, index) => {
|
|
24855
|
-
const addOnPeriod = showPeriodToggle ? selectedPeriod : addOn.
|
|
25014
|
+
const addOnPeriod = showPeriodToggle ? selectedPeriod : addOn.monthlyPrice ? BillingProductPriceInterval.Month : addOn.quarterlyPrice ? "quarter" : addOn.yearlyPrice ? BillingProductPriceInterval.Year : BillingProductPriceInterval.Month;
|
|
24856
25015
|
return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
24857
25016
|
AddOn2,
|
|
24858
25017
|
{
|