@aidc-toolkit/gs1 0.9.7-beta → 0.9.9-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,11 +17,19 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
31
+ var index_exports = {};
32
+ __export(index_exports, {
23
33
  AI39_CREATOR: () => AI39_CREATOR,
24
34
  AI82_CREATOR: () => AI82_CREATOR,
25
35
  CPID_VALIDATOR: () => CPID_VALIDATOR,
@@ -58,17 +68,24 @@ __export(src_exports, {
58
68
  fiveDigitPriceWeightCheckDigit: () => fiveDigitPriceWeightCheckDigit,
59
69
  fourDigitPriceWeightCheckDigit: () => fourDigitPriceWeightCheckDigit,
60
70
  gs1NS: () => gs1NS,
71
+ gs1Resources: () => gs1Resources,
61
72
  hasValidCheckCharacterPair: () => hasValidCheckCharacterPair,
62
- hasValidCheckDigit: () => hasValidCheckDigit
73
+ hasValidCheckDigit: () => hasValidCheckDigit,
74
+ i18nGS1Init: () => i18nGS1Init,
75
+ i18nextGS1: () => i18nextGS1
63
76
  });
64
- module.exports = __toCommonJS(src_exports);
77
+ module.exports = __toCommonJS(index_exports);
65
78
 
66
79
  // src/locale/i18n.ts
67
80
  var import_core = require("@aidc-toolkit/core");
81
+ var import_utility = require("@aidc-toolkit/utility");
82
+ var import_i18next = __toESM(require("i18next"), 1);
68
83
 
69
- // src/locale/en/locale_strings.ts
84
+ // src/locale/en/locale-strings.ts
70
85
  var localeStrings = {
71
86
  Check: {
87
+ lengthOfStringForPriceOrWeightMustBeExactly: "Length {{length}} of string for price or weight sum must be exactly {{exactLength}}",
88
+ priceOrWeightComponent: "price or weight",
72
89
  lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: "Length {{length}} of string for check character pair must be less than or equal to {{maximumLength}}"
73
90
  },
74
91
  IdentificationKey: {
@@ -102,9 +119,11 @@ var localeStrings = {
102
119
  }
103
120
  };
104
121
 
105
- // src/locale/fr/locale_strings.ts
122
+ // src/locale/fr/locale-strings.ts
106
123
  var localeStrings2 = {
107
124
  Check: {
125
+ lengthOfStringForPriceOrWeightMustBeExactly: "La longueur {{longueur}} de la cha\xEEne pour le prix ou la somme du poids doit \xEAtre exactement {{exactLength}}",
126
+ priceOrWeightComponent: "prix ou poids",
108
127
  lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: "La longueur {{length}} de la cha\xEEne pour la paire de caract\xE8res de v\xE9rification doit \xEAtre inf\xE9rieure ou \xE9gale \xE0 {{maximum Length}}"
109
128
  },
110
129
  IdentificationKey: {
@@ -141,13 +160,23 @@ var localeStrings2 = {
141
160
  // src/locale/i18n.ts
142
161
  var gs1NS = "aidct_gs1";
143
162
  (0, import_core.i18nAssertValidResources)(localeStrings, "fr", localeStrings2);
144
- (0, import_core.i18nAddResourceBundle)("en", gs1NS, localeStrings);
145
- (0, import_core.i18nAddResourceBundle)("fr", gs1NS, localeStrings2);
146
- var i18n_default = import_core.i18next;
163
+ var gs1Resources = {
164
+ en: {
165
+ aidct_gs1: localeStrings
166
+ },
167
+ fr: {
168
+ aidct_gs1: localeStrings2
169
+ }
170
+ };
171
+ var i18nextGS1 = import_i18next.default.createInstance();
172
+ async function i18nGS1Init(environment, debug = false) {
173
+ await (0, import_utility.i18nUtilityInit)(environment, debug);
174
+ await (0, import_core.i18nCoreInit)(i18nextGS1, environment, debug, gs1NS, import_utility.utilityResources, gs1Resources);
175
+ }
147
176
 
148
- // src/character_set.ts
149
- var import_utility = require("@aidc-toolkit/utility");
150
- var AI82_CREATOR = new import_utility.CharacterSetCreator([
177
+ // src/character-set.ts
178
+ var import_utility2 = require("@aidc-toolkit/utility");
179
+ var AI82_CREATOR = new import_utility2.CharacterSetCreator([
151
180
  "!",
152
181
  '"',
153
182
  "%",
@@ -230,8 +259,8 @@ var AI82_CREATOR = new import_utility.CharacterSetCreator([
230
259
  "x",
231
260
  "y",
232
261
  "z"
233
- ], import_utility.Exclusion.AllNumeric);
234
- var AI39_CREATOR = new import_utility.CharacterSetCreator([
262
+ ], import_utility2.Exclusion.AllNumeric);
263
+ var AI39_CREATOR = new import_utility2.CharacterSetCreator([
235
264
  "#",
236
265
  "-",
237
266
  "/",
@@ -271,10 +300,10 @@ var AI39_CREATOR = new import_utility.CharacterSetCreator([
271
300
  "X",
272
301
  "Y",
273
302
  "Z"
274
- ], import_utility.Exclusion.AllNumeric);
303
+ ], import_utility2.Exclusion.AllNumeric);
275
304
 
276
305
  // src/check.ts
277
- var import_utility2 = require("@aidc-toolkit/utility");
306
+ var import_utility3 = require("@aidc-toolkit/utility");
278
307
  var THREE_WEIGHT_RESULTS = [
279
308
  0,
280
309
  3,
@@ -337,37 +366,49 @@ var INVERSE_FIVE_MINUS_WEIGHT_RESULTS = [
337
366
  ];
338
367
  function checkDigitSum(exchangeWeights, s) {
339
368
  let weight3 = (s.length + Number(exchangeWeights)) % 2 === 0;
340
- return import_utility2.NUMERIC_CREATOR.characterIndexes(s).reduce((accumulator, characterIndex, index) => {
369
+ return import_utility3.NUMERIC_CREATOR.characterIndexes(s).reduce((accumulator, characterIndex, index) => {
341
370
  if (characterIndex === void 0) {
342
- throw new RangeError(`Invalid character '${s.charAt(index)}' at position ${index + 1}`);
371
+ throw new RangeError(i18nextGS1.t("CharacterSetValidator.invalidCharacterAtPosition", {
372
+ ns: import_utility3.utilityNS,
373
+ c: s.charAt(index),
374
+ position: index + 1
375
+ }));
343
376
  }
344
377
  weight3 = !weight3;
345
378
  return accumulator + (weight3 ? THREE_WEIGHT_RESULTS[characterIndex] : characterIndex);
346
379
  }, 0);
347
380
  }
348
381
  function checkDigit(s) {
349
- return import_utility2.NUMERIC_CREATOR.character(9 - (checkDigitSum(false, s) + 9) % 10);
382
+ return import_utility3.NUMERIC_CREATOR.character(9 - (checkDigitSum(false, s) + 9) % 10);
350
383
  }
351
384
  function hasValidCheckDigit(s) {
352
385
  return checkDigitSum(true, s) % 10 === 0;
353
386
  }
354
387
  function priceWeightSum(weightsResults, s) {
355
388
  if (s.length !== weightsResults.length) {
356
- throw new RangeError(`String for price or weight sum must be exactly ${weightsResults.length} characters`);
389
+ throw new RangeError(i18nextGS1.t("Check.lengthOfStringForPriceOrWeightMustBeExactly", {
390
+ length: s.length,
391
+ exactLength: weightsResults.length
392
+ }));
357
393
  }
358
- const characterIndexes = import_utility2.NUMERIC_CREATOR.characterIndexes(s);
394
+ const characterIndexes = import_utility3.NUMERIC_CREATOR.characterIndexes(s);
359
395
  return characterIndexes.reduce((accumulator, characterIndex, index) => {
360
396
  if (characterIndex === void 0) {
361
- throw new RangeError(`Invalid character '${s.charAt(index)}' at position ${index + 1}`);
397
+ throw new RangeError(i18nextGS1.t("CharacterSetValidator.invalidCharacterAtPositionOfComponent", {
398
+ ns: import_utility3.utilityNS,
399
+ c: s.charAt(index),
400
+ position: index + 1,
401
+ component: i18nextGS1.t("Check.priceOrWeightComponent")
402
+ }));
362
403
  }
363
404
  return accumulator + weightsResults[index][characterIndex];
364
405
  }, 0);
365
406
  }
366
407
  function fourDigitPriceWeightCheckDigit(s) {
367
- return import_utility2.NUMERIC_CREATOR.character(priceWeightSum([TWO_MINUS_WEIGHT_RESULTS, TWO_MINUS_WEIGHT_RESULTS, THREE_WEIGHT_RESULTS, FIVE_MINUS_WEIGHT_RESULTS], s) * 3 % 10);
408
+ return import_utility3.NUMERIC_CREATOR.character(priceWeightSum([TWO_MINUS_WEIGHT_RESULTS, TWO_MINUS_WEIGHT_RESULTS, THREE_WEIGHT_RESULTS, FIVE_MINUS_WEIGHT_RESULTS], s) * 3 % 10);
368
409
  }
369
410
  function fiveDigitPriceWeightCheckDigit(s) {
370
- return import_utility2.NUMERIC_CREATOR.character(INVERSE_FIVE_MINUS_WEIGHT_RESULTS[9 - (priceWeightSum([FIVE_PLUS_WEIGHT_RESULTS, TWO_MINUS_WEIGHT_RESULTS, FIVE_MINUS_WEIGHT_RESULTS, FIVE_PLUS_WEIGHT_RESULTS, TWO_MINUS_WEIGHT_RESULTS], s) + 9) % 10]);
411
+ return import_utility3.NUMERIC_CREATOR.character(INVERSE_FIVE_MINUS_WEIGHT_RESULTS[9 - (priceWeightSum([FIVE_PLUS_WEIGHT_RESULTS, TWO_MINUS_WEIGHT_RESULTS, FIVE_MINUS_WEIGHT_RESULTS, FIVE_PLUS_WEIGHT_RESULTS, TWO_MINUS_WEIGHT_RESULTS], s) + 9) % 10]);
371
412
  }
372
413
  var CHECK_CHARACTER_WEIGHTS = [
373
414
  107,
@@ -436,15 +477,18 @@ var CHECK_CHARACTERS = [
436
477
  function checkCharacterPair(s) {
437
478
  const weightIndexStart = CHECK_CHARACTER_WEIGHTS.length - s.length;
438
479
  if (weightIndexStart < 0) {
439
- throw new RangeError(i18n_default.t("Check.lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo", {
440
- ns: gs1NS,
480
+ throw new RangeError(i18nextGS1.t("Check.lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo", {
441
481
  length: s.length,
442
482
  maximumLength: CHECK_CHARACTER_WEIGHTS.length
443
483
  }));
444
484
  }
445
485
  const checkCharacterPairSum = AI82_CREATOR.characterIndexes(s).reduce((accumulator, characterIndex, index) => {
446
486
  if (characterIndex === void 0) {
447
- throw new RangeError(`Invalid character '${s.charAt(index)}' at position ${index + 1}`);
487
+ throw new RangeError(i18nextGS1.t("CharacterSetValidator.invalidCharacterAtPosition", {
488
+ ns: import_utility3.utilityNS,
489
+ c: s.charAt(index),
490
+ position: index + 1
491
+ }));
448
492
  }
449
493
  return accumulator + characterIndex * CHECK_CHARACTER_WEIGHTS[weightIndexStart + index];
450
494
  }, 0) % 1021;
@@ -457,7 +501,7 @@ function hasValidCheckCharacterPair(s) {
457
501
  }
458
502
 
459
503
  // src/idkey.ts
460
- var import_utility3 = require("@aidc-toolkit/utility");
504
+ var import_utility4 = require("@aidc-toolkit/utility");
461
505
  var import_ts_mixer = require("ts-mixer");
462
506
  var IdentificationKeyType = /* @__PURE__ */ ((IdentificationKeyType2) => {
463
507
  IdentificationKeyType2["GTIN"] = "GTIN";
@@ -488,7 +532,7 @@ var ContentCharacterSet = /* @__PURE__ */ ((ContentCharacterSet2) => {
488
532
  })(ContentCharacterSet || {});
489
533
  var AbstractIdentificationKeyValidator = class _AbstractIdentificationKeyValidator {
490
534
  static CHARACTER_SET_CREATORS = [
491
- import_utility3.NUMERIC_CREATOR,
535
+ import_utility4.NUMERIC_CREATOR,
492
536
  AI82_CREATOR,
493
537
  AI39_CREATOR
494
538
  ];
@@ -656,16 +700,13 @@ var AbstractNumericIdentificationKeyValidator = class extends AbstractIdentifica
656
700
  super.validatePrefix(identificationKey.substring(this._prefixPosition), validation?.positionOffset === void 0 ? this._prefixPosition : validation.positionOffset + this._prefixPosition);
657
701
  }
658
702
  if (identificationKey.length !== this.length) {
659
- throw new RangeError(i18n_default.t("IdentificationKey.identificationKeyTypeLength", {
660
- ns: gs1NS,
703
+ throw new RangeError(i18nextGS1.t("IdentificationKey.identificationKeyTypeLength", {
661
704
  identificationKeyType: this.identificationKeyType,
662
705
  length: this.length
663
706
  }));
664
707
  }
665
708
  if (!hasValidCheckDigit(this.padIdentificationKey(identificationKey, validation))) {
666
- throw new RangeError(i18n_default.t("IdentificationKey.invalidCheckDigit", {
667
- ns: gs1NS
668
- }));
709
+ throw new RangeError(i18nextGS1.t("IdentificationKey.invalidCheckDigit"));
669
710
  }
670
711
  }
671
712
  };
@@ -735,7 +776,7 @@ var GTINValidator = class _GTINValidator extends AbstractNumericIdentificationKe
735
776
  * GTIN-12.
736
777
  */
737
778
  static zeroExpand(zeroSuppressedGTIN12) {
738
- import_utility3.NUMERIC_CREATOR.validate(zeroSuppressedGTIN12, _GTINValidator.ZERO_SUPPRESSED_GTIN12_VALIDATION);
779
+ import_utility4.NUMERIC_CREATOR.validate(zeroSuppressedGTIN12, _GTINValidator.ZERO_SUPPRESSED_GTIN12_VALIDATION);
739
780
  const d = Array.from(zeroSuppressedGTIN12);
740
781
  let gtin12;
741
782
  if (d[0] === "0") {
@@ -750,9 +791,7 @@ var GTINValidator = class _GTINValidator extends AbstractNumericIdentificationKe
750
791
  }
751
792
  }
752
793
  if (gtin12 === void 0) {
753
- throw new RangeError(i18n_default.t("IdentificationKey.invalidZeroSuppressedGTIN12", {
754
- ns: gs1NS
755
- }));
794
+ throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressedGTIN12"));
756
795
  }
757
796
  GTIN12_VALIDATOR.validate(gtin12);
758
797
  return gtin12;
@@ -772,9 +811,7 @@ var GTINValidator = class _GTINValidator extends AbstractNumericIdentificationKe
772
811
  switch (gtin.length) {
773
812
  case 13 /* GTIN13 */:
774
813
  if (gtin.startsWith("0")) {
775
- throw new RangeError(i18n_default.t("IdentificationKey.invalidGTIN13AtRetail", {
776
- ns: gs1NS
777
- }));
814
+ throw new RangeError(i18nextGS1.t("IdentificationKey.invalidGTIN13AtRetail"));
778
815
  }
779
816
  PrefixManager.validatePrefix(0 /* GS1CompanyPrefix */, false, false, gtin, true, true);
780
817
  gtinLevelRestriction = 0 /* Any */;
@@ -796,19 +833,13 @@ var GTINValidator = class _GTINValidator extends AbstractNumericIdentificationKe
796
833
  gtinLevelRestriction = 2 /* OtherThanRetailConsumer */;
797
834
  break;
798
835
  default:
799
- throw new RangeError(i18n_default.t("IdentificationKey.invalidGTINLength", {
800
- ns: gs1NS
801
- }));
836
+ throw new RangeError(i18nextGS1.t("IdentificationKey.invalidGTINLength"));
802
837
  }
803
838
  if (!hasValidCheckDigit(lengthValidatedGTIN)) {
804
- throw new RangeError(i18n_default.t("IdentificationKey.invalidCheckDigit", {
805
- ns: gs1NS
806
- }));
839
+ throw new RangeError(i18nextGS1.t("IdentificationKey.invalidCheckDigit"));
807
840
  }
808
841
  if (gtinLevel !== 0 /* Any */ && gtinLevelRestriction !== 0 /* Any */ && gtinLevelRestriction !== gtinLevel) {
809
- throw new RangeError(i18n_default.t(gtinLevel === 1 /* RetailConsumer */ ? "IdentificationKey.invalidGTINAtRetail" : "IdentificationKey.invalidGTINAtOtherThanRetail", {
810
- ns: gs1NS
811
- }));
842
+ throw new RangeError(i18nextGS1.t(gtinLevel === 1 /* RetailConsumer */ ? "IdentificationKey.invalidGTINAtRetail" : "IdentificationKey.invalidGTINAtOtherThanRetail"));
812
843
  }
813
844
  }
814
845
  /**
@@ -819,9 +850,7 @@ var GTINValidator = class _GTINValidator extends AbstractNumericIdentificationKe
819
850
  */
820
851
  static validateGTIN14(gtin14) {
821
852
  if (gtin14.length !== 14 /* GTIN14 */) {
822
- throw new RangeError(i18n_default.t("IdentificationKey.invalidGTIN14Length", {
823
- ns: gs1NS
824
- }));
853
+ throw new RangeError(i18nextGS1.t("IdentificationKey.invalidGTIN14Length"));
825
854
  }
826
855
  GTINCreator.validateAny(gtin14);
827
856
  }
@@ -882,9 +911,7 @@ var SerializableNumericIdentificationKeyValidator = class _SerializableNumericId
882
911
  this._serialComponentValidation = {
883
912
  minimumLength: 1,
884
913
  maximumLength: serialComponentLength,
885
- component: () => i18n_default.t("IdentificationKey.serialComponent", {
886
- ns: gs1NS
887
- })
914
+ component: () => i18nextGS1.t("IdentificationKey.serialComponent")
888
915
  };
889
916
  this._serialComponentCreator = _SerializableNumericIdentificationKeyValidator.creatorFor(serialComponentCharacterSet);
890
917
  }
@@ -926,14 +953,12 @@ var NonNumericIdentificationKeyValidator = class _NonNumericIdentificationKeyVal
926
953
  /**
927
954
  * Validator to ensure that an identification key (minus check character pair) is not all numeric.
928
955
  */
929
- static NOT_ALL_NUMERIC_VALIDATOR = new class extends import_utility3.RegExpValidator {
956
+ static NOT_ALL_NUMERIC_VALIDATOR = new class extends import_utility4.RegExpValidator {
930
957
  /**
931
958
  * @inheritDoc
932
959
  */
933
960
  createErrorMessage(_s) {
934
- return i18n_default.t("IdentificationKey.referenceCantBeAllNumeric", {
935
- ns: gs1NS
936
- });
961
+ return i18nextGS1.t("IdentificationKey.referenceCantBeAllNumeric");
937
962
  }
938
963
  }(/\D/);
939
964
  /**
@@ -983,11 +1008,9 @@ var NonNumericIdentificationKeyValidator = class _NonNumericIdentificationKeyVal
983
1008
  positionOffset: validation?.positionOffset
984
1009
  });
985
1010
  } else if (!hasValidCheckCharacterPair(this.padIdentificationKey(identificationKey, validation))) {
986
- throw new RangeError(i18n_default.t("IdentificationKey.invalidCheckCharacterPair", {
987
- ns: gs1NS
988
- }));
1011
+ throw new RangeError(i18nextGS1.t("IdentificationKey.invalidCheckCharacterPair"));
989
1012
  }
990
- if (validation?.exclusion === import_utility3.Exclusion.AllNumeric) {
1013
+ if (validation?.exclusion === import_utility4.Exclusion.AllNumeric) {
991
1014
  _NonNumericIdentificationKeyValidator.NOT_ALL_NUMERIC_VALIDATOR.validate(partialIdentificationKey);
992
1015
  }
993
1016
  }
@@ -1075,7 +1098,7 @@ var AbstractNumericIdentificationKeyCreator = class _AbstractNumericIdentificati
1075
1098
  */
1076
1099
  init(prefixManager, prefix) {
1077
1100
  super.init(prefixManager, prefix, 1);
1078
- this._capacity = Number(import_utility3.CharacterSetCreator.powerOf10(this.referenceLength));
1101
+ this._capacity = Number(import_utility4.CharacterSetCreator.powerOf10(this.referenceLength));
1079
1102
  }
1080
1103
  /**
1081
1104
  * @inheritDoc
@@ -1112,7 +1135,7 @@ var AbstractNumericIdentificationKeyCreator = class _AbstractNumericIdentificati
1112
1135
  * @inheritDoc
1113
1136
  */
1114
1137
  create(valueOrValues, sparse = false) {
1115
- return import_utility3.NUMERIC_CREATOR.create(this.referenceLength, valueOrValues, import_utility3.Exclusion.None, sparse ? this.tweak : void 0, (reference) => this.buildIdentificationKey(reference));
1138
+ return import_utility4.NUMERIC_CREATOR.create(this.referenceLength, valueOrValues, import_utility4.Exclusion.None, sparse ? this.tweak : void 0, (reference) => this.buildIdentificationKey(reference));
1116
1139
  }
1117
1140
  /**
1118
1141
  * Create all identification keys from a partial identification key. Call is recursive until remaining reference
@@ -1139,18 +1162,18 @@ var AbstractNumericIdentificationKeyCreator = class _AbstractNumericIdentificati
1139
1162
  */
1140
1163
  static *createAllPartial(partialIdentificationKey, remainingReferenceLength, extensionWeight, weight, partialCheckDigitSum) {
1141
1164
  if (remainingReferenceLength === 0) {
1142
- yield partialIdentificationKey + import_utility3.NUMERIC_CREATOR.character(9 - (partialCheckDigitSum + 9) % 10);
1165
+ yield partialIdentificationKey + import_utility4.NUMERIC_CREATOR.character(9 - (partialCheckDigitSum + 9) % 10);
1143
1166
  } else {
1144
1167
  const nextRemainingReferenceLength = remainingReferenceLength - 1;
1145
1168
  let nextPartialCheckDigitSum = partialCheckDigitSum;
1146
1169
  if (extensionWeight !== 0) {
1147
- for (const c of import_utility3.NUMERIC_CREATOR.characterSet) {
1170
+ for (const c of import_utility4.NUMERIC_CREATOR.characterSet) {
1148
1171
  yield* _AbstractNumericIdentificationKeyCreator.createAllPartial(c + partialIdentificationKey, nextRemainingReferenceLength, 0, weight, nextPartialCheckDigitSum);
1149
1172
  nextPartialCheckDigitSum += extensionWeight;
1150
1173
  }
1151
1174
  } else {
1152
1175
  const nextWeight = 4 - weight;
1153
- for (const c of import_utility3.NUMERIC_CREATOR.characterSet) {
1176
+ for (const c of import_utility4.NUMERIC_CREATOR.characterSet) {
1154
1177
  yield* _AbstractNumericIdentificationKeyCreator.createAllPartial(partialIdentificationKey + c, nextRemainingReferenceLength, 0, nextWeight, nextPartialCheckDigitSum);
1155
1178
  nextPartialCheckDigitSum += weight;
1156
1179
  }
@@ -1163,9 +1186,14 @@ var AbstractNumericIdentificationKeyCreator = class _AbstractNumericIdentificati
1163
1186
  createAll() {
1164
1187
  const hasExtensionDigit = this.leaderType === 2 /* ExtensionDigit */;
1165
1188
  const prefix = this.prefix;
1189
+ const length = this.length;
1166
1190
  const referenceLength = this.referenceLength;
1167
1191
  const startWeight = 3 - 2 * ((referenceLength + 1 - Number(hasExtensionDigit)) % 2);
1168
- return _AbstractNumericIdentificationKeyCreator.createAllPartial(prefix, referenceLength, hasExtensionDigit ? 3 - 2 * this.length % 2 : 0, startWeight, checkDigitSum(startWeight === 3, prefix));
1192
+ return {
1193
+ [Symbol.iterator]() {
1194
+ return _AbstractNumericIdentificationKeyCreator.createAllPartial(prefix, referenceLength, hasExtensionDigit ? 3 - 2 * length % 2 : 0, startWeight, checkDigitSum(startWeight === 3, prefix));
1195
+ }
1196
+ };
1169
1197
  }
1170
1198
  };
1171
1199
  var GTINCreator = class _GTINCreator extends (0, import_ts_mixer.Mixin)(GTINValidator, AbstractNumericIdentificationKeyCreator) {
@@ -1175,9 +1203,7 @@ var GTINCreator = class _GTINCreator extends (0, import_ts_mixer.Mixin)(GTINVali
1175
1203
  static REQUIRED_INDICATOR_DIGIT_VALIDATION = {
1176
1204
  minimumLength: 1,
1177
1205
  maximumLength: 1,
1178
- component: () => i18n_default.t("IdentificationKey.indicatorDigit", {
1179
- ns: gs1NS
1180
- })
1206
+ component: () => i18nextGS1.t("IdentificationKey.indicatorDigit")
1181
1207
  };
1182
1208
  /**
1183
1209
  * Validation parameters for optional indicator digit.
@@ -1185,9 +1211,7 @@ var GTINCreator = class _GTINCreator extends (0, import_ts_mixer.Mixin)(GTINVali
1185
1211
  static OPTIONAL_INDICATOR_DIGIT_VALIDATION = {
1186
1212
  minimumLength: 0,
1187
1213
  maximumLength: 1,
1188
- component: () => i18n_default.t("IdentificationKey.indicatorDigit", {
1189
- ns: gs1NS
1190
- })
1214
+ component: () => i18nextGS1.t("IdentificationKey.indicatorDigit")
1191
1215
  };
1192
1216
  /**
1193
1217
  * Constructor. Called internally by {@link PrefixManager.gtinCreator}; should not be called by other code.
@@ -1225,8 +1249,8 @@ var GTINCreator = class _GTINCreator extends (0, import_ts_mixer.Mixin)(GTINVali
1225
1249
  * GTIN-14(s).
1226
1250
  */
1227
1251
  createGTIN14(indicatorDigit, valueOrValues, sparse = false) {
1228
- import_utility3.NUMERIC_CREATOR.validate(indicatorDigit, _GTINCreator.REQUIRED_INDICATOR_DIGIT_VALIDATION);
1229
- return import_utility3.NUMERIC_CREATOR.create(13 /* GTIN13 */ - this.prefixManager.gs1CompanyPrefix.length - 1, valueOrValues, import_utility3.Exclusion.None, sparse ? this.tweak : void 0, (reference) => {
1252
+ import_utility4.NUMERIC_CREATOR.validate(indicatorDigit, _GTINCreator.REQUIRED_INDICATOR_DIGIT_VALIDATION);
1253
+ return import_utility4.NUMERIC_CREATOR.create(13 /* GTIN13 */ - this.prefixManager.gs1CompanyPrefix.length - 1, valueOrValues, import_utility4.Exclusion.None, sparse ? this.tweak : void 0, (reference) => {
1230
1254
  const partialIdentificationKey = indicatorDigit + this.prefixManager.gs1CompanyPrefix + reference;
1231
1255
  return partialIdentificationKey + checkDigit(partialIdentificationKey);
1232
1256
  });
@@ -1256,9 +1280,7 @@ var GTINCreator = class _GTINCreator extends (0, import_ts_mixer.Mixin)(GTINVali
1256
1280
  }
1257
1281
  }
1258
1282
  if (zeroSuppressedGTIN12 === void 0) {
1259
- throw new RangeError(i18n_default.t("IdentificationKey.invalidZeroSuppressibleGTIN12", {
1260
- ns: gs1NS
1261
- }));
1283
+ throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressibleGTIN12"));
1262
1284
  }
1263
1285
  return zeroSuppressedGTIN12;
1264
1286
  }
@@ -1276,7 +1298,7 @@ var GTINCreator = class _GTINCreator extends (0, import_ts_mixer.Mixin)(GTINVali
1276
1298
  */
1277
1299
  static convertToGTIN14(indicatorDigit, gtin) {
1278
1300
  _GTINCreator.validateAny(gtin);
1279
- import_utility3.NUMERIC_CREATOR.validate(indicatorDigit, _GTINCreator.OPTIONAL_INDICATOR_DIGIT_VALIDATION);
1301
+ import_utility4.NUMERIC_CREATOR.validate(indicatorDigit, _GTINCreator.OPTIONAL_INDICATOR_DIGIT_VALIDATION);
1280
1302
  const gtinLength = gtin.length;
1281
1303
  let gtin14 = "0".repeat(14 /* GTIN14 */ - gtinLength) + gtin;
1282
1304
  if (indicatorDigit.length !== 0 && indicatorDigit !== gtin14.charAt(0)) {
@@ -1310,9 +1332,7 @@ var GTINCreator = class _GTINCreator extends (0, import_ts_mixer.Mixin)(GTINVali
1310
1332
  } else if (!gtin.startsWith("000000")) {
1311
1333
  normalizedGTIN = gtin.substring(5);
1312
1334
  } else {
1313
- throw new RangeError(i18n_default.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN13", {
1314
- ns: gs1NS
1315
- }));
1335
+ throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN13"));
1316
1336
  }
1317
1337
  break;
1318
1338
  case 12 /* GTIN12 */:
@@ -1335,15 +1355,11 @@ var GTINCreator = class _GTINCreator extends (0, import_ts_mixer.Mixin)(GTINVali
1335
1355
  } else if (!gtin.startsWith("0000000")) {
1336
1356
  normalizedGTIN = gtin.substring(6);
1337
1357
  } else {
1338
- throw new RangeError(i18n_default.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN14", {
1339
- ns: gs1NS
1340
- }));
1358
+ throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN14"));
1341
1359
  }
1342
1360
  break;
1343
1361
  default:
1344
- throw new RangeError(i18n_default.t("IdentificationKey.invalidGTINLength", {
1345
- ns: gs1NS
1346
- }));
1362
+ throw new RangeError(i18nextGS1.t("IdentificationKey.invalidGTINLength"));
1347
1363
  }
1348
1364
  _GTINCreator.validateAny(normalizedGTIN);
1349
1365
  return normalizedGTIN;
@@ -1418,7 +1434,7 @@ var SerializableNumericIdentificationKeyCreator = class extends (0, import_ts_mi
1418
1434
  if (typeof serialComponentOrComponents !== "object") {
1419
1435
  result = validateAndConcatenate(serialComponentOrComponents);
1420
1436
  } else {
1421
- result = import_utility3.IteratorProxy.from(serialComponentOrComponents).map(validateAndConcatenate);
1437
+ result = (0, import_utility4.transformIterable)(serialComponentOrComponents, validateAndConcatenate);
1422
1438
  }
1423
1439
  return result;
1424
1440
  }
@@ -1489,9 +1505,7 @@ var NonNumericIdentificationKeyCreator = class extends (0, import_ts_mixer.Mixin
1489
1505
  minimumLength: 1,
1490
1506
  // Maximum reference length has to account for prefix and check character pair.
1491
1507
  maximumLength: this.referenceLength,
1492
- component: () => i18n_default.t("IdentificationKey.reference", {
1493
- ns: gs1NS
1494
- })
1508
+ component: () => i18nextGS1.t("IdentificationKey.reference")
1495
1509
  };
1496
1510
  }
1497
1511
  /**
@@ -1523,7 +1537,7 @@ var NonNumericIdentificationKeyCreator = class extends (0, import_ts_mixer.Mixin
1523
1537
  if (typeof referenceOrReferences !== "object") {
1524
1538
  result = validateAndCreate(referenceOrReferences);
1525
1539
  } else {
1526
- result = import_utility3.IteratorProxy.from(referenceOrReferences).map(validateAndCreate);
1540
+ result = (0, import_utility4.transformIterable)(referenceOrReferences, validateAndCreate);
1527
1541
  }
1528
1542
  return result;
1529
1543
  }
@@ -1563,9 +1577,7 @@ var PrefixManager = class _PrefixManager {
1563
1577
  static GS1_COMPANY_PREFIX_VALIDATION = {
1564
1578
  minimumLength: _PrefixManager.GS1_COMPANY_PREFIX_MINIMUM_LENGTH,
1565
1579
  maximumLength: _PrefixManager.GS1_COMPANY_PREFIX_MAXIMUM_LENGTH,
1566
- component: () => i18n_default.t("Prefix.gs1CompanyPrefix", {
1567
- ns: gs1NS
1568
- })
1580
+ component: () => i18nextGS1.t("Prefix.gs1CompanyPrefix")
1569
1581
  };
1570
1582
  /**
1571
1583
  * Validation parameters for U.P.C. Company Prefix expressed as GS1 Company Prefix.
@@ -1573,9 +1585,7 @@ var PrefixManager = class _PrefixManager {
1573
1585
  static UPC_COMPANY_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION = {
1574
1586
  minimumLength: _PrefixManager.UPC_COMPANY_PREFIX_MINIMUM_LENGTH + 1,
1575
1587
  maximumLength: _PrefixManager.UPC_COMPANY_PREFIX_MAXIMUM_LENGTH + 1,
1576
- component: () => i18n_default.t("Prefix.gs1CompanyPrefix", {
1577
- ns: gs1NS
1578
- })
1588
+ component: () => i18nextGS1.t("Prefix.gs1CompanyPrefix")
1579
1589
  };
1580
1590
  /**
1581
1591
  * Validation parameters for GS1-8 Prefix expressed as GS1 Company Prefix.
@@ -1583,9 +1593,7 @@ var PrefixManager = class _PrefixManager {
1583
1593
  static GS1_8_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION = {
1584
1594
  minimumLength: _PrefixManager.GS1_8_PREFIX_MINIMUM_LENGTH + 5,
1585
1595
  maximumLength: _PrefixManager.GS1_8_PREFIX_MAXIMUM_LENGTH + 5,
1586
- component: () => i18n_default.t("Prefix.gs1CompanyPrefix", {
1587
- ns: gs1NS
1588
- })
1596
+ component: () => i18nextGS1.t("Prefix.gs1CompanyPrefix")
1589
1597
  };
1590
1598
  /**
1591
1599
  * Validation parameters for U.P.C. Company Prefix.
@@ -1593,9 +1601,7 @@ var PrefixManager = class _PrefixManager {
1593
1601
  static UPC_COMPANY_PREFIX_VALIDATION = {
1594
1602
  minimumLength: _PrefixManager.UPC_COMPANY_PREFIX_MINIMUM_LENGTH,
1595
1603
  maximumLength: _PrefixManager.UPC_COMPANY_PREFIX_MAXIMUM_LENGTH,
1596
- component: () => i18n_default.t("Prefix.upcCompanyPrefix", {
1597
- ns: gs1NS
1598
- })
1604
+ component: () => i18nextGS1.t("Prefix.upcCompanyPrefix")
1599
1605
  };
1600
1606
  /**
1601
1607
  * Validation parameters for GS1-8 Prefix.
@@ -1603,9 +1609,7 @@ var PrefixManager = class _PrefixManager {
1603
1609
  static GS1_8_PREFIX_VALIDATION = {
1604
1610
  minimumLength: _PrefixManager.GS1_8_PREFIX_MINIMUM_LENGTH,
1605
1611
  maximumLength: _PrefixManager.GS1_8_PREFIX_MAXIMUM_LENGTH,
1606
- component: () => i18n_default.t("Prefix.gs18Prefix", {
1607
- ns: gs1NS
1608
- })
1612
+ component: () => i18nextGS1.t("Prefix.gs18Prefix")
1609
1613
  };
1610
1614
  /**
1611
1615
  * Creator tweak factors. Different numeric identification key types have different tweak factors so that sparse
@@ -1805,37 +1809,27 @@ var PrefixManager = class _PrefixManager {
1805
1809
  baseValidation = _PrefixManager.GS1_COMPANY_PREFIX_VALIDATION;
1806
1810
  } else if (!prefix.startsWith("00000")) {
1807
1811
  if (!allowUPCCompanyPrefix) {
1808
- throw new RangeError(i18n_default.t("Prefix.gs1CompanyPrefixCantStartWith0", {
1809
- ns: gs1NS
1810
- }));
1812
+ throw new RangeError(i18nextGS1.t("Prefix.gs1CompanyPrefixCantStartWith0"));
1811
1813
  }
1812
1814
  baseValidation = _PrefixManager.UPC_COMPANY_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION;
1813
1815
  } else if (!prefix.startsWith("000000")) {
1814
1816
  if (!allowGS18Prefix) {
1815
- throw new RangeError(i18n_default.t("Prefix.gs1CompanyPrefixCantStartWith00000", {
1816
- ns: gs1NS
1817
- }));
1817
+ throw new RangeError(i18nextGS1.t("Prefix.gs1CompanyPrefixCantStartWith00000"));
1818
1818
  }
1819
1819
  baseValidation = _PrefixManager.GS1_8_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION;
1820
1820
  } else {
1821
- throw new RangeError(i18n_default.t("Prefix.gs1CompanyPrefixCantStartWith000000", {
1822
- ns: gs1NS
1823
- }));
1821
+ throw new RangeError(i18nextGS1.t("Prefix.gs1CompanyPrefixCantStartWith000000"));
1824
1822
  }
1825
1823
  break;
1826
1824
  case 1 /* UPCCompanyPrefix */:
1827
1825
  if (prefix.startsWith("0000")) {
1828
- throw new RangeError(i18n_default.t("Prefix.upcCompanyPrefixCantStartWith0000", {
1829
- ns: gs1NS
1830
- }));
1826
+ throw new RangeError(i18nextGS1.t("Prefix.upcCompanyPrefixCantStartWith0000"));
1831
1827
  }
1832
1828
  baseValidation = _PrefixManager.UPC_COMPANY_PREFIX_VALIDATION;
1833
1829
  break;
1834
1830
  case 2 /* GS18Prefix */:
1835
1831
  if (prefix.startsWith("0")) {
1836
- throw new RangeError(i18n_default.t("Prefix.gs18PrefixCantStartWith0", {
1837
- ns: gs1NS
1838
- }));
1832
+ throw new RangeError(i18nextGS1.t("Prefix.gs18PrefixCantStartWith0"));
1839
1833
  }
1840
1834
  baseValidation = _PrefixManager.GS1_8_PREFIX_VALIDATION;
1841
1835
  break;
@@ -1845,9 +1839,9 @@ var PrefixManager = class _PrefixManager {
1845
1839
  positionOffset
1846
1840
  };
1847
1841
  if (!isFromIdentificationKey) {
1848
- import_utility3.NUMERIC_CREATOR.validate(prefix, mergedValidation);
1842
+ import_utility4.NUMERIC_CREATOR.validate(prefix, mergedValidation);
1849
1843
  } else if (!isNumericIdentificationKey) {
1850
- import_utility3.NUMERIC_CREATOR.validate(prefix.substring(0, Math.min(mergedValidation.minimumLength, prefix.length - 1)), mergedValidation);
1844
+ import_utility4.NUMERIC_CREATOR.validate(prefix.substring(0, Math.min(mergedValidation.minimumLength, prefix.length - 1)), mergedValidation);
1851
1845
  }
1852
1846
  }
1853
1847
  /**
@@ -1866,8 +1860,7 @@ var PrefixManager = class _PrefixManager {
1866
1860
  let creator = this._identificationKeyCreatorsMap.get(identificationKeyType);
1867
1861
  if (creator === void 0) {
1868
1862
  if (this.prefixType === 2 /* GS18Prefix */ && identificationKeyType !== "GTIN" /* GTIN */) {
1869
- throw new RangeError(i18n_default.t("Prefix.identificationKeyTypeNotSupportedByGS18Prefix", {
1870
- ns: gs1NS,
1863
+ throw new RangeError(i18nextGS1.t("Prefix.identificationKeyTypeNotSupportedByGS18Prefix", {
1871
1864
  identificationKeyType
1872
1865
  }));
1873
1866
  }
@@ -2040,6 +2033,25 @@ var PrefixManager = class _PrefixManager {
2040
2033
  fiveDigitPriceWeightCheckDigit,
2041
2034
  fourDigitPriceWeightCheckDigit,
2042
2035
  gs1NS,
2036
+ gs1Resources,
2043
2037
  hasValidCheckCharacterPair,
2044
- hasValidCheckDigit
2038
+ hasValidCheckDigit,
2039
+ i18nGS1Init,
2040
+ i18nextGS1
2045
2041
  });
2042
+ /*!
2043
+ * Copyright © 2024-2025 Dolphin Data Development Ltd. and AIDC Toolkit
2044
+ * contributors
2045
+ *
2046
+ * Licensed under the Apache License, Version 2.0 (the "License");
2047
+ * you may not use this file except in compliance with the License.
2048
+ * You may obtain a copy of the License at
2049
+ *
2050
+ * https://www.apache.org/licenses/LICENSE-2.0
2051
+ *
2052
+ * Unless required by applicable law or agreed to in writing, software
2053
+ * distributed under the License is distributed on an "AS IS" BASIS,
2054
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2055
+ * See the License for the specific language governing permissions and
2056
+ * limitations under the License.
2057
+ */