@schematichq/schematic-components 1.4.1 → 1.4.3
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 +523 -320
- package/dist/schematic-components.d.ts +112 -0
- package/dist/schematic-components.esm.js +523 -320
- package/package.json +14 -14
|
@@ -283,17 +283,17 @@ var require_debounce = __commonJS({
|
|
|
283
283
|
var FUNC_ERROR_TEXT = "Expected a function";
|
|
284
284
|
var nativeMax = Math.max;
|
|
285
285
|
var nativeMin = Math.min;
|
|
286
|
-
function debounce4(func, wait,
|
|
286
|
+
function debounce4(func, wait, options) {
|
|
287
287
|
var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
288
288
|
if (typeof func != "function") {
|
|
289
289
|
throw new TypeError(FUNC_ERROR_TEXT);
|
|
290
290
|
}
|
|
291
291
|
wait = toNumber(wait) || 0;
|
|
292
|
-
if (isObject2(
|
|
293
|
-
leading = !!
|
|
294
|
-
maxing = "maxWait" in
|
|
295
|
-
maxWait = maxing ? nativeMax(toNumber(
|
|
296
|
-
trailing = "trailing" in
|
|
292
|
+
if (isObject2(options)) {
|
|
293
|
+
leading = !!options.leading;
|
|
294
|
+
maxing = "maxWait" in options;
|
|
295
|
+
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
296
|
+
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
297
297
|
}
|
|
298
298
|
function invokeFunc(time) {
|
|
299
299
|
var args = lastArgs, thisArg = lastThis;
|
|
@@ -1852,7 +1852,7 @@ var HOURS_IN_MS = MINUTES_IN_MS * 60;
|
|
|
1852
1852
|
var DAYS_IN_MS = HOURS_IN_MS * 24;
|
|
1853
1853
|
|
|
1854
1854
|
// src/const/debounce.ts
|
|
1855
|
-
var
|
|
1855
|
+
var DEBOUNCE_SETTINGS = {
|
|
1856
1856
|
leading: true,
|
|
1857
1857
|
trailing: false
|
|
1858
1858
|
};
|
|
@@ -1879,8 +1879,8 @@ function getPriceValue(billingPrice) {
|
|
|
1879
1879
|
const price = typeof billingPrice.priceDecimal === "string" ? Number(billingPrice.priceDecimal) : billingPrice.price;
|
|
1880
1880
|
return price;
|
|
1881
1881
|
}
|
|
1882
|
-
function getPlanPrice(plan, period = "month",
|
|
1883
|
-
const billingPrice =
|
|
1882
|
+
function getPlanPrice(plan, period = "month", options = { useSelectedPeriod: true }) {
|
|
1883
|
+
const billingPrice = options.useSelectedPeriod ? period === "year" ? plan.yearlyPrice : plan.monthlyPrice : plan.yearlyPrice && !plan.monthlyPrice ? plan.yearlyPrice : plan.monthlyPrice;
|
|
1884
1884
|
if (billingPrice) {
|
|
1885
1885
|
return { ...billingPrice, price: getPriceValue(billingPrice) };
|
|
1886
1886
|
}
|
|
@@ -2012,14 +2012,14 @@ function groupPlanCreditGrants(creditGrants) {
|
|
|
2012
2012
|
);
|
|
2013
2013
|
return Object.values(map);
|
|
2014
2014
|
}
|
|
2015
|
-
function groupCreditGrants(creditGrants,
|
|
2015
|
+
function groupCreditGrants(creditGrants, options) {
|
|
2016
2016
|
const today = /* @__PURE__ */ new Date();
|
|
2017
2017
|
const map = creditGrants.reduce(
|
|
2018
2018
|
(acc, grant) => {
|
|
2019
2019
|
const isExpired = !!grant.expiresAt && grant.expiresAt <= today;
|
|
2020
2020
|
const isZeroedOut = !!grant.zeroedOutDate;
|
|
2021
2021
|
if (!isExpired && !isZeroedOut) {
|
|
2022
|
-
const key =
|
|
2022
|
+
const key = options?.groupBy === "bundle" ? grant.billingCreditBundleId || grant.id : options?.groupBy === "credit" ? grant.billingCreditId : grant.id;
|
|
2023
2023
|
const current = acc[key];
|
|
2024
2024
|
acc[key] = {
|
|
2025
2025
|
// credit-specific attributes
|
|
@@ -4079,7 +4079,7 @@ attr.rem = function propAsRem(key, value) {
|
|
|
4079
4079
|
};
|
|
4080
4080
|
|
|
4081
4081
|
// src/hooks/useAvailablePlans.ts
|
|
4082
|
-
function useAvailablePlans(activePeriod,
|
|
4082
|
+
function useAvailablePlans(activePeriod, options = { useSelectedPeriod: true }) {
|
|
4083
4083
|
const { data, settings } = useEmbed();
|
|
4084
4084
|
const getAvailablePeriods = useCallback(() => {
|
|
4085
4085
|
const periods = [];
|
|
@@ -4094,14 +4094,14 @@ function useAvailablePlans(activePeriod, options2 = { useSelectedPeriod: true })
|
|
|
4094
4094
|
const getActivePlans = useCallback(
|
|
4095
4095
|
(plans) => {
|
|
4096
4096
|
const activePlans = settings.mode === "edit" ? plans.slice() : plans.filter((plan) => {
|
|
4097
|
-
if (
|
|
4097
|
+
if (options.useSelectedPeriod) {
|
|
4098
4098
|
return activePeriod === "month" && plan.monthlyPrice || activePeriod === "year" && plan.yearlyPrice || plan.chargeType === ChargeType.oneTime;
|
|
4099
4099
|
}
|
|
4100
4100
|
return plan.monthlyPrice || plan.yearlyPrice || plan.chargeType === ChargeType.oneTime;
|
|
4101
4101
|
});
|
|
4102
4102
|
return activePlans.map((plan) => ({ ...plan, isSelected: false }));
|
|
4103
4103
|
},
|
|
4104
|
-
[activePeriod,
|
|
4104
|
+
[activePeriod, options.useSelectedPeriod, settings.mode]
|
|
4105
4105
|
);
|
|
4106
4106
|
return useMemo(() => {
|
|
4107
4107
|
return {
|
|
@@ -4207,6 +4207,7 @@ var initialContext = {
|
|
|
4207
4207
|
hydrateComponent: stub,
|
|
4208
4208
|
hydrateExternal: stub,
|
|
4209
4209
|
getUpcomingInvoice: stub,
|
|
4210
|
+
getCustomerBalance: stub,
|
|
4210
4211
|
listInvoices: stub,
|
|
4211
4212
|
createSetupIntent: stub,
|
|
4212
4213
|
updatePaymentMethod: stub,
|
|
@@ -4219,7 +4220,8 @@ var initialContext = {
|
|
|
4219
4220
|
setLayout: stub,
|
|
4220
4221
|
setCheckoutState: stub,
|
|
4221
4222
|
setData: stub,
|
|
4222
|
-
updateSettings: stub
|
|
4223
|
+
updateSettings: stub,
|
|
4224
|
+
debug: stub
|
|
4223
4225
|
};
|
|
4224
4226
|
var EmbedContext = createContext(initialContext);
|
|
4225
4227
|
|
|
@@ -4431,14 +4433,14 @@ var consoleLogger = {
|
|
|
4431
4433
|
}
|
|
4432
4434
|
};
|
|
4433
4435
|
var Logger = class _Logger {
|
|
4434
|
-
constructor(concreteLogger,
|
|
4435
|
-
this.init(concreteLogger,
|
|
4436
|
+
constructor(concreteLogger, options = {}) {
|
|
4437
|
+
this.init(concreteLogger, options);
|
|
4436
4438
|
}
|
|
4437
|
-
init(concreteLogger,
|
|
4438
|
-
this.prefix =
|
|
4439
|
+
init(concreteLogger, options = {}) {
|
|
4440
|
+
this.prefix = options.prefix || "i18next:";
|
|
4439
4441
|
this.logger = concreteLogger || consoleLogger;
|
|
4440
|
-
this.options =
|
|
4441
|
-
this.debug =
|
|
4442
|
+
this.options = options;
|
|
4443
|
+
this.debug = options.debug;
|
|
4442
4444
|
}
|
|
4443
4445
|
log(...args) {
|
|
4444
4446
|
return this.forward(args, "log", "", true);
|
|
@@ -4465,10 +4467,10 @@ var Logger = class _Logger {
|
|
|
4465
4467
|
...this.options
|
|
4466
4468
|
});
|
|
4467
4469
|
}
|
|
4468
|
-
clone(
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
return new _Logger(this.logger,
|
|
4470
|
+
clone(options) {
|
|
4471
|
+
options = options || this.options;
|
|
4472
|
+
options.prefix = options.prefix || this.prefix;
|
|
4473
|
+
return new _Logger(this.logger, options);
|
|
4472
4474
|
}
|
|
4473
4475
|
};
|
|
4474
4476
|
var baseLogger = new Logger();
|
|
@@ -4512,13 +4514,13 @@ var EventEmitter = class {
|
|
|
4512
4514
|
}
|
|
4513
4515
|
};
|
|
4514
4516
|
var ResourceStore = class extends EventEmitter {
|
|
4515
|
-
constructor(data,
|
|
4517
|
+
constructor(data, options = {
|
|
4516
4518
|
ns: ["translation"],
|
|
4517
4519
|
defaultNS: "translation"
|
|
4518
4520
|
}) {
|
|
4519
4521
|
super();
|
|
4520
4522
|
this.data = data || {};
|
|
4521
|
-
this.options =
|
|
4523
|
+
this.options = options;
|
|
4522
4524
|
if (this.options.keySeparator === void 0) {
|
|
4523
4525
|
this.options.keySeparator = ".";
|
|
4524
4526
|
}
|
|
@@ -4537,9 +4539,9 @@ var ResourceStore = class extends EventEmitter {
|
|
|
4537
4539
|
this.options.ns.splice(index, 1);
|
|
4538
4540
|
}
|
|
4539
4541
|
}
|
|
4540
|
-
getResource(lng, ns, key,
|
|
4541
|
-
const keySeparator =
|
|
4542
|
-
const ignoreJSONStructure =
|
|
4542
|
+
getResource(lng, ns, key, options = {}) {
|
|
4543
|
+
const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
|
|
4544
|
+
const ignoreJSONStructure = options.ignoreJSONStructure !== void 0 ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
4543
4545
|
let path;
|
|
4544
4546
|
if (lng.indexOf(".") > -1) {
|
|
4545
4547
|
path = lng.split(".");
|
|
@@ -4564,10 +4566,10 @@ var ResourceStore = class extends EventEmitter {
|
|
|
4564
4566
|
if (result || !ignoreJSONStructure || !isString(key)) return result;
|
|
4565
4567
|
return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
|
|
4566
4568
|
}
|
|
4567
|
-
addResource(lng, ns, key, value,
|
|
4569
|
+
addResource(lng, ns, key, value, options = {
|
|
4568
4570
|
silent: false
|
|
4569
4571
|
}) {
|
|
4570
|
-
const keySeparator =
|
|
4572
|
+
const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
|
|
4571
4573
|
let path = [lng, ns];
|
|
4572
4574
|
if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
|
4573
4575
|
if (lng.indexOf(".") > -1) {
|
|
@@ -4577,9 +4579,9 @@ var ResourceStore = class extends EventEmitter {
|
|
|
4577
4579
|
}
|
|
4578
4580
|
this.addNamespaces(ns);
|
|
4579
4581
|
setPath(this.data, path, value);
|
|
4580
|
-
if (!
|
|
4582
|
+
if (!options.silent) this.emit("added", lng, ns, key, value);
|
|
4581
4583
|
}
|
|
4582
|
-
addResources(lng, ns, resources,
|
|
4584
|
+
addResources(lng, ns, resources, options = {
|
|
4583
4585
|
silent: false
|
|
4584
4586
|
}) {
|
|
4585
4587
|
for (const m2 in resources) {
|
|
@@ -4587,9 +4589,9 @@ var ResourceStore = class extends EventEmitter {
|
|
|
4587
4589
|
silent: true
|
|
4588
4590
|
});
|
|
4589
4591
|
}
|
|
4590
|
-
if (!
|
|
4592
|
+
if (!options.silent) this.emit("added", lng, ns, resources);
|
|
4591
4593
|
}
|
|
4592
|
-
addResourceBundle(lng, ns, resources, deep, overwrite,
|
|
4594
|
+
addResourceBundle(lng, ns, resources, deep, overwrite, options = {
|
|
4593
4595
|
silent: false,
|
|
4594
4596
|
skipCopy: false
|
|
4595
4597
|
}) {
|
|
@@ -4602,7 +4604,7 @@ var ResourceStore = class extends EventEmitter {
|
|
|
4602
4604
|
}
|
|
4603
4605
|
this.addNamespaces(ns);
|
|
4604
4606
|
let pack = getPath(this.data, path) || {};
|
|
4605
|
-
if (!
|
|
4607
|
+
if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
|
|
4606
4608
|
if (deep) {
|
|
4607
4609
|
deepExtend(pack, resources, overwrite);
|
|
4608
4610
|
} else {
|
|
@@ -4612,7 +4614,7 @@ var ResourceStore = class extends EventEmitter {
|
|
|
4612
4614
|
};
|
|
4613
4615
|
}
|
|
4614
4616
|
setPath(this.data, path, pack);
|
|
4615
|
-
if (!
|
|
4617
|
+
if (!options.silent) this.emit("added", lng, ns, resources);
|
|
4616
4618
|
}
|
|
4617
4619
|
removeResourceBundle(lng, ns) {
|
|
4618
4620
|
if (this.hasResourceBundle(lng, ns)) {
|
|
@@ -4645,9 +4647,9 @@ var postProcessor = {
|
|
|
4645
4647
|
addPostProcessor(module) {
|
|
4646
4648
|
this.processors[module.name] = module;
|
|
4647
4649
|
},
|
|
4648
|
-
handle(processors, value, key,
|
|
4650
|
+
handle(processors, value, key, options, translator) {
|
|
4649
4651
|
processors.forEach((processor) => {
|
|
4650
|
-
value = this.processors[processor]?.process(value, key,
|
|
4652
|
+
value = this.processors[processor]?.process(value, key, options, translator) ?? value;
|
|
4651
4653
|
});
|
|
4652
4654
|
return value;
|
|
4653
4655
|
}
|
|
@@ -4675,10 +4677,10 @@ function keysFromSelector(selector, opts) {
|
|
|
4675
4677
|
var checkedLoadedFor = {};
|
|
4676
4678
|
var shouldHandleAsObject = (res) => !isString(res) && typeof res !== "boolean" && typeof res !== "number";
|
|
4677
4679
|
var Translator = class _Translator extends EventEmitter {
|
|
4678
|
-
constructor(services,
|
|
4680
|
+
constructor(services, options = {}) {
|
|
4679
4681
|
super();
|
|
4680
4682
|
copy2(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], services, this);
|
|
4681
|
-
this.options =
|
|
4683
|
+
this.options = options;
|
|
4682
4684
|
if (this.options.keySeparator === void 0) {
|
|
4683
4685
|
this.options.keySeparator = ".";
|
|
4684
4686
|
}
|
|
@@ -4728,12 +4730,15 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
4728
4730
|
if (typeof opt !== "object" && this.options.overloadTranslationOptionHandler) {
|
|
4729
4731
|
opt = this.options.overloadTranslationOptionHandler(arguments);
|
|
4730
4732
|
}
|
|
4731
|
-
if (typeof
|
|
4733
|
+
if (typeof opt === "object") opt = {
|
|
4732
4734
|
...opt
|
|
4733
4735
|
};
|
|
4734
4736
|
if (!opt) opt = {};
|
|
4735
4737
|
if (keys == null) return "";
|
|
4736
|
-
if (typeof keys === "function") keys = keysFromSelector(keys,
|
|
4738
|
+
if (typeof keys === "function") keys = keysFromSelector(keys, {
|
|
4739
|
+
...this.options,
|
|
4740
|
+
...opt
|
|
4741
|
+
});
|
|
4737
4742
|
if (!Array.isArray(keys)) keys = [String(keys)];
|
|
4738
4743
|
const returnDetails = opt.returnDetails !== void 0 ? opt.returnDetails : this.options.returnDetails;
|
|
4739
4744
|
const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
|
|
@@ -5054,16 +5059,16 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
5054
5059
|
isValidLookup(res) {
|
|
5055
5060
|
return res !== void 0 && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === "");
|
|
5056
5061
|
}
|
|
5057
|
-
getResource(code, ns, key,
|
|
5058
|
-
if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key,
|
|
5059
|
-
return this.resourceStore.getResource(code, ns, key,
|
|
5062
|
+
getResource(code, ns, key, options = {}) {
|
|
5063
|
+
if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key, options);
|
|
5064
|
+
return this.resourceStore.getResource(code, ns, key, options);
|
|
5060
5065
|
}
|
|
5061
|
-
getUsedParamsDetails(
|
|
5066
|
+
getUsedParamsDetails(options = {}) {
|
|
5062
5067
|
const optionsKeys = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"];
|
|
5063
|
-
const useOptionsReplaceForData =
|
|
5064
|
-
let data = useOptionsReplaceForData ?
|
|
5065
|
-
if (useOptionsReplaceForData && typeof
|
|
5066
|
-
data.count =
|
|
5068
|
+
const useOptionsReplaceForData = options.replace && !isString(options.replace);
|
|
5069
|
+
let data = useOptionsReplaceForData ? options.replace : options;
|
|
5070
|
+
if (useOptionsReplaceForData && typeof options.count !== "undefined") {
|
|
5071
|
+
data.count = options.count;
|
|
5067
5072
|
}
|
|
5068
5073
|
if (this.options.interpolation.defaultVariables) {
|
|
5069
5074
|
data = {
|
|
@@ -5081,10 +5086,10 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
5081
5086
|
}
|
|
5082
5087
|
return data;
|
|
5083
5088
|
}
|
|
5084
|
-
static hasDefaultValue(
|
|
5089
|
+
static hasDefaultValue(options) {
|
|
5085
5090
|
const prefix2 = "defaultValue";
|
|
5086
|
-
for (const option in
|
|
5087
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
5091
|
+
for (const option in options) {
|
|
5092
|
+
if (Object.prototype.hasOwnProperty.call(options, option) && prefix2 === option.substring(0, prefix2.length) && void 0 !== options[option]) {
|
|
5088
5093
|
return true;
|
|
5089
5094
|
}
|
|
5090
5095
|
}
|
|
@@ -5092,8 +5097,8 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
5092
5097
|
}
|
|
5093
5098
|
};
|
|
5094
5099
|
var LanguageUtil = class {
|
|
5095
|
-
constructor(
|
|
5096
|
-
this.options =
|
|
5100
|
+
constructor(options) {
|
|
5101
|
+
this.options = options;
|
|
5097
5102
|
this.supportedLngs = this.options.supportedLngs || false;
|
|
5098
5103
|
this.logger = baseLogger.create("languageUtils");
|
|
5099
5104
|
}
|
|
@@ -5214,9 +5219,9 @@ var dummyRule = {
|
|
|
5214
5219
|
})
|
|
5215
5220
|
};
|
|
5216
5221
|
var PluralResolver = class {
|
|
5217
|
-
constructor(languageUtils,
|
|
5222
|
+
constructor(languageUtils, options = {}) {
|
|
5218
5223
|
this.languageUtils = languageUtils;
|
|
5219
|
-
this.options =
|
|
5224
|
+
this.options = options;
|
|
5220
5225
|
this.logger = baseLogger.create("pluralResolver");
|
|
5221
5226
|
this.pluralRulesCache = {};
|
|
5222
5227
|
}
|
|
@@ -5226,9 +5231,9 @@ var PluralResolver = class {
|
|
|
5226
5231
|
clearCache() {
|
|
5227
5232
|
this.pluralRulesCache = {};
|
|
5228
5233
|
}
|
|
5229
|
-
getRule(code,
|
|
5234
|
+
getRule(code, options = {}) {
|
|
5230
5235
|
const cleanedCode = getCleanedCode(code === "dev" ? "en" : code);
|
|
5231
|
-
const type =
|
|
5236
|
+
const type = options.ordinal ? "ordinal" : "cardinal";
|
|
5232
5237
|
const cacheKey = JSON.stringify({
|
|
5233
5238
|
cleanedCode,
|
|
5234
5239
|
type
|
|
@@ -5248,32 +5253,32 @@ var PluralResolver = class {
|
|
|
5248
5253
|
}
|
|
5249
5254
|
if (!code.match(/-|_/)) return dummyRule;
|
|
5250
5255
|
const lngPart = this.languageUtils.getLanguagePartFromCode(code);
|
|
5251
|
-
rule = this.getRule(lngPart,
|
|
5256
|
+
rule = this.getRule(lngPart, options);
|
|
5252
5257
|
}
|
|
5253
5258
|
this.pluralRulesCache[cacheKey] = rule;
|
|
5254
5259
|
return rule;
|
|
5255
5260
|
}
|
|
5256
|
-
needsPlural(code,
|
|
5257
|
-
let rule = this.getRule(code,
|
|
5258
|
-
if (!rule) rule = this.getRule("dev",
|
|
5261
|
+
needsPlural(code, options = {}) {
|
|
5262
|
+
let rule = this.getRule(code, options);
|
|
5263
|
+
if (!rule) rule = this.getRule("dev", options);
|
|
5259
5264
|
return rule?.resolvedOptions().pluralCategories.length > 1;
|
|
5260
5265
|
}
|
|
5261
|
-
getPluralFormsOfKey(code, key,
|
|
5262
|
-
return this.getSuffixes(code,
|
|
5266
|
+
getPluralFormsOfKey(code, key, options = {}) {
|
|
5267
|
+
return this.getSuffixes(code, options).map((suffix) => `${key}${suffix}`);
|
|
5263
5268
|
}
|
|
5264
|
-
getSuffixes(code,
|
|
5265
|
-
let rule = this.getRule(code,
|
|
5266
|
-
if (!rule) rule = this.getRule("dev",
|
|
5269
|
+
getSuffixes(code, options = {}) {
|
|
5270
|
+
let rule = this.getRule(code, options);
|
|
5271
|
+
if (!rule) rule = this.getRule("dev", options);
|
|
5267
5272
|
if (!rule) return [];
|
|
5268
|
-
return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map((pluralCategory) => `${this.options.prepend}${
|
|
5273
|
+
return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map((pluralCategory) => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${pluralCategory}`);
|
|
5269
5274
|
}
|
|
5270
|
-
getSuffix(code, count,
|
|
5271
|
-
const rule = this.getRule(code,
|
|
5275
|
+
getSuffix(code, count, options = {}) {
|
|
5276
|
+
const rule = this.getRule(code, options);
|
|
5272
5277
|
if (rule) {
|
|
5273
|
-
return `${this.options.prepend}${
|
|
5278
|
+
return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${rule.select(count)}`;
|
|
5274
5279
|
}
|
|
5275
5280
|
this.logger.warn(`no plural rule found for: ${code}`);
|
|
5276
|
-
return this.getSuffix("dev", count,
|
|
5281
|
+
return this.getSuffix("dev", count, options);
|
|
5277
5282
|
}
|
|
5278
5283
|
};
|
|
5279
5284
|
var deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJSONStructure = true) => {
|
|
@@ -5286,14 +5291,14 @@ var deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJS
|
|
|
5286
5291
|
};
|
|
5287
5292
|
var regexSafe = (val) => val.replace(/\$/g, "$$$$");
|
|
5288
5293
|
var Interpolator = class {
|
|
5289
|
-
constructor(
|
|
5294
|
+
constructor(options = {}) {
|
|
5290
5295
|
this.logger = baseLogger.create("interpolator");
|
|
5291
|
-
this.options =
|
|
5292
|
-
this.format =
|
|
5293
|
-
this.init(
|
|
5296
|
+
this.options = options;
|
|
5297
|
+
this.format = options?.interpolation?.format || ((value) => value);
|
|
5298
|
+
this.init(options);
|
|
5294
5299
|
}
|
|
5295
|
-
init(
|
|
5296
|
-
if (!
|
|
5300
|
+
init(options = {}) {
|
|
5301
|
+
if (!options.interpolation) options.interpolation = {
|
|
5297
5302
|
escapeValue: true
|
|
5298
5303
|
};
|
|
5299
5304
|
const {
|
|
@@ -5314,7 +5319,7 @@ var Interpolator = class {
|
|
|
5314
5319
|
nestingOptionsSeparator,
|
|
5315
5320
|
maxReplaces,
|
|
5316
5321
|
alwaysFormat
|
|
5317
|
-
} =
|
|
5322
|
+
} = options.interpolation;
|
|
5318
5323
|
this.escape = escape$1 !== void 0 ? escape$1 : escape;
|
|
5319
5324
|
this.escapeValue = escapeValue !== void 0 ? escapeValue : true;
|
|
5320
5325
|
this.useRawValueToEscape = useRawValueToEscape !== void 0 ? useRawValueToEscape : false;
|
|
@@ -5345,7 +5350,7 @@ var Interpolator = class {
|
|
|
5345
5350
|
this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
|
|
5346
5351
|
this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
|
|
5347
5352
|
}
|
|
5348
|
-
interpolate(str, data, lng,
|
|
5353
|
+
interpolate(str, data, lng, options) {
|
|
5349
5354
|
let match2;
|
|
5350
5355
|
let value;
|
|
5351
5356
|
let replaces;
|
|
@@ -5354,7 +5359,7 @@ var Interpolator = class {
|
|
|
5354
5359
|
if (key.indexOf(this.formatSeparator) < 0) {
|
|
5355
5360
|
const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
|
|
5356
5361
|
return this.alwaysFormat ? this.format(path, void 0, lng, {
|
|
5357
|
-
...
|
|
5362
|
+
...options,
|
|
5358
5363
|
...data,
|
|
5359
5364
|
interpolationkey: key
|
|
5360
5365
|
}) : path;
|
|
@@ -5363,14 +5368,14 @@ var Interpolator = class {
|
|
|
5363
5368
|
const k2 = p2.shift().trim();
|
|
5364
5369
|
const f2 = p2.join(this.formatSeparator).trim();
|
|
5365
5370
|
return this.format(deepFindWithDefaults(data, defaultData, k2, this.options.keySeparator, this.options.ignoreJSONStructure), f2, lng, {
|
|
5366
|
-
...
|
|
5371
|
+
...options,
|
|
5367
5372
|
...data,
|
|
5368
5373
|
interpolationkey: k2
|
|
5369
5374
|
});
|
|
5370
5375
|
};
|
|
5371
5376
|
this.resetRegExp();
|
|
5372
|
-
const missingInterpolationHandler =
|
|
5373
|
-
const skipOnVariables =
|
|
5377
|
+
const missingInterpolationHandler = options?.missingInterpolationHandler || this.options.missingInterpolationHandler;
|
|
5378
|
+
const skipOnVariables = options?.interpolation?.skipOnVariables !== void 0 ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
|
|
5374
5379
|
const todos = [{
|
|
5375
5380
|
regex: this.regexpUnescape,
|
|
5376
5381
|
safeValue: (val) => regexSafe(val)
|
|
@@ -5385,9 +5390,9 @@ var Interpolator = class {
|
|
|
5385
5390
|
value = handleFormat(matchedVar);
|
|
5386
5391
|
if (value === void 0) {
|
|
5387
5392
|
if (typeof missingInterpolationHandler === "function") {
|
|
5388
|
-
const temp = missingInterpolationHandler(str, match2,
|
|
5393
|
+
const temp = missingInterpolationHandler(str, match2, options);
|
|
5389
5394
|
value = isString(temp) ? temp : "";
|
|
5390
|
-
} else if (
|
|
5395
|
+
} else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
|
|
5391
5396
|
value = "";
|
|
5392
5397
|
} else if (skipOnVariables) {
|
|
5393
5398
|
value = match2[0];
|
|
@@ -5415,7 +5420,7 @@ var Interpolator = class {
|
|
|
5415
5420
|
});
|
|
5416
5421
|
return str;
|
|
5417
5422
|
}
|
|
5418
|
-
nest(str, fc,
|
|
5423
|
+
nest(str, fc, options = {}) {
|
|
5419
5424
|
let match2;
|
|
5420
5425
|
let value;
|
|
5421
5426
|
let clonedOptions;
|
|
@@ -5447,7 +5452,7 @@ var Interpolator = class {
|
|
|
5447
5452
|
while (match2 = this.nestingRegexp.exec(str)) {
|
|
5448
5453
|
let formatters = [];
|
|
5449
5454
|
clonedOptions = {
|
|
5450
|
-
...
|
|
5455
|
+
...options
|
|
5451
5456
|
};
|
|
5452
5457
|
clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
|
|
5453
5458
|
clonedOptions.applyPostProcessor = false;
|
|
@@ -5465,8 +5470,8 @@ var Interpolator = class {
|
|
|
5465
5470
|
value = "";
|
|
5466
5471
|
}
|
|
5467
5472
|
if (formatters.length) {
|
|
5468
|
-
value = formatters.reduce((v2, f2) => this.format(v2, f2,
|
|
5469
|
-
...
|
|
5473
|
+
value = formatters.reduce((v2, f2) => this.format(v2, f2, options.lng, {
|
|
5474
|
+
...options,
|
|
5470
5475
|
interpolationkey: match2[1].trim()
|
|
5471
5476
|
}), value.trim());
|
|
5472
5477
|
}
|
|
@@ -5528,16 +5533,16 @@ var createCachedFormatter = (fn) => {
|
|
|
5528
5533
|
};
|
|
5529
5534
|
var createNonCachedFormatter = (fn) => (v2, l2, o2) => fn(getCleanedCode(l2), o2)(v2);
|
|
5530
5535
|
var Formatter = class {
|
|
5531
|
-
constructor(
|
|
5536
|
+
constructor(options = {}) {
|
|
5532
5537
|
this.logger = baseLogger.create("formatter");
|
|
5533
|
-
this.options =
|
|
5534
|
-
this.init(
|
|
5538
|
+
this.options = options;
|
|
5539
|
+
this.init(options);
|
|
5535
5540
|
}
|
|
5536
|
-
init(services,
|
|
5541
|
+
init(services, options = {
|
|
5537
5542
|
interpolation: {}
|
|
5538
5543
|
}) {
|
|
5539
|
-
this.formatSeparator =
|
|
5540
|
-
const cf =
|
|
5544
|
+
this.formatSeparator = options.interpolation.formatSeparator || ",";
|
|
5545
|
+
const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
|
|
5541
5546
|
this.formats = {
|
|
5542
5547
|
number: cf((lng, opt) => {
|
|
5543
5548
|
const formatter = new Intl.NumberFormat(lng, {
|
|
@@ -5578,7 +5583,7 @@ var Formatter = class {
|
|
|
5578
5583
|
addCached(name, fc) {
|
|
5579
5584
|
this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
|
|
5580
5585
|
}
|
|
5581
|
-
format(value, format, lng,
|
|
5586
|
+
format(value, format, lng, options = {}) {
|
|
5582
5587
|
const formats = format.split(this.formatSeparator);
|
|
5583
5588
|
if (formats.length > 1 && formats[0].indexOf("(") > 1 && formats[0].indexOf(")") < 0 && formats.find((f2) => f2.indexOf(")") > -1)) {
|
|
5584
5589
|
const lastIndex = formats.findIndex((f2) => f2.indexOf(")") > -1);
|
|
@@ -5592,11 +5597,11 @@ var Formatter = class {
|
|
|
5592
5597
|
if (this.formats[formatName]) {
|
|
5593
5598
|
let formatted = mem;
|
|
5594
5599
|
try {
|
|
5595
|
-
const valOptions =
|
|
5596
|
-
const l2 = valOptions.locale || valOptions.lng ||
|
|
5600
|
+
const valOptions = options?.formatParams?.[options.interpolationkey] || {};
|
|
5601
|
+
const l2 = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
|
|
5597
5602
|
formatted = this.formats[formatName](mem, l2, {
|
|
5598
5603
|
...formatOptions,
|
|
5599
|
-
...
|
|
5604
|
+
...options,
|
|
5600
5605
|
...valOptions
|
|
5601
5606
|
});
|
|
5602
5607
|
} catch (error) {
|
|
@@ -5618,24 +5623,24 @@ var removePending = (q2, name) => {
|
|
|
5618
5623
|
}
|
|
5619
5624
|
};
|
|
5620
5625
|
var Connector = class extends EventEmitter {
|
|
5621
|
-
constructor(backend, store, services,
|
|
5626
|
+
constructor(backend, store, services, options = {}) {
|
|
5622
5627
|
super();
|
|
5623
5628
|
this.backend = backend;
|
|
5624
5629
|
this.store = store;
|
|
5625
5630
|
this.services = services;
|
|
5626
5631
|
this.languageUtils = services.languageUtils;
|
|
5627
|
-
this.options =
|
|
5632
|
+
this.options = options;
|
|
5628
5633
|
this.logger = baseLogger.create("backendConnector");
|
|
5629
5634
|
this.waitingReads = [];
|
|
5630
|
-
this.maxParallelReads =
|
|
5635
|
+
this.maxParallelReads = options.maxParallelReads || 10;
|
|
5631
5636
|
this.readingCalls = 0;
|
|
5632
|
-
this.maxRetries =
|
|
5633
|
-
this.retryTimeout =
|
|
5637
|
+
this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
|
|
5638
|
+
this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
|
|
5634
5639
|
this.state = {};
|
|
5635
5640
|
this.queue = [];
|
|
5636
|
-
this.backend?.init?.(services,
|
|
5641
|
+
this.backend?.init?.(services, options.backend, options);
|
|
5637
5642
|
}
|
|
5638
|
-
queueLoad(languages, namespaces,
|
|
5643
|
+
queueLoad(languages, namespaces, options, callback) {
|
|
5639
5644
|
const toLoad = {};
|
|
5640
5645
|
const pending = {};
|
|
5641
5646
|
const toLoadLanguages = {};
|
|
@@ -5644,7 +5649,7 @@ var Connector = class extends EventEmitter {
|
|
|
5644
5649
|
let hasAllNamespaces = true;
|
|
5645
5650
|
namespaces.forEach((ns) => {
|
|
5646
5651
|
const name = `${lng}|${ns}`;
|
|
5647
|
-
if (!
|
|
5652
|
+
if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
|
|
5648
5653
|
this.state[name] = 2;
|
|
5649
5654
|
} else if (this.state[name] < 0) ;
|
|
5650
5655
|
else if (this.state[name] === 1) {
|
|
@@ -5757,14 +5762,14 @@ var Connector = class extends EventEmitter {
|
|
|
5757
5762
|
}
|
|
5758
5763
|
return fc(lng, ns, resolver);
|
|
5759
5764
|
}
|
|
5760
|
-
prepareLoading(languages, namespaces,
|
|
5765
|
+
prepareLoading(languages, namespaces, options = {}, callback) {
|
|
5761
5766
|
if (!this.backend) {
|
|
5762
5767
|
this.logger.warn("No backend was added via i18next.use. Will not load resources.");
|
|
5763
5768
|
return callback && callback();
|
|
5764
5769
|
}
|
|
5765
5770
|
if (isString(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
|
|
5766
5771
|
if (isString(namespaces)) namespaces = [namespaces];
|
|
5767
|
-
const toLoad = this.queueLoad(languages, namespaces,
|
|
5772
|
+
const toLoad = this.queueLoad(languages, namespaces, options, callback);
|
|
5768
5773
|
if (!toLoad.toLoad.length) {
|
|
5769
5774
|
if (!toLoad.pending.length) callback();
|
|
5770
5775
|
return null;
|
|
@@ -5791,7 +5796,7 @@ var Connector = class extends EventEmitter {
|
|
|
5791
5796
|
this.loaded(name, err2, data);
|
|
5792
5797
|
});
|
|
5793
5798
|
}
|
|
5794
|
-
saveMissing(languages, namespace, key, fallbackValue, isUpdate,
|
|
5799
|
+
saveMissing(languages, namespace, key, fallbackValue, isUpdate, options = {}, clb = () => {
|
|
5795
5800
|
}) {
|
|
5796
5801
|
if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(namespace)) {
|
|
5797
5802
|
this.logger.warn(`did not save key "${key}" as the namespace "${namespace}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
|
|
@@ -5800,7 +5805,7 @@ var Connector = class extends EventEmitter {
|
|
|
5800
5805
|
if (key === void 0 || key === null || key === "") return;
|
|
5801
5806
|
if (this.backend?.create) {
|
|
5802
5807
|
const opts = {
|
|
5803
|
-
...
|
|
5808
|
+
...options,
|
|
5804
5809
|
isUpdate
|
|
5805
5810
|
};
|
|
5806
5811
|
const fc = this.backend.create.bind(this.backend);
|
|
@@ -5867,9 +5872,9 @@ var get = () => ({
|
|
|
5867
5872
|
if (isString(args[1])) ret.defaultValue = args[1];
|
|
5868
5873
|
if (isString(args[2])) ret.tDescription = args[2];
|
|
5869
5874
|
if (typeof args[2] === "object" || typeof args[3] === "object") {
|
|
5870
|
-
const
|
|
5871
|
-
Object.keys(
|
|
5872
|
-
ret[key] =
|
|
5875
|
+
const options = args[3] || args[2];
|
|
5876
|
+
Object.keys(options).forEach((key) => {
|
|
5877
|
+
ret[key] = options[key];
|
|
5873
5878
|
});
|
|
5874
5879
|
}
|
|
5875
5880
|
return ret;
|
|
@@ -5889,15 +5894,15 @@ var get = () => ({
|
|
|
5889
5894
|
},
|
|
5890
5895
|
cacheInBuiltFormats: true
|
|
5891
5896
|
});
|
|
5892
|
-
var transformOptions = (
|
|
5893
|
-
if (isString(
|
|
5894
|
-
if (isString(
|
|
5895
|
-
if (isString(
|
|
5896
|
-
if (
|
|
5897
|
-
|
|
5897
|
+
var transformOptions = (options) => {
|
|
5898
|
+
if (isString(options.ns)) options.ns = [options.ns];
|
|
5899
|
+
if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
|
|
5900
|
+
if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
|
|
5901
|
+
if (options.supportedLngs?.indexOf?.("cimode") < 0) {
|
|
5902
|
+
options.supportedLngs = options.supportedLngs.concat(["cimode"]);
|
|
5898
5903
|
}
|
|
5899
|
-
if (typeof
|
|
5900
|
-
return
|
|
5904
|
+
if (typeof options.initImmediate === "boolean") options.initAsync = options.initImmediate;
|
|
5905
|
+
return options;
|
|
5901
5906
|
};
|
|
5902
5907
|
var noop = () => {
|
|
5903
5908
|
};
|
|
@@ -5910,53 +5915,53 @@ var bindMemberFunctions = (inst) => {
|
|
|
5910
5915
|
});
|
|
5911
5916
|
};
|
|
5912
5917
|
var I18n = class _I18n extends EventEmitter {
|
|
5913
|
-
constructor(
|
|
5918
|
+
constructor(options = {}, callback) {
|
|
5914
5919
|
super();
|
|
5915
|
-
this.options = transformOptions(
|
|
5920
|
+
this.options = transformOptions(options);
|
|
5916
5921
|
this.services = {};
|
|
5917
5922
|
this.logger = baseLogger;
|
|
5918
5923
|
this.modules = {
|
|
5919
5924
|
external: []
|
|
5920
5925
|
};
|
|
5921
5926
|
bindMemberFunctions(this);
|
|
5922
|
-
if (callback && !this.isInitialized && !
|
|
5927
|
+
if (callback && !this.isInitialized && !options.isClone) {
|
|
5923
5928
|
if (!this.options.initAsync) {
|
|
5924
|
-
this.init(
|
|
5929
|
+
this.init(options, callback);
|
|
5925
5930
|
return this;
|
|
5926
5931
|
}
|
|
5927
5932
|
setTimeout(() => {
|
|
5928
|
-
this.init(
|
|
5933
|
+
this.init(options, callback);
|
|
5929
5934
|
}, 0);
|
|
5930
5935
|
}
|
|
5931
5936
|
}
|
|
5932
|
-
init(
|
|
5937
|
+
init(options = {}, callback) {
|
|
5933
5938
|
this.isInitializing = true;
|
|
5934
|
-
if (typeof
|
|
5935
|
-
callback =
|
|
5936
|
-
|
|
5939
|
+
if (typeof options === "function") {
|
|
5940
|
+
callback = options;
|
|
5941
|
+
options = {};
|
|
5937
5942
|
}
|
|
5938
|
-
if (
|
|
5939
|
-
if (isString(
|
|
5940
|
-
|
|
5941
|
-
} else if (
|
|
5942
|
-
|
|
5943
|
+
if (options.defaultNS == null && options.ns) {
|
|
5944
|
+
if (isString(options.ns)) {
|
|
5945
|
+
options.defaultNS = options.ns;
|
|
5946
|
+
} else if (options.ns.indexOf("translation") < 0) {
|
|
5947
|
+
options.defaultNS = options.ns[0];
|
|
5943
5948
|
}
|
|
5944
5949
|
}
|
|
5945
5950
|
const defOpts = get();
|
|
5946
5951
|
this.options = {
|
|
5947
5952
|
...defOpts,
|
|
5948
5953
|
...this.options,
|
|
5949
|
-
...transformOptions(
|
|
5954
|
+
...transformOptions(options)
|
|
5950
5955
|
};
|
|
5951
5956
|
this.options.interpolation = {
|
|
5952
5957
|
...defOpts.interpolation,
|
|
5953
5958
|
...this.options.interpolation
|
|
5954
5959
|
};
|
|
5955
|
-
if (
|
|
5956
|
-
this.options.userDefinedKeySeparator =
|
|
5960
|
+
if (options.keySeparator !== void 0) {
|
|
5961
|
+
this.options.userDefinedKeySeparator = options.keySeparator;
|
|
5957
5962
|
}
|
|
5958
|
-
if (
|
|
5959
|
-
this.options.userDefinedNsSeparator =
|
|
5963
|
+
if (options.nsSeparator !== void 0) {
|
|
5964
|
+
this.options.userDefinedNsSeparator = options.nsSeparator;
|
|
5960
5965
|
}
|
|
5961
5966
|
const createClassOnDemand = (ClassOrObject) => {
|
|
5962
5967
|
if (!ClassOrObject) return null;
|
|
@@ -6221,8 +6226,18 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
6221
6226
|
const keySeparator = this.options.keySeparator || ".";
|
|
6222
6227
|
let resultKey;
|
|
6223
6228
|
if (o2.keyPrefix && Array.isArray(key)) {
|
|
6224
|
-
resultKey = key.map((k2) =>
|
|
6229
|
+
resultKey = key.map((k2) => {
|
|
6230
|
+
if (typeof k2 === "function") k2 = keysFromSelector(k2, {
|
|
6231
|
+
...this.options,
|
|
6232
|
+
...opts
|
|
6233
|
+
});
|
|
6234
|
+
return `${o2.keyPrefix}${keySeparator}${k2}`;
|
|
6235
|
+
});
|
|
6225
6236
|
} else {
|
|
6237
|
+
if (typeof key === "function") key = keysFromSelector(key, {
|
|
6238
|
+
...this.options,
|
|
6239
|
+
...opts
|
|
6240
|
+
});
|
|
6226
6241
|
resultKey = o2.keyPrefix ? `${o2.keyPrefix}${keySeparator}${key}` : key;
|
|
6227
6242
|
}
|
|
6228
6243
|
return this.t(resultKey, o2);
|
|
@@ -6245,7 +6260,7 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
6245
6260
|
setDefaultNamespace(ns) {
|
|
6246
6261
|
this.options.defaultNS = ns;
|
|
6247
6262
|
}
|
|
6248
|
-
hasLoadedNamespace(ns,
|
|
6263
|
+
hasLoadedNamespace(ns, options = {}) {
|
|
6249
6264
|
if (!this.isInitialized) {
|
|
6250
6265
|
this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages);
|
|
6251
6266
|
return false;
|
|
@@ -6254,7 +6269,7 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
6254
6269
|
this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages);
|
|
6255
6270
|
return false;
|
|
6256
6271
|
}
|
|
6257
|
-
const lng =
|
|
6272
|
+
const lng = options.lng || this.resolvedLanguage || this.languages[0];
|
|
6258
6273
|
const fallbackLng = this.options ? this.options.fallbackLng : false;
|
|
6259
6274
|
const lastLng = this.languages[this.languages.length - 1];
|
|
6260
6275
|
if (lng.toLowerCase() === "cimode") return true;
|
|
@@ -6262,8 +6277,8 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
6262
6277
|
const loadState = this.services.backendConnector.state[`${l2}|${n}`];
|
|
6263
6278
|
return loadState === -1 || loadState === 0 || loadState === 2;
|
|
6264
6279
|
};
|
|
6265
|
-
if (
|
|
6266
|
-
const preResult =
|
|
6280
|
+
if (options.precheck) {
|
|
6281
|
+
const preResult = options.precheck(this, loadNotPending);
|
|
6267
6282
|
if (preResult !== void 0) return preResult;
|
|
6268
6283
|
}
|
|
6269
6284
|
if (this.hasResourceBundle(lng, ns)) return true;
|
|
@@ -6319,22 +6334,22 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
6319
6334
|
if (lng.toLowerCase().indexOf("-latn") > 1) return "ltr";
|
|
6320
6335
|
return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
|
|
6321
6336
|
}
|
|
6322
|
-
static createInstance(
|
|
6323
|
-
return new _I18n(
|
|
6337
|
+
static createInstance(options = {}, callback) {
|
|
6338
|
+
return new _I18n(options, callback);
|
|
6324
6339
|
}
|
|
6325
|
-
cloneInstance(
|
|
6326
|
-
const forkResourceStore =
|
|
6327
|
-
if (forkResourceStore) delete
|
|
6340
|
+
cloneInstance(options = {}, callback = noop) {
|
|
6341
|
+
const forkResourceStore = options.forkResourceStore;
|
|
6342
|
+
if (forkResourceStore) delete options.forkResourceStore;
|
|
6328
6343
|
const mergedOptions = {
|
|
6329
6344
|
...this.options,
|
|
6330
|
-
...
|
|
6345
|
+
...options,
|
|
6331
6346
|
...{
|
|
6332
6347
|
isClone: true
|
|
6333
6348
|
}
|
|
6334
6349
|
};
|
|
6335
6350
|
const clone = new _I18n(mergedOptions);
|
|
6336
|
-
if (
|
|
6337
|
-
clone.logger = clone.logger.clone(
|
|
6351
|
+
if (options.debug !== void 0 || options.prefix !== void 0) {
|
|
6352
|
+
clone.logger = clone.logger.clone(options);
|
|
6338
6353
|
}
|
|
6339
6354
|
const membersToCopy = ["store", "services", "language"];
|
|
6340
6355
|
membersToCopy.forEach((m2) => {
|
|
@@ -6455,7 +6470,7 @@ var loadLanguages2 = (i18n, lng, ns, cb) => {
|
|
|
6455
6470
|
});
|
|
6456
6471
|
i18n.loadLanguages(lng, loadedClb(i18n, cb));
|
|
6457
6472
|
};
|
|
6458
|
-
var hasLoadedNamespace2 = (ns, i18n,
|
|
6473
|
+
var hasLoadedNamespace2 = (ns, i18n, options = {}) => {
|
|
6459
6474
|
if (!i18n.languages || !i18n.languages.length) {
|
|
6460
6475
|
warnOnce(i18n, "NO_LANGUAGES", "i18n.languages were undefined or empty", {
|
|
6461
6476
|
languages: i18n.languages
|
|
@@ -6463,9 +6478,9 @@ var hasLoadedNamespace2 = (ns, i18n, options2 = {}) => {
|
|
|
6463
6478
|
return true;
|
|
6464
6479
|
}
|
|
6465
6480
|
return i18n.hasLoadedNamespace(ns, {
|
|
6466
|
-
lng:
|
|
6481
|
+
lng: options.lng,
|
|
6467
6482
|
precheck: (i18nInstance2, loadNotPending) => {
|
|
6468
|
-
if (
|
|
6483
|
+
if (options.bindI18n && options.bindI18n.indexOf("languageChanging") > -1 && i18nInstance2.services.backendConnector.backend && i18nInstance2.isLanguageChangingTo && !loadNotPending(i18nInstance2.isLanguageChangingTo, ns)) return false;
|
|
6469
6484
|
}
|
|
6470
6485
|
});
|
|
6471
6486
|
};
|
|
@@ -6510,10 +6525,10 @@ var defaultOptions = {
|
|
|
6510
6525
|
useSuspense: true,
|
|
6511
6526
|
unescape
|
|
6512
6527
|
};
|
|
6513
|
-
var setDefaults = (
|
|
6528
|
+
var setDefaults = (options = {}) => {
|
|
6514
6529
|
defaultOptions = {
|
|
6515
6530
|
...defaultOptions,
|
|
6516
|
-
...
|
|
6531
|
+
...options
|
|
6517
6532
|
};
|
|
6518
6533
|
};
|
|
6519
6534
|
var getDefaults = () => defaultOptions;
|
|
@@ -6700,8 +6715,10 @@ var en_default = {
|
|
|
6700
6715
|
"Choose add-on": "Choose add-on",
|
|
6701
6716
|
"Choose plan": "Choose plan",
|
|
6702
6717
|
"Choose your base plan": "Choose your base plan",
|
|
6703
|
-
"
|
|
6718
|
+
"Credit bundles": "Credit bundles",
|
|
6704
6719
|
Credits: "Credits",
|
|
6720
|
+
"Credits in plan": "Credits in plan",
|
|
6721
|
+
"Credits to be applied to future invoices": "Credits to be applied to future invoices",
|
|
6705
6722
|
"Current plan": "Current plan",
|
|
6706
6723
|
"Current usage exceeds the limit of this plan.": "Current usage exceeds the limit of this plan.",
|
|
6707
6724
|
"Currently using": "Currently using {{quantity}} {{unit}}",
|
|
@@ -6752,8 +6769,10 @@ var en_default = {
|
|
|
6752
6769
|
"Please provide an access token.": "Please provide an access token.",
|
|
6753
6770
|
"Powered by": "Powered by",
|
|
6754
6771
|
"Price by unit based on final tier reached.": "Price by unit based on final tier reached.",
|
|
6772
|
+
"Promotional credits": "Promotional credits",
|
|
6755
6773
|
Proration: "Proration",
|
|
6756
6774
|
"Quantity to pay for in advance": "Quantity to pay for in advance",
|
|
6775
|
+
"Remaining balance": "Remaining balance",
|
|
6757
6776
|
"Remove add-on": "Remove add-on",
|
|
6758
6777
|
Resets: "Resets {{date}}",
|
|
6759
6778
|
"Save payment method": "Save payment method",
|
|
@@ -7044,12 +7063,12 @@ var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.ra
|
|
|
7044
7063
|
var native_default = { randomUUID };
|
|
7045
7064
|
|
|
7046
7065
|
// node_modules/uuid/dist/esm-browser/v4.js
|
|
7047
|
-
function v4(
|
|
7048
|
-
if (native_default.randomUUID && !buf && !
|
|
7066
|
+
function v4(options, buf, offset) {
|
|
7067
|
+
if (native_default.randomUUID && !buf && !options) {
|
|
7049
7068
|
return native_default.randomUUID();
|
|
7050
7069
|
}
|
|
7051
|
-
|
|
7052
|
-
const rnds =
|
|
7070
|
+
options = options || {};
|
|
7071
|
+
const rnds = options.random ?? options.rng?.() ?? rng();
|
|
7053
7072
|
if (rnds.length < 16) {
|
|
7054
7073
|
throw new Error("Random bytes length must be >= 16");
|
|
7055
7074
|
}
|
|
@@ -8473,6 +8492,21 @@ function ComponentCapabilitiesFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8473
8492
|
};
|
|
8474
8493
|
}
|
|
8475
8494
|
|
|
8495
|
+
// src/api/checkoutexternal/models/ComponentCheckoutSettings.ts
|
|
8496
|
+
function ComponentCheckoutSettingsFromJSON(json) {
|
|
8497
|
+
return ComponentCheckoutSettingsFromJSONTyped(json, false);
|
|
8498
|
+
}
|
|
8499
|
+
function ComponentCheckoutSettingsFromJSONTyped(json, ignoreDiscriminator) {
|
|
8500
|
+
if (json == null) {
|
|
8501
|
+
return json;
|
|
8502
|
+
}
|
|
8503
|
+
return {
|
|
8504
|
+
collectAddress: json["collect_address"],
|
|
8505
|
+
collectEmail: json["collect_email"],
|
|
8506
|
+
collectPhone: json["collect_phone"]
|
|
8507
|
+
};
|
|
8508
|
+
}
|
|
8509
|
+
|
|
8476
8510
|
// src/api/checkoutexternal/models/PlanDetailResponseData.ts
|
|
8477
8511
|
function PlanDetailResponseDataFromJSON(json) {
|
|
8478
8512
|
return PlanDetailResponseDataFromJSONTyped(json, false);
|
|
@@ -8670,6 +8704,9 @@ function ComponentHydrateResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8670
8704
|
CompatiblePlansFromJSON
|
|
8671
8705
|
),
|
|
8672
8706
|
capabilities: json["capabilities"] == null ? void 0 : ComponentCapabilitiesFromJSON(json["capabilities"]),
|
|
8707
|
+
checkoutSettings: ComponentCheckoutSettingsFromJSON(
|
|
8708
|
+
json["checkout_settings"]
|
|
8709
|
+
),
|
|
8673
8710
|
company: json["company"] == null ? void 0 : CompanyDetailResponseDataFromJSON(json["company"]),
|
|
8674
8711
|
component: json["component"] == null ? void 0 : ComponentResponseDataFromJSON(json["component"]),
|
|
8675
8712
|
creditBundles: json["credit_bundles"].map(
|
|
@@ -10420,18 +10457,18 @@ var EmbedProvider = ({
|
|
|
10420
10457
|
children,
|
|
10421
10458
|
apiKey,
|
|
10422
10459
|
apiConfig,
|
|
10423
|
-
...
|
|
10460
|
+
...options
|
|
10424
10461
|
}) => {
|
|
10425
10462
|
const sessionIdRef = useRef2(v4_default());
|
|
10426
10463
|
const styleRef = useRef2(null);
|
|
10427
|
-
const [state, dispatch] = useReducer(reducer,
|
|
10464
|
+
const [state, dispatch] = useReducer(reducer, options, (opts) => {
|
|
10428
10465
|
const providedState = { settings: opts.settings || {} };
|
|
10429
10466
|
const resolvedState = (0, import_merge2.default)({}, initialState, providedState);
|
|
10430
10467
|
return resolvedState;
|
|
10431
10468
|
});
|
|
10432
10469
|
const customHeaders = useMemo3(
|
|
10433
10470
|
() => ({
|
|
10434
|
-
"X-Schematic-Components-Version": "1.4.
|
|
10471
|
+
"X-Schematic-Components-Version": "1.4.3",
|
|
10435
10472
|
"X-Schematic-Session-ID": sessionIdRef.current
|
|
10436
10473
|
}),
|
|
10437
10474
|
[]
|
|
@@ -10439,11 +10476,11 @@ var EmbedProvider = ({
|
|
|
10439
10476
|
const [api, setApi] = useState2({});
|
|
10440
10477
|
const debug = useCallback3(
|
|
10441
10478
|
(message, ...args) => {
|
|
10442
|
-
if (
|
|
10479
|
+
if (options.debug) {
|
|
10443
10480
|
console.debug(`[Schematic] ${message}`, ...args);
|
|
10444
10481
|
}
|
|
10445
10482
|
},
|
|
10446
|
-
[
|
|
10483
|
+
[options.debug]
|
|
10447
10484
|
);
|
|
10448
10485
|
const hydratePublic = useCallback3(async () => {
|
|
10449
10486
|
dispatch({ type: "HYDRATE_STARTED" });
|
|
@@ -10464,7 +10501,7 @@ var EmbedProvider = ({
|
|
|
10464
10501
|
}
|
|
10465
10502
|
}, [api.public]);
|
|
10466
10503
|
const debouncedHydratePublic = useMemo3(
|
|
10467
|
-
() => (0, import_debounce.default)(hydratePublic, FETCH_DEBOUNCE_TIMEOUT,
|
|
10504
|
+
() => (0, import_debounce.default)(hydratePublic, FETCH_DEBOUNCE_TIMEOUT, DEBOUNCE_SETTINGS),
|
|
10468
10505
|
[hydratePublic]
|
|
10469
10506
|
);
|
|
10470
10507
|
const hydrate = useCallback3(async () => {
|
|
@@ -10486,7 +10523,7 @@ var EmbedProvider = ({
|
|
|
10486
10523
|
}
|
|
10487
10524
|
}, [api.checkout]);
|
|
10488
10525
|
const debouncedHydrate = useMemo3(
|
|
10489
|
-
() => (0, import_debounce.default)(hydrate, FETCH_DEBOUNCE_TIMEOUT,
|
|
10526
|
+
() => (0, import_debounce.default)(hydrate, FETCH_DEBOUNCE_TIMEOUT, DEBOUNCE_SETTINGS),
|
|
10490
10527
|
[hydrate]
|
|
10491
10528
|
);
|
|
10492
10529
|
const hydrateComponent = useCallback3(
|
|
@@ -10513,7 +10550,7 @@ var EmbedProvider = ({
|
|
|
10513
10550
|
[api.checkout]
|
|
10514
10551
|
);
|
|
10515
10552
|
const debouncedHydrateComponent = useMemo3(
|
|
10516
|
-
() => (0, import_debounce.default)(hydrateComponent, FETCH_DEBOUNCE_TIMEOUT,
|
|
10553
|
+
() => (0, import_debounce.default)(hydrateComponent, FETCH_DEBOUNCE_TIMEOUT, DEBOUNCE_SETTINGS),
|
|
10517
10554
|
[hydrateComponent]
|
|
10518
10555
|
);
|
|
10519
10556
|
const hydrateExternal = useCallback3(async function(fn) {
|
|
@@ -10533,14 +10570,14 @@ var EmbedProvider = ({
|
|
|
10533
10570
|
}
|
|
10534
10571
|
}, []);
|
|
10535
10572
|
const debouncedHydrateExternal = useMemo3(
|
|
10536
|
-
() => (0, import_debounce.default)(hydrateExternal, FETCH_DEBOUNCE_TIMEOUT,
|
|
10573
|
+
() => (0, import_debounce.default)(hydrateExternal, FETCH_DEBOUNCE_TIMEOUT, DEBOUNCE_SETTINGS),
|
|
10537
10574
|
[hydrateExternal]
|
|
10538
10575
|
);
|
|
10539
10576
|
const createSetupIntent = useCallback3(async () => {
|
|
10540
10577
|
return api.checkout?.createSetupIntent();
|
|
10541
10578
|
}, [api.checkout]);
|
|
10542
10579
|
const debouncedCreateSetupIntent = useMemo3(
|
|
10543
|
-
() => (0, import_debounce.default)(createSetupIntent, FETCH_DEBOUNCE_TIMEOUT,
|
|
10580
|
+
() => (0, import_debounce.default)(createSetupIntent, FETCH_DEBOUNCE_TIMEOUT, DEBOUNCE_SETTINGS),
|
|
10544
10581
|
[createSetupIntent]
|
|
10545
10582
|
);
|
|
10546
10583
|
const updatePaymentMethod = useCallback3(
|
|
@@ -10559,7 +10596,7 @@ var EmbedProvider = ({
|
|
|
10559
10596
|
[api.checkout]
|
|
10560
10597
|
);
|
|
10561
10598
|
const debouncedUpdatePaymentMethod = useMemo3(
|
|
10562
|
-
() => (0, import_debounce.default)(updatePaymentMethod, FETCH_DEBOUNCE_TIMEOUT,
|
|
10599
|
+
() => (0, import_debounce.default)(updatePaymentMethod, FETCH_DEBOUNCE_TIMEOUT, DEBOUNCE_SETTINGS),
|
|
10563
10600
|
[updatePaymentMethod]
|
|
10564
10601
|
);
|
|
10565
10602
|
const deletePaymentMethod = useCallback3(
|
|
@@ -10578,7 +10615,7 @@ var EmbedProvider = ({
|
|
|
10578
10615
|
[api.checkout]
|
|
10579
10616
|
);
|
|
10580
10617
|
const debouncedDeletePaymentMethod = useMemo3(
|
|
10581
|
-
() => (0, import_debounce.default)(deletePaymentMethod, FETCH_DEBOUNCE_TIMEOUT,
|
|
10618
|
+
() => (0, import_debounce.default)(deletePaymentMethod, FETCH_DEBOUNCE_TIMEOUT, DEBOUNCE_SETTINGS),
|
|
10582
10619
|
[deletePaymentMethod]
|
|
10583
10620
|
);
|
|
10584
10621
|
const checkout = useCallback3(
|
|
@@ -10597,7 +10634,7 @@ var EmbedProvider = ({
|
|
|
10597
10634
|
[api.checkout]
|
|
10598
10635
|
);
|
|
10599
10636
|
const debouncedCheckout = useMemo3(
|
|
10600
|
-
() => (0, import_debounce.default)(checkout, FETCH_DEBOUNCE_TIMEOUT,
|
|
10637
|
+
() => (0, import_debounce.default)(checkout, FETCH_DEBOUNCE_TIMEOUT, DEBOUNCE_SETTINGS),
|
|
10601
10638
|
[checkout]
|
|
10602
10639
|
);
|
|
10603
10640
|
const previewCheckout = useCallback3(
|
|
@@ -10607,7 +10644,12 @@ var EmbedProvider = ({
|
|
|
10607
10644
|
[api.checkout]
|
|
10608
10645
|
);
|
|
10609
10646
|
const debouncedPreviewCheckout = useMemo3(
|
|
10610
|
-
() => (0, import_debounce.default)(previewCheckout, FETCH_DEBOUNCE_TIMEOUT,
|
|
10647
|
+
() => (0, import_debounce.default)(previewCheckout, FETCH_DEBOUNCE_TIMEOUT, {
|
|
10648
|
+
// invoke immediately for minimal latency
|
|
10649
|
+
leading: true,
|
|
10650
|
+
// but also ensure latest data is fetched
|
|
10651
|
+
trailing: true
|
|
10652
|
+
}),
|
|
10611
10653
|
[previewCheckout]
|
|
10612
10654
|
);
|
|
10613
10655
|
const unsubscribe = useCallback3(async () => {
|
|
@@ -10621,7 +10663,7 @@ var EmbedProvider = ({
|
|
|
10621
10663
|
return response;
|
|
10622
10664
|
}, [api.checkout]);
|
|
10623
10665
|
const debouncedUnsubscribe = useMemo3(
|
|
10624
|
-
() => (0, import_debounce.default)(unsubscribe, FETCH_DEBOUNCE_TIMEOUT,
|
|
10666
|
+
() => (0, import_debounce.default)(unsubscribe, FETCH_DEBOUNCE_TIMEOUT, DEBOUNCE_SETTINGS),
|
|
10625
10667
|
[unsubscribe]
|
|
10626
10668
|
);
|
|
10627
10669
|
const getUpcomingInvoice = useCallback3(
|
|
@@ -10633,19 +10675,30 @@ var EmbedProvider = ({
|
|
|
10633
10675
|
[api.checkout]
|
|
10634
10676
|
);
|
|
10635
10677
|
const debouncedGetUpcomingInvoice = useMemo3(
|
|
10636
|
-
() => (0, import_debounce.default)(getUpcomingInvoice, FETCH_DEBOUNCE_TIMEOUT,
|
|
10678
|
+
() => (0, import_debounce.default)(getUpcomingInvoice, FETCH_DEBOUNCE_TIMEOUT, DEBOUNCE_SETTINGS),
|
|
10637
10679
|
[getUpcomingInvoice]
|
|
10638
10680
|
);
|
|
10681
|
+
const getCustomerBalance = useCallback3(async () => {
|
|
10682
|
+
return api.checkout?.fetchCustomerBalance();
|
|
10683
|
+
}, [api.checkout]);
|
|
10684
|
+
const debouncedGetCustomerBalance = useMemo3(
|
|
10685
|
+
() => (0, import_debounce.default)(getCustomerBalance, FETCH_DEBOUNCE_TIMEOUT, DEBOUNCE_SETTINGS),
|
|
10686
|
+
[getCustomerBalance]
|
|
10687
|
+
);
|
|
10639
10688
|
const listInvoices = useCallback3(async () => {
|
|
10640
10689
|
return api.checkout?.listInvoices();
|
|
10641
10690
|
}, [api.checkout]);
|
|
10642
10691
|
const debouncedListInvoices = useMemo3(
|
|
10643
|
-
() => (0, import_debounce.default)(listInvoices, FETCH_DEBOUNCE_TIMEOUT,
|
|
10692
|
+
() => (0, import_debounce.default)(listInvoices, FETCH_DEBOUNCE_TIMEOUT, DEBOUNCE_SETTINGS),
|
|
10644
10693
|
[listInvoices]
|
|
10645
10694
|
);
|
|
10646
|
-
const setError = useCallback3(
|
|
10647
|
-
|
|
10648
|
-
|
|
10695
|
+
const setError = useCallback3(
|
|
10696
|
+
(error) => {
|
|
10697
|
+
debug(error.message);
|
|
10698
|
+
dispatch({ type: "ERROR", error });
|
|
10699
|
+
},
|
|
10700
|
+
[debug]
|
|
10701
|
+
);
|
|
10649
10702
|
const setAccessToken = useCallback3((token2) => {
|
|
10650
10703
|
dispatch({ type: "SET_ACCESS_TOKEN", token: token2 });
|
|
10651
10704
|
}, []);
|
|
@@ -10653,8 +10706,8 @@ var EmbedProvider = ({
|
|
|
10653
10706
|
dispatch({ type: "SET_DATA", data });
|
|
10654
10707
|
}, []);
|
|
10655
10708
|
const updateSettings = useCallback3(
|
|
10656
|
-
(settings = {},
|
|
10657
|
-
dispatch({ type: "UPDATE_SETTINGS", settings, update:
|
|
10709
|
+
(settings = {}, options2) => {
|
|
10710
|
+
dispatch({ type: "UPDATE_SETTINGS", settings, update: options2?.update });
|
|
10658
10711
|
},
|
|
10659
10712
|
[]
|
|
10660
10713
|
);
|
|
@@ -10670,13 +10723,13 @@ var EmbedProvider = ({
|
|
|
10670
10723
|
);
|
|
10671
10724
|
if (element) {
|
|
10672
10725
|
styleRef.current = element;
|
|
10673
|
-
|
|
10726
|
+
} else {
|
|
10727
|
+
const style = document.createElement("link");
|
|
10728
|
+
style.id = "schematic-fonts";
|
|
10729
|
+
style.rel = "stylesheet";
|
|
10730
|
+
document.head.appendChild(style);
|
|
10731
|
+
styleRef.current = style;
|
|
10674
10732
|
}
|
|
10675
|
-
const style = document.createElement("link");
|
|
10676
|
-
style.id = "schematic-fonts";
|
|
10677
|
-
style.rel = "stylesheet";
|
|
10678
|
-
document.head.appendChild(style);
|
|
10679
|
-
styleRef.current = style;
|
|
10680
10733
|
const darkModeQuery = matchMedia("(prefers-color-scheme: dark)");
|
|
10681
10734
|
const colorMode = darkModeQuery.matches ? "dark" : "light";
|
|
10682
10735
|
dispatch({
|
|
@@ -10687,13 +10740,17 @@ var EmbedProvider = ({
|
|
|
10687
10740
|
}
|
|
10688
10741
|
}
|
|
10689
10742
|
});
|
|
10690
|
-
|
|
10743
|
+
function darkModeQueryHandler(event) {
|
|
10691
10744
|
const newColorMode = event.matches ? "dark" : "light";
|
|
10692
10745
|
dispatch({
|
|
10693
10746
|
type: "UPDATE_SETTINGS",
|
|
10694
10747
|
settings: { theme: { colorMode: newColorMode } }
|
|
10695
10748
|
});
|
|
10696
|
-
}
|
|
10749
|
+
}
|
|
10750
|
+
darkModeQuery.addEventListener("change", darkModeQueryHandler);
|
|
10751
|
+
return () => {
|
|
10752
|
+
darkModeQuery.removeEventListener("change", darkModeQueryHandler);
|
|
10753
|
+
};
|
|
10697
10754
|
}, []);
|
|
10698
10755
|
useEffect2(() => {
|
|
10699
10756
|
const fontSet = /* @__PURE__ */ new Set([]);
|
|
@@ -10740,23 +10797,18 @@ var EmbedProvider = ({
|
|
|
10740
10797
|
}
|
|
10741
10798
|
}, [state.accessToken, apiConfig, customHeaders]);
|
|
10742
10799
|
useEffect2(() => {
|
|
10743
|
-
|
|
10744
|
-
debug(state.error.message);
|
|
10745
|
-
}
|
|
10746
|
-
}, [debug, state.error]);
|
|
10747
|
-
useEffect2(() => {
|
|
10748
|
-
const providedSettings = { ...options2.settings || {} };
|
|
10800
|
+
const providedSettings = { ...options.settings || {} };
|
|
10749
10801
|
updateSettings(providedSettings, { update: false });
|
|
10750
|
-
}, [
|
|
10802
|
+
}, [options.settings, updateSettings]);
|
|
10751
10803
|
useEffect2(() => {
|
|
10752
|
-
|
|
10804
|
+
function planChangedHandler(event) {
|
|
10753
10805
|
if (event instanceof CustomEvent) {
|
|
10754
10806
|
debug("plan changed", event.detail);
|
|
10755
10807
|
}
|
|
10756
|
-
}
|
|
10757
|
-
window.addEventListener("plan-changed",
|
|
10808
|
+
}
|
|
10809
|
+
window.addEventListener("plan-changed", planChangedHandler);
|
|
10758
10810
|
return () => {
|
|
10759
|
-
window.removeEventListener("plan-changed",
|
|
10811
|
+
window.removeEventListener("plan-changed", planChangedHandler);
|
|
10760
10812
|
};
|
|
10761
10813
|
}, [debug]);
|
|
10762
10814
|
return /* @__PURE__ */ jsx(
|
|
@@ -10781,13 +10833,15 @@ var EmbedProvider = ({
|
|
|
10781
10833
|
previewCheckout: debouncedPreviewCheckout,
|
|
10782
10834
|
unsubscribe: debouncedUnsubscribe,
|
|
10783
10835
|
getUpcomingInvoice: debouncedGetUpcomingInvoice,
|
|
10836
|
+
getCustomerBalance: debouncedGetCustomerBalance,
|
|
10784
10837
|
listInvoices: debouncedListInvoices,
|
|
10785
10838
|
setError,
|
|
10786
10839
|
setAccessToken,
|
|
10787
10840
|
setLayout,
|
|
10788
10841
|
setCheckoutState,
|
|
10789
10842
|
setData,
|
|
10790
|
-
updateSettings
|
|
10843
|
+
updateSettings,
|
|
10844
|
+
debug
|
|
10791
10845
|
},
|
|
10792
10846
|
children: /* @__PURE__ */ jsxs(ot, { theme: state.settings.theme, children: [
|
|
10793
10847
|
/* @__PURE__ */ jsx(IconStyles, {}),
|
|
@@ -12440,6 +12494,7 @@ var Sidebar = ({
|
|
|
12440
12494
|
addOns,
|
|
12441
12495
|
creditBundles = [],
|
|
12442
12496
|
usageBasedEntitlements,
|
|
12497
|
+
addOnUsageBasedEntitlements = [],
|
|
12443
12498
|
charges,
|
|
12444
12499
|
checkoutRef,
|
|
12445
12500
|
checkoutStage,
|
|
@@ -12624,6 +12679,35 @@ var Sidebar = ({
|
|
|
12624
12679
|
}
|
|
12625
12680
|
setError(void 0);
|
|
12626
12681
|
setIsLoading(true);
|
|
12682
|
+
const planPayInAdvance = payInAdvanceEntitlements.reduce(
|
|
12683
|
+
(acc, { meteredMonthlyPrice, meteredYearlyPrice, quantity }) => {
|
|
12684
|
+
const priceId2 = (planPeriod === "year" ? meteredYearlyPrice : meteredMonthlyPrice)?.priceId;
|
|
12685
|
+
if (priceId2) {
|
|
12686
|
+
acc.push({
|
|
12687
|
+
priceId: priceId2,
|
|
12688
|
+
quantity
|
|
12689
|
+
});
|
|
12690
|
+
}
|
|
12691
|
+
return acc;
|
|
12692
|
+
},
|
|
12693
|
+
[]
|
|
12694
|
+
);
|
|
12695
|
+
const addOnPayInAdvance = addOnUsageBasedEntitlements.filter(
|
|
12696
|
+
(entitlement) => entitlement.priceBehavior === "pay_in_advance" /* PayInAdvance */
|
|
12697
|
+
).reduce(
|
|
12698
|
+
(acc, { meteredMonthlyPrice, meteredYearlyPrice, quantity }) => {
|
|
12699
|
+
const priceId2 = (planPeriod === "year" ? meteredYearlyPrice : meteredMonthlyPrice)?.priceId;
|
|
12700
|
+
if (priceId2) {
|
|
12701
|
+
acc.push({
|
|
12702
|
+
priceId: priceId2,
|
|
12703
|
+
quantity
|
|
12704
|
+
});
|
|
12705
|
+
}
|
|
12706
|
+
return acc;
|
|
12707
|
+
},
|
|
12708
|
+
[]
|
|
12709
|
+
);
|
|
12710
|
+
const allPayInAdvance = [...planPayInAdvance, ...addOnPayInAdvance];
|
|
12627
12711
|
await checkout({
|
|
12628
12712
|
newPlanId: planId,
|
|
12629
12713
|
newPriceId: priceId,
|
|
@@ -12639,19 +12723,7 @@ var Sidebar = ({
|
|
|
12639
12723
|
}
|
|
12640
12724
|
return acc;
|
|
12641
12725
|
}, []),
|
|
12642
|
-
payInAdvance:
|
|
12643
|
-
(acc, { meteredMonthlyPrice, meteredYearlyPrice, quantity }) => {
|
|
12644
|
-
const priceId2 = (planPeriod === "year" ? meteredYearlyPrice : meteredMonthlyPrice)?.priceId;
|
|
12645
|
-
if (priceId2) {
|
|
12646
|
-
acc.push({
|
|
12647
|
-
priceId: priceId2,
|
|
12648
|
-
quantity
|
|
12649
|
-
});
|
|
12650
|
-
}
|
|
12651
|
-
return acc;
|
|
12652
|
-
},
|
|
12653
|
-
[]
|
|
12654
|
-
),
|
|
12726
|
+
payInAdvance: allPayInAdvance,
|
|
12655
12727
|
creditBundles: creditBundles.reduce(
|
|
12656
12728
|
(acc, { id, count }) => {
|
|
12657
12729
|
if (count > 0) {
|
|
@@ -12689,6 +12761,7 @@ var Sidebar = ({
|
|
|
12689
12761
|
setIsLoading,
|
|
12690
12762
|
setLayout,
|
|
12691
12763
|
payInAdvanceEntitlements,
|
|
12764
|
+
addOnUsageBasedEntitlements,
|
|
12692
12765
|
willTrialWithoutPaymentMethod,
|
|
12693
12766
|
promoCode
|
|
12694
12767
|
]);
|
|
@@ -14384,6 +14457,12 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14384
14457
|
),
|
|
14385
14458
|
[usageBasedEntitlements]
|
|
14386
14459
|
);
|
|
14460
|
+
const addOnPayInAdvanceEntitlements = useMemo9(
|
|
14461
|
+
() => addOnUsageBasedEntitlements.filter(
|
|
14462
|
+
(entitlement) => entitlement.priceBehavior === "pay_in_advance" /* PayInAdvance */
|
|
14463
|
+
),
|
|
14464
|
+
[addOnUsageBasedEntitlements]
|
|
14465
|
+
);
|
|
14387
14466
|
const [promoCode, setPromoCode] = useState9(null);
|
|
14388
14467
|
const [isPaymentMethodRequired, setIsPaymentMethodRequired] = useState9(false);
|
|
14389
14468
|
const willTrialWithoutPaymentMethod = useMemo9(
|
|
@@ -14607,11 +14686,12 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14607
14686
|
const entitlements = plan.entitlements.reduce(
|
|
14608
14687
|
(acc, entitlement) => {
|
|
14609
14688
|
if (entitlement.priceBehavior && (period === "month" && entitlement.meteredMonthlyPrice || period === "year" && entitlement.meteredYearlyPrice)) {
|
|
14689
|
+
const allocation = entitlement.valueNumeric || 0;
|
|
14610
14690
|
acc.push({
|
|
14611
14691
|
...entitlement,
|
|
14612
|
-
allocation
|
|
14692
|
+
allocation,
|
|
14613
14693
|
usage: 0,
|
|
14614
|
-
quantity:
|
|
14694
|
+
quantity: allocation
|
|
14615
14695
|
});
|
|
14616
14696
|
}
|
|
14617
14697
|
return acc;
|
|
@@ -14678,7 +14758,10 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14678
14758
|
}))
|
|
14679
14759
|
);
|
|
14680
14760
|
setAddOnUsageBasedEntitlements(updatedAddOnEntitlements);
|
|
14681
|
-
handlePreviewCheckout({
|
|
14761
|
+
handlePreviewCheckout({
|
|
14762
|
+
addOns: updated,
|
|
14763
|
+
addOnPayInAdvanceEntitlements: updatedAddOnEntitlements
|
|
14764
|
+
});
|
|
14682
14765
|
return updated;
|
|
14683
14766
|
});
|
|
14684
14767
|
},
|
|
@@ -14924,7 +15007,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14924
15007
|
isLoading,
|
|
14925
15008
|
period: planPeriod,
|
|
14926
15009
|
selectedPlan,
|
|
14927
|
-
entitlements:
|
|
15010
|
+
entitlements: addOnPayInAdvanceEntitlements,
|
|
14928
15011
|
updateQuantity: updateAddOnEntitlementQuantity
|
|
14929
15012
|
}
|
|
14930
15013
|
) : checkoutStage === "credits" ? /* @__PURE__ */ jsx20(
|
|
@@ -14952,6 +15035,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14952
15035
|
selectedPlan,
|
|
14953
15036
|
addOns,
|
|
14954
15037
|
usageBasedEntitlements,
|
|
15038
|
+
addOnUsageBasedEntitlements,
|
|
14955
15039
|
creditBundles,
|
|
14956
15040
|
charges,
|
|
14957
15041
|
checkoutRef,
|
|
@@ -15077,7 +15161,7 @@ var PaymentForm = ({ onConfirm }) => {
|
|
|
15077
15161
|
import { useMemo as useMemo10 } from "react";
|
|
15078
15162
|
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
15079
15163
|
var PeriodToggle = ({
|
|
15080
|
-
options
|
|
15164
|
+
options,
|
|
15081
15165
|
selectedOption,
|
|
15082
15166
|
selectedPlan,
|
|
15083
15167
|
onSelect
|
|
@@ -15110,7 +15194,7 @@ var PeriodToggle = ({
|
|
|
15110
15194
|
$width: "fit-content"
|
|
15111
15195
|
}
|
|
15112
15196
|
},
|
|
15113
|
-
children:
|
|
15197
|
+
children: options.map((option) => {
|
|
15114
15198
|
const element = /* @__PURE__ */ jsx23(
|
|
15115
15199
|
Flex,
|
|
15116
15200
|
{
|
|
@@ -16162,8 +16246,8 @@ function resolveDesignProps3(props) {
|
|
|
16162
16246
|
}
|
|
16163
16247
|
};
|
|
16164
16248
|
}
|
|
16165
|
-
function formatInvoices(invoices,
|
|
16166
|
-
const { hideUpcoming = true } =
|
|
16249
|
+
function formatInvoices(invoices, options) {
|
|
16250
|
+
const { hideUpcoming = true } = options || {};
|
|
16167
16251
|
const now = /* @__PURE__ */ new Date();
|
|
16168
16252
|
return (invoices || []).filter(({ dueDate }) => !hideUpcoming || dueDate && +dueDate <= +now).sort((a2, b2) => a2.dueDate && b2.dueDate ? +b2.dueDate - +a2.dueDate : 1).map(({ amountDue, dueDate, url, currency }) => ({
|
|
16169
16253
|
amount: formatCurrency(amountDue, currency),
|
|
@@ -17084,7 +17168,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
|
17084
17168
|
}
|
|
17085
17169
|
stripe._registerWrapper({
|
|
17086
17170
|
name: "stripe-js",
|
|
17087
|
-
version: "7.
|
|
17171
|
+
version: "7.9.0",
|
|
17088
17172
|
startTime
|
|
17089
17173
|
});
|
|
17090
17174
|
};
|
|
@@ -17159,7 +17243,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
|
|
|
17159
17243
|
var version = runtimeVersionToUrlVersion(maybeStripe.version);
|
|
17160
17244
|
var expectedVersion = RELEASE_TRAIN;
|
|
17161
17245
|
if (isTestKey && version !== expectedVersion) {
|
|
17162
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.
|
|
17246
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.9.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
17163
17247
|
}
|
|
17164
17248
|
var stripe = maybeStripe.apply(void 0, args);
|
|
17165
17249
|
registerWrapper(stripe, startTime);
|
|
@@ -17697,11 +17781,29 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
|
|
|
17697
17781
|
featureUsage: featureUsage2,
|
|
17698
17782
|
trialPaymentMethodRequired: trialPaymentMethodRequired2
|
|
17699
17783
|
} = data;
|
|
17784
|
+
const creditGroups2 = groupCreditGrants(creditGrants, {
|
|
17785
|
+
groupBy: "bundle"
|
|
17786
|
+
}).reduce(
|
|
17787
|
+
(acc, grant) => {
|
|
17788
|
+
switch (grant.grantReason) {
|
|
17789
|
+
case "plan" /* Plan */:
|
|
17790
|
+
acc.plan.push(grant);
|
|
17791
|
+
break;
|
|
17792
|
+
case "purchased" /* Purchased */:
|
|
17793
|
+
acc.bundles.push(grant);
|
|
17794
|
+
break;
|
|
17795
|
+
case "free" /* Free */:
|
|
17796
|
+
acc.promotional.push(grant);
|
|
17797
|
+
}
|
|
17798
|
+
return acc;
|
|
17799
|
+
},
|
|
17800
|
+
{ plan: [], bundles: [], promotional: [] }
|
|
17801
|
+
);
|
|
17700
17802
|
return {
|
|
17701
17803
|
currentPlan: company?.plan,
|
|
17702
17804
|
currentAddOns: company?.addOns || [],
|
|
17703
17805
|
creditBundles: creditBundles2,
|
|
17704
|
-
creditGroups:
|
|
17806
|
+
creditGroups: creditGroups2,
|
|
17705
17807
|
billingSubscription: company?.billingSubscription,
|
|
17706
17808
|
canCheckout: capabilities?.checkout ?? true,
|
|
17707
17809
|
defaultPlan: defaultPlan2,
|
|
@@ -17713,7 +17815,7 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
|
|
|
17713
17815
|
currentPlan: void 0,
|
|
17714
17816
|
currentAddOns: [],
|
|
17715
17817
|
creditBundles: [],
|
|
17716
|
-
creditGroups: [],
|
|
17818
|
+
creditGroups: { plan: [], bundles: [], promotional: [] },
|
|
17717
17819
|
billingSubscription: void 0,
|
|
17718
17820
|
canCheckout: false,
|
|
17719
17821
|
defaultPlan: void 0,
|
|
@@ -17870,77 +17972,151 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
|
|
|
17870
17972
|
);
|
|
17871
17973
|
}) })
|
|
17872
17974
|
] }),
|
|
17873
|
-
props.addOns.isVisible && creditGroups.length > 0 && /* @__PURE__ */ jsxs34(Flex, { $flexDirection: "column", $gap: "0.5rem", children: [
|
|
17975
|
+
props.addOns.isVisible && creditGroups.plan.length > 0 && /* @__PURE__ */ jsxs34(Flex, { $flexDirection: "column", $gap: "0.5rem", children: [
|
|
17874
17976
|
props.addOns.showLabel && /* @__PURE__ */ jsx42(
|
|
17875
17977
|
Text,
|
|
17876
17978
|
{
|
|
17877
17979
|
$color: isLightBackground ? darken(settings.theme.card.background, 0.46) : lighten(settings.theme.card.background, 0.46),
|
|
17878
17980
|
$leading: 1,
|
|
17879
|
-
children: t2("Credits")
|
|
17981
|
+
children: t2("Credits in plan")
|
|
17880
17982
|
}
|
|
17881
17983
|
),
|
|
17882
|
-
/* @__PURE__ */ jsx42(Flex, { $flexDirection: "column", $gap: "1rem", children: creditGroups.
|
|
17883
|
-
|
|
17884
|
-
|
|
17885
|
-
|
|
17886
|
-
|
|
17887
|
-
|
|
17888
|
-
|
|
17889
|
-
|
|
17890
|
-
|
|
17891
|
-
|
|
17892
|
-
|
|
17893
|
-
|
|
17894
|
-
|
|
17895
|
-
|
|
17896
|
-
|
|
17897
|
-
|
|
17984
|
+
/* @__PURE__ */ jsx42(Flex, { $flexDirection: "column", $gap: "1rem", children: creditGroups.plan.map((group, groupIndex) => {
|
|
17985
|
+
return /* @__PURE__ */ jsxs34(
|
|
17986
|
+
Flex,
|
|
17987
|
+
{
|
|
17988
|
+
$justifyContent: "space-between",
|
|
17989
|
+
$alignItems: "center",
|
|
17990
|
+
$flexWrap: "wrap",
|
|
17991
|
+
$gap: "0.5rem",
|
|
17992
|
+
children: [
|
|
17993
|
+
/* @__PURE__ */ jsxs34(Text, { display: props.addOns.fontStyle, children: [
|
|
17994
|
+
group.quantity,
|
|
17995
|
+
" ",
|
|
17996
|
+
getFeatureName(group, group.quantity),
|
|
17997
|
+
" ",
|
|
17998
|
+
subscriptionInterval && /* @__PURE__ */ jsxs34(Fragment20, { children: [
|
|
17999
|
+
t2("per"),
|
|
18000
|
+
" ",
|
|
18001
|
+
t2(subscriptionInterval)
|
|
18002
|
+
] })
|
|
18003
|
+
] }),
|
|
18004
|
+
group.total.used > 0 && /* @__PURE__ */ jsxs34(
|
|
18005
|
+
Text,
|
|
18006
|
+
{
|
|
18007
|
+
style: { opacity: 0.54 },
|
|
18008
|
+
$size: 0.875 * settings.theme.typography.text.fontSize,
|
|
18009
|
+
$color: settings.theme.typography.text.color,
|
|
18010
|
+
children: [
|
|
18011
|
+
group.total.used,
|
|
17898
18012
|
" ",
|
|
17899
|
-
|
|
17900
|
-
|
|
17901
|
-
|
|
17902
|
-
|
|
17903
|
-
|
|
17904
|
-
|
|
17905
|
-
|
|
17906
|
-
|
|
17907
|
-
|
|
17908
|
-
|
|
17909
|
-
|
|
17910
|
-
|
|
17911
|
-
|
|
17912
|
-
|
|
17913
|
-
|
|
18013
|
+
t2("used")
|
|
18014
|
+
]
|
|
18015
|
+
}
|
|
18016
|
+
)
|
|
18017
|
+
]
|
|
18018
|
+
},
|
|
18019
|
+
groupIndex
|
|
18020
|
+
);
|
|
18021
|
+
}) })
|
|
18022
|
+
] }),
|
|
18023
|
+
props.addOns.isVisible && creditGroups.bundles.length > 0 && /* @__PURE__ */ jsxs34(Flex, { $flexDirection: "column", $gap: "0.5rem", children: [
|
|
18024
|
+
props.addOns.showLabel && /* @__PURE__ */ jsx42(
|
|
18025
|
+
Text,
|
|
18026
|
+
{
|
|
18027
|
+
$color: isLightBackground ? darken(settings.theme.card.background, 0.46) : lighten(settings.theme.card.background, 0.46),
|
|
18028
|
+
$leading: 1,
|
|
18029
|
+
children: t2("Credit bundles")
|
|
18030
|
+
}
|
|
18031
|
+
),
|
|
18032
|
+
/* @__PURE__ */ jsx42(Flex, { $flexDirection: "column", $gap: "1rem", children: creditGroups.bundles.map((group, groupIndex) => {
|
|
18033
|
+
const bundle = group?.bundleId ? creditBundles.find((b2) => b2.id === group.bundleId) : void 0;
|
|
18034
|
+
return /* @__PURE__ */ jsxs34(
|
|
18035
|
+
Flex,
|
|
18036
|
+
{
|
|
18037
|
+
$justifyContent: "space-between",
|
|
18038
|
+
$alignItems: "center",
|
|
18039
|
+
$flexWrap: "wrap",
|
|
18040
|
+
$gap: "0.5rem",
|
|
18041
|
+
children: [
|
|
18042
|
+
bundle ? /* @__PURE__ */ jsxs34(Text, { display: props.addOns.fontStyle, children: [
|
|
18043
|
+
group.grants.length > 1 && /* @__PURE__ */ jsxs34(Text, { style: { opacity: 0.5 }, children: [
|
|
18044
|
+
"(",
|
|
18045
|
+
group.grants.length,
|
|
18046
|
+
")",
|
|
18047
|
+
" "
|
|
18048
|
+
] }),
|
|
18049
|
+
bundle.name,
|
|
18050
|
+
" (",
|
|
18051
|
+
group.quantity,
|
|
18052
|
+
" ",
|
|
18053
|
+
getFeatureName(group, group.quantity),
|
|
18054
|
+
")"
|
|
18055
|
+
] }) : /* @__PURE__ */ jsxs34(Text, { display: props.addOns.fontStyle, children: [
|
|
18056
|
+
group.quantity,
|
|
18057
|
+
" ",
|
|
18058
|
+
getFeatureName(group, group.quantity)
|
|
18059
|
+
] }),
|
|
18060
|
+
group.total.used > 0 && /* @__PURE__ */ jsxs34(
|
|
18061
|
+
Text,
|
|
18062
|
+
{
|
|
18063
|
+
style: { opacity: 0.54 },
|
|
18064
|
+
$size: 0.875 * settings.theme.typography.text.fontSize,
|
|
18065
|
+
$color: settings.theme.typography.text.color,
|
|
18066
|
+
children: [
|
|
18067
|
+
group.total.used,
|
|
17914
18068
|
" ",
|
|
17915
|
-
|
|
17916
|
-
|
|
17917
|
-
|
|
17918
|
-
|
|
18069
|
+
t2("used")
|
|
18070
|
+
]
|
|
18071
|
+
}
|
|
18072
|
+
)
|
|
18073
|
+
]
|
|
18074
|
+
},
|
|
18075
|
+
groupIndex
|
|
18076
|
+
);
|
|
18077
|
+
}) })
|
|
18078
|
+
] }),
|
|
18079
|
+
props.addOns.isVisible && creditGroups.promotional.length > 0 && /* @__PURE__ */ jsxs34(Flex, { $flexDirection: "column", $gap: "0.5rem", children: [
|
|
18080
|
+
props.addOns.showLabel && /* @__PURE__ */ jsx42(
|
|
18081
|
+
Text,
|
|
18082
|
+
{
|
|
18083
|
+
$color: isLightBackground ? darken(settings.theme.card.background, 0.46) : lighten(settings.theme.card.background, 0.46),
|
|
18084
|
+
$leading: 1,
|
|
18085
|
+
children: t2("Promotional credits")
|
|
18086
|
+
}
|
|
18087
|
+
),
|
|
18088
|
+
/* @__PURE__ */ jsx42(Flex, { $flexDirection: "column", $gap: "1rem", children: creditGroups.promotional.map((group, groupIndex) => {
|
|
18089
|
+
return /* @__PURE__ */ jsxs34(
|
|
18090
|
+
Flex,
|
|
18091
|
+
{
|
|
18092
|
+
$justifyContent: "space-between",
|
|
18093
|
+
$alignItems: "center",
|
|
18094
|
+
$flexWrap: "wrap",
|
|
18095
|
+
$gap: "0.5rem",
|
|
18096
|
+
children: [
|
|
18097
|
+
/* @__PURE__ */ jsxs34(Text, { display: props.addOns.fontStyle, children: [
|
|
18098
|
+
group.quantity,
|
|
18099
|
+
" ",
|
|
18100
|
+
getFeatureName(group, group.quantity)
|
|
18101
|
+
] }),
|
|
18102
|
+
group.total.used > 0 && /* @__PURE__ */ jsxs34(
|
|
18103
|
+
Text,
|
|
18104
|
+
{
|
|
18105
|
+
style: { opacity: 0.54 },
|
|
18106
|
+
$size: 0.875 * settings.theme.typography.text.fontSize,
|
|
18107
|
+
$color: settings.theme.typography.text.color,
|
|
18108
|
+
children: [
|
|
18109
|
+
group.total.used,
|
|
17919
18110
|
" ",
|
|
17920
|
-
|
|
17921
|
-
]
|
|
17922
|
-
|
|
17923
|
-
|
|
17924
|
-
|
|
17925
|
-
|
|
17926
|
-
|
|
17927
|
-
|
|
17928
|
-
|
|
17929
|
-
group.total.used,
|
|
17930
|
-
" ",
|
|
17931
|
-
t2("used")
|
|
17932
|
-
]
|
|
17933
|
-
}
|
|
17934
|
-
)
|
|
17935
|
-
]
|
|
17936
|
-
},
|
|
17937
|
-
groupIndex
|
|
17938
|
-
)
|
|
17939
|
-
);
|
|
17940
|
-
return acc;
|
|
17941
|
-
},
|
|
17942
|
-
[]
|
|
17943
|
-
) })
|
|
18111
|
+
t2("used")
|
|
18112
|
+
]
|
|
18113
|
+
}
|
|
18114
|
+
)
|
|
18115
|
+
]
|
|
18116
|
+
},
|
|
18117
|
+
groupIndex
|
|
18118
|
+
);
|
|
18119
|
+
}) })
|
|
17944
18120
|
] }),
|
|
17945
18121
|
canCheckout && props.callToAction.isVisible && /* @__PURE__ */ jsx42(
|
|
17946
18122
|
Button,
|
|
@@ -18959,11 +19135,12 @@ function resolveDesignProps11(props) {
|
|
|
18959
19135
|
var UpcomingBill = forwardRef15(({ className, ...rest }, ref) => {
|
|
18960
19136
|
const props = resolveDesignProps11(rest);
|
|
18961
19137
|
const { t: t2 } = useTranslation();
|
|
18962
|
-
const { data, settings, getUpcomingInvoice } = useEmbed();
|
|
19138
|
+
const { data, settings, debug, getUpcomingInvoice, getCustomerBalance } = useEmbed();
|
|
18963
19139
|
const isLightBackground = useIsLightBackground();
|
|
18964
19140
|
const [isLoading, setIsLoading] = useState18(false);
|
|
18965
19141
|
const [error, setError] = useState18();
|
|
18966
19142
|
const [upcomingInvoice, setUpcomingInvoice] = useState18();
|
|
19143
|
+
const [balances, setBalances] = useState18([]);
|
|
18967
19144
|
const discounts = useMemo28(() => {
|
|
18968
19145
|
return (isCheckoutData(data) && data.subscription?.discounts || []).map(
|
|
18969
19146
|
(discount) => ({
|
|
@@ -18992,9 +19169,22 @@ var UpcomingBill = forwardRef15(({ className, ...rest }, ref) => {
|
|
|
18992
19169
|
}
|
|
18993
19170
|
}
|
|
18994
19171
|
}, [data, getUpcomingInvoice]);
|
|
19172
|
+
const getBalances = useCallback13(async () => {
|
|
19173
|
+
try {
|
|
19174
|
+
const response = await getCustomerBalance();
|
|
19175
|
+
if (response) {
|
|
19176
|
+
setBalances(response.data.balances);
|
|
19177
|
+
}
|
|
19178
|
+
} catch (err2) {
|
|
19179
|
+
debug("Failed to fetch customer balance.", err2);
|
|
19180
|
+
}
|
|
19181
|
+
}, [debug, getCustomerBalance]);
|
|
18995
19182
|
useEffect9(() => {
|
|
18996
19183
|
getInvoice();
|
|
18997
19184
|
}, [getInvoice]);
|
|
19185
|
+
useEffect9(() => {
|
|
19186
|
+
getBalances();
|
|
19187
|
+
}, [getBalances]);
|
|
18998
19188
|
if (!isCheckoutData(data) || !data.subscription || data.subscription.cancelAt) {
|
|
18999
19189
|
return null;
|
|
19000
19190
|
}
|
|
@@ -19044,6 +19234,19 @@ var UpcomingBill = forwardRef15(({ className, ...rest }, ref) => {
|
|
|
19044
19234
|
]
|
|
19045
19235
|
}
|
|
19046
19236
|
),
|
|
19237
|
+
balances.length > 0 && /* @__PURE__ */ jsxs39(
|
|
19238
|
+
Flex,
|
|
19239
|
+
{
|
|
19240
|
+
as: TransitionBox,
|
|
19241
|
+
$justifyContent: "space-between",
|
|
19242
|
+
$alignItems: "start",
|
|
19243
|
+
$gap: "1rem",
|
|
19244
|
+
children: [
|
|
19245
|
+
/* @__PURE__ */ jsx49(Text, { $weight: 600, children: t2("Remaining balance") }),
|
|
19246
|
+
/* @__PURE__ */ jsx49(Flex, { $flexDirection: "column", $gap: "0.5rem", children: balances.map((item, idx) => /* @__PURE__ */ jsx49(Text, { children: formatCurrency(item.balance, item.currency) }, idx)) })
|
|
19247
|
+
]
|
|
19248
|
+
}
|
|
19249
|
+
),
|
|
19047
19250
|
discounts.length > 0 && /* @__PURE__ */ jsxs39(
|
|
19048
19251
|
Flex,
|
|
19049
19252
|
{
|
|
@@ -21185,7 +21388,7 @@ var {
|
|
|
21185
21388
|
Z_DEFAULT_STRATEGY,
|
|
21186
21389
|
Z_DEFLATED: Z_DEFLATED$1
|
|
21187
21390
|
} = constants$2;
|
|
21188
|
-
function Deflate$1(
|
|
21391
|
+
function Deflate$1(options) {
|
|
21189
21392
|
this.options = common.assign({
|
|
21190
21393
|
level: Z_DEFAULT_COMPRESSION,
|
|
21191
21394
|
method: Z_DEFLATED$1,
|
|
@@ -21193,7 +21396,7 @@ function Deflate$1(options2) {
|
|
|
21193
21396
|
windowBits: 15,
|
|
21194
21397
|
memLevel: 8,
|
|
21195
21398
|
strategy: Z_DEFAULT_STRATEGY
|
|
21196
|
-
},
|
|
21399
|
+
}, options || {});
|
|
21197
21400
|
let opt = this.options;
|
|
21198
21401
|
if (opt.raw && opt.windowBits > 0) {
|
|
21199
21402
|
opt.windowBits = -opt.windowBits;
|
|
@@ -21299,23 +21502,23 @@ Deflate$1.prototype.onEnd = function(status) {
|
|
|
21299
21502
|
this.err = status;
|
|
21300
21503
|
this.msg = this.strm.msg;
|
|
21301
21504
|
};
|
|
21302
|
-
function deflate$1(input,
|
|
21303
|
-
const deflator = new Deflate$1(
|
|
21505
|
+
function deflate$1(input, options) {
|
|
21506
|
+
const deflator = new Deflate$1(options);
|
|
21304
21507
|
deflator.push(input, true);
|
|
21305
21508
|
if (deflator.err) {
|
|
21306
21509
|
throw deflator.msg || messages[deflator.err];
|
|
21307
21510
|
}
|
|
21308
21511
|
return deflator.result;
|
|
21309
21512
|
}
|
|
21310
|
-
function deflateRaw$1(input,
|
|
21311
|
-
|
|
21312
|
-
|
|
21313
|
-
return deflate$1(input,
|
|
21513
|
+
function deflateRaw$1(input, options) {
|
|
21514
|
+
options = options || {};
|
|
21515
|
+
options.raw = true;
|
|
21516
|
+
return deflate$1(input, options);
|
|
21314
21517
|
}
|
|
21315
|
-
function gzip$1(input,
|
|
21316
|
-
|
|
21317
|
-
|
|
21318
|
-
return deflate$1(input,
|
|
21518
|
+
function gzip$1(input, options) {
|
|
21519
|
+
options = options || {};
|
|
21520
|
+
options.gzip = true;
|
|
21521
|
+
return deflate$1(input, options);
|
|
21319
21522
|
}
|
|
21320
21523
|
var Deflate_1$1 = Deflate$1;
|
|
21321
21524
|
var deflate_2 = deflate$1;
|
|
@@ -23128,12 +23331,12 @@ var {
|
|
|
23128
23331
|
Z_DATA_ERROR,
|
|
23129
23332
|
Z_MEM_ERROR
|
|
23130
23333
|
} = constants$2;
|
|
23131
|
-
function Inflate$1(
|
|
23334
|
+
function Inflate$1(options) {
|
|
23132
23335
|
this.options = common.assign({
|
|
23133
23336
|
chunkSize: 1024 * 64,
|
|
23134
23337
|
windowBits: 15,
|
|
23135
23338
|
to: ""
|
|
23136
|
-
},
|
|
23339
|
+
}, options || {});
|
|
23137
23340
|
const opt = this.options;
|
|
23138
23341
|
if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {
|
|
23139
23342
|
opt.windowBits = -opt.windowBits;
|
|
@@ -23141,7 +23344,7 @@ function Inflate$1(options2) {
|
|
|
23141
23344
|
opt.windowBits = -15;
|
|
23142
23345
|
}
|
|
23143
23346
|
}
|
|
23144
|
-
if (opt.windowBits >= 0 && opt.windowBits < 16 && !(
|
|
23347
|
+
if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {
|
|
23145
23348
|
opt.windowBits += 32;
|
|
23146
23349
|
}
|
|
23147
23350
|
if (opt.windowBits > 15 && opt.windowBits < 48) {
|
|
@@ -23263,16 +23466,16 @@ Inflate$1.prototype.onEnd = function(status) {
|
|
|
23263
23466
|
this.err = status;
|
|
23264
23467
|
this.msg = this.strm.msg;
|
|
23265
23468
|
};
|
|
23266
|
-
function inflate$1(input,
|
|
23267
|
-
const inflator = new Inflate$1(
|
|
23469
|
+
function inflate$1(input, options) {
|
|
23470
|
+
const inflator = new Inflate$1(options);
|
|
23268
23471
|
inflator.push(input);
|
|
23269
23472
|
if (inflator.err) throw inflator.msg || messages[inflator.err];
|
|
23270
23473
|
return inflator.result;
|
|
23271
23474
|
}
|
|
23272
|
-
function inflateRaw$1(input,
|
|
23273
|
-
|
|
23274
|
-
|
|
23275
|
-
return inflate$1(input,
|
|
23475
|
+
function inflateRaw$1(input, options) {
|
|
23476
|
+
options = options || {};
|
|
23477
|
+
options.raw = true;
|
|
23478
|
+
return inflate$1(input, options);
|
|
23276
23479
|
}
|
|
23277
23480
|
var Inflate_1$1 = Inflate$1;
|
|
23278
23481
|
var inflate_2 = inflate$1;
|
|
@@ -23340,8 +23543,8 @@ function parseEditorState(data) {
|
|
|
23340
23543
|
});
|
|
23341
23544
|
return arr;
|
|
23342
23545
|
}
|
|
23343
|
-
function createRenderer(
|
|
23344
|
-
const { useFallback = false } =
|
|
23546
|
+
function createRenderer(options) {
|
|
23547
|
+
const { useFallback = false } = options || {};
|
|
23345
23548
|
return function renderNode(node2, index) {
|
|
23346
23549
|
const { type, props = {}, children } = node2;
|
|
23347
23550
|
const name = typeof type !== "string" ? type.resolvedName : type;
|