@schematichq/schematic-components 0.7.13 → 0.7.15
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 +509 -467
- package/dist/schematic-components.d.ts +57 -61
- package/dist/schematic-components.esm.js +574 -532
- package/package.json +12 -12
|
@@ -6745,9 +6745,9 @@ var unitlessKeys = {
|
|
|
6745
6745
|
var f = "undefined" != typeof process && void 0 !== process.env && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR) || "data-styled";
|
|
6746
6746
|
var m = "active";
|
|
6747
6747
|
var y = "data-styled-version";
|
|
6748
|
-
var v = "6.1.
|
|
6748
|
+
var v = "6.1.18";
|
|
6749
6749
|
var g = "/*!sc*/\n";
|
|
6750
|
-
var S = "undefined" != typeof window && "
|
|
6750
|
+
var S = "undefined" != typeof window && "undefined" != typeof document;
|
|
6751
6751
|
var w = Boolean("boolean" == typeof SC_DISABLE_SPEEDY ? SC_DISABLE_SPEEDY : "undefined" != typeof process && void 0 !== process.env && void 0 !== process.env.REACT_APP_SC_DISABLE_SPEEDY && "" !== process.env.REACT_APP_SC_DISABLE_SPEEDY ? "false" !== process.env.REACT_APP_SC_DISABLE_SPEEDY && process.env.REACT_APP_SC_DISABLE_SPEEDY : "undefined" != typeof process && void 0 !== process.env && void 0 !== process.env.SC_DISABLE_SPEEDY && "" !== process.env.SC_DISABLE_SPEEDY ? "false" !== process.env.SC_DISABLE_SPEEDY && process.env.SC_DISABLE_SPEEDY : true);
|
|
6752
6752
|
var b = {};
|
|
6753
6753
|
var E = /invalid hook call/i;
|
|
@@ -7854,8 +7854,7 @@ var looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
|
|
|
7854
7854
|
}
|
|
7855
7855
|
return matched;
|
|
7856
7856
|
};
|
|
7857
|
-
var deepFind =
|
|
7858
|
-
let keySeparator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ".";
|
|
7857
|
+
var deepFind = (obj, path, keySeparator = ".") => {
|
|
7859
7858
|
if (!obj) return void 0;
|
|
7860
7859
|
if (obj[path]) {
|
|
7861
7860
|
if (!Object.prototype.hasOwnProperty.call(obj, path)) return void 0;
|
|
@@ -7904,39 +7903,25 @@ var consoleLogger = {
|
|
|
7904
7903
|
}
|
|
7905
7904
|
};
|
|
7906
7905
|
var Logger = class _Logger {
|
|
7907
|
-
constructor(concreteLogger) {
|
|
7908
|
-
let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
7906
|
+
constructor(concreteLogger, options2 = {}) {
|
|
7909
7907
|
this.init(concreteLogger, options2);
|
|
7910
7908
|
}
|
|
7911
|
-
init(concreteLogger) {
|
|
7912
|
-
let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
7909
|
+
init(concreteLogger, options2 = {}) {
|
|
7913
7910
|
this.prefix = options2.prefix || "i18next:";
|
|
7914
7911
|
this.logger = concreteLogger || consoleLogger;
|
|
7915
7912
|
this.options = options2;
|
|
7916
7913
|
this.debug = options2.debug;
|
|
7917
7914
|
}
|
|
7918
|
-
log() {
|
|
7919
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
7920
|
-
args[_key] = arguments[_key];
|
|
7921
|
-
}
|
|
7915
|
+
log(...args) {
|
|
7922
7916
|
return this.forward(args, "log", "", true);
|
|
7923
7917
|
}
|
|
7924
|
-
warn() {
|
|
7925
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
7926
|
-
args[_key2] = arguments[_key2];
|
|
7927
|
-
}
|
|
7918
|
+
warn(...args) {
|
|
7928
7919
|
return this.forward(args, "warn", "", true);
|
|
7929
7920
|
}
|
|
7930
|
-
error() {
|
|
7931
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
7932
|
-
args[_key3] = arguments[_key3];
|
|
7933
|
-
}
|
|
7921
|
+
error(...args) {
|
|
7934
7922
|
return this.forward(args, "error", "");
|
|
7935
7923
|
}
|
|
7936
|
-
deprecate() {
|
|
7937
|
-
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
7938
|
-
args[_key4] = arguments[_key4];
|
|
7939
|
-
}
|
|
7924
|
+
deprecate(...args) {
|
|
7940
7925
|
return this.forward(args, "warn", "WARNING DEPRECATED: ", true);
|
|
7941
7926
|
}
|
|
7942
7927
|
forward(args, lvl, prefix2, debugOnly) {
|
|
@@ -7979,14 +7964,10 @@ var EventEmitter = class {
|
|
|
7979
7964
|
}
|
|
7980
7965
|
this.observers[event].delete(listener);
|
|
7981
7966
|
}
|
|
7982
|
-
emit(event) {
|
|
7983
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
7984
|
-
args[_key - 1] = arguments[_key];
|
|
7985
|
-
}
|
|
7967
|
+
emit(event, ...args) {
|
|
7986
7968
|
if (this.observers[event]) {
|
|
7987
7969
|
const cloned = Array.from(this.observers[event].entries());
|
|
7988
|
-
cloned.forEach((
|
|
7989
|
-
let [observer, numTimesAdded] = _ref;
|
|
7970
|
+
cloned.forEach(([observer, numTimesAdded]) => {
|
|
7990
7971
|
for (let i2 = 0; i2 < numTimesAdded; i2++) {
|
|
7991
7972
|
observer(...args);
|
|
7992
7973
|
}
|
|
@@ -7994,8 +7975,7 @@ var EventEmitter = class {
|
|
|
7994
7975
|
}
|
|
7995
7976
|
if (this.observers["*"]) {
|
|
7996
7977
|
const cloned = Array.from(this.observers["*"].entries());
|
|
7997
|
-
cloned.forEach((
|
|
7998
|
-
let [observer, numTimesAdded] = _ref2;
|
|
7978
|
+
cloned.forEach(([observer, numTimesAdded]) => {
|
|
7999
7979
|
for (let i2 = 0; i2 < numTimesAdded; i2++) {
|
|
8000
7980
|
observer.apply(observer, [event, ...args]);
|
|
8001
7981
|
}
|
|
@@ -8004,11 +7984,10 @@ var EventEmitter = class {
|
|
|
8004
7984
|
}
|
|
8005
7985
|
};
|
|
8006
7986
|
var ResourceStore = class extends EventEmitter {
|
|
8007
|
-
constructor(data
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
};
|
|
7987
|
+
constructor(data, options2 = {
|
|
7988
|
+
ns: ["translation"],
|
|
7989
|
+
defaultNS: "translation"
|
|
7990
|
+
}) {
|
|
8012
7991
|
super();
|
|
8013
7992
|
this.data = data || {};
|
|
8014
7993
|
this.options = options2;
|
|
@@ -8030,8 +8009,7 @@ var ResourceStore = class extends EventEmitter {
|
|
|
8030
8009
|
this.options.ns.splice(index, 1);
|
|
8031
8010
|
}
|
|
8032
8011
|
}
|
|
8033
|
-
getResource(lng, ns, key) {
|
|
8034
|
-
let options2 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
8012
|
+
getResource(lng, ns, key, options2 = {}) {
|
|
8035
8013
|
const keySeparator = options2.keySeparator !== void 0 ? options2.keySeparator : this.options.keySeparator;
|
|
8036
8014
|
const ignoreJSONStructure = options2.ignoreJSONStructure !== void 0 ? options2.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
8037
8015
|
let path;
|
|
@@ -8058,10 +8036,9 @@ var ResourceStore = class extends EventEmitter {
|
|
|
8058
8036
|
if (result || !ignoreJSONStructure || !isString(key)) return result;
|
|
8059
8037
|
return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
|
|
8060
8038
|
}
|
|
8061
|
-
addResource(lng, ns, key, value
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
};
|
|
8039
|
+
addResource(lng, ns, key, value, options2 = {
|
|
8040
|
+
silent: false
|
|
8041
|
+
}) {
|
|
8065
8042
|
const keySeparator = options2.keySeparator !== void 0 ? options2.keySeparator : this.options.keySeparator;
|
|
8066
8043
|
let path = [lng, ns];
|
|
8067
8044
|
if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
|
@@ -8074,10 +8051,9 @@ var ResourceStore = class extends EventEmitter {
|
|
|
8074
8051
|
setPath(this.data, path, value);
|
|
8075
8052
|
if (!options2.silent) this.emit("added", lng, ns, key, value);
|
|
8076
8053
|
}
|
|
8077
|
-
addResources(lng, ns, resources
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
};
|
|
8054
|
+
addResources(lng, ns, resources, options2 = {
|
|
8055
|
+
silent: false
|
|
8056
|
+
}) {
|
|
8081
8057
|
for (const m2 in resources) {
|
|
8082
8058
|
if (isString(resources[m2]) || Array.isArray(resources[m2])) this.addResource(lng, ns, m2, resources[m2], {
|
|
8083
8059
|
silent: true
|
|
@@ -8085,11 +8061,10 @@ var ResourceStore = class extends EventEmitter {
|
|
|
8085
8061
|
}
|
|
8086
8062
|
if (!options2.silent) this.emit("added", lng, ns, resources);
|
|
8087
8063
|
}
|
|
8088
|
-
addResourceBundle(lng, ns, resources, deep, overwrite
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
};
|
|
8064
|
+
addResourceBundle(lng, ns, resources, deep, overwrite, options2 = {
|
|
8065
|
+
silent: false,
|
|
8066
|
+
skipCopy: false
|
|
8067
|
+
}) {
|
|
8093
8068
|
let path = [lng, ns];
|
|
8094
8069
|
if (lng.indexOf(".") > -1) {
|
|
8095
8070
|
path = lng.split(".");
|
|
@@ -8152,8 +8127,7 @@ var postProcessor = {
|
|
|
8152
8127
|
var checkedLoadedFor = {};
|
|
8153
8128
|
var shouldHandleAsObject = (res) => !isString(res) && typeof res !== "boolean" && typeof res !== "number";
|
|
8154
8129
|
var Translator = class _Translator extends EventEmitter {
|
|
8155
|
-
constructor(services) {
|
|
8156
|
-
let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
8130
|
+
constructor(services, options2 = {}) {
|
|
8157
8131
|
super();
|
|
8158
8132
|
copy2(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], services, this);
|
|
8159
8133
|
this.options = options2;
|
|
@@ -8165,14 +8139,14 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
8165
8139
|
changeLanguage(lng) {
|
|
8166
8140
|
if (lng) this.language = lng;
|
|
8167
8141
|
}
|
|
8168
|
-
exists(key
|
|
8169
|
-
|
|
8170
|
-
|
|
8142
|
+
exists(key, o2 = {
|
|
8143
|
+
interpolation: {}
|
|
8144
|
+
}) {
|
|
8145
|
+
const opt = {
|
|
8146
|
+
...o2
|
|
8171
8147
|
};
|
|
8172
|
-
if (key == null)
|
|
8173
|
-
|
|
8174
|
-
}
|
|
8175
|
-
const resolved = this.resolve(key, options2);
|
|
8148
|
+
if (key == null) return false;
|
|
8149
|
+
const resolved = this.resolve(key, opt);
|
|
8176
8150
|
return resolved?.res !== void 0;
|
|
8177
8151
|
}
|
|
8178
8152
|
extractFromKey(key, opt) {
|
|
@@ -8199,7 +8173,10 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
8199
8173
|
namespaces: isString(namespaces) ? [namespaces] : namespaces
|
|
8200
8174
|
};
|
|
8201
8175
|
}
|
|
8202
|
-
translate(keys,
|
|
8176
|
+
translate(keys, o2, lastKey) {
|
|
8177
|
+
let opt = typeof o2 === "object" ? {
|
|
8178
|
+
...o2
|
|
8179
|
+
} : o2;
|
|
8203
8180
|
if (typeof opt !== "object" && this.options.overloadTranslationOptionHandler) {
|
|
8204
8181
|
opt = this.options.overloadTranslationOptionHandler(arguments);
|
|
8205
8182
|
}
|
|
@@ -8216,11 +8193,12 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
8216
8193
|
namespaces
|
|
8217
8194
|
} = this.extractFromKey(keys[keys.length - 1], opt);
|
|
8218
8195
|
const namespace = namespaces[namespaces.length - 1];
|
|
8196
|
+
let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
|
|
8197
|
+
if (nsSeparator === void 0) nsSeparator = ":";
|
|
8219
8198
|
const lng = opt.lng || this.language;
|
|
8220
8199
|
const appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
|
8221
8200
|
if (lng?.toLowerCase() === "cimode") {
|
|
8222
8201
|
if (appendNamespaceToCIMode) {
|
|
8223
|
-
const nsSeparator = opt.nsSeparator || this.options.nsSeparator;
|
|
8224
8202
|
if (returnDetails) {
|
|
8225
8203
|
return {
|
|
8226
8204
|
res: `${namespace}${nsSeparator}${key}`,
|
|
@@ -8375,9 +8353,11 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
8375
8353
|
}
|
|
8376
8354
|
}
|
|
8377
8355
|
res = this.extendTranslation(res, keys, opt, resolved, lastKey);
|
|
8378
|
-
if (usedKey && res === key && this.options.appendNamespaceToMissingKey)
|
|
8356
|
+
if (usedKey && res === key && this.options.appendNamespaceToMissingKey) {
|
|
8357
|
+
res = `${namespace}${nsSeparator}${key}`;
|
|
8358
|
+
}
|
|
8379
8359
|
if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
|
|
8380
|
-
res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}
|
|
8360
|
+
res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}${nsSeparator}${key}` : key, usedDefault ? res : void 0, opt);
|
|
8381
8361
|
}
|
|
8382
8362
|
}
|
|
8383
8363
|
if (returnDetails) {
|
|
@@ -8388,7 +8368,6 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
8388
8368
|
return res;
|
|
8389
8369
|
}
|
|
8390
8370
|
extendTranslation(res, key, opt, resolved, lastKey) {
|
|
8391
|
-
var _this = this;
|
|
8392
8371
|
if (this.i18nFormat?.parse) {
|
|
8393
8372
|
res = this.i18nFormat.parse(res, {
|
|
8394
8373
|
...this.options.interpolation.defaultVariables,
|
|
@@ -8424,15 +8403,12 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
8424
8403
|
if (nestBef < nestAft) opt.nest = false;
|
|
8425
8404
|
}
|
|
8426
8405
|
if (!opt.lng && resolved && resolved.res) opt.lng = this.language || resolved.usedLng;
|
|
8427
|
-
if (opt.nest !== false) res = this.interpolator.nest(res,
|
|
8428
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
8429
|
-
args[_key] = arguments[_key];
|
|
8430
|
-
}
|
|
8406
|
+
if (opt.nest !== false) res = this.interpolator.nest(res, (...args) => {
|
|
8431
8407
|
if (lastKey?.[0] === args[0] && !opt.context) {
|
|
8432
|
-
|
|
8408
|
+
this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
|
|
8433
8409
|
return null;
|
|
8434
8410
|
}
|
|
8435
|
-
return
|
|
8411
|
+
return this.translate(...args, key);
|
|
8436
8412
|
}, opt);
|
|
8437
8413
|
if (opt.interpolation) this.interpolator.reset();
|
|
8438
8414
|
}
|
|
@@ -8449,8 +8425,7 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
8449
8425
|
}
|
|
8450
8426
|
return res;
|
|
8451
8427
|
}
|
|
8452
|
-
resolve(keys) {
|
|
8453
|
-
let opt = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
8428
|
+
resolve(keys, opt = {}) {
|
|
8454
8429
|
let found;
|
|
8455
8430
|
let usedKey;
|
|
8456
8431
|
let exactUsedKey;
|
|
@@ -8530,13 +8505,11 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
8530
8505
|
isValidLookup(res) {
|
|
8531
8506
|
return res !== void 0 && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === "");
|
|
8532
8507
|
}
|
|
8533
|
-
getResource(code, ns, key) {
|
|
8534
|
-
let options2 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
8508
|
+
getResource(code, ns, key, options2 = {}) {
|
|
8535
8509
|
if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key, options2);
|
|
8536
8510
|
return this.resourceStore.getResource(code, ns, key, options2);
|
|
8537
8511
|
}
|
|
8538
|
-
getUsedParamsDetails() {
|
|
8539
|
-
let options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
8512
|
+
getUsedParamsDetails(options2 = {}) {
|
|
8540
8513
|
const optionsKeys = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"];
|
|
8541
8514
|
const useOptionsReplaceForData = options2.replace && !isString(options2.replace);
|
|
8542
8515
|
let data = useOptionsReplaceForData ? options2.replace : options2;
|
|
@@ -8692,8 +8665,7 @@ var dummyRule = {
|
|
|
8692
8665
|
})
|
|
8693
8666
|
};
|
|
8694
8667
|
var PluralResolver = class {
|
|
8695
|
-
constructor(languageUtils) {
|
|
8696
|
-
let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
8668
|
+
constructor(languageUtils, options2 = {}) {
|
|
8697
8669
|
this.languageUtils = languageUtils;
|
|
8698
8670
|
this.options = options2;
|
|
8699
8671
|
this.logger = baseLogger.create("pluralResolver");
|
|
@@ -8705,8 +8677,7 @@ var PluralResolver = class {
|
|
|
8705
8677
|
clearCache() {
|
|
8706
8678
|
this.pluralRulesCache = {};
|
|
8707
8679
|
}
|
|
8708
|
-
getRule(code) {
|
|
8709
|
-
let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
8680
|
+
getRule(code, options2 = {}) {
|
|
8710
8681
|
const cleanedCode = getCleanedCode(code === "dev" ? "en" : code);
|
|
8711
8682
|
const type = options2.ordinal ? "ordinal" : "cardinal";
|
|
8712
8683
|
const cacheKey = JSON.stringify({
|
|
@@ -8733,25 +8704,21 @@ var PluralResolver = class {
|
|
|
8733
8704
|
this.pluralRulesCache[cacheKey] = rule;
|
|
8734
8705
|
return rule;
|
|
8735
8706
|
}
|
|
8736
|
-
needsPlural(code) {
|
|
8737
|
-
let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
8707
|
+
needsPlural(code, options2 = {}) {
|
|
8738
8708
|
let rule = this.getRule(code, options2);
|
|
8739
8709
|
if (!rule) rule = this.getRule("dev", options2);
|
|
8740
8710
|
return rule?.resolvedOptions().pluralCategories.length > 1;
|
|
8741
8711
|
}
|
|
8742
|
-
getPluralFormsOfKey(code, key) {
|
|
8743
|
-
let options2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
8712
|
+
getPluralFormsOfKey(code, key, options2 = {}) {
|
|
8744
8713
|
return this.getSuffixes(code, options2).map((suffix) => `${key}${suffix}`);
|
|
8745
8714
|
}
|
|
8746
|
-
getSuffixes(code) {
|
|
8747
|
-
let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
8715
|
+
getSuffixes(code, options2 = {}) {
|
|
8748
8716
|
let rule = this.getRule(code, options2);
|
|
8749
8717
|
if (!rule) rule = this.getRule("dev", options2);
|
|
8750
8718
|
if (!rule) return [];
|
|
8751
8719
|
return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map((pluralCategory) => `${this.options.prepend}${options2.ordinal ? `ordinal${this.options.prepend}` : ""}${pluralCategory}`);
|
|
8752
8720
|
}
|
|
8753
|
-
getSuffix(code, count) {
|
|
8754
|
-
let options2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
8721
|
+
getSuffix(code, count, options2 = {}) {
|
|
8755
8722
|
const rule = this.getRule(code, options2);
|
|
8756
8723
|
if (rule) {
|
|
8757
8724
|
return `${this.options.prepend}${options2.ordinal ? `ordinal${this.options.prepend}` : ""}${rule.select(count)}`;
|
|
@@ -8760,9 +8727,7 @@ var PluralResolver = class {
|
|
|
8760
8727
|
return this.getSuffix("dev", count, options2);
|
|
8761
8728
|
}
|
|
8762
8729
|
};
|
|
8763
|
-
var deepFindWithDefaults =
|
|
8764
|
-
let keySeparator = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : ".";
|
|
8765
|
-
let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : true;
|
|
8730
|
+
var deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJSONStructure = true) => {
|
|
8766
8731
|
let path = getPathWithDefaults(data, defaultData, key);
|
|
8767
8732
|
if (!path && ignoreJSONStructure && isString(key)) {
|
|
8768
8733
|
path = deepFind(data, key, keySeparator);
|
|
@@ -8772,15 +8737,13 @@ var deepFindWithDefaults = function(data, defaultData, key) {
|
|
|
8772
8737
|
};
|
|
8773
8738
|
var regexSafe = (val) => val.replace(/\$/g, "$$$$");
|
|
8774
8739
|
var Interpolator = class {
|
|
8775
|
-
constructor() {
|
|
8776
|
-
let options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
8740
|
+
constructor(options2 = {}) {
|
|
8777
8741
|
this.logger = baseLogger.create("interpolator");
|
|
8778
8742
|
this.options = options2;
|
|
8779
8743
|
this.format = options2?.interpolation?.format || ((value) => value);
|
|
8780
8744
|
this.init(options2);
|
|
8781
8745
|
}
|
|
8782
|
-
init() {
|
|
8783
|
-
let options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
8746
|
+
init(options2 = {}) {
|
|
8784
8747
|
if (!options2.interpolation) options2.interpolation = {
|
|
8785
8748
|
escapeValue: true
|
|
8786
8749
|
};
|
|
@@ -8903,8 +8866,7 @@ var Interpolator = class {
|
|
|
8903
8866
|
});
|
|
8904
8867
|
return str;
|
|
8905
8868
|
}
|
|
8906
|
-
nest(str, fc) {
|
|
8907
|
-
let options2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
8869
|
+
nest(str, fc, options2 = {}) {
|
|
8908
8870
|
let match2;
|
|
8909
8871
|
let value;
|
|
8910
8872
|
let clonedOptions;
|
|
@@ -9000,68 +8962,68 @@ var parseFormatStr = (formatStr) => {
|
|
|
9000
8962
|
};
|
|
9001
8963
|
var createCachedFormatter = (fn) => {
|
|
9002
8964
|
const cache = {};
|
|
9003
|
-
return (
|
|
9004
|
-
let optForCache =
|
|
9005
|
-
if (
|
|
8965
|
+
return (v2, l2, o2) => {
|
|
8966
|
+
let optForCache = o2;
|
|
8967
|
+
if (o2 && o2.interpolationkey && o2.formatParams && o2.formatParams[o2.interpolationkey] && o2[o2.interpolationkey]) {
|
|
9006
8968
|
optForCache = {
|
|
9007
8969
|
...optForCache,
|
|
9008
|
-
[
|
|
8970
|
+
[o2.interpolationkey]: void 0
|
|
9009
8971
|
};
|
|
9010
8972
|
}
|
|
9011
|
-
const key =
|
|
9012
|
-
let
|
|
9013
|
-
if (!
|
|
9014
|
-
|
|
9015
|
-
cache[key] =
|
|
8973
|
+
const key = l2 + JSON.stringify(optForCache);
|
|
8974
|
+
let frm = cache[key];
|
|
8975
|
+
if (!frm) {
|
|
8976
|
+
frm = fn(getCleanedCode(l2), o2);
|
|
8977
|
+
cache[key] = frm;
|
|
9016
8978
|
}
|
|
9017
|
-
return
|
|
8979
|
+
return frm(v2);
|
|
9018
8980
|
};
|
|
9019
8981
|
};
|
|
8982
|
+
var createNonCachedFormatter = (fn) => (v2, l2, o2) => fn(getCleanedCode(l2), o2)(v2);
|
|
9020
8983
|
var Formatter = class {
|
|
9021
|
-
constructor() {
|
|
9022
|
-
let options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
8984
|
+
constructor(options2 = {}) {
|
|
9023
8985
|
this.logger = baseLogger.create("formatter");
|
|
9024
8986
|
this.options = options2;
|
|
8987
|
+
this.init(options2);
|
|
8988
|
+
}
|
|
8989
|
+
init(services, options2 = {
|
|
8990
|
+
interpolation: {}
|
|
8991
|
+
}) {
|
|
8992
|
+
this.formatSeparator = options2.interpolation.formatSeparator || ",";
|
|
8993
|
+
const cf = options2.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
|
|
9025
8994
|
this.formats = {
|
|
9026
|
-
number:
|
|
8995
|
+
number: cf((lng, opt) => {
|
|
9027
8996
|
const formatter = new Intl.NumberFormat(lng, {
|
|
9028
8997
|
...opt
|
|
9029
8998
|
});
|
|
9030
8999
|
return (val) => formatter.format(val);
|
|
9031
9000
|
}),
|
|
9032
|
-
currency:
|
|
9001
|
+
currency: cf((lng, opt) => {
|
|
9033
9002
|
const formatter = new Intl.NumberFormat(lng, {
|
|
9034
9003
|
...opt,
|
|
9035
9004
|
style: "currency"
|
|
9036
9005
|
});
|
|
9037
9006
|
return (val) => formatter.format(val);
|
|
9038
9007
|
}),
|
|
9039
|
-
datetime:
|
|
9008
|
+
datetime: cf((lng, opt) => {
|
|
9040
9009
|
const formatter = new Intl.DateTimeFormat(lng, {
|
|
9041
9010
|
...opt
|
|
9042
9011
|
});
|
|
9043
9012
|
return (val) => formatter.format(val);
|
|
9044
9013
|
}),
|
|
9045
|
-
relativetime:
|
|
9014
|
+
relativetime: cf((lng, opt) => {
|
|
9046
9015
|
const formatter = new Intl.RelativeTimeFormat(lng, {
|
|
9047
9016
|
...opt
|
|
9048
9017
|
});
|
|
9049
9018
|
return (val) => formatter.format(val, opt.range || "day");
|
|
9050
9019
|
}),
|
|
9051
|
-
list:
|
|
9020
|
+
list: cf((lng, opt) => {
|
|
9052
9021
|
const formatter = new Intl.ListFormat(lng, {
|
|
9053
9022
|
...opt
|
|
9054
9023
|
});
|
|
9055
9024
|
return (val) => formatter.format(val);
|
|
9056
9025
|
})
|
|
9057
9026
|
};
|
|
9058
|
-
this.init(options2);
|
|
9059
|
-
}
|
|
9060
|
-
init(services) {
|
|
9061
|
-
let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
9062
|
-
interpolation: {}
|
|
9063
|
-
};
|
|
9064
|
-
this.formatSeparator = options2.interpolation.formatSeparator || ",";
|
|
9065
9027
|
}
|
|
9066
9028
|
add(name, fc) {
|
|
9067
9029
|
this.formats[name.toLowerCase().trim()] = fc;
|
|
@@ -9069,8 +9031,7 @@ var Formatter = class {
|
|
|
9069
9031
|
addCached(name, fc) {
|
|
9070
9032
|
this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
|
|
9071
9033
|
}
|
|
9072
|
-
format(value, format, lng) {
|
|
9073
|
-
let options2 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
9034
|
+
format(value, format, lng, options2 = {}) {
|
|
9074
9035
|
const formats = format.split(this.formatSeparator);
|
|
9075
9036
|
if (formats.length > 1 && formats[0].indexOf("(") > 1 && formats[0].indexOf(")") < 0 && formats.find((f2) => f2.indexOf(")") > -1)) {
|
|
9076
9037
|
const lastIndex = formats.findIndex((f2) => f2.indexOf(")") > -1);
|
|
@@ -9110,8 +9071,7 @@ var removePending = (q2, name) => {
|
|
|
9110
9071
|
}
|
|
9111
9072
|
};
|
|
9112
9073
|
var Connector = class extends EventEmitter {
|
|
9113
|
-
constructor(backend, store, services) {
|
|
9114
|
-
let options2 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
9074
|
+
constructor(backend, store, services, options2 = {}) {
|
|
9115
9075
|
super();
|
|
9116
9076
|
this.backend = backend;
|
|
9117
9077
|
this.store = store;
|
|
@@ -9206,10 +9166,7 @@ var Connector = class extends EventEmitter {
|
|
|
9206
9166
|
this.emit("loaded", loaded);
|
|
9207
9167
|
this.queue = this.queue.filter((q2) => !q2.done);
|
|
9208
9168
|
}
|
|
9209
|
-
read(lng, ns, fcName) {
|
|
9210
|
-
let tried = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0;
|
|
9211
|
-
let wait = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : this.retryTimeout;
|
|
9212
|
-
let callback = arguments.length > 5 ? arguments[5] : void 0;
|
|
9169
|
+
read(lng, ns, fcName, tried = 0, wait = this.retryTimeout, callback) {
|
|
9213
9170
|
if (!lng.length) return callback(null, {});
|
|
9214
9171
|
if (this.readingCalls >= this.maxParallelReads) {
|
|
9215
9172
|
this.waitingReads.push({
|
|
@@ -9253,9 +9210,7 @@ var Connector = class extends EventEmitter {
|
|
|
9253
9210
|
}
|
|
9254
9211
|
return fc(lng, ns, resolver);
|
|
9255
9212
|
}
|
|
9256
|
-
prepareLoading(languages, namespaces) {
|
|
9257
|
-
let options2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
9258
|
-
let callback = arguments.length > 3 ? arguments[3] : void 0;
|
|
9213
|
+
prepareLoading(languages, namespaces, options2 = {}, callback) {
|
|
9259
9214
|
if (!this.backend) {
|
|
9260
9215
|
this.logger.warn("No backend was added via i18next.use. Will not load resources.");
|
|
9261
9216
|
return callback && callback();
|
|
@@ -9279,8 +9234,7 @@ var Connector = class extends EventEmitter {
|
|
|
9279
9234
|
reload: true
|
|
9280
9235
|
}, callback);
|
|
9281
9236
|
}
|
|
9282
|
-
loadOne(name) {
|
|
9283
|
-
let prefix2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
9237
|
+
loadOne(name, prefix2 = "") {
|
|
9284
9238
|
const s2 = name.split("|");
|
|
9285
9239
|
const lng = s2[0];
|
|
9286
9240
|
const ns = s2[1];
|
|
@@ -9290,10 +9244,8 @@ var Connector = class extends EventEmitter {
|
|
|
9290
9244
|
this.loaded(name, err2, data);
|
|
9291
9245
|
});
|
|
9292
9246
|
}
|
|
9293
|
-
saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
|
|
9294
|
-
|
|
9295
|
-
let clb = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : () => {
|
|
9296
|
-
};
|
|
9247
|
+
saveMissing(languages, namespace, key, fallbackValue, isUpdate, options2 = {}, clb = () => {
|
|
9248
|
+
}) {
|
|
9297
9249
|
if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(namespace)) {
|
|
9298
9250
|
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!!!");
|
|
9299
9251
|
return;
|
|
@@ -9387,7 +9339,8 @@ var get = () => ({
|
|
|
9387
9339
|
nestingOptionsSeparator: ",",
|
|
9388
9340
|
maxReplaces: 1e3,
|
|
9389
9341
|
skipOnVariables: true
|
|
9390
|
-
}
|
|
9342
|
+
},
|
|
9343
|
+
cacheInBuiltFormats: true
|
|
9391
9344
|
});
|
|
9392
9345
|
var transformOptions = (options2) => {
|
|
9393
9346
|
if (isString(options2.ns)) options2.ns = [options2.ns];
|
|
@@ -9410,9 +9363,7 @@ var bindMemberFunctions = (inst) => {
|
|
|
9410
9363
|
});
|
|
9411
9364
|
};
|
|
9412
9365
|
var I18n = class _I18n extends EventEmitter {
|
|
9413
|
-
constructor() {
|
|
9414
|
-
let options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
9415
|
-
let callback = arguments.length > 1 ? arguments[1] : void 0;
|
|
9366
|
+
constructor(options2 = {}, callback) {
|
|
9416
9367
|
super();
|
|
9417
9368
|
this.options = transformOptions(options2);
|
|
9418
9369
|
this.services = {};
|
|
@@ -9431,10 +9382,7 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
9431
9382
|
}, 0);
|
|
9432
9383
|
}
|
|
9433
9384
|
}
|
|
9434
|
-
init() {
|
|
9435
|
-
var _this = this;
|
|
9436
|
-
let options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
9437
|
-
let callback = arguments.length > 1 ? arguments[1] : void 0;
|
|
9385
|
+
init(options2 = {}, callback) {
|
|
9438
9386
|
this.isInitializing = true;
|
|
9439
9387
|
if (typeof options2 === "function") {
|
|
9440
9388
|
callback = options2;
|
|
@@ -9500,11 +9448,8 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
9500
9448
|
hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
|
|
9501
9449
|
};
|
|
9502
9450
|
s2.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s2.resourceStore, s2, this.options);
|
|
9503
|
-
s2.backendConnector.on("*",
|
|
9504
|
-
|
|
9505
|
-
args[_key - 1] = arguments[_key];
|
|
9506
|
-
}
|
|
9507
|
-
_this.emit(event, ...args);
|
|
9451
|
+
s2.backendConnector.on("*", (event, ...args) => {
|
|
9452
|
+
this.emit(event, ...args);
|
|
9508
9453
|
});
|
|
9509
9454
|
if (this.modules.languageDetector) {
|
|
9510
9455
|
s2.languageDetector = createClassOnDemand(this.modules.languageDetector);
|
|
@@ -9515,11 +9460,8 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
9515
9460
|
if (s2.i18nFormat.init) s2.i18nFormat.init(this);
|
|
9516
9461
|
}
|
|
9517
9462
|
this.translator = new Translator(this.services, this.options);
|
|
9518
|
-
this.translator.on("*",
|
|
9519
|
-
|
|
9520
|
-
args[_key2 - 1] = arguments[_key2];
|
|
9521
|
-
}
|
|
9522
|
-
_this.emit(event, ...args);
|
|
9463
|
+
this.translator.on("*", (event, ...args) => {
|
|
9464
|
+
this.emit(event, ...args);
|
|
9523
9465
|
});
|
|
9524
9466
|
this.modules.external.forEach((m2) => {
|
|
9525
9467
|
if (m2.init) m2.init(this);
|
|
@@ -9536,15 +9478,13 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
9536
9478
|
}
|
|
9537
9479
|
const storeApi = ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"];
|
|
9538
9480
|
storeApi.forEach((fcName) => {
|
|
9539
|
-
this[fcName] =
|
|
9540
|
-
return _this.store[fcName](...arguments);
|
|
9541
|
-
};
|
|
9481
|
+
this[fcName] = (...args) => this.store[fcName](...args);
|
|
9542
9482
|
});
|
|
9543
9483
|
const storeApiChained = ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"];
|
|
9544
9484
|
storeApiChained.forEach((fcName) => {
|
|
9545
|
-
this[fcName] =
|
|
9546
|
-
|
|
9547
|
-
return
|
|
9485
|
+
this[fcName] = (...args) => {
|
|
9486
|
+
this.store[fcName](...args);
|
|
9487
|
+
return this;
|
|
9548
9488
|
};
|
|
9549
9489
|
});
|
|
9550
9490
|
const deferred = defer();
|
|
@@ -9568,8 +9508,7 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
9568
9508
|
}
|
|
9569
9509
|
return deferred;
|
|
9570
9510
|
}
|
|
9571
|
-
loadResources(language) {
|
|
9572
|
-
let callback = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
|
|
9511
|
+
loadResources(language, callback = noop) {
|
|
9573
9512
|
let usedCallback = callback;
|
|
9574
9513
|
const usedLng = isString(language) ? language : this.language;
|
|
9575
9514
|
if (typeof language === "function") usedCallback = language;
|
|
@@ -9658,11 +9597,10 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
9658
9597
|
}
|
|
9659
9598
|
if (!this.resolvedLanguage && this.languages.indexOf(l2) < 0 && this.store.hasLanguageSomeTranslations(l2)) {
|
|
9660
9599
|
this.resolvedLanguage = l2;
|
|
9661
|
-
|
|
9600
|
+
this.languages.unshift(l2);
|
|
9662
9601
|
}
|
|
9663
9602
|
}
|
|
9664
9603
|
changeLanguage(lng, callback) {
|
|
9665
|
-
var _this2 = this;
|
|
9666
9604
|
this.isLanguageChangingTo = lng;
|
|
9667
9605
|
const deferred = defer();
|
|
9668
9606
|
this.emit("languageChanging", lng);
|
|
@@ -9684,12 +9622,8 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
9684
9622
|
} else {
|
|
9685
9623
|
this.isLanguageChangingTo = void 0;
|
|
9686
9624
|
}
|
|
9687
|
-
deferred.resolve(
|
|
9688
|
-
|
|
9689
|
-
});
|
|
9690
|
-
if (callback) callback(err2, function() {
|
|
9691
|
-
return _this2.t(...arguments);
|
|
9692
|
-
});
|
|
9625
|
+
deferred.resolve((...args) => this.t(...args));
|
|
9626
|
+
if (callback) callback(err2, (...args) => this.t(...args));
|
|
9693
9627
|
};
|
|
9694
9628
|
const setLng = (lngs) => {
|
|
9695
9629
|
if (!lng && !lngs && this.services.languageDetector) lngs = [];
|
|
@@ -9720,14 +9654,10 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
9720
9654
|
return deferred;
|
|
9721
9655
|
}
|
|
9722
9656
|
getFixedT(lng, ns, keyPrefix) {
|
|
9723
|
-
|
|
9724
|
-
const fixedT = function(key, opts) {
|
|
9657
|
+
const fixedT = (key, opts, ...rest) => {
|
|
9725
9658
|
let o2;
|
|
9726
9659
|
if (typeof opts !== "object") {
|
|
9727
|
-
|
|
9728
|
-
rest[_key3 - 2] = arguments[_key3];
|
|
9729
|
-
}
|
|
9730
|
-
o2 = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
|
|
9660
|
+
o2 = this.options.overloadTranslationOptionHandler([key, opts].concat(rest));
|
|
9731
9661
|
} else {
|
|
9732
9662
|
o2 = {
|
|
9733
9663
|
...opts
|
|
@@ -9737,14 +9667,14 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
9737
9667
|
o2.lngs = o2.lngs || fixedT.lngs;
|
|
9738
9668
|
o2.ns = o2.ns || fixedT.ns;
|
|
9739
9669
|
if (o2.keyPrefix !== "") o2.keyPrefix = o2.keyPrefix || keyPrefix || fixedT.keyPrefix;
|
|
9740
|
-
const keySeparator =
|
|
9670
|
+
const keySeparator = this.options.keySeparator || ".";
|
|
9741
9671
|
let resultKey;
|
|
9742
9672
|
if (o2.keyPrefix && Array.isArray(key)) {
|
|
9743
9673
|
resultKey = key.map((k2) => `${o2.keyPrefix}${keySeparator}${k2}`);
|
|
9744
9674
|
} else {
|
|
9745
9675
|
resultKey = o2.keyPrefix ? `${o2.keyPrefix}${keySeparator}${key}` : key;
|
|
9746
9676
|
}
|
|
9747
|
-
return
|
|
9677
|
+
return this.t(resultKey, o2);
|
|
9748
9678
|
};
|
|
9749
9679
|
if (isString(lng)) {
|
|
9750
9680
|
fixedT.lng = lng;
|
|
@@ -9755,23 +9685,16 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
9755
9685
|
fixedT.keyPrefix = keyPrefix;
|
|
9756
9686
|
return fixedT;
|
|
9757
9687
|
}
|
|
9758
|
-
t() {
|
|
9759
|
-
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
9760
|
-
args[_key4] = arguments[_key4];
|
|
9761
|
-
}
|
|
9688
|
+
t(...args) {
|
|
9762
9689
|
return this.translator?.translate(...args);
|
|
9763
9690
|
}
|
|
9764
|
-
exists() {
|
|
9765
|
-
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
9766
|
-
args[_key5] = arguments[_key5];
|
|
9767
|
-
}
|
|
9691
|
+
exists(...args) {
|
|
9768
9692
|
return this.translator?.exists(...args);
|
|
9769
9693
|
}
|
|
9770
9694
|
setDefaultNamespace(ns) {
|
|
9771
9695
|
this.options.defaultNS = ns;
|
|
9772
9696
|
}
|
|
9773
|
-
hasLoadedNamespace(ns) {
|
|
9774
|
-
let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
9697
|
+
hasLoadedNamespace(ns, options2 = {}) {
|
|
9775
9698
|
if (!this.isInitialized) {
|
|
9776
9699
|
this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages);
|
|
9777
9700
|
return false;
|
|
@@ -9836,14 +9759,10 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
9836
9759
|
const languageUtils = this.services?.languageUtils || new LanguageUtil(get());
|
|
9837
9760
|
return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
|
|
9838
9761
|
}
|
|
9839
|
-
static createInstance() {
|
|
9840
|
-
let options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
9841
|
-
let callback = arguments.length > 1 ? arguments[1] : void 0;
|
|
9762
|
+
static createInstance(options2 = {}, callback) {
|
|
9842
9763
|
return new _I18n(options2, callback);
|
|
9843
9764
|
}
|
|
9844
|
-
cloneInstance() {
|
|
9845
|
-
let options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
9846
|
-
let callback = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
|
|
9765
|
+
cloneInstance(options2 = {}, callback = noop) {
|
|
9847
9766
|
const forkResourceStore = options2.forkResourceStore;
|
|
9848
9767
|
if (forkResourceStore) delete options2.forkResourceStore;
|
|
9849
9768
|
const mergedOptions = {
|
|
@@ -9872,21 +9791,19 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
9872
9791
|
prev2[l2] = {
|
|
9873
9792
|
...this.store.data[l2]
|
|
9874
9793
|
};
|
|
9875
|
-
|
|
9794
|
+
prev2[l2] = Object.keys(prev2[l2]).reduce((acc, n) => {
|
|
9876
9795
|
acc[n] = {
|
|
9877
9796
|
...prev2[l2][n]
|
|
9878
9797
|
};
|
|
9879
9798
|
return acc;
|
|
9880
|
-
},
|
|
9799
|
+
}, prev2[l2]);
|
|
9800
|
+
return prev2;
|
|
9881
9801
|
}, {});
|
|
9882
9802
|
clone.store = new ResourceStore(clonedData, mergedOptions);
|
|
9883
9803
|
clone.services.resourceStore = clone.store;
|
|
9884
9804
|
}
|
|
9885
9805
|
clone.translator = new Translator(clone.services, mergedOptions);
|
|
9886
|
-
clone.translator.on("*",
|
|
9887
|
-
for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
|
|
9888
|
-
args[_key6 - 1] = arguments[_key6];
|
|
9889
|
-
}
|
|
9806
|
+
clone.translator.on("*", (event, ...args) => {
|
|
9890
9807
|
clone.emit(event, ...args);
|
|
9891
9808
|
});
|
|
9892
9809
|
clone.init(mergedOptions, callback);
|
|
@@ -14734,6 +14651,8 @@ function BillingPriceViewFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
14734
14651
|
id: json["id"],
|
|
14735
14652
|
interval: json["interval"],
|
|
14736
14653
|
isActive: json["is_active"],
|
|
14654
|
+
meterEventName: json["meter_event_name"] == null ? void 0 : json["meter_event_name"],
|
|
14655
|
+
meterEventPayloadKey: json["meter_event_payload_key"] == null ? void 0 : json["meter_event_payload_key"],
|
|
14737
14656
|
meterId: json["meter_id"] == null ? void 0 : json["meter_id"],
|
|
14738
14657
|
packageSize: json["package_size"],
|
|
14739
14658
|
price: json["price"],
|
|
@@ -15274,12 +15193,12 @@ function EventSummaryResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
15274
15193
|
return json;
|
|
15275
15194
|
}
|
|
15276
15195
|
return {
|
|
15277
|
-
companyCount: json["company_count"],
|
|
15196
|
+
companyCount: json["company_count"] == null ? void 0 : json["company_count"],
|
|
15278
15197
|
environmentId: json["environment_id"],
|
|
15279
15198
|
eventCount: json["event_count"],
|
|
15280
15199
|
eventSubtype: json["event_subtype"],
|
|
15281
15200
|
lastSeenAt: json["last_seen_at"] == null ? void 0 : new Date(json["last_seen_at"]),
|
|
15282
|
-
userCount: json["user_count"]
|
|
15201
|
+
userCount: json["user_count"] == null ? void 0 : json["user_count"]
|
|
15283
15202
|
};
|
|
15284
15203
|
}
|
|
15285
15204
|
|
|
@@ -15547,6 +15466,7 @@ function CompanyPlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
15547
15466
|
chargeType: json["charge_type"],
|
|
15548
15467
|
companyCanTrial: json["company_can_trial"],
|
|
15549
15468
|
companyCount: json["company_count"],
|
|
15469
|
+
controlledBy: json["controlled_by"],
|
|
15550
15470
|
createdAt: new Date(json["created_at"]),
|
|
15551
15471
|
current: json["current"],
|
|
15552
15472
|
custom: json["custom"],
|
|
@@ -15632,6 +15552,7 @@ function PlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
15632
15552
|
billingProduct: json["billing_product"] == null ? void 0 : BillingProductDetailResponseDataFromJSON(json["billing_product"]),
|
|
15633
15553
|
chargeType: json["charge_type"],
|
|
15634
15554
|
companyCount: json["company_count"],
|
|
15555
|
+
controlledBy: json["controlled_by"],
|
|
15635
15556
|
createdAt: new Date(json["created_at"]),
|
|
15636
15557
|
description: json["description"],
|
|
15637
15558
|
features: json["features"].map(
|
|
@@ -15778,31 +15699,45 @@ function ComponentHydrateResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
15778
15699
|
};
|
|
15779
15700
|
}
|
|
15780
15701
|
|
|
15781
|
-
// src/api/checkoutexternal/models/
|
|
15782
|
-
function
|
|
15783
|
-
return
|
|
15702
|
+
// src/api/checkoutexternal/models/SetupIntentResponseData.ts
|
|
15703
|
+
function SetupIntentResponseDataFromJSON(json) {
|
|
15704
|
+
return SetupIntentResponseDataFromJSONTyped(json, false);
|
|
15784
15705
|
}
|
|
15785
|
-
function
|
|
15706
|
+
function SetupIntentResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
15786
15707
|
if (json == null) {
|
|
15787
15708
|
return json;
|
|
15788
15709
|
}
|
|
15789
15710
|
return {
|
|
15790
|
-
|
|
15711
|
+
publishableKey: json["publishable_key"],
|
|
15712
|
+
setupIntentClientSecret: json["setup_intent_client_secret"] == null ? void 0 : json["setup_intent_client_secret"]
|
|
15713
|
+
};
|
|
15714
|
+
}
|
|
15715
|
+
|
|
15716
|
+
// src/api/checkoutexternal/models/CreateSetupIntentResponse.ts
|
|
15717
|
+
function CreateSetupIntentResponseFromJSON(json) {
|
|
15718
|
+
return CreateSetupIntentResponseFromJSONTyped(json, false);
|
|
15719
|
+
}
|
|
15720
|
+
function CreateSetupIntentResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
15721
|
+
if (json == null) {
|
|
15722
|
+
return json;
|
|
15723
|
+
}
|
|
15724
|
+
return {
|
|
15725
|
+
data: SetupIntentResponseDataFromJSON(json["data"]),
|
|
15791
15726
|
params: json["params"]
|
|
15792
15727
|
};
|
|
15793
15728
|
}
|
|
15794
15729
|
|
|
15795
|
-
// src/api/checkoutexternal/models/
|
|
15796
|
-
function
|
|
15797
|
-
return
|
|
15730
|
+
// src/api/checkoutexternal/models/DeletePaymentMethodResponse.ts
|
|
15731
|
+
function DeletePaymentMethodResponseFromJSON(json) {
|
|
15732
|
+
return DeletePaymentMethodResponseFromJSONTyped(json, false);
|
|
15798
15733
|
}
|
|
15799
|
-
function
|
|
15734
|
+
function DeletePaymentMethodResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
15800
15735
|
if (json == null) {
|
|
15801
15736
|
return json;
|
|
15802
15737
|
}
|
|
15803
15738
|
return {
|
|
15804
|
-
|
|
15805
|
-
|
|
15739
|
+
data: DeleteResponseFromJSON(json["data"]),
|
|
15740
|
+
params: json["params"]
|
|
15806
15741
|
};
|
|
15807
15742
|
}
|
|
15808
15743
|
|
|
@@ -16052,6 +15987,38 @@ var CheckoutexternalApi = class extends BaseAPI {
|
|
|
16052
15987
|
const response = await this.checkoutUnsubscribeRaw(initOverrides);
|
|
16053
15988
|
return await response.value();
|
|
16054
15989
|
}
|
|
15990
|
+
/**
|
|
15991
|
+
* Create setup intent
|
|
15992
|
+
*/
|
|
15993
|
+
async createSetupIntentRaw(initOverrides) {
|
|
15994
|
+
const queryParameters = {};
|
|
15995
|
+
const headerParameters = {};
|
|
15996
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
15997
|
+
headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
|
|
15998
|
+
"X-Schematic-Api-Key"
|
|
15999
|
+
);
|
|
16000
|
+
}
|
|
16001
|
+
const response = await this.request(
|
|
16002
|
+
{
|
|
16003
|
+
path: `/components/setup-intent`,
|
|
16004
|
+
method: "POST",
|
|
16005
|
+
headers: headerParameters,
|
|
16006
|
+
query: queryParameters
|
|
16007
|
+
},
|
|
16008
|
+
initOverrides
|
|
16009
|
+
);
|
|
16010
|
+
return new JSONApiResponse(
|
|
16011
|
+
response,
|
|
16012
|
+
(jsonValue) => CreateSetupIntentResponseFromJSON(jsonValue)
|
|
16013
|
+
);
|
|
16014
|
+
}
|
|
16015
|
+
/**
|
|
16016
|
+
* Create setup intent
|
|
16017
|
+
*/
|
|
16018
|
+
async createSetupIntent(initOverrides) {
|
|
16019
|
+
const response = await this.createSetupIntentRaw(initOverrides);
|
|
16020
|
+
return await response.value();
|
|
16021
|
+
}
|
|
16055
16022
|
/**
|
|
16056
16023
|
* Delete payment method
|
|
16057
16024
|
*/
|
|
@@ -16415,8 +16382,10 @@ var en_default = {
|
|
|
16415
16382
|
"Manage plan": "Manage plan",
|
|
16416
16383
|
Monthly: "Monthly",
|
|
16417
16384
|
Next: "Next",
|
|
16385
|
+
"No invoices created yet": "No invoices created yet",
|
|
16418
16386
|
"No limit": "No limit",
|
|
16419
16387
|
"No payment method added yet": "No payment method added yet",
|
|
16388
|
+
"No upcoming invoice": "No upcoming invoice",
|
|
16420
16389
|
"Not ready to cancel?": "Not ready to cancel?",
|
|
16421
16390
|
"On demand": "On demand",
|
|
16422
16391
|
"One time ": "One time",
|
|
@@ -16426,6 +16395,7 @@ var en_default = {
|
|
|
16426
16395
|
"Pay now": "Pay now",
|
|
16427
16396
|
"Payment Method": "Payment Method",
|
|
16428
16397
|
"Percent off": "{{percent}}% off",
|
|
16398
|
+
"Plan selected": "Plan selected",
|
|
16429
16399
|
Plan: "Plan",
|
|
16430
16400
|
Plans: "Plans",
|
|
16431
16401
|
"Please provide an access token.": "Please provide an access token.",
|
|
@@ -16447,13 +16417,15 @@ var en_default = {
|
|
|
16447
16417
|
"Session expired. Please refresh and try again.": "Session expired. Please refresh and try again.",
|
|
16448
16418
|
"Show details": "Show details",
|
|
16449
16419
|
"Start trial": "Start trial",
|
|
16420
|
+
"Start X day trial": "Start {{days}} day trial",
|
|
16450
16421
|
"Subscribe and close": "Subscribe and close",
|
|
16451
16422
|
"Subscription canceled": "Subscription canceled",
|
|
16452
16423
|
Subscription: "Subscription",
|
|
16453
16424
|
"Talk to support": "Talk to support",
|
|
16454
16425
|
Total: "Total",
|
|
16455
16426
|
"Trial ends in": "Trial ends in {{days}} days",
|
|
16456
|
-
"Trial
|
|
16427
|
+
"Trial in progress": "Trial in progress",
|
|
16428
|
+
"Trial selected": "Trial selected",
|
|
16457
16429
|
Trial: "Trial",
|
|
16458
16430
|
Unlimited: "Unlimited {{item}}",
|
|
16459
16431
|
"Unsubscribe failed": "Unsubscribe failed",
|
|
@@ -17148,7 +17120,7 @@ var EmbedProvider = ({
|
|
|
17148
17120
|
(0, import_react11.useEffect)(() => {
|
|
17149
17121
|
if (accessToken) {
|
|
17150
17122
|
const { headers = {} } = apiConfig ?? {};
|
|
17151
|
-
headers["X-Schematic-Components-Version"] = "0.7.
|
|
17123
|
+
headers["X-Schematic-Components-Version"] = "0.7.15";
|
|
17152
17124
|
headers["X-Schematic-Session-ID"] = sessionIdRef.current;
|
|
17153
17125
|
const config = new Configuration({
|
|
17154
17126
|
...apiConfig,
|
|
@@ -17275,7 +17247,7 @@ var Box = dt.div((props) => {
|
|
|
17275
17247
|
function reducer(acc, [key, value]) {
|
|
17276
17248
|
if (key.startsWith("$") && !["$viewport"].includes(key)) {
|
|
17277
17249
|
acc.push(
|
|
17278
|
-
// keys
|
|
17250
|
+
// keys should always be CSS properties
|
|
17279
17251
|
attr(camelToHyphen(key.slice(1)), value)
|
|
17280
17252
|
);
|
|
17281
17253
|
}
|
|
@@ -17285,11 +17257,11 @@ var Box = dt.div((props) => {
|
|
|
17285
17257
|
for (const [key, value] of Object.entries(props.$viewport || {})) {
|
|
17286
17258
|
styles.push(lt`
|
|
17287
17259
|
${{
|
|
17288
|
-
sm: "@
|
|
17289
|
-
md: "@
|
|
17290
|
-
lg: "@
|
|
17291
|
-
xl: "@
|
|
17292
|
-
"2xl": "@
|
|
17260
|
+
sm: "@container (min-width: 640px)",
|
|
17261
|
+
md: "@container (min-width: 768px)",
|
|
17262
|
+
lg: "@container (min-width: 1024px)",
|
|
17263
|
+
xl: "@container (min-width: 1280px)",
|
|
17264
|
+
"2xl": "@container (min-width: 1536px)"
|
|
17293
17265
|
}[key] || key} {
|
|
17294
17266
|
${Object.entries(value || {}).reduce(reducer, [])}
|
|
17295
17267
|
}
|
|
@@ -17592,29 +17564,23 @@ var Button = dt.button(
|
|
|
17592
17564
|
case "sm":
|
|
17593
17565
|
return lt`
|
|
17594
17566
|
font-size: ${15 / TEXT_BASE_SIZE}rem;
|
|
17595
|
-
${
|
|
17596
|
-
|
|
17597
|
-
|
|
17598
|
-
border-radius: ${6 / TEXT_BASE_SIZE}rem;
|
|
17599
|
-
`}
|
|
17567
|
+
height: ${40 / TEXT_BASE_SIZE}rem;
|
|
17568
|
+
padding: ${7 / TEXT_BASE_SIZE}rem ${20 / TEXT_BASE_SIZE}rem;
|
|
17569
|
+
border-radius: ${6 / TEXT_BASE_SIZE}rem;
|
|
17600
17570
|
`;
|
|
17601
17571
|
case "md":
|
|
17602
17572
|
return lt`
|
|
17603
17573
|
font-size: ${17 / TEXT_BASE_SIZE}rem;
|
|
17604
|
-
${
|
|
17605
|
-
|
|
17606
|
-
|
|
17607
|
-
border-radius: ${8 / TEXT_BASE_SIZE}rem;
|
|
17608
|
-
`}
|
|
17574
|
+
height: ${52 / TEXT_BASE_SIZE}rem;
|
|
17575
|
+
padding: ${8 / TEXT_BASE_SIZE}rem ${24 / TEXT_BASE_SIZE}rem;
|
|
17576
|
+
border-radius: ${8 / TEXT_BASE_SIZE}rem;
|
|
17609
17577
|
`;
|
|
17610
17578
|
case "lg":
|
|
17611
17579
|
return lt`
|
|
17612
17580
|
font-size: ${19 / TEXT_BASE_SIZE}rem;
|
|
17613
|
-
${
|
|
17614
|
-
|
|
17615
|
-
|
|
17616
|
-
border-radius: ${10 / TEXT_BASE_SIZE}rem;
|
|
17617
|
-
`}
|
|
17581
|
+
height: ${64 / TEXT_BASE_SIZE}rem;
|
|
17582
|
+
padding: ${9 / TEXT_BASE_SIZE}rem ${28 / TEXT_BASE_SIZE}rem;
|
|
17583
|
+
border-radius: ${10 / TEXT_BASE_SIZE}rem;
|
|
17618
17584
|
`;
|
|
17619
17585
|
}
|
|
17620
17586
|
}}
|
|
@@ -18478,6 +18444,7 @@ var Container2 = dt.div`
|
|
|
18478
18444
|
line-height: 1.35;
|
|
18479
18445
|
width: 100%;
|
|
18480
18446
|
height: 100%;
|
|
18447
|
+
container-type: inline-size;
|
|
18481
18448
|
|
|
18482
18449
|
*,
|
|
18483
18450
|
*::before,
|
|
@@ -18632,7 +18599,8 @@ var StageButton = ({
|
|
|
18632
18599
|
isLoading,
|
|
18633
18600
|
requiresPayment,
|
|
18634
18601
|
setCheckoutStage,
|
|
18635
|
-
trialPaymentMethodRequired
|
|
18602
|
+
trialPaymentMethodRequired,
|
|
18603
|
+
willTrial
|
|
18636
18604
|
}) => {
|
|
18637
18605
|
const { t: t2 } = useTranslation();
|
|
18638
18606
|
const NoPaymentRequired = () => {
|
|
@@ -18648,42 +18616,14 @@ var StageButton = ({
|
|
|
18648
18616
|
);
|
|
18649
18617
|
};
|
|
18650
18618
|
if (checkoutStage === "plan") {
|
|
18651
|
-
if (canTrial) {
|
|
18652
|
-
if (trialPaymentMethodRequired) {
|
|
18653
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
18654
|
-
Button,
|
|
18655
|
-
{
|
|
18656
|
-
type: "button",
|
|
18657
|
-
disabled: !hasAddOns && !canUpdateSubscription,
|
|
18658
|
-
onClick: async () => {
|
|
18659
|
-
setCheckoutStage?.("checkout");
|
|
18660
|
-
},
|
|
18661
|
-
$isLoading: isLoading,
|
|
18662
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
18663
|
-
Flex,
|
|
18664
|
-
{
|
|
18665
|
-
$gap: "0.5rem",
|
|
18666
|
-
$justifyContent: "center",
|
|
18667
|
-
$alignItems: "center",
|
|
18668
|
-
$padding: "0 1rem",
|
|
18669
|
-
children: [
|
|
18670
|
-
t2("Next"),
|
|
18671
|
-
": ",
|
|
18672
|
-
t2("Checkout"),
|
|
18673
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon2, { name: "arrow-right" })
|
|
18674
|
-
]
|
|
18675
|
-
}
|
|
18676
|
-
)
|
|
18677
|
-
}
|
|
18678
|
-
);
|
|
18679
|
-
}
|
|
18619
|
+
if (canTrial && trialPaymentMethodRequired) {
|
|
18680
18620
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
18681
18621
|
Button,
|
|
18682
18622
|
{
|
|
18683
18623
|
type: "button",
|
|
18684
|
-
disabled: !
|
|
18624
|
+
disabled: !hasAddOns && !canUpdateSubscription,
|
|
18685
18625
|
onClick: async () => {
|
|
18686
|
-
checkout
|
|
18626
|
+
setCheckoutStage?.("checkout");
|
|
18687
18627
|
},
|
|
18688
18628
|
$isLoading: isLoading,
|
|
18689
18629
|
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
@@ -18694,7 +18634,9 @@ var StageButton = ({
|
|
|
18694
18634
|
$alignItems: "center",
|
|
18695
18635
|
$padding: "0 1rem",
|
|
18696
18636
|
children: [
|
|
18697
|
-
t2("
|
|
18637
|
+
t2("Next"),
|
|
18638
|
+
": ",
|
|
18639
|
+
t2("Checkout"),
|
|
18698
18640
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon2, { name: "arrow-right" })
|
|
18699
18641
|
]
|
|
18700
18642
|
}
|
|
@@ -18703,7 +18645,7 @@ var StageButton = ({
|
|
|
18703
18645
|
);
|
|
18704
18646
|
}
|
|
18705
18647
|
if (!requiresPayment && !checkoutStages?.some(
|
|
18706
|
-
(stage) => stage.id === "
|
|
18648
|
+
(stage) => stage.id === "usage" || stage.id === "addons"
|
|
18707
18649
|
)) {
|
|
18708
18650
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(NoPaymentRequired, {});
|
|
18709
18651
|
}
|
|
@@ -18729,7 +18671,7 @@ var StageButton = ({
|
|
|
18729
18671
|
);
|
|
18730
18672
|
}
|
|
18731
18673
|
if (checkoutStage === "usage") {
|
|
18732
|
-
if (!requiresPayment) {
|
|
18674
|
+
if (!requiresPayment && !checkoutStages?.some((stage) => stage.id === "addons")) {
|
|
18733
18675
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(NoPaymentRequired, {});
|
|
18734
18676
|
}
|
|
18735
18677
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
@@ -18801,7 +18743,7 @@ var StageButton = ({
|
|
|
18801
18743
|
disabled: isLoading || !hasUnstagedChanges || !canCheckout,
|
|
18802
18744
|
onClick: checkout,
|
|
18803
18745
|
$isLoading: isLoading,
|
|
18804
|
-
children:
|
|
18746
|
+
children: willTrial ? t2("Start trial") : t2("Pay now")
|
|
18805
18747
|
}
|
|
18806
18748
|
);
|
|
18807
18749
|
}
|
|
@@ -18827,7 +18769,8 @@ var Sidebar = ({
|
|
|
18827
18769
|
setError,
|
|
18828
18770
|
setIsLoading,
|
|
18829
18771
|
updatePromoCode,
|
|
18830
|
-
showHeader = true
|
|
18772
|
+
showHeader = true,
|
|
18773
|
+
willTrial = false
|
|
18831
18774
|
}) => {
|
|
18832
18775
|
const { t: t2 } = useTranslation();
|
|
18833
18776
|
const theme = nt();
|
|
@@ -18957,10 +18900,10 @@ var Sidebar = ({
|
|
|
18957
18900
|
...promoCode && { promoCode }
|
|
18958
18901
|
}
|
|
18959
18902
|
});
|
|
18960
|
-
dispatchPlanChangedEvent(response.data);
|
|
18961
18903
|
setIsLoading(false);
|
|
18962
18904
|
setLayout("portal");
|
|
18963
|
-
hydrate();
|
|
18905
|
+
await hydrate();
|
|
18906
|
+
dispatchPlanChangedEvent(response.data);
|
|
18964
18907
|
} catch {
|
|
18965
18908
|
setLayout("checkout");
|
|
18966
18909
|
setError(
|
|
@@ -19058,6 +19001,7 @@ var Sidebar = ({
|
|
|
19058
19001
|
currentUsageBasedEntitlements,
|
|
19059
19002
|
usageBasedEntitlements
|
|
19060
19003
|
]);
|
|
19004
|
+
const willPeriodChange = planPeriod !== data.company?.plan?.planPeriod;
|
|
19061
19005
|
const willPlanChange = typeof selectedPlan !== "undefined" && !selectedPlan.current;
|
|
19062
19006
|
const removedAddOns = currentAddOns.filter(
|
|
19063
19007
|
(current) => !selectedAddOns.some((selected) => current.id === selected.id) && current.planPeriod !== "one-time"
|
|
@@ -19067,10 +19011,10 @@ var Sidebar = ({
|
|
|
19067
19011
|
);
|
|
19068
19012
|
const willAddOnsChange = removedAddOns.length > 0 || addedAddOns.length > 0;
|
|
19069
19013
|
const willPayInAdvanceEntitlementsChange = payInAdvanceEntitlements.length > 0 && payInAdvanceEntitlements.some(({ quantity, usage }) => quantity !== usage);
|
|
19070
|
-
const hasUnstagedChanges = willPlanChange || willAddOnsChange || willPayInAdvanceEntitlementsChange;
|
|
19014
|
+
const hasUnstagedChanges = willPeriodChange || willPlanChange || willAddOnsChange || willPayInAdvanceEntitlementsChange;
|
|
19071
19015
|
const canUpdateSubscription = mode === "edit" || api !== null && !isLoading;
|
|
19072
19016
|
const canCheckout = canUpdateSubscription && (!!data.subscription?.paymentMethod || typeof paymentMethodId === "string");
|
|
19073
|
-
const isTrialable = selectedPlan?.companyCanTrial;
|
|
19017
|
+
const isTrialable = selectedPlan?.companyCanTrial === true;
|
|
19074
19018
|
const today = /* @__PURE__ */ new Date();
|
|
19075
19019
|
const trialEndsOn = new Date(today);
|
|
19076
19020
|
if (isTrialable && selectedPlan.trialDays) {
|
|
@@ -19146,7 +19090,7 @@ var Sidebar = ({
|
|
|
19146
19090
|
}
|
|
19147
19091
|
) }),
|
|
19148
19092
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Flex, { $flexDirection: "column", $gap: "0.5rem", $marginBottom: "1.5rem", children: [
|
|
19149
|
-
|
|
19093
|
+
currentPlan && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
19150
19094
|
Flex,
|
|
19151
19095
|
{
|
|
19152
19096
|
$justifyContent: "space-between",
|
|
@@ -19165,10 +19109,10 @@ var Sidebar = ({
|
|
|
19165
19109
|
$size: theme.typography.heading4.fontSize,
|
|
19166
19110
|
$weight: theme.typography.heading4.fontWeight,
|
|
19167
19111
|
$color: theme.typography.heading4.color,
|
|
19168
|
-
children:
|
|
19112
|
+
children: currentPlan.name
|
|
19169
19113
|
}
|
|
19170
19114
|
) }),
|
|
19171
|
-
typeof
|
|
19115
|
+
typeof currentPlan.planPrice === "number" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Box, { $whiteSpace: "nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
19172
19116
|
Text,
|
|
19173
19117
|
{
|
|
19174
19118
|
$font: theme.typography.text.fontFamily,
|
|
@@ -19177,14 +19121,12 @@ var Sidebar = ({
|
|
|
19177
19121
|
$color: theme.typography.text.color,
|
|
19178
19122
|
children: [
|
|
19179
19123
|
formatCurrency(
|
|
19180
|
-
|
|
19181
|
-
data.company
|
|
19124
|
+
currentPlan.planPrice,
|
|
19125
|
+
data.company?.billingSubscription?.currency
|
|
19182
19126
|
),
|
|
19183
19127
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("sub", { children: [
|
|
19184
19128
|
"/",
|
|
19185
|
-
shortenPeriod(
|
|
19186
|
-
data.company.plan.planPeriod || planPeriod
|
|
19187
|
-
)
|
|
19129
|
+
shortenPeriod(currentPlan.planPeriod || planPeriod)
|
|
19188
19130
|
] })
|
|
19189
19131
|
]
|
|
19190
19132
|
}
|
|
@@ -19950,7 +19892,7 @@ var Sidebar = ({
|
|
|
19950
19892
|
layout === "checkout" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
19951
19893
|
StageButton,
|
|
19952
19894
|
{
|
|
19953
|
-
canTrial:
|
|
19895
|
+
canTrial: isTrialable,
|
|
19954
19896
|
canCheckout,
|
|
19955
19897
|
canUpdateSubscription,
|
|
19956
19898
|
checkout,
|
|
@@ -19962,7 +19904,8 @@ var Sidebar = ({
|
|
|
19962
19904
|
isLoading,
|
|
19963
19905
|
requiresPayment,
|
|
19964
19906
|
setCheckoutStage,
|
|
19965
|
-
trialPaymentMethodRequired: data.trialPaymentMethodRequired === true
|
|
19907
|
+
trialPaymentMethodRequired: data.trialPaymentMethodRequired === true,
|
|
19908
|
+
willTrial
|
|
19966
19909
|
}
|
|
19967
19910
|
),
|
|
19968
19911
|
layout === "unsubscribe" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { onClick: unsubscribe, $isLoading: isLoading, children: t2("Cancel subscription") }),
|
|
@@ -20272,13 +20215,11 @@ var Navigation = ({
|
|
|
20272
20215
|
}
|
|
20273
20216
|
),
|
|
20274
20217
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
20275
|
-
|
|
20218
|
+
Text,
|
|
20276
20219
|
{
|
|
20220
|
+
as: Box,
|
|
20277
20221
|
tabIndex: 0,
|
|
20278
|
-
$
|
|
20279
|
-
$fontFamily: theme.typography.text.fontFamily,
|
|
20280
|
-
$fontWeight: index === activeIndex ? 600 : 400,
|
|
20281
|
-
$color: theme.typography.text.color,
|
|
20222
|
+
$weight: index === activeIndex ? 600 : 400,
|
|
20282
20223
|
...!showFullContent && {
|
|
20283
20224
|
$overflow: "hidden",
|
|
20284
20225
|
$whiteSpace: "nowrap",
|
|
@@ -20331,15 +20272,162 @@ var ButtonLink = dt.a`
|
|
|
20331
20272
|
|
|
20332
20273
|
// src/components/shared/checkout-dialog/Plan.tsx
|
|
20333
20274
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
20275
|
+
var Selected = ({ isCurrent = false, isTrial = false }) => {
|
|
20276
|
+
const { t: t2 } = useTranslation();
|
|
20277
|
+
const theme = nt();
|
|
20278
|
+
const text = (0, import_react25.useMemo)(() => {
|
|
20279
|
+
if (isCurrent) {
|
|
20280
|
+
return isTrial ? t2("Trial in progress") : t2("Current plan");
|
|
20281
|
+
}
|
|
20282
|
+
return isTrial ? t2("Trial selected") : t2("Plan selected");
|
|
20283
|
+
}, [t2, isCurrent, isTrial]);
|
|
20284
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
20285
|
+
Flex,
|
|
20286
|
+
{
|
|
20287
|
+
$justifyContent: "center",
|
|
20288
|
+
$alignItems: "center",
|
|
20289
|
+
$gap: "0.25rem",
|
|
20290
|
+
$padding: "0.625rem 0",
|
|
20291
|
+
children: [
|
|
20292
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20293
|
+
Icon2,
|
|
20294
|
+
{
|
|
20295
|
+
name: "check-rounded",
|
|
20296
|
+
style: {
|
|
20297
|
+
fontSize: 20,
|
|
20298
|
+
lineHeight: 1,
|
|
20299
|
+
color: theme.primary
|
|
20300
|
+
}
|
|
20301
|
+
}
|
|
20302
|
+
),
|
|
20303
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20304
|
+
Text,
|
|
20305
|
+
{
|
|
20306
|
+
$font: theme.typography.text.fontFamily,
|
|
20307
|
+
$size: 15 / 16 * theme.typography.text.fontSize,
|
|
20308
|
+
$weight: theme.typography.text.fontWeight,
|
|
20309
|
+
$color: theme.typography.text.color,
|
|
20310
|
+
$leading: 1,
|
|
20311
|
+
children: text
|
|
20312
|
+
}
|
|
20313
|
+
)
|
|
20314
|
+
]
|
|
20315
|
+
}
|
|
20316
|
+
);
|
|
20317
|
+
};
|
|
20318
|
+
var PlanButtonGroup = ({
|
|
20319
|
+
plan,
|
|
20320
|
+
isLoading,
|
|
20321
|
+
isSelected,
|
|
20322
|
+
onSelect,
|
|
20323
|
+
willTrial
|
|
20324
|
+
}) => {
|
|
20325
|
+
const { t: t2 } = useTranslation();
|
|
20326
|
+
const { data } = useEmbed();
|
|
20327
|
+
const isCurrent = plan.id === data.company?.plan?.id;
|
|
20328
|
+
if (plan.companyCanTrial) {
|
|
20329
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Flex, { $flexDirection: "column", $gap: "1.5rem", children: [
|
|
20330
|
+
data.subscription?.status !== "trialing" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: isSelected && willTrial ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20331
|
+
Selected,
|
|
20332
|
+
{
|
|
20333
|
+
isCurrent,
|
|
20334
|
+
isTrial: plan.companyCanTrial && willTrial
|
|
20335
|
+
}
|
|
20336
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20337
|
+
Button,
|
|
20338
|
+
{
|
|
20339
|
+
type: "button",
|
|
20340
|
+
disabled: (isLoading || !plan.valid) && !plan.custom,
|
|
20341
|
+
...!plan.custom && {
|
|
20342
|
+
onClick: () => {
|
|
20343
|
+
onSelect({
|
|
20344
|
+
plan,
|
|
20345
|
+
shouldTrial: true
|
|
20346
|
+
});
|
|
20347
|
+
}
|
|
20348
|
+
},
|
|
20349
|
+
$size: "sm",
|
|
20350
|
+
$color: "primary",
|
|
20351
|
+
$variant: "filled",
|
|
20352
|
+
children: plan.custom ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20353
|
+
ButtonLink,
|
|
20354
|
+
{
|
|
20355
|
+
href: plan.customPlanConfig?.ctaWebSite ?? "#",
|
|
20356
|
+
target: "_blank",
|
|
20357
|
+
children: plan.customPlanConfig?.ctaText ?? t2("Talk to support")
|
|
20358
|
+
}
|
|
20359
|
+
) : !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20360
|
+
Tooltip,
|
|
20361
|
+
{
|
|
20362
|
+
trigger: t2("Over usage limit"),
|
|
20363
|
+
content: t2("Current usage exceeds the limit of this plan.")
|
|
20364
|
+
}
|
|
20365
|
+
) : t2("Start X day trial", { days: plan.trialDays })
|
|
20366
|
+
}
|
|
20367
|
+
) }),
|
|
20368
|
+
!plan.custom && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: isSelected && (!willTrial || data.subscription?.status === "trialing") ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Selected, { isCurrent }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20369
|
+
Button,
|
|
20370
|
+
{
|
|
20371
|
+
type: "button",
|
|
20372
|
+
disabled: isLoading || !plan.valid,
|
|
20373
|
+
onClick: () => {
|
|
20374
|
+
onSelect({ plan, shouldTrial: false });
|
|
20375
|
+
},
|
|
20376
|
+
$size: "sm",
|
|
20377
|
+
$color: "primary",
|
|
20378
|
+
$variant: data.subscription?.status === "trialing" ? "filled" : "text",
|
|
20379
|
+
children: !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20380
|
+
Tooltip,
|
|
20381
|
+
{
|
|
20382
|
+
trigger: t2("Over usage limit"),
|
|
20383
|
+
content: t2("Current usage exceeds the limit of this plan.")
|
|
20384
|
+
}
|
|
20385
|
+
) : t2("Choose plan")
|
|
20386
|
+
}
|
|
20387
|
+
) })
|
|
20388
|
+
] });
|
|
20389
|
+
}
|
|
20390
|
+
return isSelected ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Selected, { isCurrent }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20391
|
+
Button,
|
|
20392
|
+
{
|
|
20393
|
+
type: "button",
|
|
20394
|
+
disabled: (isLoading || !plan.valid) && !plan.custom,
|
|
20395
|
+
...!plan.custom && {
|
|
20396
|
+
onClick: () => {
|
|
20397
|
+
onSelect({ plan });
|
|
20398
|
+
}
|
|
20399
|
+
},
|
|
20400
|
+
$size: "sm",
|
|
20401
|
+
$color: "primary",
|
|
20402
|
+
$variant: "filled",
|
|
20403
|
+
children: plan.custom ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20404
|
+
ButtonLink,
|
|
20405
|
+
{
|
|
20406
|
+
href: plan.customPlanConfig?.ctaWebSite ?? "#",
|
|
20407
|
+
target: "_blank",
|
|
20408
|
+
children: plan.customPlanConfig?.ctaText ?? t2("Talk to support")
|
|
20409
|
+
}
|
|
20410
|
+
) : !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20411
|
+
Tooltip,
|
|
20412
|
+
{
|
|
20413
|
+
trigger: t2("Over usage limit"),
|
|
20414
|
+
content: t2("Current usage exceeds the limit of this plan.")
|
|
20415
|
+
}
|
|
20416
|
+
) : t2("Choose plan")
|
|
20417
|
+
}
|
|
20418
|
+
);
|
|
20419
|
+
};
|
|
20334
20420
|
var Plan = ({
|
|
20335
20421
|
isLoading,
|
|
20336
20422
|
plans,
|
|
20337
20423
|
selectedPlan,
|
|
20338
20424
|
period,
|
|
20339
|
-
selectPlan
|
|
20425
|
+
selectPlan,
|
|
20426
|
+
willTrial
|
|
20340
20427
|
}) => {
|
|
20341
20428
|
const { t: t2 } = useTranslation();
|
|
20342
20429
|
const theme = nt();
|
|
20430
|
+
const { data } = useEmbed();
|
|
20343
20431
|
const isLightBackground = useIsLightBackground();
|
|
20344
20432
|
const [entitlementCounts, setEntitlementCounts] = (0, import_react25.useState)(
|
|
20345
20433
|
() => plans.reduce(
|
|
@@ -20353,7 +20441,6 @@ var Plan = ({
|
|
|
20353
20441
|
{}
|
|
20354
20442
|
)
|
|
20355
20443
|
);
|
|
20356
|
-
const cardPadding = theme.card.padding / TEXT_BASE_SIZE;
|
|
20357
20444
|
const handleToggleShowAll = (id) => {
|
|
20358
20445
|
setEntitlementCounts((prev2) => {
|
|
20359
20446
|
const count = { ...prev2[id] };
|
|
@@ -20366,6 +20453,7 @@ var Plan = ({
|
|
|
20366
20453
|
};
|
|
20367
20454
|
});
|
|
20368
20455
|
};
|
|
20456
|
+
const cardPadding = theme.card.padding / TEXT_BASE_SIZE;
|
|
20369
20457
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20370
20458
|
Box,
|
|
20371
20459
|
{
|
|
@@ -20474,7 +20562,7 @@ var Plan = ({
|
|
|
20474
20562
|
$size: 0.75 * theme.typography.text.fontSize,
|
|
20475
20563
|
$weight: theme.typography.text.fontWeight,
|
|
20476
20564
|
$color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
|
|
20477
|
-
children: t2("Active")
|
|
20565
|
+
children: data.subscription?.status === "trialing" ? t2("Trialing") : t2("Active")
|
|
20478
20566
|
}
|
|
20479
20567
|
)
|
|
20480
20568
|
}
|
|
@@ -20689,70 +20777,14 @@ var Plan = ({
|
|
|
20689
20777
|
}
|
|
20690
20778
|
)
|
|
20691
20779
|
] }),
|
|
20692
|
-
|
|
20693
|
-
|
|
20694
|
-
{
|
|
20695
|
-
$justifyContent: "center",
|
|
20696
|
-
$alignItems: "center",
|
|
20697
|
-
$gap: "0.25rem",
|
|
20698
|
-
$padding: "0.625rem 0",
|
|
20699
|
-
children: [
|
|
20700
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20701
|
-
Icon2,
|
|
20702
|
-
{
|
|
20703
|
-
name: "check-rounded",
|
|
20704
|
-
style: {
|
|
20705
|
-
fontSize: 20,
|
|
20706
|
-
lineHeight: 1,
|
|
20707
|
-
color: theme.primary
|
|
20708
|
-
}
|
|
20709
|
-
}
|
|
20710
|
-
),
|
|
20711
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20712
|
-
Text,
|
|
20713
|
-
{
|
|
20714
|
-
$font: theme.typography.text.fontFamily,
|
|
20715
|
-
$size: 15 / 16 * theme.typography.text.fontSize,
|
|
20716
|
-
$weight: theme.typography.text.fontWeight,
|
|
20717
|
-
$color: theme.typography.text.color,
|
|
20718
|
-
$leading: 1,
|
|
20719
|
-
children: plan.current ? t2("Current plan") : t2("Selected")
|
|
20720
|
-
}
|
|
20721
|
-
)
|
|
20722
|
-
]
|
|
20723
|
-
}
|
|
20724
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20725
|
-
Button,
|
|
20780
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20781
|
+
PlanButtonGroup,
|
|
20726
20782
|
{
|
|
20727
|
-
|
|
20728
|
-
|
|
20729
|
-
|
|
20730
|
-
|
|
20731
|
-
|
|
20732
|
-
return;
|
|
20733
|
-
}
|
|
20734
|
-
selectPlan({ plan });
|
|
20735
|
-
}
|
|
20736
|
-
},
|
|
20737
|
-
$size: "sm",
|
|
20738
|
-
$color: "primary",
|
|
20739
|
-
$variant: plan.current ? "outline" : "filled",
|
|
20740
|
-
children: plan.custom ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20741
|
-
ButtonLink,
|
|
20742
|
-
{
|
|
20743
|
-
href: plan.customPlanConfig?.ctaWebSite ?? "#",
|
|
20744
|
-
target: "_blank",
|
|
20745
|
-
children: plan.customPlanConfig?.ctaText ?? t2("Talk to support")
|
|
20746
|
-
}
|
|
20747
|
-
) : !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20748
|
-
Tooltip,
|
|
20749
|
-
{
|
|
20750
|
-
trigger: t2("Over usage limit"),
|
|
20751
|
-
content: t2(
|
|
20752
|
-
"Current usage exceeds the limit of this plan."
|
|
20753
|
-
)
|
|
20754
|
-
}
|
|
20755
|
-
) : plan.companyCanTrial ? t2("Trial plan", { days: plan.trialDays }) : t2("Choose plan")
|
|
20783
|
+
plan,
|
|
20784
|
+
isLoading,
|
|
20785
|
+
isSelected: plan.id === selectedPlan?.id,
|
|
20786
|
+
onSelect: selectPlan,
|
|
20787
|
+
willTrial
|
|
20756
20788
|
}
|
|
20757
20789
|
)
|
|
20758
20790
|
]
|
|
@@ -20967,7 +20999,6 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
20967
20999
|
);
|
|
20968
21000
|
const [isLoading, setIsLoading] = (0, import_react26.useState)(false);
|
|
20969
21001
|
const [error, setError] = (0, import_react26.useState)();
|
|
20970
|
-
const [promoCode, setPromoCode] = (0, import_react26.useState)();
|
|
20971
21002
|
const [planPeriod, setPlanPeriod] = (0, import_react26.useState)(
|
|
20972
21003
|
selected.period || data.company?.plan?.planPeriod || "month"
|
|
20973
21004
|
);
|
|
@@ -20981,6 +21012,9 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
20981
21012
|
(plan) => selected.planId ? plan.id === selected.planId : plan.current
|
|
20982
21013
|
)
|
|
20983
21014
|
);
|
|
21015
|
+
const [willTrial, setWillTrial] = (0, import_react26.useState)(
|
|
21016
|
+
data.subscription?.status !== "trialing" && !data.trialPaymentMethodRequired
|
|
21017
|
+
);
|
|
20984
21018
|
const [addOns, setAddOns] = (0, import_react26.useState)(
|
|
20985
21019
|
() => availableAddOns.map((addOn) => ({
|
|
20986
21020
|
...addOn,
|
|
@@ -20989,6 +21023,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
20989
21023
|
)
|
|
20990
21024
|
}))
|
|
20991
21025
|
);
|
|
21026
|
+
const hasActiveAddOns = addOns.some((addOn) => addOn.isSelected);
|
|
20992
21027
|
const currentEntitlements = (0, import_react26.useMemo)(() => {
|
|
20993
21028
|
return data.featureUsage?.features || [];
|
|
20994
21029
|
}, [data.featureUsage?.features]);
|
|
@@ -21007,11 +21042,14 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
21007
21042
|
),
|
|
21008
21043
|
[usageBasedEntitlements]
|
|
21009
21044
|
);
|
|
21010
|
-
const hasActiveAddOns = addOns.some((addOn) => addOn.isSelected);
|
|
21011
21045
|
const hasActivePayInAdvanceEntitlements = payInAdvanceEntitlements.some(
|
|
21012
21046
|
({ quantity }) => quantity > 0
|
|
21013
21047
|
);
|
|
21014
|
-
const
|
|
21048
|
+
const [promoCode, setPromoCode] = (0, import_react26.useState)();
|
|
21049
|
+
const isTrialable = selectedPlan?.isTrialable === true && selectedPlan?.companyCanTrial === true;
|
|
21050
|
+
const isTrialableAndFree = isTrialable && data.trialPaymentMethodRequired !== true;
|
|
21051
|
+
const planRequiresPayment = !isTrialableAndFree || !isTrialable && selectedPlan?.isFree !== true;
|
|
21052
|
+
const requiresPayment = planRequiresPayment || hasActiveAddOns || hasActivePayInAdvanceEntitlements;
|
|
21015
21053
|
const checkoutStages = (0, import_react26.useMemo)(() => {
|
|
21016
21054
|
const stages = [
|
|
21017
21055
|
{
|
|
@@ -21021,13 +21059,16 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
21021
21059
|
description: t2("Choose your base plan")
|
|
21022
21060
|
}
|
|
21023
21061
|
];
|
|
21024
|
-
if (
|
|
21062
|
+
if (willTrial) {
|
|
21063
|
+
return stages;
|
|
21064
|
+
}
|
|
21065
|
+
if (payInAdvanceEntitlements.length > 0) {
|
|
21025
21066
|
stages.push({
|
|
21026
21067
|
id: "usage",
|
|
21027
21068
|
name: t2("Quantity")
|
|
21028
21069
|
});
|
|
21029
21070
|
}
|
|
21030
|
-
if (availableAddOns.length
|
|
21071
|
+
if (availableAddOns.length > 0) {
|
|
21031
21072
|
stages.push({
|
|
21032
21073
|
id: "addons",
|
|
21033
21074
|
name: t2("Add-ons"),
|
|
@@ -21045,9 +21086,9 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
21045
21086
|
return stages;
|
|
21046
21087
|
}, [
|
|
21047
21088
|
t2,
|
|
21089
|
+
willTrial,
|
|
21048
21090
|
payInAdvanceEntitlements,
|
|
21049
21091
|
availableAddOns,
|
|
21050
|
-
selectedPlan?.companyCanTrial,
|
|
21051
21092
|
requiresPayment
|
|
21052
21093
|
]);
|
|
21053
21094
|
const [checkoutStage, setCheckoutStage] = (0, import_react26.useState)(() => {
|
|
@@ -21152,6 +21193,8 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
21152
21193
|
setSelectedPlan(plan);
|
|
21153
21194
|
setUsageBasedEntitlements(entitlements);
|
|
21154
21195
|
}
|
|
21196
|
+
const shouldTrial = updates.shouldTrial ?? false;
|
|
21197
|
+
setWillTrial(shouldTrial && !data.trialPaymentMethodRequired);
|
|
21155
21198
|
previewCheckout({
|
|
21156
21199
|
period,
|
|
21157
21200
|
plan: updates.plan,
|
|
@@ -21160,7 +21203,13 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
21160
21203
|
)
|
|
21161
21204
|
});
|
|
21162
21205
|
},
|
|
21163
|
-
[
|
|
21206
|
+
[
|
|
21207
|
+
data.trialPaymentMethodRequired,
|
|
21208
|
+
planPeriod,
|
|
21209
|
+
selectedPlan,
|
|
21210
|
+
currentEntitlements,
|
|
21211
|
+
previewCheckout
|
|
21212
|
+
]
|
|
21164
21213
|
);
|
|
21165
21214
|
const changePlanPeriod = (0, import_react26.useCallback)(
|
|
21166
21215
|
(period) => {
|
|
@@ -21357,7 +21406,8 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
21357
21406
|
period: planPeriod,
|
|
21358
21407
|
plans: availablePlans,
|
|
21359
21408
|
selectedPlan,
|
|
21360
|
-
selectPlan
|
|
21409
|
+
selectPlan,
|
|
21410
|
+
willTrial
|
|
21361
21411
|
}
|
|
21362
21412
|
),
|
|
21363
21413
|
checkoutStage === "usage" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
@@ -21409,7 +21459,8 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
21409
21459
|
setCheckoutStage: (stage) => setCheckoutStage(stage),
|
|
21410
21460
|
setError: (msg) => setError(msg),
|
|
21411
21461
|
setIsLoading,
|
|
21412
|
-
updatePromoCode: (code) => updatePromoCode(code)
|
|
21462
|
+
updatePromoCode: (code) => updatePromoCode(code),
|
|
21463
|
+
willTrial
|
|
21413
21464
|
}
|
|
21414
21465
|
)
|
|
21415
21466
|
]
|
|
@@ -21996,17 +22047,16 @@ var StyledViewport = dt.div.withConfig({
|
|
|
21996
22047
|
shouldForwardProp: (prop) => !["$numberOfColumns", "numberOfColumns"].includes(prop)
|
|
21997
22048
|
})`
|
|
21998
22049
|
display: grid;
|
|
21999
|
-
grid-template-columns: repeat(1, minmax(300px, 1fr));
|
|
22000
22050
|
margin-left: auto;
|
|
22001
22051
|
margin-right: auto;
|
|
22002
22052
|
gap: 1rem;
|
|
22003
22053
|
|
|
22004
|
-
@
|
|
22005
|
-
grid-template-columns:
|
|
22054
|
+
@container (max-width: 767px) {
|
|
22055
|
+
grid-template-columns: repeat(1, minmax(300px, 1fr));
|
|
22006
22056
|
}
|
|
22007
22057
|
|
|
22008
|
-
@container (
|
|
22009
|
-
grid-template-columns: repeat(
|
|
22058
|
+
@container (min-width: 768px) {
|
|
22059
|
+
grid-template-columns: ${({ theme }) => lt`repeat(${theme.numberOfColumns}, minmax(300px, 1fr))`};
|
|
22010
22060
|
}
|
|
22011
22061
|
`;
|
|
22012
22062
|
|
|
@@ -22617,9 +22667,6 @@ var Invoices = (0, import_react34.forwardRef)(({ className, data, ...rest }, ref
|
|
|
22617
22667
|
(0, import_react34.useEffect)(() => {
|
|
22618
22668
|
setInvoices(formatInvoices(data));
|
|
22619
22669
|
}, [data]);
|
|
22620
|
-
if (invoices.length === 0) {
|
|
22621
|
-
return null;
|
|
22622
|
-
}
|
|
22623
22670
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Element, { ref, className, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Flex, { $flexDirection: "column", $gap: "1rem", children: [
|
|
22624
22671
|
props.header.isVisible && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Flex, { $justifyContent: "space-between", $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
22625
22672
|
Text,
|
|
@@ -22631,48 +22678,50 @@ var Invoices = (0, import_react34.forwardRef)(({ className, data, ...rest }, ref
|
|
|
22631
22678
|
children: t2("Invoices")
|
|
22632
22679
|
}
|
|
22633
22680
|
) }),
|
|
22634
|
-
/* @__PURE__ */ (0, import_jsx_runtime30.
|
|
22635
|
-
|
|
22636
|
-
|
|
22637
|
-
|
|
22681
|
+
invoices.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [
|
|
22682
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Flex, { $flexDirection: "column", $gap: "0.5rem", children: invoices.slice(0, listSize).map(({ date, amount, url }, index) => {
|
|
22683
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Flex, { $justifyContent: "space-between", children: [
|
|
22684
|
+
props.date.isVisible && date && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
22685
|
+
InvoiceDate,
|
|
22686
|
+
{
|
|
22687
|
+
date,
|
|
22688
|
+
fontStyle: props.date.fontStyle,
|
|
22689
|
+
url
|
|
22690
|
+
}
|
|
22691
|
+
),
|
|
22692
|
+
props.amount.isVisible && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
22693
|
+
Text,
|
|
22694
|
+
{
|
|
22695
|
+
$font: theme.typography[props.amount.fontStyle].fontFamily,
|
|
22696
|
+
$size: theme.typography[props.amount.fontStyle].fontSize,
|
|
22697
|
+
$weight: theme.typography[props.amount.fontStyle].fontWeight,
|
|
22698
|
+
$color: theme.typography[props.amount.fontStyle].color,
|
|
22699
|
+
children: amount
|
|
22700
|
+
}
|
|
22701
|
+
)
|
|
22702
|
+
] }, index);
|
|
22703
|
+
}) }),
|
|
22704
|
+
props.collapse.isVisible && invoices.length > props.limit.number && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Flex, { $alignItems: "center", $gap: "0.5rem", children: [
|
|
22705
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
22706
|
+
Icon2,
|
|
22638
22707
|
{
|
|
22639
|
-
|
|
22640
|
-
|
|
22641
|
-
url
|
|
22708
|
+
name: `chevron-${listSize === props.limit.number ? "down" : "up"}`,
|
|
22709
|
+
style: { color: "#D0D0D0" }
|
|
22642
22710
|
}
|
|
22643
22711
|
),
|
|
22644
|
-
|
|
22712
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
22645
22713
|
Text,
|
|
22646
22714
|
{
|
|
22647
|
-
|
|
22648
|
-
$
|
|
22649
|
-
$
|
|
22650
|
-
$
|
|
22651
|
-
|
|
22715
|
+
onClick: toggleListSize,
|
|
22716
|
+
$font: theme.typography[props.collapse.fontStyle].fontFamily,
|
|
22717
|
+
$size: theme.typography[props.collapse.fontStyle].fontSize,
|
|
22718
|
+
$weight: theme.typography[props.collapse.fontStyle].fontWeight,
|
|
22719
|
+
$color: theme.typography[props.collapse.fontStyle].color,
|
|
22720
|
+
children: listSize === props.limit.number ? t2("See more") : t2("See less")
|
|
22652
22721
|
}
|
|
22653
22722
|
)
|
|
22654
|
-
] }
|
|
22655
|
-
}) })
|
|
22656
|
-
props.collapse.isVisible && invoices.length > props.limit.number && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Flex, { $alignItems: "center", $gap: "0.5rem", children: [
|
|
22657
|
-
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
22658
|
-
Icon2,
|
|
22659
|
-
{
|
|
22660
|
-
name: `chevron-${listSize === props.limit.number ? "down" : "up"}`,
|
|
22661
|
-
style: { color: "#D0D0D0" }
|
|
22662
|
-
}
|
|
22663
|
-
),
|
|
22664
|
-
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
22665
|
-
Text,
|
|
22666
|
-
{
|
|
22667
|
-
onClick: toggleListSize,
|
|
22668
|
-
$font: theme.typography[props.collapse.fontStyle].fontFamily,
|
|
22669
|
-
$size: theme.typography[props.collapse.fontStyle].fontSize,
|
|
22670
|
-
$weight: theme.typography[props.collapse.fontStyle].fontWeight,
|
|
22671
|
-
$color: theme.typography[props.collapse.fontStyle].color,
|
|
22672
|
-
children: listSize === props.limit.number ? t2("See more") : t2("See less")
|
|
22673
|
-
}
|
|
22674
|
-
)
|
|
22675
|
-
] })
|
|
22723
|
+
] })
|
|
22724
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Text, { display: "heading2", children: t2("No invoices created yet") })
|
|
22676
22725
|
] }) });
|
|
22677
22726
|
});
|
|
22678
22727
|
Invoices.displayName = "Invoices";
|
|
@@ -22686,11 +22735,10 @@ var Container3 = dt.div`
|
|
|
22686
22735
|
flex-direction: column;
|
|
22687
22736
|
|
|
22688
22737
|
&:last-child {
|
|
22689
|
-
overflow: hidden;
|
|
22690
|
-
|
|
22691
22738
|
${({ theme }) => {
|
|
22692
22739
|
const borderRadius = `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`;
|
|
22693
22740
|
return theme.sectionLayout === "merged" && lt`
|
|
22741
|
+
overflow: hidden;
|
|
22694
22742
|
border-bottom-left-radius: ${borderRadius};
|
|
22695
22743
|
border-bottom-right-radius: ${borderRadius};
|
|
22696
22744
|
`;
|
|
@@ -23395,7 +23443,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
|
23395
23443
|
}
|
|
23396
23444
|
stripe._registerWrapper({
|
|
23397
23445
|
name: "stripe-js",
|
|
23398
|
-
version: "7.
|
|
23446
|
+
version: "7.3.0",
|
|
23399
23447
|
startTime
|
|
23400
23448
|
});
|
|
23401
23449
|
};
|
|
@@ -23470,7 +23518,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
|
|
|
23470
23518
|
var version = runtimeVersionToUrlVersion(maybeStripe.version);
|
|
23471
23519
|
var expectedVersion = RELEASE_TRAIN;
|
|
23472
23520
|
if (isTestKey && version !== expectedVersion) {
|
|
23473
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.
|
|
23521
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.3.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
23474
23522
|
}
|
|
23475
23523
|
var stripe = maybeStripe.apply(void 0, args);
|
|
23476
23524
|
registerWrapper(stripe, startTime);
|
|
@@ -24666,7 +24714,7 @@ var PricingTable = (0, import_react40.forwardRef)(({ children, className, ...res
|
|
|
24666
24714
|
"Current usage exceeds the limit of this plan."
|
|
24667
24715
|
)
|
|
24668
24716
|
}
|
|
24669
|
-
) : plan.companyCanTrial ? t2("
|
|
24717
|
+
) : plan.companyCanTrial ? t2("Start X day trial", { days: plan.trialDays }) : t2("Choose plan")
|
|
24670
24718
|
}
|
|
24671
24719
|
)
|
|
24672
24720
|
]
|
|
@@ -25026,7 +25074,7 @@ var UpcomingBill = (0, import_react43.forwardRef)(({ className, ...rest }, ref)
|
|
|
25026
25074
|
const theme = nt();
|
|
25027
25075
|
const { data } = useEmbed();
|
|
25028
25076
|
const isLightBackground = useIsLightBackground();
|
|
25029
|
-
const {
|
|
25077
|
+
const { discounts, upcomingInvoice } = (0, import_react43.useMemo)(() => {
|
|
25030
25078
|
const discounts2 = (data.subscription?.discounts || []).map((discount) => ({
|
|
25031
25079
|
amountOff: discount.amountOff,
|
|
25032
25080
|
couponId: discount.couponId,
|
|
@@ -25036,24 +25084,10 @@ var UpcomingBill = (0, import_react43.forwardRef)(({ className, ...rest }, ref)
|
|
|
25036
25084
|
}));
|
|
25037
25085
|
return {
|
|
25038
25086
|
discounts: discounts2,
|
|
25039
|
-
upcomingInvoice:
|
|
25040
|
-
...typeof data.upcomingInvoice?.amountDue === "number" && {
|
|
25041
|
-
amountDue: data.upcomingInvoice.amountDue
|
|
25042
|
-
},
|
|
25043
|
-
...data.subscription?.interval && {
|
|
25044
|
-
interval: data.subscription.interval
|
|
25045
|
-
},
|
|
25046
|
-
...data.upcomingInvoice?.dueDate && {
|
|
25047
|
-
dueDate: toPrettyDate(new Date(data.upcomingInvoice.dueDate))
|
|
25048
|
-
},
|
|
25049
|
-
currency: data.upcomingInvoice?.currency
|
|
25050
|
-
}
|
|
25087
|
+
upcomingInvoice: data.upcomingInvoice
|
|
25051
25088
|
};
|
|
25052
25089
|
}, [data.subscription, data.upcomingInvoice]);
|
|
25053
|
-
|
|
25054
|
-
return null;
|
|
25055
|
-
}
|
|
25056
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
25090
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
25057
25091
|
Element,
|
|
25058
25092
|
{
|
|
25059
25093
|
as: Flex,
|
|
@@ -25061,8 +25095,8 @@ var UpcomingBill = (0, import_react43.forwardRef)(({ className, ...rest }, ref)
|
|
|
25061
25095
|
className,
|
|
25062
25096
|
$flexDirection: "column",
|
|
25063
25097
|
$gap: "1rem",
|
|
25064
|
-
children: [
|
|
25065
|
-
props.header.isVisible && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Flex, { $justifyContent: "space-between", $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
25098
|
+
children: upcomingInvoice ? /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
|
|
25099
|
+
props.header.isVisible && upcomingInvoice.dueDate && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Flex, { $justifyContent: "space-between", $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
25066
25100
|
Text,
|
|
25067
25101
|
{
|
|
25068
25102
|
$font: theme.typography[props.header.fontStyle].fontFamily,
|
|
@@ -25072,7 +25106,7 @@ var UpcomingBill = (0, import_react43.forwardRef)(({ className, ...rest }, ref)
|
|
|
25072
25106
|
children: [
|
|
25073
25107
|
props.header.prefix,
|
|
25074
25108
|
" ",
|
|
25075
|
-
upcomingInvoice.dueDate
|
|
25109
|
+
toPrettyDate(upcomingInvoice.dueDate)
|
|
25076
25110
|
]
|
|
25077
25111
|
}
|
|
25078
25112
|
) }),
|
|
@@ -25114,41 +25148,49 @@ var UpcomingBill = (0, import_react43.forwardRef)(({ className, ...rest }, ref)
|
|
|
25114
25148
|
children: t2("Discount")
|
|
25115
25149
|
}
|
|
25116
25150
|
) }),
|
|
25117
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Box, { children: discounts.map((discount) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
25118
|
-
|
|
25119
|
-
|
|
25120
|
-
|
|
25121
|
-
|
|
25122
|
-
|
|
25123
|
-
|
|
25124
|
-
|
|
25125
|
-
|
|
25126
|
-
|
|
25127
|
-
|
|
25151
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Box, { children: discounts.map((discount) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
25152
|
+
Flex,
|
|
25153
|
+
{
|
|
25154
|
+
$alignItems: "center",
|
|
25155
|
+
$gap: "0.5rem",
|
|
25156
|
+
children: [
|
|
25157
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
25158
|
+
Flex,
|
|
25159
|
+
{
|
|
25160
|
+
$alignItems: "center",
|
|
25161
|
+
$padding: "0.1875rem 0.375rem",
|
|
25162
|
+
$borderWidth: "1px",
|
|
25163
|
+
$borderStyle: "solid",
|
|
25164
|
+
$borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.15)" : "hsla(0, 0%, 100%, 0.15)",
|
|
25165
|
+
$borderRadius: "0.3125rem",
|
|
25166
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
25167
|
+
Text,
|
|
25168
|
+
{
|
|
25169
|
+
$font: theme.typography.text.fontFamily,
|
|
25170
|
+
$size: 0.75 * theme.typography.text.fontSize,
|
|
25171
|
+
$weight: theme.typography.text.fontWeight,
|
|
25172
|
+
$color: theme.typography.text.color,
|
|
25173
|
+
children: discount.customerFacingCode
|
|
25174
|
+
}
|
|
25175
|
+
)
|
|
25176
|
+
}
|
|
25177
|
+
),
|
|
25178
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
25128
25179
|
Text,
|
|
25129
25180
|
{
|
|
25130
25181
|
$font: theme.typography.text.fontFamily,
|
|
25131
|
-
$size:
|
|
25182
|
+
$size: theme.typography.text.fontSize,
|
|
25132
25183
|
$weight: theme.typography.text.fontWeight,
|
|
25133
25184
|
$color: theme.typography.text.color,
|
|
25134
|
-
children: discount.
|
|
25185
|
+
children: t2("Percent off", { percent: discount.percentOff })
|
|
25135
25186
|
}
|
|
25136
|
-
)
|
|
25137
|
-
|
|
25138
|
-
|
|
25139
|
-
|
|
25140
|
-
|
|
25141
|
-
{
|
|
25142
|
-
$font: theme.typography.text.fontFamily,
|
|
25143
|
-
$size: theme.typography.text.fontSize,
|
|
25144
|
-
$weight: theme.typography.text.fontWeight,
|
|
25145
|
-
$color: theme.typography.text.color,
|
|
25146
|
-
children: t2("Percent off", { percent: discount.percentOff })
|
|
25147
|
-
}
|
|
25148
|
-
) })
|
|
25149
|
-
] }, discount.couponId)) })
|
|
25187
|
+
) })
|
|
25188
|
+
]
|
|
25189
|
+
},
|
|
25190
|
+
discount.couponId
|
|
25191
|
+
)) })
|
|
25150
25192
|
] })
|
|
25151
|
-
]
|
|
25193
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { display: "heading2", children: t2("No upcoming invoice") })
|
|
25152
25194
|
}
|
|
25153
25195
|
);
|
|
25154
25196
|
});
|