@schematichq/schematic-components 2.37.0 → 2.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2034,6 +2034,7 @@ var initialContext = {
2034
2034
  getUpcomingInvoice: stub,
2035
2035
  getCustomerBalance: stub,
2036
2036
  listInvoices: stub,
2037
+ getInvoiceLink: stub,
2037
2038
  getCreditUsageByUser: stub,
2038
2039
  getFeatureUsageByUser: stub,
2039
2040
  createSetupIntent: stub,
@@ -8276,6 +8277,84 @@ function CreateCheckoutResponseFromJSONTyped(json, ignoreDiscriminator) {
8276
8277
  };
8277
8278
  }
8278
8279
 
8280
+ // src/api/checkoutexternal/models/CreditSpendWindowUnit.ts
8281
+ function CreditSpendWindowUnitFromJSON(json) {
8282
+ return CreditSpendWindowUnitFromJSONTyped(json, false);
8283
+ }
8284
+ function CreditSpendWindowUnitFromJSONTyped(json, ignoreDiscriminator) {
8285
+ return json;
8286
+ }
8287
+ function CreditSpendWindowUnitToJSON(value) {
8288
+ return value;
8289
+ }
8290
+
8291
+ // src/api/checkoutexternal/models/CreateCompanySpendPolicyRequestBody.ts
8292
+ function CreateCompanySpendPolicyRequestBodyToJSON(json) {
8293
+ return CreateCompanySpendPolicyRequestBodyToJSONTyped(json, false);
8294
+ }
8295
+ function CreateCompanySpendPolicyRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
8296
+ if (value == null) {
8297
+ return value;
8298
+ }
8299
+ return {
8300
+ billing_credit_id: value["billingCreditId"],
8301
+ label: value["label"],
8302
+ max_per_draw: value["maxPerDraw"],
8303
+ user_id: value["userId"],
8304
+ window_amount: value["windowAmount"],
8305
+ window_unit: CreditSpendWindowUnitToJSON(value["windowUnit"])
8306
+ };
8307
+ }
8308
+
8309
+ // src/api/checkoutexternal/models/CreditSpendPolicyScope.ts
8310
+ function CreditSpendPolicyScopeFromJSON(json) {
8311
+ return CreditSpendPolicyScopeFromJSONTyped(json, false);
8312
+ }
8313
+ function CreditSpendPolicyScopeFromJSONTyped(json, ignoreDiscriminator) {
8314
+ return json;
8315
+ }
8316
+
8317
+ // src/api/checkoutexternal/models/CreditSpendPolicyResponseData.ts
8318
+ function CreditSpendPolicyResponseDataFromJSON(json) {
8319
+ return CreditSpendPolicyResponseDataFromJSONTyped(json, false);
8320
+ }
8321
+ function CreditSpendPolicyResponseDataFromJSONTyped(json, ignoreDiscriminator) {
8322
+ if (json == null) {
8323
+ return json;
8324
+ }
8325
+ return {
8326
+ billingCreditId: json["billing_credit_id"],
8327
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
8328
+ consumed: json["consumed"] == null ? void 0 : json["consumed"],
8329
+ createdAt: new Date(json["created_at"]),
8330
+ headroom: json["headroom"] == null ? void 0 : json["headroom"],
8331
+ id: json["id"],
8332
+ label: json["label"] == null ? void 0 : json["label"],
8333
+ maxPerDraw: json["max_per_draw"] == null ? void 0 : json["max_per_draw"],
8334
+ resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
8335
+ scopeType: CreditSpendPolicyScopeFromJSON(json["scope_type"]),
8336
+ updatedAt: new Date(json["updated_at"]),
8337
+ userId: json["user_id"] == null ? void 0 : json["user_id"],
8338
+ windowAmount: json["window_amount"] == null ? void 0 : json["window_amount"],
8339
+ windowCount: json["window_count"],
8340
+ windowUnit: json["window_unit"] == null ? void 0 : CreditSpendWindowUnitFromJSON(json["window_unit"])
8341
+ };
8342
+ }
8343
+
8344
+ // src/api/checkoutexternal/models/CreateCompanySpendPolicyResponse.ts
8345
+ function CreateCompanySpendPolicyResponseFromJSON(json) {
8346
+ return CreateCompanySpendPolicyResponseFromJSONTyped(json, false);
8347
+ }
8348
+ function CreateCompanySpendPolicyResponseFromJSONTyped(json, ignoreDiscriminator) {
8349
+ if (json == null) {
8350
+ return json;
8351
+ }
8352
+ return {
8353
+ data: CreditSpendPolicyResponseDataFromJSON(json["data"]),
8354
+ params: json["params"]
8355
+ };
8356
+ }
8357
+
8279
8358
  // src/api/checkoutexternal/models/SetupIntentResponseData.ts
8280
8359
  function SetupIntentResponseDataFromJSON(json) {
8281
8360
  return SetupIntentResponseDataFromJSONTyped(json, false);
@@ -8364,6 +8443,20 @@ function CreditUserUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
8364
8443
  };
8365
8444
  }
8366
8445
 
8446
+ // src/api/checkoutexternal/models/DeleteCompanySpendPolicyResponse.ts
8447
+ function DeleteCompanySpendPolicyResponseFromJSON(json) {
8448
+ return DeleteCompanySpendPolicyResponseFromJSONTyped(json, false);
8449
+ }
8450
+ function DeleteCompanySpendPolicyResponseFromJSONTyped(json, ignoreDiscriminator) {
8451
+ if (json == null) {
8452
+ return json;
8453
+ }
8454
+ return {
8455
+ data: DeleteResponseFromJSON(json["data"]),
8456
+ params: json["params"]
8457
+ };
8458
+ }
8459
+
8367
8460
  // src/api/checkoutexternal/models/DeletePaymentMethodResponse.ts
8368
8461
  function DeletePaymentMethodResponseFromJSON(json) {
8369
8462
  return DeletePaymentMethodResponseFromJSONTyped(json, false);
@@ -8738,6 +8831,34 @@ function GetFeatureUsageByUserResponseFromJSONTyped(json, ignoreDiscriminator) {
8738
8831
  };
8739
8832
  }
8740
8833
 
8834
+ // src/api/checkoutexternal/models/InvoiceLink.ts
8835
+ function InvoiceLinkFromJSON(json) {
8836
+ return InvoiceLinkFromJSONTyped(json, false);
8837
+ }
8838
+ function InvoiceLinkFromJSONTyped(json, ignoreDiscriminator) {
8839
+ if (json == null) {
8840
+ return json;
8841
+ }
8842
+ return {
8843
+ id: json["id"],
8844
+ url: json["url"]
8845
+ };
8846
+ }
8847
+
8848
+ // src/api/checkoutexternal/models/GetInvoiceLinkResponse.ts
8849
+ function GetInvoiceLinkResponseFromJSON(json) {
8850
+ return GetInvoiceLinkResponseFromJSONTyped(json, false);
8851
+ }
8852
+ function GetInvoiceLinkResponseFromJSONTyped(json, ignoreDiscriminator) {
8853
+ if (json == null) {
8854
+ return json;
8855
+ }
8856
+ return {
8857
+ data: InvoiceLinkFromJSON(json["data"]),
8858
+ params: json["params"]
8859
+ };
8860
+ }
8861
+
8741
8862
  // src/api/checkoutexternal/models/GetSetupIntentResponse.ts
8742
8863
  function GetSetupIntentResponseFromJSON(json) {
8743
8864
  return GetSetupIntentResponseFromJSONTyped(json, false);
@@ -8851,6 +8972,35 @@ function ListCheckoutsResponseFromJSONTyped(json, ignoreDiscriminator) {
8851
8972
  };
8852
8973
  }
8853
8974
 
8975
+ // src/api/checkoutexternal/models/ListCompanySpendPoliciesParams.ts
8976
+ function ListCompanySpendPoliciesParamsFromJSON(json) {
8977
+ return ListCompanySpendPoliciesParamsFromJSONTyped(json, false);
8978
+ }
8979
+ function ListCompanySpendPoliciesParamsFromJSONTyped(json, ignoreDiscriminator) {
8980
+ if (json == null) {
8981
+ return json;
8982
+ }
8983
+ return {
8984
+ billingCreditId: json["billing_credit_id"] == null ? void 0 : json["billing_credit_id"]
8985
+ };
8986
+ }
8987
+
8988
+ // src/api/checkoutexternal/models/ListCompanySpendPoliciesResponse.ts
8989
+ function ListCompanySpendPoliciesResponseFromJSON(json) {
8990
+ return ListCompanySpendPoliciesResponseFromJSONTyped(json, false);
8991
+ }
8992
+ function ListCompanySpendPoliciesResponseFromJSONTyped(json, ignoreDiscriminator) {
8993
+ if (json == null) {
8994
+ return json;
8995
+ }
8996
+ return {
8997
+ data: json["data"].map(
8998
+ CreditSpendPolicyResponseDataFromJSON
8999
+ ),
9000
+ params: ListCompanySpendPoliciesParamsFromJSON(json["params"])
9001
+ };
9002
+ }
9003
+
8854
9004
  // src/api/checkoutexternal/models/ListInvoicesParams.ts
