@schematichq/schematic-components 1.4.1 → 1.4.2

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.
@@ -289,17 +289,17 @@ var require_debounce = __commonJS({
289
289
  var FUNC_ERROR_TEXT = "Expected a function";
290
290
  var nativeMax = Math.max;
291
291
  var nativeMin = Math.min;
292
- function debounce4(func, wait, options2) {
292
+ function debounce4(func, wait, options) {
293
293
  var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
294
294
  if (typeof func != "function") {
295
295
  throw new TypeError(FUNC_ERROR_TEXT);
296
296
  }
297
297
  wait = toNumber(wait) || 0;
298
- if (isObject2(options2)) {
299
- leading = !!options2.leading;
300
- maxing = "maxWait" in options2;
301
- maxWait = maxing ? nativeMax(toNumber(options2.maxWait) || 0, wait) : maxWait;
302
- trailing = "trailing" in options2 ? !!options2.trailing : trailing;
298
+ if (isObject2(options)) {
299
+ leading = !!options.leading;
300
+ maxing = "maxWait" in options;
301
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
302
+ trailing = "trailing" in options ? !!options.trailing : trailing;
303
303
  }
304
304
  function invokeFunc(time) {
305
305
  var args = lastArgs, thisArg = lastThis;
@@ -1945,8 +1945,8 @@ function getPriceValue(billingPrice) {
1945
1945
  const price = typeof billingPrice.priceDecimal === "string" ? Number(billingPrice.priceDecimal) : billingPrice.price;
1946
1946
  return price;
1947
1947
  }
1948
- function getPlanPrice(plan, period = "month", options2 = { useSelectedPeriod: true }) {
1949
- const billingPrice = options2.useSelectedPeriod ? period === "year" ? plan.yearlyPrice : plan.monthlyPrice : plan.yearlyPrice && !plan.monthlyPrice ? plan.yearlyPrice : plan.monthlyPrice;
1948
+ function getPlanPrice(plan, period = "month", options = { useSelectedPeriod: true }) {
1949
+ const billingPrice = options.useSelectedPeriod ? period === "year" ? plan.yearlyPrice : plan.monthlyPrice : plan.yearlyPrice && !plan.monthlyPrice ? plan.yearlyPrice : plan.monthlyPrice;
1950
1950
  if (billingPrice) {
1951
1951
  return { ...billingPrice, price: getPriceValue(billingPrice) };
1952
1952
  }
@@ -2078,14 +2078,14 @@ function groupPlanCreditGrants(creditGrants) {
2078
2078
  );
2079
2079
  return Object.values(map);
2080
2080
  }
2081
- function groupCreditGrants(creditGrants, options2) {
2081
+ function groupCreditGrants(creditGrants, options) {
2082
2082
  const today = /* @__PURE__ */ new Date();
2083
2083
  const map = creditGrants.reduce(
2084
2084
  (acc, grant) => {
2085
2085
  const isExpired = !!grant.expiresAt && grant.expiresAt <= today;
2086
2086
  const isZeroedOut = !!grant.zeroedOutDate;
2087
2087
  if (!isExpired && !isZeroedOut) {
2088
- const key = options2?.groupBy === "bundle" ? grant.billingCreditBundleId || grant.id : options2?.groupBy === "credit" ? grant.billingCreditId : grant.id;
2088
+ const key = options?.groupBy === "bundle" ? grant.billingCreditBundleId || grant.id : options?.groupBy === "credit" ? grant.billingCreditId : grant.id;
2089
2089
  const current = acc[key];
2090
2090
  acc[key] = {
2091
2091
  // credit-specific attributes
@@ -4145,7 +4145,7 @@ attr.rem = function propAsRem(key, value) {
4145
4145
  };
4146
4146
 
4147
4147
  // src/hooks/useAvailablePlans.ts
4148
- function useAvailablePlans(activePeriod, options2 = { useSelectedPeriod: true }) {
4148
+ function useAvailablePlans(activePeriod, options = { useSelectedPeriod: true }) {
4149
4149
  const { data, settings } = useEmbed();
4150
4150
  const getAvailablePeriods = (0, import_react2.useCallback)(() => {
4151
4151
  const periods = [];
@@ -4160,14 +4160,14 @@ function useAvailablePlans(activePeriod, options2 = { useSelectedPeriod: true })
4160
4160
  const getActivePlans = (0, import_react2.useCallback)(
4161
4161
  (plans) => {
4162
4162
  const activePlans = settings.mode === "edit" ? plans.slice() : plans.filter((plan) => {
4163
- if (options2.useSelectedPeriod) {
4163
+ if (options.useSelectedPeriod) {
4164
4164
  return activePeriod === "month" && plan.monthlyPrice || activePeriod === "year" && plan.yearlyPrice || plan.chargeType === ChargeType.oneTime;
4165
4165
  }
4166
4166
  return plan.monthlyPrice || plan.yearlyPrice || plan.chargeType === ChargeType.oneTime;
4167
4167
  });
4168
4168
  return activePlans.map((plan) => ({ ...plan, isSelected: false }));
4169
4169
  },
4170
- [activePeriod, options2.useSelectedPeriod, settings.mode]
4170
+ [activePeriod, options.useSelectedPeriod, settings.mode]
4171
4171
  );
4172
4172
  return (0, import_react2.useMemo)(() => {
4173
4173
  return {
@@ -4497,14 +4497,14 @@ var consoleLogger = {
4497
4497
  }
4498
4498
  };
4499
4499
  var Logger = class _Logger {
4500
- constructor(concreteLogger, options2 = {}) {
4501
- this.init(concreteLogger, options2);
4500
+ constructor(concreteLogger, options = {}) {
4501
+ this.init(concreteLogger, options);
4502
4502
  }
4503
- init(concreteLogger, options2 = {}) {
4504
- this.prefix = options2.prefix || "i18next:";
4503
+ init(concreteLogger, options = {}) {
4504
+ this.prefix = options.prefix || "i18next:";
4505
4505
  this.logger = concreteLogger || consoleLogger;
4506
- this.options = options2;
4507
- this.debug = options2.debug;
4506
+ this.options = options;
4507
+ this.debug = options.debug;
4508
4508
  }
4509
4509
  log(...args) {
4510
4510
  return this.forward(args, "log", "", true);
@@ -4531,10 +4531,10 @@ var Logger = class _Logger {
4531
4531
  ...this.options
4532
4532
  });
4533
4533
  }
4534
- clone(options2) {
4535
- options2 = options2 || this.options;
4536
- options2.prefix = options2.prefix || this.prefix;
4537
- return new _Logger(this.logger, options2);
4534
+ clone(options) {
4535
+ options = options || this.options;
4536
+ options.prefix = options.prefix || this.prefix;
4537
+ return new _Logger(this.logger, options);
4538
4538
  }
4539
4539
  };
4540
4540
  var baseLogger = new Logger();
@@ -4578,13 +4578,13 @@ var EventEmitter = class {
4578
4578
  }
4579
4579
  };
4580
4580
  var ResourceStore = class extends EventEmitter {
4581
- constructor(data, options2 = {
4581
+ constructor(data, options = {
4582
4582
  ns: ["translation"],
4583
4583
  defaultNS: "translation"
4584
4584
  }) {
4585
4585
  super();
4586
4586
  this.data = data || {};
4587
- this.options = options2;
4587
+ this.options = options;
4588
4588
  if (this.options.keySeparator === void 0) {
4589
4589
  this.options.keySeparator = ".";
4590
4590
  }
@@ -4603,9 +4603,9 @@ var ResourceStore = class extends EventEmitter {
4603
4603
  this.options.ns.splice(index, 1);
4604
4604
  }
4605
4605
  }
4606
- getResource(lng, ns, key, options2 = {}) {
4607
- const keySeparator = options2.keySeparator !== void 0 ? options2.keySeparator : this.options.keySeparator;
4608
- const ignoreJSONStructure = options2.ignoreJSONStructure !== void 0 ? options2.ignoreJSONStructure : this.options.ignoreJSONStructure;
4606
+ getResource(lng, ns, key, options = {}) {
4607
+ const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
4608
+ const ignoreJSONStructure = options.ignoreJSONStructure !== void 0 ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
4609
4609
  let path;
4610
4610
  if (lng.indexOf(".") > -1) {
4611
4611
  path = lng.split(".");
@@ -4630,10 +4630,10 @@ var ResourceStore = class extends EventEmitter {
4630
4630
  if (result || !ignoreJSONStructure || !isString(key)) return result;
4631
4631
  return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
4632
4632
  }
4633
- addResource(lng, ns, key, value, options2 = {
4633
+ addResource(lng, ns, key, value, options = {
4634
4634
  silent: false
4635
4635
  }) {
4636
- const keySeparator = options2.keySeparator !== void 0 ? options2.keySeparator : this.options.keySeparator;
4636
+ const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
4637
4637
  let path = [lng, ns];
4638
4638
  if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
4639
4639
  if (lng.indexOf(".") > -1) {
@@ -4643,9 +4643,9 @@ var ResourceStore = class extends EventEmitter {
4643
4643
  }
4644
4644
  this.addNamespaces(ns);
4645
4645
  setPath(this.data, path, value);
4646
- if (!options2.silent) this.emit("added", lng, ns, key, value);
4646
+ if (!options.silent) this.emit("added", lng, ns, key, value);
4647
4647
  }
4648
- addResources(lng, ns, resources, options2 = {
4648
+ addResources(lng, ns, resources, options = {
4649
4649
  silent: false
4650
4650
  }) {
4651
4651
  for (const m2 in resources) {
@@ -4653,9 +4653,9 @@ var ResourceStore = class extends EventEmitter {
4653
4653
  silent: true
4654
4654
  });
4655
4655
  }
4656
- if (!options2.silent) this.emit("added", lng, ns, resources);
4656
+ if (!options.silent) this.emit("added", lng, ns, resources);
4657
4657
  }
4658
- addResourceBundle(lng, ns, resources, deep, overwrite, options2 = {
4658
+ addResourceBundle(lng, ns, resources, deep, overwrite, options = {
4659
4659
  silent: false,
4660
4660
  skipCopy: false
4661
4661
  }) {
@@ -4668,7 +4668,7 @@ var ResourceStore = class extends EventEmitter {
4668
4668
  }
4669
4669
  this.addNamespaces(ns);
4670
4670
  let pack = getPath(this.data, path) || {};
4671
- if (!options2.skipCopy) resources = JSON.parse(JSON.stringify(resources));
4671
+ if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
4672
4672
  if (deep) {
4673
4673
  deepExtend(pack, resources, overwrite);
4674
4674
  } else {
@@ -4678,7 +4678,7 @@ var ResourceStore = class extends EventEmitter {
4678
4678
  };
4679
4679
  }
4680
4680
  setPath(this.data, path, pack);
4681
- if (!options2.silent) this.emit("added", lng, ns, resources);
4681
+ if (!options.silent) this.emit("added", lng, ns, resources);
4682
4682
  }
4683
4683
  removeResourceBundle(lng, ns) {
4684
4684
  if (this.hasResourceBundle(lng, ns)) {
@@ -4711,9 +4711,9 @@ var postProcessor = {
4711
4711
  addPostProcessor(module2) {
4712
4712
  this.processors[module2.name] = module2;
4713
4713
  },
4714
- handle(processors, value, key, options2, translator) {
4714
+ handle(processors, value, key, options, translator) {
4715
4715
  processors.forEach((processor) => {
4716
- value = this.processors[processor]?.process(value, key, options2, translator) ?? value;
4716
+ value = this.processors[processor]?.process(value, key, options, translator) ?? value;
4717
4717
  });
4718
4718
  return value;
4719
4719
  }
@@ -4741,10 +4741,10 @@ function keysFromSelector(selector, opts) {
4741
4741
  var checkedLoadedFor = {};
4742
4742
  var shouldHandleAsObject = (res) => !isString(res) && typeof res !== "boolean" && typeof res !== "number";
4743
4743
  var Translator = class _Translator extends EventEmitter {
4744
- constructor(services, options2 = {}) {
4744
+ constructor(services, options = {}) {
4745
4745
  super();
4746
4746
  copy2(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], services, this);
4747
- this.options = options2;
4747
+ this.options = options;
4748
4748
  if (this.options.keySeparator === void 0) {
4749
4749
  this.options.keySeparator = ".";
4750
4750
  }
@@ -4794,12 +4794,15 @@ var Translator = class _Translator extends EventEmitter {
4794
4794
  if (typeof opt !== "object" && this.options.overloadTranslationOptionHandler) {
4795
4795
  opt = this.options.overloadTranslationOptionHandler(arguments);
4796
4796
  }
4797
- if (typeof options === "object") opt = {
4797
+ if (typeof opt === "object") opt = {
4798
4798
  ...opt
4799
4799
  };
4800
4800
  if (!opt) opt = {};
4801
4801
  if (keys == null) return "";
4802
- if (typeof keys === "function") keys = keysFromSelector(keys, opt);
4802
+ if (typeof keys === "function") keys = keysFromSelector(keys, {
4803
+ ...this.options,
4804
+ ...opt
4805
+ });
4803
4806
  if (!Array.isArray(keys)) keys = [String(keys)];
4804
4807
  const returnDetails = opt.returnDetails !== void 0 ? opt.returnDetails : this.options.returnDetails;
4805
4808
  const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
@@ -5120,16 +5123,16 @@ var Translator = class _Translator extends EventEmitter {
5120
5123
  isValidLookup(res) {
5121
5124
  return res !== void 0 && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === "");
5122
5125
  }
5123
- getResource(code, ns, key, options2 = {}) {
5124
- if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key, options2);
5125
- return this.resourceStore.getResource(code, ns, key, options2);
5126
+ getResource(code, ns, key, options = {}) {
5127
+ if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key, options);
5128
+ return this.resourceStore.getResource(code, ns, key, options);
5126
5129
  }
5127
- getUsedParamsDetails(options2 = {}) {
5130
+ getUsedParamsDetails(options = {}) {
5128
5131
  const optionsKeys = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"];
5129
- const useOptionsReplaceForData = options2.replace && !isString(options2.replace);
5130
- let data = useOptionsReplaceForData ? options2.replace : options2;
5131
- if (useOptionsReplaceForData && typeof options2.count !== "undefined") {
5132
- data.count = options2.count;
5132
+ const useOptionsReplaceForData = options.replace && !isString(options.replace);
5133
+ let data = useOptionsReplaceForData ? options.replace : options;
5134
+ if (useOptionsReplaceForData && typeof options.count !== "undefined") {
5135
+ data.count = options.count;
5133
5136
  }
5134
5137
  if (this.options.interpolation.defaultVariables) {
5135
5138
  data = {
@@ -5147,10 +5150,10 @@ var Translator = class _Translator extends EventEmitter {
5147
5150
  }
5148
5151
  return data;
5149
5152
  }
5150
- static hasDefaultValue(options2) {
5153
+ static hasDefaultValue(options) {
5151
5154
  const prefix2 = "defaultValue";
5152
- for (const option in options2) {
5153
- if (Object.prototype.hasOwnProperty.call(options2, option) && prefix2 === option.substring(0, prefix2.length) && void 0 !== options2[option]) {
5155
+ for (const option in options) {
5156
+ if (Object.prototype.hasOwnProperty.call(options, option) && prefix2 === option.substring(0, prefix2.length) && void 0 !== options[option]) {
5154
5157
  return true;
5155
5158
  }
5156
5159
  }
@@ -5158,8 +5161,8 @@ var Translator = class _Translator extends EventEmitter {
5158
5161
  }
5159
5162
  };
5160
5163
  var LanguageUtil = class {
5161
- constructor(options2) {
5162
- this.options = options2;
5164
+ constructor(options) {
5165
+ this.options = options;
5163
5166
  this.supportedLngs = this.options.supportedLngs || false;
5164
5167
  this.logger = baseLogger.create("languageUtils");
5165
5168
  }
@@ -5280,9 +5283,9 @@ var dummyRule = {
5280
5283
  })
5281
5284
  };
5282
5285
  var PluralResolver = class {
5283
- constructor(languageUtils, options2 = {}) {
5286
+ constructor(languageUtils, options = {}) {
5284
5287
  this.languageUtils = languageUtils;
5285
- this.options = options2;
5288
+ this.options = options;
5286
5289
  this.logger = baseLogger.create("pluralResolver");
5287
5290
  this.pluralRulesCache = {};
5288
5291
  }
@@ -5292,9 +5295,9 @@ var PluralResolver = class {
5292
5295
  clearCache() {
5293
5296
  this.pluralRulesCache = {};
5294
5297
  }
5295
- getRule(code, options2 = {}) {
5298
+ getRule(code, options = {}) {
5296
5299
  const cleanedCode = getCleanedCode(code === "dev" ? "en" : code);
5297
- const type = options2.ordinal ? "ordinal" : "cardinal";
5300
+ const type = options.ordinal ? "ordinal" : "cardinal";
5298
5301
  const cacheKey = JSON.stringify({
5299
5302
  cleanedCode,
5300
5303
  type
@@ -5314,32 +5317,32 @@ var PluralResolver = class {
5314
5317
  }
5315
5318
  if (!code.match(/-|_/)) return dummyRule;
5316
5319
  const lngPart = this.languageUtils.getLanguagePartFromCode(code);
5317
- rule = this.getRule(lngPart, options2);
5320
+ rule = this.getRule(lngPart, options);
5318
5321
  }
5319
5322
  this.pluralRulesCache[cacheKey] = rule;
5320
5323
  return rule;
5321
5324
  }
5322
- needsPlural(code, options2 = {}) {
5323
- let rule = this.getRule(code, options2);
5324
- if (!rule) rule = this.getRule("dev", options2);
5325
+ needsPlural(code, options = {}) {
5326
+ let rule = this.getRule(code, options);
5327
+ if (!rule) rule = this.getRule("dev", options);
5325
5328
  return rule?.resolvedOptions().pluralCategories.length > 1;
5326
5329
  }
5327
- getPluralFormsOfKey(code, key, options2 = {}) {
5328
- return this.getSuffixes(code, options2).map((suffix) => `${key}${suffix}`);
5330
+ getPluralFormsOfKey(code, key, options = {}) {
5331
+ return this.getSuffixes(code, options).map((suffix) => `${key}${suffix}`);
5329
5332
  }
5330
- getSuffixes(code, options2 = {}) {
5331
- let rule = this.getRule(code, options2);
5332
- if (!rule) rule = this.getRule("dev", options2);
5333
+ getSuffixes(code, options = {}) {
5334
+ let rule = this.getRule(code, options);
5335
+ if (!rule) rule = this.getRule("dev", options);
5333
5336
  if (!rule) return [];
5334
- return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map((pluralCategory) => `${this.options.prepend}${options2.ordinal ? `ordinal${this.options.prepend}` : ""}${pluralCategory}`);
5337
+ return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map((pluralCategory) => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${pluralCategory}`);
5335
5338
  }
5336
- getSuffix(code, count, options2 = {}) {
5337
- const rule = this.getRule(code, options2);
5339
+ getSuffix(code, count, options = {}) {
5340
+ const rule = this.getRule(code, options);
5338
5341
  if (rule) {
5339
- return `${this.options.prepend}${options2.ordinal ? `ordinal${this.options.prepend}` : ""}${rule.select(count)}`;
5342
+ return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${rule.select(count)}`;
5340
5343
  }
5341
5344
  this.logger.warn(`no plural rule found for: ${code}`);
5342
- return this.getSuffix("dev", count, options2);
5345
+ return this.getSuffix("dev", count, options);
5343
5346
  }
5344
5347
  };
5345
5348
  var deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJSONStructure = true) => {
@@ -5352,14 +5355,14 @@ var deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJS
5352
5355
  };
5353
5356
  var regexSafe = (val) => val.replace(/\$/g, "$$$$");
5354
5357
  var Interpolator = class {
5355
- constructor(options2 = {}) {
5358
+ constructor(options = {}) {
5356
5359
  this.logger = baseLogger.create("interpolator");
5357
- this.options = options2;
5358
- this.format = options2?.interpolation?.format || ((value) => value);
5359
- this.init(options2);
5360
+ this.options = options;
5361
+ this.format = options?.interpolation?.format || ((value) => value);
5362
+ this.init(options);
5360
5363
  }
5361
- init(options2 = {}) {
5362
- if (!options2.interpolation) options2.interpolation = {
5364
+ init(options = {}) {
5365
+ if (!options.interpolation) options.interpolation = {
5363
5366
  escapeValue: true
5364
5367
  };
5365
5368
  const {
@@ -5380,7 +5383,7 @@ var Interpolator = class {
5380
5383
  nestingOptionsSeparator,
5381
5384
  maxReplaces,
5382
5385
  alwaysFormat
5383
- } = options2.interpolation;
5386
+ } = options.interpolation;
5384
5387
  this.escape = escape$1 !== void 0 ? escape$1 : escape;
5385
5388
  this.escapeValue = escapeValue !== void 0 ? escapeValue : true;
5386
5389
  this.useRawValueToEscape = useRawValueToEscape !== void 0 ? useRawValueToEscape : false;
@@ -5411,7 +5414,7 @@ var Interpolator = class {
5411
5414
  this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
5412
5415
  this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
5413
5416
  }
5414
- interpolate(str, data, lng, options2) {
5417
+ interpolate(str, data, lng, options) {
5415
5418
  let match2;
5416
5419
  let value;
5417
5420
  let replaces;
@@ -5420,7 +5423,7 @@ var Interpolator = class {
5420
5423
  if (key.indexOf(this.formatSeparator) < 0) {
5421
5424
  const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
5422
5425
  return this.alwaysFormat ? this.format(path, void 0, lng, {
5423
- ...options2,
5426
+ ...options,
5424
5427
  ...data,
5425
5428
  interpolationkey: key
5426
5429
  }) : path;
@@ -5429,14 +5432,14 @@ var Interpolator = class {
5429
5432
  const k2 = p2.shift().trim();
5430
5433
  const f2 = p2.join(this.formatSeparator).trim();
5431
5434
  return this.format(deepFindWithDefaults(data, defaultData, k2, this.options.keySeparator, this.options.ignoreJSONStructure), f2, lng, {
5432
- ...options2,
5435
+ ...options,
5433
5436
  ...data,
5434
5437
  interpolationkey: k2
5435
5438
  });
5436
5439
  };
5437
5440
  this.resetRegExp();
5438
- const missingInterpolationHandler = options2?.missingInterpolationHandler || this.options.missingInterpolationHandler;
5439
- const skipOnVariables = options2?.interpolation?.skipOnVariables !== void 0 ? options2.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
5441
+ const missingInterpolationHandler = options?.missingInterpolationHandler || this.options.missingInterpolationHandler;
5442
+ const skipOnVariables = options?.interpolation?.skipOnVariables !== void 0 ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
5440
5443
  const todos = [{
5441
5444
  regex: this.regexpUnescape,
5442
5445
  safeValue: (val) => regexSafe(val)
@@ -5451,9 +5454,9 @@ var Interpolator = class {
5451
5454
  value = handleFormat(matchedVar);
5452
5455
  if (value === void 0) {
5453
5456
  if (typeof missingInterpolationHandler === "function") {
5454
- const temp = missingInterpolationHandler(str, match2, options2);
5457
+ const temp = missingInterpolationHandler(str, match2, options);
5455
5458
  value = isString(temp) ? temp : "";
5456
- } else if (options2 && Object.prototype.hasOwnProperty.call(options2, matchedVar)) {
5459
+ } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
5457
5460
  value = "";
5458
5461
  } else if (skipOnVariables) {
5459
5462
  value = match2[0];
@@ -5481,7 +5484,7 @@ var Interpolator = class {
5481
5484
  });
5482
5485
  return str;
5483
5486
  }
5484
- nest(str, fc, options2 = {}) {
5487
+ nest(str, fc, options = {}) {
5485
5488
  let match2;
5486
5489
  let value;
5487
5490
  let clonedOptions;
@@ -5513,7 +5516,7 @@ var Interpolator = class {
5513
5516
  while (match2 = this.nestingRegexp.exec(str)) {
5514
5517
  let formatters = [];
5515
5518
  clonedOptions = {
5516
- ...options2
5519
+ ...options
5517
5520
  };
5518
5521
  clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
5519
5522
  clonedOptions.applyPostProcessor = false;
@@ -5531,8 +5534,8 @@ var Interpolator = class {
5531
5534
  value = "";
5532
5535
  }
5533
5536
  if (formatters.length) {
5534
- value = formatters.reduce((v2, f2) => this.format(v2, f2, options2.lng, {
5535
- ...options2,
5537
+ value = formatters.reduce((v2, f2) => this.format(v2, f2, options.lng, {
5538
+ ...options,
5536
5539
  interpolationkey: match2[1].trim()
5537
5540
  }), value.trim());
5538
5541
  }
@@ -5594,16 +5597,16 @@ var createCachedFormatter = (fn) => {
5594
5597
  };
5595
5598
  var createNonCachedFormatter = (fn) => (v2, l2, o2) => fn(getCleanedCode(l2), o2)(v2);
5596
5599
  var Formatter = class {
5597
- constructor(options2 = {}) {
5600
+ constructor(options = {}) {
5598
5601
  this.logger = baseLogger.create("formatter");
5599
- this.options = options2;
5600
- this.init(options2);
5602
+ this.options = options;
5603
+ this.init(options);
5601
5604
  }
5602
- init(services, options2 = {
5605
+ init(services, options = {
5603
5606
  interpolation: {}
5604
5607
  }) {
5605
- this.formatSeparator = options2.interpolation.formatSeparator || ",";
5606
- const cf = options2.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
5608
+ this.formatSeparator = options.interpolation.formatSeparator || ",";
5609
+ const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
5607
5610
  this.formats = {
5608
5611
  number: cf((lng, opt) => {
5609
5612
  const formatter = new Intl.NumberFormat(lng, {
@@ -5644,7 +5647,7 @@ var Formatter = class {
5644
5647
  addCached(name, fc) {
5645
5648
  this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
5646
5649
  }
5647
- format(value, format, lng, options2 = {}) {
5650
+ format(value, format, lng, options = {}) {
5648
5651
  const formats = format.split(this.formatSeparator);
5649
5652
  if (formats.length > 1 && formats[0].indexOf("(") > 1 && formats[0].indexOf(")") < 0 && formats.find((f2) => f2.indexOf(")") > -1)) {
5650
5653
  const lastIndex = formats.findIndex((f2) => f2.indexOf(")") > -1);
@@ -5658,11 +5661,11 @@ var Formatter = class {
5658
5661
  if (this.formats[formatName]) {
5659
5662
  let formatted = mem;
5660
5663
  try {
5661
- const valOptions = options2?.formatParams?.[options2.interpolationkey] || {};
5662
- const l2 = valOptions.locale || valOptions.lng || options2.locale || options2.lng || lng;
5664
+ const valOptions = options?.formatParams?.[options.interpolationkey] || {};
5665
+ const l2 = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
5663
5666
  formatted = this.formats[formatName](mem, l2, {
5664
5667
  ...formatOptions,
5665
- ...options2,
5668
+ ...options,
5666
5669
  ...valOptions
5667
5670
  });
5668
5671
  } catch (error) {
@@ -5684,24 +5687,24 @@ var removePending = (q2, name) => {
5684
5687
  }
5685
5688
  };
5686
5689
  var Connector = class extends EventEmitter {
5687
- constructor(backend, store, services, options2 = {}) {
5690
+ constructor(backend, store, services, options = {}) {
5688
5691
  super();
5689
5692
  this.backend = backend;
5690
5693
  this.store = store;
5691
5694
  this.services = services;
5692
5695
  this.languageUtils = services.languageUtils;
5693
- this.options = options2;
5696
+ this.options = options;
5694
5697
  this.logger = baseLogger.create("backendConnector");
5695
5698
  this.waitingReads = [];
5696
- this.maxParallelReads = options2.maxParallelReads || 10;
5699
+ this.maxParallelReads = options.maxParallelReads || 10;
5697
5700
  this.readingCalls = 0;
5698
- this.maxRetries = options2.maxRetries >= 0 ? options2.maxRetries : 5;
5699
- this.retryTimeout = options2.retryTimeout >= 1 ? options2.retryTimeout : 350;
5701
+ this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
5702
+ this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
5700
5703
  this.state = {};
5701
5704
  this.queue = [];
5702
- this.backend?.init?.(services, options2.backend, options2);
5705
+ this.backend?.init?.(services, options.backend, options);
5703
5706
  }
5704
- queueLoad(languages, namespaces, options2, callback) {
5707
+ queueLoad(languages, namespaces, options, callback) {
5705
5708
  const toLoad = {};
5706
5709
  const pending = {};
5707
5710
  const toLoadLanguages = {};
@@ -5710,7 +5713,7 @@ var Connector = class extends EventEmitter {
5710
5713
  let hasAllNamespaces = true;
5711
5714
  namespaces.forEach((ns) => {
5712
5715
  const name = `${lng}|${ns}`;
5713
- if (!options2.reload && this.store.hasResourceBundle(lng, ns)) {
5716
+ if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
5714
5717
  this.state[name] = 2;
5715
5718
  } else if (this.state[name] < 0) ;
5716
5719
  else if (this.state[name] === 1) {
@@ -5823,14 +5826,14 @@ var Connector = class extends EventEmitter {
5823
5826
  }
5824
5827
  return fc(lng, ns, resolver);
5825
5828
  }
5826
- prepareLoading(languages, namespaces, options2 = {}, callback) {
5829
+ prepareLoading(languages, namespaces, options = {}, callback) {
5827
5830
  if (!this.backend) {
5828
5831
  this.logger.warn("No backend was added via i18next.use. Will not load resources.");
5829
5832
  return callback && callback();
5830
5833
  }
5831
5834
  if (isString(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
5832
5835
  if (isString(namespaces)) namespaces = [namespaces];
5833
- const toLoad = this.queueLoad(languages, namespaces, options2, callback);
5836
+ const toLoad = this.queueLoad(languages, namespaces, options, callback);
5834
5837
  if (!toLoad.toLoad.length) {
5835
5838
  if (!toLoad.pending.length) callback();
5836
5839
  return null;
@@ -5857,7 +5860,7 @@ var Connector = class extends EventEmitter {
5857
5860
  this.loaded(name, err2, data);
5858
5861
  });
5859
5862
  }
5860
- saveMissing(languages, namespace, key, fallbackValue, isUpdate, options2 = {}, clb = () => {
5863
+ saveMissing(languages, namespace, key, fallbackValue, isUpdate, options = {}, clb = () => {
5861
5864
  }) {
5862
5865
  if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(namespace)) {
5863
5866
  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!!!");
@@ -5866,7 +5869,7 @@ var Connector = class extends EventEmitter {
5866
5869
  if (key === void 0 || key === null || key === "") return;
5867
5870
  if (this.backend?.create) {
5868
5871
  const opts = {
5869
- ...options2,
5872
+ ...options,
5870
5873
  isUpdate
5871
5874
  };
5872
5875
  const fc = this.backend.create.bind(this.backend);
@@ -5933,9 +5936,9 @@ var get = () => ({
5933
5936
  if (isString(args[1])) ret.defaultValue = args[1];
5934
5937
  if (isString(args[2])) ret.tDescription = args[2];
5935
5938
  if (typeof args[2] === "object" || typeof args[3] === "object") {
5936
- const options2 = args[3] || args[2];
5937
- Object.keys(options2).forEach((key) => {
5938
- ret[key] = options2[key];
5939
+ const options = args[3] || args[2];
5940
+ Object.keys(options).forEach((key) => {
5941
+ ret[key] = options[key];
5939
5942
  });
5940
5943
  }
5941
5944
  return ret;
@@ -5955,15 +5958,15 @@ var get = () => ({
5955
5958
  },
5956
5959
  cacheInBuiltFormats: true
5957
5960
  });
5958
- var transformOptions = (options2) => {
5959
- if (isString(options2.ns)) options2.ns = [options2.ns];
5960
- if (isString(options2.fallbackLng)) options2.fallbackLng = [options2.fallbackLng];
5961
- if (isString(options2.fallbackNS)) options2.fallbackNS = [options2.fallbackNS];
5962
- if (options2.supportedLngs?.indexOf?.("cimode") < 0) {
5963
- options2.supportedLngs = options2.supportedLngs.concat(["cimode"]);
5961
+ var transformOptions = (options) => {
5962
+ if (isString(options.ns)) options.ns = [options.ns];
5963
+ if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
5964
+ if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
5965
+ if (options.supportedLngs?.indexOf?.("cimode") < 0) {
5966
+ options.supportedLngs = options.supportedLngs.concat(["cimode"]);
5964
5967
  }
5965
- if (typeof options2.initImmediate === "boolean") options2.initAsync = options2.initImmediate;
5966
- return options2;
5968
+ if (typeof options.initImmediate === "boolean") options.initAsync = options.initImmediate;
5969
+ return options;
5967
5970
  };
5968
5971
  var noop = () => {
5969
5972
  };
@@ -5976,53 +5979,53 @@ var bindMemberFunctions = (inst) => {
5976
5979
  });
5977
5980
  };
5978
5981
  var I18n = class _I18n extends EventEmitter {
5979
- constructor(options2 = {}, callback) {
5982
+ constructor(options = {}, callback) {
5980
5983
  super();
5981
- this.options = transformOptions(options2);
5984
+ this.options = transformOptions(options);
5982
5985
  this.services = {};
5983
5986
  this.logger = baseLogger;
5984
5987
  this.modules = {
5985
5988
  external: []
5986
5989
  };
5987
5990
  bindMemberFunctions(this);
5988
- if (callback && !this.isInitialized && !options2.isClone) {
5991
+ if (callback && !this.isInitialized && !options.isClone) {
5989
5992
  if (!this.options.initAsync) {
5990
- this.init(options2, callback);
5993
+ this.init(options, callback);
5991
5994
  return this;
5992
5995
  }
5993
5996
  setTimeout(() => {
5994
- this.init(options2, callback);
5997
+ this.init(options, callback);
5995
5998
  }, 0);
5996
5999
  }
5997
6000
  }
5998
- init(options2 = {}, callback) {
6001
+ init(options = {}, callback) {
5999
6002
  this.isInitializing = true;
6000
- if (typeof options2 === "function") {
6001
- callback = options2;
6002
- options2 = {};
6003
+ if (typeof options === "function") {
6004
+ callback = options;
6005
+ options = {};
6003
6006
  }
6004
- if (options2.defaultNS == null && options2.ns) {
6005
- if (isString(options2.ns)) {
6006
- options2.defaultNS = options2.ns;
6007
- } else if (options2.ns.indexOf("translation") < 0) {
6008
- options2.defaultNS = options2.ns[0];
6007
+ if (options.defaultNS == null && options.ns) {
6008
+ if (isString(options.ns)) {
6009
+ options.defaultNS = options.ns;
6010
+ } else if (options.ns.indexOf("translation") < 0) {
6011
+ options.defaultNS = options.ns[0];
6009
6012
  }
6010
6013
  }
6011
6014
  const defOpts = get();
6012
6015
  this.options = {
6013
6016
  ...defOpts,
6014
6017
  ...this.options,
6015
- ...transformOptions(options2)
6018
+ ...transformOptions(options)
6016
6019
  };
6017
6020
  this.options.interpolation = {
6018
6021
  ...defOpts.interpolation,
6019
6022
  ...this.options.interpolation
6020
6023
  };
6021
- if (options2.keySeparator !== void 0) {
6022
- this.options.userDefinedKeySeparator = options2.keySeparator;
6024
+ if (options.keySeparator !== void 0) {
6025
+ this.options.userDefinedKeySeparator = options.keySeparator;
6023
6026
  }
6024
- if (options2.nsSeparator !== void 0) {
6025
- this.options.userDefinedNsSeparator = options2.nsSeparator;
6027
+ if (options.nsSeparator !== void 0) {
6028
+ this.options.userDefinedNsSeparator = options.nsSeparator;
6026
6029
  }
6027
6030
  const createClassOnDemand = (ClassOrObject) => {
6028
6031
  if (!ClassOrObject) return null;
@@ -6287,8 +6290,18 @@ var I18n = class _I18n extends EventEmitter {
6287
6290
  const keySeparator = this.options.keySeparator || ".";
6288
6291
  let resultKey;
6289
6292
  if (o2.keyPrefix && Array.isArray(key)) {
6290
- resultKey = key.map((k2) => `${o2.keyPrefix}${keySeparator}${k2}`);
6293
+ resultKey = key.map((k2) => {
6294
+ if (typeof k2 === "function") k2 = keysFromSelector(k2, {
6295
+ ...this.options,
6296
+ ...opts
6297
+ });
6298
+ return `${o2.keyPrefix}${keySeparator}${k2}`;
6299
+ });
6291
6300
  } else {
6301
+ if (typeof key === "function") key = keysFromSelector(key, {
6302
+ ...this.options,
6303
+ ...opts
6304
+ });
6292
6305
  resultKey = o2.keyPrefix ? `${o2.keyPrefix}${keySeparator}${key}` : key;
6293
6306
  }
6294
6307
  return this.t(resultKey, o2);
@@ -6311,7 +6324,7 @@ var I18n = class _I18n extends EventEmitter {
6311
6324
  setDefaultNamespace(ns) {
6312
6325
  this.options.defaultNS = ns;
6313
6326
  }
6314
- hasLoadedNamespace(ns, options2 = {}) {
6327
+ hasLoadedNamespace(ns, options = {}) {
6315
6328
  if (!this.isInitialized) {
6316
6329
  this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages);
6317
6330
  return false;
@@ -6320,7 +6333,7 @@ var I18n = class _I18n extends EventEmitter {
6320
6333
  this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages);
6321
6334
  return false;
6322
6335
  }
6323
- const lng = options2.lng || this.resolvedLanguage || this.languages[0];
6336
+ const lng = options.lng || this.resolvedLanguage || this.languages[0];
6324
6337
  const fallbackLng = this.options ? this.options.fallbackLng : false;
6325
6338
  const lastLng = this.languages[this.languages.length - 1];
6326
6339
  if (lng.toLowerCase() === "cimode") return true;
@@ -6328,8 +6341,8 @@ var I18n = class _I18n extends EventEmitter {
6328
6341
  const loadState = this.services.backendConnector.state[`${l2}|${n}`];
6329
6342
  return loadState === -1 || loadState === 0 || loadState === 2;
6330
6343
  };
6331
- if (options2.precheck) {
6332
- const preResult = options2.precheck(this, loadNotPending);
6344
+ if (options.precheck) {
6345
+ const preResult = options.precheck(this, loadNotPending);
6333
6346
  if (preResult !== void 0) return preResult;
6334
6347
  }
6335
6348
  if (this.hasResourceBundle(lng, ns)) return true;
@@ -6385,22 +6398,22 @@ var I18n = class _I18n extends EventEmitter {
6385
6398
  if (lng.toLowerCase().indexOf("-latn") > 1) return "ltr";
6386
6399
  return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
6387
6400
  }
6388
- static createInstance(options2 = {}, callback) {
6389
- return new _I18n(options2, callback);
6401
+ static createInstance(options = {}, callback) {
6402
+ return new _I18n(options, callback);
6390
6403
  }
6391
- cloneInstance(options2 = {}, callback = noop) {
6392
- const forkResourceStore = options2.forkResourceStore;
6393
- if (forkResourceStore) delete options2.forkResourceStore;
6404
+ cloneInstance(options = {}, callback = noop) {
6405
+ const forkResourceStore = options.forkResourceStore;
6406
+ if (forkResourceStore) delete options.forkResourceStore;
6394
6407
  const mergedOptions = {
6395
6408
  ...this.options,
6396
- ...options2,
6409
+ ...options,
6397
6410
  ...{
6398
6411
  isClone: true
6399
6412
  }
6400
6413
  };
6401
6414
  const clone = new _I18n(mergedOptions);
6402
- if (options2.debug !== void 0 || options2.prefix !== void 0) {
6403
- clone.logger = clone.logger.clone(options2);
6415
+ if (options.debug !== void 0 || options.prefix !== void 0) {
6416
+ clone.logger = clone.logger.clone(options);
6404
6417
  }
6405
6418
  const membersToCopy = ["store", "services", "language"];
6406
6419
  membersToCopy.forEach((m2) => {
@@ -6521,7 +6534,7 @@ var loadLanguages2 = (i18n, lng, ns, cb) => {
6521
6534
  });
6522
6535
  i18n.loadLanguages(lng, loadedClb(i18n, cb));
6523
6536
  };
6524
- var hasLoadedNamespace2 = (ns, i18n, options2 = {}) => {
6537
+ var hasLoadedNamespace2 = (ns, i18n, options = {}) => {
6525
6538
  if (!i18n.languages || !i18n.languages.length) {
6526
6539
  warnOnce(i18n, "NO_LANGUAGES", "i18n.languages were undefined or empty", {
6527
6540
  languages: i18n.languages
@@ -6529,9 +6542,9 @@ var hasLoadedNamespace2 = (ns, i18n, options2 = {}) => {
6529
6542
  return true;
6530
6543
  }
6531
6544
  return i18n.hasLoadedNamespace(ns, {
6532
- lng: options2.lng,
6545
+ lng: options.lng,
6533
6546
  precheck: (i18nInstance2, loadNotPending) => {
6534
- if (options2.bindI18n && options2.bindI18n.indexOf("languageChanging") > -1 && i18nInstance2.services.backendConnector.backend && i18nInstance2.isLanguageChangingTo && !loadNotPending(i18nInstance2.isLanguageChangingTo, ns)) return false;
6547
+ if (options.bindI18n && options.bindI18n.indexOf("languageChanging") > -1 && i18nInstance2.services.backendConnector.backend && i18nInstance2.isLanguageChangingTo && !loadNotPending(i18nInstance2.isLanguageChangingTo, ns)) return false;
6535
6548
  }
6536
6549
  });
6537
6550
  };
@@ -6576,10 +6589,10 @@ var defaultOptions = {
6576
6589
  useSuspense: true,
6577
6590
  unescape
6578
6591
  };
6579
- var setDefaults = (options2 = {}) => {
6592
+ var setDefaults = (options = {}) => {
6580
6593
  defaultOptions = {
6581
6594
  ...defaultOptions,
6582
- ...options2
6595
+ ...options
6583
6596
  };
6584
6597
  };
6585
6598
  var getDefaults = () => defaultOptions;
@@ -7103,12 +7116,12 @@ var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.ra
7103
7116
  var native_default = { randomUUID };
7104
7117
 
7105
7118
  // node_modules/uuid/dist/esm-browser/v4.js
7106
- function v4(options2, buf, offset) {
7107
- if (native_default.randomUUID && !buf && !options2) {
7119
+ function v4(options, buf, offset) {
7120
+ if (native_default.randomUUID && !buf && !options) {
7108
7121
  return native_default.randomUUID();
7109
7122
  }
7110
- options2 = options2 || {};
7111
- const rnds = options2.random ?? options2.rng?.() ?? rng();
7123
+ options = options || {};
7124
+ const rnds = options.random ?? options.rng?.() ?? rng();
7112
7125
  if (rnds.length < 16) {
7113
7126
  throw new Error("Random bytes length must be >= 16");
7114
7127
  }
@@ -8532,6 +8545,21 @@ function ComponentCapabilitiesFromJSONTyped(json, ignoreDiscriminator) {
8532
8545
  };
8533
8546
  }
8534
8547
 
8548
+ // src/api/checkoutexternal/models/ComponentCheckoutSettings.ts
8549
+ function ComponentCheckoutSettingsFromJSON(json) {
8550
+ return ComponentCheckoutSettingsFromJSONTyped(json, false);
8551
+ }
8552
+ function ComponentCheckoutSettingsFromJSONTyped(json, ignoreDiscriminator) {
8553
+ if (json == null) {
8554
+ return json;
8555
+ }
8556
+ return {
8557
+ collectAddress: json["collect_address"],
8558
+ collectEmail: json["collect_email"],
8559
+ collectPhone: json["collect_phone"]
8560
+ };
8561
+ }
8562
+
8535
8563
  // src/api/checkoutexternal/models/PlanDetailResponseData.ts
8536
8564
  function PlanDetailResponseDataFromJSON(json) {
8537
8565
  return PlanDetailResponseDataFromJSONTyped(json, false);
@@ -8729,6 +8757,9 @@ function ComponentHydrateResponseDataFromJSONTyped(json, ignoreDiscriminator) {
8729
8757
  CompatiblePlansFromJSON
8730
8758
  ),
8731
8759
  capabilities: json["capabilities"] == null ? void 0 : ComponentCapabilitiesFromJSON(json["capabilities"]),
8760
+ checkoutSettings: ComponentCheckoutSettingsFromJSON(
8761
+ json["checkout_settings"]
8762
+ ),
8732
8763
  company: json["company"] == null ? void 0 : CompanyDetailResponseDataFromJSON(json["company"]),
8733
8764
  component: json["component"] == null ? void 0 : ComponentResponseDataFromJSON(json["component"]),
8734
8765
  creditBundles: json["credit_bundles"].map(
@@ -10479,18 +10510,18 @@ var EmbedProvider = ({
10479
10510
  children,
10480
10511
  apiKey,
10481
10512
  apiConfig,
10482
- ...options2
10513
+ ...options
10483
10514
  }) => {
10484
10515
  const sessionIdRef = (0, import_react12.useRef)(v4_default());
10485
10516
  const styleRef = (0, import_react12.useRef)(null);
10486
- const [state, dispatch] = (0, import_react12.useReducer)(reducer, options2, (opts) => {
10517
+ const [state, dispatch] = (0, import_react12.useReducer)(reducer, options, (opts) => {
10487
10518
  const providedState = { settings: opts.settings || {} };
10488
10519
  const resolvedState = (0, import_merge2.default)({}, initialState, providedState);
10489
10520
  return resolvedState;
10490
10521
  });
10491
10522
  const customHeaders = (0, import_react12.useMemo)(
10492
10523
  () => ({
10493
- "X-Schematic-Components-Version": "1.4.1",
10524
+ "X-Schematic-Components-Version": "1.4.2",
10494
10525
  "X-Schematic-Session-ID": sessionIdRef.current
10495
10526
  }),
10496
10527
  []
@@ -10498,11 +10529,11 @@ var EmbedProvider = ({
10498
10529
  const [api, setApi] = (0, import_react12.useState)({});
10499
10530
  const debug = (0, import_react12.useCallback)(
10500
10531
  (message, ...args) => {
10501
- if (options2.debug) {
10532
+ if (options.debug) {
10502
10533
  console.debug(`[Schematic] ${message}`, ...args);
10503
10534
  }
10504
10535
  },
10505
- [options2.debug]
10536
+ [options.debug]
10506
10537
  );
10507
10538
  const hydratePublic = (0, import_react12.useCallback)(async () => {
10508
10539
  dispatch({ type: "HYDRATE_STARTED" });
@@ -10712,8 +10743,8 @@ var EmbedProvider = ({
10712
10743
  dispatch({ type: "SET_DATA", data });
10713
10744
  }, []);
10714
10745
  const updateSettings = (0, import_react12.useCallback)(
10715
- (settings = {}, options3) => {
10716
- dispatch({ type: "UPDATE_SETTINGS", settings, update: options3?.update });
10746
+ (settings = {}, options2) => {
10747
+ dispatch({ type: "UPDATE_SETTINGS", settings, update: options2?.update });
10717
10748
  },
10718
10749
  []
10719
10750
  );
@@ -10804,9 +10835,9 @@ var EmbedProvider = ({
10804
10835
  }
10805
10836
  }, [debug, state.error]);
10806
10837
  (0, import_react12.useEffect)(() => {
10807
- const providedSettings = { ...options2.settings || {} };
10838
+ const providedSettings = { ...options.settings || {} };
10808
10839
  updateSettings(providedSettings, { update: false });
10809
- }, [options2.settings, updateSettings]);
10840
+ }, [options.settings, updateSettings]);
10810
10841
  (0, import_react12.useEffect)(() => {
10811
10842
  const planChanged = (event) => {
10812
10843
  if (event instanceof CustomEvent) {
@@ -12489,6 +12520,7 @@ var Sidebar = ({
12489
12520
  addOns,
12490
12521
  creditBundles = [],
12491
12522
  usageBasedEntitlements,
12523
+ addOnUsageBasedEntitlements = [],
12492
12524
  charges,
12493
12525
  checkoutRef,
12494
12526
  checkoutStage,
@@ -12673,6 +12705,35 @@ var Sidebar = ({
12673
12705
  }
12674
12706
  setError(void 0);
12675
12707
  setIsLoading(true);
12708
+ const planPayInAdvance = payInAdvanceEntitlements.reduce(
12709
+ (acc, { meteredMonthlyPrice, meteredYearlyPrice, quantity }) => {
12710
+ const priceId2 = (planPeriod === "year" ? meteredYearlyPrice : meteredMonthlyPrice)?.priceId;
12711
+ if (priceId2) {
12712
+ acc.push({
12713
+ priceId: priceId2,
12714
+ quantity
12715
+ });
12716
+ }
12717
+ return acc;
12718
+ },
12719
+ []
12720
+ );
12721
+ const addOnPayInAdvance = addOnUsageBasedEntitlements.filter(
12722
+ (entitlement) => entitlement.priceBehavior === "pay_in_advance" /* PayInAdvance */
12723
+ ).reduce(
12724
+ (acc, { meteredMonthlyPrice, meteredYearlyPrice, quantity }) => {
12725
+ const priceId2 = (planPeriod === "year" ? meteredYearlyPrice : meteredMonthlyPrice)?.priceId;
12726
+ if (priceId2) {
12727
+ acc.push({
12728
+ priceId: priceId2,
12729
+ quantity
12730
+ });
12731
+ }
12732
+ return acc;
12733
+ },
12734
+ []
12735
+ );
12736
+ const allPayInAdvance = [...planPayInAdvance, ...addOnPayInAdvance];
12676
12737
  await checkout({
12677
12738
  newPlanId: planId,
12678
12739
  newPriceId: priceId,
@@ -12688,19 +12749,7 @@ var Sidebar = ({
12688
12749
  }
12689
12750
  return acc;
12690
12751
  }, []),
12691
- payInAdvance: payInAdvanceEntitlements.reduce(
12692
- (acc, { meteredMonthlyPrice, meteredYearlyPrice, quantity }) => {
12693
- const priceId2 = (planPeriod === "year" ? meteredYearlyPrice : meteredMonthlyPrice)?.priceId;
12694
- if (priceId2) {
12695
- acc.push({
12696
- priceId: priceId2,
12697
- quantity
12698
- });
12699
- }
12700
- return acc;
12701
- },
12702
- []
12703
- ),
12752
+ payInAdvance: allPayInAdvance,
12704
12753
  creditBundles: creditBundles.reduce(
12705
12754
  (acc, { id, count }) => {
12706
12755
  if (count > 0) {
@@ -12738,6 +12787,7 @@ var Sidebar = ({
12738
12787
  setIsLoading,
12739
12788
  setLayout,
12740
12789
  payInAdvanceEntitlements,
12790
+ addOnUsageBasedEntitlements,
12741
12791
  willTrialWithoutPaymentMethod,
12742
12792
  promoCode
12743
12793
  ]);
@@ -14433,6 +14483,12 @@ var CheckoutDialog = ({ top = 0 }) => {
14433
14483
  ),
14434
14484
  [usageBasedEntitlements]
14435
14485
  );
14486
+ const addOnPayInAdvanceEntitlements = (0, import_react30.useMemo)(
14487
+ () => addOnUsageBasedEntitlements.filter(
14488
+ (entitlement) => entitlement.priceBehavior === "pay_in_advance" /* PayInAdvance */
14489
+ ),
14490
+ [addOnUsageBasedEntitlements]
14491
+ );
14436
14492
  const [promoCode, setPromoCode] = (0, import_react30.useState)(null);
14437
14493
  const [isPaymentMethodRequired, setIsPaymentMethodRequired] = (0, import_react30.useState)(false);
14438
14494
  const willTrialWithoutPaymentMethod = (0, import_react30.useMemo)(
@@ -14727,7 +14783,10 @@ var CheckoutDialog = ({ top = 0 }) => {
14727
14783
  }))
14728
14784
  );
14729
14785
  setAddOnUsageBasedEntitlements(updatedAddOnEntitlements);
14730
- handlePreviewCheckout({ addOns: updated });
14786
+ handlePreviewCheckout({
14787
+ addOns: updated,
14788
+ addOnPayInAdvanceEntitlements: updatedAddOnEntitlements
14789
+ });
14731
14790
  return updated;
14732
14791
  });
14733
14792
  },
@@ -14973,7 +15032,7 @@ var CheckoutDialog = ({ top = 0 }) => {
14973
15032
  isLoading,
14974
15033
  period: planPeriod,
14975
15034
  selectedPlan,
14976
- entitlements: addOnUsageBasedEntitlements,
15035
+ entitlements: addOnPayInAdvanceEntitlements,
14977
15036
  updateQuantity: updateAddOnEntitlementQuantity
14978
15037
  }
14979
15038
  ) : checkoutStage === "credits" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
@@ -15001,6 +15060,7 @@ var CheckoutDialog = ({ top = 0 }) => {
15001
15060
  selectedPlan,
15002
15061
  addOns,
15003
15062
  usageBasedEntitlements,
15063
+ addOnUsageBasedEntitlements,
15004
15064
  creditBundles,
15005
15065
  charges,
15006
15066
  checkoutRef,
@@ -15122,7 +15182,7 @@ var PaymentForm = ({ onConfirm }) => {
15122
15182
  var import_react33 = require("react");
15123
15183
  var import_jsx_runtime24 = require("react/jsx-runtime");
15124
15184
  var PeriodToggle = ({
15125
- options: options2,
15185
+ options,
15126
15186
  selectedOption,
15127
15187
  selectedPlan,
15128
15188
  onSelect
@@ -15155,7 +15215,7 @@ var PeriodToggle = ({
15155
15215
  $width: "fit-content"
15156
15216
  }
15157
15217
  },
15158
- children: options2.map((option) => {
15218
+ children: options.map((option) => {
15159
15219
  const element = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
15160
15220
  Flex,
15161
15221
  {
@@ -16207,8 +16267,8 @@ function resolveDesignProps3(props) {
16207
16267
  }
16208
16268
  };
16209
16269
  }
16210
- function formatInvoices(invoices, options2) {
16211
- const { hideUpcoming = true } = options2 || {};
16270
+ function formatInvoices(invoices, options) {
16271
+ const { hideUpcoming = true } = options || {};
16212
16272
  const now = /* @__PURE__ */ new Date();
16213
16273
  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 }) => ({
16214
16274
  amount: formatCurrency(amountDue, currency),
@@ -17129,7 +17189,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
17129
17189
  }
17130
17190
  stripe._registerWrapper({
17131
17191
  name: "stripe-js",
17132
- version: "7.8.0",
17192
+ version: "7.9.0",
17133
17193
  startTime
17134
17194
  });
17135
17195
  };
@@ -17204,7 +17264,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
17204
17264
  var version = runtimeVersionToUrlVersion(maybeStripe.version);
17205
17265
  var expectedVersion = RELEASE_TRAIN;
17206
17266
  if (isTestKey && version !== expectedVersion) {
17207
- console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.8.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
17267
+ 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"));
17208
17268
  }
17209
17269
  var stripe = maybeStripe.apply(void 0, args);
17210
17270
  registerWrapper(stripe, startTime);
@@ -21224,7 +21284,7 @@ var {
21224
21284
  Z_DEFAULT_STRATEGY,
21225
21285
  Z_DEFLATED: Z_DEFLATED$1
21226
21286
  } = constants$2;
21227
- function Deflate$1(options2) {
21287
+ function Deflate$1(options) {
21228
21288
  this.options = common.assign({
21229
21289
  level: Z_DEFAULT_COMPRESSION,
21230
21290
  method: Z_DEFLATED$1,
@@ -21232,7 +21292,7 @@ function Deflate$1(options2) {
21232
21292
  windowBits: 15,
21233
21293
  memLevel: 8,
21234
21294
  strategy: Z_DEFAULT_STRATEGY
21235
- }, options2 || {});
21295
+ }, options || {});
21236
21296
  let opt = this.options;
21237
21297
  if (opt.raw && opt.windowBits > 0) {
21238
21298
  opt.windowBits = -opt.windowBits;
@@ -21338,23 +21398,23 @@ Deflate$1.prototype.onEnd = function(status) {
21338
21398
  this.err = status;
21339
21399
  this.msg = this.strm.msg;
21340
21400
  };
21341
- function deflate$1(input, options2) {
21342
- const deflator = new Deflate$1(options2);
21401
+ function deflate$1(input, options) {
21402
+ const deflator = new Deflate$1(options);
21343
21403
  deflator.push(input, true);
21344
21404
  if (deflator.err) {
21345
21405
  throw deflator.msg || messages[deflator.err];
21346
21406
  }
21347
21407
  return deflator.result;
21348
21408
  }
21349
- function deflateRaw$1(input, options2) {
21350
- options2 = options2 || {};
21351
- options2.raw = true;
21352
- return deflate$1(input, options2);
21409
+ function deflateRaw$1(input, options) {
21410
+ options = options || {};
21411
+ options.raw = true;
21412
+ return deflate$1(input, options);
21353
21413
  }
21354
- function gzip$1(input, options2) {
21355
- options2 = options2 || {};
21356
- options2.gzip = true;
21357
- return deflate$1(input, options2);
21414
+ function gzip$1(input, options) {
21415
+ options = options || {};
21416
+ options.gzip = true;
21417
+ return deflate$1(input, options);
21358
21418
  }
21359
21419
  var Deflate_1$1 = Deflate$1;
21360
21420
  var deflate_2 = deflate$1;
@@ -23167,12 +23227,12 @@ var {
23167
23227
  Z_DATA_ERROR,
23168
23228
  Z_MEM_ERROR
23169
23229
  } = constants$2;
23170
- function Inflate$1(options2) {
23230
+ function Inflate$1(options) {
23171
23231
  this.options = common.assign({
23172
23232
  chunkSize: 1024 * 64,
23173
23233
  windowBits: 15,
23174
23234
  to: ""
23175
- }, options2 || {});
23235
+ }, options || {});
23176
23236
  const opt = this.options;
23177
23237
  if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {
23178
23238
  opt.windowBits = -opt.windowBits;
@@ -23180,7 +23240,7 @@ function Inflate$1(options2) {
23180
23240
  opt.windowBits = -15;
23181
23241
  }
23182
23242
  }
23183
- if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options2 && options2.windowBits)) {
23243
+ if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {
23184
23244
  opt.windowBits += 32;
23185
23245
  }
23186
23246
  if (opt.windowBits > 15 && opt.windowBits < 48) {
@@ -23302,16 +23362,16 @@ Inflate$1.prototype.onEnd = function(status) {
23302
23362
  this.err = status;
23303
23363
  this.msg = this.strm.msg;
23304
23364
  };
23305
- function inflate$1(input, options2) {
23306
- const inflator = new Inflate$1(options2);
23365
+ function inflate$1(input, options) {
23366
+ const inflator = new Inflate$1(options);
23307
23367
  inflator.push(input);
23308
23368
  if (inflator.err) throw inflator.msg || messages[inflator.err];
23309
23369
  return inflator.result;
23310
23370
  }
23311
- function inflateRaw$1(input, options2) {
23312
- options2 = options2 || {};
23313
- options2.raw = true;
23314
- return inflate$1(input, options2);
23371
+ function inflateRaw$1(input, options) {
23372
+ options = options || {};
23373
+ options.raw = true;
23374
+ return inflate$1(input, options);
23315
23375
  }
23316
23376
  var Inflate_1$1 = Inflate$1;
23317
23377
  var inflate_2 = inflate$1;
@@ -23379,8 +23439,8 @@ function parseEditorState(data) {
23379
23439
  });
23380
23440
  return arr;
23381
23441
  }
23382
- function createRenderer(options2) {
23383
- const { useFallback = false } = options2 || {};
23442
+ function createRenderer(options) {
23443
+ const { useFallback = false } = options || {};
23384
23444
  return function renderNode(node2, index) {
23385
23445
  const { type, props = {}, children } = node2;
23386
23446
  const name = typeof type !== "string" ? type.resolvedName : type;