@mapomodule/uikit 1.0.0-alpha.54 → 1.0.0-alpha.55

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.
Files changed (62) hide show
  1. package/.playground/.nuxt/app.config.mjs +18 -0
  2. package/.playground/.nuxt/component-chunk.mjs +1 -0
  3. package/.playground/.nuxt/components.d.ts +174 -0
  4. package/.playground/.nuxt/dev/index.mjs +2245 -0
  5. package/.playground/.nuxt/dev/index.mjs.map +1 -0
  6. package/.playground/.nuxt/dist/server/client.manifest.json +18 -0
  7. package/.playground/.nuxt/dist/server/client.manifest.mjs +1 -0
  8. package/.playground/.nuxt/dist/server/server.mjs +1 -0
  9. package/.playground/.nuxt/eslint.config.d.mts +9 -0
  10. package/.playground/.nuxt/eslint.config.mjs +53 -0
  11. package/.playground/.nuxt/i18n.options.mjs +212 -0
  12. package/.playground/.nuxt/imports.d.ts +40 -0
  13. package/.playground/.nuxt/manifest/latest.json +1 -0
  14. package/.playground/.nuxt/manifest/meta/b92b330e-90fa-4e57-8491-c880cac75e65.json +1 -0
  15. package/.playground/.nuxt/manifest/meta/dev.json +1 -0
  16. package/.playground/.nuxt/nitro.json +17 -0
  17. package/.playground/.nuxt/nuxt-i18n-logger.mjs +1 -0
  18. package/.playground/.nuxt/nuxt.d.ts +35 -0
  19. package/.playground/.nuxt/nuxt.json +9 -0
  20. package/.playground/.nuxt/schema/nuxt.schema.d.ts +17 -0
  21. package/.playground/.nuxt/schema/nuxt.schema.json +3 -0
  22. package/.playground/.nuxt/tsconfig.json +255 -0
  23. package/.playground/.nuxt/tsconfig.server.json +174 -0
  24. package/.playground/.nuxt/types/app-defaults.d.ts +7 -0
  25. package/.playground/.nuxt/types/app.config.d.ts +31 -0
  26. package/.playground/.nuxt/types/build.d.ts +26 -0
  27. package/.playground/.nuxt/types/builder-env.d.ts +1 -0
  28. package/.playground/.nuxt/types/i18n-plugin.d.ts +104 -0
  29. package/.playground/.nuxt/types/imports.d.ts +415 -0
  30. package/.playground/.nuxt/types/layouts.d.ts +7 -0
  31. package/.playground/.nuxt/types/middleware.d.ts +7 -0
  32. package/.playground/.nuxt/types/nitro-config.d.ts +14 -0
  33. package/.playground/.nuxt/types/nitro-imports.d.ts +144 -0
  34. package/.playground/.nuxt/types/nitro-middleware.d.ts +6 -0
  35. package/.playground/.nuxt/types/nitro-nuxt.d.ts +34 -0
  36. package/.playground/.nuxt/types/nitro-routes.d.ts +14 -0
  37. package/.playground/.nuxt/types/nitro.d.ts +3 -0
  38. package/.playground/.nuxt/types/plugins.d.ts +49 -0
  39. package/.playground/.nuxt/types/schema.d.ts +264 -0
  40. package/.playground/.nuxt/types/vue-shim.d.ts +0 -0
  41. package/.playground/node_modules/.cache/jiti/.playground-nuxt.config.3bd7bec1.mjs +16 -0
  42. package/.playground/node_modules/.cache/jiti/core-nuxt.config.d02cc970.mjs +5 -0
  43. package/.playground/node_modules/.cache/jiti/defaults-i18n.72ef2ce7.mjs +39 -0
  44. package/.playground/node_modules/.cache/jiti/src-module.93ea0fdf.mjs +23 -0
  45. package/.playground/node_modules/.cache/jiti/uikit-nuxt.config.c75a491b.mjs +25 -0
  46. package/.playground/node_modules/.cache/vite/client/deps/@intlify_core-base.js +3278 -0
  47. package/.playground/node_modules/.cache/vite/client/deps/@intlify_core-base.js.map +7 -0
  48. package/.playground/node_modules/.cache/vite/client/deps/@intlify_shared.js +70 -0
  49. package/.playground/node_modules/.cache/vite/client/deps/@intlify_shared.js.map +7 -0
  50. package/.playground/node_modules/.cache/vite/client/deps/_metadata.json +43 -0
  51. package/.playground/node_modules/.cache/vite/client/deps/chunk-XHSPHVXN.js +208 -0
  52. package/.playground/node_modules/.cache/vite/client/deps/chunk-XHSPHVXN.js.map +7 -0
  53. package/.playground/node_modules/.cache/vite/client/deps/is-https.js +22 -0
  54. package/.playground/node_modules/.cache/vite/client/deps/is-https.js.map +7 -0
  55. package/.playground/node_modules/.cache/vite/client/deps/js-cookie.js +106 -0
  56. package/.playground/node_modules/.cache/vite/client/deps/js-cookie.js.map +7 -0
  57. package/.playground/node_modules/.cache/vite/client/deps/package.json +3 -0
  58. package/.playground/node_modules/.cache/vite/client/deps/pinia.js +1451 -0
  59. package/.playground/node_modules/.cache/vite/client/deps/pinia.js.map +7 -0
  60. package/CHANGELOG.md +11 -0
  61. package/components/MenuManager/MenuNodeEditor.vue +7 -5
  62. package/package.json +2 -2