8855
9005
  function ListInvoicesParamsFromJSON(json) {
8856
9006
  return ListInvoicesParamsFromJSONTyped(json, false);
@@ -9181,6 +9331,36 @@ function UpdateCheckoutTaxIDResponseFromJSONTyped(json, ignoreDiscriminator) {
9181
9331
  };
9182
9332
  }
9183
9333
 
9334
+ // src/api/checkoutexternal/models/UpdateCompanySpendPolicyResponse.ts
9335
+ function UpdateCompanySpendPolicyResponseFromJSON(json) {
9336
+ return UpdateCompanySpendPolicyResponseFromJSONTyped(json, false);
9337
+ }
9338
+ function UpdateCompanySpendPolicyResponseFromJSONTyped(json, ignoreDiscriminator) {
9339
+ if (json == null) {
9340
+ return json;
9341
+ }
9342
+ return {
9343
+ data: CreditSpendPolicyResponseDataFromJSON(json["data"]),
9344
+ params: json["params"]
9345
+ };
9346
+ }
9347
+
9348
+ // src/api/checkoutexternal/models/UpdateCreditSpendPolicyRequestBody.ts
9349
+ function UpdateCreditSpendPolicyRequestBodyToJSON(json) {
9350
+ return UpdateCreditSpendPolicyRequestBodyToJSONTyped(json, false);
9351
+ }
9352
+ function UpdateCreditSpendPolicyRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
9353
+ if (value == null) {
9354
+ return value;
9355
+ }
9356
+ return {
9357
+ label: value["label"],
9358
+ max_per_draw: value["maxPerDraw"],
9359
+ window_amount: value["windowAmount"],
9360
+ window_unit: CreditSpendWindowUnitToJSON(value["windowUnit"])
9361
+ };
9362
+ }
9363
+
9184
9364
  // src/api/checkoutexternal/models/UpdatePaymentMethodRequestBody.ts
9185
9365
  function UpdatePaymentMethodRequestBodyToJSON(json) {
9186
9366
  return UpdatePaymentMethodRequestBodyToJSONTyped(json, false);
@@ -9338,6 +9518,51 @@ var CheckoutexternalApi = class extends BaseAPI {
9338
9518
  );
9339
9519
  return await response.value();
9340
9520
  }
9521
+ /**
9522
+ * Create company spend policy
9523
+ */
9524
+ async createCompanySpendPolicyRaw(requestParameters, initOverrides) {
9525
+ if (requestParameters["createCompanySpendPolicyRequestBody"] == null) {
9526
+ throw new RequiredError(
9527
+ "createCompanySpendPolicyRequestBody",
9528
+ 'Required parameter "createCompanySpendPolicyRequestBody" was null or undefined when calling createCompanySpendPolicy().'
9529
+ );
9530
+ }
9531
+ const queryParameters = {};
9532
+ const headerParameters = {};
9533
+ headerParameters["Content-Type"] = "application/json";
9534
+ if (this.configuration && this.configuration.apiKey) {
9535
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
9536
+ "X-Schematic-Api-Key"
9537
+ );
9538
+ }
9539
+ const response = await this.request(
9540
+ {
9541
+ path: `/company/credits/spend-policies`,
9542
+ method: "POST",
9543
+ headers: headerParameters,
9544
+ query: queryParameters,
9545
+ body: CreateCompanySpendPolicyRequestBodyToJSON(
9546
+ requestParameters["createCompanySpendPolicyRequestBody"]
9547
+ )
9548
+ },
9549
+ initOverrides
9550
+ );
9551
+ return new JSONApiResponse(
9552
+ response,
9553
+ (jsonValue) => CreateCompanySpendPolicyResponseFromJSON(jsonValue)
9554
+ );
9555
+ }
9556
+ /**
9557
+ * Create company spend policy
9558
+ */
9559
+ async createCompanySpendPolicy(requestParameters, initOverrides) {
9560
+ const response = await this.createCompanySpendPolicyRaw(
9561
+ requestParameters,
9562
+ initOverrides
9563
+ );
9564
+ return await response.value();
9565
+ }
9341
9566
  /**
9342
9567
  * A Stripe SetupIntent for collecting a new payment method with Stripe\'s Payment Element. Confirm it with `stripe.confirmSetup`; the method it saves joins the company\'s methods on file.
9343
9568
  * Create a setup intent
@@ -9372,6 +9597,50 @@ var CheckoutexternalApi = class extends BaseAPI {
9372
9597
  const response = await this.createSetupIntentRaw(initOverrides);
9373
9598
  return await response.value();
9374
9599
  }
9600
+ /**
9601
+ * Delete company spend policy
9602
+ */
9603
+ async deleteCompanySpendPolicyRaw(requestParameters, initOverrides) {
9604
+ if (requestParameters["spendPolicyId"] == null) {
9605
+ throw new RequiredError(
9606
+ "spendPolicyId",
9607
+ 'Required parameter "spendPolicyId" was null or undefined when calling deleteCompanySpendPolicy().'
9608
+ );
9609
+ }
9610
+ const queryParameters = {};
9611
+ const headerParameters = {};
9612
+ if (this.configuration && this.configuration.apiKey) {
9613
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
9614
+ "X-Schematic-Api-Key"
9615
+ );
9616
+ }
9617
+ const response = await this.request(
9618
+ {
9619
+ path: `/company/credits/spend-policies/{spend_policy_id}`.replace(
9620
+ `{${"spend_policy_id"}}`,
9621
+ encodeURIComponent(String(requestParameters["spendPolicyId"]))
9622
+ ),
9623
+ method: "DELETE",
9624
+ headers: headerParameters,
9625
+ query: queryParameters
9626
+ },
9627
+ initOverrides
9628
+ );
9629
+ return new JSONApiResponse(
9630
+ response,
9631
+ (jsonValue) => DeleteCompanySpendPolicyResponseFromJSON(jsonValue)
9632
+ );
9633
+ }
9634
+ /**
9635
+ * Delete company spend policy
9636
+ */
9637
+ async deleteCompanySpendPolicy(requestParameters, initOverrides) {
9638
+ const response = await this.deleteCompanySpendPolicyRaw(
9639
+ requestParameters,
9640
+ initOverrides
9641
+ );
9642
+ return await response.value();
9643
+ }
9375
9644
  /**
9376
9645
  * Detaches a payment method from the company\'s billing customer. The path parameter is the payment method\'s `id` from the list, not a checkout\'s; `usePaymentMethods().remove` calls this and reloads the list. The list says whether each method can be removed.
9377
9646
  * Remove a payment method
@@ -10098,6 +10367,50 @@ var CheckoutexternalApi = class extends BaseAPI {
10098
10367
  );
10099
10368
  return await response.value();
10100
10369
  }
10370
+ /**
10371
+ * Get invoice link
10372
+ */
10373
+ async getInvoiceLinkRaw(requestParameters, initOverrides) {
10374
+ if (requestParameters["billingInvoiceId"] == null) {
10375
+ throw new RequiredError(
10376
+ "billingInvoiceId",
10377
+ 'Required parameter "billingInvoiceId" was null or undefined when calling getInvoiceLink().'
10378
+ );
10379
+ }
10380
+ const queryParameters = {};
10381
+ const headerParameters = {};
10382
+ if (this.configuration && this.configuration.apiKey) {
10383
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
10384
+ "X-Schematic-Api-Key"
10385
+ );
10386
+ }
10387
+ const response = await this.request(
10388
+ {
10389
+ path: `/components/invoices/{billing_invoice_id}/link`.replace(
10390
+ `{${"billing_invoice_id"}}`,
10391
+ encodeURIComponent(String(requestParameters["billingInvoiceId"]))
10392
+ ),
10393
+ method: "GET",
10394
+ headers: headerParameters,
10395
+ query: queryParameters
10396
+ },
10397
+ initOverrides
10398
+ );
10399
+ return new JSONApiResponse(
10400
+ response,
10401
+ (jsonValue) => GetInvoiceLinkResponseFromJSON(jsonValue)
10402
+ );
10403
+ }
10404
+ /**
10405
+ * Get invoice link
10406
+ */
10407
+ async getInvoiceLink(requestParameters, initOverrides) {
10408
+ const response = await this.getInvoiceLinkRaw(
10409
+ requestParameters,
10410
+ initOverrides
10411
+ );
10412
+ return await response.value();
10413
+ }
10101
10414
  /**
10102
10415
  * Get setup intent
10103
10416
  */
