@aidc-toolkit/gs1 0.9.12-beta → 0.9.13-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 +1 -2051
- package/dist/index.js +1 -1978
- package/package.json +8 -11
package/dist/index.js
CHANGED
|
@@ -1,1981 +1,4 @@
|
|
|
1
|
-
// src/locale/i18n.ts
|
|
2
|
-
import { i18nAssertValidResources, i18nCoreInit } from "@aidc-toolkit/core";
|
|
3
|
-
import { i18nUtilityInit, utilityResources } from "@aidc-toolkit/utility";
|
|
4
|
-
import i18next from "i18next";
|
|
5
|
-
|
|
6
|
-
// src/locale/en/locale-strings.ts
|
|
7
|
-
var localeStrings = {
|
|
8
|
-
Check: {
|
|
9
|
-
lengthOfStringForPriceOrWeightMustBeExactly: "Length {{length}} of string for price or weight sum must be exactly {{exactLength}}",
|
|
10
|
-
priceOrWeightComponent: "price or weight",
|
|
11
|
-
lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: "Length {{length}} of string for check character pair must be less than or equal to {{maximumLength}}"
|
|
12
|
-
},
|
|
13
|
-
IdentificationKey: {
|
|
14
|
-
identificationKeyTypeLength: "{{identificationKeyType}} must be {{length}} digits long",
|
|
15
|
-
invalidCheckDigit: "Invalid check digit",
|
|
16
|
-
invalidGTINLength: "GTIN must be 13, 12, 8, or 14 digits long",
|
|
17
|
-
invalidGTIN14Length: "GTIN must be 14 digits long",
|
|
18
|
-
invalidZeroSuppressedGTIN12: "Invalid zero-suppressed GTIN-12",
|
|
19
|
-
invalidZeroSuppressibleGTIN12: "GTIN-12 not zero-suppressible",
|
|
20
|
-
invalidZeroSuppressedGTIN12AsGTIN13: "Invalid zero-suppressed GTIN-12 as GTIN-13",
|
|
21
|
-
invalidZeroSuppressedGTIN12AsGTIN14: "Invalid zero-suppressed GTIN-12 as GTIN-14",
|
|
22
|
-
invalidGTIN13AtRetail: "GTIN-13 at retail consumer trade item level can't start with zero",
|
|
23
|
-
invalidGTINAtRetail: "GTIN not supported at retail consumer trade item level",
|
|
24
|
-
invalidGTINAtOtherThanRetail: "GTIN not supported at other than retail consumer trade item level",
|
|
25
|
-
indicatorDigit: "indicator digit",
|
|
26
|
-
serialComponent: "serial component",
|
|
27
|
-
reference: "reference",
|
|
28
|
-
referenceCantBeAllNumeric: "Reference can't be all-numeric",
|
|
29
|
-
invalidCheckCharacterPair: "Invalid check character pair"
|
|
30
|
-
},
|
|
31
|
-
Prefix: {
|
|
32
|
-
gs1CompanyPrefix: "GS1 Company Prefix",
|
|
33
|
-
upcCompanyPrefix: "U.P.C. Company Prefix",
|
|
34
|
-
gs18Prefix: "GS1-8 Prefix",
|
|
35
|
-
invalidPrefixType: "Invalid prefix type",
|
|
36
|
-
gs1CompanyPrefixCantStartWith0: `GS1 Company Prefix can't start with "0"`,
|
|
37
|
-
gs1CompanyPrefixCantStartWith00000: `GS1 Company Prefix can't start with "00000"`,
|
|
38
|
-
gs1CompanyPrefixCantStartWith000000: `GS1 Company Prefix can't start with "000000"`,
|
|
39
|
-
upcCompanyPrefixCantStartWith0000: `U.P.C. Company Prefix can't start with "0000"`,
|
|
40
|
-
gs18PrefixCantStartWith0: `GS1-8 Prefix can't start with "0"`,
|
|
41
|
-
identificationKeyTypeNotSupportedByGS18Prefix: "{{identificationKeyType}} not supported by GS1-8 Prefix"
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// src/locale/fr/locale-strings.ts
|
|
46
|
-
var localeStrings2 = {
|
|
47
|
-
Check: {
|
|
48
|
-
lengthOfStringForPriceOrWeightMustBeExactly: "La longueur {{longueur}} de la cha\xEEne pour le prix ou la somme du poids doit \xEAtre exactement {{exactLength}}",
|
|
49
|
-
priceOrWeightComponent: "prix ou poids",
|
|
50
|
-
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}}"
|
|
51
|
-
},
|
|
52
|
-
IdentificationKey: {
|
|
53
|
-
identificationKeyTypeLength: "{{identificationKeyType}} doit comporter {{length}} chiffres",
|
|
54
|
-
invalidCheckDigit: "Chiffre de contr\xF4le non valide",
|
|
55
|
-
invalidGTINLength: "Le GTIN doit comporter 13, 12, 8 ou 14 chiffres",
|
|
56
|
-
invalidGTIN14Length: "Le GTIN doit comporter 14 chiffres",
|
|
57
|
-
invalidZeroSuppressedGTIN12: "Code GTIN-12 non valide avec z\xE9ro supprim\xE9",
|
|
58
|
-
invalidZeroSuppressibleGTIN12: "Le GTIN-12 ne peut pas \xEAtre supprim\xE9 par z\xE9ro",
|
|
59
|
-
invalidZeroSuppressedGTIN12AsGTIN13: "GTIN-12 non valide avec z\xE9ro supprim\xE9 en tant que GTIN-13",
|
|
60
|
-
invalidZeroSuppressedGTIN12AsGTIN14: "GTIN-12 non valide avec z\xE9ro supprim\xE9 en tant que GTIN-14",
|
|
61
|
-
invalidGTIN13AtRetail: "Le GTIN-13 au niveau des articles de consommation au d\xE9tail ne peut pas commencer par z\xE9ro",
|
|
62
|
-
invalidGTINAtRetail: "Le GTIN n'est pas pris en charge au niveau des articles de consommation au d\xE9tail",
|
|
63
|
-
invalidGTINAtOtherThanRetail: "Le GTIN n'est pas pris en charge \xE0 d'autres niveaux que ceux des articles de consommation au d\xE9tail",
|
|
64
|
-
indicatorDigit: "chiffre indicateur",
|
|
65
|
-
serialComponent: "composant s\xE9rie",
|
|
66
|
-
reference: "r\xE9f\xE9rence",
|
|
67
|
-
referenceCantBeAllNumeric: "La r\xE9f\xE9rence ne peut pas \xEAtre enti\xE8rement num\xE9rique",
|
|
68
|
-
invalidCheckCharacterPair: "Paire de caract\xE8res de contr\xF4le non valide"
|
|
69
|
-
},
|
|
70
|
-
Prefix: {
|
|
71
|
-
gs1CompanyPrefix: "Pr\xE9fixe de l'entreprise GS1",
|
|
72
|
-
upcCompanyPrefix: "Pr\xE9fixe de l'entreprise U.P.C.",
|
|
73
|
-
gs18Prefix: "Pr\xE9fixe GS1-8",
|
|
74
|
-
invalidPrefixType: "Type de pr\xE9fixe invalide",
|
|
75
|
-
gs1CompanyPrefixCantStartWith0: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "0"`,
|
|
76
|
-
gs1CompanyPrefixCantStartWith00000: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "00000"`,
|
|
77
|
-
gs1CompanyPrefixCantStartWith000000: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "000000"`,
|
|
78
|
-
upcCompanyPrefixCantStartWith0000: `Le pr\xE9fixe de l'entreprise U.P.C. ne peut pas commencer par "0000"`,
|
|
79
|
-
gs18PrefixCantStartWith0: 'Le pr\xE9fixe GS1-8 ne peut pas commencer par "0"',
|
|
80
|
-
identificationKeyTypeNotSupportedByGS18Prefix: "{{identificationKeyType}} non pris en charge par le pr\xE9fixe GS1-8"
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// src/locale/i18n.ts
|
|
85
|
-
var gs1NS = "aidct_gs1";
|
|
86
|
-
i18nAssertValidResources(localeStrings, "fr", localeStrings2);
|
|
87
|
-
var gs1Resources = {
|
|
88
|
-
en: {
|
|
89
|
-
aidct_gs1: localeStrings
|
|
90
|
-
},
|
|
91
|
-
fr: {
|
|
92
|
-
aidct_gs1: localeStrings2
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
var i18nextGS1 = i18next.createInstance();
|
|
96
|
-
async function i18nGS1Init(environment, debug = false) {
|
|
97
|
-
await i18nUtilityInit(environment, debug);
|
|
98
|
-
await i18nCoreInit(i18nextGS1, environment, debug, gs1NS, utilityResources, gs1Resources);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// src/character-set.ts
|
|
102
|
-
import { CharacterSetCreator, Exclusion } from "@aidc-toolkit/utility";
|
|
103
|
-
var AI82_CREATOR = new CharacterSetCreator([
|
|
104
|
-
"!",
|
|
105
|
-
'"',
|
|
106
|
-
"%",
|
|
107
|
-
"&",
|
|
108
|
-
"'",
|
|
109
|
-
"(",
|
|
110
|
-
")",
|
|
111
|
-
"*",
|
|
112
|
-
"+",
|
|
113
|
-
",",
|
|
114
|
-
"-",
|
|
115
|
-
".",
|
|
116
|
-
"/",
|
|
117
|
-
"0",
|
|
118
|
-
"1",
|
|
119
|
-
"2",
|
|
120
|
-
"3",
|
|
121
|
-
"4",
|
|
122
|
-
"5",
|
|
123
|
-
"6",
|
|
124
|
-
"7",
|
|
125
|
-
"8",
|
|
126
|
-
"9",
|
|
127
|
-
":",
|
|
128
|
-
";",
|
|
129
|
-
"<",
|
|
130
|
-
"=",
|
|
131
|
-
">",
|
|
132
|
-
"?",
|
|
133
|
-
"A",
|
|
134
|
-
"B",
|
|
135
|
-
"C",
|
|
136
|
-
"D",
|
|
137
|
-
"E",
|
|
138
|
-
"F",
|
|
139
|
-
"G",
|
|
140
|
-
"H",
|
|
141
|
-
"I",
|
|
142
|
-
"J",
|
|
143
|
-
"K",
|
|
144
|
-
"L",
|
|
145
|
-
"M",
|
|
146
|
-
"N",
|
|
147
|
-
"O",
|
|
148
|
-
"P",
|
|
149
|
-
"Q",
|
|
150
|
-
"R",
|
|
151
|
-
"S",
|
|
152
|
-
"T",
|
|
153
|
-
"U",
|
|
154
|
-
"V",
|
|
155
|
-
"W",
|
|
156
|
-
"X",
|
|
157
|
-
"Y",
|
|
158
|
-
"Z",
|
|
159
|
-
"_",
|
|
160
|
-
"a",
|
|
161
|
-
"b",
|
|
162
|
-
"c",
|
|
163
|
-
"d",
|
|
164
|
-
"e",
|
|
165
|
-
"f",
|
|
166
|
-
"g",
|
|
167
|
-
"h",
|
|
168
|
-
"i",
|
|
169
|
-
"j",
|
|
170
|
-
"k",
|
|
171
|
-
"l",
|
|
172
|
-
"m",
|
|
173
|
-
"n",
|
|
174
|
-
"o",
|
|
175
|
-
"p",
|
|
176
|
-
"q",
|
|
177
|
-
"r",
|
|
178
|
-
"s",
|
|
179
|
-
"t",
|
|
180
|
-
"u",
|
|
181
|
-
"v",
|
|
182
|
-
"w",
|
|
183
|
-
"x",
|
|
184
|
-
"y",
|
|
185
|
-
"z"
|
|
186
|
-
], Exclusion.AllNumeric);
|
|
187
|
-
var AI39_CREATOR = new CharacterSetCreator([
|
|
188
|
-
"#",
|
|
189
|
-
"-",
|
|
190
|
-
"/",
|
|
191
|
-
"0",
|
|
192
|
-
"1",
|
|
193
|
-
"2",
|
|
194
|
-
"3",
|
|
195
|
-
"4",
|
|
196
|
-
"5",
|
|
197
|
-
"6",
|
|
198
|
-
"7",
|
|
199
|
-
"8",
|
|
200
|
-
"9",
|
|
201
|
-
"A",
|
|
202
|
-
"B",
|
|
203
|
-
"C",
|
|
204
|
-
"D",
|
|
205
|
-
"E",
|
|
206
|
-
"F",
|
|
207
|
-
"G",
|
|
208
|
-
"H",
|
|
209
|
-
"I",
|
|
210
|
-
"J",
|
|
211
|
-
"K",
|
|
212
|
-
"L",
|
|
213
|
-
"M",
|
|
214
|
-
"N",
|
|
215
|
-
"O",
|
|
216
|
-
"P",
|
|
217
|
-
"Q",
|
|
218
|
-
"R",
|
|
219
|
-
"S",
|
|
220
|
-
"T",
|
|
221
|
-
"U",
|
|
222
|
-
"V",
|
|
223
|
-
"W",
|
|
224
|
-
"X",
|
|
225
|
-
"Y",
|
|
226
|
-
"Z"
|
|
227
|
-
], Exclusion.AllNumeric);
|
|
228
|
-
|
|
229
|
-
// src/check.ts
|
|
230
|
-
import { NUMERIC_CREATOR, utilityNS } from "@aidc-toolkit/utility";
|
|
231
|
-
var THREE_WEIGHT_RESULTS = [
|
|
232
|
-
0,
|
|
233
|
-
3,
|
|
234
|
-
6,
|
|
235
|
-
9,
|
|
236
|
-
12,
|
|
237
|
-
15,
|
|
238
|
-
18,
|
|
239
|
-
21,
|
|
240
|
-
24,
|
|
241
|
-
27
|
|
242
|
-
];
|
|
243
|
-
var TWO_MINUS_WEIGHT_RESULTS = [
|
|
244
|
-
0,
|
|
245
|
-
2,
|
|
246
|
-
4,
|
|
247
|
-
6,
|
|
248
|
-
8,
|
|
249
|
-
9,
|
|
250
|
-
1,
|
|
251
|
-
3,
|
|
252
|
-
5,
|
|
253
|
-
7
|
|
254
|
-
];
|
|
255
|
-
var FIVE_PLUS_WEIGHT_RESULTS = [
|
|
256
|
-
0,
|
|
257
|
-
5,
|
|
258
|
-
1,
|
|
259
|
-
6,
|
|
260
|
-
2,
|
|
261
|
-
7,
|
|
262
|
-
3,
|
|
263
|
-
8,
|
|
264
|
-
4,
|
|
265
|
-
9
|
|
266
|
-
];
|
|
267
|
-
var FIVE_MINUS_WEIGHT_RESULTS = [
|
|
268
|
-
0,
|
|
269
|
-
5,
|
|
270
|
-
9,
|
|
271
|
-
4,
|
|
272
|
-
8,
|
|
273
|
-
3,
|
|
274
|
-
7,
|
|
275
|
-
2,
|
|
276
|
-
6,
|
|
277
|
-
1
|
|
278
|
-
];
|
|
279
|
-
var INVERSE_FIVE_MINUS_WEIGHT_RESULTS = [
|
|
280
|
-
0,
|
|
281
|
-
9,
|
|
282
|
-
7,
|
|
283
|
-
5,
|
|
284
|
-
3,
|
|
285
|
-
1,
|
|
286
|
-
8,
|
|
287
|
-
6,
|
|
288
|
-
4,
|
|
289
|
-
2
|
|
290
|
-
];
|
|
291
|
-
function checkDigitSum(exchangeWeights, s) {
|
|
292
|
-
let weight3 = (s.length + Number(exchangeWeights)) % 2 === 0;
|
|
293
|
-
return NUMERIC_CREATOR.characterIndexes(s).reduce((accumulator, characterIndex, index) => {
|
|
294
|
-
if (characterIndex === void 0) {
|
|
295
|
-
throw new RangeError(i18nextGS1.t("CharacterSetValidator.invalidCharacterAtPosition", {
|
|
296
|
-
ns: utilityNS,
|
|
297
|
-
c: s.charAt(index),
|
|
298
|
-
position: index + 1
|
|
299
|
-
}));
|
|
300
|
-
}
|
|
301
|
-
weight3 = !weight3;
|
|
302
|
-
return accumulator + (weight3 ? THREE_WEIGHT_RESULTS[characterIndex] : characterIndex);
|
|
303
|
-
}, 0);
|
|
304
|
-
}
|
|
305
|
-
function checkDigit(s) {
|
|
306
|
-
return NUMERIC_CREATOR.character(9 - (checkDigitSum(false, s) + 9) % 10);
|
|
307
|
-
}
|
|
308
|
-
function hasValidCheckDigit(s) {
|
|
309
|
-
return checkDigitSum(true, s) % 10 === 0;
|
|
310
|
-
}
|
|
311
|
-
function priceWeightSum(weightsResults, s) {
|
|
312
|
-
if (s.length !== weightsResults.length) {
|
|
313
|
-
throw new RangeError(i18nextGS1.t("Check.lengthOfStringForPriceOrWeightMustBeExactly", {
|
|
314
|
-
length: s.length,
|
|
315
|
-
exactLength: weightsResults.length
|
|
316
|
-
}));
|
|
317
|
-
}
|
|
318
|
-
const characterIndexes = NUMERIC_CREATOR.characterIndexes(s);
|
|
319
|
-
return characterIndexes.reduce((accumulator, characterIndex, index) => {
|
|
320
|
-
if (characterIndex === void 0) {
|
|
321
|
-
throw new RangeError(i18nextGS1.t("CharacterSetValidator.invalidCharacterAtPositionOfComponent", {
|
|
322
|
-
ns: utilityNS,
|
|
323
|
-
c: s.charAt(index),
|
|
324
|
-
position: index + 1,
|
|
325
|
-
component: i18nextGS1.t("Check.priceOrWeightComponent")
|
|
326
|
-
}));
|
|
327
|
-
}
|
|
328
|
-
return accumulator + weightsResults[index][characterIndex];
|
|
329
|
-
}, 0);
|
|
330
|
-
}
|
|
331
|
-
function fourDigitPriceWeightCheckDigit(s) {
|
|
332
|
-
return NUMERIC_CREATOR.character(priceWeightSum([TWO_MINUS_WEIGHT_RESULTS, TWO_MINUS_WEIGHT_RESULTS, THREE_WEIGHT_RESULTS, FIVE_MINUS_WEIGHT_RESULTS], s) * 3 % 10);
|
|
333
|
-
}
|
|
334
|
-
function fiveDigitPriceWeightCheckDigit(s) {
|
|
335
|
-
return 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]);
|
|
336
|
-
}
|
|
337
|
-
var CHECK_CHARACTER_WEIGHTS = [
|
|
338
|
-
107,
|
|
339
|
-
103,
|
|
340
|
-
101,
|
|
341
|
-
97,
|
|
342
|
-
89,
|
|
343
|
-
83,
|
|
344
|
-
79,
|
|
345
|
-
73,
|
|
346
|
-
71,
|
|
347
|
-
67,
|
|
348
|
-
61,
|
|
349
|
-
59,
|
|
350
|
-
53,
|
|
351
|
-
47,
|
|
352
|
-
43,
|
|
353
|
-
41,
|
|
354
|
-
37,
|
|
355
|
-
31,
|
|
356
|
-
29,
|
|
357
|
-
23,
|
|
358
|
-
19,
|
|
359
|
-
17,
|
|
360
|
-
13,
|
|
361
|
-
11,
|
|
362
|
-
7,
|
|
363
|
-
5,
|
|
364
|
-
3,
|
|
365
|
-
2
|
|
366
|
-
];
|
|
367
|
-
var CHECK_CHARACTERS = [
|
|
368
|
-
"2",
|
|
369
|
-
"3",
|
|
370
|
-
"4",
|
|
371
|
-
"5",
|
|
372
|
-
"6",
|
|
373
|
-
"7",
|
|
374
|
-
"8",
|
|
375
|
-
"9",
|
|
376
|
-
"A",
|
|
377
|
-
"B",
|
|
378
|
-
"C",
|
|
379
|
-
"D",
|
|
380
|
-
"E",
|
|
381
|
-
"F",
|
|
382
|
-
"G",
|
|
383
|
-
"H",
|
|
384
|
-
"J",
|
|
385
|
-
"K",
|
|
386
|
-
"L",
|
|
387
|
-
"M",
|
|
388
|
-
"N",
|
|
389
|
-
"P",
|
|
390
|
-
"Q",
|
|
391
|
-
"R",
|
|
392
|
-
"S",
|
|
393
|
-
"T",
|
|
394
|
-
"U",
|
|
395
|
-
"V",
|
|
396
|
-
"W",
|
|
397
|
-
"X",
|
|
398
|
-
"Y",
|
|
399
|
-
"Z"
|
|
400
|
-
];
|
|
401
|
-
function checkCharacterPair(s) {
|
|
402
|
-
const weightIndexStart = CHECK_CHARACTER_WEIGHTS.length - s.length;
|
|
403
|
-
if (weightIndexStart < 0) {
|
|
404
|
-
throw new RangeError(i18nextGS1.t("Check.lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo", {
|
|
405
|
-
length: s.length,
|
|
406
|
-
maximumLength: CHECK_CHARACTER_WEIGHTS.length
|
|
407
|
-
}));
|
|
408
|
-
}
|
|
409
|
-
const checkCharacterPairSum = AI82_CREATOR.characterIndexes(s).reduce((accumulator, characterIndex, index) => {
|
|
410
|
-
if (characterIndex === void 0) {
|
|
411
|
-
throw new RangeError(i18nextGS1.t("CharacterSetValidator.invalidCharacterAtPosition", {
|
|
412
|
-
ns: utilityNS,
|
|
413
|
-
c: s.charAt(index),
|
|
414
|
-
position: index + 1
|
|
415
|
-
}));
|
|
416
|
-
}
|
|
417
|
-
return accumulator + characterIndex * CHECK_CHARACTER_WEIGHTS[weightIndexStart + index];
|
|
418
|
-
}, 0) % 1021;
|
|
419
|
-
const checkCharacterPairSumMod32 = checkCharacterPairSum % 32;
|
|
420
|
-
return CHECK_CHARACTERS[(checkCharacterPairSum - checkCharacterPairSumMod32) / 32] + CHECK_CHARACTERS[checkCharacterPairSumMod32];
|
|
421
|
-
}
|
|
422
|
-
function hasValidCheckCharacterPair(s) {
|
|
423
|
-
const checkCharacterPairIndex = s.length - 2;
|
|
424
|
-
return checkCharacterPair(s.substring(0, checkCharacterPairIndex)) === s.substring(checkCharacterPairIndex);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
// src/idkey.ts
|
|
428
|
-
import {
|
|
429
|
-
CharacterSetCreator as CharacterSetCreator2,
|
|
430
|
-
Exclusion as Exclusion2,
|
|
431
|
-
NUMERIC_CREATOR as NUMERIC_CREATOR2,
|
|
432
|
-
RegExpValidator,
|
|
433
|
-
transformIterable
|
|
434
|
-
} from "@aidc-toolkit/utility";
|
|
435
|
-
import { Mixin } from "ts-mixer";
|
|
436
|
-
var IdentificationKeyType = /* @__PURE__ */ ((IdentificationKeyType2) => {
|
|
437
|
-
IdentificationKeyType2["GTIN"] = "GTIN";
|
|
438
|
-
IdentificationKeyType2["GLN"] = "GLN";
|
|
439
|
-
IdentificationKeyType2["SSCC"] = "SSCC";
|
|
440
|
-
IdentificationKeyType2["GRAI"] = "GRAI";
|
|
441
|
-
IdentificationKeyType2["GIAI"] = "GIAI";
|
|
442
|
-
IdentificationKeyType2["GSRN"] = "GSRN";
|
|
443
|
-
IdentificationKeyType2["GDTI"] = "GDTI";
|
|
444
|
-
IdentificationKeyType2["GINC"] = "GINC";
|
|
445
|
-
IdentificationKeyType2["GSIN"] = "GSIN";
|
|
446
|
-
IdentificationKeyType2["GCN"] = "GCN";
|
|
447
|
-
IdentificationKeyType2["CPID"] = "CPID";
|
|
448
|
-
IdentificationKeyType2["GMN"] = "GMN";
|
|
449
|
-
return IdentificationKeyType2;
|
|
450
|
-
})(IdentificationKeyType || {});
|
|
451
|
-
var PrefixType = /* @__PURE__ */ ((PrefixType2) => {
|
|
452
|
-
PrefixType2[PrefixType2["GS1CompanyPrefix"] = 0] = "GS1CompanyPrefix";
|
|
453
|
-
PrefixType2[PrefixType2["UPCCompanyPrefix"] = 1] = "UPCCompanyPrefix";
|
|
454
|
-
PrefixType2[PrefixType2["GS18Prefix"] = 2] = "GS18Prefix";
|
|
455
|
-
return PrefixType2;
|
|
456
|
-
})(PrefixType || {});
|
|
457
|
-
var ContentCharacterSet = /* @__PURE__ */ ((ContentCharacterSet2) => {
|
|
458
|
-
ContentCharacterSet2[ContentCharacterSet2["Numeric"] = 0] = "Numeric";
|
|
459
|
-
ContentCharacterSet2[ContentCharacterSet2["AI82"] = 1] = "AI82";
|
|
460
|
-
ContentCharacterSet2[ContentCharacterSet2["AI39"] = 2] = "AI39";
|
|
461
|
-
return ContentCharacterSet2;
|
|
462
|
-
})(ContentCharacterSet || {});
|
|
463
|
-
var AbstractIdentificationKeyValidator = class _AbstractIdentificationKeyValidator {
|
|
464
|
-
static CHARACTER_SET_CREATORS = [
|
|
465
|
-
NUMERIC_CREATOR2,
|
|
466
|
-
AI82_CREATOR,
|
|
467
|
-
AI39_CREATOR
|
|
468
|
-
];
|
|
469
|
-
/**
|
|
470
|
-
* Identification key type.
|
|
471
|
-
*/
|
|
472
|
-
_identificationKeyType;
|
|
473
|
-
/**
|
|
474
|
-
* Prefix type.
|
|
475
|
-
*/
|
|
476
|
-
_prefixType;
|
|
477
|
-
/**
|
|
478
|
-
* Length.
|
|
479
|
-
*/
|
|
480
|
-
_length;
|
|
481
|
-
/**
|
|
482
|
-
* Reference character set.
|
|
483
|
-
*/
|
|
484
|
-
_referenceCharacterSet;
|
|
485
|
-
/**
|
|
486
|
-
* Reference creator.
|
|
487
|
-
*/
|
|
488
|
-
_referenceCreator;
|
|
489
|
-
/**
|
|
490
|
-
* Get the character set creator for a character set.
|
|
491
|
-
*
|
|
492
|
-
* @param characterSet
|
|
493
|
-
* Character set.
|
|
494
|
-
*
|
|
495
|
-
* @returns
|
|
496
|
-
* Character set creator.
|
|
497
|
-
*/
|
|
498
|
-
static creatorFor(characterSet) {
|
|
499
|
-
return _AbstractIdentificationKeyValidator.CHARACTER_SET_CREATORS[characterSet];
|
|
500
|
-
}
|
|
501
|
-
/**
|
|
502
|
-
* Constructor.
|
|
503
|
-
*
|
|
504
|
-
* @param identificationKeyType
|
|
505
|
-
* Identification key type.
|
|
506
|
-
*
|
|
507
|
-
* @param prefixType
|
|
508
|
-
* Prefix type.
|
|
509
|
-
*
|
|
510
|
-
* @param length
|
|
511
|
-
* Length.
|
|
512
|
-
*
|
|
513
|
-
* @param referenceCharacterSet
|
|
514
|
-
* Reference character set.
|
|
515
|
-
*/
|
|
516
|
-
constructor(identificationKeyType, prefixType, length, referenceCharacterSet) {
|
|
517
|
-
this._identificationKeyType = identificationKeyType;
|
|
518
|
-
this._prefixType = prefixType;
|
|
519
|
-
this._length = length;
|
|
520
|
-
this._referenceCharacterSet = referenceCharacterSet;
|
|
521
|
-
this._referenceCreator = _AbstractIdentificationKeyValidator.creatorFor(referenceCharacterSet);
|
|
522
|
-
}
|
|
523
|
-
/**
|
|
524
|
-
* @inheritDoc
|
|
525
|
-
*/
|
|
526
|
-
get identificationKeyType() {
|
|
527
|
-
return this._identificationKeyType;
|
|
528
|
-
}
|
|
529
|
-
/**
|
|
530
|
-
* @inheritDoc
|
|
531
|
-
*/
|
|
532
|
-
get prefixType() {
|
|
533
|
-
return this._prefixType;
|
|
534
|
-
}
|
|
535
|
-
/**
|
|
536
|
-
* @inheritDoc
|
|
537
|
-
*/
|
|
538
|
-
get length() {
|
|
539
|
-
return this._length;
|
|
540
|
-
}
|
|
541
|
-
/**
|
|
542
|
-
* @inheritDoc
|
|
543
|
-
*/
|
|
544
|
-
get referenceCharacterSet() {
|
|
545
|
-
return this._referenceCharacterSet;
|
|
546
|
-
}
|
|
547
|
-
/**
|
|
548
|
-
* @inheritDoc
|
|
549
|
-
*/
|
|
550
|
-
get referenceCreator() {
|
|
551
|
-
return this._referenceCreator;
|
|
552
|
-
}
|
|
553
|
-
/**
|
|
554
|
-
* Pad an identification key on the left with zero-value character for validation purposes. This is done to align an
|
|
555
|
-
* identification key with a position offset for any error message that may be thrown by the reference validator.
|
|
556
|
-
*
|
|
557
|
-
* @param identificationKey
|
|
558
|
-
* Identification key.
|
|
559
|
-
*
|
|
560
|
-
* @param validation
|
|
561
|
-
* Identification key validation parameters.
|
|
562
|
-
*
|
|
563
|
-
* @returns
|
|
564
|
-
* Padded identification key.
|
|
565
|
-
*/
|
|
566
|
-
padIdentificationKey(identificationKey, validation) {
|
|
567
|
-
return validation?.positionOffset === void 0 ? identificationKey : this.referenceCreator.character(0).repeat(validation.positionOffset).concat(identificationKey);
|
|
568
|
-
}
|
|
569
|
-
/**
|
|
570
|
-
* Validate the prefix within an identification key.
|
|
571
|
-
*
|
|
572
|
-
* @param partialIdentificationKey
|
|
573
|
-
* Partial identification key.
|
|
574
|
-
*
|
|
575
|
-
* @param positionOffset
|
|
576
|
-
* Position offset within a larger string.
|
|
577
|
-
*/
|
|
578
|
-
validatePrefix(partialIdentificationKey, positionOffset) {
|
|
579
|
-
PrefixManager.validatePrefix(this.prefixType, true, false, partialIdentificationKey, true, this.referenceCharacterSet === 0 /* Numeric */, positionOffset);
|
|
580
|
-
}
|
|
581
|
-
};
|
|
582
|
-
var LeaderType = /* @__PURE__ */ ((LeaderType2) => {
|
|
583
|
-
LeaderType2[LeaderType2["None"] = 0] = "None";
|
|
584
|
-
LeaderType2[LeaderType2["IndicatorDigit"] = 1] = "IndicatorDigit";
|
|
585
|
-
LeaderType2[LeaderType2["ExtensionDigit"] = 2] = "ExtensionDigit";
|
|
586
|
-
return LeaderType2;
|
|
587
|
-
})(LeaderType || {});
|
|
588
|
-
var AbstractNumericIdentificationKeyValidator = class extends AbstractIdentificationKeyValidator {
|
|
589
|
-
/**
|
|
590
|
-
* Leader type.
|
|
591
|
-
*/
|
|
592
|
-
_leaderType;
|
|
593
|
-
/**
|
|
594
|
-
* Prefix position, determined by the leader type.
|
|
595
|
-
*/
|
|
596
|
-
_prefixPosition;
|
|
597
|
-
/**
|
|
598
|
-
* Constructor.
|
|
599
|
-
*
|
|
600
|
-
* @param identificationKeyType
|
|
601
|
-
* Identification key type.
|
|
602
|
-
*
|
|
603
|
-
* @param prefixType
|
|
604
|
-
* Prefix type.
|
|
605
|
-
*
|
|
606
|
-
* @param length
|
|
607
|
-
* Length.
|
|
608
|
-
*
|
|
609
|
-
* @param leaderType
|
|
610
|
-
* Leader type.
|
|
611
|
-
*/
|
|
612
|
-
constructor(identificationKeyType, prefixType, length, leaderType) {
|
|
613
|
-
super(identificationKeyType, prefixType, length, 0 /* Numeric */);
|
|
614
|
-
this._leaderType = leaderType;
|
|
615
|
-
this._prefixPosition = Number(this.leaderType === 2 /* ExtensionDigit */);
|
|
616
|
-
}
|
|
617
|
-
/**
|
|
618
|
-
* @inheritDoc
|
|
619
|
-
*/
|
|
620
|
-
get leaderType() {
|
|
621
|
-
return this._leaderType;
|
|
622
|
-
}
|
|
623
|
-
/**
|
|
624
|
-
* @inheritDoc
|
|
625
|
-
*/
|
|
626
|
-
validate(identificationKey, validation) {
|
|
627
|
-
if (this._prefixPosition === 0) {
|
|
628
|
-
super.validatePrefix(identificationKey, validation?.positionOffset);
|
|
629
|
-
} else {
|
|
630
|
-
super.validatePrefix(identificationKey.substring(this._prefixPosition), validation?.positionOffset === void 0 ? this._prefixPosition : validation.positionOffset + this._prefixPosition);
|
|
631
|
-
}
|
|
632
|
-
if (identificationKey.length !== this.length) {
|
|
633
|
-
throw new RangeError(i18nextGS1.t("IdentificationKey.identificationKeyTypeLength", {
|
|
634
|
-
identificationKeyType: this.identificationKeyType,
|
|
635
|
-
length: this.length
|
|
636
|
-
}));
|
|
637
|
-
}
|
|
638
|
-
if (!hasValidCheckDigit(this.padIdentificationKey(identificationKey, validation))) {
|
|
639
|
-
throw new RangeError(i18nextGS1.t("IdentificationKey.invalidCheckDigit"));
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
};
|
|
643
|
-
var GTINType = /* @__PURE__ */ ((GTINType2) => {
|
|
644
|
-
GTINType2[GTINType2["GTIN13"] = 13] = "GTIN13";
|
|
645
|
-
GTINType2[GTINType2["GTIN12"] = 12] = "GTIN12";
|
|
646
|
-
GTINType2[GTINType2["GTIN8"] = 8] = "GTIN8";
|
|
647
|
-
GTINType2[GTINType2["GTIN14"] = 14] = "GTIN14";
|
|
648
|
-
return GTINType2;
|
|
649
|
-
})(GTINType || {});
|
|
650
|
-
var GTINLevel = /* @__PURE__ */ ((GTINLevel2) => {
|
|
651
|
-
GTINLevel2[GTINLevel2["Any"] = 0] = "Any";
|
|
652
|
-
GTINLevel2[GTINLevel2["RetailConsumer"] = 1] = "RetailConsumer";
|
|
653
|
-
GTINLevel2[GTINLevel2["OtherThanRetailConsumer"] = 2] = "OtherThanRetailConsumer";
|
|
654
|
-
return GTINLevel2;
|
|
655
|
-
})(GTINLevel || {});
|
|
656
|
-
var GTINValidator = class _GTINValidator extends AbstractNumericIdentificationKeyValidator {
|
|
657
|
-
/**
|
|
658
|
-
* Validation parameters for optional indicator digit.
|
|
659
|
-
*/
|
|
660
|
-
static OPTIONAL_INDICATOR_DIGIT_VALIDATION = {
|
|
661
|
-
minimumLength: 0,
|
|
662
|
-
maximumLength: 1,
|
|
663
|
-
component: () => i18nextGS1.t("IdentificationKey.indicatorDigit")
|
|
664
|
-
};
|
|
665
|
-
/**
|
|
666
|
-
* Validation parameters for zero-suppressed GTIN-12.
|
|
667
|
-
*/
|
|
668
|
-
static ZERO_SUPPRESSED_GTIN12_VALIDATION = {
|
|
669
|
-
minimumLength: 8,
|
|
670
|
-
maximumLength: 8
|
|
671
|
-
};
|
|
672
|
-
/**
|
|
673
|
-
* Constructor.
|
|
674
|
-
*
|
|
675
|
-
* @param gtinType
|
|
676
|
-
* GTIN type.
|
|
677
|
-
*/
|
|
678
|
-
constructor(gtinType) {
|
|
679
|
-
let prefixType;
|
|
680
|
-
switch (gtinType) {
|
|
681
|
-
case 13 /* GTIN13 */:
|
|
682
|
-
prefixType = 0 /* GS1CompanyPrefix */;
|
|
683
|
-
break;
|
|
684
|
-
case 12 /* GTIN12 */:
|
|
685
|
-
prefixType = 1 /* UPCCompanyPrefix */;
|
|
686
|
-
break;
|
|
687
|
-
case 8 /* GTIN8 */:
|
|
688
|
-
prefixType = 2 /* GS18Prefix */;
|
|
689
|
-
break;
|
|
690
|
-
default:
|
|
691
|
-
throw new Error("Not supported");
|
|
692
|
-
}
|
|
693
|
-
super("GTIN" /* GTIN */, prefixType, gtinType, 1 /* IndicatorDigit */);
|
|
694
|
-
}
|
|
695
|
-
/**
|
|
696
|
-
* @inheritDoc
|
|
697
|
-
*/
|
|
698
|
-
get gtinType() {
|
|
699
|
-
return this.length;
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* @inheritDoc
|
|
703
|
-
*/
|
|
704
|
-
validatePrefix(partialIdentificationKey, positionOffset) {
|
|
705
|
-
PrefixManager.validatePrefix(this.prefixType, false, false, partialIdentificationKey, true, true, positionOffset);
|
|
706
|
-
}
|
|
707
|
-
/**
|
|
708
|
-
* Zero suppress a GTIN-12.
|
|
709
|
-
*
|
|
710
|
-
* @param gtin12
|
|
711
|
-
* GTIN-12.
|
|
712
|
-
*
|
|
713
|
-
* @returns
|
|
714
|
-
* Zero-suppressed GTIN-12.
|
|
715
|
-
*/
|
|
716
|
-
static zeroSuppress(gtin12) {
|
|
717
|
-
GTIN12_VALIDATOR.validate(gtin12);
|
|
718
|
-
const d = Array.from(gtin12);
|
|
719
|
-
let zeroSuppressedGTIN12;
|
|
720
|
-
if (d[0] === "0" && d[6] === "0" && d[7] === "0") {
|
|
721
|
-
if (d[10] >= "5" && d[8] === "0" && d[9] === "0" && d[5] !== "0") {
|
|
722
|
-
zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[5]}${d[10]}${d[11]}`;
|
|
723
|
-
} else if (d[5] === "0" && d[8] === "0" && d[9] === "0" && d[4] !== "0") {
|
|
724
|
-
zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[10]}4${d[11]}`;
|
|
725
|
-
} else if (d[3] <= "2" && d[4] === "0" && d[5] === "0") {
|
|
726
|
-
zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[8]}${d[9]}${d[10]}${d[3]}${d[11]}`;
|
|
727
|
-
} else if (d[3] >= "3" && d[4] === "0" && d[5] === "0" && d[8] === "0") {
|
|
728
|
-
zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[9]}${d[10]}3${d[11]}`;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
if (zeroSuppressedGTIN12 === void 0) {
|
|
732
|
-
throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressibleGTIN12"));
|
|
733
|
-
}
|
|
734
|
-
return zeroSuppressedGTIN12;
|
|
735
|
-
}
|
|
736
|
-
/**
|
|
737
|
-
* Zero expand a zero-suppressed GTIN-12.
|
|
738
|
-
*
|
|
739
|
-
* @param zeroSuppressedGTIN12
|
|
740
|
-
* Zero-suppressed GTIN-12.
|
|
741
|
-
*
|
|
742
|
-
* @returns
|
|
743
|
-
* GTIN-12.
|
|
744
|
-
*/
|
|
745
|
-
static zeroExpand(zeroSuppressedGTIN12) {
|
|
746
|
-
NUMERIC_CREATOR2.validate(zeroSuppressedGTIN12, _GTINValidator.ZERO_SUPPRESSED_GTIN12_VALIDATION);
|
|
747
|
-
const d = Array.from(zeroSuppressedGTIN12);
|
|
748
|
-
let gtin12;
|
|
749
|
-
if (d[0] === "0") {
|
|
750
|
-
if (d[6] >= "5" && d[5] !== "0") {
|
|
751
|
-
gtin12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[5]}0000${d[6]}${d[7]}`;
|
|
752
|
-
} else if (d[6] === "4" && d[4] !== "0") {
|
|
753
|
-
gtin12 = `0${d[1]}${d[2]}${d[3]}${d[4]}00000${d[5]}${d[7]}`;
|
|
754
|
-
} else if (d[6] <= "2") {
|
|
755
|
-
gtin12 = `0${d[1]}${d[2]}${d[6]}0000${d[3]}${d[4]}${d[5]}${d[7]}`;
|
|
756
|
-
} else if (d[6] === "3" && d[3] >= "3") {
|
|
757
|
-
gtin12 = `0${d[1]}${d[2]}${d[3]}00000${d[4]}${d[5]}${d[7]}`;
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
if (gtin12 === void 0) {
|
|
761
|
-
throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressedGTIN12"));
|
|
762
|
-
}
|
|
763
|
-
GTIN12_VALIDATOR.validate(gtin12);
|
|
764
|
-
return gtin12;
|
|
765
|
-
}
|
|
766
|
-
/**
|
|
767
|
-
* Convert a GTIN of any length to a GTIN-14 with an optional indicator digit.
|
|
768
|
-
*
|
|
769
|
-
* @param indicatorDigit
|
|
770
|
-
* Indicator digit. If blank, assumes "0" if the GTIN is not already a GTIN-14.
|
|
771
|
-
*
|
|
772
|
-
* @param gtin
|
|
773
|
-
* GTIN.
|
|
774
|
-
*
|
|
775
|
-
* @returns
|
|
776
|
-
* GTIN-14.
|
|
777
|
-
*/
|
|
778
|
-
static convertToGTIN14(indicatorDigit, gtin) {
|
|
779
|
-
GTINCreator.validateAny(gtin);
|
|
780
|
-
NUMERIC_CREATOR2.validate(indicatorDigit, _GTINValidator.OPTIONAL_INDICATOR_DIGIT_VALIDATION);
|
|
781
|
-
const gtinLength = gtin.length;
|
|
782
|
-
let gtin14 = "0".repeat(14 /* GTIN14 */ - gtinLength) + gtin;
|
|
783
|
-
if (indicatorDigit.length !== 0 && indicatorDigit !== gtin14.charAt(0)) {
|
|
784
|
-
const partialGTIN14 = indicatorDigit + gtin14.substring(1, 14 /* GTIN14 */ - 1);
|
|
785
|
-
gtin14 = partialGTIN14 + checkDigit(partialGTIN14);
|
|
786
|
-
}
|
|
787
|
-
return gtin14;
|
|
788
|
-
}
|
|
789
|
-
/**
|
|
790
|
-
* Normalize a GTIN of any length.
|
|
791
|
-
* - A GTIN-14 that starts with six zeros or a GTIN-13 that starts with five zeros is normalized to GTIN-8.
|
|
792
|
-
* - A GTIN-14 that starts with two zeros or a GTIN-13 that starts with one zero is normalized to GTIN-12.
|
|
793
|
-
* - A GTIN-14 that starts with one zero is normalized to GTIN-13.
|
|
794
|
-
* - Otherwise, the GTIN is unchanged.
|
|
795
|
-
*
|
|
796
|
-
* @param gtin
|
|
797
|
-
* GTIN.
|
|
798
|
-
*
|
|
799
|
-
* @returns
|
|
800
|
-
* Normalized GTIN.
|
|
801
|
-
*/
|
|
802
|
-
static normalize(gtin) {
|
|
803
|
-
const gtinLength = gtin.length;
|
|
804
|
-
let normalizedGTIN;
|
|
805
|
-
switch (gtinLength) {
|
|
806
|
-
case 13 /* GTIN13 */:
|
|
807
|
-
if (!gtin.startsWith("0")) {
|
|
808
|
-
normalizedGTIN = gtin;
|
|
809
|
-
} else if (!gtin.startsWith("00000")) {
|
|
810
|
-
normalizedGTIN = gtin.substring(1);
|
|
811
|
-
} else if (!gtin.startsWith("000000")) {
|
|
812
|
-
normalizedGTIN = gtin.substring(5);
|
|
813
|
-
} else {
|
|
814
|
-
throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN13"));
|
|
815
|
-
}
|
|
816
|
-
break;
|
|
817
|
-
case 12 /* GTIN12 */:
|
|
818
|
-
normalizedGTIN = gtin;
|
|
819
|
-
break;
|
|
820
|
-
case 8 /* GTIN8 */:
|
|
821
|
-
if (!gtin.startsWith("0")) {
|
|
822
|
-
normalizedGTIN = gtin;
|
|
823
|
-
} else {
|
|
824
|
-
normalizedGTIN = _GTINValidator.zeroExpand(gtin);
|
|
825
|
-
}
|
|
826
|
-
break;
|
|
827
|
-
case 14 /* GTIN14 */:
|
|
828
|
-
if (!gtin.startsWith("0")) {
|
|
829
|
-
normalizedGTIN = gtin;
|
|
830
|
-
} else if (!gtin.startsWith("00")) {
|
|
831
|
-
normalizedGTIN = gtin.substring(1);
|
|
832
|
-
} else if (!gtin.startsWith("000000")) {
|
|
833
|
-
normalizedGTIN = gtin.substring(2);
|
|
834
|
-
} else if (!gtin.startsWith("0000000")) {
|
|
835
|
-
normalizedGTIN = gtin.substring(6);
|
|
836
|
-
} else {
|
|
837
|
-
throw new RangeError(i18nextGS1.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN14"));
|
|
838
|
-
}
|
|
839
|
-
break;
|
|
840
|
-
default:
|
|
841
|
-
throw new RangeError(i18nextGS1.t("IdentificationKey.invalidGTINLength"));
|
|
842
|
-
}
|
|
843
|
-
GTINCreator.validateAny(normalizedGTIN);
|
|
844
|
-
return normalizedGTIN;
|
|
845
|
-
}
|
|
846
|
-
/**
|
|
847
|
-
* Validate any GTIN, optionally against a level.
|
|
848
|
-
*
|
|
849
|
-
* @param gtin
|
|
850
|
-
* GTIN.
|
|
851
|
-
*
|
|
852
|
-
* @param gtinLevel
|
|
853
|
-
* Level at which GTIN is to be validated.
|
|
854
|
-
*/
|
|
855
|
-
static validateAny(gtin, gtinLevel = 0 /* Any */) {
|
|
856
|
-
let lengthValidatedGTIN = gtin;
|
|
857
|
-
let gtinLevelRestriction;
|
|
858
|
-
switch (gtin.length) {
|
|
859
|
-
case 13 /* GTIN13 */:
|
|
860
|
-
if (gtin.startsWith("0")) {
|
|
861
|
-
throw new RangeError(i18nextGS1.t("IdentificationKey.invalidGTIN13AtRetail"));
|
|
862
|
-
}
|
|
863
|
-
PrefixManager.validatePrefix(0 /* GS1CompanyPrefix */, false, false, gtin, true, true);
|
|
864
|
-
gtinLevelRestriction = 0 /* Any */;
|
|
865
|
-
break;
|
|
866
|
-
case 12 /* GTIN12 */:
|
|
867
|
-
PrefixManager.validatePrefix(1 /* UPCCompanyPrefix */, false, false, gtin, true, true);
|
|
868
|
-
gtinLevelRestriction = 0 /* Any */;
|
|
869
|
-
break;
|
|
870
|
-
case 8 /* GTIN8 */:
|
|
871
|
-
if (!gtin.startsWith("0")) {
|
|
872
|
-
PrefixManager.validatePrefix(2 /* GS18Prefix */, false, false, gtin, true, true);
|
|
873
|
-
} else {
|
|
874
|
-
lengthValidatedGTIN = _GTINValidator.zeroExpand(gtin);
|
|
875
|
-
}
|
|
876
|
-
gtinLevelRestriction = 1 /* RetailConsumer */;
|
|
877
|
-
break;
|
|
878
|
-
case 14 /* GTIN14 */:
|
|
879
|
-
PrefixManager.validatePrefix(0 /* GS1CompanyPrefix */, true, true, gtin.substring(1), true, true);
|
|
880
|
-
gtinLevelRestriction = 2 /* OtherThanRetailConsumer */;
|
|
881
|
-
break;
|
|
882
|
-
default:
|
|
883
|
-
throw new RangeError(i18nextGS1.t("IdentificationKey.invalidGTINLength"));
|
|
884
|
-
}
|
|
885
|
-
if (!hasValidCheckDigit(lengthValidatedGTIN)) {
|
|
886
|
-
throw new RangeError(i18nextGS1.t("IdentificationKey.invalidCheckDigit"));
|
|
887
|
-
}
|
|
888
|
-
if (gtinLevel !== 0 /* Any */ && gtinLevelRestriction !== 0 /* Any */ && gtinLevelRestriction !== gtinLevel) {
|
|
889
|
-
throw new RangeError(i18nextGS1.t(gtinLevel === 1 /* RetailConsumer */ ? "IdentificationKey.invalidGTINAtRetail" : "IdentificationKey.invalidGTINAtOtherThanRetail"));
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
/**
|
|
893
|
-
* Validate a GTIN-14.
|
|
894
|
-
*
|
|
895
|
-
* @param gtin14
|
|
896
|
-
* GTIN-14.
|
|
897
|
-
*/
|
|
898
|
-
static validateGTIN14(gtin14) {
|
|
899
|
-
if (gtin14.length !== 14 /* GTIN14 */) {
|
|
900
|
-
throw new RangeError(i18nextGS1.t("IdentificationKey.invalidGTIN14Length"));
|
|
901
|
-
}
|
|
902
|
-
GTINCreator.validateAny(gtin14);
|
|
903
|
-
}
|
|
904
|
-
};
|
|
905
|
-
var NonGTINNumericIdentificationKeyValidator = class extends AbstractNumericIdentificationKeyValidator {
|
|
906
|
-
/**
|
|
907
|
-
* Constructor.
|
|
908
|
-
*
|
|
909
|
-
* @param identificationKeyType
|
|
910
|
-
* Identification key type.
|
|
911
|
-
*
|
|
912
|
-
* @param length
|
|
913
|
-
* Length.
|
|
914
|
-
*
|
|
915
|
-
* @param leaderType
|
|
916
|
-
* Leader type.
|
|
917
|
-
*/
|
|
918
|
-
constructor(identificationKeyType, length, leaderType = 0 /* None */) {
|
|
919
|
-
super(identificationKeyType, 0 /* GS1CompanyPrefix */, length, leaderType);
|
|
920
|
-
}
|
|
921
|
-
};
|
|
922
|
-
var SerializableNumericIdentificationKeyValidator = class _SerializableNumericIdentificationKeyValidator extends NonGTINNumericIdentificationKeyValidator {
|
|
923
|
-
/**
|
|
924
|
-
* Serial component length.
|
|
925
|
-
*/
|
|
926
|
-
_serialComponentLength;
|
|
927
|
-
/**
|
|
928
|
-
* Serial component character set.
|
|
929
|
-
*/
|
|
930
|
-
_serialComponentCharacterSet;
|
|
931
|
-
/**
|
|
932
|
-
* Serial component validation parameters.
|
|
933
|
-
*/
|
|
934
|
-
_serialComponentValidation;
|
|
935
|
-
/**
|
|
936
|
-
* Serial component creator.
|
|
937
|
-
*/
|
|
938
|
-
_serialComponentCreator;
|
|
939
|
-
/**
|
|
940
|
-
* Constructor.
|
|
941
|
-
*
|
|
942
|
-
* @param identificationKeyType
|
|
943
|
-
* Identification key type.
|
|
944
|
-
*
|
|
945
|
-
* @param length
|
|
946
|
-
* Length.
|
|
947
|
-
*
|
|
948
|
-
* @param serialComponentLength
|
|
949
|
-
* Serial component length.
|
|
950
|
-
*
|
|
951
|
-
* @param serialComponentCharacterSet
|
|
952
|
-
* Serial component character set.
|
|
953
|
-
*/
|
|
954
|
-
constructor(identificationKeyType, length, serialComponentLength, serialComponentCharacterSet) {
|
|
955
|
-
super(identificationKeyType, length, 0 /* None */);
|
|
956
|
-
this._serialComponentLength = serialComponentLength;
|
|
957
|
-
this._serialComponentCharacterSet = serialComponentCharacterSet;
|
|
958
|
-
this._serialComponentValidation = {
|
|
959
|
-
minimumLength: 1,
|
|
960
|
-
maximumLength: serialComponentLength,
|
|
961
|
-
component: () => i18nextGS1.t("IdentificationKey.serialComponent")
|
|
962
|
-
};
|
|
963
|
-
this._serialComponentCreator = _SerializableNumericIdentificationKeyValidator.creatorFor(serialComponentCharacterSet);
|
|
964
|
-
}
|
|
965
|
-
/**
|
|
966
|
-
* Get the serial component length.
|
|
967
|
-
*/
|
|
968
|
-
get serialComponentLength() {
|
|
969
|
-
return this._serialComponentLength;
|
|
970
|
-
}
|
|
971
|
-
/**
|
|
972
|
-
* Get the serial component character set.
|
|
973
|
-
*/
|
|
974
|
-
get serialComponentCharacterSet() {
|
|
975
|
-
return this._serialComponentCharacterSet;
|
|
976
|
-
}
|
|
977
|
-
/**
|
|
978
|
-
* Get the serial component validation parameters.
|
|
979
|
-
*/
|
|
980
|
-
get serialComponentValidation() {
|
|
981
|
-
return this._serialComponentValidation;
|
|
982
|
-
}
|
|
983
|
-
/**
|
|
984
|
-
* Get the serial component creator.
|
|
985
|
-
*/
|
|
986
|
-
get serialComponentCreator() {
|
|
987
|
-
return this._serialComponentCreator;
|
|
988
|
-
}
|
|
989
|
-
/**
|
|
990
|
-
* @inheritDoc
|
|
991
|
-
*/
|
|
992
|
-
validate(identificationKey, validation) {
|
|
993
|
-
super.validate(identificationKey.substring(0, this.length), validation);
|
|
994
|
-
if (identificationKey.length > this.length) {
|
|
995
|
-
this.serialComponentCreator.validate(identificationKey.substring(this.length), this._serialComponentValidation);
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
};
|
|
999
|
-
var NonNumericIdentificationKeyValidator = class _NonNumericIdentificationKeyValidator extends AbstractIdentificationKeyValidator {
|
|
1000
|
-
/**
|
|
1001
|
-
* Validator to ensure that an identification key (minus check character pair) is not all numeric.
|
|
1002
|
-
*/
|
|
1003
|
-
static NOT_ALL_NUMERIC_VALIDATOR = new class extends RegExpValidator {
|
|
1004
|
-
/**
|
|
1005
|
-
* @inheritDoc
|
|
1006
|
-
*/
|
|
1007
|
-
createErrorMessage(_s) {
|
|
1008
|
-
return i18nextGS1.t("IdentificationKey.referenceCantBeAllNumeric");
|
|
1009
|
-
}
|
|
1010
|
-
}(/\D/);
|
|
1011
|
-
/**
|
|
1012
|
-
* True if the identification key requires a check character pair.
|
|
1013
|
-
*/
|
|
1014
|
-
_requiresCheckCharacterPair;
|
|
1015
|
-
/**
|
|
1016
|
-
* Constructor.
|
|
1017
|
-
*
|
|
1018
|
-
* @param identificationKeyType
|
|
1019
|
-
* Identification key type.
|
|
1020
|
-
*
|
|
1021
|
-
* @param length
|
|
1022
|
-
* Length.
|
|
1023
|
-
*
|
|
1024
|
-
* @param referenceCharacterSet
|
|
1025
|
-
* Reference character set.
|
|
1026
|
-
*
|
|
1027
|
-
* @param requiresCheckCharacterPair
|
|
1028
|
-
* True if the identification key requires a check character pair.
|
|
1029
|
-
*/
|
|
1030
|
-
constructor(identificationKeyType, length, referenceCharacterSet, requiresCheckCharacterPair = false) {
|
|
1031
|
-
super(identificationKeyType, 0 /* GS1CompanyPrefix */, length, referenceCharacterSet);
|
|
1032
|
-
this._requiresCheckCharacterPair = requiresCheckCharacterPair;
|
|
1033
|
-
}
|
|
1034
|
-
/**
|
|
1035
|
-
* Determine if the identification key requires a check character pair.
|
|
1036
|
-
*/
|
|
1037
|
-
get requiresCheckCharacterPair() {
|
|
1038
|
-
return this._requiresCheckCharacterPair;
|
|
1039
|
-
}
|
|
1040
|
-
/**
|
|
1041
|
-
* Validate a non-numeric identification key and throw an error if validation fails.
|
|
1042
|
-
*
|
|
1043
|
-
* @param identificationKey
|
|
1044
|
-
* Identification key.
|
|
1045
|
-
*
|
|
1046
|
-
* @param validation
|
|
1047
|
-
* Validation parameters.
|
|
1048
|
-
*/
|
|
1049
|
-
validate(identificationKey, validation) {
|
|
1050
|
-
const partialIdentificationKey = this.requiresCheckCharacterPair ? identificationKey.substring(0, identificationKey.length - 2) : identificationKey;
|
|
1051
|
-
super.validatePrefix(partialIdentificationKey, validation?.positionOffset);
|
|
1052
|
-
if (!this.requiresCheckCharacterPair) {
|
|
1053
|
-
this.referenceCreator.validate(identificationKey, {
|
|
1054
|
-
maximumLength: this.length,
|
|
1055
|
-
positionOffset: validation?.positionOffset
|
|
1056
|
-
});
|
|
1057
|
-
} else if (!hasValidCheckCharacterPair(this.padIdentificationKey(identificationKey, validation))) {
|
|
1058
|
-
throw new RangeError(i18nextGS1.t("IdentificationKey.invalidCheckCharacterPair"));
|
|
1059
|
-
}
|
|
1060
|
-
if (validation?.exclusion === Exclusion2.AllNumeric) {
|
|
1061
|
-
_NonNumericIdentificationKeyValidator.NOT_ALL_NUMERIC_VALIDATOR.validate(partialIdentificationKey);
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
};
|
|
1065
|
-
var GTIN13_VALIDATOR = new GTINValidator(13 /* GTIN13 */);
|
|
1066
|
-
var GTIN12_VALIDATOR = new GTINValidator(12 /* GTIN12 */);
|
|
1067
|
-
var GTIN8_VALIDATOR = new GTINValidator(8 /* GTIN8 */);
|
|
1068
|
-
var GTIN_VALIDATORS = [
|
|
1069
|
-
GTIN13_VALIDATOR,
|
|
1070
|
-
GTIN12_VALIDATOR,
|
|
1071
|
-
GTIN8_VALIDATOR
|
|
1072
|
-
];
|
|
1073
|
-
var GLN_VALIDATOR = new NonGTINNumericIdentificationKeyValidator("GLN" /* GLN */, 13);
|
|
1074
|
-
var SSCC_VALIDATOR = new NonGTINNumericIdentificationKeyValidator("SSCC" /* SSCC */, 18, 2 /* ExtensionDigit */);
|
|
1075
|
-
var GRAI_VALIDATOR = new SerializableNumericIdentificationKeyValidator("GRAI" /* GRAI */, 13, 16, 1 /* AI82 */);
|
|
1076
|
-
var GIAI_VALIDATOR = new NonNumericIdentificationKeyValidator("GIAI" /* GIAI */, 30, 1 /* AI82 */);
|
|
1077
|
-
var GSRN_VALIDATOR = new NonGTINNumericIdentificationKeyValidator("GSRN" /* GSRN */, 18);
|
|
1078
|
-
var GDTI_VALIDATOR = new SerializableNumericIdentificationKeyValidator("GDTI" /* GDTI */, 13, 17, 1 /* AI82 */);
|
|
1079
|
-
var GINC_VALIDATOR = new NonNumericIdentificationKeyValidator("GINC" /* GINC */, 30, 1 /* AI82 */);
|
|
1080
|
-
var GSIN_VALIDATOR = new NonGTINNumericIdentificationKeyValidator("GSIN" /* GSIN */, 17);
|
|
1081
|
-
var GCN_VALIDATOR = new SerializableNumericIdentificationKeyValidator("GCN" /* GCN */, 13, 12, 0 /* Numeric */);
|
|
1082
|
-
var CPID_VALIDATOR = new NonNumericIdentificationKeyValidator("CPID" /* CPID */, 30, 2 /* AI39 */);
|
|
1083
|
-
var GMN_VALIDATOR = new NonNumericIdentificationKeyValidator("GMN" /* GMN */, 25, 1 /* AI82 */, true);
|
|
1084
|
-
var AbstractIdentificationKeyCreator = class {
|
|
1085
|
-
/**
|
|
1086
|
-
* Prefix manager.
|
|
1087
|
-
*/
|
|
1088
|
-
_prefixManager;
|
|
1089
|
-
/**
|
|
1090
|
-
* Reference length.
|
|
1091
|
-
*/
|
|
1092
|
-
_referenceLength;
|
|
1093
|
-
/**
|
|
1094
|
-
* Initialize the prefix manager. This method is in lieu of a constructor due to the mixin architecture.
|
|
1095
|
-
*
|
|
1096
|
-
* @param prefixManager
|
|
1097
|
-
* Prefix manager.
|
|
1098
|
-
*
|
|
1099
|
-
* @param prefix
|
|
1100
|
-
* Prefix within prefix manager to use to calculate reference length.
|
|
1101
|
-
*
|
|
1102
|
-
* @param checkAllowance
|
|
1103
|
-
* Number of characters to allow for check digit or check character pair.
|
|
1104
|
-
*/
|
|
1105
|
-
init(prefixManager, prefix, checkAllowance) {
|
|
1106
|
-
this._prefixManager = prefixManager;
|
|
1107
|
-
this._referenceLength = this.length - prefix.length - checkAllowance;
|
|
1108
|
-
}
|
|
1109
|
-
/**
|
|
1110
|
-
* @inheritDoc
|
|
1111
|
-
*/
|
|
1112
|
-
get prefixManager() {
|
|
1113
|
-
return this._prefixManager;
|
|
1114
|
-
}
|
|
1115
|
-
/**
|
|
1116
|
-
* @inheritDoc
|
|
1117
|
-
*/
|
|
1118
|
-
get prefix() {
|
|
1119
|
-
return this.prefixManager.gs1CompanyPrefix;
|
|
1120
|
-
}
|
|
1121
|
-
/**
|
|
1122
|
-
* @inheritDoc
|
|
1123
|
-
*/
|
|
1124
|
-
get referenceLength() {
|
|
1125
|
-
return this._referenceLength;
|
|
1126
|
-
}
|
|
1127
|
-
};
|
|
1128
|
-
var AbstractNumericIdentificationKeyCreator = class _AbstractNumericIdentificationKeyCreator extends AbstractIdentificationKeyCreator {
|
|
1129
|
-
/**
|
|
1130
|
-
* Capacity.
|
|
1131
|
-
*/
|
|
1132
|
-
_capacity;
|
|
1133
|
-
/**
|
|
1134
|
-
* Tweak for sparse creation.
|
|
1135
|
-
*/
|
|
1136
|
-
_tweak = 0n;
|
|
1137
|
-
/**
|
|
1138
|
-
* Initialize the prefix manager. This method is in lieu of a constructor due to the mixin architecture.
|
|
1139
|
-
*
|
|
1140
|
-
* @param prefixManager
|
|
1141
|
-
* Prefix manager.
|
|
1142
|
-
*
|
|
1143
|
-
* @param prefix
|
|
1144
|
-
* Prefix within prefix manager to use to calculate reference length.
|
|
1145
|
-
*/
|
|
1146
|
-
init(prefixManager, prefix) {
|
|
1147
|
-
super.init(prefixManager, prefix, 1);
|
|
1148
|
-
this._capacity = Number(CharacterSetCreator2.powerOf10(this.referenceLength));
|
|
1149
|
-
}
|
|
1150
|
-
/**
|
|
1151
|
-
* @inheritDoc
|
|
1152
|
-
*/
|
|
1153
|
-
get capacity() {
|
|
1154
|
-
return this._capacity;
|
|
1155
|
-
}
|
|
1156
|
-
/**
|
|
1157
|
-
* Get the tweak for sparse creation.
|
|
1158
|
-
*/
|
|
1159
|
-
get tweak() {
|
|
1160
|
-
return this._tweak;
|
|
1161
|
-
}
|
|
1162
|
-
/**
|
|
1163
|
-
* Set the tweak for sparse creation.
|
|
1164
|
-
*/
|
|
1165
|
-
set tweak(value) {
|
|
1166
|
-
this._tweak = value;
|
|
1167
|
-
}
|
|
1168
|
-
/**
|
|
1169
|
-
* Build an identification key from a reference by merging it with the prefix and adding the check digit.
|
|
1170
|
-
*
|
|
1171
|
-
* @param reference
|
|
1172
|
-
* Identification key reference.
|
|
1173
|
-
*
|
|
1174
|
-
* @returns
|
|
1175
|
-
* Identification key.
|
|
1176
|
-
*/
|
|
1177
|
-
buildIdentificationKey(reference) {
|
|
1178
|
-
const partialIdentificationKey = this.leaderType === 2 /* ExtensionDigit */ ? reference.substring(0, 1) + this.prefix + reference.substring(1) : this.prefix + reference;
|
|
1179
|
-
return partialIdentificationKey + checkDigit(partialIdentificationKey);
|
|
1180
|
-
}
|
|
1181
|
-
/**
|
|
1182
|
-
* @inheritDoc
|
|
1183
|
-
*/
|
|
1184
|
-
create(valueOrValues, sparse = false) {
|
|
1185
|
-
return NUMERIC_CREATOR2.create(this.referenceLength, valueOrValues, Exclusion2.None, sparse ? this.tweak : void 0, (reference) => this.buildIdentificationKey(reference));
|
|
1186
|
-
}
|
|
1187
|
-
/**
|
|
1188
|
-
* Create all identification keys from a partial identification key. Call is recursive until remaining reference
|
|
1189
|
-
* length is 0.
|
|
1190
|
-
*
|
|
1191
|
-
* @param partialIdentificationKey
|
|
1192
|
-
* Partial identification key. Initial value is `this.prefix`.
|
|
1193
|
-
*
|
|
1194
|
-
* @param remainingReferenceLength
|
|
1195
|
-
* Remaining reference length. Initial value is `this.referenceLength`.
|
|
1196
|
-
*
|
|
1197
|
-
* @param extensionWeight
|
|
1198
|
-
* If this value is not zero, the identification key has an extension digit, this call is setting it, and this value
|
|
1199
|
-
* is applied to the calculation of the check digit.
|
|
1200
|
-
*
|
|
1201
|
-
* @param weight
|
|
1202
|
-
* If the extension weight is zero, this value is applied to the calculation of the check digit.
|
|
1203
|
-
*
|
|
1204
|
-
* @param partialCheckDigitSum
|
|
1205
|
-
* Partial check digit sum for the partial identification key.
|
|
1206
|
-
*
|
|
1207
|
-
* @yields
|
|
1208
|
-
* Identification key.
|
|
1209
|
-
*/
|
|
1210
|
-
static *createAllPartial(partialIdentificationKey, remainingReferenceLength, extensionWeight, weight, partialCheckDigitSum) {
|
|
1211
|
-
if (remainingReferenceLength === 0) {
|
|
1212
|
-
yield partialIdentificationKey + NUMERIC_CREATOR2.character(9 - (partialCheckDigitSum + 9) % 10);
|
|
1213
|
-
} else {
|
|
1214
|
-
const nextRemainingReferenceLength = remainingReferenceLength - 1;
|
|
1215
|
-
let nextPartialCheckDigitSum = partialCheckDigitSum;
|
|
1216
|
-
if (extensionWeight !== 0) {
|
|
1217
|
-
for (const c of NUMERIC_CREATOR2.characterSet) {
|
|
1218
|
-
yield* _AbstractNumericIdentificationKeyCreator.createAllPartial(c + partialIdentificationKey, nextRemainingReferenceLength, 0, weight, nextPartialCheckDigitSum);
|
|
1219
|
-
nextPartialCheckDigitSum += extensionWeight;
|
|
1220
|
-
}
|
|
1221
|
-
} else {
|
|
1222
|
-
const nextWeight = 4 - weight;
|
|
1223
|
-
for (const c of NUMERIC_CREATOR2.characterSet) {
|
|
1224
|
-
yield* _AbstractNumericIdentificationKeyCreator.createAllPartial(partialIdentificationKey + c, nextRemainingReferenceLength, 0, nextWeight, nextPartialCheckDigitSum);
|
|
1225
|
-
nextPartialCheckDigitSum += weight;
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
/**
|
|
1231
|
-
* @inheritDoc
|
|
1232
|
-
*/
|
|
1233
|
-
createAll() {
|
|
1234
|
-
const hasExtensionDigit = this.leaderType === 2 /* ExtensionDigit */;
|
|
1235
|
-
const prefix = this.prefix;
|
|
1236
|
-
const length = this.length;
|
|
1237
|
-
const referenceLength = this.referenceLength;
|
|
1238
|
-
const startWeight = 3 - 2 * ((referenceLength + 1 - Number(hasExtensionDigit)) % 2);
|
|
1239
|
-
return {
|
|
1240
|
-
[Symbol.iterator]() {
|
|
1241
|
-
return _AbstractNumericIdentificationKeyCreator.createAllPartial(prefix, referenceLength, hasExtensionDigit ? 3 - 2 * length % 2 : 0, startWeight, checkDigitSum(startWeight === 3, prefix));
|
|
1242
|
-
}
|
|
1243
|
-
};
|
|
1244
|
-
}
|
|
1245
|
-
};
|
|
1246
|
-
var GTINCreator = class _GTINCreator extends Mixin(GTINValidator, AbstractNumericIdentificationKeyCreator) {
|
|
1247
|
-
/**
|
|
1248
|
-
* Validation parameters for required indicator digit.
|
|
1249
|
-
*/
|
|
1250
|
-
static REQUIRED_INDICATOR_DIGIT_VALIDATION = {
|
|
1251
|
-
minimumLength: 1,
|
|
1252
|
-
maximumLength: 1,
|
|
1253
|
-
component: () => i18nextGS1.t("IdentificationKey.indicatorDigit")
|
|
1254
|
-
};
|
|
1255
|
-
/**
|
|
1256
|
-
* Constructor. Called internally by {@link PrefixManager.gtinCreator}; should not be called by other code.
|
|
1257
|
-
*
|
|
1258
|
-
* @param prefixManager
|
|
1259
|
-
* Prefix manager.
|
|
1260
|
-
*
|
|
1261
|
-
* @param gtinType
|
|
1262
|
-
* GTIN type.
|
|
1263
|
-
*/
|
|
1264
|
-
constructor(prefixManager, gtinType) {
|
|
1265
|
-
super(gtinType);
|
|
1266
|
-
this.init(prefixManager, prefixManager.prefix);
|
|
1267
|
-
}
|
|
1268
|
-
/**
|
|
1269
|
-
* @inheritDoc
|
|
1270
|
-
*/
|
|
1271
|
-
get prefix() {
|
|
1272
|
-
return this.prefixManager.prefix;
|
|
1273
|
-
}
|
|
1274
|
-
/**
|
|
1275
|
-
* Create GTIN-14(s) with an indicator digit and reference(s) based on numeric value(s). The value(s) is/are
|
|
1276
|
-
* converted to reference(s) of the appropriate length using {@linkcode NUMERIC_CREATOR}.
|
|
1277
|
-
*
|
|
1278
|
-
* @param indicatorDigit
|
|
1279
|
-
* Indicator digit.
|
|
1280
|
-
*
|
|
1281
|
-
* @param valueOrValues
|
|
1282
|
-
* Numeric value(s).
|
|
1283
|
-
*
|
|
1284
|
-
* @param sparse
|
|
1285
|
-
* If true, the value(s) is/are mapped to a sparse sequence resistant to discovery. Default is false.
|
|
1286
|
-
*
|
|
1287
|
-
* @returns
|
|
1288
|
-
* GTIN-14(s).
|
|
1289
|
-
*/
|
|
1290
|
-
createGTIN14(indicatorDigit, valueOrValues, sparse = false) {
|
|
1291
|
-
NUMERIC_CREATOR2.validate(indicatorDigit, _GTINCreator.REQUIRED_INDICATOR_DIGIT_VALIDATION);
|
|
1292
|
-
return NUMERIC_CREATOR2.create(13 /* GTIN13 */ - this.prefixManager.gs1CompanyPrefix.length - 1, valueOrValues, Exclusion2.None, sparse ? this.tweak : void 0, (reference) => {
|
|
1293
|
-
const partialIdentificationKey = indicatorDigit + this.prefixManager.gs1CompanyPrefix + reference;
|
|
1294
|
-
return partialIdentificationKey + checkDigit(partialIdentificationKey);
|
|
1295
|
-
});
|
|
1296
|
-
}
|
|
1297
|
-
};
|
|
1298
|
-
var NonGTINNumericIdentificationKeyCreator = class extends Mixin(NonGTINNumericIdentificationKeyValidator, AbstractNumericIdentificationKeyCreator) {
|
|
1299
|
-
/**
|
|
1300
|
-
* Constructor. Called internally by {@link PrefixManager} non-GTIN numeric identification key creator getters;
|
|
1301
|
-
* should not be called by other code.
|
|
1302
|
-
*
|
|
1303
|
-
* @param prefixManager
|
|
1304
|
-
* Prefix manager.
|
|
1305
|
-
*
|
|
1306
|
-
* @param identificationKeyType
|
|
1307
|
-
* Identification key type.
|
|
1308
|
-
*
|
|
1309
|
-
* @param length
|
|
1310
|
-
* Length.
|
|
1311
|
-
*
|
|
1312
|
-
* @param leaderType
|
|
1313
|
-
* Leader type.
|
|
1314
|
-
*/
|
|
1315
|
-
constructor(prefixManager, identificationKeyType, length, leaderType = 0 /* None */) {
|
|
1316
|
-
super(identificationKeyType, length, leaderType);
|
|
1317
|
-
this.init(prefixManager, prefixManager.gs1CompanyPrefix);
|
|
1318
|
-
}
|
|
1319
|
-
};
|
|
1320
|
-
var SerializableNumericIdentificationKeyCreator = class extends Mixin(SerializableNumericIdentificationKeyValidator, AbstractNumericIdentificationKeyCreator) {
|
|
1321
|
-
/**
|
|
1322
|
-
* Constructor. Called internally by {@link PrefixManager} serialized numeric identification key creator getters;
|
|
1323
|
-
* should not be called by other code.
|
|
1324
|
-
*
|
|
1325
|
-
* @param prefixManager
|
|
1326
|
-
* Prefix manager.
|
|
1327
|
-
*
|
|
1328
|
-
* @param identificationKeyType
|
|
1329
|
-
* Identification key type.
|
|
1330
|
-
*
|
|
1331
|
-
* @param length
|
|
1332
|
-
* Length.
|
|
1333
|
-
*
|
|
1334
|
-
* @param serialComponentLength
|
|
1335
|
-
* Serial component length.
|
|
1336
|
-
*
|
|
1337
|
-
* @param serialComponentCharacterSet
|
|
1338
|
-
* Serial component character set.
|
|
1339
|
-
*/
|
|
1340
|
-
constructor(prefixManager, identificationKeyType, length, serialComponentLength, serialComponentCharacterSet) {
|
|
1341
|
-
super(identificationKeyType, length, serialComponentLength, serialComponentCharacterSet);
|
|
1342
|
-
this.init(prefixManager, prefixManager.gs1CompanyPrefix);
|
|
1343
|
-
}
|
|
1344
|
-
/**
|
|
1345
|
-
* Concatenate a validated base identification key with serial component(s).
|
|
1346
|
-
*
|
|
1347
|
-
* @param baseIdentificationKey
|
|
1348
|
-
* Base identification key.
|
|
1349
|
-
*
|
|
1350
|
-
* @param serialComponentOrComponents
|
|
1351
|
-
* Serial component(s).
|
|
1352
|
-
*
|
|
1353
|
-
* @returns
|
|
1354
|
-
* Serialized identification key(s).
|
|
1355
|
-
*/
|
|
1356
|
-
concatenateValidated(baseIdentificationKey, serialComponentOrComponents) {
|
|
1357
|
-
let result;
|
|
1358
|
-
const serialComponentCreator = this.serialComponentCreator;
|
|
1359
|
-
const serialComponentValidation = this.serialComponentValidation;
|
|
1360
|
-
function validateAndConcatenate(serialComponent) {
|
|
1361
|
-
serialComponentCreator.validate(serialComponent, serialComponentValidation);
|
|
1362
|
-
return baseIdentificationKey + serialComponent;
|
|
1363
|
-
}
|
|
1364
|
-
if (typeof serialComponentOrComponents !== "object") {
|
|
1365
|
-
result = validateAndConcatenate(serialComponentOrComponents);
|
|
1366
|
-
} else {
|
|
1367
|
-
result = transformIterable(serialComponentOrComponents, validateAndConcatenate);
|
|
1368
|
-
}
|
|
1369
|
-
return result;
|
|
1370
|
-
}
|
|
1371
|
-
/**
|
|
1372
|
-
* Create serialized identification key(s) with a reference based on a numeric value concatenated with serial
|
|
1373
|
-
* component(s). The value is converted to a reference of the appropriate length using {@linkcode NUMERIC_CREATOR}.
|
|
1374
|
-
*
|
|
1375
|
-
* @param value
|
|
1376
|
-
* Numeric value of the reference.
|
|
1377
|
-
*
|
|
1378
|
-
* @param serialComponentOrComponents
|
|
1379
|
-
* Serial component(s).
|
|
1380
|
-
*
|
|
1381
|
-
* @param sparse
|
|
1382
|
-
* If true, the value is mapped to a sparse sequence resistant to discovery. Default is false.
|
|
1383
|
-
*
|
|
1384
|
-
* @returns
|
|
1385
|
-
* Serialized identification keys.
|
|
1386
|
-
*/
|
|
1387
|
-
createSerialized(value, serialComponentOrComponents, sparse) {
|
|
1388
|
-
return this.concatenateValidated(this.create(value, sparse), serialComponentOrComponents);
|
|
1389
|
-
}
|
|
1390
|
-
/**
|
|
1391
|
-
* Concatenate a base identification key with serial component(s).
|
|
1392
|
-
*
|
|
1393
|
-
* @param baseIdentificationKey
|
|
1394
|
-
* Base identification key.
|
|
1395
|
-
*
|
|
1396
|
-
* @param serialComponentOrComponents
|
|
1397
|
-
* Serial component(s).
|
|
1398
|
-
*
|
|
1399
|
-
* @returns
|
|
1400
|
-
* Serialized identification key(s).
|
|
1401
|
-
*/
|
|
1402
|
-
concatenate(baseIdentificationKey, serialComponentOrComponents) {
|
|
1403
|
-
this.validate(baseIdentificationKey);
|
|
1404
|
-
return this.concatenateValidated(baseIdentificationKey, serialComponentOrComponents);
|
|
1405
|
-
}
|
|
1406
|
-
};
|
|
1407
|
-
var NonNumericIdentificationKeyCreator = class extends Mixin(NonNumericIdentificationKeyValidator, AbstractIdentificationKeyCreator) {
|
|
1408
|
-
/**
|
|
1409
|
-
* Reference validation parameters.
|
|
1410
|
-
*/
|
|
1411
|
-
_referenceValidation;
|
|
1412
|
-
/**
|
|
1413
|
-
* Constructor. Called internally by {@link PrefixManager} non-numeric identification key creator getters; should
|
|
1414
|
-
* not be called by other code.
|
|
1415
|
-
*
|
|
1416
|
-
* @param prefixManager
|
|
1417
|
-
* Prefix manager.
|
|
1418
|
-
*
|
|
1419
|
-
* @param identificationKeyType
|
|
1420
|
-
* Identification key type.
|
|
1421
|
-
*
|
|
1422
|
-
* @param length
|
|
1423
|
-
* Length.
|
|
1424
|
-
*
|
|
1425
|
-
* @param referenceCharacterSet
|
|
1426
|
-
* Reference character set.
|
|
1427
|
-
*
|
|
1428
|
-
* @param requiresCheckCharacterPair
|
|
1429
|
-
* True if the identification key requires a check character pair.
|
|
1430
|
-
*/
|
|
1431
|
-
constructor(prefixManager, identificationKeyType, length, referenceCharacterSet, requiresCheckCharacterPair = false) {
|
|
1432
|
-
super(identificationKeyType, length, referenceCharacterSet, requiresCheckCharacterPair);
|
|
1433
|
-
this.init(prefixManager, prefixManager.gs1CompanyPrefix, 2 * Number(requiresCheckCharacterPair));
|
|
1434
|
-
this._referenceValidation = {
|
|
1435
|
-
minimumLength: 1,
|
|
1436
|
-
// Maximum reference length has to account for prefix and check character pair.
|
|
1437
|
-
maximumLength: this.referenceLength,
|
|
1438
|
-
component: () => i18nextGS1.t("IdentificationKey.reference")
|
|
1439
|
-
};
|
|
1440
|
-
}
|
|
1441
|
-
/**
|
|
1442
|
-
* Get the reference validation parameters.
|
|
1443
|
-
*/
|
|
1444
|
-
get referenceValidation() {
|
|
1445
|
-
return this._referenceValidation;
|
|
1446
|
-
}
|
|
1447
|
-
/**
|
|
1448
|
-
* Create identification key(s) with reference(s).
|
|
1449
|
-
*
|
|
1450
|
-
* @param referenceOrReferences
|
|
1451
|
-
* Reference(s).
|
|
1452
|
-
*
|
|
1453
|
-
* @returns
|
|
1454
|
-
* Identification key(s).
|
|
1455
|
-
*/
|
|
1456
|
-
create(referenceOrReferences) {
|
|
1457
|
-
let result;
|
|
1458
|
-
const referenceCreator = this.referenceCreator;
|
|
1459
|
-
const referenceValidation = this.referenceValidation;
|
|
1460
|
-
const prefix = this.prefix;
|
|
1461
|
-
const requiresCheckCharacterPair = this.requiresCheckCharacterPair;
|
|
1462
|
-
function validateAndCreate(reference) {
|
|
1463
|
-
referenceCreator.validate(reference, referenceValidation);
|
|
1464
|
-
const partialIdentificationKey = prefix + reference;
|
|
1465
|
-
return requiresCheckCharacterPair ? partialIdentificationKey + checkCharacterPair(partialIdentificationKey) : partialIdentificationKey;
|
|
1466
|
-
}
|
|
1467
|
-
if (typeof referenceOrReferences !== "object") {
|
|
1468
|
-
result = validateAndCreate(referenceOrReferences);
|
|
1469
|
-
} else {
|
|
1470
|
-
result = transformIterable(referenceOrReferences, validateAndCreate);
|
|
1471
|
-
}
|
|
1472
|
-
return result;
|
|
1473
|
-
}
|
|
1474
|
-
};
|
|
1475
|
-
var PrefixManager = class _PrefixManager {
|
|
1476
|
-
/**
|
|
1477
|
-
* Cached prefix managers, keyed by GS1 Company Prefix.
|
|
1478
|
-
*/
|
|
1479
|
-
static PREFIX_MANAGERS_MAP = /* @__PURE__ */ new Map();
|
|
1480
|
-
/**
|
|
1481
|
-
* GS1 Company Prefix minimum length.
|
|
1482
|
-
*/
|
|
1483
|
-
static GS1_COMPANY_PREFIX_MINIMUM_LENGTH = 4;
|
|
1484
|
-
/**
|
|
1485
|
-
* GS1 Company Prefix maximum length.
|
|
1486
|
-
*/
|
|
1487
|
-
static GS1_COMPANY_PREFIX_MAXIMUM_LENGTH = 12;
|
|
1488
|
-
/**
|
|
1489
|
-
* U.P.C. Company Prefix minimum length.
|
|
1490
|
-
*/
|
|
1491
|
-
static UPC_COMPANY_PREFIX_MINIMUM_LENGTH = 6;
|
|
1492
|
-
/**
|
|
1493
|
-
* U.P.C. Company Prefix maximum length.
|
|
1494
|
-
*/
|
|
1495
|
-
static UPC_COMPANY_PREFIX_MAXIMUM_LENGTH = 11;
|
|
1496
|
-
/**
|
|
1497
|
-
* GS1-8 Prefix minimum length.
|
|
1498
|
-
*/
|
|
1499
|
-
static GS1_8_PREFIX_MINIMUM_LENGTH = 2;
|
|
1500
|
-
/**
|
|
1501
|
-
* GS1-8 Prefix maximum length.
|
|
1502
|
-
*/
|
|
1503
|
-
static GS1_8_PREFIX_MAXIMUM_LENGTH = 7;
|
|
1504
|
-
/**
|
|
1505
|
-
* Validation parameters for GS1 Company Prefix.
|
|
1506
|
-
*/
|
|
1507
|
-
static GS1_COMPANY_PREFIX_VALIDATION = {
|
|
1508
|
-
minimumLength: _PrefixManager.GS1_COMPANY_PREFIX_MINIMUM_LENGTH,
|
|
1509
|
-
maximumLength: _PrefixManager.GS1_COMPANY_PREFIX_MAXIMUM_LENGTH,
|
|
1510
|
-
component: () => i18nextGS1.t("Prefix.gs1CompanyPrefix")
|
|
1511
|
-
};
|
|
1512
|
-
/**
|
|
1513
|
-
* Validation parameters for U.P.C. Company Prefix expressed as GS1 Company Prefix.
|
|
1514
|
-
*/
|
|
1515
|
-
static UPC_COMPANY_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION = {
|
|
1516
|
-
minimumLength: _PrefixManager.UPC_COMPANY_PREFIX_MINIMUM_LENGTH + 1,
|
|
1517
|
-
maximumLength: _PrefixManager.UPC_COMPANY_PREFIX_MAXIMUM_LENGTH + 1,
|
|
1518
|
-
component: () => i18nextGS1.t("Prefix.gs1CompanyPrefix")
|
|
1519
|
-
};
|
|
1520
|
-
/**
|
|
1521
|
-
* Validation parameters for GS1-8 Prefix expressed as GS1 Company Prefix.
|
|
1522
|
-
*/
|
|
1523
|
-
static GS1_8_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION = {
|
|
1524
|
-
minimumLength: _PrefixManager.GS1_8_PREFIX_MINIMUM_LENGTH + 5,
|
|
1525
|
-
maximumLength: _PrefixManager.GS1_8_PREFIX_MAXIMUM_LENGTH + 5,
|
|
1526
|
-
component: () => i18nextGS1.t("Prefix.gs1CompanyPrefix")
|
|
1527
|
-
};
|
|
1528
|
-
/**
|
|
1529
|
-
* Validation parameters for U.P.C. Company Prefix.
|
|
1530
|
-
*/
|
|
1531
|
-
static UPC_COMPANY_PREFIX_VALIDATION = {
|
|
1532
|
-
minimumLength: _PrefixManager.UPC_COMPANY_PREFIX_MINIMUM_LENGTH,
|
|
1533
|
-
maximumLength: _PrefixManager.UPC_COMPANY_PREFIX_MAXIMUM_LENGTH,
|
|
1534
|
-
component: () => i18nextGS1.t("Prefix.upcCompanyPrefix")
|
|
1535
|
-
};
|
|
1536
|
-
/**
|
|
1537
|
-
* Validation parameters for GS1-8 Prefix.
|
|
1538
|
-
*/
|
|
1539
|
-
static GS1_8_PREFIX_VALIDATION = {
|
|
1540
|
-
minimumLength: _PrefixManager.GS1_8_PREFIX_MINIMUM_LENGTH,
|
|
1541
|
-
maximumLength: _PrefixManager.GS1_8_PREFIX_MAXIMUM_LENGTH,
|
|
1542
|
-
component: () => i18nextGS1.t("Prefix.gs18Prefix")
|
|
1543
|
-
};
|
|
1544
|
-
/**
|
|
1545
|
-
* Creator tweak factors. Different numeric identification key types have different tweak factors so that sparse
|
|
1546
|
-
* creation generates different sequences for each.
|
|
1547
|
-
*/
|
|
1548
|
-
static CREATOR_TWEAK_FACTORS_MAP = /* @__PURE__ */ new Map([
|
|
1549
|
-
["GTIN" /* GTIN */, 1987n],
|
|
1550
|
-
["GLN" /* GLN */, 4241n],
|
|
1551
|
-
["SSCC" /* SSCC */, 8087n],
|
|
1552
|
-
["GRAI" /* GRAI */, 3221n],
|
|
1553
|
-
["GSRN" /* GSRN */, 2341n],
|
|
1554
|
-
["GDTI" /* GDTI */, 7333n],
|
|
1555
|
-
["GSIN" /* GSIN */, 5623n],
|
|
1556
|
-
["GCN" /* GCN */, 6869n]
|
|
1557
|
-
]);
|
|
1558
|
-
/**
|
|
1559
|
-
* Normalized prefix type.
|
|
1560
|
-
*/
|
|
1561
|
-
_prefixType;
|
|
1562
|
-
/**
|
|
1563
|
-
* Normalized prefix.
|
|
1564
|
-
*/
|
|
1565
|
-
_prefix;
|
|
1566
|
-
/**
|
|
1567
|
-
* Prefix as GS1 Company Prefix.
|
|
1568
|
-
*/
|
|
1569
|
-
_gs1CompanyPrefix;
|
|
1570
|
-
/**
|
|
1571
|
-
* U.P.C. Company Prefix if prefix type is {@link PrefixType.UPCCompanyPrefix}.
|
|
1572
|
-
*/
|
|
1573
|
-
_upcCompanyPrefix;
|
|
1574
|
-
/**
|
|
1575
|
-
* GS1-8 Prefix if prefix type is {@link PrefixType.GS18Prefix}.
|
|
1576
|
-
*/
|
|
1577
|
-
_gs18Prefix;
|
|
1578
|
-
/**
|
|
1579
|
-
* Default tweak factor.
|
|
1580
|
-
*/
|
|
1581
|
-
_defaultTweakFactor;
|
|
1582
|
-
/**
|
|
1583
|
-
* Tweak factor.
|
|
1584
|
-
*/
|
|
1585
|
-
_tweakFactor = 0n;
|
|
1586
|
-
/**
|
|
1587
|
-
* Cached identification key creators.
|
|
1588
|
-
*/
|
|
1589
|
-
_identificationKeyCreatorsMap = /* @__PURE__ */ new Map();
|
|
1590
|
-
/**
|
|
1591
|
-
* Constructor.
|
|
1592
|
-
*
|
|
1593
|
-
* @param gs1CompanyPrefix
|
|
1594
|
-
* GS1 Company Prefix.
|
|
1595
|
-
*/
|
|
1596
|
-
constructor(gs1CompanyPrefix) {
|
|
1597
|
-
this._gs1CompanyPrefix = gs1CompanyPrefix;
|
|
1598
|
-
if (!gs1CompanyPrefix.startsWith("0")) {
|
|
1599
|
-
this._prefixType = 0 /* GS1CompanyPrefix */;
|
|
1600
|
-
this._prefix = this._gs1CompanyPrefix;
|
|
1601
|
-
} else if (!gs1CompanyPrefix.startsWith("00000")) {
|
|
1602
|
-
this._prefixType = 1 /* UPCCompanyPrefix */;
|
|
1603
|
-
this._upcCompanyPrefix = gs1CompanyPrefix.substring(1);
|
|
1604
|
-
this._prefix = this._upcCompanyPrefix;
|
|
1605
|
-
} else {
|
|
1606
|
-
this._prefixType = 2 /* GS18Prefix */;
|
|
1607
|
-
this._gs18Prefix = gs1CompanyPrefix.substring(5);
|
|
1608
|
-
this._prefix = this._gs18Prefix;
|
|
1609
|
-
}
|
|
1610
|
-
this._defaultTweakFactor = BigInt(`1${this.gs1CompanyPrefix}`);
|
|
1611
|
-
this.resetTweakFactor();
|
|
1612
|
-
}
|
|
1613
|
-
/**
|
|
1614
|
-
* Get the prefix type.
|
|
1615
|
-
*/
|
|
1616
|
-
get prefixType() {
|
|
1617
|
-
return this._prefixType;
|
|
1618
|
-
}
|
|
1619
|
-
/**
|
|
1620
|
-
* Get the prefix.
|
|
1621
|
-
*/
|
|
1622
|
-
get prefix() {
|
|
1623
|
-
return this._prefix;
|
|
1624
|
-
}
|
|
1625
|
-
/**
|
|
1626
|
-
* Get the GS1 Company Prefix.
|
|
1627
|
-
*/
|
|
1628
|
-
get gs1CompanyPrefix() {
|
|
1629
|
-
return this._gs1CompanyPrefix;
|
|
1630
|
-
}
|
|
1631
|
-
/**
|
|
1632
|
-
* Get the U.P.C. Company Prefix if prefix type is {@link PrefixType.UPCCompanyPrefix} or undefined if not.
|
|
1633
|
-
*/
|
|
1634
|
-
get upcCompanyPrefix() {
|
|
1635
|
-
return this._upcCompanyPrefix;
|
|
1636
|
-
}
|
|
1637
|
-
/**
|
|
1638
|
-
* Get the GS1-8 Prefix if prefix type is {@link PrefixType.GS18Prefix} or undefined if not.
|
|
1639
|
-
*/
|
|
1640
|
-
get gs18Prefix() {
|
|
1641
|
-
return this._gs18Prefix;
|
|
1642
|
-
}
|
|
1643
|
-
/**
|
|
1644
|
-
* Set the tweak for an identification key creator if it's a numeric identification key creator.
|
|
1645
|
-
*
|
|
1646
|
-
* @param creator
|
|
1647
|
-
* Identification key creator.
|
|
1648
|
-
*/
|
|
1649
|
-
setCreatorTweak(creator) {
|
|
1650
|
-
const creatorTweakFactor = _PrefixManager.CREATOR_TWEAK_FACTORS_MAP.get(creator.identificationKeyType);
|
|
1651
|
-
if (creatorTweakFactor !== void 0) {
|
|
1652
|
-
creator.tweak = this.tweakFactor * creatorTweakFactor;
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
/**
|
|
1656
|
-
* Get the tweak factor.
|
|
1657
|
-
*/
|
|
1658
|
-
get tweakFactor() {
|
|
1659
|
-
return this._tweakFactor;
|
|
1660
|
-
}
|
|
1661
|
-
/**
|
|
1662
|
-
* Set the tweak factor.
|
|
1663
|
-
*
|
|
1664
|
-
* @param value
|
|
1665
|
-
* Tweak factor.
|
|
1666
|
-
*/
|
|
1667
|
-
set tweakFactor(value) {
|
|
1668
|
-
const tweakFactor = BigInt(value);
|
|
1669
|
-
if (this._tweakFactor !== tweakFactor) {
|
|
1670
|
-
this._tweakFactor = tweakFactor;
|
|
1671
|
-
for (const creator of this._identificationKeyCreatorsMap.values()) {
|
|
1672
|
-
this.setCreatorTweak(creator);
|
|
1673
|
-
}
|
|
1674
|
-
}
|
|
1675
|
-
}
|
|
1676
|
-
/**
|
|
1677
|
-
* Reset the tweak factor to its default (numeric value of the GS1 Company Prefix preceded by '1').
|
|
1678
|
-
*/
|
|
1679
|
-
resetTweakFactor() {
|
|
1680
|
-
this.tweakFactor = this._defaultTweakFactor;
|
|
1681
|
-
}
|
|
1682
|
-
/**
|
|
1683
|
-
* Get a prefix manager.
|
|
1684
|
-
*
|
|
1685
|
-
* @param prefixType
|
|
1686
|
-
* Prefix type.
|
|
1687
|
-
*
|
|
1688
|
-
* @param prefix
|
|
1689
|
-
* Prefix.
|
|
1690
|
-
*
|
|
1691
|
-
* @returns
|
|
1692
|
-
* Prefix manager with normalized prefix type and prefix.
|
|
1693
|
-
*/
|
|
1694
|
-
static get(prefixType, prefix) {
|
|
1695
|
-
_PrefixManager.validatePrefix(prefixType, true, true, prefix);
|
|
1696
|
-
let gs1CompanyPrefix;
|
|
1697
|
-
switch (prefixType) {
|
|
1698
|
-
case 0 /* GS1CompanyPrefix */:
|
|
1699
|
-
gs1CompanyPrefix = prefix;
|
|
1700
|
-
break;
|
|
1701
|
-
case 1 /* UPCCompanyPrefix */:
|
|
1702
|
-
gs1CompanyPrefix = "0" + prefix;
|
|
1703
|
-
break;
|
|
1704
|
-
case 2 /* GS18Prefix */:
|
|
1705
|
-
gs1CompanyPrefix = "00000" + prefix;
|
|
1706
|
-
break;
|
|
1707
|
-
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- Method may be called by unsafe means.
|
|
1708
|
-
default:
|
|
1709
|
-
throw new RangeError(i18nextGS1.t("Prefix.invalidPrefixType"));
|
|
1710
|
-
}
|
|
1711
|
-
let prefixManager = _PrefixManager.PREFIX_MANAGERS_MAP.get(gs1CompanyPrefix);
|
|
1712
|
-
if (prefixManager === void 0) {
|
|
1713
|
-
prefixManager = new _PrefixManager(gs1CompanyPrefix);
|
|
1714
|
-
_PrefixManager.PREFIX_MANAGERS_MAP.set(gs1CompanyPrefix, prefixManager);
|
|
1715
|
-
}
|
|
1716
|
-
return prefixManager;
|
|
1717
|
-
}
|
|
1718
|
-
/**
|
|
1719
|
-
* Validate a prefix.
|
|
1720
|
-
*
|
|
1721
|
-
* @param prefixType
|
|
1722
|
-
* Prefix type.
|
|
1723
|
-
*
|
|
1724
|
-
* @param allowUPCCompanyPrefix
|
|
1725
|
-
* If true, a U.P.C. Company Prefix expressed as a GS1 Company Prefix is permitted.
|
|
1726
|
-
*
|
|
1727
|
-
* @param allowGS18Prefix
|
|
1728
|
-
* If true, a GS1-8 Prefix expressed as a GS1 Company Prefix is permitted.
|
|
1729
|
-
*
|
|
1730
|
-
* @param prefix
|
|
1731
|
-
* Prefix.
|
|
1732
|
-
*
|
|
1733
|
-
* @param isFromIdentificationKey
|
|
1734
|
-
* If true, the prefix is from an identification key and should be trimmed before its character set is validated.
|
|
1735
|
-
*
|
|
1736
|
-
* @param isNumericIdentificationKey
|
|
1737
|
-
* If true, the prefix is from a numeric identification key and its character set will be validated by the caller.
|
|
1738
|
-
*
|
|
1739
|
-
* @param positionOffset
|
|
1740
|
-
* Position offset within a larger string.
|
|
1741
|
-
*/
|
|
1742
|
-
static validatePrefix(prefixType, allowUPCCompanyPrefix, allowGS18Prefix, prefix, isFromIdentificationKey = false, isNumericIdentificationKey = false, positionOffset) {
|
|
1743
|
-
let baseValidation;
|
|
1744
|
-
switch (prefixType) {
|
|
1745
|
-
case 0 /* GS1CompanyPrefix */:
|
|
1746
|
-
if (!prefix.startsWith("0")) {
|
|
1747
|
-
baseValidation = _PrefixManager.GS1_COMPANY_PREFIX_VALIDATION;
|
|
1748
|
-
} else if (!prefix.startsWith("00000")) {
|
|
1749
|
-
if (!allowUPCCompanyPrefix) {
|
|
1750
|
-
throw new RangeError(i18nextGS1.t("Prefix.gs1CompanyPrefixCantStartWith0"));
|
|
1751
|
-
}
|
|
1752
|
-
baseValidation = _PrefixManager.UPC_COMPANY_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION;
|
|
1753
|
-
} else if (!prefix.startsWith("000000")) {
|
|
1754
|
-
if (!allowGS18Prefix) {
|
|
1755
|
-
throw new RangeError(i18nextGS1.t("Prefix.gs1CompanyPrefixCantStartWith00000"));
|
|
1756
|
-
}
|
|
1757
|
-
baseValidation = _PrefixManager.GS1_8_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION;
|
|
1758
|
-
} else {
|
|
1759
|
-
throw new RangeError(i18nextGS1.t("Prefix.gs1CompanyPrefixCantStartWith000000"));
|
|
1760
|
-
}
|
|
1761
|
-
break;
|
|
1762
|
-
case 1 /* UPCCompanyPrefix */:
|
|
1763
|
-
if (prefix.startsWith("0000")) {
|
|
1764
|
-
throw new RangeError(i18nextGS1.t("Prefix.upcCompanyPrefixCantStartWith0000"));
|
|
1765
|
-
}
|
|
1766
|
-
baseValidation = _PrefixManager.UPC_COMPANY_PREFIX_VALIDATION;
|
|
1767
|
-
break;
|
|
1768
|
-
case 2 /* GS18Prefix */:
|
|
1769
|
-
if (prefix.startsWith("0")) {
|
|
1770
|
-
throw new RangeError(i18nextGS1.t("Prefix.gs18PrefixCantStartWith0"));
|
|
1771
|
-
}
|
|
1772
|
-
baseValidation = _PrefixManager.GS1_8_PREFIX_VALIDATION;
|
|
1773
|
-
break;
|
|
1774
|
-
}
|
|
1775
|
-
const mergedValidation = {
|
|
1776
|
-
...baseValidation,
|
|
1777
|
-
positionOffset
|
|
1778
|
-
};
|
|
1779
|
-
if (!isFromIdentificationKey) {
|
|
1780
|
-
NUMERIC_CREATOR2.validate(prefix, mergedValidation);
|
|
1781
|
-
} else if (!isNumericIdentificationKey) {
|
|
1782
|
-
NUMERIC_CREATOR2.validate(prefix.substring(0, Math.min(mergedValidation.minimumLength, prefix.length - 1)), mergedValidation);
|
|
1783
|
-
}
|
|
1784
|
-
}
|
|
1785
|
-
/**
|
|
1786
|
-
* Get an identification key creator.
|
|
1787
|
-
*
|
|
1788
|
-
* @param identificationKeyType
|
|
1789
|
-
* Identification key type.
|
|
1790
|
-
*
|
|
1791
|
-
* @param constructorCallback
|
|
1792
|
-
* Constructor callback.
|
|
1793
|
-
*
|
|
1794
|
-
* @returns
|
|
1795
|
-
* Identification key creator.
|
|
1796
|
-
*/
|
|
1797
|
-
getIdentificationKeyCreator(identificationKeyType, constructorCallback) {
|
|
1798
|
-
let creator = this._identificationKeyCreatorsMap.get(identificationKeyType);
|
|
1799
|
-
if (creator === void 0) {
|
|
1800
|
-
if (this.prefixType === 2 /* GS18Prefix */ && identificationKeyType !== "GTIN" /* GTIN */) {
|
|
1801
|
-
throw new RangeError(i18nextGS1.t("Prefix.identificationKeyTypeNotSupportedByGS18Prefix", {
|
|
1802
|
-
identificationKeyType
|
|
1803
|
-
}));
|
|
1804
|
-
}
|
|
1805
|
-
creator = constructorCallback();
|
|
1806
|
-
this.setCreatorTweak(creator);
|
|
1807
|
-
this._identificationKeyCreatorsMap.set(identificationKeyType, creator);
|
|
1808
|
-
}
|
|
1809
|
-
return creator;
|
|
1810
|
-
}
|
|
1811
|
-
/**
|
|
1812
|
-
* Get non-GTIN numeric identification key creator.
|
|
1813
|
-
*
|
|
1814
|
-
* @param validator
|
|
1815
|
-
* Validator on which identification key creator is based.
|
|
1816
|
-
*
|
|
1817
|
-
* @returns
|
|
1818
|
-
* Identification key creator.
|
|
1819
|
-
*/
|
|
1820
|
-
getNonGTINNumericIdentificationKeyCreator(validator) {
|
|
1821
|
-
return this.getIdentificationKeyCreator(validator.identificationKeyType, () => new NonGTINNumericIdentificationKeyCreator(this, validator.identificationKeyType, validator.length, validator.leaderType));
|
|
1822
|
-
}
|
|
1823
|
-
/**
|
|
1824
|
-
* Get serialized numeric identification key creator.
|
|
1825
|
-
*
|
|
1826
|
-
* @param validator
|
|
1827
|
-
* Validator on which identification key creator is based.
|
|
1828
|
-
*
|
|
1829
|
-
* @returns
|
|
1830
|
-
* Identification key creator.
|
|
1831
|
-
*/
|
|
1832
|
-
getSerializableNumericIdentificationKeyCreator(validator) {
|
|
1833
|
-
return this.getIdentificationKeyCreator(validator.identificationKeyType, () => new SerializableNumericIdentificationKeyCreator(this, validator.identificationKeyType, validator.length, validator.serialComponentLength, validator.serialComponentCharacterSet));
|
|
1834
|
-
}
|
|
1835
|
-
/**
|
|
1836
|
-
* Get non-numeric identification key creator.
|
|
1837
|
-
*
|
|
1838
|
-
* @param validator
|
|
1839
|
-
* Validator on which identification key creator is based.
|
|
1840
|
-
*
|
|
1841
|
-
* @returns
|
|
1842
|
-
* Identification key creator.
|
|
1843
|
-
*/
|
|
1844
|
-
getNonNumericIdentificationKeyCreator(validator) {
|
|
1845
|
-
return this.getIdentificationKeyCreator(validator.identificationKeyType, () => new NonNumericIdentificationKeyCreator(this, validator.identificationKeyType, validator.length, validator.referenceCharacterSet, validator.requiresCheckCharacterPair));
|
|
1846
|
-
}
|
|
1847
|
-
/**
|
|
1848
|
-
* Get GTIN creator.
|
|
1849
|
-
*/
|
|
1850
|
-
get gtinCreator() {
|
|
1851
|
-
return this.getIdentificationKeyCreator("GTIN" /* GTIN */, () => {
|
|
1852
|
-
let gtinType;
|
|
1853
|
-
switch (this.prefixType) {
|
|
1854
|
-
case 0 /* GS1CompanyPrefix */:
|
|
1855
|
-
gtinType = 13 /* GTIN13 */;
|
|
1856
|
-
break;
|
|
1857
|
-
case 1 /* UPCCompanyPrefix */:
|
|
1858
|
-
gtinType = 12 /* GTIN12 */;
|
|
1859
|
-
break;
|
|
1860
|
-
case 2 /* GS18Prefix */:
|
|
1861
|
-
gtinType = 8 /* GTIN8 */;
|
|
1862
|
-
break;
|
|
1863
|
-
}
|
|
1864
|
-
return new GTINCreator(this, gtinType);
|
|
1865
|
-
});
|
|
1866
|
-
}
|
|
1867
|
-
/**
|
|
1868
|
-
* Get GLN creator.
|
|
1869
|
-
*/
|
|
1870
|
-
get glnCreator() {
|
|
1871
|
-
return this.getNonGTINNumericIdentificationKeyCreator(GLN_VALIDATOR);
|
|
1872
|
-
}
|
|
1873
|
-
/**
|
|
1874
|
-
* Get SSCC creator.
|
|
1875
|
-
*/
|
|
1876
|
-
get ssccCreator() {
|
|
1877
|
-
return this.getNonGTINNumericIdentificationKeyCreator(SSCC_VALIDATOR);
|
|
1878
|
-
}
|
|
1879
|
-
/**
|
|
1880
|
-
* Get GRAI creator.
|
|
1881
|
-
*/
|
|
1882
|
-
get graiCreator() {
|
|
1883
|
-
return this.getSerializableNumericIdentificationKeyCreator(GRAI_VALIDATOR);
|
|
1884
|
-
}
|
|
1885
|
-
/**
|
|
1886
|
-
* Get GIAI creator.
|
|
1887
|
-
*/
|
|
1888
|
-
get giaiCreator() {
|
|
1889
|
-
return this.getNonNumericIdentificationKeyCreator(GIAI_VALIDATOR);
|
|
1890
|
-
}
|
|
1891
|
-
/**
|
|
1892
|
-
* Get GSRN creator.
|
|
1893
|
-
*/
|
|
1894
|
-
get gsrnCreator() {
|
|
1895
|
-
return this.getNonGTINNumericIdentificationKeyCreator(GSRN_VALIDATOR);
|
|
1896
|
-
}
|
|
1897
|
-
/**
|
|
1898
|
-
* Get GDTI creator.
|
|
1899
|
-
*/
|
|
1900
|
-
get gdtiCreator() {
|
|
1901
|
-
return this.getSerializableNumericIdentificationKeyCreator(GDTI_VALIDATOR);
|
|
1902
|
-
}
|
|
1903
|
-
/**
|
|
1904
|
-
* Get GINC creator.
|
|
1905
|
-
*/
|
|
1906
|
-
get gincCreator() {
|
|
1907
|
-
return this.getNonNumericIdentificationKeyCreator(GINC_VALIDATOR);
|
|
1908
|
-
}
|
|
1909
|
-
/**
|
|
1910
|
-
* Get GSIN creator.
|
|
1911
|
-
*/
|
|
1912
|
-
get gsinCreator() {
|
|
1913
|
-
return this.getNonGTINNumericIdentificationKeyCreator(GSIN_VALIDATOR);
|
|
1914
|
-
}
|
|
1915
|
-
/**
|
|
1916
|
-
* Get GCN creator.
|
|
1917
|
-
*/
|
|
1918
|
-
get gcnCreator() {
|
|
1919
|
-
return this.getSerializableNumericIdentificationKeyCreator(GCN_VALIDATOR);
|
|
1920
|
-
}
|
|
1921
|
-
/**
|
|
1922
|
-
* Get CPID creator.
|
|
1923
|
-
*/
|
|
1924
|
-
get cpidCreator() {
|
|
1925
|
-
return this.getNonNumericIdentificationKeyCreator(CPID_VALIDATOR);
|
|
1926
|
-
}
|
|
1927
|
-
/**
|
|
1928
|
-
* Get GMN creator.
|
|
1929
|
-
*/
|
|
1930
|
-
get gmnCreator() {
|
|
1931
|
-
return this.getNonNumericIdentificationKeyCreator(GMN_VALIDATOR);
|
|
1932
|
-
}
|
|
1933
|
-
};
|
|
1934
|
-
export {
|
|
1935
|
-
AI39_CREATOR,
|
|
1936
|
-
AI82_CREATOR,
|
|
1937
|
-
CPID_VALIDATOR,
|
|
1938
|
-
ContentCharacterSet,
|
|
1939
|
-
GCN_VALIDATOR,
|
|
1940
|
-
GDTI_VALIDATOR,
|
|
1941
|
-
GIAI_VALIDATOR,
|
|
1942
|
-
GINC_VALIDATOR,
|
|
1943
|
-
GLN_VALIDATOR,
|
|
1944
|
-
GMN_VALIDATOR,
|
|
1945
|
-
GRAI_VALIDATOR,
|
|
1946
|
-
GSIN_VALIDATOR,
|
|
1947
|
-
GSRN_VALIDATOR,
|
|
1948
|
-
GTIN12_VALIDATOR,
|
|
1949
|
-
GTIN13_VALIDATOR,
|
|
1950
|
-
GTIN8_VALIDATOR,
|
|
1951
|
-
GTINCreator,
|
|
1952
|
-
GTINLevel,
|
|
1953
|
-
GTINType,
|
|
1954
|
-
GTINValidator,
|
|
1955
|
-
GTIN_VALIDATORS,
|
|
1956
|
-
IdentificationKeyType,
|
|
1957
|
-
LeaderType,
|
|
1958
|
-
NonGTINNumericIdentificationKeyCreator,
|
|
1959
|
-
NonGTINNumericIdentificationKeyValidator,
|
|
1960
|
-
NonNumericIdentificationKeyCreator,
|
|
1961
|
-
NonNumericIdentificationKeyValidator,
|
|
1962
|
-
PrefixManager,
|
|
1963
|
-
PrefixType,
|
|
1964
|
-
SSCC_VALIDATOR,
|
|
1965
|
-
SerializableNumericIdentificationKeyCreator,
|
|
1966
|
-
SerializableNumericIdentificationKeyValidator,
|
|
1967
|
-
checkCharacterPair,
|
|
1968
|
-
checkDigit,
|
|
1969
|
-
checkDigitSum,
|
|
1970
|
-
fiveDigitPriceWeightCheckDigit,
|
|
1971
|
-
fourDigitPriceWeightCheckDigit,
|
|
1972
|
-
gs1NS,
|
|
1973
|
-
gs1Resources,
|
|
1974
|
-
hasValidCheckCharacterPair,
|
|
1975
|
-
hasValidCheckDigit,
|
|
1976
|
-
i18nGS1Init,
|
|
1977
|
-
i18nextGS1
|
|
1978
|
-
};
|
|
1
|
+
import{i18nAssertValidResources as Z,i18nCoreInit as Q}from"@aidc-toolkit/core";import{i18nUtilityInit as j,utilityResources as J}from"@aidc-toolkit/utility";import ee from"i18next";var v={Check:{lengthOfStringForPriceOrWeightMustBeExactly:"Length {{length}} of string for price or weight sum must be exactly {{exactLength}}",priceOrWeightComponent:"price or weight",lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo:"Length {{length}} of string for check character pair must be less than or equal to {{maximumLength}}"},IdentificationKey:{identificationKeyTypeLength:"{{identificationKeyType}} must be {{length}} digits long",invalidCheckDigit:"Invalid check digit",invalidGTINLength:"GTIN must be 13, 12, 8, or 14 digits long",invalidGTIN14Length:"GTIN must be 14 digits long",invalidZeroSuppressedGTIN12:"Invalid zero-suppressed GTIN-12",invalidZeroSuppressibleGTIN12:"GTIN-12 not zero-suppressible",invalidZeroSuppressedGTIN12AsGTIN13:"Invalid zero-suppressed GTIN-12 as GTIN-13",invalidZeroSuppressedGTIN12AsGTIN14:"Invalid zero-suppressed GTIN-12 as GTIN-14",invalidGTIN13AtRetail:"GTIN-13 at retail consumer trade item level can't start with zero",invalidGTINAtRetail:"GTIN not supported at retail consumer trade item level",invalidGTINAtOtherThanRetail:"GTIN not supported at other than retail consumer trade item level",indicatorDigit:"indicator digit",serialComponent:"serial component",reference:"reference",referenceCantBeAllNumeric:"Reference can't be all-numeric",invalidCheckCharacterPair:"Invalid check character pair"},Prefix:{gs1CompanyPrefix:"GS1 Company Prefix",upcCompanyPrefix:"U.P.C. Company Prefix",gs18Prefix:"GS1-8 Prefix",invalidPrefixType:"Invalid prefix type",gs1CompanyPrefixCantStartWith0:`GS1 Company Prefix can't start with "0"`,gs1CompanyPrefixCantStartWith00000:`GS1 Company Prefix can't start with "00000"`,gs1CompanyPrefixCantStartWith000000:`GS1 Company Prefix can't start with "000000"`,upcCompanyPrefixCantStartWith0000:`U.P.C. Company Prefix can't start with "0000"`,gs18PrefixCantStartWith0:`GS1-8 Prefix can't start with "0"`,identificationKeyTypeNotSupportedByGS18Prefix:"{{identificationKeyType}} not supported by GS1-8 Prefix"}};var L={Check:{lengthOfStringForPriceOrWeightMustBeExactly:"La longueur {{longueur}} de la cha\xEEne pour le prix ou la somme du poids doit \xEAtre exactement {{exactLength}}",priceOrWeightComponent:"prix ou poids",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}}"},IdentificationKey:{identificationKeyTypeLength:"{{identificationKeyType}} doit comporter {{length}} chiffres",invalidCheckDigit:"Chiffre de contr\xF4le non valide",invalidGTINLength:"Le GTIN doit comporter 13, 12, 8 ou 14 chiffres",invalidGTIN14Length:"Le GTIN doit comporter 14 chiffres",invalidZeroSuppressedGTIN12:"Code GTIN-12 non valide avec z\xE9ro supprim\xE9",invalidZeroSuppressibleGTIN12:"Le GTIN-12 ne peut pas \xEAtre supprim\xE9 par z\xE9ro",invalidZeroSuppressedGTIN12AsGTIN13:"GTIN-12 non valide avec z\xE9ro supprim\xE9 en tant que GTIN-13",invalidZeroSuppressedGTIN12AsGTIN14:"GTIN-12 non valide avec z\xE9ro supprim\xE9 en tant que GTIN-14",invalidGTIN13AtRetail:"Le GTIN-13 au niveau des articles de consommation au d\xE9tail ne peut pas commencer par z\xE9ro",invalidGTINAtRetail:"Le GTIN n'est pas pris en charge au niveau des articles de consommation au d\xE9tail",invalidGTINAtOtherThanRetail:"Le GTIN n'est pas pris en charge \xE0 d'autres niveaux que ceux des articles de consommation au d\xE9tail",indicatorDigit:"chiffre indicateur",serialComponent:"composant s\xE9rie",reference:"r\xE9f\xE9rence",referenceCantBeAllNumeric:"La r\xE9f\xE9rence ne peut pas \xEAtre enti\xE8rement num\xE9rique",invalidCheckCharacterPair:"Paire de caract\xE8res de contr\xF4le non valide"},Prefix:{gs1CompanyPrefix:"Pr\xE9fixe de l'entreprise GS1",upcCompanyPrefix:"Pr\xE9fixe de l'entreprise U.P.C.",gs18Prefix:"Pr\xE9fixe GS1-8",invalidPrefixType:"Type de pr\xE9fixe invalide",gs1CompanyPrefixCantStartWith0:`Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "0"`,gs1CompanyPrefixCantStartWith00000:`Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "00000"`,gs1CompanyPrefixCantStartWith000000:`Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "000000"`,upcCompanyPrefixCantStartWith0000:`Le pr\xE9fixe de l'entreprise U.P.C. ne peut pas commencer par "0000"`,gs18PrefixCantStartWith0:'Le pr\xE9fixe GS1-8 ne peut pas commencer par "0"',identificationKeyTypeNotSupportedByGS18Prefix:"{{identificationKeyType}} non pris en charge par le pr\xE9fixe GS1-8"}};var te="aidct_gs1";Z(v,"fr",L);var re={en:{aidct_gs1:v},fr:{aidct_gs1:L}},a=ee.createInstance();async function be(n,e=!1){await j(n,e),await Q(a,n,e,te,J,re)}import{CharacterSetCreator as F,Exclusion as U}from"@aidc-toolkit/utility";var x=new F(["!",'"',"%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","_","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],U.AllNumeric),W=new F(["#","-","/","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],U.AllNumeric);import{NUMERIC_CREATOR as y,utilityNS as b}from"@aidc-toolkit/utility";var H=[0,3,6,9,12,15,18,21,24,27],N=[0,2,4,6,8,9,1,3,5,7],$=[0,5,1,6,2,7,3,8,4,9],z=[0,5,9,4,8,3,7,2,6,1],ie=[0,9,7,5,3,1,8,6,4,2];function P(n,e){let t=(e.length+Number(n))%2===0;return y.characterIndexes(e).reduce((r,i,o)=>{if(i===void 0)throw new RangeError(a.t("CharacterSetValidator.invalidCharacterAtPosition",{ns:b,c:e.charAt(o),position:o+1}));return t=!t,r+(t?H[i]:i)},0)}function G(n){return y.character(9-(P(!1,n)+9)%10)}function K(n){return P(!0,n)%10===0}function Y(n,e){if(e.length!==n.length)throw new RangeError(a.t("Check.lengthOfStringForPriceOrWeightMustBeExactly",{length:e.length,exactLength:n.length}));return y.characterIndexes(e).reduce((r,i,o)=>{if(i===void 0)throw new RangeError(a.t("CharacterSetValidator.invalidCharacterAtPositionOfComponent",{ns:b,c:e.charAt(o),position:o+1,component:a.t("Check.priceOrWeightComponent")}));return r+n[o][i]},0)}function De(n){return y.character(Y([N,N,H,z],n)*3%10)}function Fe(n){return y.character(ie[9-(Y([$,N,z,$,N],n)+9)%10])}var E=[107,103,101,97,89,83,79,73,71,67,61,59,53,47,43,41,37,31,29,23,19,17,13,11,7,5,3,2],X=["2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"];function M(n){let e=E.length-n.length;if(e<0)throw new RangeError(a.t("Check.lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo",{length:n.length,maximumLength:E.length}));let t=x.characterIndexes(n).reduce((i,o,s)=>{if(o===void 0)throw new RangeError(a.t("CharacterSetValidator.invalidCharacterAtPosition",{ns:b,c:n.charAt(s),position:s+1}));return i+o*E[e+s]},0)%1021,r=t%32;return X[(t-r)/32]+X[r]}function q(n){let e=n.length-2;return M(n.substring(0,e))===n.substring(e)}import{CharacterSetCreator as ne,Exclusion as D,NUMERIC_CREATOR as d,RegExpValidator as ae,transformIterable as B}from"@aidc-toolkit/utility";import{Mixin as R}from"ts-mixer";var oe=(f=>(f.GTIN="GTIN",f.GLN="GLN",f.SSCC="SSCC",f.GRAI="GRAI",f.GIAI="GIAI",f.GSRN="GSRN",f.GDTI="GDTI",f.GINC="GINC",f.GSIN="GSIN",f.GCN="GCN",f.CPID="CPID",f.GMN="GMN",f))(oe||{}),se=(r=>(r[r.GS1CompanyPrefix=0]="GS1CompanyPrefix",r[r.UPCCompanyPrefix=1]="UPCCompanyPrefix",r[r.GS18Prefix=2]="GS18Prefix",r))(se||{}),ce=(r=>(r[r.Numeric=0]="Numeric",r[r.AI82=1]="AI82",r[r.AI39=2]="AI39",r))(ce||{}),_=class n{static CHARACTER_SET_CREATORS=[d,x,W];_identificationKeyType;_prefixType;_length;_referenceCharacterSet;_referenceCreator;static creatorFor(e){return n.CHARACTER_SET_CREATORS[e]}constructor(e,t,r,i){this._identificationKeyType=e,this._prefixType=t,this._length=r,this._referenceCharacterSet=i,this._referenceCreator=n.creatorFor(i)}get identificationKeyType(){return this._identificationKeyType}get prefixType(){return this._prefixType}get length(){return this._length}get referenceCharacterSet(){return this._referenceCharacterSet}get referenceCreator(){return this._referenceCreator}padIdentificationKey(e,t){return t?.positionOffset===void 0?e:this.referenceCreator.character(0).repeat(t.positionOffset).concat(e)}validatePrefix(e,t){u.validatePrefix(this.prefixType,!0,!1,e,!0,this.referenceCharacterSet===0,t)}},pe=(r=>(r[r.None=0]="None",r[r.IndicatorDigit=1]="IndicatorDigit",r[r.ExtensionDigit=2]="ExtensionDigit",r))(pe||{}),S=class extends _{_leaderType;_prefixPosition;constructor(e,t,r,i){super(e,t,r,0),this._leaderType=i,this._prefixPosition=+(this.leaderType===2)}get leaderType(){return this._leaderType}validate(e,t){if(this._prefixPosition===0?super.validatePrefix(e,t?.positionOffset):super.validatePrefix(e.substring(this._prefixPosition),t?.positionOffset===void 0?this._prefixPosition:t.positionOffset+this._prefixPosition),e.length!==this.length)throw new RangeError(a.t("IdentificationKey.identificationKeyTypeLength",{identificationKeyType:this.identificationKeyType,length:this.length}));if(!K(this.padIdentificationKey(e,t)))throw new RangeError(a.t("IdentificationKey.invalidCheckDigit"))}},fe=(i=>(i[i.GTIN13=13]="GTIN13",i[i.GTIN12=12]="GTIN12",i[i.GTIN8=8]="GTIN8",i[i.GTIN14=14]="GTIN14",i))(fe||{}),de=(r=>(r[r.Any=0]="Any",r[r.RetailConsumer=1]="RetailConsumer",r[r.OtherThanRetailConsumer=2]="OtherThanRetailConsumer",r))(de||{}),g=class n extends S{static OPTIONAL_INDICATOR_DIGIT_VALIDATION={minimumLength:0,maximumLength:1,component:()=>a.t("IdentificationKey.indicatorDigit")};static ZERO_SUPPRESSED_GTIN12_VALIDATION={minimumLength:8,maximumLength:8};constructor(e){let t;switch(e){case 13:t=0;break;case 12:t=1;break;case 8:t=2;break;default:throw new Error("Not supported")}super("GTIN",t,e,1)}get gtinType(){return this.length}validatePrefix(e,t){u.validatePrefix(this.prefixType,!1,!1,e,!0,!0,t)}static zeroSuppress(e){w.validate(e);let t=Array.from(e),r;if(t[0]==="0"&&t[6]==="0"&&t[7]==="0"&&(t[10]>="5"&&t[8]==="0"&&t[9]==="0"&&t[5]!=="0"?r=`0${t[1]}${t[2]}${t[3]}${t[4]}${t[5]}${t[10]}${t[11]}`:t[5]==="0"&&t[8]==="0"&&t[9]==="0"&&t[4]!=="0"?r=`0${t[1]}${t[2]}${t[3]}${t[4]}${t[10]}4${t[11]}`:t[3]<="2"&&t[4]==="0"&&t[5]==="0"?r=`0${t[1]}${t[2]}${t[8]}${t[9]}${t[10]}${t[3]}${t[11]}`:t[3]>="3"&&t[4]==="0"&&t[5]==="0"&&t[8]==="0"&&(r=`0${t[1]}${t[2]}${t[3]}${t[9]}${t[10]}3${t[11]}`)),r===void 0)throw new RangeError(a.t("IdentificationKey.invalidZeroSuppressibleGTIN12"));return r}static zeroExpand(e){d.validate(e,n.ZERO_SUPPRESSED_GTIN12_VALIDATION);let t=Array.from(e),r;if(t[0]==="0"&&(t[6]>="5"&&t[5]!=="0"?r=`0${t[1]}${t[2]}${t[3]}${t[4]}${t[5]}0000${t[6]}${t[7]}`:t[6]==="4"&&t[4]!=="0"?r=`0${t[1]}${t[2]}${t[3]}${t[4]}00000${t[5]}${t[7]}`:t[6]<="2"?r=`0${t[1]}${t[2]}${t[6]}0000${t[3]}${t[4]}${t[5]}${t[7]}`:t[6]==="3"&&t[3]>="3"&&(r=`0${t[1]}${t[2]}${t[3]}00000${t[4]}${t[5]}${t[7]}`)),r===void 0)throw new RangeError(a.t("IdentificationKey.invalidZeroSuppressedGTIN12"));return w.validate(r),r}static convertToGTIN14(e,t){T.validateAny(t),d.validate(e,n.OPTIONAL_INDICATOR_DIGIT_VALIDATION);let r=t.length,i="0".repeat(14-r)+t;if(e.length!==0&&e!==i.charAt(0)){let o=e+i.substring(1,13);i=o+G(o)}return i}static normalize(e){let t=e.length,r;switch(t){case 13:if(!e.startsWith("0"))r=e;else if(!e.startsWith("00000"))r=e.substring(1);else if(!e.startsWith("000000"))r=e.substring(5);else throw new RangeError(a.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN13"));break;case 12:r=e;break;case 8:e.startsWith("0")?r=n.zeroExpand(e):r=e;break;case 14:if(!e.startsWith("0"))r=e;else if(!e.startsWith("00"))r=e.substring(1);else if(!e.startsWith("000000"))r=e.substring(2);else if(!e.startsWith("0000000"))r=e.substring(6);else throw new RangeError(a.t("IdentificationKey.invalidZeroSuppressedGTIN12AsGTIN14"));break;default:throw new RangeError(a.t("IdentificationKey.invalidGTINLength"))}return T.validateAny(r),r}static validateAny(e,t=0){let r=e,i;switch(e.length){case 13:if(e.startsWith("0"))throw new RangeError(a.t("IdentificationKey.invalidGTIN13AtRetail"));u.validatePrefix(0,!1,!1,e,!0,!0),i=0;break;case 12:u.validatePrefix(1,!1,!1,e,!0,!0),i=0;break;case 8:e.startsWith("0")?r=n.zeroExpand(e):u.validatePrefix(2,!1,!1,e,!0,!0),i=1;break;case 14:u.validatePrefix(0,!0,!0,e.substring(1),!0,!0),i=2;break;default:throw new RangeError(a.t("IdentificationKey.invalidGTINLength"))}if(!K(r))throw new RangeError(a.t("IdentificationKey.invalidCheckDigit"));if(t!==0&&i!==0&&i!==t)throw new RangeError(a.t(t===1?"IdentificationKey.invalidGTINAtRetail":"IdentificationKey.invalidGTINAtOtherThanRetail"))}static validateGTIN14(e){if(e.length!==14)throw new RangeError(a.t("IdentificationKey.invalidGTIN14Length"));T.validateAny(e)}},h=class extends S{constructor(e,t,r=0){super(e,0,t,r)}},m=class n extends h{_serialComponentLength;_serialComponentCharacterSet;_serialComponentValidation;_serialComponentCreator;constructor(e,t,r,i){super(e,t,0),this._serialComponentLength=r,this._serialComponentCharacterSet=i,this._serialComponentValidation={minimumLength:1,maximumLength:r,component:()=>a.t("IdentificationKey.serialComponent")},this._serialComponentCreator=n.creatorFor(i)}get serialComponentLength(){return this._serialComponentLength}get serialComponentCharacterSet(){return this._serialComponentCharacterSet}get serialComponentValidation(){return this._serialComponentValidation}get serialComponentCreator(){return this._serialComponentCreator}validate(e,t){super.validate(e.substring(0,this.length),t),e.length>this.length&&this.serialComponentCreator.validate(e.substring(this.length),this._serialComponentValidation)}},I=class n extends _{static NOT_ALL_NUMERIC_VALIDATOR=new class extends ae{createErrorMessage(e){return a.t("IdentificationKey.referenceCantBeAllNumeric")}}(/\D/);_requiresCheckCharacterPair;constructor(e,t,r,i=!1){super(e,0,t,r),this._requiresCheckCharacterPair=i}get requiresCheckCharacterPair(){return this._requiresCheckCharacterPair}validate(e,t){let r=this.requiresCheckCharacterPair?e.substring(0,e.length-2):e;if(super.validatePrefix(r,t?.positionOffset),!this.requiresCheckCharacterPair)this.referenceCreator.validate(e,{maximumLength:this.length,positionOffset:t?.positionOffset});else if(!q(this.padIdentificationKey(e,t)))throw new RangeError(a.t("IdentificationKey.invalidCheckCharacterPair"));t?.exclusion===D.AllNumeric&&n.NOT_ALL_NUMERIC_VALIDATOR.validate(r)}},le=new g(13),w=new g(12),ue=new g(8),Ye=[le,w,ue],he=new h("GLN",13),Ie=new h("SSCC",18,2),Te=new m("GRAI",13,16,1),ge=new I("GIAI",30,1),me=new h("GSRN",18),ye=new m("GDTI",13,17,1),Ce=new I("GINC",30,1),xe=new h("GSIN",17),Ne=new m("GCN",13,12,0),Pe=new I("CPID",30,2),Ge=new I("GMN",25,1,!0),A=class{_prefixManager;_referenceLength;init(e,t,r){this._prefixManager=e,this._referenceLength=this.length-t.length-r}get prefixManager(){return this._prefixManager}get prefix(){return this.prefixManager.gs1CompanyPrefix}get referenceLength(){return this._referenceLength}},C=class n extends A{_capacity;_tweak=0n;init(e,t){super.init(e,t,1),this._capacity=Number(ne.powerOf10(this.referenceLength))}get capacity(){return this._capacity}get tweak(){return this._tweak}set tweak(e){this._tweak=e}buildIdentificationKey(e){let t=this.leaderType===2?e.substring(0,1)+this.prefix+e.substring(1):this.prefix+e;return t+G(t)}create(e,t=!1){return d.create(this.referenceLength,e,D.None,t?this.tweak:void 0,r=>this.buildIdentificationKey(r))}static*createAllPartial(e,t,r,i,o){if(t===0)yield e+d.character(9-(o+9)%10);else{let s=t-1,p=o;if(r!==0)for(let c of d.characterSet)yield*n.createAllPartial(c+e,s,0,i,p),p+=r;else{let c=4-i;for(let l of d.characterSet)yield*n.createAllPartial(e+l,s,0,c,p),p+=i}}}createAll(){let e=this.leaderType===2,t=this.prefix,r=this.length,i=this.referenceLength,o=3-2*((i+1-Number(e))%2);return{[Symbol.iterator](){return n.createAllPartial(t,i,e?3-2*r%2:0,o,P(o===3,t))}}}},T=class n extends R(g,C){static REQUIRED_INDICATOR_DIGIT_VALIDATION={minimumLength:1,maximumLength:1,component:()=>a.t("IdentificationKey.indicatorDigit")};constructor(e,t){super(t),this.init(e,e.prefix)}get prefix(){return this.prefixManager.prefix}createGTIN14(e,t,r=!1){return d.validate(e,n.REQUIRED_INDICATOR_DIGIT_VALIDATION),d.create(13-this.prefixManager.gs1CompanyPrefix.length-1,t,D.None,r?this.tweak:void 0,i=>{let o=e+this.prefixManager.gs1CompanyPrefix+i;return o+G(o)})}},O=class extends R(h,C){constructor(e,t,r,i=0){super(t,r,i),this.init(e,e.gs1CompanyPrefix)}},V=class extends R(m,C){constructor(e,t,r,i,o){super(t,r,i,o),this.init(e,e.gs1CompanyPrefix)}concatenateValidated(e,t){let r,i=this.serialComponentCreator,o=this.serialComponentValidation;function s(p){return i.validate(p,o),e+p}return typeof t!="object"?r=s(t):r=B(t,s),r}createSerialized(e,t,r){return this.concatenateValidated(this.create(e,r),t)}concatenate(e,t){return this.validate(e),this.concatenateValidated(e,t)}},k=class extends R(I,A){_referenceValidation;constructor(e,t,r,i,o=!1){super(t,r,i,o),this.init(e,e.gs1CompanyPrefix,2*Number(o)),this._referenceValidation={minimumLength:1,maximumLength:this.referenceLength,component:()=>a.t("IdentificationKey.reference")}}get referenceValidation(){return this._referenceValidation}create(e){let t,r=this.referenceCreator,i=this.referenceValidation,o=this.prefix,s=this.requiresCheckCharacterPair;function p(c){r.validate(c,i);let l=o+c;return s?l+M(l):l}return typeof e!="object"?t=p(e):t=B(e,p),t}},u=class n{static PREFIX_MANAGERS_MAP=new Map;static GS1_COMPANY_PREFIX_MINIMUM_LENGTH=4;static GS1_COMPANY_PREFIX_MAXIMUM_LENGTH=12;static UPC_COMPANY_PREFIX_MINIMUM_LENGTH=6;static UPC_COMPANY_PREFIX_MAXIMUM_LENGTH=11;static GS1_8_PREFIX_MINIMUM_LENGTH=2;static GS1_8_PREFIX_MAXIMUM_LENGTH=7;static GS1_COMPANY_PREFIX_VALIDATION={minimumLength:n.GS1_COMPANY_PREFIX_MINIMUM_LENGTH,maximumLength:n.GS1_COMPANY_PREFIX_MAXIMUM_LENGTH,component:()=>a.t("Prefix.gs1CompanyPrefix")};static UPC_COMPANY_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION={minimumLength:n.UPC_COMPANY_PREFIX_MINIMUM_LENGTH+1,maximumLength:n.UPC_COMPANY_PREFIX_MAXIMUM_LENGTH+1,component:()=>a.t("Prefix.gs1CompanyPrefix")};static GS1_8_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION={minimumLength:n.GS1_8_PREFIX_MINIMUM_LENGTH+5,maximumLength:n.GS1_8_PREFIX_MAXIMUM_LENGTH+5,component:()=>a.t("Prefix.gs1CompanyPrefix")};static UPC_COMPANY_PREFIX_VALIDATION={minimumLength:n.UPC_COMPANY_PREFIX_MINIMUM_LENGTH,maximumLength:n.UPC_COMPANY_PREFIX_MAXIMUM_LENGTH,component:()=>a.t("Prefix.upcCompanyPrefix")};static GS1_8_PREFIX_VALIDATION={minimumLength:n.GS1_8_PREFIX_MINIMUM_LENGTH,maximumLength:n.GS1_8_PREFIX_MAXIMUM_LENGTH,component:()=>a.t("Prefix.gs18Prefix")};static CREATOR_TWEAK_FACTORS_MAP=new Map([["GTIN",1987n],["GLN",4241n],["SSCC",8087n],["GRAI",3221n],["GSRN",2341n],["GDTI",7333n],["GSIN",5623n],["GCN",6869n]]);_prefixType;_prefix;_gs1CompanyPrefix;_upcCompanyPrefix;_gs18Prefix;_defaultTweakFactor;_tweakFactor=0n;_identificationKeyCreatorsMap=new Map;constructor(e){this._gs1CompanyPrefix=e,e.startsWith("0")?e.startsWith("00000")?(this._prefixType=2,this._gs18Prefix=e.substring(5),this._prefix=this._gs18Prefix):(this._prefixType=1,this._upcCompanyPrefix=e.substring(1),this._prefix=this._upcCompanyPrefix):(this._prefixType=0,this._prefix=this._gs1CompanyPrefix),this._defaultTweakFactor=BigInt(`1${this.gs1CompanyPrefix}`),this.resetTweakFactor()}get prefixType(){return this._prefixType}get prefix(){return this._prefix}get gs1CompanyPrefix(){return this._gs1CompanyPrefix}get upcCompanyPrefix(){return this._upcCompanyPrefix}get gs18Prefix(){return this._gs18Prefix}setCreatorTweak(e){let t=n.CREATOR_TWEAK_FACTORS_MAP.get(e.identificationKeyType);t!==void 0&&(e.tweak=this.tweakFactor*t)}get tweakFactor(){return this._tweakFactor}set tweakFactor(e){let t=BigInt(e);if(this._tweakFactor!==t){this._tweakFactor=t;for(let r of this._identificationKeyCreatorsMap.values())this.setCreatorTweak(r)}}resetTweakFactor(){this.tweakFactor=this._defaultTweakFactor}static get(e,t){n.validatePrefix(e,!0,!0,t);let r;switch(e){case 0:r=t;break;case 1:r="0"+t;break;case 2:r="00000"+t;break;default:throw new RangeError(a.t("Prefix.invalidPrefixType"))}let i=n.PREFIX_MANAGERS_MAP.get(r);return i===void 0&&(i=new n(r),n.PREFIX_MANAGERS_MAP.set(r,i)),i}static validatePrefix(e,t,r,i,o=!1,s=!1,p){let c;switch(e){case 0:if(!i.startsWith("0"))c=n.GS1_COMPANY_PREFIX_VALIDATION;else if(i.startsWith("00000")){if(i.startsWith("000000"))throw new RangeError(a.t("Prefix.gs1CompanyPrefixCantStartWith000000"));if(!r)throw new RangeError(a.t("Prefix.gs1CompanyPrefixCantStartWith00000"));c=n.GS1_8_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION}else{if(!t)throw new RangeError(a.t("Prefix.gs1CompanyPrefixCantStartWith0"));c=n.UPC_COMPANY_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION}break;case 1:if(i.startsWith("0000"))throw new RangeError(a.t("Prefix.upcCompanyPrefixCantStartWith0000"));c=n.UPC_COMPANY_PREFIX_VALIDATION;break;case 2:if(i.startsWith("0"))throw new RangeError(a.t("Prefix.gs18PrefixCantStartWith0"));c=n.GS1_8_PREFIX_VALIDATION;break}let l={...c,positionOffset:p};o?s||d.validate(i.substring(0,Math.min(l.minimumLength,i.length-1)),l):d.validate(i,l)}getIdentificationKeyCreator(e,t){let r=this._identificationKeyCreatorsMap.get(e);if(r===void 0){if(this.prefixType===2&&e!=="GTIN")throw new RangeError(a.t("Prefix.identificationKeyTypeNotSupportedByGS18Prefix",{identificationKeyType:e}));r=t(),this.setCreatorTweak(r),this._identificationKeyCreatorsMap.set(e,r)}return r}getNonGTINNumericIdentificationKeyCreator(e){return this.getIdentificationKeyCreator(e.identificationKeyType,()=>new O(this,e.identificationKeyType,e.length,e.leaderType))}getSerializableNumericIdentificationKeyCreator(e){return this.getIdentificationKeyCreator(e.identificationKeyType,()=>new V(this,e.identificationKeyType,e.length,e.serialComponentLength,e.serialComponentCharacterSet))}getNonNumericIdentificationKeyCreator(e){return this.getIdentificationKeyCreator(e.identificationKeyType,()=>new k(this,e.identificationKeyType,e.length,e.referenceCharacterSet,e.requiresCheckCharacterPair))}get gtinCreator(){return this.getIdentificationKeyCreator("GTIN",()=>{let e;switch(this.prefixType){case 0:e=13;break;case 1:e=12;break;case 2:e=8;break}return new T(this,e)})}get glnCreator(){return this.getNonGTINNumericIdentificationKeyCreator(he)}get ssccCreator(){return this.getNonGTINNumericIdentificationKeyCreator(Ie)}get graiCreator(){return this.getSerializableNumericIdentificationKeyCreator(Te)}get giaiCreator(){return this.getNonNumericIdentificationKeyCreator(ge)}get gsrnCreator(){return this.getNonGTINNumericIdentificationKeyCreator(me)}get gdtiCreator(){return this.getSerializableNumericIdentificationKeyCreator(ye)}get gincCreator(){return this.getNonNumericIdentificationKeyCreator(Ce)}get gsinCreator(){return this.getNonGTINNumericIdentificationKeyCreator(xe)}get gcnCreator(){return this.getSerializableNumericIdentificationKeyCreator(Ne)}get cpidCreator(){return this.getNonNumericIdentificationKeyCreator(Pe)}get gmnCreator(){return this.getNonNumericIdentificationKeyCreator(Ge)}};export{W as AI39_CREATOR,x as AI82_CREATOR,Pe as CPID_VALIDATOR,ce as ContentCharacterSet,Ne as GCN_VALIDATOR,ye as GDTI_VALIDATOR,ge as GIAI_VALIDATOR,Ce as GINC_VALIDATOR,he as GLN_VALIDATOR,Ge as GMN_VALIDATOR,Te as GRAI_VALIDATOR,xe as GSIN_VALIDATOR,me as GSRN_VALIDATOR,w as GTIN12_VALIDATOR,le as GTIN13_VALIDATOR,ue as GTIN8_VALIDATOR,T as GTINCreator,de as GTINLevel,fe as GTINType,g as GTINValidator,Ye as GTIN_VALIDATORS,oe as IdentificationKeyType,pe as LeaderType,O as NonGTINNumericIdentificationKeyCreator,h as NonGTINNumericIdentificationKeyValidator,k as NonNumericIdentificationKeyCreator,I as NonNumericIdentificationKeyValidator,u as PrefixManager,se as PrefixType,Ie as SSCC_VALIDATOR,V as SerializableNumericIdentificationKeyCreator,m as SerializableNumericIdentificationKeyValidator,M as checkCharacterPair,G as checkDigit,P as checkDigitSum,Fe as fiveDigitPriceWeightCheckDigit,De as fourDigitPriceWeightCheckDigit,te as gs1NS,re as gs1Resources,q as hasValidCheckCharacterPair,K as hasValidCheckDigit,be as i18nGS1Init,a as i18nextGS1};
|
|
1979
2
|
/*!
|
|
1980
3
|
* Copyright © 2024-2025 Dolphin Data Development Ltd. and AIDC Toolkit
|
|
1981
4
|
* contributors
|