@@ -0,0 +1,3278 @@
1
+ import {
2
+ assign,
3
+ create,
4
+ escapeHtml,
5
+ format,
6
+ generateCodeFrame,
7
+ generateFormatCacheKey,
8
+ getGlobalThis,
9
+ hasOwn,
10
+ inBrowser,
11
+ isArray,
12
+ isBoolean,
13
+ isDate,
14
+ isEmptyObject,
15
+ isFunction,
16
+ isNumber,
17
+ isObject,
18
+ isPlainObject,
19
+ isPromise,
20
+ isRegExp,
21
+ isString,
22
+ join,
23
+ mark,
24
+ measure,
25
+ toDisplayString,
26
+ warn,
27
+ warnOnce
28
+ } from "./chunk-XHSPHVXN.js";
29
+
30
+ // ../../../node_modules/.pnpm/@intlify+message-compiler@11.1.5/node_modules/@intlify/message-compiler/dist/message-compiler.mjs
31
+ function createPosition(line, column, offset) {
32
+ return { line, column, offset };
33
+ }
34
+ function createLocation(start, end, source) {
35
+ const loc = { start, end };
36
+ if (source != null) {
37
+ loc.source = source;
38
+ }
39
+ return loc;
40
+ }
41
+ var CompileErrorCodes = {
42
+ // tokenizer error codes
43
+ EXPECTED_TOKEN: 1,
44
+ INVALID_TOKEN_IN_PLACEHOLDER: 2,
45
+ UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3,
46
+ UNKNOWN_ESCAPE_SEQUENCE: 4,
47
+ INVALID_UNICODE_ESCAPE_SEQUENCE: 5,
48
+ UNBALANCED_CLOSING_BRACE: 6,
49
+ UNTERMINATED_CLOSING_BRACE: 7,
50
+ EMPTY_PLACEHOLDER: 8,
51
+ NOT_ALLOW_NEST_PLACEHOLDER: 9,
52
+ INVALID_LINKED_FORMAT: 10,
53
+ // parser error codes
54
+ MUST_HAVE_MESSAGES_IN_PLURAL: 11,
55
+ UNEXPECTED_EMPTY_LINKED_MODIFIER: 12,
56
+ UNEXPECTED_EMPTY_LINKED_KEY: 13,
57
+ UNEXPECTED_LEXICAL_ANALYSIS: 14,
58
+ // generator error codes
59
+ UNHANDLED_CODEGEN_NODE_TYPE: 15,
60
+ // minifier error codes
61
+ UNHANDLED_MINIFIER_NODE_TYPE: 16
62
+ };
63
+ var COMPILE_ERROR_CODES_EXTEND_POINT = 17;
64
+ var errorMessages = {
65
+ // tokenizer error messages
66
+ [CompileErrorCodes.EXPECTED_TOKEN]: `Expected token: '{0}'`,
67
+ [CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]: `Invalid token in placeholder: '{0}'`,
68
+ [CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]: `Unterminated single quote in placeholder`,
69
+ [CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]: `Unknown escape sequence: \\{0}`,
70
+ [CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]: `Invalid unicode escape sequence: {0}`,
71
+ [CompileErrorCodes.UNBALANCED_CLOSING_BRACE]: `Unbalanced closing brace`,
72
+ [CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]: `Unterminated closing brace`,
73
+ [CompileErrorCodes.EMPTY_PLACEHOLDER]: `Empty placeholder`,
74
+ [CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]: `Not allowed nest placeholder`,
75
+ [CompileErrorCodes.INVALID_LINKED_FORMAT]: `Invalid linked format`,
76
+ // parser error messages
77
+ [CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]: `Plural must have messages`,
78
+ [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]: `Unexpected empty linked modifier`,
79
+ [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]: `Unexpected empty linked key`,
80
+ [CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]: `Unexpected lexical analysis in token: '{0}'`,
81
+ // generator error messages
82
+ [CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE]: `unhandled codegen node type: '{0}'`,
83
+ // minimizer error messages
84
+ [CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE]: `unhandled mimifier node type: '{0}'`
85
+ };
86
+ function createCompileError(code, loc, options = {}) {
87
+ const { domain, messages, args } = options;
88
+ const msg = true ? format((messages || errorMessages)[code] || "", ...args || []) : code;
89
+ const error = new SyntaxError(String(msg));
90
+ error.code = code;
91
+ if (loc) {
92
+ error.location = loc;
93
+ }
94
+ error.domain = domain;
95
+ return error;
96
+ }
97
+ function defaultOnError(error) {
98
+ throw error;
99
+ }
100
+ var RE_HTML_TAG = /<\/?[\w\s="/.':;#-\/]+>/;
101
+ var detectHtmlTag = (source) => RE_HTML_TAG.test(source);
102
+ var CHAR_SP = " ";
103
+ var CHAR_CR = "\r";
104
+ var CHAR_LF = "\n";
105
+ var CHAR_LS = String.fromCharCode(8232);
106
+ var CHAR_PS = String.fromCharCode(8233);
107
+ function createScanner(str) {
108
+ const _buf = str;
109
+ let _index = 0;
110
+ let _line = 1;
111
+ let _column = 1;
112
+ let _peekOffset = 0;
113
+ const isCRLF = (index2) => _buf[index2] === CHAR_CR && _buf[index2 + 1] === CHAR_LF;
114
+ const isLF = (index2) => _buf[index2] === CHAR_LF;
115
+ const isPS = (index2) => _buf[index2] === CHAR_PS;
116
+ const isLS = (index2) => _buf[index2] === CHAR_LS;
117
+ const isLineEnd = (index2) => isCRLF(index2) || isLF(index2) || isPS(index2) || isLS(index2);
118
+ const index = () => _index;
119
+ const line = () => _line;
120
+ const column = () => _column;
121
+ const peekOffset = () => _peekOffset;
122
+ const charAt = (offset) => isCRLF(offset) || isPS(offset) || isLS(offset) ? CHAR_LF : _buf[offset];
123
+ const currentChar = () => charAt(_index);
124
+ const currentPeek = () => charAt(_index + _peekOffset);
125
+ function next() {
126
+ _peekOffset = 0;
127
+ if (isLineEnd(_index)) {
128
+ _line++;
129
+ _column = 0;
130
+ }
131
+ if (isCRLF(_index)) {
132
+ _index++;
133
+ }
134
+ _index++;
135
+ _column++;
136
+ return _buf[_index];
137
+ }
138
+ function peek() {
139
+ if (isCRLF(_index + _peekOffset)) {
140
+ _peekOffset++;
141
+ }
142
+ _peekOffset++;
143
+ return _buf[_index + _peekOffset];
144
+ }
145
+ function reset() {
146
+ _index = 0;
147
+ _line = 1;
148
+ _column = 1;
149
+ _peekOffset = 0;
150
+ }
151
+ function resetPeek(offset = 0) {
152
+ _peekOffset = offset;
153
+ }
154
+ function skipToPeek() {
155
+ const target = _index + _peekOffset;
156
+ while (target !== _index) {
157
+ next();
158
+ }
159
+ _peekOffset = 0;
160
+ }
161
+ return {
162
+ index,
163
+ line,
164
+ column,
165
+ peekOffset,
166
+ charAt,
167
+ currentChar,
168
+ currentPeek,
169
+ next,
170
+ peek,
171
+ reset,
172
+ resetPeek,
173
+ skipToPeek
174
+ };
175
+ }
176
+ var EOF = void 0;
177
+ var DOT = ".";
178
+ var LITERAL_DELIMITER = "'";
179
+ var ERROR_DOMAIN$3 = "tokenizer";
180
+ function createTokenizer(source, options = {}) {
181
+ const location = options.location !== false;
182
+ const _scnr = createScanner(source);
183
+ const currentOffset = () => _scnr.index();
184
+ const currentPosition = () => createPosition(_scnr.line(), _scnr.column(), _scnr.index());
185
+ const _initLoc = currentPosition();
186
+ const _initOffset = currentOffset();
187
+ const _context = {
188
+ currentType: 13,
189
+ offset: _initOffset,
190
+ startLoc: _initLoc,
191
+ endLoc: _initLoc,
192
+ lastType: 13,
193
+ lastOffset: _initOffset,
194
+ lastStartLoc: _initLoc,
195
+ lastEndLoc: _initLoc,
196
+ braceNest: 0,
197
+ inLinked: false,
198
+ text: ""
199
+ };
200
+ const context = () => _context;
201
+ const { onError } = options;
202
+ function emitError(code, pos, offset, ...args) {
203
+ const ctx = context();
204
+ pos.column += offset;
205
+ pos.offset += offset;
206
+ if (onError) {
207
+ const loc = location ? createLocation(ctx.startLoc, pos) : null;
208
+ const err = createCompileError(code, loc, {
209
+ domain: ERROR_DOMAIN$3,
210
+ args
211
+ });
212
+ onError(err);
213
+ }
214
+ }
215
+ function getToken(context2, type, value) {
216
+ context2.endLoc = currentPosition();
217
+ context2.currentType = type;
218
+ const token = { type };
219
+ if (location) {
220
+ token.loc = createLocation(context2.startLoc, context2.endLoc);
221
+ }
222
+ if (value != null) {
223
+ token.value = value;
224
+ }
225
+ return token;
226
+ }
227
+ const getEndToken = (context2) => getToken(
228
+ context2,
229
+ 13
230
+ /* TokenTypes.EOF */
231
+ );
232
+ function eat(scnr, ch) {
233
+ if (scnr.currentChar() === ch) {
234
+ scnr.next();
235
+ return ch;
236
+ } else {
237
+ emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch);
238
+ return "";
239
+ }
240
+ }
241
+ function peekSpaces(scnr) {
242
+ let buf = "";
243
+ while (scnr.currentPeek() === CHAR_SP || scnr.currentPeek() === CHAR_LF) {
244
+ buf += scnr.currentPeek();
245
+ scnr.peek();
246
+ }
247
+ return buf;
248
+ }
249
+ function skipSpaces(scnr) {
250
+ const buf = peekSpaces(scnr);
251
+ scnr.skipToPeek();
252
+ return buf;
253
+ }
254
+ function isIdentifierStart(ch) {
255
+ if (ch === EOF) {
256
+ return false;
257
+ }
258
+ const cc = ch.charCodeAt(0);
259
+ return cc >= 97 && cc <= 122 || // a-z
260
+ cc >= 65 && cc <= 90 || // A-Z
261
+ cc === 95;
262
+ }
263
+ function isNumberStart(ch) {
264
+ if (ch === EOF) {
265
+ return false;
266
+ }
267
+ const cc = ch.charCodeAt(0);
268
+ return cc >= 48 && cc <= 57;
269
+ }
270
+ function isNamedIdentifierStart(scnr, context2) {
271
+ const { currentType } = context2;
272
+ if (currentType !== 2) {
273
+ return false;
274
+ }
275
+ peekSpaces(scnr);
276
+ const ret = isIdentifierStart(scnr.currentPeek());
277
+ scnr.resetPeek();
278
+ return ret;
279
+ }
280
+ function isListIdentifierStart(scnr, context2) {
281
+ const { currentType } = context2;
282
+ if (currentType !== 2) {
283
+ return false;
284
+ }
285
+ peekSpaces(scnr);
286
+ const ch = scnr.currentPeek() === "-" ? scnr.peek() : scnr.currentPeek();
287
+ const ret = isNumberStart(ch);
288
+ scnr.resetPeek();
289
+ return ret;
290
+ }
291
+ function isLiteralStart(scnr, context2) {
292
+ const { currentType } = context2;
293
+ if (currentType !== 2) {
294
+ return false;
295
+ }
296
+ peekSpaces(scnr);
297
+ const ret = scnr.currentPeek() === LITERAL_DELIMITER;
298
+ scnr.resetPeek();
299
+ return ret;
300
+ }
301
+ function isLinkedDotStart(scnr, context2) {
302
+ const { currentType } = context2;
303
+ if (currentType !== 7) {
304
+ return false;
305
+ }
306
+ peekSpaces(scnr);
307
+ const ret = scnr.currentPeek() === ".";
308
+ scnr.resetPeek();
309
+ return ret;
310
+ }
311
+ function isLinkedModifierStart(scnr, context2) {
312
+ const { currentType } = context2;
313
+ if (currentType !== 8) {
314
+ return false;
315
+ }
316
+ peekSpaces(scnr);
317
+ const ret = isIdentifierStart(scnr.currentPeek());
318
+ scnr.resetPeek();
319
+ return ret;
320
+ }
321
+ function isLinkedDelimiterStart(scnr, context2) {
322
+ const { currentType } = context2;
323
+ if (!(currentType === 7 || currentType === 11)) {
324
+ return false;
325
+ }
326
+ peekSpaces(scnr);
327
+ const ret = scnr.currentPeek() === ":";
328
+ scnr.resetPeek();
329
+ return ret;
330
+ }
331
+ function isLinkedReferStart(scnr, context2) {
332
+ const { currentType } = context2;
333
+ if (currentType !== 9) {
334
+ return false;
335
+ }
336
+ const fn = () => {
337
+ const ch = scnr.currentPeek();
338
+ if (ch === "{") {
339
+ return isIdentifierStart(scnr.peek());
340
+ } else if (ch === "@" || ch === "|" || ch === ":" || ch === "." || ch === CHAR_SP || !ch) {
341
+ return false;
342
+ } else if (ch === CHAR_LF) {
343
+ scnr.peek();
344
+ return fn();
345
+ } else {
346
+ return isTextStart(scnr, false);
347
+ }
348
+ };
349
+ const ret = fn();
350
+ scnr.resetPeek();
351
+ return ret;
352
+ }
353
+ function isPluralStart(scnr) {
354
+ peekSpaces(scnr);
355
+ const ret = scnr.currentPeek() === "|";
356
+ scnr.resetPeek();
357
+ return ret;
358
+ }
359
+ function isTextStart(scnr, reset = true) {
360
+ const fn = (hasSpace = false, prev = "") => {
361
+ const ch = scnr.currentPeek();
362
+ if (ch === "{") {
363
+ return hasSpace;
364
+ } else if (ch === "@" || !ch) {
365
+ return hasSpace;
366
+ } else if (ch === "|") {
367
+ return !(prev === CHAR_SP || prev === CHAR_LF);
368
+ } else if (ch === CHAR_SP) {
369
+ scnr.peek();
370
+ return fn(true, CHAR_SP);
371
+ } else if (ch === CHAR_LF) {
372
+ scnr.peek();
373
+ return fn(true, CHAR_LF);
374
+ } else {
375
+ return true;
376
+ }
377
+ };
378
+ const ret = fn();
379
+ reset && scnr.resetPeek();
380
+ return ret;
381
+ }
382
+ function takeChar(scnr, fn) {
383
+ const ch = scnr.currentChar();
384
+ if (ch === EOF) {
385
+ return EOF;
386
+ }
387
+ if (fn(ch)) {
388
+ scnr.next();
389
+ return ch;
390
+ }
391
+ return null;
392
+ }
393
+ function isIdentifier(ch) {
394
+ const cc = ch.charCodeAt(0);
395
+ return cc >= 97 && cc <= 122 || // a-z
396
+ cc >= 65 && cc <= 90 || // A-Z
397
+ cc >= 48 && cc <= 57 || // 0-9
398
+ cc === 95 || // _
399
+ cc === 36;
400
+ }
401
+ function takeIdentifierChar(scnr) {
402
+ return takeChar(scnr, isIdentifier);
403
+ }
404
+ function isNamedIdentifier(ch) {
405
+ const cc = ch.charCodeAt(0);
406
+ return cc >= 97 && cc <= 122 || // a-z
407
+ cc >= 65 && cc <= 90 || // A-Z
408
+ cc >= 48 && cc <= 57 || // 0-9
409
+ cc === 95 || // _
410
+ cc === 36 || // $
411
+ cc === 45;
412
+ }
413
+ function takeNamedIdentifierChar(scnr) {
414
+ return takeChar(scnr, isNamedIdentifier);
415
+ }
416
+ function isDigit(ch) {
417
+ const cc = ch.charCodeAt(0);
418
+ return cc >= 48 && cc <= 57;
419
+ }
420
+ function takeDigit(scnr) {
421
+ return takeChar(scnr, isDigit);
422
+ }
423
+ function isHexDigit(ch) {
424
+ const cc = ch.charCodeAt(0);
425
+ return cc >= 48 && cc <= 57 || // 0-9
426
+ cc >= 65 && cc <= 70 || // A-F
427
+ cc >= 97 && cc <= 102;
428
+ }
429
+ function takeHexDigit(scnr) {
430
+ return takeChar(scnr, isHexDigit);
431
+ }
432
+ function getDigits(scnr) {
433
+ let ch = "";
434
+ let num = "";
435
+ while (ch = takeDigit(scnr)) {
436
+ num += ch;
437
+ }
438
+ return num;
439
+ }
440
+ function readText(scnr) {
441
+ let buf = "";
442
+ while (true) {
443
+ const ch = scnr.currentChar();
444
+ if (ch === "{" || ch === "}" || ch === "@" || ch === "|" || !ch) {
445
+ break;
446
+ } else if (ch === CHAR_SP || ch === CHAR_LF) {
447
+ if (isTextStart(scnr)) {
448
+ buf += ch;
449
+ scnr.next();
450
+ } else if (isPluralStart(scnr)) {
451
+ break;
452
+ } else {
453
+ buf += ch;
454
+ scnr.next();
455
+ }
456
+ } else {
457
+ buf += ch;
458
+ scnr.next();
459
+ }
460
+ }
461
+ return buf;
462
+ }
463
+ function readNamedIdentifier(scnr) {
464
+ skipSpaces(scnr);
465
+ let ch = "";
466
+ let name = "";
467
+ while (ch = takeNamedIdentifierChar(scnr)) {
468
+ name += ch;
469
+ }
470
+ if (scnr.currentChar() === EOF) {
471
+ emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0);
472
+ }
473
+ return name;
474
+ }
475
+ function readListIdentifier(scnr) {
476
+ skipSpaces(scnr);
477
+ let value = "";
478
+ if (scnr.currentChar() === "-") {
479
+ scnr.next();
480
+ value += `-${getDigits(scnr)}`;
481
+ } else {
482
+ value += getDigits(scnr);
483
+ }
484
+ if (scnr.currentChar() === EOF) {
485
+ emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0);
486
+ }
487
+ return value;
488
+ }
489
+ function isLiteral2(ch) {
490
+ return ch !== LITERAL_DELIMITER && ch !== CHAR_LF;
491
+ }
492
+ function readLiteral(scnr) {
493
+ skipSpaces(scnr);
494
+ eat(scnr, `'`);
495
+ let ch = "";
496
+ let literal = "";
497
+ while (ch = takeChar(scnr, isLiteral2)) {
498
+ if (ch === "\\") {
499
+ literal += readEscapeSequence(scnr);
500
+ } else {
501
+ literal += ch;
502
+ }
503
+ }
504
+ const current = scnr.currentChar();
505
+ if (current === CHAR_LF || current === EOF) {
506
+ emitError(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER, currentPosition(), 0);
507
+ if (current === CHAR_LF) {
508
+ scnr.next();
509
+ eat(scnr, `'`);
510
+ }
511
+ return literal;
512
+ }
513
+ eat(scnr, `'`);
514
+ return literal;
515
+ }
516
+ function readEscapeSequence(scnr) {
517
+ const ch = scnr.currentChar();
518
+ switch (ch) {
519
+ case "\\":
520
+ case `'`:
521
+ scnr.next();
522
+ return `\\${ch}`;
523
+ case "u":
524
+ return readUnicodeEscapeSequence(scnr, ch, 4);
525
+ case "U":
526
+ return readUnicodeEscapeSequence(scnr, ch, 6);
527
+ default:
528
+ emitError(CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE, currentPosition(), 0, ch);
529
+ return "";
530
+ }
531
+ }
532
+ function readUnicodeEscapeSequence(scnr, unicode, digits) {
533
+ eat(scnr, unicode);
534
+ let sequence = "";
535
+ for (let i = 0; i < digits; i++) {
536
+ const ch = takeHexDigit(scnr);
537
+ if (!ch) {
538
+ emitError(CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE, currentPosition(), 0, `\\${unicode}${sequence}${scnr.currentChar()}`);
539
+ break;
540
+ }
541
+ sequence += ch;
542
+ }
543
+ return `\\${unicode}${sequence}`;
544
+ }
545
+ function isInvalidIdentifier(ch) {
546
+ return ch !== "{" && ch !== "}" && ch !== CHAR_SP && ch !== CHAR_LF;
547
+ }
548
+ function readInvalidIdentifier(scnr) {
549
+ skipSpaces(scnr);
550
+ let ch = "";
551
+ let identifiers = "";
552
+ while (ch = takeChar(scnr, isInvalidIdentifier)) {
553
+ identifiers += ch;
554
+ }
555
+ return identifiers;
556
+ }
557
+ function readLinkedModifier(scnr) {
558
+ let ch = "";
559
+ let name = "";
560
+ while (ch = takeIdentifierChar(scnr)) {
561
+ name += ch;
562
+ }
563
+ return name;
564
+ }
565
+ function readLinkedRefer(scnr) {
566
+ const fn = (buf) => {
567
+ const ch = scnr.currentChar();
568
+ if (ch === "{" || ch === "@" || ch === "|" || ch === "(" || ch === ")" || !ch) {
569
+ return buf;
570
+ } else if (ch === CHAR_SP) {
571
+ return buf;
572
+ } else if (ch === CHAR_LF || ch === DOT) {
573
+ buf += ch;
574
+ scnr.next();
575
+ return fn(buf);
576
+ } else {
577
+ buf += ch;
578
+ scnr.next();
579
+ return fn(buf);
580
+ }
581
+ };
582
+ return fn("");
583
+ }
584
+ function readPlural(scnr) {
585
+ skipSpaces(scnr);
586
+ const plural = eat(
587
+ scnr,
588
+ "|"
589
+ /* TokenChars.Pipe */
590
+ );
591
+ skipSpaces(scnr);
592
+ return plural;
593
+ }
594
+ function readTokenInPlaceholder(scnr, context2) {
595
+ let token = null;
596
+ const ch = scnr.currentChar();
597
+ switch (ch) {
598
+ case "{":
599
+ if (context2.braceNest >= 1) {
600
+ emitError(CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER, currentPosition(), 0);
601
+ }
602
+ scnr.next();
603
+ token = getToken(
604
+ context2,
605
+ 2,
606
+ "{"
607
+ /* TokenChars.BraceLeft */
608
+ );
609
+ skipSpaces(scnr);
610
+ context2.braceNest++;
611
+ return token;
612
+ case "}":
613
+ if (context2.braceNest > 0 && context2.currentType === 2) {
614
+ emitError(CompileErrorCodes.EMPTY_PLACEHOLDER, currentPosition(), 0);
615
+ }
616
+ scnr.next();
617
+ token = getToken(
618
+ context2,
619
+ 3,
620
+ "}"
621
+ /* TokenChars.BraceRight */
622
+ );
623
+ context2.braceNest--;
624
+ context2.braceNest > 0 && skipSpaces(scnr);
625
+ if (context2.inLinked && context2.braceNest === 0) {
626
+ context2.inLinked = false;
627
+ }
628
+ return token;
629
+ case "@":
630
+ if (context2.braceNest > 0) {
631
+ emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0);
632
+ }
633
+ token = readTokenInLinked(scnr, context2) || getEndToken(context2);
634
+ context2.braceNest = 0;
635
+ return token;
636
+ default: {
637
+ let validNamedIdentifier = true;
638
+ let validListIdentifier = true;
639
+ let validLiteral = true;
640
+ if (isPluralStart(scnr)) {
641
+ if (context2.braceNest > 0) {
642
+ emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0);
643
+ }
644
+ token = getToken(context2, 1, readPlural(scnr));
645
+ context2.braceNest = 0;
646
+ context2.inLinked = false;
647
+ return token;
648
+ }
649
+ if (context2.braceNest > 0 && (context2.currentType === 4 || context2.currentType === 5 || context2.currentType === 6)) {
650
+ emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0);
651
+ context2.braceNest = 0;
652
+ return readToken(scnr, context2);
653
+ }
654
+ if (validNamedIdentifier = isNamedIdentifierStart(scnr, context2)) {
655
+ token = getToken(context2, 4, readNamedIdentifier(scnr));
656
+ skipSpaces(scnr);
657
+ return token;
658
+ }
659
+ if (validListIdentifier = isListIdentifierStart(scnr, context2)) {
660
+ token = getToken(context2, 5, readListIdentifier(scnr));
661
+ skipSpaces(scnr);
662
+ return token;
663
+ }
664
+ if (validLiteral = isLiteralStart(scnr, context2)) {
665
+ token = getToken(context2, 6, readLiteral(scnr));
666
+ skipSpaces(scnr);
667
+ return token;
668
+ }
669
+ if (!validNamedIdentifier && !validListIdentifier && !validLiteral) {
670
+ token = getToken(context2, 12, readInvalidIdentifier(scnr));
671
+ emitError(CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER, currentPosition(), 0, token.value);
672
+ skipSpaces(scnr);
673
+ return token;
674
+ }
675
+ break;
676
+ }
677
+ }
678
+ return token;
679
+ }
680
+ function readTokenInLinked(scnr, context2) {
681
+ const { currentType } = context2;
682
+ let token = null;
683
+ const ch = scnr.currentChar();
684
+ if ((currentType === 7 || currentType === 8 || currentType === 11 || currentType === 9) && (ch === CHAR_LF || ch === CHAR_SP)) {
685
+ emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0);
686
+ }
687
+ switch (ch) {
688
+ case "@":
689
+ scnr.next();
690
+ token = getToken(
691
+ context2,
692
+ 7,
693
+ "@"
694
+ /* TokenChars.LinkedAlias */
695
+ );
696
+ context2.inLinked = true;
697
+ return token;
698
+ case ".":
699
+ skipSpaces(scnr);
700
+ scnr.next();
701
+ return getToken(
702
+ context2,
703
+ 8,
704
+ "."
705
+ /* TokenChars.LinkedDot */
706
+ );
707
+ case ":":
708
+ skipSpaces(scnr);
709
+ scnr.next();
710
+ return getToken(
711
+ context2,
712
+ 9,
713
+ ":"
714
+ /* TokenChars.LinkedDelimiter */
715
+ );
716
+ default:
717
+ if (isPluralStart(scnr)) {
718
+ token = getToken(context2, 1, readPlural(scnr));
719
+ context2.braceNest = 0;
720
+ context2.inLinked = false;
721
+ return token;
722
+ }
723
+ if (isLinkedDotStart(scnr, context2) || isLinkedDelimiterStart(scnr, context2)) {
724
+ skipSpaces(scnr);
725
+ return readTokenInLinked(scnr, context2);
726
+ }
727
+ if (isLinkedModifierStart(scnr, context2)) {
728
+ skipSpaces(scnr);
729
+ return getToken(context2, 11, readLinkedModifier(scnr));
730
+ }
731
+ if (isLinkedReferStart(scnr, context2)) {
732
+ skipSpaces(scnr);
733
+ if (ch === "{") {
734
+ return readTokenInPlaceholder(scnr, context2) || token;
735
+ } else {
736
+ return getToken(context2, 10, readLinkedRefer(scnr));
737
+ }
738
+ }
739
+ if (currentType === 7) {
740
+ emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0);
741
+ }
742
+ context2.braceNest = 0;
743
+ context2.inLinked = false;
744
+ return readToken(scnr, context2);
745
+ }
746
+ }
747
+ function readToken(scnr, context2) {
748
+ let token = {
749
+ type: 13
750
+ /* TokenTypes.EOF */
751
+ };
752
+ if (context2.braceNest > 0) {
753
+ return readTokenInPlaceholder(scnr, context2) || getEndToken(context2);
754
+ }
755
+ if (context2.inLinked) {
756
+ return readTokenInLinked(scnr, context2) || getEndToken(context2);
757
+ }
758
+ const ch = scnr.currentChar();
759
+ switch (ch) {
760
+ case "{":
761
+ return readTokenInPlaceholder(scnr, context2) || getEndToken(context2);
762
+ case "}":
763
+ emitError(CompileErrorCodes.UNBALANCED_CLOSING_BRACE, currentPosition(), 0);
764
+ scnr.next();
765
+ return getToken(
766
+ context2,
767
+ 3,
768
+ "}"
769
+ /* TokenChars.BraceRight */
770
+ );
771
+ case "@":
772
+ return readTokenInLinked(scnr, context2) || getEndToken(context2);
773
+ default: {
774
+ if (isPluralStart(scnr)) {
775
+ token = getToken(context2, 1, readPlural(scnr));
776
+ context2.braceNest = 0;
777
+ context2.inLinked = false;
778
+ return token;
779
+ }
780
+ if (isTextStart(scnr)) {
781
+ return getToken(context2, 0, readText(scnr));
782
+ }
783
+ break;
784
+ }
785
+ }
786
+ return token;
787
+ }
788
+ function nextToken() {
789
+ const { currentType, offset, startLoc, endLoc } = _context;
790
+ _context.lastType = currentType;
791
+ _context.lastOffset = offset;
792
+ _context.lastStartLoc = startLoc;
793
+ _context.lastEndLoc = endLoc;
794
+ _context.offset = currentOffset();
795
+ _context.startLoc = currentPosition();
796
+ if (_scnr.currentChar() === EOF) {
797
+ return getToken(
798
+ _context,
799
+ 13
800
+ /* TokenTypes.EOF */
801
+ );
802
+ }
803
+ return readToken(_scnr, _context);
804
+ }
805
+ return {
806
+ nextToken,
807
+ currentOffset,
808
+ currentPosition,
809
+ context
810
+ };
811
+ }
812
+ var ERROR_DOMAIN$2 = "parser";
813
+ var KNOWN_ESCAPES = /(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;
814
+ function fromEscapeSequence(match, codePoint4, codePoint6) {
815
+ switch (match) {
816
+ case `\\\\`:
817
+ return `\\`;
818
+ // eslint-disable-next-line no-useless-escape
819
+ case `\\'`:
820
+ return `'`;
821
+ default: {
822
+ const codePoint = parseInt(codePoint4 || codePoint6, 16);
823
+ if (codePoint <= 55295 || codePoint >= 57344) {
824
+ return String.fromCodePoint(codePoint);
825
+ }
826
+ return "�";
827
+ }
828
+ }
829
+ }
830
+ function createParser(options = {}) {
831
+ const location = options.location !== false;
832
+ const { onError } = options;
833
+ function emitError(tokenzer, code, start, offset, ...args) {
834
+ const end = tokenzer.currentPosition();
835
+ end.offset += offset;
836
+ end.column += offset;
837
+ if (onError) {
838
+ const loc = location ? createLocation(start, end) : null;
839
+ const err = createCompileError(code, loc, {
840
+ domain: ERROR_DOMAIN$2,
841
+ args
842
+ });
843
+ onError(err);
844
+ }
845
+ }
846
+ function startNode(type, offset, loc) {
847
+ const node = { type };
848
+ if (location) {
849
+ node.start = offset;
850
+ node.end = offset;
851
+ node.loc = { start: loc, end: loc };
852
+ }
853
+ return node;
854
+ }
855
+ function endNode(node, offset, pos, type) {
856
+ if (location) {
857
+ node.end = offset;
858
+ if (node.loc) {
859
+ node.loc.end = pos;
860
+ }
861
+ }
862
+ }
863
+ function parseText(tokenizer, value) {
864
+ const context = tokenizer.context();
865
+ const node = startNode(3, context.offset, context.startLoc);
866
+ node.value = value;
867
+ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
868
+ return node;
869
+ }
870
+ function parseList(tokenizer, index) {
871
+ const context = tokenizer.context();
872
+ const { lastOffset: offset, lastStartLoc: loc } = context;
873
+ const node = startNode(5, offset, loc);
874
+ node.index = parseInt(index, 10);
875
+ tokenizer.nextToken();
876
+ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
877
+ return node;
878
+ }
879
+ function parseNamed(tokenizer, key) {
880
+ const context = tokenizer.context();
881
+ const { lastOffset: offset, lastStartLoc: loc } = context;
882
+ const node = startNode(4, offset, loc);
883
+ node.key = key;
884
+ tokenizer.nextToken();
885
+ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
886
+ return node;
887
+ }
888
+ function parseLiteral(tokenizer, value) {
889
+ const context = tokenizer.context();
890
+ const { lastOffset: offset, lastStartLoc: loc } = context;
891
+ const node = startNode(9, offset, loc);
892
+ node.value = value.replace(KNOWN_ESCAPES, fromEscapeSequence);
893
+ tokenizer.nextToken();
894
+ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
895
+ return node;
896
+ }
897
+ function parseLinkedModifier(tokenizer) {
898
+ const token = tokenizer.nextToken();
899
+ const context = tokenizer.context();
900
+ const { lastOffset: offset, lastStartLoc: loc } = context;
901
+ const node = startNode(8, offset, loc);
902
+ if (token.type !== 11) {
903
+ emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER, context.lastStartLoc, 0);
904
+ node.value = "";
905
+ endNode(node, offset, loc);
906
+ return {
907
+ nextConsumeToken: token,
908
+ node
909
+ };
910
+ }
911
+ if (token.value == null) {
912
+ emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
913
+ }
914
+ node.value = token.value || "";
915
+ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
916
+ return {
917
+ node
918
+ };
919
+ }
920
+ function parseLinkedKey(tokenizer, value) {
921
+ const context = tokenizer.context();
922
+ const node = startNode(7, context.offset, context.startLoc);
923
+ node.value = value;
924
+ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
925
+ return node;
926
+ }
927
+ function parseLinked(tokenizer) {
928
+ const context = tokenizer.context();
929
+ const linkedNode = startNode(6, context.offset, context.startLoc);
930
+ let token = tokenizer.nextToken();
931
+ if (token.type === 8) {
932
+ const parsed = parseLinkedModifier(tokenizer);
933
+ linkedNode.modifier = parsed.node;
934
+ token = parsed.nextConsumeToken || tokenizer.nextToken();
935
+ }
936
+ if (token.type !== 9) {
937
+ emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
938
+ }
939
+ token = tokenizer.nextToken();
940
+ if (token.type === 2) {
941
+ token = tokenizer.nextToken();
942
+ }
943
+ switch (token.type) {
944
+ case 10:
945
+ if (token.value == null) {
946
+ emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
947
+ }
948
+ linkedNode.key = parseLinkedKey(tokenizer, token.value || "");
949
+ break;
950
+ case 4:
951
+ if (token.value == null) {
952
+ emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
953
+ }
954
+ linkedNode.key = parseNamed(tokenizer, token.value || "");
955
+ break;
956
+ case 5:
957
+ if (token.value == null) {
958
+ emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
959
+ }
960
+ linkedNode.key = parseList(tokenizer, token.value || "");
961
+ break;
962
+ case 6:
963
+ if (token.value == null) {
964
+ emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
965
+ }
966
+ linkedNode.key = parseLiteral(tokenizer, token.value || "");
967
+ break;
968
+ default: {
969
+ emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY, context.lastStartLoc, 0);
970
+ const nextContext = tokenizer.context();
971
+ const emptyLinkedKeyNode = startNode(7, nextContext.offset, nextContext.startLoc);
972
+ emptyLinkedKeyNode.value = "";
973
+ endNode(emptyLinkedKeyNode, nextContext.offset, nextContext.startLoc);
974
+ linkedNode.key = emptyLinkedKeyNode;
975
+ endNode(linkedNode, nextContext.offset, nextContext.startLoc);
976
+ return {
977
+ nextConsumeToken: token,
978
+ node: linkedNode
979
+ };
980
+ }
981
+ }
982
+ endNode(linkedNode, tokenizer.currentOffset(), tokenizer.currentPosition());
983
+ return {
984
+ node: linkedNode
985
+ };
986
+ }
987
+ function parseMessage(tokenizer) {
988
+ const context = tokenizer.context();
989
+ const startOffset = context.currentType === 1 ? tokenizer.currentOffset() : context.offset;
990
+ const startLoc = context.currentType === 1 ? context.endLoc : context.startLoc;
991
+ const node = startNode(2, startOffset, startLoc);
992
+ node.items = [];
993
+ let nextToken = null;
994
+ do {
995
+ const token = nextToken || tokenizer.nextToken();
996
+ nextToken = null;
997
+ switch (token.type) {
998
+ case 0:
999
+ if (token.value == null) {
1000
+ emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
1001
+ }
1002
+ node.items.push(parseText(tokenizer, token.value || ""));
1003
+ break;
1004
+ case 5:
1005
+ if (token.value == null) {
1006
+ emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
1007
+ }
1008
+ node.items.push(parseList(tokenizer, token.value || ""));
1009
+ break;
1010
+ case 4:
1011
+ if (token.value == null) {
1012
+ emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
1013
+ }
1014
+ node.items.push(parseNamed(tokenizer, token.value || ""));
1015
+ break;
1016
+ case 6:
1017
+ if (token.value == null) {
1018
+ emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
1019
+ }
1020
+ node.items.push(parseLiteral(tokenizer, token.value || ""));
1021
+ break;
1022
+ case 7: {
1023
+ const parsed = parseLinked(tokenizer);
1024
+ node.items.push(parsed.node);
1025
+ nextToken = parsed.nextConsumeToken || null;
1026
+ break;
1027
+ }
1028
+ }
1029
+ } while (context.currentType !== 13 && context.currentType !== 1);
1030
+ const endOffset = context.currentType === 1 ? context.lastOffset : tokenizer.currentOffset();
1031
+ const endLoc = context.currentType === 1 ? context.lastEndLoc : tokenizer.currentPosition();
1032
+ endNode(node, endOffset, endLoc);
1033
+ return node;
1034
+ }
1035
+ function parsePlural(tokenizer, offset, loc, msgNode) {
1036
+ const context = tokenizer.context();
1037
+ let hasEmptyMessage = msgNode.items.length === 0;
1038
+ const node = startNode(1, offset, loc);
1039
+ node.cases = [];
1040
+ node.cases.push(msgNode);
1041
+ do {
1042
+ const msg = parseMessage(tokenizer);
1043
+ if (!hasEmptyMessage) {
1044
+ hasEmptyMessage = msg.items.length === 0;
1045
+ }
1046
+ node.cases.push(msg);
1047
+ } while (context.currentType !== 13);
1048
+ if (hasEmptyMessage) {
1049
+ emitError(tokenizer, CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL, loc, 0);
1050
+ }
1051
+ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
1052
+ return node;
1053
+ }
1054
+ function parseResource(tokenizer) {
1055
+ const context = tokenizer.context();
1056
+ const { offset, startLoc } = context;
1057
+ const msgNode = parseMessage(tokenizer);
1058
+ if (context.currentType === 13) {
1059
+ return msgNode;
1060
+ } else {
1061
+ return parsePlural(tokenizer, offset, startLoc, msgNode);
1062
+ }
1063
+ }
1064
+ function parse2(source) {
1065
+ const tokenizer = createTokenizer(source, assign({}, options));
1066
+ const context = tokenizer.context();
1067
+ const node = startNode(0, context.offset, context.startLoc);
1068
+ if (location && node.loc) {
1069
+ node.loc.source = source;
1070
+ }
1071
+ node.body = parseResource(tokenizer);
1072
+ if (options.onCacheKey) {
1073
+ node.cacheKey = options.onCacheKey(source);
1074
+ }
1075
+ if (context.currentType !== 13) {
1076
+ emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, source[context.offset] || "");
1077
+ }
1078
+ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
1079
+ return node;
1080
+ }
1081
+ return { parse: parse2 };
1082
+ }
1083
+ function getTokenCaption(token) {
1084
+ if (token.type === 13) {
1085
+ return "EOF";
1086
+ }
1087
+ const name = (token.value || "").replace(/\r?\n/gu, "\\n");
1088
+ return name.length > 10 ? name.slice(0, 9) + "…" : name;
1089
+ }
1090
+ function createTransformer(ast, options = {}) {
1091
+ const _context = {
1092
+ ast,
1093
+ helpers: /* @__PURE__ */ new Set()
1094
+ };
1095
+ const context = () => _context;
1096
+ const helper = (name) => {
1097
+ _context.helpers.add(name);
1098
+ return name;
1099
+ };
1100
+ return { context, helper };
1101
+ }
1102
+ function traverseNodes(nodes, transformer) {
1103
+ for (let i = 0; i < nodes.length; i++) {
1104
+ traverseNode(nodes[i], transformer);
1105
+ }
1106
+ }
1107
+ function traverseNode(node, transformer) {
1108
+ switch (node.type) {
1109
+ case 1:
1110
+ traverseNodes(node.cases, transformer);
1111
+ transformer.helper(
1112
+ "plural"
1113
+ /* HelperNameMap.PLURAL */
1114
+ );
1115
+ break;
1116
+ case 2:
1117
+ traverseNodes(node.items, transformer);
1118
+ break;
1119
+ case 6: {
1120
+ const linked = node;
1121
+ traverseNode(linked.key, transformer);
1122
+ transformer.helper(
1123
+ "linked"
1124
+ /* HelperNameMap.LINKED */
1125
+ );
1126
+ transformer.helper(
1127
+ "type"
1128
+ /* HelperNameMap.TYPE */
1129
+ );
1130
+ break;
1131
+ }
1132
+ case 5:
1133
+ transformer.helper(
1134
+ "interpolate"
1135
+ /* HelperNameMap.INTERPOLATE */
1136
+ );
1137
+ transformer.helper(
1138
+ "list"
1139
+ /* HelperNameMap.LIST */
1140
+ );
1141
+ break;
1142
+ case 4:
1143
+ transformer.helper(
1144
+ "interpolate"
1145
+ /* HelperNameMap.INTERPOLATE */
1146
+ );
1147
+ transformer.helper(
1148
+ "named"
1149
+ /* HelperNameMap.NAMED */
1150
+ );
1151
+ break;
1152
+ }
1153
+ }
1154
+ function transform(ast, options = {}) {
1155
+ const transformer = createTransformer(ast);
1156
+ transformer.helper(
1157
+ "normalize"
1158
+ /* HelperNameMap.NORMALIZE */
1159
+ );
1160
+ ast.body && traverseNode(ast.body, transformer);
1161
+ const context = transformer.context();
1162
+ ast.helpers = Array.from(context.helpers);
1163
+ }
1164
+ function optimize(ast) {
1165
+ const body = ast.body;
1166
+ if (body.type === 2) {
1167
+ optimizeMessageNode(body);
1168
+ } else {
1169
+ body.cases.forEach((c) => optimizeMessageNode(c));
1170
+ }
1171
+ return ast;
1172
+ }
1173
+ function optimizeMessageNode(message) {
1174
+ if (message.items.length === 1) {
1175
+ const item = message.items[0];
1176
+ if (item.type === 3 || item.type === 9) {
1177
+ message.static = item.value;
1178
+ delete item.value;
1179
+ }
1180
+ } else {
1181
+ const values = [];
1182
+ for (let i = 0; i < message.items.length; i++) {
1183
+ const item = message.items[i];
1184
+ if (!(item.type === 3 || item.type === 9)) {
1185
+ break;
1186
+ }
1187
+ if (item.value == null) {
1188
+ break;
1189
+ }
1190
+ values.push(item.value);
1191
+ }
1192
+ if (values.length === message.items.length) {
1193
+ message.static = join(values);
1194
+ for (let i = 0; i < message.items.length; i++) {
1195
+ const item = message.items[i];
1196
+ if (item.type === 3 || item.type === 9) {
1197
+ delete item.value;
1198
+ }
1199
+ }
1200
+ }
1201
+ }
1202
+ }
1203
+ var ERROR_DOMAIN$1 = "minifier";
1204
+ function minify(node) {
1205
+ node.t = node.type;
1206
+ switch (node.type) {
1207
+ case 0: {
1208
+ const resource = node;
1209
+ minify(resource.body);
1210
+ resource.b = resource.body;
1211
+ delete resource.body;
1212
+ break;
1213
+ }
1214
+ case 1: {
1215
+ const plural = node;
1216
+ const cases = plural.cases;
1217
+ for (let i = 0; i < cases.length; i++) {
1218
+ minify(cases[i]);
1219
+ }
1220
+ plural.c = cases;
1221
+ delete plural.cases;
1222
+ break;
1223
+ }
1224
+ case 2: {
1225
+ const message = node;
1226
+ const items = message.items;
1227
+ for (let i = 0; i < items.length; i++) {
1228
+ minify(items[i]);
1229
+ }
1230
+ message.i = items;
1231
+ delete message.items;
1232
+ if (message.static) {
1233
+ message.s = message.static;
1234
+ delete message.static;
1235
+ }
1236
+ break;
1237
+ }
1238
+ case 3:
1239
+ case 9:
1240
+ case 8:
1241
+ case 7: {
1242
+ const valueNode = node;
1243
+ if (valueNode.value) {
1244
+ valueNode.v = valueNode.value;
1245
+ delete valueNode.value;
1246
+ }
1247
+ break;
1248
+ }
1249
+ case 6: {
1250
+ const linked = node;
1251
+ minify(linked.key);
1252
+ linked.k = linked.key;
1253
+ delete linked.key;
1254
+ if (linked.modifier) {
1255
+ minify(linked.modifier);
1256
+ linked.m = linked.modifier;
1257
+ delete linked.modifier;
1258
+ }
1259
+ break;
1260
+ }
1261
+ case 5: {
1262
+ const list = node;
1263
+ list.i = list.index;
1264
+ delete list.index;
1265
+ break;
1266
+ }
1267
+ case 4: {
1268
+ const named = node;
1269
+ named.k = named.key;
1270
+ delete named.key;
1271
+ break;
1272
+ }
1273
+ default:
1274
+ if (true) {
1275
+ throw createCompileError(CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE, null, {
1276
+ domain: ERROR_DOMAIN$1,
1277
+ args: [node.type]
1278
+ });
1279
+ }
1280
+ }
1281
+ delete node.type;
1282
+ }
1283
+ var ERROR_DOMAIN = "parser";
1284
+ function createCodeGenerator(ast, options) {
1285
+ const { sourceMap, filename, breakLineCode, needIndent: _needIndent } = options;
1286
+ const location = options.location !== false;
1287
+ const _context = {
1288
+ filename,
1289
+ code: "",
1290
+ column: 1,
1291
+ line: 1,
1292
+ offset: 0,
1293
+ map: void 0,
1294
+ breakLineCode,
1295
+ needIndent: _needIndent,
1296
+ indentLevel: 0
1297
+ };
1298
+ if (location && ast.loc) {
1299
+ _context.source = ast.loc.source;
1300
+ }
1301
+ const context = () => _context;
1302
+ function push(code, node) {
1303
+ _context.code += code;
1304
+ }
1305
+ function _newline(n, withBreakLine = true) {
1306
+ const _breakLineCode = withBreakLine ? breakLineCode : "";
1307
+ push(_needIndent ? _breakLineCode + ` `.repeat(n) : _breakLineCode);
1308
+ }
1309
+ function indent(withNewLine = true) {
1310
+ const level = ++_context.indentLevel;
1311
+ withNewLine && _newline(level);
1312
+ }
1313
+ function deindent(withNewLine = true) {
1314
+ const level = --_context.indentLevel;
1315
+ withNewLine && _newline(level);
1316
+ }
1317
+ function newline() {
1318
+ _newline(_context.indentLevel);
1319
+ }
1320
+ const helper = (key) => `_${key}`;
1321
+ const needIndent = () => _context.needIndent;
1322
+ return {
1323
+ context,
1324
+ push,
1325
+ indent,
1326
+ deindent,
1327
+ newline,
1328
+ helper,
1329
+ needIndent
1330
+ };
1331
+ }
1332
+ function generateLinkedNode(generator, node) {
1333
+ const { helper } = generator;
1334
+ generator.push(`${helper(
1335
+ "linked"
1336
+ /* HelperNameMap.LINKED */
1337
+ )}(`);
1338
+ generateNode(generator, node.key);
1339
+ if (node.modifier) {
1340
+ generator.push(`, `);
1341
+ generateNode(generator, node.modifier);
1342
+ generator.push(`, _type`);
1343
+ } else {
1344
+ generator.push(`, undefined, _type`);
1345
+ }
1346
+ generator.push(`)`);
1347
+ }
1348
+ function generateMessageNode(generator, node) {
1349
+ const { helper, needIndent } = generator;
1350
+ generator.push(`${helper(
1351
+ "normalize"
1352
+ /* HelperNameMap.NORMALIZE */
1353
+ )}([`);
1354
+ generator.indent(needIndent());
1355
+ const length = node.items.length;
1356
+ for (let i = 0; i < length; i++) {
1357
+ generateNode(generator, node.items[i]);
1358
+ if (i === length - 1) {
1359
+ break;
1360
+ }
1361
+ generator.push(", ");
1362
+ }
1363
+ generator.deindent(needIndent());
1364
+ generator.push("])");
1365
+ }
1366
+ function generatePluralNode(generator, node) {
1367
+ const { helper, needIndent } = generator;
1368
+ if (node.cases.length > 1) {
1369
+ generator.push(`${helper(
1370
+ "plural"
1371
+ /* HelperNameMap.PLURAL */
1372
+ )}([`);
1373
+ generator.indent(needIndent());
1374
+ const length = node.cases.length;
1375
+ for (let i = 0; i < length; i++) {
1376
+ generateNode(generator, node.cases[i]);
1377
+ if (i === length - 1) {
1378
+ break;
1379
+ }
1380
+ generator.push(", ");
1381
+ }
1382
+ generator.deindent(needIndent());
1383
+ generator.push(`])`);
1384
+ }
1385
+ }
1386
+ function generateResource(generator, node) {
1387
+ if (node.body) {
1388
+ generateNode(generator, node.body);
1389
+ } else {
1390
+ generator.push("null");
1391
+ }
1392
+ }
1393
+ function generateNode(generator, node) {
1394
+ const { helper } = generator;
1395
+ switch (node.type) {
1396
+ case 0:
1397
+ generateResource(generator, node);
1398
+ break;
1399
+ case 1:
1400
+ generatePluralNode(generator, node);
1401
+ break;
1402
+ case 2:
1403
+ generateMessageNode(generator, node);
1404
+ break;
1405
+ case 6:
1406
+ generateLinkedNode(generator, node);
1407
+ break;
1408
+ case 8:
1409
+ generator.push(JSON.stringify(node.value), node);
1410
+ break;
1411
+ case 7:
1412
+ generator.push(JSON.stringify(node.value), node);
1413
+ break;
1414
+ case 5:
1415
+ generator.push(`${helper(
1416
+ "interpolate"
1417
+ /* HelperNameMap.INTERPOLATE */
1418
+ )}(${helper(
1419
+ "list"
1420
+ /* HelperNameMap.LIST */
1421
+ )}(${node.index}))`, node);
1422
+ break;
1423
+ case 4:
1424
+ generator.push(`${helper(
1425
+ "interpolate"
1426
+ /* HelperNameMap.INTERPOLATE */
1427
+ )}(${helper(
1428
+ "named"
1429
+ /* HelperNameMap.NAMED */
1430
+ )}(${JSON.stringify(node.key)}))`, node);
1431
+ break;
1432
+ case 9:
1433
+ generator.push(JSON.stringify(node.value), node);
1434
+ break;
1435
+ case 3:
1436
+ generator.push(JSON.stringify(node.value), node);
1437
+ break;
1438
+ default:
1439
+ if (true) {
1440
+ throw createCompileError(CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE, null, {
1441
+ domain: ERROR_DOMAIN,
1442
+ args: [node.type]
1443
+ });
1444
+ }
1445
+ }
1446
+ }
1447
+ var generate = (ast, options = {}) => {
1448
+ const mode = isString(options.mode) ? options.mode : "normal";
1449
+ const filename = isString(options.filename) ? options.filename : "message.intl";
1450
+ const sourceMap = !!options.sourceMap;
1451
+ const breakLineCode = options.breakLineCode != null ? options.breakLineCode : mode === "arrow" ? ";" : "\n";
1452
+ const needIndent = options.needIndent ? options.needIndent : mode !== "arrow";
1453
+ const helpers = ast.helpers || [];
1454
+ const generator = createCodeGenerator(ast, {
1455
+ mode,
1456
+ filename,
1457
+ sourceMap,
1458
+ breakLineCode,
1459
+ needIndent
1460
+ });
1461
+ generator.push(mode === "normal" ? `function __msg__ (ctx) {` : `(ctx) => {`);
1462
+ generator.indent(needIndent);
1463
+ if (helpers.length > 0) {
1464
+ generator.push(`const { ${join(helpers.map((s) => `${s}: _${s}`), ", ")} } = ctx`);
1465
+ generator.newline();
1466
+ }
1467
+ generator.push(`return `);
1468
+ generateNode(generator, ast);
1469
+ generator.deindent(needIndent);
1470
+ generator.push(`}`);
1471
+ delete ast.helpers;
1472
+ const { code, map } = generator.context();
1473
+ return {
1474
+ ast,
1475
+ code,
1476
+ map: map ? map.toJSON() : void 0
1477
+ // eslint-disable-line @typescript-eslint/no-explicit-any
1478
+ };
1479
+ };
1480
+ function baseCompile(source, options = {}) {
1481
+ const assignedOptions = assign({}, options);
1482
+ const jit = !!assignedOptions.jit;
1483
+ const enalbeMinify = !!assignedOptions.minify;
1484
+ const enambeOptimize = assignedOptions.optimize == null ? true : assignedOptions.optimize;
1485
+ const parser = createParser(assignedOptions);
1486
+ const ast = parser.parse(source);
1487
+ if (!jit) {
1488
+ transform(ast, assignedOptions);
1489
+ return generate(ast, assignedOptions);
1490
+ } else {
1491
+ enambeOptimize && optimize(ast);
1492
+ enalbeMinify && minify(ast);
1493
+ return { ast, code: "" };
1494
+ }
1495
+ }
1496
+
1497
+ // ../../../node_modules/.pnpm/@intlify+core-base@10.0.7/node_modules/@intlify/core-base/dist/core-base.mjs
1498
+ function initFeatureFlags() {
1499
+ if (typeof __INTLIFY_PROD_DEVTOOLS__ !== "boolean") {
1500
+ getGlobalThis().__INTLIFY_PROD_DEVTOOLS__ = false;
1501
+ }
1502
+ if (typeof __INTLIFY_DROP_MESSAGE_COMPILER__ !== "boolean") {
1503
+ getGlobalThis().__INTLIFY_DROP_MESSAGE_COMPILER__ = false;
1504
+ }
1505
+ }
1506
+ function isMessageAST(val) {
1507
+ return isObject(val) && resolveType(val) === 0 && (hasOwn(val, "b") || hasOwn(val, "body"));
1508
+ }
1509
+ var PROPS_BODY = ["b", "body"];
1510
+ function resolveBody(node) {
1511
+ return resolveProps(node, PROPS_BODY);
1512
+ }
1513
+ var PROPS_CASES = ["c", "cases"];
1514
+ function resolveCases(node) {
1515
+ return resolveProps(node, PROPS_CASES, []);
1516
+ }
1517
+ var PROPS_STATIC = ["s", "static"];
1518
+ function resolveStatic(node) {
1519
+ return resolveProps(node, PROPS_STATIC);
1520
+ }
1521
+ var PROPS_ITEMS = ["i", "items"];
1522
+ function resolveItems(node) {
1523
+ return resolveProps(node, PROPS_ITEMS, []);
1524
+ }
1525
+ var PROPS_TYPE = ["t", "type"];
1526
+ function resolveType(node) {
1527
+ return resolveProps(node, PROPS_TYPE);
1528
+ }
1529
+ var PROPS_VALUE = ["v", "value"];
1530
+ function resolveValue$1(node, type) {
1531
+ const resolved = resolveProps(node, PROPS_VALUE);
1532
+ if (resolved != null) {
1533
+ return resolved;
1534
+ } else {
1535
+ throw createUnhandleNodeError(type);
1536
+ }
1537
+ }
1538
+ var PROPS_MODIFIER = ["m", "modifier"];
1539
+ function resolveLinkedModifier(node) {
1540
+ return resolveProps(node, PROPS_MODIFIER);
1541
+ }
1542
+ var PROPS_KEY = ["k", "key"];
1543
+ function resolveLinkedKey(node) {
1544
+ const resolved = resolveProps(node, PROPS_KEY);
1545
+ if (resolved) {
1546
+ return resolved;
1547
+ } else {
1548
+ throw createUnhandleNodeError(
1549
+ 6
1550
+ /* NodeTypes.Linked */
1551
+ );
1552
+ }
1553
+ }
1554
+ function resolveProps(node, props, defaultValue) {
1555
+ for (let i = 0; i < props.length; i++) {
1556
+ const prop = props[i];
1557
+ if (hasOwn(node, prop) && node[prop] != null) {
1558
+ return node[prop];
1559
+ }
1560
+ }
1561
+ return defaultValue;
1562
+ }
1563
+ var AST_NODE_PROPS_KEYS = [
1564
+ ...PROPS_BODY,
1565
+ ...PROPS_CASES,
1566
+ ...PROPS_STATIC,
1567
+ ...PROPS_ITEMS,
1568
+ ...PROPS_KEY,
1569
+ ...PROPS_MODIFIER,
1570
+ ...PROPS_VALUE,
1571
+ ...PROPS_TYPE
1572
+ ];
1573
+ function createUnhandleNodeError(type) {
1574
+ return new Error(`unhandled node type: ${type}`);
1575
+ }
1576
+ function format2(ast) {
1577
+ const msg = (ctx) => formatParts(ctx, ast);
1578
+ return msg;
1579
+ }
1580
+ function formatParts(ctx, ast) {
1581
+ const body = resolveBody(ast);
1582
+ if (body == null) {
1583
+ throw createUnhandleNodeError(
1584
+ 0
1585
+ /* NodeTypes.Resource */
1586
+ );
1587
+ }
1588
+ const type = resolveType(body);
1589
+ if (type === 1) {
1590
+ const plural = body;
1591
+ const cases = resolveCases(plural);
1592
+ return ctx.plural(cases.reduce((messages, c) => [
1593
+ ...messages,
1594
+ formatMessageParts(ctx, c)
1595
+ ], []));
1596
+ } else {
1597
+ return formatMessageParts(ctx, body);
1598
+ }
1599
+ }
1600
+ function formatMessageParts(ctx, node) {
1601
+ const static_ = resolveStatic(node);
1602
+ if (static_ != null) {
1603
+ return ctx.type === "text" ? static_ : ctx.normalize([static_]);
1604
+ } else {
1605
+ const messages = resolveItems(node).reduce((acm, c) => [...acm, formatMessagePart(ctx, c)], []);
1606
+ return ctx.normalize(messages);
1607
+ }
1608
+ }
1609
+ function formatMessagePart(ctx, node) {
1610
+ const type = resolveType(node);
1611
+ switch (type) {
1612
+ case 3: {
1613
+ return resolveValue$1(node, type);
1614
+ }
1615
+ case 9: {
1616
+ return resolveValue$1(node, type);
1617
+ }
1618
+ case 4: {
1619
+ const named = node;
1620
+ if (hasOwn(named, "k") && named.k) {
1621
+ return ctx.interpolate(ctx.named(named.k));
1622
+ }
1623
+ if (hasOwn(named, "key") && named.key) {
1624
+ return ctx.interpolate(ctx.named(named.key));
1625
+ }
1626
+ throw createUnhandleNodeError(type);
1627
+ }
1628
+ case 5: {
1629
+ const list = node;
1630
+ if (hasOwn(list, "i") && isNumber(list.i)) {
1631
+ return ctx.interpolate(ctx.list(list.i));
1632
+ }
1633
+ if (hasOwn(list, "index") && isNumber(list.index)) {
1634
+ return ctx.interpolate(ctx.list(list.index));
1635
+ }
1636
+ throw createUnhandleNodeError(type);
1637
+ }
1638
+ case 6: {
1639
+ const linked = node;
1640
+ const modifier = resolveLinkedModifier(linked);
1641
+ const key = resolveLinkedKey(linked);
1642
+ return ctx.linked(formatMessagePart(ctx, key), modifier ? formatMessagePart(ctx, modifier) : void 0, ctx.type);
1643
+ }
1644
+ case 7: {
1645
+ return resolveValue$1(node, type);
1646
+ }
1647
+ case 8: {
1648
+ return resolveValue$1(node, type);
1649
+ }
1650
+ default:
1651
+ throw new Error(`unhandled node on format message part: ${type}`);
1652
+ }
1653
+ }
1654
+ var WARN_MESSAGE = `Detected HTML in '{source}' message. Recommend not using HTML messages to avoid XSS.`;
1655
+ function checkHtmlMessage(source, warnHtmlMessage) {
1656
+ if (warnHtmlMessage && detectHtmlTag(source)) {
1657
+ warn(format(WARN_MESSAGE, { source }));
1658
+ }
1659
+ }
1660
+ var defaultOnCacheKey = (message) => message;
1661
+ var compileCache = create();
1662
+ function clearCompileCache() {
1663
+ compileCache = create();
1664
+ }
1665
+ function baseCompile2(message, options = {}) {
1666
+ let detectError = false;
1667
+ const onError = options.onError || defaultOnError;
1668
+ options.onError = (err) => {
1669
+ detectError = true;
1670
+ onError(err);
1671
+ };
1672
+ return { ...baseCompile(message, options), detectError };
1673
+ }
1674
+ function compile(message, context) {
1675
+ if (!__INTLIFY_DROP_MESSAGE_COMPILER__ && isString(message)) {
1676
+ const warnHtmlMessage = isBoolean(context.warnHtmlMessage) ? context.warnHtmlMessage : true;
1677
+ checkHtmlMessage(message, warnHtmlMessage);
1678
+ const onCacheKey = context.onCacheKey || defaultOnCacheKey;
1679
+ const cacheKey = onCacheKey(message);
1680
+ const cached = compileCache[cacheKey];
1681
+ if (cached) {
1682
+ return cached;
1683
+ }
1684
+ const { ast, detectError } = baseCompile2(message, {
1685
+ ...context,
1686
+ location: true,
1687
+ jit: true
1688
+ });
1689
+ const msg = format2(ast);
1690
+ return !detectError ? compileCache[cacheKey] = msg : msg;
1691
+ } else {
1692
+ if (!isMessageAST(message)) {
1693
+ warn(`the message that is resolve with key '${context.key}' is not supported for jit compilation`);
1694
+ return () => message;
1695
+ }
1696
+ const cacheKey = message.cacheKey;
1697
+ if (cacheKey) {
1698
+ const cached = compileCache[cacheKey];
1699
+ if (cached) {
1700
+ return cached;
1701
+ }
1702
+ return compileCache[cacheKey] = format2(message);
1703
+ } else {
1704
+ return format2(message);
1705
+ }
1706
+ }
1707
+ }
1708
+ var devtools = null;
1709
+ function setDevToolsHook(hook) {
1710
+ devtools = hook;
1711
+ }
1712
+ function getDevToolsHook() {
1713
+ return devtools;
1714
+ }
1715
+ function initI18nDevTools(i18n, version, meta) {
1716
+ devtools && devtools.emit("i18n:init", {
1717
+ timestamp: Date.now(),
1718
+ i18n,
1719
+ version,
1720
+ meta
1721
+ });
1722
+ }
1723
+ var translateDevTools = createDevToolsHook("function:translate");
1724
+ function createDevToolsHook(hook) {
1725
+ return (payloads) => devtools && devtools.emit(hook, payloads);
1726
+ }
1727
+ var CoreErrorCodes = {
1728
+ INVALID_ARGUMENT: COMPILE_ERROR_CODES_EXTEND_POINT,
1729
+ // 17
1730
+ INVALID_DATE_ARGUMENT: 18,
1731
+ INVALID_ISO_DATE_ARGUMENT: 19,
1732
+ NOT_SUPPORT_NON_STRING_MESSAGE: 20,
1733
+ NOT_SUPPORT_LOCALE_PROMISE_VALUE: 21,
1734
+ NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: 22,
1735
+ NOT_SUPPORT_LOCALE_TYPE: 23
1736
+ };
1737
+ var CORE_ERROR_CODES_EXTEND_POINT = 24;
1738
+ function createCoreError(code) {
1739
+ return createCompileError(code, null, true ? { messages: errorMessages2 } : void 0);
1740
+ }
1741
+ var errorMessages2 = {
1742
+ [CoreErrorCodes.INVALID_ARGUMENT]: "Invalid arguments",
1743
+ [CoreErrorCodes.INVALID_DATE_ARGUMENT]: "The date provided is an invalid Date object.Make sure your Date represents a valid date.",
1744
+ [CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT]: "The argument provided is not a valid ISO date string",
1745
+ [CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE]: "Not support non-string message",
1746
+ [CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE]: "cannot support promise value",
1747
+ [CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION]: "cannot support async function",
1748
+ [CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE]: "cannot support locale type"
1749
+ };
1750
+ function getLocale(context, options) {
1751
+ return options.locale != null ? resolveLocale(options.locale) : resolveLocale(context.locale);
1752
+ }
1753
+ var _resolveLocale;
1754
+ function resolveLocale(locale) {
1755
+ if (isString(locale)) {
1756
+ return locale;
1757
+ } else {
1758
+ if (isFunction(locale)) {
1759
+ if (locale.resolvedOnce && _resolveLocale != null) {
1760
+ return _resolveLocale;
1761
+ } else if (locale.constructor.name === "Function") {
1762
+ const resolve = locale();
1763
+ if (isPromise(resolve)) {
1764
+ throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE);
1765
+ }
1766
+ return _resolveLocale = resolve;
1767
+ } else {
1768
+ throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION);
1769
+ }
1770
+ } else {
1771
+ throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE);
1772
+ }
1773
+ }
1774
+ }
1775
+ function fallbackWithSimple(ctx, fallback, start) {
1776
+ return [.../* @__PURE__ */ new Set([
1777
+ start,
1778
+ ...isArray(fallback) ? fallback : isObject(fallback) ? Object.keys(fallback) : isString(fallback) ? [fallback] : [start]
1779
+ ])];
1780
+ }
1781
+ function fallbackWithLocaleChain(ctx, fallback, start) {
1782
+ const startLocale = isString(start) ? start : DEFAULT_LOCALE;
1783
+ const context = ctx;
1784
+ if (!context.__localeChainCache) {
1785
+ context.__localeChainCache = /* @__PURE__ */ new Map();
1786
+ }
1787
+ let chain = context.__localeChainCache.get(startLocale);
1788
+ if (!chain) {
1789
+ chain = [];
1790
+ let block = [start];
1791
+ while (isArray(block)) {
1792
+ block = appendBlockToChain(chain, block, fallback);
1793
+ }
1794
+ const defaults = isArray(fallback) || !isPlainObject(fallback) ? fallback : fallback["default"] ? fallback["default"] : null;
1795
+ block = isString(defaults) ? [defaults] : defaults;
1796
+ if (isArray(block)) {
1797
+ appendBlockToChain(chain, block, false);
1798
+ }
1799
+ context.__localeChainCache.set(startLocale, chain);
1800
+ }
1801
+ return chain;
1802
+ }
1803
+ function appendBlockToChain(chain, block, blocks) {
1804
+ let follow = true;
1805
+ for (let i = 0; i < block.length && isBoolean(follow); i++) {
1806
+ const locale = block[i];
1807
+ if (isString(locale)) {
1808
+ follow = appendLocaleToChain(chain, block[i], blocks);
1809
+ }
1810
+ }
1811
+ return follow;
1812
+ }
1813
+ function appendLocaleToChain(chain, locale, blocks) {
1814
+ let follow;
1815
+ const tokens = locale.split("-");
1816
+ do {
1817
+ const target = tokens.join("-");
1818
+ follow = appendItemToChain(chain, target, blocks);
1819
+ tokens.splice(-1, 1);
1820
+ } while (tokens.length && follow === true);
1821
+ return follow;
1822
+ }
1823
+ function appendItemToChain(chain, target, blocks) {
1824
+ let follow = false;
1825
+ if (!chain.includes(target)) {
1826
+ follow = true;
1827
+ if (target) {
1828
+ follow = target[target.length - 1] !== "!";
1829
+ const locale = target.replace(/!/g, "");
1830
+ chain.push(locale);
1831
+ if ((isArray(blocks) || isPlainObject(blocks)) && blocks[locale]) {
1832
+ follow = blocks[locale];
1833
+ }
1834
+ }
1835
+ }
1836
+ return follow;
1837
+ }
1838
+ var pathStateMachine = [];
1839
+ pathStateMachine[
1840
+ 0
1841
+ /* States.BEFORE_PATH */
1842
+ ] = {
1843
+ [
1844
+ "w"
1845
+ /* PathCharTypes.WORKSPACE */
1846
+ ]: [
1847
+ 0
1848
+ /* States.BEFORE_PATH */
1849
+ ],
1850
+ [
1851
+ "i"
1852
+ /* PathCharTypes.IDENT */
1853
+ ]: [
1854
+ 3,
1855
+ 0
1856
+ /* Actions.APPEND */
1857
+ ],
1858
+ [
1859
+ "["
1860
+ /* PathCharTypes.LEFT_BRACKET */
1861
+ ]: [
1862
+ 4
1863
+ /* States.IN_SUB_PATH */
1864
+ ],
1865
+ [
1866
+ "o"
1867
+ /* PathCharTypes.END_OF_FAIL */
1868
+ ]: [
1869
+ 7
1870
+ /* States.AFTER_PATH */
1871
+ ]
1872
+ };
1873
+ pathStateMachine[
1874
+ 1
1875
+ /* States.IN_PATH */
1876
+ ] = {
1877
+ [
1878
+ "w"
1879
+ /* PathCharTypes.WORKSPACE */
1880
+ ]: [
1881
+ 1
1882
+ /* States.IN_PATH */
1883
+ ],
1884
+ [
1885
+ "."
1886
+ /* PathCharTypes.DOT */
1887
+ ]: [
1888
+ 2
1889
+ /* States.BEFORE_IDENT */
1890
+ ],
1891
+ [
1892
+ "["
1893
+ /* PathCharTypes.LEFT_BRACKET */
1894
+ ]: [
1895
+ 4
1896
+ /* States.IN_SUB_PATH */
1897
+ ],
1898
+ [
1899
+ "o"
1900
+ /* PathCharTypes.END_OF_FAIL */
1901
+ ]: [
1902
+ 7
1903
+ /* States.AFTER_PATH */
1904
+ ]
1905
+ };
1906
+ pathStateMachine[
1907
+ 2
1908
+ /* States.BEFORE_IDENT */
1909
+ ] = {
1910
+ [
1911
+ "w"
1912
+ /* PathCharTypes.WORKSPACE */
1913
+ ]: [
1914
+ 2
1915
+ /* States.BEFORE_IDENT */
1916
+ ],
1917
+ [
1918
+ "i"
1919
+ /* PathCharTypes.IDENT */
1920
+ ]: [
1921
+ 3,
1922
+ 0
1923
+ /* Actions.APPEND */
1924
+ ],
1925
+ [
1926
+ "0"
1927
+ /* PathCharTypes.ZERO */
1928
+ ]: [
1929
+ 3,
1930
+ 0
1931
+ /* Actions.APPEND */
1932
+ ]
1933
+ };
1934
+ pathStateMachine[
1935
+ 3
1936
+ /* States.IN_IDENT */
1937
+ ] = {
1938
+ [
1939
+ "i"
1940
+ /* PathCharTypes.IDENT */
1941
+ ]: [
1942
+ 3,
1943
+ 0
1944
+ /* Actions.APPEND */
1945
+ ],
1946
+ [
1947
+ "0"
1948
+ /* PathCharTypes.ZERO */
1949
+ ]: [
1950
+ 3,
1951
+ 0
1952
+ /* Actions.APPEND */
1953
+ ],
1954
+ [
1955
+ "w"
1956
+ /* PathCharTypes.WORKSPACE */
1957
+ ]: [
1958
+ 1,
1959
+ 1
1960
+ /* Actions.PUSH */
1961
+ ],
1962
+ [
1963
+ "."
1964
+ /* PathCharTypes.DOT */
1965
+ ]: [
1966
+ 2,
1967
+ 1
1968
+ /* Actions.PUSH */
1969
+ ],
1970
+ [
1971
+ "["
1972
+ /* PathCharTypes.LEFT_BRACKET */
1973
+ ]: [
1974
+ 4,
1975
+ 1
1976
+ /* Actions.PUSH */
1977
+ ],
1978
+ [
1979
+ "o"
1980
+ /* PathCharTypes.END_OF_FAIL */
1981
+ ]: [
1982
+ 7,
1983
+ 1
1984
+ /* Actions.PUSH */
1985
+ ]
1986
+ };
1987
+ pathStateMachine[
1988
+ 4
1989
+ /* States.IN_SUB_PATH */
1990
+ ] = {
1991
+ [
1992
+ "'"
1993
+ /* PathCharTypes.SINGLE_QUOTE */
1994
+ ]: [
1995
+ 5,
1996
+ 0
1997
+ /* Actions.APPEND */
1998
+ ],
1999
+ [
2000
+ '"'
2001
+ /* PathCharTypes.DOUBLE_QUOTE */
2002
+ ]: [
2003
+ 6,
2004
+ 0
2005
+ /* Actions.APPEND */
2006
+ ],
2007
+ [
2008
+ "["
2009
+ /* PathCharTypes.LEFT_BRACKET */
2010
+ ]: [
2011
+ 4,
2012
+ 2
2013
+ /* Actions.INC_SUB_PATH_DEPTH */
2014
+ ],
2015
+ [
2016
+ "]"
2017
+ /* PathCharTypes.RIGHT_BRACKET */
2018
+ ]: [
2019
+ 1,
2020
+ 3
2021
+ /* Actions.PUSH_SUB_PATH */
2022
+ ],
2023
+ [
2024
+ "o"
2025
+ /* PathCharTypes.END_OF_FAIL */
2026
+ ]: 8,
2027
+ [
2028
+ "l"
2029
+ /* PathCharTypes.ELSE */
2030
+ ]: [
2031
+ 4,
2032
+ 0
2033
+ /* Actions.APPEND */
2034
+ ]
2035
+ };
2036
+ pathStateMachine[
2037
+ 5
2038
+ /* States.IN_SINGLE_QUOTE */
2039
+ ] = {
2040
+ [
2041
+ "'"
2042
+ /* PathCharTypes.SINGLE_QUOTE */
2043
+ ]: [
2044
+ 4,
2045
+ 0
2046
+ /* Actions.APPEND */
2047
+ ],
2048
+ [
2049
+ "o"
2050
+ /* PathCharTypes.END_OF_FAIL */
2051
+ ]: 8,
2052
+ [
2053
+ "l"
2054
+ /* PathCharTypes.ELSE */
2055
+ ]: [
2056
+ 5,
2057
+ 0
2058
+ /* Actions.APPEND */
2059
+ ]
2060
+ };
2061
+ pathStateMachine[
2062
+ 6
2063
+ /* States.IN_DOUBLE_QUOTE */
2064
+ ] = {
2065
+ [
2066
+ '"'
2067
+ /* PathCharTypes.DOUBLE_QUOTE */
2068
+ ]: [
2069
+ 4,
2070
+ 0
2071
+ /* Actions.APPEND */
2072
+ ],
2073
+ [
2074
+ "o"
2075
+ /* PathCharTypes.END_OF_FAIL */
2076
+ ]: 8,
2077
+ [
2078
+ "l"
2079
+ /* PathCharTypes.ELSE */
2080
+ ]: [
2081
+ 6,
2082
+ 0
2083
+ /* Actions.APPEND */
2084
+ ]
2085
+ };
2086
+ var literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;
2087
+ function isLiteral(exp) {
2088
+ return literalValueRE.test(exp);
2089
+ }
2090
+ function stripQuotes(str) {
2091
+ const a = str.charCodeAt(0);
2092
+ const b = str.charCodeAt(str.length - 1);
2093
+ return a === b && (a === 34 || a === 39) ? str.slice(1, -1) : str;
2094
+ }
2095
+ function getPathCharType(ch) {
2096
+ if (ch === void 0 || ch === null) {
2097
+ return "o";
2098
+ }
2099
+ const code = ch.charCodeAt(0);
2100
+ switch (code) {
2101
+ case 91:
2102
+ // [
2103
+ case 93:
2104
+ // ]
2105
+ case 46:
2106
+ // .
2107
+ case 34:
2108
+ // "
2109
+ case 39:
2110
+ return ch;
2111
+ case 95:
2112
+ // _
2113
+ case 36:
2114
+ // $
2115
+ case 45:
2116
+ return "i";
2117
+ case 9:
2118
+ // Tab (HT)
2119
+ case 10:
2120
+ // Newline (LF)
2121
+ case 13:
2122
+ // Return (CR)
2123
+ case 160:
2124
+ // No-break space (NBSP)
2125
+ case 65279:
2126
+ // Byte Order Mark (BOM)
2127
+ case 8232:
2128
+ // Line Separator (LS)
2129
+ case 8233:
2130
+ return "w";
2131
+ }
2132
+ return "i";
2133
+ }
2134
+ function formatSubPath(path) {
2135
+ const trimmed = path.trim();
2136
+ if (path.charAt(0) === "0" && isNaN(parseInt(path))) {
2137
+ return false;
2138
+ }
2139
+ return isLiteral(trimmed) ? stripQuotes(trimmed) : "*" + trimmed;
2140
+ }
2141
+ function parse(path) {
2142
+ const keys = [];
2143
+ let index = -1;
2144
+ let mode = 0;
2145
+ let subPathDepth = 0;
2146
+ let c;
2147
+ let key;
2148
+ let newChar;
2149
+ let type;
2150
+ let transition;
2151
+ let action;
2152
+ let typeMap;
2153
+ const actions = [];
2154
+ actions[
2155
+ 0
2156
+ /* Actions.APPEND */
2157
+ ] = () => {
2158
+ if (key === void 0) {
2159
+ key = newChar;
2160
+ } else {
2161
+ key += newChar;
2162
+ }
2163
+ };
2164
+ actions[
2165
+ 1
2166
+ /* Actions.PUSH */
2167
+ ] = () => {
2168
+ if (key !== void 0) {
2169
+ keys.push(key);
2170
+ key = void 0;
2171
+ }
2172
+ };
2173
+ actions[
2174
+ 2
2175
+ /* Actions.INC_SUB_PATH_DEPTH */
2176
+ ] = () => {
2177
+ actions[
2178
+ 0
2179
+ /* Actions.APPEND */
2180
+ ]();
2181
+ subPathDepth++;
2182
+ };
2183
+ actions[
2184
+ 3
2185
+ /* Actions.PUSH_SUB_PATH */
2186
+ ] = () => {
2187
+ if (subPathDepth > 0) {
2188
+ subPathDepth--;
2189
+ mode = 4;
2190
+ actions[
2191
+ 0
2192
+ /* Actions.APPEND */
2193
+ ]();
2194
+ } else {
2195
+ subPathDepth = 0;
2196
+ if (key === void 0) {
2197
+ return false;
2198
+ }
2199
+ key = formatSubPath(key);
2200
+ if (key === false) {
2201
+ return false;
2202
+ } else {
2203
+ actions[
2204
+ 1
2205
+ /* Actions.PUSH */
2206
+ ]();
2207
+ }
2208
+ }
2209
+ };
2210
+ function maybeUnescapeQuote() {
2211
+ const nextChar = path[index + 1];
2212
+ if (mode === 5 && nextChar === "'" || mode === 6 && nextChar === '"') {
2213
+ index++;
2214
+ newChar = "\\" + nextChar;
2215
+ actions[
2216
+ 0
2217
+ /* Actions.APPEND */
2218
+ ]();
2219
+ return true;
2220
+ }
2221
+ }
2222
+ while (mode !== null) {
2223
+ index++;
2224
+ c = path[index];
2225
+ if (c === "\\" && maybeUnescapeQuote()) {
2226
+ continue;
2227
+ }
2228
+ type = getPathCharType(c);
2229
+ typeMap = pathStateMachine[mode];
2230
+ transition = typeMap[type] || typeMap[
2231
+ "l"
2232
+ /* PathCharTypes.ELSE */
2233
+ ] || 8;
2234
+ if (transition === 8) {
2235
+ return;
2236
+ }
2237
+ mode = transition[0];
2238
+ if (transition[1] !== void 0) {
2239
+ action = actions[transition[1]];
2240
+ if (action) {
2241
+ newChar = c;
2242
+ if (action() === false) {
2243
+ return;
2244
+ }
2245
+ }
2246
+ }
2247
+ if (mode === 7) {
2248
+ return keys;
2249
+ }
2250
+ }
2251
+ }
2252
+ var cache = /* @__PURE__ */ new Map();
2253
+ function resolveWithKeyValue(obj, path) {
2254
+ return isObject(obj) ? obj[path] : null;
2255
+ }
2256
+ function resolveValue(obj, path) {
2257
+ if (!isObject(obj)) {
2258
+ return null;
2259
+ }
2260
+ let hit = cache.get(path);
2261
+ if (!hit) {
2262
+ hit = parse(path);
2263
+ if (hit) {
2264
+ cache.set(path, hit);
2265
+ }
2266
+ }
2267
+ if (!hit) {
2268
+ return null;
2269
+ }
2270
+ const len = hit.length;
2271
+ let last = obj;
2272
+ let i = 0;
2273
+ while (i < len) {
2274
+ const key = hit[i];
2275
+ if (AST_NODE_PROPS_KEYS.includes(key) && isMessageAST(last)) {
2276
+ return null;
2277
+ }
2278
+ const val = last[key];
2279
+ if (val === void 0) {
2280
+ return null;
2281
+ }
2282
+ if (isFunction(last)) {
2283
+ return null;
2284
+ }
2285
+ last = val;
2286
+ i++;
2287
+ }
2288
+ return last;
2289
+ }
2290
+ var CoreWarnCodes = {
2291
+ NOT_FOUND_KEY: 1,
2292
+ FALLBACK_TO_TRANSLATE: 2,
2293
+ CANNOT_FORMAT_NUMBER: 3,
2294
+ FALLBACK_TO_NUMBER_FORMAT: 4,
2295
+ CANNOT_FORMAT_DATE: 5,
2296
+ FALLBACK_TO_DATE_FORMAT: 6,
2297
+ EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: 7
2298
+ };
2299
+ var CORE_WARN_CODES_EXTEND_POINT = 8;
2300
+ var warnMessages = {
2301
+ [CoreWarnCodes.NOT_FOUND_KEY]: `Not found '{key}' key in '{locale}' locale messages.`,
2302
+ [CoreWarnCodes.FALLBACK_TO_TRANSLATE]: `Fall back to translate '{key}' key with '{target}' locale.`,
2303
+ [CoreWarnCodes.CANNOT_FORMAT_NUMBER]: `Cannot format a number value due to not supported Intl.NumberFormat.`,
2304
+ [CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT]: `Fall back to number format '{key}' key with '{target}' locale.`,
2305
+ [CoreWarnCodes.CANNOT_FORMAT_DATE]: `Cannot format a date value due to not supported Intl.DateTimeFormat.`,
2306
+ [CoreWarnCodes.FALLBACK_TO_DATE_FORMAT]: `Fall back to datetime format '{key}' key with '{target}' locale.`,
2307
+ [CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER]: `This project is using Custom Message Compiler, which is an experimental feature. It may receive breaking changes or be removed in the future.`
2308
+ };
2309
+ function getWarnMessage(code, ...args) {
2310
+ return format(warnMessages[code], ...args);
2311
+ }
2312
+ var VERSION = "10.0.7";
2313
+ var NOT_REOSLVED = -1;
2314
+ var DEFAULT_LOCALE = "en-US";
2315
+ var MISSING_RESOLVE_VALUE = "";
2316
+ var capitalize = (str) => `${str.charAt(0).toLocaleUpperCase()}${str.substr(1)}`;
2317
+ function getDefaultLinkedModifiers() {
2318
+ return {
2319
+ upper: (val, type) => {
2320
+ return type === "text" && isString(val) ? val.toUpperCase() : type === "vnode" && isObject(val) && "__v_isVNode" in val ? val.children.toUpperCase() : val;
2321
+ },
2322
+ lower: (val, type) => {
2323
+ return type === "text" && isString(val) ? val.toLowerCase() : type === "vnode" && isObject(val) && "__v_isVNode" in val ? val.children.toLowerCase() : val;
2324
+ },
2325
+ capitalize: (val, type) => {
2326
+ return type === "text" && isString(val) ? capitalize(val) : type === "vnode" && isObject(val) && "__v_isVNode" in val ? capitalize(val.children) : val;
2327
+ }
2328
+ };
2329
+ }
2330
+ var _compiler;
2331
+ function registerMessageCompiler(compiler) {
2332
+ _compiler = compiler;
2333
+ }
2334
+ var _resolver;
2335
+ function registerMessageResolver(resolver) {
2336
+ _resolver = resolver;
2337
+ }
2338
+ var _fallbacker;
2339
+ function registerLocaleFallbacker(fallbacker) {
2340
+ _fallbacker = fallbacker;
2341
+ }
2342
+ var _additionalMeta = null;
2343
+ var setAdditionalMeta = (meta) => {
2344
+ _additionalMeta = meta;
2345
+ };
2346
+ var getAdditionalMeta = () => _additionalMeta;
2347
+ var _fallbackContext = null;
2348
+ var setFallbackContext = (context) => {
2349
+ _fallbackContext = context;
2350
+ };
2351
+ var getFallbackContext = () => _fallbackContext;
2352
+ var _cid = 0;
2353
+ function createCoreContext(options = {}) {
2354
+ const onWarn = isFunction(options.onWarn) ? options.onWarn : warn;
2355
+ const version = isString(options.version) ? options.version : VERSION;
2356
+ const locale = isString(options.locale) || isFunction(options.locale) ? options.locale : DEFAULT_LOCALE;
2357
+ const _locale = isFunction(locale) ? DEFAULT_LOCALE : locale;
2358
+ const fallbackLocale = isArray(options.fallbackLocale) || isPlainObject(options.fallbackLocale) || isString(options.fallbackLocale) || options.fallbackLocale === false ? options.fallbackLocale : _locale;
2359
+ const messages = isPlainObject(options.messages) ? options.messages : createResources(_locale);
2360
+ const datetimeFormats = isPlainObject(options.datetimeFormats) ? options.datetimeFormats : createResources(_locale);
2361
+ const numberFormats = isPlainObject(options.numberFormats) ? options.numberFormats : createResources(_locale);
2362
+ const modifiers = assign(create(), options.modifiers, getDefaultLinkedModifiers());
2363
+ const pluralRules = options.pluralRules || create();
2364
+ const missing = isFunction(options.missing) ? options.missing : null;
2365
+ const missingWarn = isBoolean(options.missingWarn) || isRegExp(options.missingWarn) ? options.missingWarn : true;
2366
+ const fallbackWarn = isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) ? options.fallbackWarn : true;
2367
+ const fallbackFormat = !!options.fallbackFormat;
2368
+ const unresolving = !!options.unresolving;
2369
+ const postTranslation = isFunction(options.postTranslation) ? options.postTranslation : null;
2370
+ const processor = isPlainObject(options.processor) ? options.processor : null;
2371
+ const warnHtmlMessage = isBoolean(options.warnHtmlMessage) ? options.warnHtmlMessage : true;
2372
+ const escapeParameter = !!options.escapeParameter;
2373
+ const messageCompiler = isFunction(options.messageCompiler) ? options.messageCompiler : _compiler;
2374
+ if (isFunction(options.messageCompiler)) {
2375
+ warnOnce(getWarnMessage(CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER));
2376
+ }
2377
+ const messageResolver = isFunction(options.messageResolver) ? options.messageResolver : _resolver || resolveWithKeyValue;
2378
+ const localeFallbacker = isFunction(options.localeFallbacker) ? options.localeFallbacker : _fallbacker || fallbackWithSimple;
2379
+ const fallbackContext = isObject(options.fallbackContext) ? options.fallbackContext : void 0;
2380
+ const internalOptions = options;
2381
+ const __datetimeFormatters = isObject(internalOptions.__datetimeFormatters) ? internalOptions.__datetimeFormatters : /* @__PURE__ */ new Map();
2382
+ const __numberFormatters = isObject(internalOptions.__numberFormatters) ? internalOptions.__numberFormatters : /* @__PURE__ */ new Map();
2383
+ const __meta = isObject(internalOptions.__meta) ? internalOptions.__meta : {};
2384
+ _cid++;
2385
+ const context = {
2386
+ version,
2387
+ cid: _cid,
2388
+ locale,
2389
+ fallbackLocale,
2390
+ messages,
2391
+ modifiers,
2392
+ pluralRules,
2393
+ missing,
2394
+ missingWarn,
2395
+ fallbackWarn,
2396
+ fallbackFormat,
2397
+ unresolving,
2398
+ postTranslation,
2399
+ processor,
2400
+ warnHtmlMessage,
2401
+ escapeParameter,
2402
+ messageCompiler,
2403
+ messageResolver,
2404
+ localeFallbacker,
2405
+ fallbackContext,
2406
+ onWarn,
2407
+ __meta
2408
+ };
2409
+ {
2410
+ context.datetimeFormats = datetimeFormats;
2411
+ context.numberFormats = numberFormats;
2412
+ context.__datetimeFormatters = __datetimeFormatters;
2413
+ context.__numberFormatters = __numberFormatters;
2414
+ }
2415
+ if (true) {
2416
+ context.__v_emitter = internalOptions.__v_emitter != null ? internalOptions.__v_emitter : void 0;
2417
+ }
2418
+ if (true) {
2419
+ initI18nDevTools(context, version, __meta);
2420
+ }
2421
+ return context;
2422
+ }
2423
+ var createResources = (locale) => ({ [locale]: create() });
2424
+ function isTranslateFallbackWarn(fallback, key) {
2425
+ return fallback instanceof RegExp ? fallback.test(key) : fallback;
2426
+ }
2427
+ function isTranslateMissingWarn(missing, key) {
2428
+ return missing instanceof RegExp ? missing.test(key) : missing;
2429
+ }
2430
+ function handleMissing(context, key, locale, missingWarn, type) {
2431
+ const { missing, onWarn } = context;
2432
+ if (true) {
2433
+ const emitter = context.__v_emitter;
2434
+ if (emitter) {
2435
+ emitter.emit("missing", {
2436
+ locale,
2437
+ key,
2438
+ type,
2439
+ groupId: `${type}:${key}`
2440
+ });
2441
+ }
2442
+ }
2443
+ if (missing !== null) {
2444
+ const ret = missing(context, locale, key, type);
2445
+ return isString(ret) ? ret : key;
2446
+ } else {
2447
+ if (isTranslateMissingWarn(missingWarn, key)) {
2448
+ onWarn(getWarnMessage(CoreWarnCodes.NOT_FOUND_KEY, { key, locale }));
2449
+ }
2450
+ return key;
2451
+ }
2452
+ }
2453
+ function updateFallbackLocale(ctx, locale, fallback) {
2454
+ const context = ctx;
2455
+ context.__localeChainCache = /* @__PURE__ */ new Map();
2456
+ ctx.localeFallbacker(ctx, fallback, locale);
2457
+ }
2458
+ function isAlmostSameLocale(locale, compareLocale) {
2459
+ if (locale === compareLocale)
2460
+ return false;
2461
+ return locale.split("-")[0] === compareLocale.split("-")[0];
2462
+ }
2463
+ function isImplicitFallback(targetLocale, locales) {
2464
+ const index = locales.indexOf(targetLocale);
2465
+ if (index === -1) {
2466
+ return false;
2467
+ }
2468
+ for (let i = index + 1; i < locales.length; i++) {
2469
+ if (isAlmostSameLocale(targetLocale, locales[i])) {
2470
+ return true;
2471
+ }
2472
+ }
2473
+ return false;
2474
+ }
2475
+ var intlDefined = typeof Intl !== "undefined";
2476
+ var Availabilities = {
2477
+ dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== "undefined",
2478
+ numberFormat: intlDefined && typeof Intl.NumberFormat !== "undefined"
2479
+ };
2480
+ function datetime(context, ...args) {
2481
+ const { datetimeFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context;
2482
+ const { __datetimeFormatters } = context;
2483
+ if (!Availabilities.dateTimeFormat) {
2484
+ onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_DATE));
2485
+ return MISSING_RESOLVE_VALUE;
2486
+ }
2487
+ const [key, value, options, overrides] = parseDateTimeArgs(...args);
2488
+ const missingWarn = isBoolean(options.missingWarn) ? options.missingWarn : context.missingWarn;
2489
+ const fallbackWarn = isBoolean(options.fallbackWarn) ? options.fallbackWarn : context.fallbackWarn;
2490
+ const part = !!options.part;
2491
+ const locale = getLocale(context, options);
2492
+ const locales = localeFallbacker(
2493
+ context,
2494
+ // eslint-disable-line @typescript-eslint/no-explicit-any
2495
+ fallbackLocale,
2496
+ locale
2497
+ );
2498
+ if (!isString(key) || key === "") {
2499
+ return new Intl.DateTimeFormat(locale, overrides).format(value);
2500
+ }
2501
+ let datetimeFormat = {};
2502
+ let targetLocale;
2503
+ let format3 = null;
2504
+ let from = locale;
2505
+ let to = null;
2506
+ const type = "datetime format";
2507
+ for (let i = 0; i < locales.length; i++) {
2508
+ targetLocale = to = locales[i];
2509
+ if (locale !== targetLocale && isTranslateFallbackWarn(fallbackWarn, key)) {
2510
+ onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_DATE_FORMAT, {
2511
+ key,
2512
+ target: targetLocale
2513
+ }));
2514
+ }
2515
+ if (locale !== targetLocale) {
2516
+ const emitter = context.__v_emitter;
2517
+ if (emitter) {
2518
+ emitter.emit("fallback", {
2519
+ type,
2520
+ key,
2521
+ from,
2522
+ to,
2523
+ groupId: `${type}:${key}`
2524
+ });
2525
+ }
2526
+ }
2527
+ datetimeFormat = datetimeFormats[targetLocale] || {};
2528
+ format3 = datetimeFormat[key];
2529
+ if (isPlainObject(format3))
2530
+ break;
2531
+ handleMissing(context, key, targetLocale, missingWarn, type);
2532
+ from = to;
2533
+ }
2534
+ if (!isPlainObject(format3) || !isString(targetLocale)) {
2535
+ return unresolving ? NOT_REOSLVED : key;
2536
+ }
2537
+ let id = `${targetLocale}__${key}`;
2538
+ if (!isEmptyObject(overrides)) {
2539
+ id = `${id}__${JSON.stringify(overrides)}`;
2540
+ }
2541
+ let formatter = __datetimeFormatters.get(id);
2542
+ if (!formatter) {
2543
+ formatter = new Intl.DateTimeFormat(targetLocale, assign({}, format3, overrides));
2544
+ __datetimeFormatters.set(id, formatter);
2545
+ }
2546
+ return !part ? formatter.format(value) : formatter.formatToParts(value);
2547
+ }
2548
+ var DATETIME_FORMAT_OPTIONS_KEYS = [
2549
+ "localeMatcher",
2550
+ "weekday",
2551
+ "era",
2552
+ "year",
2553
+ "month",
2554
+ "day",
2555
+ "hour",
2556
+ "minute",
2557
+ "second",
2558
+ "timeZoneName",
2559
+ "formatMatcher",
2560
+ "hour12",
2561
+ "timeZone",
2562
+ "dateStyle",
2563
+ "timeStyle",
2564
+ "calendar",
2565
+ "dayPeriod",
2566
+ "numberingSystem",
2567
+ "hourCycle",
2568
+ "fractionalSecondDigits"
2569
+ ];
2570
+ function parseDateTimeArgs(...args) {
2571
+ const [arg1, arg2, arg3, arg4] = args;
2572
+ const options = create();
2573
+ let overrides = create();
2574
+ let value;
2575
+ if (isString(arg1)) {
2576
+ const matches = arg1.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/);
2577
+ if (!matches) {
2578
+ throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT);
2579
+ }
2580
+ const dateTime = matches[3] ? matches[3].trim().startsWith("T") ? `${matches[1].trim()}${matches[3].trim()}` : `${matches[1].trim()}T${matches[3].trim()}` : matches[1].trim();
2581
+ value = new Date(dateTime);
2582
+ try {
2583
+ value.toISOString();
2584
+ } catch {
2585
+ throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT);
2586
+ }
2587
+ } else if (isDate(arg1)) {
2588
+ if (isNaN(arg1.getTime())) {
2589
+ throw createCoreError(CoreErrorCodes.INVALID_DATE_ARGUMENT);
2590
+ }
2591
+ value = arg1;
2592
+ } else if (isNumber(arg1)) {
2593
+ value = arg1;
2594
+ } else {
2595
+ throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT);
2596
+ }
2597
+ if (isString(arg2)) {
2598
+ options.key = arg2;
2599
+ } else if (isPlainObject(arg2)) {
2600
+ Object.keys(arg2).forEach((key) => {
2601
+ if (DATETIME_FORMAT_OPTIONS_KEYS.includes(key)) {
2602
+ overrides[key] = arg2[key];
2603
+ } else {
2604
+ options[key] = arg2[key];
2605
+ }
2606
+ });
2607
+ }
2608
+ if (isString(arg3)) {
2609
+ options.locale = arg3;
2610
+ } else if (isPlainObject(arg3)) {
2611
+ overrides = arg3;
2612
+ }
2613
+ if (isPlainObject(arg4)) {
2614
+ overrides = arg4;
2615
+ }
2616
+ return [options.key || "", value, options, overrides];
2617
+ }
2618
+ function clearDateTimeFormat(ctx, locale, format3) {
2619
+ const context = ctx;
2620
+ for (const key in format3) {
2621
+ const id = `${locale}__${key}`;
2622
+ if (!context.__datetimeFormatters.has(id)) {
2623
+ continue;
2624
+ }
2625
+ context.__datetimeFormatters.delete(id);
2626
+ }
2627
+ }
2628
+ function number(context, ...args) {
2629
+ const { numberFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context;
2630
+ const { __numberFormatters } = context;
2631
+ if (!Availabilities.numberFormat) {
2632
+ onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_NUMBER));
2633
+ return MISSING_RESOLVE_VALUE;
2634
+ }
2635
+ const [key, value, options, overrides] = parseNumberArgs(...args);
2636
+ const missingWarn = isBoolean(options.missingWarn) ? options.missingWarn : context.missingWarn;
2637
+ const fallbackWarn = isBoolean(options.fallbackWarn) ? options.fallbackWarn : context.fallbackWarn;
2638
+ const part = !!options.part;
2639
+ const locale = getLocale(context, options);
2640
+ const locales = localeFallbacker(
2641
+ context,
2642
+ // eslint-disable-line @typescript-eslint/no-explicit-any
2643
+ fallbackLocale,
2644
+ locale
2645
+ );
2646
+ if (!isString(key) || key === "") {
2647
+ return new Intl.NumberFormat(locale, overrides).format(value);
2648
+ }
2649
+ let numberFormat = {};
2650
+ let targetLocale;
2651
+ let format3 = null;
2652
+ let from = locale;
2653
+ let to = null;
2654
+ const type = "number format";
2655
+ for (let i = 0; i < locales.length; i++) {
2656
+ targetLocale = to = locales[i];
2657
+ if (locale !== targetLocale && isTranslateFallbackWarn(fallbackWarn, key)) {
2658
+ onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT, {
2659
+ key,
2660
+ target: targetLocale
2661
+ }));
2662
+ }
2663
+ if (locale !== targetLocale) {
2664
+ const emitter = context.__v_emitter;
2665
+ if (emitter) {
2666
+ emitter.emit("fallback", {
2667
+ type,
2668
+ key,
2669
+ from,
2670
+ to,
2671
+ groupId: `${type}:${key}`
2672
+ });
2673
+ }
2674
+ }
2675
+ numberFormat = numberFormats[targetLocale] || {};
2676
+ format3 = numberFormat[key];
2677
+ if (isPlainObject(format3))
2678
+ break;
2679
+ handleMissing(context, key, targetLocale, missingWarn, type);
2680
+ from = to;
2681
+ }
2682
+ if (!isPlainObject(format3) || !isString(targetLocale)) {
2683
+ return unresolving ? NOT_REOSLVED : key;
2684
+ }
2685
+ let id = `${targetLocale}__${key}`;
2686
+ if (!isEmptyObject(overrides)) {
2687
+ id = `${id}__${JSON.stringify(overrides)}`;
2688
+ }
2689
+ let formatter = __numberFormatters.get(id);
2690
+ if (!formatter) {
2691
+ formatter = new Intl.NumberFormat(targetLocale, assign({}, format3, overrides));
2692
+ __numberFormatters.set(id, formatter);
2693
+ }
2694
+ return !part ? formatter.format(value) : formatter.formatToParts(value);
2695
+ }
2696
+ var NUMBER_FORMAT_OPTIONS_KEYS = [
2697
+ "localeMatcher",
2698
+ "style",
2699
+ "currency",
2700
+ "currencyDisplay",
2701
+ "currencySign",
2702
+ "useGrouping",
2703
+ "minimumIntegerDigits",
2704
+ "minimumFractionDigits",
2705
+ "maximumFractionDigits",
2706
+ "minimumSignificantDigits",
2707
+ "maximumSignificantDigits",
2708
+ "compactDisplay",
2709
+ "notation",
2710
+ "signDisplay",
2711
+ "unit",
2712
+ "unitDisplay",
2713
+ "roundingMode",
2714
+ "roundingPriority",
2715
+ "roundingIncrement",
2716
+ "trailingZeroDisplay"
2717
+ ];
2718
+ function parseNumberArgs(...args) {
2719
+ const [arg1, arg2, arg3, arg4] = args;
2720
+ const options = create();
2721
+ let overrides = create();
2722
+ if (!isNumber(arg1)) {
2723
+ throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT);
2724
+ }
2725
+ const value = arg1;
2726
+ if (isString(arg2)) {
2727
+ options.key = arg2;
2728
+ } else if (isPlainObject(arg2)) {
2729
+ Object.keys(arg2).forEach((key) => {
2730
+ if (NUMBER_FORMAT_OPTIONS_KEYS.includes(key)) {
2731
+ overrides[key] = arg2[key];
2732
+ } else {
2733
+ options[key] = arg2[key];
2734
+ }
2735
+ });
2736
+ }
2737
+ if (isString(arg3)) {
2738
+ options.locale = arg3;
2739
+ } else if (isPlainObject(arg3)) {
2740
+ overrides = arg3;
2741
+ }
2742
+ if (isPlainObject(arg4)) {
2743
+ overrides = arg4;
2744
+ }
2745
+ return [options.key || "", value, options, overrides];
2746
+ }
2747
+ function clearNumberFormat(ctx, locale, format3) {
2748
+ const context = ctx;
2749
+ for (const key in format3) {
2750
+ const id = `${locale}__${key}`;
2751
+ if (!context.__numberFormatters.has(id)) {
2752
+ continue;
2753
+ }
2754
+ context.__numberFormatters.delete(id);
2755
+ }
2756
+ }
2757
+ var DEFAULT_MODIFIER = (str) => str;
2758
+ var DEFAULT_MESSAGE = (ctx) => "";
2759
+ var DEFAULT_MESSAGE_DATA_TYPE = "text";
2760
+ var DEFAULT_NORMALIZE = (values) => values.length === 0 ? "" : join(values);
2761
+ var DEFAULT_INTERPOLATE = toDisplayString;
2762
+ function pluralDefault(choice, choicesLength) {
2763
+ choice = Math.abs(choice);
2764
+ if (choicesLength === 2) {
2765
+ return choice ? choice > 1 ? 1 : 0 : 1;
2766
+ }
2767
+ return choice ? Math.min(choice, 2) : 0;
2768
+ }
2769
+ function getPluralIndex(options) {
2770
+ const index = isNumber(options.pluralIndex) ? options.pluralIndex : -1;
2771
+ return options.named && (isNumber(options.named.count) || isNumber(options.named.n)) ? isNumber(options.named.count) ? options.named.count : isNumber(options.named.n) ? options.named.n : index : index;
2772
+ }
2773
+ function normalizeNamed(pluralIndex, props) {
2774
+ if (!props.count) {
2775
+ props.count = pluralIndex;
2776
+ }
2777
+ if (!props.n) {
2778
+ props.n = pluralIndex;
2779
+ }
2780
+ }
2781
+ function createMessageContext(options = {}) {
2782
+ const locale = options.locale;
2783
+ const pluralIndex = getPluralIndex(options);
2784
+ const pluralRule = isObject(options.pluralRules) && isString(locale) && isFunction(options.pluralRules[locale]) ? options.pluralRules[locale] : pluralDefault;
2785
+ const orgPluralRule = isObject(options.pluralRules) && isString(locale) && isFunction(options.pluralRules[locale]) ? pluralDefault : void 0;
2786
+ const plural = (messages) => {
2787
+ return messages[pluralRule(pluralIndex, messages.length, orgPluralRule)];
2788
+ };
2789
+ const _list = options.list || [];
2790
+ const list = (index) => _list[index];
2791
+ const _named = options.named || create();
2792
+ isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named);
2793
+ const named = (key) => _named[key];
2794
+ function message(key, useLinked) {
2795
+ const msg = isFunction(options.messages) ? options.messages(key, !!useLinked) : isObject(options.messages) ? options.messages[key] : false;
2796
+ return !msg ? options.parent ? options.parent.message(key) : DEFAULT_MESSAGE : msg;
2797
+ }
2798
+ const _modifier = (name) => options.modifiers ? options.modifiers[name] : DEFAULT_MODIFIER;
2799
+ const normalize = isPlainObject(options.processor) && isFunction(options.processor.normalize) ? options.processor.normalize : DEFAULT_NORMALIZE;
2800
+ const interpolate = isPlainObject(options.processor) && isFunction(options.processor.interpolate) ? options.processor.interpolate : DEFAULT_INTERPOLATE;
2801
+ const type = isPlainObject(options.processor) && isString(options.processor.type) ? options.processor.type : DEFAULT_MESSAGE_DATA_TYPE;
2802
+ const linked = (key, ...args) => {
2803
+ const [arg1, arg2] = args;
2804
+ let type2 = "text";
2805
+ let modifier = "";
2806
+ if (args.length === 1) {
2807
+ if (isObject(arg1)) {
2808
+ modifier = arg1.modifier || modifier;
2809
+ type2 = arg1.type || type2;
2810
+ } else if (isString(arg1)) {
2811
+ modifier = arg1 || modifier;
2812
+ }
2813
+ } else if (args.length === 2) {
2814
+ if (isString(arg1)) {
2815
+ modifier = arg1 || modifier;
2816
+ }
2817
+ if (isString(arg2)) {
2818
+ type2 = arg2 || type2;
2819
+ }
2820
+ }
2821
+ const ret = message(key, true)(ctx);
2822
+ const msg = (
2823
+ // The message in vnode resolved with linked are returned as an array by processor.nomalize
2824
+ type2 === "vnode" && isArray(ret) && modifier ? ret[0] : ret
2825
+ );
2826
+ return modifier ? _modifier(modifier)(msg, type2) : msg;
2827
+ };
2828
+ const ctx = {
2829
+ [
2830
+ "list"
2831
+ /* HelperNameMap.LIST */
2832
+ ]: list,
2833
+ [
2834
+ "named"
2835
+ /* HelperNameMap.NAMED */
2836
+ ]: named,
2837
+ [
2838
+ "plural"
2839
+ /* HelperNameMap.PLURAL */
2840
+ ]: plural,
2841
+ [
2842
+ "linked"
2843
+ /* HelperNameMap.LINKED */
2844
+ ]: linked,
2845
+ [
2846
+ "message"
2847
+ /* HelperNameMap.MESSAGE */
2848
+ ]: message,
2849
+ [
2850
+ "type"
2851
+ /* HelperNameMap.TYPE */
2852
+ ]: type,
2853
+ [
2854
+ "interpolate"
2855
+ /* HelperNameMap.INTERPOLATE */
2856
+ ]: interpolate,
2857
+ [
2858
+ "normalize"
2859
+ /* HelperNameMap.NORMALIZE */
2860
+ ]: normalize,
2861
+ [
2862
+ "values"
2863
+ /* HelperNameMap.VALUES */
2864
+ ]: assign(create(), _list, _named)
2865
+ };
2866
+ return ctx;
2867
+ }
2868
+ var NOOP_MESSAGE_FUNCTION = () => "";
2869
+ var isMessageFunction = (val) => isFunction(val);
2870
+ function translate(context, ...args) {
2871
+ const { fallbackFormat, postTranslation, unresolving, messageCompiler, fallbackLocale, messages } = context;
2872
+ const [key, options] = parseTranslateArgs(...args);
2873
+ const missingWarn = isBoolean(options.missingWarn) ? options.missingWarn : context.missingWarn;
2874
+ const fallbackWarn = isBoolean(options.fallbackWarn) ? options.fallbackWarn : context.fallbackWarn;
2875
+ const escapeParameter = isBoolean(options.escapeParameter) ? options.escapeParameter : context.escapeParameter;
2876
+ const resolvedMessage = !!options.resolvedMessage;
2877
+ const defaultMsgOrKey = isString(options.default) || isBoolean(options.default) ? !isBoolean(options.default) ? options.default : !messageCompiler ? () => key : key : fallbackFormat ? !messageCompiler ? () => key : key : null;
2878
+ const enableDefaultMsg = fallbackFormat || defaultMsgOrKey != null && (isString(defaultMsgOrKey) || isFunction(defaultMsgOrKey));
2879
+ const locale = getLocale(context, options);
2880
+ escapeParameter && escapeParams(options);
2881
+ let [formatScope, targetLocale, message] = !resolvedMessage ? resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) : [
2882
+ key,
2883
+ locale,
2884
+ messages[locale] || create()
2885
+ ];
2886
+ let format3 = formatScope;
2887
+ let cacheBaseKey = key;
2888
+ if (!resolvedMessage && !(isString(format3) || isMessageAST(format3) || isMessageFunction(format3))) {
2889
+ if (enableDefaultMsg) {
2890
+ format3 = defaultMsgOrKey;
2891
+ cacheBaseKey = format3;
2892
+ }
2893
+ }
2894
+ if (!resolvedMessage && (!(isString(format3) || isMessageAST(format3) || isMessageFunction(format3)) || !isString(targetLocale))) {
2895
+ return unresolving ? NOT_REOSLVED : key;
2896
+ }
2897
+ if (isString(format3) && context.messageCompiler == null) {
2898
+ warn(`The message format compilation is not supported in this build. Because message compiler isn't included. You need to pre-compilation all message format. So translate function return '${key}'.`);
2899
+ return key;
2900
+ }
2901
+ let occurred = false;
2902
+ const onError = () => {
2903
+ occurred = true;
2904
+ };
2905
+ const msg = !isMessageFunction(format3) ? compileMessageFormat(context, key, targetLocale, format3, cacheBaseKey, onError) : format3;
2906
+ if (occurred) {
2907
+ return format3;
2908
+ }
2909
+ const ctxOptions = getMessageContextOptions(context, targetLocale, message, options);
2910
+ const msgContext = createMessageContext(ctxOptions);
2911
+ const messaged = evaluateMessage(context, msg, msgContext);
2912
+ const ret = postTranslation ? postTranslation(messaged, key) : messaged;
2913
+ if (true) {
2914
+ const payloads = {
2915
+ timestamp: Date.now(),
2916
+ key: isString(key) ? key : isMessageFunction(format3) ? format3.key : "",
2917
+ locale: targetLocale || (isMessageFunction(format3) ? format3.locale : ""),
2918
+ format: isString(format3) ? format3 : isMessageFunction(format3) ? format3.source : "",
2919
+ message: ret
2920
+ };
2921
+ payloads.meta = assign({}, context.__meta, getAdditionalMeta() || {});
2922
+ translateDevTools(payloads);
2923
+ }
2924
+ return ret;
2925
+ }
2926
+ function escapeParams(options) {
2927
+ if (isArray(options.list)) {
2928
+ options.list = options.list.map((item) => isString(item) ? escapeHtml(item) : item);
2929
+ } else if (isObject(options.named)) {
2930
+ Object.keys(options.named).forEach((key) => {
2931
+ if (isString(options.named[key])) {
2932
+ options.named[key] = escapeHtml(options.named[key]);
2933
+ }
2934
+ });
2935
+ }
2936
+ }
2937
+ function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) {
2938
+ const { messages, onWarn, messageResolver: resolveValue2, localeFallbacker } = context;
2939
+ const locales = localeFallbacker(context, fallbackLocale, locale);
2940
+ let message = create();
2941
+ let targetLocale;
2942
+ let format3 = null;
2943
+ let from = locale;
2944
+ let to = null;
2945
+ const type = "translate";
2946
+ for (let i = 0; i < locales.length; i++) {
2947
+ targetLocale = to = locales[i];
2948
+ if (locale !== targetLocale && !isAlmostSameLocale(locale, targetLocale) && isTranslateFallbackWarn(fallbackWarn, key)) {
2949
+ onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_TRANSLATE, {
2950
+ key,
2951
+ target: targetLocale
2952
+ }));
2953
+ }
2954
+ if (locale !== targetLocale) {
2955
+ const emitter = context.__v_emitter;
2956
+ if (emitter) {
2957
+ emitter.emit("fallback", {
2958
+ type,
2959
+ key,
2960
+ from,
2961
+ to,
2962
+ groupId: `${type}:${key}`
2963
+ });
2964
+ }
2965
+ }
2966
+ message = messages[targetLocale] || create();
2967
+ let start = null;
2968
+ let startTag;
2969
+ let endTag;
2970
+ if (inBrowser) {
2971
+ start = window.performance.now();
2972
+ startTag = "intlify-message-resolve-start";
2973
+ endTag = "intlify-message-resolve-end";
2974
+ mark && mark(startTag);
2975
+ }
2976
+ if ((format3 = resolveValue2(message, key)) === null) {
2977
+ format3 = message[key];
2978
+ }
2979
+ if (inBrowser) {
2980
+ const end = window.performance.now();
2981
+ const emitter = context.__v_emitter;
2982
+ if (emitter && start && format3) {
2983
+ emitter.emit("message-resolve", {
2984
+ type: "message-resolve",
2985
+ key,
2986
+ message: format3,
2987
+ time: end - start,
2988
+ groupId: `${type}:${key}`
2989
+ });
2990
+ }
2991
+ if (startTag && endTag && mark && measure) {
2992
+ mark(endTag);
2993
+ measure("intlify message resolve", startTag, endTag);
2994
+ }
2995
+ }
2996
+ if (isString(format3) || isMessageAST(format3) || isMessageFunction(format3)) {
2997
+ break;
2998
+ }
2999
+ if (!isImplicitFallback(targetLocale, locales)) {
3000
+ const missingRet = handleMissing(
3001
+ context,
3002
+ // eslint-disable-line @typescript-eslint/no-explicit-any
3003
+ key,
3004
+ targetLocale,
3005
+ missingWarn,
3006
+ type
3007
+ );
3008
+ if (missingRet !== key) {
3009
+ format3 = missingRet;
3010
+ }
3011
+ }
3012
+ from = to;
3013
+ }
3014
+ return [format3, targetLocale, message];
3015
+ }
3016
+ function compileMessageFormat(context, key, targetLocale, format3, cacheBaseKey, onError) {
3017
+ const { messageCompiler, warnHtmlMessage } = context;
3018
+ if (isMessageFunction(format3)) {
3019
+ const msg2 = format3;
3020
+ msg2.locale = msg2.locale || targetLocale;
3021
+ msg2.key = msg2.key || key;
3022
+ return msg2;
3023
+ }
3024
+ if (messageCompiler == null) {
3025
+ const msg2 = () => format3;
3026
+ msg2.locale = targetLocale;
3027
+ msg2.key = key;
3028
+ return msg2;
3029
+ }
3030
+ let start = null;
3031
+ let startTag;
3032
+ let endTag;
3033
+ if (inBrowser) {
3034
+ start = window.performance.now();
3035
+ startTag = "intlify-message-compilation-start";
3036
+ endTag = "intlify-message-compilation-end";
3037
+ mark && mark(startTag);
3038
+ }
3039
+ const msg = messageCompiler(format3, getCompileContext(context, targetLocale, cacheBaseKey, format3, warnHtmlMessage, onError));
3040
+ if (inBrowser) {
3041
+ const end = window.performance.now();
3042
+ const emitter = context.__v_emitter;
3043
+ if (emitter && start) {
3044
+ emitter.emit("message-compilation", {
3045
+ type: "message-compilation",
3046
+ message: format3,
3047
+ time: end - start,
3048
+ groupId: `${"translate"}:${key}`
3049
+ });
3050
+ }
3051
+ if (startTag && endTag && mark && measure) {
3052
+ mark(endTag);
3053
+ measure("intlify message compilation", startTag, endTag);
3054
+ }
3055
+ }
3056
+ msg.locale = targetLocale;
3057
+ msg.key = key;
3058
+ msg.source = format3;
3059
+ return msg;
3060
+ }
3061
+ function evaluateMessage(context, msg, msgCtx) {
3062
+ let start = null;
3063
+ let startTag;
3064
+ let endTag;
3065
+ if (inBrowser) {
3066
+ start = window.performance.now();
3067
+ startTag = "intlify-message-evaluation-start";
3068
+ endTag = "intlify-message-evaluation-end";
3069
+ mark && mark(startTag);
3070
+ }
3071
+ const messaged = msg(msgCtx);
3072
+ if (inBrowser) {
3073
+ const end = window.performance.now();
3074
+ const emitter = context.__v_emitter;
3075
+ if (emitter && start) {
3076
+ emitter.emit("message-evaluation", {
3077
+ type: "message-evaluation",
3078
+ value: messaged,
3079
+ time: end - start,
3080
+ groupId: `${"translate"}:${msg.key}`
3081
+ });
3082
+ }
3083
+ if (startTag && endTag && mark && measure) {
3084
+ mark(endTag);
3085
+ measure("intlify message evaluation", startTag, endTag);
3086
+ }
3087
+ }
3088
+ return messaged;
3089
+ }
3090
+ function parseTranslateArgs(...args) {
3091
+ const [arg1, arg2, arg3] = args;
3092
+ const options = create();
3093
+ if (!isString(arg1) && !isNumber(arg1) && !isMessageFunction(arg1) && !isMessageAST(arg1)) {
3094
+ throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT);
3095
+ }
3096
+ const key = isNumber(arg1) ? String(arg1) : isMessageFunction(arg1) ? arg1 : arg1;
3097
+ if (isNumber(arg2)) {
3098
+ options.plural = arg2;
3099
+ } else if (isString(arg2)) {
3100
+ options.default = arg2;
3101
+ } else if (isPlainObject(arg2) && !isEmptyObject(arg2)) {
3102
+ options.named = arg2;
3103
+ } else if (isArray(arg2)) {
3104
+ options.list = arg2;
3105
+ }
3106
+ if (isNumber(arg3)) {
3107
+ options.plural = arg3;
3108
+ } else if (isString(arg3)) {
3109
+ options.default = arg3;
3110
+ } else if (isPlainObject(arg3)) {
3111
+ assign(options, arg3);
3112
+ }
3113
+ return [key, options];
3114
+ }
3115
+ function getCompileContext(context, locale, key, source, warnHtmlMessage, onError) {
3116
+ return {
3117
+ locale,
3118
+ key,
3119
+ warnHtmlMessage,
3120
+ onError: (err) => {
3121
+ onError && onError(err);
3122
+ if (true) {
3123
+ const _source = getSourceForCodeFrame(source);
3124
+ const message = `Message compilation error: ${err.message}`;
3125
+ const codeFrame = err.location && _source && generateCodeFrame(_source, err.location.start.offset, err.location.end.offset);
3126
+ const emitter = context.__v_emitter;
3127
+ if (emitter && _source) {
3128
+ emitter.emit("compile-error", {
3129
+ message: _source,
3130
+ error: err.message,
3131
+ start: err.location && err.location.start.offset,
3132
+ end: err.location && err.location.end.offset,
3133
+ groupId: `${"translate"}:${key}`
3134
+ });
3135
+ }
3136
+ console.error(codeFrame ? `${message}
3137
+ ${codeFrame}` : message);
3138
+ } else {
3139
+ throw err;
3140
+ }
3141
+ },
3142
+ onCacheKey: (source2) => generateFormatCacheKey(locale, key, source2)
3143
+ };
3144
+ }
3145
+ function getSourceForCodeFrame(source) {
3146
+ if (isString(source)) {
3147
+ return source;
3148
+ } else {
3149
+ if (source.loc && source.loc.source) {
3150
+ return source.loc.source;
3151
+ }
3152
+ }
3153
+ }
3154
+ function getMessageContextOptions(context, locale, message, options) {
3155
+ const { modifiers, pluralRules, messageResolver: resolveValue2, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context;
3156
+ const resolveMessage = (key, useLinked) => {
3157
+ let val = resolveValue2(message, key);
3158
+ if (val == null && (fallbackContext || useLinked)) {
3159
+ const [, , message2] = resolveMessageFormat(
3160
+ fallbackContext || context,
3161
+ // NOTE: if has fallbackContext, fallback to root, else if use linked, fallback to local context
3162
+ key,
3163
+ locale,
3164
+ fallbackLocale,
3165
+ fallbackWarn,
3166
+ missingWarn
3167
+ );
3168
+ val = resolveValue2(message2, key);
3169
+ }
3170
+ if (isString(val) || isMessageAST(val)) {
3171
+ let occurred = false;
3172
+ const onError = () => {
3173
+ occurred = true;
3174
+ };
3175
+ const msg = compileMessageFormat(context, key, locale, val, key, onError);
3176
+ return !occurred ? msg : NOOP_MESSAGE_FUNCTION;
3177
+ } else if (isMessageFunction(val)) {
3178
+ return val;
3179
+ } else {
3180
+ return NOOP_MESSAGE_FUNCTION;
3181
+ }
3182
+ };
3183
+ const ctxOptions = {
3184
+ locale,
3185
+ modifiers,
3186
+ pluralRules,
3187
+ messages: resolveMessage
3188
+ };
3189
+ if (context.processor) {
3190
+ ctxOptions.processor = context.processor;
3191
+ }
3192
+ if (options.list) {
3193
+ ctxOptions.list = options.list;
3194
+ }
3195
+ if (options.named) {
3196
+ ctxOptions.named = options.named;
3197
+ }
3198
+ if (isNumber(options.plural)) {
3199
+ ctxOptions.pluralIndex = options.plural;
3200
+ }
3201
+ return ctxOptions;
3202
+ }
3203
+ {
3204
+ initFeatureFlags();
3205
+ }
3206
+ export {
3207
+ AST_NODE_PROPS_KEYS,
3208
+ CORE_ERROR_CODES_EXTEND_POINT,
3209
+ CORE_WARN_CODES_EXTEND_POINT,
3210
+ CompileErrorCodes,
3211
+ CoreErrorCodes,
3212
+ CoreWarnCodes,
3213
+ DATETIME_FORMAT_OPTIONS_KEYS,
3214
+ DEFAULT_LOCALE,
3215
+ DEFAULT_MESSAGE_DATA_TYPE,
3216
+ MISSING_RESOLVE_VALUE,
3217
+ NOT_REOSLVED,
3218
+ NUMBER_FORMAT_OPTIONS_KEYS,
3219
+ VERSION,
3220
+ clearCompileCache,
3221
+ clearDateTimeFormat,
3222
+ clearNumberFormat,
3223
+ compile,
3224
+ createCompileError,
3225
+ createCoreContext,
3226
+ createCoreError,
3227
+ createMessageContext,
3228
+ datetime,
3229
+ fallbackWithLocaleChain,
3230
+ fallbackWithSimple,
3231
+ getAdditionalMeta,
3232
+ getDevToolsHook,
3233
+ getFallbackContext,
3234
+ getLocale,
3235
+ getWarnMessage,
3236
+ handleMissing,
3237
+ initI18nDevTools,
3238
+ isAlmostSameLocale,
3239
+ isImplicitFallback,
3240
+ isMessageAST,
3241
+ isMessageFunction,
3242
+ isTranslateFallbackWarn,
3243
+ isTranslateMissingWarn,
3244
+ number,
3245
+ parse,
3246
+ parseDateTimeArgs,
3247
+ parseNumberArgs,
3248
+ parseTranslateArgs,
3249
+ registerLocaleFallbacker,
3250
+ registerMessageCompiler,
3251
+ registerMessageResolver,
3252
+ resolveLocale,
3253
+ resolveValue,
3254
+ resolveWithKeyValue,
3255
+ setAdditionalMeta,
3256
+ setDevToolsHook,
3257
+ setFallbackContext,
3258
+ translate,
3259
+ translateDevTools,
3260
+ updateFallbackLocale
3261
+ };
3262
+ /*! Bundled license information:
3263
+
3264
+ @intlify/message-compiler/dist/message-compiler.mjs:
3265
+ (*!
3266
+ * message-compiler v11.1.5
3267
+ * (c) 2025 kazuya kawaguchi
3268
+ * Released under the MIT License.
3269
+ *)
3270
+
3271
+ @intlify/core-base/dist/core-base.mjs:
3272
+ (*!
3273
+ * core-base v10.0.7
3274
+ * (c) 2025 kazuya kawaguchi
3275
+ * Released under the MIT License.
3276
+ *)
3277
+ */
3278
+ //# sourceMappingURL=@intlify_core-base.js.map