@@ -10320,6 +10633,44 @@ var CheckoutexternalApi = class extends BaseAPI {
10320
10633
  );
10321
10634
  return await response.value();
10322
10635
  }
10636
+ /**
10637
+ * List company spend policies
10638
+ */
10639
+ async listCompanySpendPoliciesRaw(requestParameters, initOverrides) {
10640
+ const queryParameters = {};
10641
+ if (requestParameters["billingCreditId"] != null) {
10642
+ queryParameters["billing_credit_id"] = requestParameters["billingCreditId"];
10643
+ }
10644
+ const headerParameters = {};
10645
+ if (this.configuration && this.configuration.apiKey) {
10646
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
10647
+ "X-Schematic-Api-Key"
10648
+ );
10649
+ }
10650
+ const response = await this.request(
10651
+ {
10652
+ path: `/company/credits/spend-policies`,
10653
+ method: "GET",
10654
+ headers: headerParameters,
10655
+ query: queryParameters
10656
+ },
10657
+ initOverrides
10658
+ );
10659
+ return new JSONApiResponse(
10660
+ response,
10661
+ (jsonValue) => ListCompanySpendPoliciesResponseFromJSON(jsonValue)
10662
+ );
10663
+ }
10664
+ /**
10665
+ * List company spend policies
10666
+ */
10667
+ async listCompanySpendPolicies(requestParameters = {}, initOverrides) {
10668
+ const response = await this.listCompanySpendPoliciesRaw(
10669
+ requestParameters,
10670
+ initOverrides
10671
+ );
10672
+ return await response.value();
10673
+ }
10323
10674
  /**
10324
10675
  * List invoices
10325
10676
  */
@@ -10554,6 +10905,60 @@ var CheckoutexternalApi = class extends BaseAPI {
10554
10905
  );
10555
10906
  return await response.value();
10556
10907
  }
10908
+ /**
10909
+ * Update company spend policy
10910
+ */
10911
+ async updateCompanySpendPolicyRaw(requestParameters, initOverrides) {
10912
+ if (requestParameters["spendPolicyId"] == null) {
10913
+ throw new RequiredError(
10914
+ "spendPolicyId",
10915
+ 'Required parameter "spendPolicyId" was null or undefined when calling updateCompanySpendPolicy().'
10916
+ );
10917
+ }
10918
+ if (requestParameters["updateCreditSpendPolicyRequestBody"] == null) {
10919
+ throw new RequiredError(
10920
+ "updateCreditSpendPolicyRequestBody",
10921
+ 'Required parameter "updateCreditSpendPolicyRequestBody" was null or undefined when calling updateCompanySpendPolicy().'
10922
+ );
10923
+ }
10924
+ const queryParameters = {};
10925
+ const headerParameters = {};
10926
+ headerParameters["Content-Type"] = "application/json";
10927
+ if (this.configuration && this.configuration.apiKey) {
10928
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
10929
+ "X-Schematic-Api-Key"
10930
+ );
10931
+ }
10932
+ const response = await this.request(
10933
+ {
10934
+ path: `/company/credits/spend-policies/{spend_policy_id}`.replace(
10935
+ `{${"spend_policy_id"}}`,
10936
+ encodeURIComponent(String(requestParameters["spendPolicyId"]))
10937
+ ),
10938
+ method: "PUT",
10939
+ headers: headerParameters,
10940
+ query: queryParameters,
10941
+ body: UpdateCreditSpendPolicyRequestBodyToJSON(
10942
+ requestParameters["updateCreditSpendPolicyRequestBody"]
10943
+ )
10944
+ },
10945
+ initOverrides
10946
+ );
10947
+ return new JSONApiResponse(
10948
+ response,
10949
+ (jsonValue) => UpdateCompanySpendPolicyResponseFromJSON(jsonValue)
10950
+ );
10951
+ }
10952
+ /**
10953
+ * Update company spend policy
10954
+ */
10955
+ async updateCompanySpendPolicy(requestParameters, initOverrides) {
10956
+ const response = await this.updateCompanySpendPolicyRaw(
10957
+ requestParameters,
10958
+ initOverrides
10959
+ );
10960
+ return await response.value();
10961
+ }
10557
10962
  /**
10558
10963
  * Makes a method on file the one the company\'s charges use. The body\'s `payment_method_id` is the provider\'s id of the method, the `external_id` the list returns; `usePaymentMethods().setDefault` calls this and reloads the list. A card saved during a checkout joins the methods on file and becomes the default the same way.
10559
10964
  * Make a payment method the default
@@ -12581,7 +12986,7 @@ function resolveLocale(locale) {
12581
12986
  return locale !== void 0 && locale !== "" && isUsableLocale(locale) ? locale : DEFAULT_LOCALE;
12582
12987
  }
12583
12988
 
12584
- // node_modules/.pnpm/i18next@26.7.1_typescript@6.0.3/node_modules/i18next/dist/esm/i18next.js
12989
+ // node_modules/.pnpm/i18next@27.0.0_typescript@6.0.3/node_modules/i18next/dist/esm/i18next.js
12585
12990
  var isString = (obj) => typeof obj === "string";
12586
12991
  var defer = () => {
12587
12992
  let res;
@@ -12696,12 +13101,11 @@ var _entityMap = {
12696
13101
  "<": "&lt;",
12697
13102
  ">": "&gt;",
12698
13103
  '"': "&quot;",
12699
- "'": "&#39;",
12700
- "/": "&#x2F;"
13104
+ "'": "&#39;"
12701
13105
  };
12702
13106
  var escape = (data) => {
12703
13107
  if (isString(data)) {
12704
- return data.replace(/[&<>"'\/]/g, (s) => _entityMap[s]);
13108
+ return data.replace(/[&<>"']/g, (s) => _entityMap[s]);
12705
13109
  }
12706
13110
  return data;
12707
13111
  };
@@ -12748,6 +13152,9 @@ var deepFind = (obj, path, keySeparator = ".") => {
12748
13152
  if (!Object.prototype.hasOwnProperty.call(obj, path)) return void 0;
12749
13153
  return obj[path];
12750
13154
  }
13155
+ if (!keySeparator) {
13156
+ return Object.prototype.hasOwnProperty.call(obj, path) ? obj[path] : void 0;
13157
+ }
12751
13158
  const tokens = path.split(keySeparator);
12752
13159
  let current = obj;
12753
13160
  for (let i2 = 0; i2 < tokens.length; ) {
@@ -12892,15 +13299,20 @@ var EventEmitter = class {
12892
13299
  }
12893
13300
  };
12894
13301
  var nonEmptyBundles = /* @__PURE__ */ new WeakSet();
13302
+ var assertSeparateArguments = (method, ...args) => {
13303
+ if (args.some((a2) => !isString(a2))) {
13304
+ throw new TypeError(`${method}: pass language, namespace${method === "addResource" ? " and key" : ""} as separate strings; the dotted form ('en.translation.key') was removed in i18next v27`);
13305
+ }
13306
+ };
12895
13307
  var ResourceStore = class extends EventEmitter {
12896
13308
  constructor(data, options = {
12897
13309
  ns: ["translation"],
12898
13310
  defaultNS: "translation"
12899
- }) {
13311
+ }, logger = baseLogger) {
12900
13312
  super();
12901
13313
  this.data = data || {};
12902
13314
  this.options = options;
12903
- this.logger = baseLogger.create("resourceStore");
13315
+ this.logger = logger.create("resourceStore");
12904
13316
  if (this.options.keySeparator === void 0) {
12905
13317
  this.options.keySeparator = ".";
12906
13318
  }
@@ -12919,49 +13331,30 @@ var ResourceStore = class extends EventEmitter {
12919
13331
  this.options.ns.splice(index, 1);
12920
13332
  }
12921
13333
  }
