@intlify/core 12.0.0-alpha.4 → 12.0.0-alpha.6

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.
@@ -1,30 +1,51 @@
1
1
  /**
2
- * @intlify/core v12.0.0-alpha.4
2
+ * @intlify/core v12.0.0-alpha.6
3
3
  * (c) 2016-present kazuya kawaguchi and contributors
4
4
  * @license MIT
5
- **/ function warn(e, t) {
6
- typeof console < `u` && (console.warn(`[intlify] ` + e), t && console.warn(t.stack));
7
- }
8
- const RE_ARGS = /\{([0-9a-z]+)\}/gi;
9
- function format$1(e, ...n) {
10
- return n.length === 1 && isObject(n[0]) && (n = n[0]), (!n || !n.hasOwnProperty) && (n = {}), e.replace(RE_ARGS, (e, t) => n.hasOwnProperty(t) ? n[t] : ``);
5
+ **/ const e = /\{([0-9a-z]+)\}/gi;
6
+ function t(t, ...n) {
7
+ return n.length === 1 && y(n[0]) && (n = n[0]), (!n || !n.hasOwnProperty) && (n = {}), t.replace(e, (e, t) => n.hasOwnProperty(t) ? n[t] : ``);
11
8
  }
12
- const generateFormatCacheKey = (e, t, n) => friendlyJSONstringify({
9
+ const n = (e, t, n) => r({
13
10
  l: e,
14
11
  k: t,
15
12
  s: n
16
- }), friendlyJSONstringify = (e) => JSON.stringify(e).replace(/\u2028/g, `\\u2028`).replace(/\u2029/g, `\\u2029`).replace(/\u0027/g, `\\u0027`), isNumber = (e) => typeof e == `number` && isFinite(e), isDate = (e) => toTypeString(e) === `[object Date]`, isRegExp = (e) => toTypeString(e) === `[object RegExp]`, isKeylessObject = (e) => Object.keys(e).length === 0, assign = Object.assign, _create = Object.create, create = (e = null) => _create(e);
17
- function escapeHtml(e) {
13
+ }), r = (e) => JSON.stringify(e).replace(/\u2028/g, `\\u2028`).replace(/\u2029/g, `\\u2029`).replace(/\u0027/g, `\\u0027`), i = (e) => typeof e == `number` && isFinite(e), a = (e) => S(e) === `[object Date]`, o = (e) => S(e) === `[object RegExp]`, s = (e) => Object.keys(e).length === 0, c = Object.assign, l = Object.create, u = (e = null) => l(e), d = Object.prototype.hasOwnProperty;
14
+ function f(e, t) {
15
+ return d.call(e, t);
16
+ }
17
+ function p(e, t) {
18
+ let n = e[t];
19
+ return f(e, t) ? n : void 0;
20
+ }
21
+ function m(e) {
22
+ return f(Object.prototype, e);
23
+ }
24
+ const h = Array.isArray, g = (e) => typeof e == `function`, _ = (e) => typeof e == `string`, v = (e) => typeof e == `boolean`, y = (e) => typeof e == `object` && !!e, b = (e) => y(e) && g(e.then) && g(e.catch), x = Object.prototype.toString, S = (e) => x.call(e), C = (e) => S(e) === `[object Object]`, w = (e) => e == null ? `` : h(e) || C(e) && e.toString === x ? JSON.stringify(e, null, 2) : String(e);
25
+ function ee(e, t = ``) {
26
+ return e.reduce((e, n, r) => r === 0 ? e + n : e + t + n, ``);
27
+ }
28
+ function te(e, t) {
29
+ typeof console < `u` && (console.warn(`[intlify] ` + e), t && console.warn(t.stack));
30
+ }
31
+ function T(e) {
18
32
  return e.replace(/&/g, `&amp;`).replace(/</g, `&lt;`).replace(/>/g, `&gt;`).replace(/"/g, `&quot;`).replace(/'/g, `&apos;`).replace(/\//g, `&#x2F;`).replace(/=/g, `&#x3D;`);
19
33
  }
20
- function escapeAttributeValue(e) {
34
+ function ne(e) {
21
35
  return e.replace(/&(?![a-z0-9#]{2,6};)/gi, `&amp;`).replace(/"/g, `&quot;`).replace(/'/g, `&apos;`).replace(/</g, `&lt;`).replace(/>/g, `&gt;`);
22
36
  }
23
- const javascriptSchemePattern = /^\s*javascript\s*(?::|&#0*58;?|&#x0*3a;?|&colon;?)/i, urlAttributePattern = /^(?:href|src|action|formaction)$/i;
24
- function hasJavascriptScheme(e) {
25
- return javascriptSchemePattern.test(e);
37
+ const re = /^javascript:/i, ie = /^(?:href|src|action|formaction)$/i, ae = /&#(?:x([0-9a-f]+)|(\d+));?/gi, E = /&(?:Tab|NewLine);/g, oe = /&colon;?/gi, se = /[\u0000-\u0020\u007f-\u009f]/g, ce = /(?:^|[\s"'<>/])on\w+\s*=\s*["']?[^"'>]+["']?/i, le = /(^|[\s"'<>/])on(\w+\s*=)/gi, ue = /(?:^|[\s"'<>/])srcdoc\s*=/i, de = /(^|[\s"'<>/])s(rcdoc\s*=)/gi, fe = /(^|[\s"'<>/])((?:href|src|action|formaction)\s*=\s*)([^\s"'=<>`]+)/gi;
38
+ function pe(e, t, n) {
39
+ let r = t || n;
40
+ if (!r) return e;
41
+ let i = Number.parseInt(r, t ? 16 : 10);
42
+ return i <= 127 ? String.fromCharCode(i) : e;
43
+ }
44
+ function D(e) {
45
+ let t = e.replace(ae, pe).replace(E, ``).replace(oe, `:`).replace(se, ``);
46
+ return re.test(t);
26
47
  }
27
- function sanitizeStyleValue(e) {
48
+ function me(e) {
28
49
  let t = /url\s*\(/gi, n = ``, r = 0, i;
29
50
  for (; (i = t.exec(e)) !== null;) {
30
51
  let a = i.index, o = t.lastIndex - 1, s = o + 1, c = 1, l = null;
@@ -40,42 +61,41 @@ function sanitizeStyleValue(e) {
40
61
  }
41
62
  if (c !== 0) break;
42
63
  let u = e.slice(o + 1, s).trim(), d = u.startsWith(`"`) && u.endsWith(`"`) || u.startsWith(`'`) && u.endsWith(`'`) ? u.slice(1, -1).trim() : u;
43
- n += e.slice(r, a), n += hasJavascriptScheme(d) ? `url(about:blank)` : e.slice(a, s + 1), r = s + 1;
64
+ n += e.slice(r, a), n += D(d) ? `url(about:blank)` : e.slice(a, s + 1), r = s + 1;
44
65
  }
45
66
  return n + e.slice(r);
46
67
  }
47
- function sanitizeAttributeValue(e, t) {
48
- return urlAttributePattern.test(e) && hasJavascriptScheme(t) ? `about:blank` : escapeAttributeValue(e.toLowerCase() === `style` ? sanitizeStyleValue(t) : t);
68
+ function he(e, t) {
69
+ return ie.test(e) && D(t) ? `about:blank` : ne(e.toLowerCase() === `style` ? me(t) : t);
49
70
  }
50
- function sanitizeTranslatedHtml(e) {
51
- return e = e.replace(/([\w:-]+)\s*=\s*"([^"]*)"/g, (e, t, n) => `${t}="${sanitizeAttributeValue(t, n)}"`), e = e.replace(/([\w:-]+)\s*=\s*'([^']*)'/g, (e, t, n) => `${t}='${sanitizeAttributeValue(t, n)}'`), /\s*on\w+\s*=\s*["']?[^"'>]+["']?/i.test(e) && (e = e.replace(/(\s+)on(\w+\s*=)/gi, `$1&#111;n$2`)), e = e.replace(/(\s+(?:href|src|action|formaction)\s*=\s*)([^\s"'=<>`]+)/gi, (e, t, n) => hasJavascriptScheme(n) ? `${t}about:blank` : e), e;
71
+ function ge(e) {
72
+ return e = e.replace(/([\w:-]+)\s*=\s*"([^"]*)"/g, (e, t, n) => `${t}="${he(t, n)}"`), e = e.replace(/([\w:-]+)\s*=\s*'([^']*)'/g, (e, t, n) => `${t}='${he(t, n)}'`), ce.test(e) && (e = e.replace(le, `$1&#111;n$2`)), ue.test(e) && (e = e.replace(de, `$1&#115;$2`)), e = e.replace(fe, (e, t, n, r) => D(r) ? `${t}${n}about:blank` : e), e;
52
73
  }
53
- const hasOwnProperty = Object.prototype.hasOwnProperty;
54
- function hasOwn(e, t) {
55
- return hasOwnProperty.call(e, t);
56
- }
57
- const isArray = Array.isArray, isFunction = (e) => typeof e == `function`, isString = (e) => typeof e == `string`, isBoolean = (e) => typeof e == `boolean`, isObject = (e) => typeof e == `object` && !!e, isPromise = (e) => isObject(e) && isFunction(e.then) && isFunction(e.catch), objectToString = Object.prototype.toString, toTypeString = (e) => objectToString.call(e), isPlainObject = (e) => toTypeString(e) === `[object Object]`, toDisplayString = (e) => e == null ? `` : isArray(e) || isPlainObject(e) && e.toString === objectToString ? JSON.stringify(e, null, 2) : String(e);
58
- function join(e, t = ``) {
59
- return e.reduce((e, n, r) => r === 0 ? e + n : e + t + n, ``);
60
- }
61
- const isNotObjectOrIsArray = (e) => !isObject(e) || isArray(e);
62
- function deepCopy(e, t) {
63
- if (isNotObjectOrIsArray(e) || isNotObjectOrIsArray(t)) throw Error(`Invalid value`);
64
- let n = [{
65
- src: e,
66
- des: t
67
- }];
74
+ const _e = (e) => !y(e) || h(e);
75
+ function ve(e, t) {
76
+ if (_e(e) || _e(t) || t === Object.prototype) throw Error(`Invalid value`);
77
+ let n = [e, t];
68
78
  for (; n.length;) {
69
- let { src: e, des: t } = n.pop();
70
- Object.keys(e).forEach((r) => {
71
- r !== `__proto__` && (isObject(e[r]) && !isObject(t[r]) && (t[r] = Array.isArray(e[r]) ? [] : create()), isNotObjectOrIsArray(t[r]) || isNotObjectOrIsArray(e[r]) ? t[r] = e[r] : n.push({
72
- src: e[r],
73
- des: t[r]
74
- }));
75
- });
79
+ let e = n.pop(), t = n.pop(), r = Object.keys(t);
80
+ for (let i = 0; i < r.length; i++) {
81
+ let a = r[i];
82
+ if (a === `__proto__`) continue;
83
+ let o = t[a];
84
+ if (!y(o)) {
85
+ e[a] = o;
86
+ continue;
87
+ }
88
+ if (h(o)) {
89
+ let t = [];
90
+ t.length = o.length, e[a] = t, n.push(o, t);
91
+ continue;
92
+ }
93
+ let s = e[a];
94
+ (!y(s) || h(s)) && (s = e[a] = u()), n.push(o, s);
95
+ }
76
96
  }
77
97
  }
78
- const CompileErrorCodes = {
98
+ const O = {
79
99
  EXPECTED_TOKEN: 1,
80
100
  INVALID_TOKEN_IN_PLACEHOLDER: 2,
81
101
  UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3,
@@ -93,240 +113,240 @@ const CompileErrorCodes = {
93
113
  UNHANDLED_CODEGEN_NODE_TYPE: 15,
94
114
  UNHANDLED_MINIFIER_NODE_TYPE: 16
95
115
  };
96
- CompileErrorCodes.EXPECTED_TOKEN, CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER, CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER, CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE, CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE, CompileErrorCodes.UNBALANCED_CLOSING_BRACE, CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, CompileErrorCodes.EMPTY_PLACEHOLDER, CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER, CompileErrorCodes.INVALID_LINKED_FORMAT, CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE, CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE;
97
- function createCompileError(e, t, n = {}) {
116
+ O.EXPECTED_TOKEN, O.INVALID_TOKEN_IN_PLACEHOLDER, O.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER, O.UNKNOWN_ESCAPE_SEQUENCE, O.INVALID_UNICODE_ESCAPE_SEQUENCE, O.UNBALANCED_CLOSING_BRACE, O.UNTERMINATED_CLOSING_BRACE, O.EMPTY_PLACEHOLDER, O.NOT_ALLOW_NEST_PLACEHOLDER, O.INVALID_LINKED_FORMAT, O.MUST_HAVE_MESSAGES_IN_PLURAL, O.UNEXPECTED_EMPTY_LINKED_MODIFIER, O.UNEXPECTED_EMPTY_LINKED_KEY, O.UNEXPECTED_LEXICAL_ANALYSIS, O.UNHANDLED_CODEGEN_NODE_TYPE, O.UNHANDLED_MINIFIER_NODE_TYPE;
117
+ function ye(e, t, n = {}) {
98
118
  let { domain: r, messages: i, args: a } = n, o = SyntaxError(String(e));
99
119
  return o.code = e, t && (o.location = t), o.domain = r, o;
100
120
  }
101
- function isMessageAST(e) {
102
- return isObject(e) && resolveType(e) === 0 && (hasOwn(e, `b`) || hasOwn(e, `body`));
121
+ function k(e) {
122
+ return y(e) && N(e) === 0 && (f(e, `b`) || f(e, `body`));
103
123
  }
104
- const PROPS_BODY = [`b`, `body`];
105
- function resolveBody(e) {
106
- return resolveProps(e, PROPS_BODY);
124
+ const be = [`b`, `body`];
125
+ function xe(e) {
126
+ return F(e, be);
107
127
  }
108
- const PROPS_CASES = [`c`, `cases`];
109
- function resolveCases(e) {
110
- return resolveProps(e, PROPS_CASES, []);
128
+ const A = [`c`, `cases`];
129
+ function Se(e) {
130
+ return F(e, A, []);
111
131
  }
112
- const PROPS_STATIC = [`s`, `static`];
113
- function resolveStatic(e) {
114
- return resolveProps(e, PROPS_STATIC);
132
+ const j = [`s`, `static`];
133
+ function Ce(e) {
134
+ return F(e, j);
115
135
  }
116
- const PROPS_ITEMS = [`i`, `items`];
117
- function resolveItems(e) {
118
- return resolveProps(e, PROPS_ITEMS, []);
136
+ const M = [`i`, `items`];
137
+ function we(e) {
138
+ return F(e, M, []);
119
139
  }
120
- const PROPS_TYPE = [`t`, `type`];
121
- function resolveType(e) {
122
- return resolveProps(e, PROPS_TYPE);
140
+ const Te = [`t`, `type`];
141
+ function N(e) {
142
+ return F(e, Te);
123
143
  }
124
- const PROPS_VALUE = [`v`, `value`];
125
- function resolveValue$1(e, t) {
126
- let n = resolveProps(e, PROPS_VALUE);
144
+ const Ee = [`v`, `value`];
145
+ function P(e, t) {
146
+ let n = F(e, Ee);
127
147
  if (n != null) return n;
128
- throw createUnhandleNodeError(t);
148
+ throw I(t);
129
149
  }
130
- const PROPS_MODIFIER = [`m`, `modifier`];
131
- function resolveLinkedModifier(e) {
132
- return resolveProps(e, PROPS_MODIFIER);
150
+ const De = [`m`, `modifier`];
151
+ function Oe(e) {
152
+ return F(e, De);
133
153
  }
134
- const PROPS_KEY = [`k`, `key`];
135
- function resolveLinkedKey(e) {
136
- let t = resolveProps(e, PROPS_KEY);
154
+ const ke = [`k`, `key`];
155
+ function Ae(e) {
156
+ let t = F(e, ke);
137
157
  if (t) return t;
138
- throw createUnhandleNodeError(6);
158
+ throw I(6);
139
159
  }
140
- function resolveProps(e, t, n) {
160
+ function F(e, t, n) {
141
161
  for (let n = 0; n < t.length; n++) {
142
162
  let r = t[n];
143
- if (hasOwn(e, r) && e[r] != null) return e[r];
163
+ if (f(e, r) && e[r] != null) return e[r];
144
164
  }
145
165
  return n;
146
166
  }
147
- const AST_NODE_PROPS_KEYS = [
148
- ...PROPS_BODY,
149
- ...PROPS_CASES,
150
- ...PROPS_STATIC,
151
- ...PROPS_ITEMS,
152
- ...PROPS_KEY,
153
- ...PROPS_MODIFIER,
154
- ...PROPS_VALUE,
155
- ...PROPS_TYPE
167
+ const je = [
168
+ ...be,
169
+ ...A,
170
+ ...j,
171
+ ...M,
172
+ ...ke,
173
+ ...De,
174
+ ...Ee,
175
+ ...Te
156
176
  ];
157
- function createUnhandleNodeError(e) {
177
+ function I(e) {
158
178
  return Error(`unhandled node type: ${e}`);
159
179
  }
160
- function format(e) {
161
- return (t) => formatParts(t, e);
180
+ function Me(e) {
181
+ return (t) => Ne(t, e);
162
182
  }
163
- function formatParts(e, t) {
164
- let n = resolveBody(t);
165
- if (n == null) throw createUnhandleNodeError(0);
166
- if (resolveType(n) === 1) {
167
- let t = resolveCases(n);
168
- return e.plural(t.reduce((t, n) => [...isArray(t) ? t : [t], formatMessageParts(e, n)], []));
169
- } else return formatMessageParts(e, n);
183
+ function Ne(e, t) {
184
+ let n = xe(t);
185
+ if (n == null) throw I(0);
186
+ if (N(n) === 1) {
187
+ let t = Se(n);
188
+ return e.plural(t.reduce((t, n) => [...h(t) ? t : [t], Pe(e, n)], []));
189
+ }
190
+ return Pe(e, n);
170
191
  }
171
- function formatMessageParts(e, t) {
172
- let n = resolveStatic(t);
192
+ function Pe(e, t) {
193
+ let n = Ce(t);
173
194
  if (n != null) return e.type === `text` ? n : e.normalize([n]);
174
195
  {
175
- let n = resolveItems(t).reduce((t, n) => [...t, formatMessagePart(e, n)], []);
196
+ let n = we(t).reduce((t, n) => [...t, L(e, n)], []);
176
197
  return e.normalize(n);
177
198
  }
178
199
  }
179
- function formatMessagePart(e, t) {
180
- let n = resolveType(t);
200
+ function L(e, t) {
201
+ let n = N(t);
181
202
  switch (n) {
182
- case 3: return resolveValue$1(t, n);
183
- case 9: return resolveValue$1(t, n);
203
+ case 3: return P(t, n);
204
+ case 9: return P(t, n);
184
205
  case 4: {
185
206
  let r = t;
186
- if (hasOwn(r, `k`) && r.k) return e.interpolate(e.named(r.k));
187
- if (hasOwn(r, `key`) && r.key) return e.interpolate(e.named(r.key));
188
- throw createUnhandleNodeError(n);
207
+ if (f(r, `k`) && r.k) return e.interpolate(e.named(r.k));
208
+ if (f(r, `key`) && r.key) return e.interpolate(e.named(r.key));
209
+ throw I(n);
189
210
  }
190
211
  case 5: {
191
212
  let r = t;
192
- if (hasOwn(r, `i`) && isNumber(r.i)) return e.interpolate(e.list(r.i));
193
- if (hasOwn(r, `index`) && isNumber(r.index)) return e.interpolate(e.list(r.index));
194
- throw createUnhandleNodeError(n);
213
+ if (f(r, `i`) && i(r.i)) return e.interpolate(e.list(r.i));
214
+ if (f(r, `index`) && i(r.index)) return e.interpolate(e.list(r.index));
215
+ throw I(n);
195
216
  }
196
217
  case 6: {
197
- let n = t, r = resolveLinkedModifier(n), i = resolveLinkedKey(n);
198
- return e.linked(formatMessagePart(e, i), r ? formatMessagePart(e, r) : void 0, e.type);
218
+ let n = t, r = Oe(n), i = Ae(n);
219
+ return e.linked(L(e, i), r ? L(e, r) : void 0, e.type);
199
220
  }
200
- case 7: return resolveValue$1(t, n);
201
- case 8: return resolveValue$1(t, n);
221
+ case 7: return P(t, n);
222
+ case 8: return P(t, n);
202
223
  default: throw Error(`unhandled node on format message part: ${n}`);
203
224
  }
204
225
  }
205
- let compileCache = create();
206
- function clearCompileCache() {
207
- compileCache = create();
226
+ let R = u();
227
+ function Fe() {
228
+ R = u();
208
229
  }
209
- function compile(e, t) {
230
+ function Ie(e, t) {
210
231
  {
232
+ if (!k(e)) return (() => e);
211
233
  let t = e.cacheKey;
212
- return t ? compileCache[t] || (compileCache[t] = format(e)) : format(e);
234
+ return t ? R[t] || (R[t] = Me(e)) : Me(e);
213
235
  }
214
236
  }
215
- const CoreErrorCodes = {
237
+ const z = {
216
238
  INVALID_ARGUMENT: 17,
217
239
  INVALID_DATE_ARGUMENT: 18,
218
240
  INVALID_ISO_DATE_ARGUMENT: 19,
219
- NOT_SUPPORT_NON_STRING_MESSAGE: 20,
220
- NOT_SUPPORT_LOCALE_PROMISE_VALUE: 21,
221
- NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: 22,
222
- NOT_SUPPORT_LOCALE_TYPE: 23
223
- }, CORE_ERROR_CODES_EXTEND_POINT = 24;
224
- function createCoreError(e) {
225
- return createCompileError(e, null, void 0);
226
- }
227
- CoreErrorCodes.INVALID_ARGUMENT, CoreErrorCodes.INVALID_DATE_ARGUMENT, CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT, CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE, CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE, CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION, CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE;
228
- function getLocale(e, t) {
229
- return t.locale == null ? resolveLocale(e.locale) : resolveLocale(t.locale);
230
- }
231
- let _resolveLocale;
232
- function resolveLocale(e) {
233
- if (isString(e)) return e;
234
- if (isFunction(e)) {
235
- if (e.resolvedOnce && _resolveLocale != null) return _resolveLocale;
241
+ NOT_SUPPORT_LOCALE_PROMISE_VALUE: 20,
242
+ NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: 21,
243
+ NOT_SUPPORT_LOCALE_TYPE: 22
244
+ }, Le = 23;
245
+ function Re(e) {
246
+ return ye(e, null, void 0);
247
+ }
248
+ z.INVALID_ARGUMENT, z.INVALID_DATE_ARGUMENT, z.INVALID_ISO_DATE_ARGUMENT, z.NOT_SUPPORT_LOCALE_PROMISE_VALUE, z.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION, z.NOT_SUPPORT_LOCALE_TYPE;
249
+ function B(e, t) {
250
+ return t.locale == null ? H(e.locale) : H(t.locale);
251
+ }
252
+ let V;
253
+ function H(e) {
254
+ if (_(e)) return e;
255
+ if (g(e)) {
256
+ if (e.resolvedOnce && V != null) return V;
236
257
  if (e.constructor.name === `Function`) {
237
258
  let t = e();
238
- if (isPromise(t)) throw Error(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE);
239
- return _resolveLocale = t;
240
- } else throw Error(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION);
241
- } else throw Error(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE);
242
- }
243
- function fallbackWithSimple(e, t, n) {
244
- return [...new Set([n, ...isArray(t) ? t : isObject(t) ? Object.keys(t) : isString(t) ? [t] : [n]])];
245
- }
246
- function fallbackWithLocaleChain(e, t, n) {
247
- let r = isString(n) ? n : DEFAULT_LOCALE, i = e;
248
- i.__localeChainCache || (i.__localeChainCache = /* @__PURE__ */ new Map());
249
- let a = i.__localeChainCache.get(r);
250
- if (!a) {
251
- a = [];
252
- let e = [n];
253
- for (; isArray(e);) e = appendBlockToChain(a, e, t);
254
- let o = isArray(t) || !isPlainObject(t) ? t : t.default ? t.default : null;
255
- e = isString(o) ? [o] : o, isArray(e) && appendBlockToChain(a, e, !1), i.__localeChainCache.set(r, a);
259
+ if (b(t)) throw Error(z.NOT_SUPPORT_LOCALE_PROMISE_VALUE);
260
+ return V = t;
261
+ }
262
+ throw Error(z.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION);
256
263
  }
257
- return a;
258
- }
259
- function appendBlockToChain(e, t, n) {
264
+ throw Error(z.NOT_SUPPORT_LOCALE_TYPE);
265
+ }
266
+ function ze(e, t, n) {
267
+ return [.../* @__PURE__ */ new Set([n, ...h(t) ? t : y(t) ? Object.keys(t).filter((e) => e !== "default") : _(t) ? [t] : [n]])];
268
+ }
269
+ function Be(e, t, n) {
270
+ let r = _(n) ? n : G, i = e, a;
271
+ y(t) ? (i.__localeChainObjectCache || (i.__localeChainObjectCache = /* @__PURE__ */ new WeakMap()), a = i.__localeChainObjectCache.get(t), a || (a = /* @__PURE__ */ new Map(), i.__localeChainObjectCache.set(t, a))) : (i.__localeChainCache || (i.__localeChainCache = /* @__PURE__ */ new Map()), a = i.__localeChainCache.get(t), a || (a = /* @__PURE__ */ new Map(), i.__localeChainCache.set(t, a)));
272
+ let o = a.get(r);
273
+ if (o) return o;
274
+ let s = [], c = [n];
275
+ for (; h(c);) c = Ve(s, c, t);
276
+ let l = h(t) || !C(t) ? t : t.default ? t.default : null;
277
+ return c = _(l) ? [l] : l, h(c) && Ve(s, c, !1), a.set(r, s), s;
278
+ }
279
+ function Ve(e, t, n) {
260
280
  let r = !0;
261
- for (let i = 0; i < t.length && isBoolean(r); i++) {
281
+ for (let i = 0; i < t.length && v(r); i++) {
262
282
  let a = t[i];
263
- isString(a) && (r = appendLocaleToChain(e, t[i], n));
283
+ _(a) && (r = He(e, t[i], n));
264
284
  }
265
285
  return r;
266
286
  }
267
- function appendLocaleToChain(e, t, n) {
287
+ function He(e, t, n) {
268
288
  let r, i = t.split(`-`);
269
289
  do
270
- r = appendItemToChain(e, i.join(`-`), n), i.splice(-1, 1);
290
+ r = Ue(e, i.join(`-`), n), i.splice(-1, 1);
271
291
  while (i.length && r === !0);
272
292
  return r;
273
293
  }
274
- function appendItemToChain(e, t, n) {
294
+ function Ue(e, t, n) {
275
295
  let r = !1;
276
296
  if (!e.includes(t) && (r = !0, t)) {
277
297
  r = t[t.length - 1] !== `!`;
278
298
  let i = t.replace(/!/g, ``);
279
- e.push(i), (isArray(n) || isPlainObject(n)) && n[i] && (r = n[i]);
299
+ e.push(i), (h(n) || C(n)) && n[i] && (r = n[i]);
280
300
  }
281
301
  return r;
282
302
  }
283
- const pathStateMachine = [];
284
- pathStateMachine[0] = {
303
+ const U = [];
304
+ U[0] = {
285
305
  w: [0],
286
306
  i: [3, 0],
287
307
  "[": [4],
288
308
  o: [7]
289
- }, pathStateMachine[1] = {
309
+ }, U[1] = {
290
310
  w: [1],
291
311
  ".": [2],
292
312
  "[": [4],
293
313
  o: [7]
294
- }, pathStateMachine[2] = {
314
+ }, U[2] = {
295
315
  w: [2],
296
316
  i: [3, 0],
297
317
  0: [3, 0]
298
- }, pathStateMachine[3] = {
318
+ }, U[3] = {
299
319
  i: [3, 0],
300
320
  0: [3, 0],
301
321
  w: [1, 1],
302
322
  ".": [2, 1],
303
323
  "[": [4, 1],
304
324
  o: [7, 1]
305
- }, pathStateMachine[4] = {
325
+ }, U[4] = {
306
326
  "'": [5, 0],
307
327
  "\"": [6, 0],
308
328
  "[": [4, 2],
309
329
  "]": [1, 3],
310
330
  o: 8,
311
331
  l: [4, 0]
312
- }, pathStateMachine[5] = {
332
+ }, U[5] = {
313
333
  "'": [4, 0],
314
334
  o: 8,
315
335
  l: [5, 0]
316
- }, pathStateMachine[6] = {
336
+ }, U[6] = {
317
337
  "\"": [4, 0],
318
338
  o: 8,
319
339
  l: [6, 0]
320
340
  };
321
- const literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;
322
- function isLiteral(e) {
323
- return literalValueRE.test(e);
341
+ const We = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;
342
+ function Ge(e) {
343
+ return We.test(e);
324
344
  }
325
- function stripQuotes(e) {
345
+ function Ke(e) {
326
346
  let t = e.charCodeAt(0);
327
347
  return t === e.charCodeAt(e.length - 1) && (t === 34 || t === 39) ? e.slice(1, -1) : e;
328
348
  }
329
- function getPathCharType(e) {
349
+ function qe(e) {
330
350
  if (e == null) return `o`;
331
351
  switch (e.charCodeAt(0)) {
332
352
  case 91:
@@ -347,11 +367,11 @@ function getPathCharType(e) {
347
367
  }
348
368
  return `i`;
349
369
  }
350
- function formatSubPath(e) {
370
+ function Je(e) {
351
371
  let t = e.trim();
352
- return e.charAt(0) === `0` && isNaN(parseInt(e)) ? !1 : isLiteral(t) ? stripQuotes(t) : `*` + t;
372
+ return e.charAt(0) === `0` && isNaN(parseInt(e)) ? !1 : Ge(t) ? Ke(t) : `*` + t;
353
373
  }
354
- function parse(e) {
374
+ function Ye(e) {
355
375
  let t = [], n = -1, r = 0, i = 0, a, o, s, c, l, u, d, f = [];
356
376
  f[0] = () => {
357
377
  o === void 0 ? o = s : o += s;
@@ -362,7 +382,7 @@ function parse(e) {
362
382
  }, f[3] = () => {
363
383
  if (i > 0) i--, r = 4, f[0]();
364
384
  else {
365
- if (i = 0, o === void 0 || (o = formatSubPath(o), o === !1)) return !1;
385
+ if (i = 0, o === void 0 || (o = Je(o), o === !1)) return !1;
366
386
  f[1]();
367
387
  }
368
388
  };
@@ -371,29 +391,29 @@ function parse(e) {
371
391
  if (r === 5 && t === `'` || r === 6 && t === `"`) return n++, s = `\\` + t, f[0](), !0;
372
392
  }
373
393
  for (; r !== null;) if (n++, a = e[n], !(a === `\\` && p())) {
374
- if (c = getPathCharType(a), d = pathStateMachine[r], l = d[c] || d.l || 8, l === 8 || (r = l[0], l[1] !== void 0 && (u = f[l[1]], u && (s = a, u() === !1)))) return;
394
+ if (c = qe(a), d = U[r], l = d[c] || d.l || 8, l === 8 || (r = l[0], l[1] !== void 0 && (u = f[l[1]], u && (s = a, u() === !1)))) return;
375
395
  if (r === 7) return t;
376
396
  }
377
397
  }
378
- const cache = /* @__PURE__ */ new Map();
379
- function resolveWithKeyValue(e, t) {
380
- return isObject(e) ? e[t] : null;
398
+ const Xe = /* @__PURE__ */ new Map();
399
+ function Ze(e, t) {
400
+ return y(e) ? p(e, t) : null;
381
401
  }
382
- function resolveValue(e, t) {
383
- if (!isObject(e)) return null;
384
- let n = cache.get(t);
385
- if (n || (n = parse(t), n && cache.set(t, n)), !n) return null;
402
+ function Qe(e, t) {
403
+ if (!y(e)) return null;
404
+ let n = Xe.get(t);
405
+ if (n || (n = Ye(t), n && Xe.set(t, n)), !n) return null;
386
406
  let r = n.length, i = e, a = 0;
387
407
  for (; a < r;) {
388
408
  let e = n[a];
389
- if (AST_NODE_PROPS_KEYS.includes(e) && isMessageAST(i) || !isObject(i) || !hasOwn(i, e)) return null;
409
+ if (je.includes(e) && k(i) || !y(i) || !f(i, e)) return null;
390
410
  let t = i[e];
391
- if (t === void 0 || isFunction(i)) return null;
411
+ if (t === void 0 || g(i)) return null;
392
412
  i = t, a++;
393
413
  }
394
414
  return i;
395
415
  }
396
- const CoreWarnCodes = {
416
+ const W = {
397
417
  NOT_FOUND_KEY: 1,
398
418
  FALLBACK_TO_TRANSLATE: 2,
399
419
  CANNOT_FORMAT_NUMBER: 3,
@@ -402,126 +422,184 @@ const CoreWarnCodes = {
402
422
  FALLBACK_TO_DATE_FORMAT: 6,
403
423
  EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: 7,
404
424
  INVALID_NUMBER_ARGUMENT: 8,
405
- INVALID_DATE_ARGUMENT: 9
406
- }, CORE_WARN_CODES_EXTEND_POINT = 10, warnMessages = {
407
- [CoreWarnCodes.NOT_FOUND_KEY]: `Not found '{key}' key in '{locale}' locale messages.`,
408
- [CoreWarnCodes.FALLBACK_TO_TRANSLATE]: `Fall back to translate '{key}' key with '{target}' locale.`,
409
- [CoreWarnCodes.CANNOT_FORMAT_NUMBER]: `Cannot format a number value due to not supported Intl.NumberFormat.`,
410
- [CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT]: `Fall back to number format '{key}' key with '{target}' locale.`,
411
- [CoreWarnCodes.CANNOT_FORMAT_DATE]: `Cannot format a date value due to not supported Intl.DateTimeFormat.`,
412
- [CoreWarnCodes.FALLBACK_TO_DATE_FORMAT]: `Fall back to datetime format '{key}' key with '{target}' locale.`,
413
- [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.`,
414
- [CoreWarnCodes.INVALID_NUMBER_ARGUMENT]: `Invalid argument for number formatting: expected a number but received '{value}'.`,
415
- [CoreWarnCodes.INVALID_DATE_ARGUMENT]: `Invalid argument for datetime formatting: expected a Date, number, or ISO string but received '{value}'.`
425
+ INVALID_DATE_ARGUMENT: 9,
426
+ IGNORE_UNSAFE_LOCALE: 10,
427
+ FALLBACK_TO_DEFAULT_PLURAL_RULE: 11,
428
+ FALLBACK_FROM_INVALID_LOCALE: 12
429
+ }, $e = 13, et = {
430
+ [W.NOT_FOUND_KEY]: `Not found '{key}' key in '{locale}' locale {resource}.`,
431
+ [W.FALLBACK_TO_TRANSLATE]: `Fall back to translate '{key}' key with '{target}' locale.`,
432
+ [W.CANNOT_FORMAT_NUMBER]: `Cannot format a number value due to not supported Intl.NumberFormat.`,
433
+ [W.FALLBACK_TO_NUMBER_FORMAT]: `Fall back to number format '{key}' key with '{target}' locale.`,
434
+ [W.CANNOT_FORMAT_DATE]: `Cannot format a date value due to not supported Intl.DateTimeFormat.`,
435
+ [W.FALLBACK_TO_DATE_FORMAT]: `Fall back to datetime format '{key}' key with '{target}' locale.`,
436
+ [W.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.`,
437
+ [W.INVALID_NUMBER_ARGUMENT]: `Invalid argument for number formatting: expected a number but received '{value}'.`,
438
+ [W.INVALID_DATE_ARGUMENT]: `Invalid argument for datetime formatting: expected a Date, number, or ISO string but received '{value}'.`,
439
+ [W.IGNORE_UNSAFE_LOCALE]: `Ignore '{locale}' locale: it is a property name of Object.prototype`,
440
+ [W.FALLBACK_TO_DEFAULT_PLURAL_RULE]: `Fall back to the default plural rule for '{locale}' locale: Intl.PluralRules does not support it`,
441
+ [W.FALLBACK_FROM_INVALID_LOCALE]: `Fall back to '{target}' locale for {type} formatting with '{locale}' locale: it is not a BCP 47 language tag`
416
442
  };
417
- function getWarnMessage(e, ...t) {
418
- return format$1(warnMessages[e], ...t);
443
+ function tt(e, ...n) {
444
+ return t(et[e], ...n);
419
445
  }
420
- const VERSION = `12.0.0-alpha.4`, NOT_RESOLVED = -1, DEFAULT_LOCALE = `en-US`, MISSING_RESOLVE_VALUE = ``, capitalize = (e) => `${e.charAt(0).toLocaleUpperCase()}${e.substr(1)}`;
421
- function getDefaultLinkedModifiers() {
446
+ const nt = `12.0.0-alpha.6`, rt = -1, G = `en-US`, it = ``, at = (e) => `${e.charAt(0).toLocaleUpperCase()}${e.substr(1)}`;
447
+ function ot() {
422
448
  return {
423
- upper: (e, t) => t === `text` && isString(e) ? e.toUpperCase() : t === `vnode` && isObject(e) && `__v_isVNode` in e ? e.children.toUpperCase() : e,
424
- lower: (e, t) => t === `text` && isString(e) ? e.toLowerCase() : t === `vnode` && isObject(e) && `__v_isVNode` in e ? e.children.toLowerCase() : e,
425
- capitalize: (e, t) => t === `text` && isString(e) ? capitalize(e) : t === `vnode` && isObject(e) && `__v_isVNode` in e ? capitalize(e.children) : e
449
+ upper: (e, t) => t === `text` && _(e) ? e.toUpperCase() : t === `vnode` && y(e) && `__v_isVNode` in e ? e.children.toUpperCase() : e,
450
+ lower: (e, t) => t === `text` && _(e) ? e.toLowerCase() : t === `vnode` && y(e) && `__v_isVNode` in e ? e.children.toLowerCase() : e,
451
+ capitalize: (e, t) => t === `text` && _(e) ? at(e) : t === `vnode` && y(e) && `__v_isVNode` in e ? at(e.children) : e
426
452
  };
427
453
  }
428
- let _compiler;
429
- function registerMessageCompiler(e) {
430
- _compiler = e;
431
- }
432
- let _resolver;
433
- function registerMessageResolver(e) {
434
- _resolver = e;
435
- }
436
- let _fallbacker;
437
- function registerLocaleFallbacker(e) {
438
- _fallbacker = e;
439
- }
440
- let _fallbackContext = null;
441
- const setFallbackContext = (e) => {
442
- _fallbackContext = e;
443
- }, getFallbackContext = () => _fallbackContext;
444
- let _cid = 0;
445
- function createCoreContext(t = {}) {
446
- let n = isFunction(t.onWarn) ? t.onWarn : warn, r = isString(t.version) ? t.version : VERSION, i = isString(t.locale) || isFunction(t.locale) ? t.locale : DEFAULT_LOCALE, a = isFunction(i) ? DEFAULT_LOCALE : i, o = isArray(t.fallbackLocale) || isPlainObject(t.fallbackLocale) || isString(t.fallbackLocale) || t.fallbackLocale === !1 ? t.fallbackLocale : a, c = isPlainObject(t.messages) ? t.messages : createResources(a), u = isPlainObject(t.datetimeFormats) ? t.datetimeFormats : createResources(a), f = isPlainObject(t.numberFormats) ? t.numberFormats : createResources(a), p = assign(create(), t.modifiers, getDefaultLinkedModifiers()), m = t.pluralRules || create(), h = isFunction(t.missing) ? t.missing : null, g = isBoolean(t.missingWarn) || isRegExp(t.missingWarn) ? t.missingWarn : !0, _ = isBoolean(t.fallbackWarn) || isRegExp(t.fallbackWarn) ? t.fallbackWarn : !0, v = !!t.fallbackFormat, y = !!t.unresolving, b = isFunction(t.postTranslation) ? t.postTranslation : null, x = isPlainObject(t.processor) ? t.processor : null, T = isBoolean(t.warnHtmlMessage) ? t.warnHtmlMessage : !0, E = !!t.escapeParameter, D = isFunction(t.messageCompiler) ? t.messageCompiler : _compiler || null, O = isFunction(t.messageResolver) ? t.messageResolver : _resolver || resolveWithKeyValue, k = isFunction(t.localeFallbacker) ? t.localeFallbacker : _fallbacker || fallbackWithSimple, A = isObject(t.fallbackContext) ? t.fallbackContext : void 0, j = t, M = isObject(j.__datetimeFormatters) ? j.__datetimeFormatters : /* @__PURE__ */ new Map(), N = isObject(j.__numberFormatters) ? j.__numberFormatters : /* @__PURE__ */ new Map();
447
- _cid++;
448
- let P = {
449
- version: r,
450
- cid: _cid,
451
- locale: i,
452
- fallbackLocale: o,
453
- messages: c,
454
- modifiers: p,
455
- pluralRules: m,
456
- missing: h,
457
- missingWarn: g,
458
- fallbackWarn: _,
459
- fallbackFormat: v,
460
- unresolving: y,
461
- postTranslation: b,
462
- processor: x,
463
- warnHtmlMessage: T,
464
- escapeParameter: E,
465
- messageCompiler: D,
466
- messageResolver: O,
467
- localeFallbacker: k,
468
- fallbackContext: A,
469
- onWarn: n
454
+ let st;
455
+ function ct(e) {
456
+ st = e;
457
+ }
458
+ let lt;
459
+ function ut(e) {
460
+ lt = e;
461
+ }
462
+ let dt;
463
+ function ft(e) {
464
+ dt = e;
465
+ }
466
+ let pt = 0;
467
+ function mt(e = {}) {
468
+ let t = g(e.onWarn) ? e.onWarn : te, n = _(e.version) ? e.version : nt, r = _(e.locale) || g(e.locale) ? e.locale : G, i = g(r) ? G : r, a = _t(e.fallbackLocale) ? e.fallbackLocale : i, o = C(e.messages) ? e.messages : K(i), s = C(e.datetimeFormats) ? e.datetimeFormats : K(i), l = C(e.numberFormats) ? e.numberFormats : K(i), d = c(u(), e.modifiers, ot()), f = e.pluralRules || u(), p = g(e.missing) ? e.missing : null, m = !q(e.missingWarn) || e.missingWarn, h = !q(e.fallbackWarn) || e.fallbackWarn, b = !!e.fallbackFormat, x = !!e.unresolving, S = g(e.postTranslation) ? e.postTranslation : null, w = C(e.processor) ? e.processor : null, ee = !v(e.warnHtmlMessage) || e.warnHtmlMessage, T = !!e.escapeParameter, ne = g(e.messageCompiler) ? e.messageCompiler : st || null, re = g(e.messageResolver) ? e.messageResolver : lt || Ze, ie = g(e.localeFallbacker) ? e.localeFallbacker : dt || ze, ae = y(e.fallbackContext) ? e.fallbackContext : void 0;
469
+ pt++;
470
+ let E = {
471
+ version: n,
472
+ cid: pt,
473
+ locale: r,
474
+ fallbackLocale: a,
475
+ messages: o,
476
+ modifiers: d,
477
+ pluralRules: f,
478
+ missing: p,
479
+ missingWarn: m,
480
+ fallbackWarn: h,
481
+ fallbackFormat: b,
482
+ unresolving: x,
483
+ postTranslation: S,
484
+ processor: w,
485
+ warnHtmlMessage: ee,
486
+ escapeParameter: T,
487
+ messageCompiler: ne,
488
+ messageResolver: re,
489
+ localeFallbacker: ie,
490
+ fallbackContext: ae,
491
+ onWarn: t
470
492
  };
471
- return P.datetimeFormats = u, P.numberFormats = f, P.__datetimeFormatters = M, P.__numberFormatters = N, P;
493
+ return E.datetimeFormats = s, E.numberFormats = l, E.__datetimeFormatters = /* @__PURE__ */ new Map(), E.__numberFormatters = /* @__PURE__ */ new Map(), E;
472
494
  }
473
- const createResources = (e) => ({ [e]: create() });
474
- function getLocaleMessage(e, t) {
475
- let n = e.messages[t];
495
+ const K = (e) => ({ [e]: u() });
496
+ function ht(e, t) {
497
+ let n = p(e.messages, t);
476
498
  if (n == null) return;
477
- let r = create();
478
- return deepCopy(n, r), r;
499
+ let r = u();
500
+ return ve(n, r), r;
501
+ }
502
+ function gt(e, t, n) {
503
+ m(t) || (e.messages[t] = n);
479
504
  }
480
- function setLocaleMessage(e, t, n) {
481
- e.messages[t] = n;
505
+ function _t(e) {
506
+ return _(e) || h(e) || C(e) || e === !1;
482
507
  }
483
- function isTranslateFallbackWarn(e, t) {
484
- return isRegExp(e) ? e.test(t) : e;
508
+ function q(e) {
509
+ return v(e) || o(e);
485
510
  }
486
- function isTranslateMissingWarn(e, t) {
487
- return isRegExp(e) ? e.test(t) : e;
511
+ function vt(e, t) {
512
+ return o(e) ? e.test(t) : e;
488
513
  }
489
- function handleMissing(e, t, n, r, i) {
514
+ function yt(e, t) {
515
+ return o(e) ? e.test(t) : e;
516
+ }
517
+ function J(e, t, n, r, i) {
490
518
  let { missing: a, onWarn: o } = e;
491
519
  if (a !== null) {
492
520
  let r = a(e, n, t, i);
493
- return isString(r) ? r : t;
494
- } else return t;
521
+ return _(r) ? r : t;
522
+ }
523
+ return t;
495
524
  }
496
- function updateFallbackLocale(e, t, n) {
497
- let r = e;
498
- r.__localeChainCache = /* @__PURE__ */ new Map(), e.localeFallbacker(e, n, t);
525
+ function bt(e, t) {
526
+ let n = e;
527
+ y(t) ? n.__localeChainObjectCache?.delete(t) : n.__localeChainCache?.delete(t);
499
528
  }
500
- function isAlmostSameLocale(e, t) {
501
- return e === t ? !1 : e.split(`-`)[0] === t.split(`-`)[0];
529
+ function xt(e, t, n) {
530
+ bt(e, n), e.fallbackContext && bt(e.fallbackContext, n);
531
+ {
532
+ let { __datetimeFormatters: t, __numberFormatters: n } = e;
533
+ t.clear(), n.clear();
534
+ }
535
+ e.localeFallbacker(e, n, t);
536
+ }
537
+ function St(e, t) {
538
+ return e !== t && e.split(`-`)[0] === t.split(`-`)[0];
502
539
  }
503
- function isImplicitFallback(e, t) {
540
+ function Ct(e, t) {
504
541
  let n = t.indexOf(e);
505
542
  if (n === -1) return !1;
506
- for (let r = n + 1; r < t.length; r++) if (isAlmostSameLocale(e, t[r])) return !0;
543
+ for (let r = n + 1; r < t.length; r++) if (St(e, t[r])) return !0;
507
544
  return !1;
508
545
  }
509
- function datetime(e, ...t) {
510
- let { datetimeFormats: n, unresolving: r, fallbackLocale: i, onWarn: s, localeFallbacker: u } = e, { __datetimeFormatters: d } = e;
511
- if (!isString(t[0]) && !isDate(t[0]) && !isNumber(t[0])) return ``;
512
- let [f, p, m, h] = parseDateTimeArgs(...t), g = isBoolean(m.missingWarn) ? m.missingWarn : e.missingWarn;
513
- isBoolean(m.fallbackWarn) ? m.fallbackWarn : e.fallbackWarn;
514
- let _ = !!m.part, v = getLocale(e, m), y = u(e, i, v);
515
- if (!isString(f) || f === ``) return new Intl.DateTimeFormat(v.replace(/!/g, ``), h).format(p);
516
- let b = {}, x, S = null;
517
- for (let t = 0; t < y.length && (x = y[t], b = n[x] || {}, S = b[f], !isPlainObject(S)); t++) handleMissing(e, f, x, g, `datetime format`);
518
- if (!isPlainObject(S) || !isString(x)) return r ? -1 : f;
519
- let C = `${x}__${f}`;
520
- isPlainObject(h) && !isKeylessObject(h) && (C = `${C}__${JSON.stringify(h)}`);
521
- let w = d.get(C);
522
- return w || (w = new Intl.DateTimeFormat(x, assign({}, S, h)), d.set(C, w)), _ ? w.formatToParts(p) : w.format(p);
523
- }
524
- const DATETIME_FORMAT_OPTIONS_KEYS = [
546
+ function wt(e, t, n, r, i, a, o) {
547
+ let { fallbackLocale: s, localeFallbacker: c, onWarn: l } = e, u = c(e, s, n);
548
+ for (let n = 0; n < u.length; n++) {
549
+ let a = u[n], s = p(p(r, a) || {}, t);
550
+ if (C(s) && _(a)) return a;
551
+ J(e, t, a, i, o);
552
+ }
553
+ return null;
554
+ }
555
+ function Tt(e) {
556
+ try {
557
+ return Intl.getCanonicalLocales(e), !0;
558
+ } catch {
559
+ return !1;
560
+ }
561
+ }
562
+ function Et(e, t, n, r, i) {
563
+ try {
564
+ return new t(n, r);
565
+ } catch (i) {
566
+ if (Tt(n)) throw i;
567
+ let { fallbackLocale: a, localeFallbacker: o, onWarn: s } = e;
568
+ return new t(o(e, a, n).find(Tt) || `en-US`, r);
569
+ }
570
+ }
571
+ function Dt(e, [t, n, r, i], a, o, s, l) {
572
+ let u = v(r.missingWarn) ? r.missingWarn : e.missingWarn, d = v(r.fallbackWarn) ? r.fallbackWarn : e.fallbackWarn, f = !!r.part, p = B(e, r);
573
+ if (!_(t) || t === ``) {
574
+ let t = Et(e, a, p.replace(/!/g, ``), i, l);
575
+ return f ? t.formatToParts(n) : t.format(n);
576
+ }
577
+ let m = wt(e, t, p, s, u, d, l);
578
+ if (!_(m)) return e.unresolving ? -1 : t;
579
+ let h = s[m][t], g = Ot(m, t, i), y = o.get(g);
580
+ return y || (y = Et(e, a, m, c({}, h, i), l), o.set(g, y)), f ? y.formatToParts(n) : y.format(n);
581
+ }
582
+ function Ot(e, t, n) {
583
+ let r = `${e}__${t}`;
584
+ return C(n) && !s(n) && (r = `${r}__${JSON.stringify(n)}`), r;
585
+ }
586
+ function kt(e, t, n) {
587
+ for (let r in n) {
588
+ let n = `${t}__${r}`;
589
+ for (let t of e.keys()) (t === n || t.startsWith(`${n}__`)) && e.delete(t);
590
+ }
591
+ }
592
+ function At(e, t, n, r) {
593
+ let [, i, a, o] = e, s = n;
594
+ return _(i) ? t.key = i : C(i) && Object.keys(i).forEach((e) => {
595
+ r.includes(e) ? s[e] = i[e] : t[e] = i[e];
596
+ }), _(a) ? t.locale = a : C(a) && (s = a), C(o) && (s = o), s;
597
+ }
598
+ function jt(e, ...t) {
599
+ let { datetimeFormats: n, onWarn: r } = e, { __datetimeFormatters: o } = e;
600
+ return !_(t[0]) && !a(t[0]) && !i(t[0]) ? `` : Dt(e, Nt(...t), Intl.DateTimeFormat, o, n, `datetime format`);
601
+ }
602
+ const Mt = [
525
603
  `localeMatcher`,
526
604
  `weekday`,
527
605
  `era`,
@@ -543,55 +621,39 @@ const DATETIME_FORMAT_OPTIONS_KEYS = [
543
621
  `hourCycle`,
544
622
  `fractionalSecondDigits`
545
623
  ];
546
- function parseDateTimeArgs(...e) {
547
- let [t, n, r, i] = e, s = create(), c = create(), l;
548
- if (isString(t)) {
549
- let e = t.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/);
550
- if (!e) throw Error(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT);
624
+ function Nt(...e) {
625
+ let [t] = e, n = u(), r = u(), o;
626
+ if (_(t)) {
627
+ let e = t.match(/^(\d{4}-\d{2}-\d{2})(?:(T|\s)(.+))?$/);
628
+ if (!e) throw Error(z.INVALID_ISO_DATE_ARGUMENT);
551
629
  let n = e[3] ? e[3].trim().startsWith(`T`) ? `${e[1].trim()}${e[3].trim()}` : `${e[1].trim()}T${e[3].trim()}` : e[1].trim();
552
- l = new Date(n);
630
+ o = new Date(n);
553
631
  try {
554
- l.toISOString();
632
+ o.toISOString();
555
633
  } catch {
556
- throw Error(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT);
634
+ throw Error(z.INVALID_ISO_DATE_ARGUMENT);
557
635
  }
558
- } else if (isDate(t)) {
559
- if (isNaN(t.getTime())) throw Error(CoreErrorCodes.INVALID_DATE_ARGUMENT);
560
- l = t;
561
- } else if (isNumber(t)) l = t;
562
- else throw Error(CoreErrorCodes.INVALID_ARGUMENT);
563
- return isString(n) ? s.key = n : isPlainObject(n) && Object.keys(n).forEach((e) => {
564
- DATETIME_FORMAT_OPTIONS_KEYS.includes(e) ? c[e] = n[e] : s[e] = n[e];
565
- }), isString(r) ? s.locale = r : isPlainObject(r) && (c = r), isPlainObject(i) && (c = i), [
566
- s.key || ``,
567
- l,
568
- s,
569
- c
636
+ } else if (a(t)) {
637
+ if (isNaN(t.getTime())) throw Error(z.INVALID_DATE_ARGUMENT);
638
+ o = t;
639
+ } else if (i(t)) o = t;
640
+ else throw Error(z.INVALID_ARGUMENT);
641
+ let s = At(e, n, r, Mt);
642
+ return [
643
+ n.key || ``,
644
+ o,
645
+ n,
646
+ s
570
647
  ];
571
648
  }
572
- function clearDateTimeFormat(e, t, n) {
573
- let r = e;
574
- for (let e in n) {
575
- let n = `${t}__${e}`;
576
- r.__datetimeFormatters.has(n) && r.__datetimeFormatters.delete(n);
577
- }
649
+ function Pt(e, t, n) {
650
+ kt(e.__datetimeFormatters, t, n);
651
+ }
652
+ function Ft(e, ...t) {
653
+ let { numberFormats: n, onWarn: r } = e, { __numberFormatters: a } = e;
654
+ return i(t[0]) ? Dt(e, Lt(...t), Intl.NumberFormat, a, n, `number format`) : ``;
578
655
  }
579
- function number(e, ...t) {
580
- let { numberFormats: n, unresolving: r, fallbackLocale: i, onWarn: o, localeFallbacker: s } = e, { __numberFormatters: u } = e;
581
- if (!isNumber(t[0])) return ``;
582
- let [d, f, p, m] = parseNumberArgs(...t), h = isBoolean(p.missingWarn) ? p.missingWarn : e.missingWarn;
583
- isBoolean(p.fallbackWarn) ? p.fallbackWarn : e.fallbackWarn;
584
- let g = !!p.part, _ = getLocale(e, p), v = s(e, i, _);
585
- if (!isString(d) || d === ``) return new Intl.NumberFormat(_.replace(/!/g, ``), m).format(f);
586
- let y = {}, b, x = null;
587
- for (let t = 0; t < v.length && (b = v[t], y = n[b] || {}, x = y[d], !isPlainObject(x)); t++) handleMissing(e, d, b, h, `number format`);
588
- if (!isPlainObject(x) || !isString(b)) return r ? -1 : d;
589
- let S = `${b}__${d}`;
590
- isPlainObject(m) && !isKeylessObject(m) && (S = `${S}__${JSON.stringify(m)}`);
591
- let C = u.get(S);
592
- return C || (C = new Intl.NumberFormat(b, assign({}, x, m)), u.set(S, C)), g ? C.formatToParts(f) : C.format(f);
593
- }
594
- const NUMBER_FORMAT_OPTIONS_KEYS = [
656
+ const It = [
595
657
  `localeMatcher`,
596
658
  `style`,
597
659
  `currency`,
@@ -613,124 +675,134 @@ const NUMBER_FORMAT_OPTIONS_KEYS = [
613
675
  `roundingIncrement`,
614
676
  `trailingZeroDisplay`
615
677
  ];
616
- function parseNumberArgs(...e) {
617
- let [t, n, r, i] = e, o = create(), s = create();
618
- if (!isNumber(t)) throw Error(CoreErrorCodes.INVALID_ARGUMENT);
619
- let c = t;
620
- return isString(n) ? o.key = n : isPlainObject(n) && Object.keys(n).forEach((e) => {
621
- NUMBER_FORMAT_OPTIONS_KEYS.includes(e) ? s[e] = n[e] : o[e] = n[e];
622
- }), isString(r) ? o.locale = r : isPlainObject(r) && (s = r), isPlainObject(i) && (s = i), [
623
- o.key || ``,
624
- c,
625
- o,
626
- s
678
+ function Lt(...e) {
679
+ let [t] = e, n = u(), r = u();
680
+ if (!i(t)) throw Error(z.INVALID_ARGUMENT);
681
+ let a = t, o = At(e, n, r, It);
682
+ return [
683
+ n.key || ``,
684
+ a,
685
+ n,
686
+ o
627
687
  ];
628
688
  }
629
- function clearNumberFormat(e, t, n) {
630
- let r = e;
631
- for (let e in n) {
632
- let n = `${t}__${e}`;
633
- r.__numberFormatters.has(n) && r.__numberFormatters.delete(n);
634
- }
689
+ function Rt(e, t, n) {
690
+ kt(e.__numberFormatters, t, n);
635
691
  }
636
- const DEFAULT_MODIFIER = (e) => e, DEFAULT_MESSAGE = (e) => ``, DEFAULT_MESSAGE_DATA_TYPE = `text`, DEFAULT_NORMALIZE = (e) => e.length === 0 ? `` : join(e), DEFAULT_INTERPOLATE = toDisplayString;
637
- function pluralDefault(e, t) {
692
+ const zt = (e) => e, Bt = (e) => ``, Vt = `text`, Ht = (e) => e.length === 0 ? `` : ee(e), Ut = w;
693
+ function Y(e, t) {
638
694
  return e = Math.abs(e), t === 2 ? e === 1 ? 0 : 1 : Math.min(e, 2);
639
695
  }
640
- const PLURAL_CATEGORY_ORDER = [
696
+ const X = [
641
697
  `zero`,
642
698
  `one`,
643
699
  `two`,
644
700
  `few`,
645
701
  `many`,
646
702
  `other`
647
- ], intlPluralRulesCache = /* @__PURE__ */ new Map();
648
- function getIntlPluralRules(e) {
649
- let t = intlPluralRulesCache.get(e);
650
- if (!t) {
651
- let n = new Intl.PluralRules(e);
652
- t = {
653
- rules: n,
654
- categories: n.resolvedOptions().pluralCategories.slice().sort((e, t) => PLURAL_CATEGORY_ORDER.indexOf(e) - PLURAL_CATEGORY_ORDER.indexOf(t))
655
- }, intlPluralRulesCache.set(e, t);
703
+ ], Z = /* @__PURE__ */ new Map();
704
+ function Wt(e) {
705
+ try {
706
+ if (Intl.PluralRules.supportedLocalesOf(e).length === 0) return null;
707
+ let t = new Intl.PluralRules(e);
708
+ return {
709
+ rules: t,
710
+ categories: t.resolvedOptions().pluralCategories.slice().sort((e, t) => X.indexOf(e) - X.indexOf(t))
711
+ };
712
+ } catch {
713
+ return null;
656
714
  }
657
- return t;
658
715
  }
659
- function getPluralIndex(e) {
660
- return isNumber(e.pluralIndex) ? e.pluralIndex : isNumber(e.named?.count) ? e.named.count : isNumber(e.named?.n) ? e.named.n : -1;
661
- }
662
- function createMessageContext(e = {}) {
663
- let t = e.locale, n = getPluralIndex(e), r;
664
- r = isString(t) && isFunction(e.pluralRules?.[t]) ? e.pluralRules[t] : isString(t) && typeof Intl < `u` && Intl.PluralRules !== void 0 ? (e, n) => {
665
- let { rules: r, categories: i } = getIntlPluralRules(t);
666
- if (n > i.length) return pluralDefault(e, n);
667
- let a = r.select(Math.abs(e)), o = i.indexOf(a);
668
- return Math.min(o === -1 ? n - 1 : o, n - 1);
669
- } : pluralDefault;
670
- let i = r === pluralDefault ? void 0 : pluralDefault, o = (e) => e[r(n, e.length, i)], s = e.list || [], c = (e) => s[e], u = e.named || create();
671
- isNumber(e.pluralIndex) && (u.count ??= e.pluralIndex, u.n ??= e.pluralIndex);
672
- let f = (e) => u[e];
673
- function p(t, n) {
674
- return (isFunction(e.messages) ? e.messages(t, !!n) : isObject(e.messages) ? e.messages[t] : !1) || (e.parent ? e.parent.message(t) : DEFAULT_MESSAGE);
716
+ function Gt(e) {
717
+ let t = Z.get(e);
718
+ return t === void 0 && (t = Wt(e), Z.size >= 1e3 && Z.delete(Z.keys().next().value), Z.set(e, t)), t;
719
+ }
720
+ function Kt(e) {
721
+ return i(e.pluralIndex) ? e.pluralIndex : i(e.named?.count) ? e.named.count : i(e.named?.n) ? e.named.n : -1;
722
+ }
723
+ function qt(e = {}) {
724
+ let t = e.locale, n = Kt(e), r;
725
+ r = _(t) && e.pluralRules && g(p(e.pluralRules, t)) ? e.pluralRules[t] : _(t) && typeof Intl < `u` && Intl.PluralRules !== void 0 ? (e, n) => {
726
+ let r = Gt(t);
727
+ if (r === null || n > r.categories.length) return Y(e, n);
728
+ let { rules: i, categories: a } = r, o = i.select(Math.abs(e)), s = a.indexOf(o);
729
+ return Math.min(s === -1 ? n - 1 : s, n - 1);
730
+ } : Y;
731
+ let a = r === Y ? void 0 : Y, o = (e) => e[r(n, e.length, a)], s = e.list || [], l = (e) => s[e], d = e.named || u(), f = i(e.pluralIndex), v = (t) => {
732
+ let n = m(t) ? p(d, t) : d[t];
733
+ return f && n == null && (t === `count` || t === `n`) ? e.pluralIndex : n;
734
+ };
735
+ function b(t, n) {
736
+ return (g(e.messages) ? e.messages(t, !!n) : y(e.messages) ? e.messages[t] : !1) || (e.parent ? e.parent.message(t) : Bt);
675
737
  }
676
- let m = (t) => e.modifiers ? e.modifiers[t] : DEFAULT_MODIFIER, h = isFunction(e.processor?.normalize) ? e.processor.normalize : DEFAULT_NORMALIZE, g = isFunction(e.processor?.interpolate) ? e.processor.interpolate : DEFAULT_INTERPOLATE, _ = {
677
- list: c,
678
- named: f,
738
+ let x = (t) => e.modifiers ? p(e.modifiers, t) : zt, S = g(e.processor?.normalize) ? e.processor.normalize : Ht, C = g(e.processor?.interpolate) ? e.processor.interpolate : Ut, w = {
739
+ list: l,
740
+ named: v,
679
741
  plural: o,
680
742
  linked: (e, ...t) => {
681
743
  let [n, r] = t, i = `text`, a = ``;
682
- t.length === 1 ? isObject(n) ? (a = n.modifier || a, i = n.type || i) : isString(n) && (a = n || a) : t.length === 2 && (isString(n) && (a = n || a), isString(r) && (i = r || i));
683
- let o = p(e, !0)(_), s = o === `` || o === void 0 ? e : o, c = i === `vnode` && isArray(s) && a ? s[0] : s;
684
- return a ? m(a)(c, i) : c;
744
+ t.length === 1 ? y(n) ? (a = n.modifier || a, i = n.type || i) : _(n) && (a = n || a) : t.length === 2 && (_(n) && (a = n || a), _(r) && (i = r || i));
745
+ let o = b(e, !0)(w), s = o === `` || o === void 0 ? e : o, c = i === `vnode` && h(s) && a ? s[0] : s;
746
+ if (!a) return c;
747
+ let l = x(a);
748
+ return g(l) ? l(c, i) : c;
685
749
  },
686
- message: p,
687
- type: isString(e.processor?.type) ? e.processor.type : DEFAULT_MESSAGE_DATA_TYPE,
688
- interpolate: g,
689
- normalize: h,
690
- values: assign(create(), s, u)
750
+ message: b,
751
+ type: _(e.processor?.type) ? e.processor.type : Vt,
752
+ interpolate: C,
753
+ normalize: S,
754
+ values: c(u(), s, d, f ? {
755
+ count: v(`count`),
756
+ n: v(`n`)
757
+ } : {})
691
758
  };
692
- return _;
759
+ return w;
693
760
  }
694
- const NOOP_MESSAGE_FUNCTION = () => ``, isMessageFunction = (e) => isFunction(e);
695
- function translate(e, ...t) {
696
- let [n, r] = parseTranslateArgs(...t), i = getLocale(e, r), a = isBoolean(r.escapeParameter) ? r.escapeParameter : e.escapeParameter;
697
- a && escapeParams(r);
761
+ const Jt = () => ``, Q = (e) => g(e), $ = (e) => _(e) || k(e) || Q(e);
762
+ function Yt(e, ...t) {
763
+ let [n, r] = $t(...t), i = B(e, r), a = v(r.escapeParameter) ? r.escapeParameter : e.escapeParameter;
764
+ a && Xt(r);
698
765
  let o = !!r.resolvedMessage, [s, c, l] = o ? [
699
766
  n,
700
767
  i,
701
- e.messages[i] || create()
702
- ] : resolveMessageFormat(e, n, i, e.fallbackLocale, isBoolean(r.fallbackWarn) ? r.fallbackWarn : e.fallbackWarn, isBoolean(r.missingWarn) ? r.missingWarn : e.missingWarn), u = n;
703
- if (!o && !(isString(s) || isMessageAST(s) || isMessageFunction(s))) {
704
- let t = isString(r.default) ? r.default : isBoolean(r.default) || e.fallbackFormat ? e.messageCompiler ? n : () => n : null;
705
- (e.fallbackFormat || t != null && (isString(t) || isFunction(t))) && (s = t, u = s);
768
+ p(e.messages, i) || u()
769
+ ] : Zt(e, n, i, e.fallbackLocale, v(r.fallbackWarn) ? r.fallbackWarn : e.fallbackWarn, v(r.missingWarn) ? r.missingWarn : e.missingWarn), d = n;
770
+ if (!o && !$(s)) {
771
+ let t = _(r.default) ? r.default : v(r.default) || e.fallbackFormat ? e.messageCompiler ? n : () => n : null;
772
+ (e.fallbackFormat || t != null && (_(t) || g(t))) && (s = t, d = s);
706
773
  }
707
- if (!o && (!(isString(s) || isMessageAST(s) || isMessageFunction(s)) || !isString(c))) return e.unresolving ? -1 : n;
708
- let f = !1, p = isMessageFunction(s) ? s : compileMessageFormat(e, n, c, s, u, () => {
774
+ if (!o && (!$(s) || !_(c))) return e.unresolving ? -1 : n;
775
+ let f = !1, m = Q(s) ? s : Qt(e, n, c, s, d, () => {
709
776
  f = !0;
710
777
  });
711
778
  if (f) return s;
712
- let m = p(createMessageContext(getMessageContextOptions(e, c, l, r))), h = e.postTranslation ? e.postTranslation(m, n) : m;
713
- return a && isString(h) && (h = sanitizeTranslatedHtml(h)), h;
714
- }
715
- function escapeParams(e) {
716
- isArray(e.list) ? e.list = e.list.map((e) => isString(e) ? escapeHtml(e) : e) : isObject(e.named) && Object.keys(e.named).forEach((t) => {
717
- isString(e.named[t]) && (e.named[t] = escapeHtml(e.named[t]));
718
- });
779
+ let h = m(qt(tn(e, c, l, r))), y = e.postTranslation ? e.postTranslation(h, n) : h;
780
+ return a && _(y) && (y = ge(y)), y;
781
+ }
782
+ function Xt(e) {
783
+ if (h(e.list) && (e.list = e.list.map((e) => _(e) ? T(e) : e)), y(e.named)) {
784
+ let t = e.named, n = u();
785
+ for (let e of Object.keys(t)) {
786
+ let r = t[e];
787
+ n[e] = _(r) ? T(r) : r;
788
+ }
789
+ e.named = n;
790
+ }
719
791
  }
720
- function resolveMessageFormat(e, t, n, r, i, a) {
721
- let { messages: o, onWarn: s, messageResolver: c, localeFallbacker: l } = e, u = l(e, r, n), f = create(), p, m = null;
722
- for (let n = 0; n < u.length && (p = u[n], f = o[p] || create(), (m = c(f, t)) === null && (m = f[t]), !(isString(m) || isMessageAST(m) || isMessageFunction(m))); n++) if (!isImplicitFallback(p, u)) {
723
- let n = handleMissing(e, t, p, a, `translate`);
724
- n !== t && (m = n);
792
+ function Zt(e, t, n, r, i, a) {
793
+ let { messages: o, onWarn: s, messageResolver: c, localeFallbacker: l } = e, d = l(e, r, n), f = u(), m, h = null;
794
+ for (let n = 0; n < d.length && (m = d[n], f = p(o, m) || u(), (h = c(f, t)) === null && (h = p(f, t)), !$(h)); n++) if (!Ct(m, d)) {
795
+ let n = J(e, t, m, a, `translate`);
796
+ n !== t && (h = n);
725
797
  }
726
798
  return [
799
+ h,
727
800
  m,
728
- p,
729
801
  f
730
802
  ];
731
803
  }
732
- function compileMessageFormat(e, t, n, r, i, a) {
733
- if (isMessageFunction(r)) {
804
+ function Qt(e, t, n, r, i, a) {
805
+ if (Q(r)) {
734
806
  let e = r;
735
807
  return e.locale = e.locale || n, e.key = e.key || t, e;
736
808
  }
@@ -738,51 +810,50 @@ function compileMessageFormat(e, t, n, r, i, a) {
738
810
  let e = (() => r);
739
811
  return e.locale = n, e.key = t, e;
740
812
  }
741
- let o = e.messageCompiler(r, getCompileContext(e, n, i, r, e.warnHtmlMessage, a));
813
+ let o = e.messageCompiler(r, en(e, n, i, r, e.warnHtmlMessage, a));
742
814
  return o.locale = n, o.key = t, o.source = r, o;
743
815
  }
744
- function parseTranslateArgs(...e) {
816
+ function $t(...e) {
745
817
  let [t, n, r] = e;
746
- if (!isString(t) && !isNumber(t) && !isMessageFunction(t) && !isMessageAST(t)) throw Error(CoreErrorCodes.INVALID_ARGUMENT);
747
- let i = isNumber(t) ? String(t) : (isMessageFunction(t), t), o = create();
748
- return isNumber(n) ? o.plural = n : isString(n) ? o.default = n : isPlainObject(n) && !isKeylessObject(n) ? o.named = n : isArray(n) && (o.list = n), isNumber(r) ? o.plural = r : isString(r) ? o.default = r : isPlainObject(r) && assign(o, r), [i, o];
818
+ if (!_(t) && !i(t) && !Q(t) && !k(t)) throw Error(z.INVALID_ARGUMENT);
819
+ let a = i(t) ? String(t) : (Q(t), t), o = u();
820
+ return i(n) ? o.plural = n : _(n) ? o.default = n : C(n) && !s(n) ? o.named = n : h(n) && (o.list = n), i(r) ? o.plural = r : _(r) ? o.default = r : C(r) && c(o, r), [a, o];
749
821
  }
750
- function getCompileContext(e, t, n, i, a, o) {
822
+ function en(e, t, r, i, a, o) {
751
823
  return {
752
824
  locale: t,
753
- key: n,
825
+ key: r,
754
826
  warnHtmlMessage: a,
755
827
  onError: (e) => {
756
828
  throw o?.(e), e;
757
829
  },
758
- onCacheKey: (e) => generateFormatCacheKey(t, n, e)
830
+ onCacheKey: (e) => n(t, r, e)
759
831
  };
760
832
  }
761
- function getMessageContextOptions(e, t, n, r) {
762
- let { modifiers: i, pluralRules: o, messageResolver: s, fallbackLocale: c, fallbackWarn: l, missingWarn: u, fallbackContext: d } = e;
833
+ function tn(e, t, n, r) {
834
+ let { modifiers: a, pluralRules: o, messageResolver: s, fallbackLocale: c, fallbackWarn: l, missingWarn: u, fallbackContext: d } = e;
763
835
  return {
764
836
  locale: t,
765
- modifiers: i,
837
+ modifiers: a,
766
838
  pluralRules: o,
767
839
  messages: (r, i) => {
768
840
  let a = s(n, r);
769
841
  if (a == null && (d || i)) {
770
- let [n, , i] = resolveMessageFormat(d || e, r, t, c, l, u);
842
+ let [n, , i] = Zt(d || e, r, t, c, l, u);
771
843
  a = n ?? s(i, r);
772
844
  }
773
- if (isString(a) || isMessageAST(a)) {
774
- let n = !1, i = compileMessageFormat(e, r, t, a, r, () => {
845
+ if (_(a) || k(a)) {
846
+ let n = !1, i = Qt(e, r, t, a, r, () => {
775
847
  n = !0;
776
848
  });
777
- return n ? NOOP_MESSAGE_FUNCTION : i;
778
- } else if (isMessageFunction(a)) return a;
779
- else return NOOP_MESSAGE_FUNCTION;
849
+ return n ? Jt : i;
850
+ }
851
+ return Q(a) ? a : Jt;
780
852
  },
781
853
  processor: e.processor ?? void 0,
782
854
  list: r.list ?? void 0,
783
855
  named: r.named ?? void 0,
784
- pluralIndex: isNumber(r.plural) ? r.plural : void 0
856
+ pluralIndex: i(r.plural) ? r.plural : void 0
785
857
  };
786
858
  }
787
- registerMessageCompiler(compile), registerMessageResolver(resolveValue), registerLocaleFallbacker(fallbackWithLocaleChain);
788
- export { AST_NODE_PROPS_KEYS, CORE_ERROR_CODES_EXTEND_POINT, CORE_WARN_CODES_EXTEND_POINT, CoreWarnCodes, DATETIME_FORMAT_OPTIONS_KEYS, DEFAULT_LOCALE, DEFAULT_MESSAGE_DATA_TYPE, MISSING_RESOLVE_VALUE, NOT_RESOLVED, NUMBER_FORMAT_OPTIONS_KEYS, VERSION, clearCompileCache, clearDateTimeFormat, clearNumberFormat, compile, createCompileError, createCoreContext, createCoreError, createMessageContext, datetime, fallbackWithLocaleChain, fallbackWithSimple, getFallbackContext, getLocale, getLocaleMessage, getWarnMessage, handleMissing, isAlmostSameLocale, isImplicitFallback, isMessageAST, isMessageFunction, isTranslateFallbackWarn, isTranslateMissingWarn, number, parse, parseDateTimeArgs, parseNumberArgs, parseTranslateArgs, registerLocaleFallbacker, registerMessageCompiler, registerMessageResolver, resolveLocale, resolveValue, resolveWithKeyValue, setFallbackContext, setLocaleMessage, translate, updateFallbackLocale };
859
+ export { je as AST_NODE_PROPS_KEYS, Le as CORE_ERROR_CODES_EXTEND_POINT, $e as CORE_WARN_CODES_EXTEND_POINT, W as CoreWarnCodes, Mt as DATETIME_FORMAT_OPTIONS_KEYS, G as DEFAULT_LOCALE, Vt as DEFAULT_MESSAGE_DATA_TYPE, it as MISSING_RESOLVE_VALUE, rt as NOT_RESOLVED, It as NUMBER_FORMAT_OPTIONS_KEYS, nt as VERSION, Fe as clearCompileCache, Pt as clearDateTimeFormat, Rt as clearNumberFormat, Ie as compile, ye as createCompileError, mt as createCoreContext, Re as createCoreError, qt as createMessageContext, jt as datetime, Be as fallbackWithLocaleChain, ze as fallbackWithSimple, B as getLocale, ht as getLocaleMessage, tt as getWarnMessage, J as handleMissing, St as isAlmostSameLocale, _t as isFallbackLocale, Ct as isImplicitFallback, k as isMessageAST, $ as isMessageFormat, Q as isMessageFunction, vt as isTranslateFallbackWarn, yt as isTranslateMissingWarn, q as isWarnOption, Ft as number, Ye as parse, Nt as parseDateTimeArgs, Lt as parseNumberArgs, $t as parseTranslateArgs, ft as registerLocaleFallbacker, ct as registerMessageCompiler, ut as registerMessageResolver, H as resolveLocale, Qe as resolveValue, Ze as resolveWithKeyValue, gt as setLocaleMessage, Yt as translate, xt as updateFallbackLocale };