12922
- deprecateDottedLng(method) {
12923
- this.logger.once(method, "deprecate", `${method}: a dotted language ('en.translation.key') that carries the namespace and key is removed in v27; pass language, namespace and key as separate arguments`);
12924
- }
12925
13334
  getResource(lng, ns, key, options = {}) {
12926
13335
  const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
12927
13336
  const ignoreJSONStructure = options.ignoreJSONStructure !== void 0 ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
12928
- let path;
12929
- if (lng.includes(".")) {
12930
- this.deprecateDottedLng("getResource");
12931
- path = lng.split(".");
12932
- } else {
12933
- path = [lng, ns];
12934
- if (key) {
12935
- if (Array.isArray(key)) {
12936
- path.push(...key);
12937
- } else if (isString(key) && keySeparator) {
12938
- path.push(...key.split(keySeparator));
12939
- } else {
12940
- path.push(key);
12941
- }
13337
+ const path = [lng, ns];
13338
+ if (key) {
13339
+ if (Array.isArray(key)) {
13340
+ path.push(...key);
13341
+ } else if (isString(key) && keySeparator) {
13342
+ path.push(...key.split(keySeparator));
13343
+ } else {
13344
+ path.push(key);
12942
13345
  }
12943
13346
  }
12944
13347
  const result = getPath(this.data, path);
12945
- if (result == null && !ns && !key && lng.includes(".")) {
12946
- lng = path[0];
12947
- ns = path[1];
12948
- key = path.slice(2).join(".");
12949
- }
12950
13348
  if (result != null || !ignoreJSONStructure || !isString(key)) return result;
12951
13349
  return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
12952
13350
  }
12953
13351
  addResource(lng, ns, key, value, options = {
12954
13352
  silent: false
12955
13353
  }) {
13354
+ assertSeparateArguments("addResource", lng, ns, key);
12956
13355
  const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
12957
13356
  let path = [lng, ns];
12958
13357
  if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
12959
- if (lng.includes(".")) {
12960
- this.deprecateDottedLng("addResource");
12961
- path = lng.split(".");
12962
- value = ns;
12963
- ns = path[1];
12964
- }
12965
13358
  this.addNamespaces(ns);
12966
13359
  setPath(this.data, path, value);
12967
13360
  if (!options.silent) this.emit("added", lng, ns, key, value);
@@ -12969,25 +13362,21 @@ var ResourceStore = class extends EventEmitter {
12969
13362
  addResources(lng, ns, resources, options = {
12970
13363
  silent: false
12971
13364
  }) {
12972
- for (const m2 in resources) {
12973
- if (isString(resources[m2]) || Array.isArray(resources[m2])) this.addResource(lng, ns, m2, resources[m2], {
13365
+ assertSeparateArguments("addResources", lng, ns);
13366
+ Object.keys(resources || {}).forEach((m2) => {
13367
+ if (m2 === "__proto__" || m2 === "constructor") return;
13368
+ this.addResource(lng, ns, m2, resources[m2], {
12974
13369
  silent: true
12975
13370
  });
12976
- }
13371
+ });
12977
13372
  if (!options.silent) this.emit("added", lng, ns, resources);
12978
13373
  }
12979
13374
  addResourceBundle(lng, ns, resources, deep, overwrite, options = {
12980
13375
  silent: false,
12981
13376
  skipCopy: false
12982
13377
  }) {
12983
- let path = [lng, ns];
12984
- if (lng.includes(".")) {
12985
- this.deprecateDottedLng("addResourceBundle");
12986
- path = lng.split(".");
12987
- deep = resources;
12988
- resources = ns;
12989
- ns = path[1];
12990
- }
13378
+ assertSeparateArguments("addResourceBundle", lng, ns);
13379
+ const path = [lng, ns];
12991
13380
  this.addNamespaces(ns);
12992
13381
  let pack = getPath(this.data, path) || {};
12993
13382
  if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
@@ -13034,18 +13423,6 @@ var ResourceStore = class extends EventEmitter {
13034
13423
  return this.data;
13035
13424
  }
13036
13425
  };
13037
- var postProcessor = {
13038
- processors: {},
13039
- addPostProcessor(module2) {
13040
- this.processors[module2.name] = module2;
13041
- },
13042
- handle(processors, value, key, options, translator) {
13043
- processors.forEach((processor) => {
13044
- value = this.processors[processor]?.process(value, key, options, translator) ?? value;
13045
- });
13046
- return value;
13047
- }
13048
- };
13049
13426
  var PATH_KEY = /* @__PURE__ */ Symbol("i18next/PATH_KEY");
13050
13427
  function createProxy() {
13051
13428
  const state = [];
@@ -13064,7 +13441,7 @@ function keysFromSelector(selector, opts) {
13064
13441
  const {
13065
13442
  [PATH_KEY]: path
13066
13443
  } = selector(createProxy());
13067
- const keySeparator = opts?.keySeparator ?? ".";
13444
+ const keySeparator = opts?.keySeparator || ".";
13068
13445
  const nsSeparator = opts?.nsSeparator ?? ":";
13069
13446
  const strict = opts?.enableSelector === "strict";
13070
13447
  if (path.length > 1 && nsSeparator) {
@@ -13083,12 +13460,12 @@ var shouldHandleAsObject = (res) => !isString(res) && typeof res !== "boolean" &
13083
13460
  var Translator = class _Translator extends EventEmitter {
13084
13461
  constructor(services, options = {}) {
13085
13462
  super();
13086
- copy2(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils", "ownPostProcessors"], services, this);
13463
+ copy2(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils", "postProcessors"], services, this);
13087
13464
  this.options = options;
13088
13465
  if (this.options.keySeparator === void 0) {
13089
13466
  this.options.keySeparator = ".";
13090
13467
  }
13091
- this.logger = baseLogger.create("translator");
13468
+ this.logger = (services.logger || baseLogger).create("translator");
13092
13469
  this.checkedLoadedFor = {};
13093
13470
  }
13094
13471
  changeLanguage(lng) {
@@ -13212,23 +13589,24 @@ var Translator = class _Translator extends EventEmitter {
13212
13589
  }
13213
13590
  const handleAsObject = shouldHandleAsObject(resForObjHndl);
13214
13591
  const resType = Object.prototype.toString.apply(resForObjHndl);
13215
- if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && !noObject.includes(resType) && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
13216
- if (!opt.returnObjects && !this.options.returnObjects) {
13217
- if (!this.options.returnedObjectHandler) {
13218
- this.logger.warn("accessing an object - but returnObjects options is not enabled!");
13219
- this.logger.once("returnedObject", "deprecate", "accessing an object without returnObjects returns a sentence about it today; from v27 t() returns the key, as for a missing key (returnedObjectHandler can keep today's text)");
13220
- }
13221
- const r2 = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
13222
- ...opt,
13223
- ns: namespaces
13224
- }) : `key '${key} (${this.language})' returned an object instead of string.`;
13225
- if (returnDetails) {
13226
- resolved.res = r2;
13227
- resolved.usedParams = this.getUsedParamsDetails(opt);
13228
- return resolved;
13229
- }
13230
- return r2;
13592
+ const isObjectHit = handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && !noObject.includes(resType) && !(isString(joinArrays) && Array.isArray(resForObjHndl));
13593
+ const objectNotReturned = isObjectHit && !opt.returnObjects && !this.options.returnObjects;
13594
+ if (objectNotReturned && this.options.returnedObjectHandler) {
13595
+ const r2 = this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
13596
+ ...opt,
13597
+ ns: namespaces
13598
+ });
13599
+ if (returnDetails) {
13600
+ resolved.res = r2;
13601
+ resolved.usedParams = this.getUsedParamsDetails(opt);
13602
+ return resolved;
13231
13603
  }
13604
+ return r2;
13605
+ }
13606
+ if (objectNotReturned) {
13607
+ this.logger.warn("accessing an object - but returnObjects options is not enabled!");
13608
+ }
13609
+ if (isObjectHit && !objectNotReturned) {
13232
13610
  if (keySeparator) {
13233
13611
  const resTypeIsArray = Array.isArray(resForObjHndl);
13234
13612
  const copy3 = resTypeIsArray ? [] : {};
@@ -13265,18 +13643,19 @@ var Translator = class _Translator extends EventEmitter {
13265
13643
  } else {
13266
13644
  let usedDefault = false;
13267
13645
  let usedKey = false;
13268
- if (!this.isValidLookup(res) && hasDefaultValue) {
13646
+ if (objectNotReturned) res = void 0;
13647
+ if (!this.isValidLookup(res) && hasDefaultValue && !(objectNotReturned && shouldHandleAsObject(defaultValue))) {
13269
13648
  usedDefault = true;
13270
13649
  res = defaultValue;
13271
13650
  }
13272
- if (!this.isValidLookup(res)) {
13651
+ if (!this.isValidLookup(res) && !(usedDefault && res === "")) {
13273
13652
  usedKey = true;
13274
13653
  res = key;
13275
13654
  }
13276
13655
  const missingKeyNoValueFallbackToKey = opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
13277
13656
  const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? void 0 : res;
13278
13657
  const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
13279
- if (usedKey || usedDefault || updateMissing) {
13658
+ if (!objectNotReturned && (usedKey || usedDefault || updateMissing)) {
13280
13659
  this.logger.log(updateMissing ? "updateKey" : "missingKey", lng, namespace, needsPluralHandling && !updateMissing ? `${key}${this.pluralResolver.getSuffix(lng, opt.count, opt)}` : key, updateMissing ? defaultValue : res);
13281
13660
  if (keySeparator) {
13282
13661
  const fk = this.resolve(key, {
@@ -13384,18 +13763,21 @@ var Translator = class _Translator extends EventEmitter {
13384
13763
  const postProcess = opt.postProcess || this.options.postProcess;
13385
13764
  const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
13386
13765
  if (res != null && postProcessorNames?.length && opt.applyPostProcessor !== false) {
13387
- postProcessorNames.forEach((name) => {
13388
- if (this.logger.debug && postProcessor.processors[name] && this.ownPostProcessors && !this.ownPostProcessors.has(name)) {
13389
- this.logger.once(name, "deprecate", `postProcess: '${name}' was registered with use() on another i18next instance; from v27 post-processors are per instance, so call use() with it on this instance too`);
13390
- }
13391
- });
13392
- res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
13766
+ const ppOptions = this.options?.postProcessPassResolved ? {
13393
13767
  i18nResolved: {
13394
13768
  ...resolved,
13395
13769
  usedParams: this.getUsedParamsDetails(opt)
13396
13770
  },
13397
13771
  ...opt
13398
- } : opt, this);
13772
+ } : opt;
13773
+ postProcessorNames.forEach((name) => {
13774
+ const processor = this.postProcessors?.[name];
13775
+ if (!processor) {
13776
+ this.logger.once(`postProcess:${name}`, "warn", `postProcess: '${name}' is not registered on this i18next instance; call use() with it on this instance`);
13777
+ return;
13778
+ }
13779
+ res = processor.process(res, key, ppOptions, this) ?? res;
13780
+ });
13399
13781
  }
13400
13782
  return res;
13401
13783
  }
@@ -13524,14 +13906,16 @@ var Translator = class _Translator extends EventEmitter {
13524
13906
  }
13525
13907
  };
13526
13908
  var LanguageUtil = class {
13527
- constructor(options) {
13909
+ constructor(options, logger = baseLogger) {
13528
13910
  this.options = options;
13529
13911
  this.supportedLngs = this.options.supportedLngs || false;
13530
- this.logger = baseLogger.create("languageUtils");
13912
+ this.logger = logger.create("languageUtils");
13531
13913
  this.resolveHierarchyCache = {};
13914
+ this.formattedCodes = /* @__PURE__ */ new Map();
13532
13915
  }
13533
13916
  clearCache() {
13534
13917
  this.resolveHierarchyCache = {};
13918
+ this.formattedCodes.clear();
13535
13919
  }
13536
13920
  getScriptPartFromCode(code) {
13537
13921
  code = getCleanedCode(code);
@@ -13549,35 +13933,28 @@ var LanguageUtil = class {
13549
13933
  return this.formatLanguageCode(p2[0]);
13550
13934
  }
13551
13935
  formatLanguageCode(code) {
13552
- if (isString(code) && code.includes("-")) {
13553
- let formattedCode;
13936
+ if (!isString(code)) return code;
13937
+ let formatted = this.formattedCodes.get(code);
13938
+ if (formatted !== void 0) return formatted;
13939
+ formatted = this.formatUncached(code);
13940
+ if (this.formattedCodes.size >= 1e3) this.formattedCodes.clear();
13941
+ this.formattedCodes.set(code, formatted);
13942
+ return formatted;
13943
+ }
13944
+ formatUncached(code) {
13945
+ const hasSubtags = code.includes("-");
13946
+ if (hasSubtags || this.options.cleanCode !== false) {
13947
+ let canonical;
13554
13948
  try {
13555
- formattedCode = Intl.getCanonicalLocales(code)[0];
13949
+ canonical = Intl.getCanonicalLocales(code)[0];
13556
13950
  } catch (e) {
13557
13951
  }
13558
- if (formattedCode && this.options.lowerCaseLng) {
13559
- formattedCode = formattedCode.toLowerCase();
13560
- }
13561
- if (formattedCode) return formattedCode;
13562
- if (this.options.lowerCaseLng) {
13563
- return code.toLowerCase();
13952
+ if (canonical && (hasSubtags || canonical.toLowerCase() === code.toLowerCase())) {
13953
+ return this.options.lowerCaseLng ? canonical.toLowerCase() : canonical;
13564
13954
  }
13565
- return code;
13955
+ if (canonical) return code.toLowerCase();
13566
13956
  }
13567
- const formatted = this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
13568
- if (this.logger.debug && isString(code)) this.deprecateBareCode(code, formatted);
13569
- return formatted;
13570
- }
13571
- deprecateBareCode(code, formatted) {
13572
- let v27;
13573
- try {
13574
- v27 = Intl.getCanonicalLocales(code)[0];
13575
- } catch (e) {
13576
- return;
13577
- }
13578
- if (this.options.lowerCaseLng) v27 = v27.toLowerCase();
13579
- if (v27 === formatted) return;
13580
- this.logger.once(code, "deprecate", `language code '${code}' is used as '${formatted}'; i18next v27 canonicalizes it to '${v27}', use '${v27}' in lng, fallbackLng, supportedLngs and the resources`);
13957
+ return this.options.lowerCaseLng || this.options.cleanCode && !hasSubtags ? code.toLowerCase() : code;
13581
13958
  }
13582
13959
  isSupportedCode(code) {
13583
13960
  if (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) {
@@ -13689,10 +14066,10 @@ var dummyRule = {
13689
14066
  })
13690
14067
  };
13691
14068
  var PluralResolver = class {
13692
- constructor(languageUtils, options = {}) {
14069
+ constructor(languageUtils, options = {}, logger = baseLogger) {
13693
14070
  this.languageUtils = languageUtils;
13694
14071
  this.options = options;
13695
- this.logger = baseLogger.create("pluralResolver");
14072
+ this.logger = logger.create("pluralResolver");
13696
14073
  this.pluralRulesCache = {};
13697
14074
  }
13698
14075
  clearCache() {
@@ -13757,8 +14134,8 @@ var deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJS
13757
14134
  return path;
13758
14135
  };
13759
14136
  var Interpolator = class {
13760
- constructor(options = {}) {
13761
- this.logger = baseLogger.create("interpolator");
14137
+ constructor(options = {}, logger = baseLogger) {
14138
+ this.logger = logger.create("interpolator");
13762
14139
  this.options = options;
13763
14140
  this.format = options?.interpolation?.format || ((value) => value);
13764
14141
  this.init(options);
@@ -13772,39 +14149,26 @@ var Interpolator = class {
13772
14149
  escapeValue,
13773
14150
  useRawValueToEscape,
13774
14151
  prefix: prefix2,
13775
- prefixEscaped,
13776
14152
  suffix,
13777
- suffixEscaped,
13778
14153
  formatSeparator,
13779
14154
  unescapeSuffix,
13780
14155
  unescapePrefix,
13781
14156
  nestingPrefix,
13782
- nestingPrefixEscaped,
13783
14157
  nestingSuffix,
13784
- nestingSuffixEscaped,
13785
14158
  nestingOptionsSeparator,
13786
14159
  maxReplaces,
13787
14160
  alwaysFormat
13788
14161
  } = options.interpolation;
13789
- if (prefixEscaped || suffixEscaped || nestingPrefixEscaped || nestingSuffixEscaped) {
13790
- const names = Object.entries({
13791
- prefixEscaped,
13792
- suffixEscaped,
13793
- nestingPrefixEscaped,
13794
- nestingSuffixEscaped
13795
- }).filter(([, v2]) => v2).map(([k2]) => k2);
13796
- this.logger.once(names.join(), "deprecate", `interpolation.${names.join(", interpolation.")}: the regex-escaped delimiter options are removed in v27; pass the literal delimiters as prefix, suffix, nestingPrefix and nestingSuffix`);
13797
- }
13798
14162
  this.escape = escape$1 !== void 0 ? escape$1 : escape;
13799
14163
  this.escapeValue = escapeValue !== void 0 ? escapeValue : true;
13800
14164
  this.useRawValueToEscape = useRawValueToEscape !== void 0 ? useRawValueToEscape : false;
13801
- this.prefix = prefix2 ? regexEscape(prefix2) : prefixEscaped || "{{";
13802
- this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || "}}";
14165
+ this.prefix = prefix2 ? regexEscape(prefix2) : "{{";
14166
+ this.suffix = suffix ? regexEscape(suffix) : "}}";
13803
14167
  this.formatSeparator = formatSeparator || ",";
13804
14168
  this.unescapePrefix = unescapeSuffix ? "" : unescapePrefix ? regexEscape(unescapePrefix) : "-";
13805
14169
  this.unescapeSuffix = this.unescapePrefix ? "" : unescapeSuffix ? regexEscape(unescapeSuffix) : "";
13806
- this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape("$t(");
13807
- this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(")");
14170
+ this.nestingPrefix = regexEscape(nestingPrefix || "$t(");
14171
+ this.nestingSuffix = regexEscape(nestingSuffix || ")");
13808
14172
  this.nestingOptionsSeparator = nestingOptionsSeparator || ",";
13809
14173
  this.maxReplaces = maxReplaces || 1e3;
13810
14174
  this.alwaysFormat = alwaysFormat !== void 0 ? alwaysFormat : false;
@@ -13860,13 +14224,7 @@ var Interpolator = class {
13860
14224
  safeValue: (val) => val
13861
14225
  }, {
13862
14226
  regex: this.regexp,
13863
- safeValue: (val) => {
13864
- if (!this.escapeValue) return val;
13865
- if (this.escape === escape && this.options?.interpolation?.escapeValue !== false && isString(val) && val.includes("/")) {
13866
- this.logger.once("/", "deprecate", "escapeValue renders '/' in a value as '&#x2F;' today; from v27 the default escape leaves '/' as it is");
13867
- }
13868
- return this.escape(val);
13869
- }
14227
+ safeValue: (val) => this.escapeValue ? this.escape(val) : val
13870
14228
  }];
13871
14229
  const unescapedValues = [];
13872
14230
  let shift = 0;
@@ -14051,6 +14409,7 @@ var Formatter = class {
14051
14409
  init(services, options = {
14052
14410
  interpolation: {}
14053
14411
  }) {
14412
+ if (services?.logger?.create) this.logger = services.logger.create("formatter");
14054
14413
  this.formatSeparator = options.interpolation.formatSeparator || ",";
14055
14414
  const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
14056
14415
  this.formats = {
@@ -14146,7 +14505,7 @@ var Connector = class extends EventEmitter {
14146
14505
  this.services = services;
14147
14506
  this.languageUtils = services.languageUtils;
14148
14507
  this.options = options;
14149
- this.logger = baseLogger.create("backendConnector");
14508
+ this.logger = (services.logger || baseLogger).create("backendConnector");
14150
14509
  this.waitingReads = [];
14151
14510
  this.maxParallelReads = options.maxParallelReads || 10;
14152
14511
  this.readingCalls = 0;
@@ -14306,15 +14665,10 @@ var Connector = class extends EventEmitter {
14306
14665
  reload: true
14307
14666
  }, callback);
14308
14667
  }
14309
- noticeDevFallback(lng) {
14310
- if (lng !== "dev" || !this.devIsDefaultFallback) return;
14311
- this.logger.once("dev", "warn", "language 'dev' is requested because fallbackLng is not set (its default is ['dev']); i18next v27 defaults to fallbackLng: false and loads and saves missing keys in the requested language instead. Set fallbackLng to your source language, or to 'dev' to keep this behavior");
14312
- }
14313
14668
  loadOne(name, prefix2 = "") {
14314
14669
  const s = name.split("|");
14315
14670
  const lng = s[0];
14316
14671
  const ns = s[1];
14317
- this.noticeDevFallback(lng);
14318
14672
  this.read(lng, ns, "read", void 0, void 0, (err, data) => {
14319
14673
  if (err) this.logger.warn(`${prefix2}loading namespace ${ns} for language ${lng} failed`, err);
14320
14674
  if (!err && data) this.logger.log(`${prefix2}loaded namespace ${ns} for language ${lng}`, data);
@@ -14329,7 +14683,6 @@ var Connector = class extends EventEmitter {
14329
14683
  }
14330
14684
  if (key === void 0 || key === null || key === "") return;
14331
14685
  if (this.backend?.create) {
14332
- languages?.forEach?.((l2) => this.noticeDevFallback(l2));
14333
14686
  const opts = {
14334
14687
  ...options,
14335
14688
  isUpdate
@@ -14364,7 +14717,7 @@ var get = () => ({
14364
14717
  initAsync: true,
14365
14718
  ns: ["translation"],
14366
14719
  defaultNS: ["translation"],
14367
- fallbackLng: ["dev"],
14720
+ fallbackLng: false,
14368
14721
  fallbackNS: false,
14369
14722
  supportedLngs: false,
14370
14723
  nonExplicitSupportedLngs: false,
@@ -14385,7 +14738,7 @@ var get = () => ({
14385
14738
  postProcess: false,
14386
14739
  postProcessPassResolved: false,
14387
14740
  returnNull: false,
14388
- returnEmptyString: true,
14741
+ returnEmptyString: false,
14389
14742
  returnObjects: false,
14390
14743
  joinArrays: false,
14391
14744
  returnedObjectHandler: false,
@@ -14430,7 +14783,39 @@ var transformOptions = (options) => {
14430
14783
  };
14431
14784
  var noop = () => {
14432
14785
  };
14433
- var loggerOwner;
14786
+ var withDefaults = (options) => {
14787
+ const defOpts = get();
14788
+ const merged = {
14789
+ ...defOpts,
14790
+ ...options
14791
+ };
14792
+ merged.interpolation = {
14793
+ ...defOpts.interpolation,
14794
+ ...options.interpolation
14795
+ };
14796
+ if (typeof merged.overloadTranslationOptionHandler !== "function") {
14797
+ merged.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
14798
+ }
14799
+ return merged;
14800
+ };
14801
+ var configuredLanguageCodes = (options) => {
14802
+ const codes = [].concat(options.supportedLngs || [], options.preload || []);
14803
+ codes.push(...Object.keys(options.resources || {}));
14804
+ const fallbackLng = options.fallbackLng;
14805
+ if (isString(fallbackLng) || Array.isArray(fallbackLng)) codes.push(...[].concat(fallbackLng));
14806
+ else if (fallbackLng && typeof fallbackLng === "object") {
14807
+ Object.keys(fallbackLng).forEach((code) => {
14808
+ if (code !== "default") codes.push(code);
14809
+ codes.push(...[].concat(fallbackLng[code]));
14810
+ });
14811
+ }
14812
+ return codes;
14813
+ };
14814
+ var isRefusedLanguageCode = (i18n2, code) => {
14815
+ if (!isString(code) || isSafeLanguageCode(code) || i18n2.configuredLngs?.has(code)) return false;
14816
+ i18n2.logger.once(`lng:${code}`, "warn", `refused the language code '${code.slice(0, 64)}' from lng, changeLanguage(), the language detector or loadLanguages(): it is not configured and has other characters than letters, digits, '-', '_', '@' and '.' (or '..', or more than 128). List it in supportedLngs to use it`);
14817
+ return true;
14818
+ };
14434
14819
  var bindMemberFunctions = (inst) => {
14435
14820
  const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
14436
14821
  mems.forEach((mem) => {
@@ -14442,17 +14827,18 @@ var bindMemberFunctions = (inst) => {
14442
14827
  var I18n = class _I18n extends EventEmitter {
14443
14828
  constructor(options = {}, callback) {
14444
14829
  super();
14445
- this.options = transformOptions(options);
14830
+ this.userOptions = transformOptions(options);
14831
+ this.options = withDefaults(this.userOptions);
14446
14832
  this.services = {
14447
- ownPostProcessors: /* @__PURE__ */ new Set()
14833
+ postProcessors: /* @__PURE__ */ Object.create(null)
14448
14834
  };
14449
- this.logger = baseLogger;
14835
+ this.logger = new Logger(null, this.options);
14450
14836
  this.modules = {
14451
14837
  external: []
14452
14838
  };
14453
14839
  bindMemberFunctions(this);
14454
14840
  if (callback && !this.isInitialized && !options.isClone) {
14455
- if (!this.options.initAsync) {
14841
+ if (!this.userOptions.initAsync) {
14456
14842
  this.init(options, callback);
14457
14843
  return this;
14458
14844
  }
@@ -14474,25 +14860,23 @@ var I18n = class _I18n extends EventEmitter {
14474
14860
  options.defaultNS = options.ns[0];
14475
14861
  }
14476
14862
  }
14477
- const fallbackLngIsDefault = options.fallbackLng === void 0 && this.options.fallbackLng === void 0;
14478
- const defOpts = get();
14479
- this.options = {
14480
- ...defOpts,
14481
- ...this.options,
14482
- ...transformOptions(options)
14483
- };
14484
- this.options.interpolation = {
14485
- ...defOpts.interpolation,
14486
- ...this.options.interpolation
14863
+ transformOptions(options);
14864
+ const userOptions = {
14865
+ ...this.userOptions,
14866
+ ...options
14487
14867
  };
14488
- if (options.keySeparator !== void 0) {
14489
- this.options.userDefinedKeySeparator = options.keySeparator;
14868
+ this.options = withDefaults({
14869
+ ...this.options,
14870
+ ...options
14871
+ });
14872
+ if (userOptions.keySeparator !== void 0) {
14873
+ this.options.userDefinedKeySeparator = userOptions.keySeparator;
14490
14874
  }
14491
- if (options.nsSeparator !== void 0) {
14492
- this.options.userDefinedNsSeparator = options.nsSeparator;
14875
+ if (userOptions.nsSeparator !== void 0) {
14876
+ this.options.userDefinedNsSeparator = userOptions.nsSeparator;
14493
14877
  }
14494
- if (typeof this.options.overloadTranslationOptionHandler !== "function") {
14495
- this.options.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
14878
+ if (!this.options.isClone) {
14879
+ this.configuredLngs = /* @__PURE__ */ new Set([...this.configuredLngs || [], ...configuredLanguageCodes(userOptions)]);
14496
14880
  }
14497
14881
  const createClassOnDemand = (ClassOrObject) => {
14498
14882
  if (!ClassOrObject) return null;
@@ -14500,15 +14884,10 @@ var I18n = class _I18n extends EventEmitter {
14500
14884
  return ClassOrObject;
14501
14885
  };
14502
14886
  if (!this.options.isClone) {
14503
- if (loggerOwner && loggerOwner !== this && loggerOwner.modules.logger !== this.modules.logger) {
14504
- baseLogger.deprecate("init: this init() replaces the logger another i18next instance set with use(), as the logger is shared in v26; from v27 each instance keeps its own logger");
14505
- }
14506
- loggerOwner = this.modules.logger ? this : void 0;
14507
- if (this.modules.logger) {
14508
- baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
14509
- } else {
14510
- baseLogger.init(null, this.options);
14511
- }
14887
+ this.logger.init(createClassOnDemand(this.modules.logger), this.options);
14888
+ const {
14889
+ logger
14890
+ } = this;
14512
14891
  this.pendingWarnings?.forEach((msg) => this.logger.warn(msg));
14513
14892
  this.pendingWarnings = void 0;
14514
14893
  let formatter;
@@ -14517,27 +14896,26 @@ var I18n = class _I18n extends EventEmitter {
14517
14896
  } else {
14518
14897
  formatter = Formatter;
14519
14898
  }
14520
- const lu = new LanguageUtil(this.options);
14521
- this.store = new ResourceStore(this.options.resources, this.options);
14899
+ const lu = new LanguageUtil(this.options, logger);
14900
+ this.store = new ResourceStore(this.options.resources, this.options, logger);
14522
14901
  const s = this.services;
14523
- s.logger = baseLogger;
14902
+ s.logger = logger;
14524
14903
  s.resourceStore = this.store;
14525
14904
  s.languageUtils = lu;
14526
14905
  s.pluralResolver = new PluralResolver(lu, {
14527
14906
  prepend: this.options.pluralSeparator
14528
- });
14907
+ }, logger);
14529
14908
  if (formatter) {
14530
14909
  s.formatter = createClassOnDemand(formatter);
14531
14910
  if (s.formatter.init) s.formatter.init(s, this.options);
14532
14911
  this.options.interpolation.format = s.formatter.format.bind(s.formatter);
14533
14912
  }
14534
- s.interpolator = new Interpolator(this.options);
14913
+ s.interpolator = new Interpolator(this.options, logger);
14535
14914
  s.utils = {
14536
14915
  hasLoadedNamespace: this.hasLoadedNamespace.bind(this),
14537
14916
  reloadResources: this.reloadResources.bind(this)
14538
14917
  };
14539
14918
  s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
14540
- s.backendConnector.devIsDefaultFallback = fallbackLngIsDefault;
14541
14919
  s.backendConnector.on("*", (event, ...args) => {
14542
14920
  this.emit(event, ...args);
14543
14921
  });
@@ -14678,8 +15056,7 @@ var I18n = class _I18n extends EventEmitter {
14678
15056
  setModule("i18nFormat");
14679
15057
  }
14680
15058
  if (module2.type === "postProcessor") {
14681
- postProcessor.addPostProcessor(module2);
14682
- this.services.ownPostProcessors?.add(module2.name);
15059
+ this.services.postProcessors[module2.name] = module2;
14683
15060
  }
14684
15061
  if (module2.type === "formatter") {
14685
15062
  setModule("formatter");
@@ -14754,14 +15131,16 @@ var I18n = class _I18n extends EventEmitter {
14754
15131
  };
14755
15132
  const setLng = (lngs) => {
14756
15133
  if (!lng && !lngs && this.services.languageDetector) lngs = [];
14757
- const fl = isString(lngs) ? lngs : lngs && lngs[0];
14758
- const l2 = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
14759
- if (l2 && this.logger.debug && !isSafeLanguageCode(l2)) {
14760
- const configured = [].concat(this.options.supportedLngs || [], this.services.languageUtils.getFallbackCodes(this.options.fallbackLng, l2), this.options.preload || []);
14761
- if (!configured.includes(l2) && !Object.prototype.hasOwnProperty.call(this.store.data, l2)) {
14762
- this.logger.once(`lng:${l2}`, "deprecate", `changeLanguage: the language code '${l2.slice(0, 64)}' comes from lng, changeLanguage() or the language detector and is not configured; from v27 such a code is refused unless it has only letters, digits, '-', '_', '@' and '.' (no '..'), at most 128 characters. Set supportedLngs, or check the code before passing it on`);
14763
- }
15134
+ const {
15135
+ supportedLngs
15136
+ } = this.options;
15137
+ if (lngs && !supportedLngs) {
15138
+ const accepted = [].concat(lngs).filter((c2) => !isRefusedLanguageCode(this, c2));
15139
+ if (accepted.length < [].concat(lngs).length) lngs = accepted;
14764
15140
  }
15141
+ const fl = isString(lngs) ? lngs : lngs && lngs[0];
15142
+ let l2 = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
15143
+ if (supportedLngs && isRefusedLanguageCode(this, l2)) l2 = this.services.languageUtils.getBestMatchFromCodes([]);
14765
15144
  if (l2) {
14766
15145
  if (!this.language) {
14767
15146
  setLngProps(l2);
@@ -14876,7 +15255,7 @@ var I18n = class _I18n extends EventEmitter {
14876
15255
  }
14877
15256
  loadNamespaces(ns, callback) {
14878
15257
  const deferred = defer();
14879
- if (!this.options.ns) {
15258
+ if (!this.options.ns || !this.services.backendConnector) {
14880
15259
  if (callback) callback();
14881
15260
  return Promise.resolve();
14882
15261
  }
@@ -14894,7 +15273,7 @@ var I18n = class _I18n extends EventEmitter {
14894
15273
  const deferred = defer();
14895
15274
  if (isString(lngs)) lngs = [lngs];
14896
15275
  const preloaded = this.options.preload || [];
14897
- const newLngs = lngs.filter((lng) => !preloaded.includes(lng) && this.services.languageUtils.isSupportedCode(lng));
15276
+ const newLngs = lngs.filter((lng) => !preloaded.includes(lng) && !isRefusedLanguageCode(this, lng) && this.services.languageUtils.isSupportedCode(lng));
14898
15277
  if (!newLngs.length) {
14899
15278
  if (callback) callback();
14900
15279
  return Promise.resolve();
@@ -14944,16 +15323,15 @@ var I18n = class _I18n extends EventEmitter {
14944
15323
  }
14945
15324
  };
14946
15325
  const clone = new _I18n(mergedOptions);
14947
- if (options.debug !== void 0 || options.prefix !== void 0) {
14948
- clone.logger = clone.logger.clone(options);
14949
- }
14950
- const membersToCopy = ["store", "services", "language"];
15326
+ clone.logger = options.debug !== void 0 || options.prefix !== void 0 ? this.logger.clone(options) : this.logger;
15327
+ const membersToCopy = ["store", "language"];
14951
15328
  membersToCopy.forEach((m2) => {
14952
15329
  clone[m2] = this[m2];
14953
15330
  });
14954
15331
  clone.services = {
14955
15332
  ...this.services
14956
15333
  };
15334
+ clone.services.postProcessors = Object.create(this.services.postProcessors);
14957
15335
  clone.services.utils = {
14958
15336
  ...clone.services.utils,
14959
15337
  hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone),
@@ -14970,7 +15348,7 @@ var I18n = class _I18n extends EventEmitter {
14970
15348
  return copied;
14971
15349
  };
14972
15350
  const clonedData = copyData(this.store.data);
14973
- clone.store = new ResourceStore(clonedData, mergedOptions);
15351
+ clone.store = new ResourceStore(clonedData, mergedOptions, this.logger);
14974
15352
  clone.services.resourceStore = clone.store;
14975
15353
  }
14976
15354
  if (options.interpolation) {
@@ -14984,8 +15362,9 @@ var I18n = class _I18n extends EventEmitter {
14984
15362
  ...mergedOptions,
14985
15363
  interpolation: mergedInterpolation
14986
15364
  };
14987
- clone.services.interpolator = new Interpolator(mergedForInterpolator);
15365
+ clone.services.interpolator = new Interpolator(mergedForInterpolator, this.logger);
14988
15366
  }
15367
+ clone.configuredLngs = /* @__PURE__ */ new Set([...this.configuredLngs || [], ...configuredLanguageCodes(options)]);
14989
15368
  clone.translator = new Translator(clone.services, mergedOptions);
14990
15369
  clone.translator.on("*", (event, ...args) => {
14991
15370
  clone.emit(event, ...args);
@@ -17013,6 +17392,25 @@ var createKeyboardExecutionHandler = (fn) => {
17013
17392
  return handler;
17014
17393
  };
17015
17394
 
17395
+ // src/utils/invoiceLink.ts
17396
+ function openInvoiceLink(event, storedUrl, fetchUrl) {
17397
+ if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
17398
+ return Promise.resolve();
17399
+ }
17400
+ const tab = window.open("", "_blank");
17401
+ if (tab === null) {
17402
+ return Promise.resolve();
17403
+ }
17404
+ event.preventDefault();
17405
+ tab.opener = null;
17406
+ return fetchUrl().then(
17407
+ (url) => url || storedUrl,
17408
+ () => storedUrl
17409
+ ).then((url) => {
17410
+ tab.location.href = url;
17411
+ });
17412
+ }
17413
+
17016
17414
  // src/utils/markdown.tsx
17017
17415
  var import_react4 = require("react");
17018
17416
  var import_jsx_runtime3 = require("react/jsx-runtime");
@@ -17765,7 +18163,7 @@ var reducer = (state, action) => {
17765
18163
  // src/context/EmbedProvider.tsx
17766
18164
  var import_jsx_runtime4 = require("react/jsx-runtime");
17767
18165
  var getCustomHeaders = (sessionId) => ({
17768
- "X-Schematic-Components-Version": "2.37.0",
18166
+ "X-Schematic-Components-Version": "2.38.0",
17769
18167
  "X-Schematic-Session-ID": sessionId
17770
18168
  });
17771
18169
  var normalizeCurrencyFilter = (filter2) => {
@@ -18153,6 +18551,12 @@ var EmbedProvider = ({
18153
18551
  () => (0, import_debounce2.default)(listInvoices, FETCH_DEBOUNCE_TIMEOUT, LEADING_DEBOUNCE_SETTINGS),
18154
18552
  [listInvoices]
18155
18553
  );
18554
+ const getInvoiceLink = (0, import_react5.useCallback)(
18555
+ async (billingInvoiceId) => {
18556
+ return checkoutApi?.getInvoiceLink({ billingInvoiceId });
18557
+ },
18558
+ [checkoutApi]
18559
+ );
18156
18560
  const getCreditUsageByUser = (0, import_react5.useCallback)(
18157
18561
  async (billingCreditId, limit) => {
18158
18562
  return checkoutApi?.getCreditUsageByUser({ billingCreditId, limit });
@@ -18347,6 +18751,7 @@ var EmbedProvider = ({
18347
18751
  getUpcomingInvoice: debouncedGetUpcomingInvoice,
18348
18752
  getCustomerBalance: debouncedGetCustomerBalance,
18349
18753
  listInvoices: debouncedListInvoices,
18754
+ getInvoiceLink,
18350
18755
  getCreditUsageByUser: debouncedGetCreditUsageByUser,
18351
18756
  getFeatureUsageByUser: debouncedGetFeatureUsageByUser,
18352
18757
  finishCheckout,
@@ -27326,12 +27731,13 @@ function formatInvoices(invoices, locale, options) {
27326
27731
  const dateA = a2.dueDate ?? a2.createdAt;
27327
27732
  const dateB = b2.dueDate ?? b2.createdAt;
27328
27733
  return +dateB - +dateA;
27329
- }).map(({ amountDue, dueDate, createdAt, url, currency }) => {
27734
+ }).map(({ amountDue, dueDate, createdAt, id, url, currency }) => {
27330
27735
  const formatted = formatCurrency(Math.abs(amountDue), {
27331
27736
  locale,
27332
27737
  currency
27333
27738
  });
27334
27739
  return {
27740
+ id,
27335
27741
  amount: amountDue < 0 ? `(${formatted})` : formatted,
27336
27742
  amountDue,
27337
27743
  date: toPrettyDate(dueDate ?? createdAt, { locale }),
@@ -27342,7 +27748,7 @@ function formatInvoices(invoices, locale, options) {
27342
27748
  var Invoices = (0, import_react45.forwardRef)(({ className, ...rest }, ref) => {
27343
27749
  const props = resolveDesignProps3(rest);
27344
27750
  const { t: t3, locale } = useTranslation();
27345
- const { data, listInvoices, settings } = useEmbed();
27751
+ const { data, getInvoiceLink, listInvoices, settings } = useEmbed();
27346
27752
  const [isLoading, setIsLoading] = (0, import_react45.useState)(false);
27347
27753
  const [error, setError] = (0, import_react45.useState)();
27348
27754
  const [rawInvoices, setInvoices] = (0, import_react45.useState)(
@@ -27419,7 +27825,7 @@ var Invoices = (0, import_react45.forwardRef)(({ className, ...rest }, ref) => {
27419
27825
  props.header.isVisible && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Flex, { $justifyContent: "space-between", $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Text, { display: props.header.fontStyle, children: t3("Invoices") }) }),
27420
27826
  invoices.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
27421
27827
  /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Flex, { $flexDirection: "column", $gap: "0.5rem", children: visibleInvoices.items.map(
27422
- ({ date, amount, amountDue, url }, index) => {
27828
+ ({ id, date, amount, amountDue, url }, index) => {
27423
27829
  return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
27424
27830
  Flex,
27425
27831
  {
@@ -27430,11 +27836,18 @@ var Invoices = (0, import_react45.forwardRef)(({ className, ...rest }, ref) => {
27430
27836
  Text,
27431
27837
  {
27432
27838
  display: props.date.fontStyle,
27433
- ...url && {
27839
+ ...id && url && {
27434
27840
  as: "a",
27435
27841
  href: url,
27436
27842
  target: "_blank",
27437
- rel: "noreferrer"
27843
+ rel: "noreferrer",
27844
+ onClick: (event) => {
27845
+ void openInvoiceLink(
27846
+ event,
27847
+ url,
27848
+ async () => (await getInvoiceLink(id))?.data.url
27849
+ );
27850
+ }
27438
27851
  },
27439
27852
  $color: url ? settings.theme.typography.link.color : settings.theme.typography.text.color,
27440
27853
  children: date