@intlify/core 11.4.18 → 11.4.19

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,5 +1,5 @@
1
1
  /*!
2
- * core v11.4.18
2
+ * core v11.4.19
3
3
  * (c) 2026 kazuya kawaguchi
4
4
  * Released under the MIT License.
5
5
  */
@@ -190,19 +190,26 @@ const namedWhitespaceCharacterReferencePattern = /&(?:Tab|NewLine);/g;
190
190
  const colonCharacterReferencePattern = /:?/gi;
191
191
  // eslint-disable-next-line no-control-regex -- URL scheme normalization requires the full control range
192
192
  const controlOrWhitespacePattern = /[\u0000-\u0020\u007f-\u009f]/g;
193
- const eventHandlerPattern = /(?:^|[\s"'<>/])on\w+\s*=\s*["']?[^"'>]+["']?/i;
194
- const eventHandlerAttributePattern = /(^|[\s"'<>/])on(\w+\s*=)/gi;
193
+ const eventHandlerPattern = /^on\w/i;
195
194
  // `srcdoc` holds a whole HTML document: its value is entity-decoded and then parsed again,
196
195
  // so neither escaping the value nor neutralizing `on*` inside it makes it inert
197
- const srcdocPattern = /(?:^|[\s"'<>/])srcdoc\s*=/i;
198
- const srcdocAttributePattern = /(^|[\s"'<>/])s(rcdoc\s*=)/gi;
196
+ const srcdocPattern = /^srcdoc$/i;
199
197
  // `<base>` changes how the page resolves every relative URL after it, and SVG `<animate>` and `<set>`
200
198
  // can set `href` of an SVG `<a>` through `values` or `to`, which the URL check does not look at.
201
199
  // `<script>` does not run when inserted with `innerHTML`, but it runs when the HTML is rendered
202
- // on the server (SSR) and the browser parses it as part of the page
203
- const dangerousElementPattern = /<(?:base|animate|set|script)(?=[\s/>]|$)/i;
204
- const dangerousElementStartTagPattern = /<(base|animate|set|script)(?=[\s/>]|$)/gi;
205
- const unquotedUrlAttributePattern = /(^|[\s"'<>/])((?:href|xlink:href|src|action|formaction)\s*=\s*)([^\s"'=<>`]+)/gi;
200
+ // on the server (SSR) and the browser parses it as part of the page.
201
+ // `<plaintext>` turns the rest of the page into text
202
+ const dangerousElementPattern = /^(?:base|animate|set|script|plaintext)$/i;
203
+ // The content of these elements is text up to their end tag when they are HTML elements, and markup when
204
+ // they are SVG or MathML elements. Their content is turned into text, so that it reads the same in both
205
+ const textContentElementPattern = /^(?:iframe|noembed|noframes|noscript|style|textarea|title|xmp)$/i;
206
+ // The rules of the HTML tokenizer for tags, comments, and the end of a tag that is not closed (`$`):
207
+ // - `<` or `</`, and the tag name
208
+ const tagStartPattern = /<(\/?)([a-z][^\t\n\f\r />]*)/iy;
209
+ // - whitespace and `/`, and then `>` or an attribute: its name, and its value in quotes or without quotes
210
+ const tagStepPattern = /([\t\n\f\r /]*)(?:(>)|([^\t\n\f\r />][^\t\n\f\r />=]*)(?:[\t\n\f\r ]*=[\t\n\f\r ]*(?:(["'])([\s\S]*?)(\4|$)|([^\t\n\f\r >]*)))?)/y;
211
+ // - a comment, which ends with `-->` or `--!>`, or with `>` or `->` right after `<!--`
212
+ const commentPattern = /<!--(?:>|->|[\s\S]*?--!?>)/y;
206
213
  function decodeNumericCharacterReference(match, hex, decimal) {
207
214
  const digits = hex || decimal;
208
215
  if (!digits) {
@@ -274,42 +281,167 @@ function sanitizeAttributeValue(attrName, value) {
274
281
  const sanitizedValue = attrName.toLowerCase() === 'style' ? sanitizeStyleValue(value) : value;
275
282
  return escapeAttributeValue(sanitizedValue);
276
283
  }
284
+ function escapeLessThan(text) {
285
+ return text.replace(/</g, '&lt;');
286
+ }
287
+ function serializeAttribute(attrName, value, quote, neutralized) {
288
+ // Character references are not decoded in attribute names, so escaping a character renames the attribute
289
+ let name = attrName;
290
+ if (eventHandlerPattern.test(attrName)) {
291
+ neutralized.eventHandler = true;
292
+ name = `&#111;n${attrName.slice(2)}`;
293
+ }
294
+ else if (srcdocPattern.test(attrName)) {
295
+ neutralized.srcdoc = true;
296
+ name = `&#115;${attrName.slice(1)}`;
297
+ }
298
+ if (value === undefined) {
299
+ return name;
300
+ }
301
+ // An unquoted value stays unquoted: it has no whitespace or `>`, and escaping does not add them
302
+ const valueQuote = quote || '';
303
+ return `${name}=${valueQuote}${sanitizeAttributeValue(attrName, value)}${valueQuote}`;
304
+ }
305
+ /**
306
+ * Read a tag with the rules of the HTML tokenizer.
307
+ * A start tag is written again with its attributes sanitized, and an end tag is kept as it is
308
+ *
309
+ * @param html - The HTML
310
+ * @param start - The index of `<`
311
+ * @param neutralized - What has been neutralized
312
+ * @returns The tag, the tag name, and the index after the tag (-1 when the tag is not closed),
313
+ * or `undefined` when `<` does not start a tag
314
+ */
315
+ function readTag(html, start, neutralized) {
316
+ tagStartPattern.lastIndex = start;
317
+ const tagStart = tagStartPattern.exec(html);
318
+ if (!tagStart) {
319
+ return;
320
+ }
321
+ const [, slash, tagName] = tagStart;
322
+ let tag = tagStart[0];
323
+ let step;
324
+ tagStepPattern.lastIndex = tagStartPattern.lastIndex;
325
+ while ((step = tagStepPattern.exec(html))) {
326
+ const [raw, separator, close, attrName, quote, quotedValue, closingQuote, unquotedValue] = step;
327
+ if (close) {
328
+ const end = tagStepPattern.lastIndex;
329
+ // browsers ignore the attributes of end tags
330
+ return [slash ? html.slice(start, end) : tag + raw, tagName, end];
331
+ }
332
+ if (quote && !closingQuote) {
333
+ break;
334
+ }
335
+ if (!slash) {
336
+ const value = quote ? quotedValue : unquotedValue;
337
+ tag += separator + serializeAttribute(attrName, value, quote, neutralized);
338
+ }
339
+ }
340
+ return [tag, tagName, -1];
341
+ }
342
+ /**
343
+ * Find the end tag of an element whose content is text, as the HTML tokenizer does:
344
+ * the first `</` followed by the tag name, and by whitespace, `/` or `>`
345
+ *
346
+ * @returns The index of the end tag, or -1 when it is not found or not closed in the string
347
+ */
348
+ function findTextContentEnd(html, from, tagName) {
349
+ for (let index = html.indexOf('</', from); index !== -1; index = html.indexOf('</', index + 2)) {
350
+ const endTag = readTag(html, index, {});
351
+ if (endTag && endTag[1].toLowerCase() === tagName.toLowerCase()) {
352
+ return endTag[2] === -1 ? -1 : index;
353
+ }
354
+ }
355
+ return -1;
356
+ }
357
+ /**
358
+ * Sanitize the translated HTML
359
+ *
360
+ * @remarks
361
+ * Tags are read with the rules of the HTML tokenizer, so that the sanitizer and browsers agree on
362
+ * where each tag and each attribute starts and ends, and every attribute of every start tag is checked.
363
+ * What is still open at the end of the string (a tag, a comment, or an element whose content is text,
364
+ * like `<textarea>`) becomes text: on the server (SSR), the rest of the page follows the translation,
365
+ * and it would be read as a part of what is open
366
+ *
367
+ * @param html - The translated HTML
368
+ * @returns The sanitized HTML
369
+ */
277
370
  function sanitizeTranslatedHtml(html) {
278
- // Escape dangerous characters in attribute values
279
- // Process attributes with double quotes
280
- html = html.replace(/([\w:-]+)\s*=\s*"([^"]*)"/g, (_, attrName, attrValue) => `${attrName}="${sanitizeAttributeValue(attrName, attrValue)}"`);
281
- // Process attributes with single quotes
282
- html = html.replace(/([\w:-]+)\s*=\s*'([^']*)'/g, (_, attrName, attrValue) => `${attrName}='${sanitizeAttributeValue(attrName, attrValue)}'`);
283
- // Detect and neutralize event handler attributes
284
- if (eventHandlerPattern.test(html)) {
285
- {
371
+ const neutralized = {};
372
+ let result = '';
373
+ let index = 0;
374
+ let lessThan;
375
+ while ((lessThan = html.indexOf('<', index)) !== -1) {
376
+ result += html.slice(index, lessThan);
377
+ index = lessThan + 1;
378
+ const read = readTag(html, lessThan, neutralized);
379
+ if (read) {
380
+ const [tag, tagName, end] = read;
381
+ if (end === -1) {
382
+ neutralized.unclosed = true;
383
+ result += escapeLessThan(html.slice(lessThan));
384
+ index = html.length;
385
+ break;
386
+ }
387
+ index = end;
388
+ if (tag[1] === '/') {
389
+ result += tag;
390
+ }
391
+ else if (dangerousElementPattern.test(tagName)) {
392
+ // the start tag becomes text
393
+ neutralized.element = true;
394
+ result += escapeLessThan(tag);
395
+ }
396
+ else if (textContentElementPattern.test(tagName)) {
397
+ const contentEnd = findTextContentEnd(html, end, tagName);
398
+ if (contentEnd === -1) {
399
+ // the start tag becomes text, and the content is read as HTML, as browsers do then
400
+ neutralized.unclosed = true;
401
+ result += escapeLessThan(tag);
402
+ }
403
+ else {
404
+ result += tag + escapeLessThan(html.slice(end, contentEnd));
405
+ index = contentEnd;
406
+ }
407
+ }
408
+ else {
409
+ result += tag;
410
+ }
411
+ continue;
412
+ }
413
+ commentPattern.lastIndex = lessThan;
414
+ if (commentPattern.test(html)) {
415
+ result += html.slice(lessThan, commentPattern.lastIndex);
416
+ index = commentPattern.lastIndex;
417
+ continue;
418
+ }
419
+ if (html.startsWith('<!--', lessThan)) {
420
+ neutralized.unclosed = true;
421
+ }
422
+ // `<!DOCTYPE`, `<![CDATA[`, `<?`, `</` without a tag name, `<` at the end and any other `<` become text
423
+ result += '&lt;';
424
+ }
425
+ result += html.slice(index);
426
+ {
427
+ if (neutralized.eventHandler) {
286
428
  warn('Potentially dangerous event handlers detected in translation. ' +
287
429
  'Consider removing onclick, onerror, etc. from your translation messages.');
288
430
  }
289
- // Neutralize event handler attributes by escaping 'on'
290
- html = html.replace(eventHandlerAttributePattern, '$1&#111;n$2');
291
- }
292
- // Detect and neutralize `srcdoc` attributes
293
- if (srcdocPattern.test(html)) {
294
- {
431
+ if (neutralized.srcdoc) {
295
432
  warn('Potentially dangerous srcdoc attribute detected in translation. ' +
296
433
  'Consider removing srcdoc from your translation messages.');
297
434
  }
298
- // Neutralize `srcdoc` by escaping 's': character references are not decoded in attribute names
299
- html = html.replace(srcdocAttributePattern, '$1&#115;$2');
300
- }
301
- // Detect and neutralize `<base>`, `<animate>`, `<set>` and `<script>` elements
302
- if (dangerousElementPattern.test(html)) {
303
- {
304
- warn('Potentially dangerous element (<base>, <animate>, <set> or <script>) ' +
435
+ if (neutralized.element) {
436
+ warn('Potentially dangerous element (<base>, <animate>, <set>, <script> or <plaintext>) ' +
305
437
  'detected in translation. Consider removing it from your translation messages.');
306
438
  }
307
- // Neutralize these elements by escaping '<': the start tag becomes text
308
- html = html.replace(dangerousElementStartTagPattern, '&lt;$1');
439
+ if (neutralized.unclosed) {
440
+ warn('Unclosed tag, comment or element (such as <textarea>) detected in translation. ' +
441
+ 'Consider closing it in your translation messages.');
442
+ }
309
443
  }
310
- // Disable javascript: URLs in unquoted attributes
311
- html = html.replace(unquotedUrlAttributePattern, (match, boundary, prefix, attrValue) => hasJavascriptScheme(attrValue) ? `${boundary}${prefix}about:blank` : match);
312
- return html;
444
+ return result;
313
445
  }
314
446
 
315
447
  const CompileErrorCodes = {
@@ -1099,7 +1231,7 @@ function getWarnMessage(code, ...args) {
1099
1231
  * Intlify core-base version
1100
1232
  * @internal
1101
1233
  */
1102
- const VERSION = '11.4.18';
1234
+ const VERSION = '11.4.19';
1103
1235
  const NOT_REOSLVED = -1;
1104
1236
  const DEFAULT_LOCALE = 'en-US';
1105
1237
  const MISSING_RESOLVE_VALUE = '';
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * core v11.4.18
2
+ * core v11.4.19
3
3
  * (c) 2026 kazuya kawaguchi
4
4
  * Released under the MIT License.
5
5
  */
6
- const RE_ARGS=/\{([0-9a-zA-Z]+)\}/g;function format$1(e,...t){return 1===t.length&&isObject(t[0])&&(t=t[0]),t&&t.hasOwnProperty||(t={}),e.replace(RE_ARGS,((e,r)=>t.hasOwnProperty(r)?t[r]:""))}const generateFormatCacheKey=(e,t,r)=>friendlyJSONstringify({l:e,k:t,s:r}),friendlyJSONstringify=e=>JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029").replace(/\u0027/g,"\\u0027"),isNumber=e=>"number"==typeof e&&isFinite(e),isDate=e=>"[object Date]"===toTypeString(e),isRegExp=e=>"[object RegExp]"===toTypeString(e),isEmptyObject=e=>isPlainObject(e)&&0===Object.keys(e).length,assign=Object.assign,_create=Object.create,create=(e=null)=>_create(e),hasOwnProperty=Object.prototype.hasOwnProperty;function hasOwn(e,t){return hasOwnProperty.call(e,t)}function getOwn(e,t){const r=e[t];return hasOwn(e,t)?r:void 0}function isObjectPrototypeKey(e){return hasOwn(Object.prototype,e)}const isArray=Array.isArray,isFunction=e=>"function"==typeof e,isString=e=>"string"==typeof e,isBoolean=e=>"boolean"==typeof e,isObject=e=>null!==e&&"object"==typeof e,isPromise=e=>isObject(e)&&isFunction(e.then)&&isFunction(e.catch),objectToString=Object.prototype.toString,toTypeString=e=>objectToString.call(e),isPlainObject=e=>"[object Object]"===toTypeString(e),toDisplayString=e=>null==e?"":isArray(e)||isPlainObject(e)&&e.toString===objectToString?JSON.stringify(e,null,2):String(e);function join(e,t=""){return e.reduce(((e,r,a)=>0===a?e+r:e+t+r),"")}function warn(e,t){"undefined"!=typeof console&&(console.warn("[intlify] "+e),t&&console.warn(t.stack))}function escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/\//g,"&#x2F;").replace(/=/g,"&#x3D;")}function escapeAttributeValue(e){return e.replace(/&(?![a-z0-9#]{2,6};)/gi,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const javascriptSchemePattern=/^javascript:/i,urlAttributePattern=/^(?:href|xlink:href|src|action|formaction)$/i,numericCharacterReferencePattern=/&#(?:x([0-9a-f]+)|(\d+));?/gi,namedWhitespaceCharacterReferencePattern=/&(?:Tab|NewLine);/g,colonCharacterReferencePattern=/&colon;?/gi,controlOrWhitespacePattern=/[\u0000-\u0020\u007f-\u009f]/g,eventHandlerPattern=/(?:^|[\s"'<>/])on\w+\s*=\s*["']?[^"'>]+["']?/i,eventHandlerAttributePattern=/(^|[\s"'<>/])on(\w+\s*=)/gi,srcdocPattern=/(?:^|[\s"'<>/])srcdoc\s*=/i,srcdocAttributePattern=/(^|[\s"'<>/])s(rcdoc\s*=)/gi,dangerousElementPattern=/<(?:base|animate|set|script)(?=[\s/>]|$)/i,dangerousElementStartTagPattern=/<(base|animate|set|script)(?=[\s/>]|$)/gi,unquotedUrlAttributePattern=/(^|[\s"'<>/])((?:href|xlink:href|src|action|formaction)\s*=\s*)([^\s"'=<>`]+)/gi;function decodeNumericCharacterReference(e,t,r){const a=t||r;if(!a)return e;const n=Number.parseInt(a,t?16:10);return n<=127?String.fromCharCode(n):e}function hasJavascriptScheme(e){const t=e.replace(numericCharacterReferencePattern,decodeNumericCharacterReference).replace(namedWhitespaceCharacterReferencePattern,"").replace(colonCharacterReferencePattern,":").replace(controlOrWhitespacePattern,"");return javascriptSchemePattern.test(t)}function sanitizeStyleValue(e){const t=/url\s*\(/gi;let r,a="",n=0;for(;null!==(r=t.exec(e));){const s=r.index,o=t.lastIndex-1;let i=o+1,l=1,c=null;for(;i<e.length;i++){const t=e[i];if(c)t===c&&(c=null);else if('"'===t||"'"===t)c=t;else if("("===t)l++;else if(")"===t&&(l--,0===l))break}if(0!==l)break;const u=e.slice(o+1,i).trim(),m=u.startsWith('"')&&u.endsWith('"')||u.startsWith("'")&&u.endsWith("'")?u.slice(1,-1).trim():u;a+=e.slice(n,s),a+=hasJavascriptScheme(m)?"url(about:blank)":e.slice(s,i+1),n=i+1}return a+e.slice(n)}function sanitizeAttributeValue(e,t){if(urlAttributePattern.test(e)&&hasJavascriptScheme(t))return"about:blank";return escapeAttributeValue("style"===e.toLowerCase()?sanitizeStyleValue(t):t)}function sanitizeTranslatedHtml(e){return e=(e=e.replace(/([\w:-]+)\s*=\s*"([^"]*)"/g,((e,t,r)=>`${t}="${sanitizeAttributeValue(t,r)}"`))).replace(/([\w:-]+)\s*=\s*'([^']*)'/g,((e,t,r)=>`${t}='${sanitizeAttributeValue(t,r)}'`)),eventHandlerPattern.test(e)&&(e=e.replace(eventHandlerAttributePattern,"$1&#111;n$2")),srcdocPattern.test(e)&&(e=e.replace(srcdocAttributePattern,"$1&#115;$2")),dangerousElementPattern.test(e)&&(e=e.replace(dangerousElementStartTagPattern,"&lt;$1")),e=e.replace(unquotedUrlAttributePattern,((e,t,r,a)=>hasJavascriptScheme(a)?`${t}${r}about:blank`:e))}const CompileErrorCodes={EXPECTED_TOKEN:1,INVALID_TOKEN_IN_PLACEHOLDER:2,UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER:3,UNKNOWN_ESCAPE_SEQUENCE:4,INVALID_UNICODE_ESCAPE_SEQUENCE:5,UNBALANCED_CLOSING_BRACE:6,UNTERMINATED_CLOSING_BRACE:7,EMPTY_PLACEHOLDER:8,NOT_ALLOW_NEST_PLACEHOLDER:9,INVALID_LINKED_FORMAT:10,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,UNHANDLED_CODEGEN_NODE_TYPE:15,UNHANDLED_MINIFIER_NODE_TYPE:16},COMPILE_ERROR_CODES_EXTEND_POINT=17;function createCompileError(e,t,r={}){const{domain:a,messages:n,args:s}=r,o=new SyntaxError(String(e));return o.code=e,t&&(o.location=t),o.domain=a,o}function isMessageAST(e){return isObject(e)&&0===resolveType(e)&&(hasOwn(e,"b")||hasOwn(e,"body"))}const PROPS_BODY=["b","body"];function resolveBody(e){return resolveProps(e,PROPS_BODY)}const PROPS_CASES=["c","cases"];function resolveCases(e){return resolveProps(e,PROPS_CASES,[])}const PROPS_STATIC=["s","static"];function resolveStatic(e){return resolveProps(e,PROPS_STATIC)}const PROPS_ITEMS=["i","items"];function resolveItems(e){return resolveProps(e,PROPS_ITEMS,[])}const PROPS_TYPE=["t","type"];function resolveType(e){return resolveProps(e,PROPS_TYPE)}const PROPS_VALUE=["v","value"];function resolveValue$1(e,t){const r=resolveProps(e,PROPS_VALUE);if(null!=r)return r;throw createUnhandleNodeError(t)}const PROPS_MODIFIER=["m","modifier"];function resolveLinkedModifier(e){return resolveProps(e,PROPS_MODIFIER)}const PROPS_KEY=["k","key"];function resolveLinkedKey(e){const t=resolveProps(e,PROPS_KEY);if(t)return t;throw createUnhandleNodeError(6)}function resolveProps(e,t,r){for(let a=0;a<t.length;a++){const r=t[a];if(hasOwn(e,r)&&null!=e[r])return e[r]}return r}const AST_NODE_PROPS_KEYS=[...PROPS_BODY,...PROPS_CASES,...PROPS_STATIC,...PROPS_ITEMS,...PROPS_KEY,...PROPS_MODIFIER,...PROPS_VALUE,...PROPS_TYPE];function createUnhandleNodeError(e){return new Error(`unhandled node type: ${e}`)}function format(e){return t=>formatParts(t,e)}function formatParts(e,t){const r=resolveBody(t);if(null==r)throw createUnhandleNodeError(0);if(1===resolveType(r)){const t=resolveCases(r);return e.plural(t.reduce(((t,r)=>[...t,formatMessageParts(e,r)]),[]))}return formatMessageParts(e,r)}function formatMessageParts(e,t){const r=resolveStatic(t);if(null!=r)return"text"===e.type?r:e.normalize([r]);{const r=resolveItems(t).reduce(((t,r)=>[...t,formatMessagePart(e,r)]),[]);return e.normalize(r)}}function formatMessagePart(e,t){const r=resolveType(t);switch(r){case 3:case 9:case 7:case 8:return resolveValue$1(t,r);case 4:{const a=t;if(hasOwn(a,"k")&&a.k)return e.interpolate(e.named(a.k));if(hasOwn(a,"key")&&a.key)return e.interpolate(e.named(a.key));throw createUnhandleNodeError(r)}case 5:{const a=t;if(hasOwn(a,"i")&&isNumber(a.i))return e.interpolate(e.list(a.i));if(hasOwn(a,"index")&&isNumber(a.index))return e.interpolate(e.list(a.index));throw createUnhandleNodeError(r)}case 6:{const r=t,a=resolveLinkedModifier(r),n=resolveLinkedKey(r);return e.linked(formatMessagePart(e,n),a?formatMessagePart(e,a):void 0,e.type)}default:throw new Error(`unhandled node on format message part: ${r}`)}}let compileCache=create();function clearCompileCache(){compileCache=create()}function compile(e,t){{if(!isMessageAST(e))return()=>e;const t=e.cacheKey;if(t){const r=compileCache[t];return r||(compileCache[t]=format(e))}return format(e)}}let devtools=null;function setDevToolsHook(e){devtools=e}function getDevToolsHook(){return devtools}function initI18nDevTools(e,t,r){devtools&&devtools.emit("i18n:init",{timestamp:Date.now(),i18n:e,version:t,meta:r})}const translateDevTools=createDevToolsHook("function:translate");function createDevToolsHook(e){return t=>devtools&&devtools.emit(e,t)}const CoreErrorCodes={INVALID_ARGUMENT:17,INVALID_DATE_ARGUMENT:18,INVALID_ISO_DATE_ARGUMENT:19,NOT_SUPPORT_NON_STRING_MESSAGE:20,NOT_SUPPORT_LOCALE_PROMISE_VALUE:21,NOT_SUPPORT_LOCALE_ASYNC_FUNCTION:22,NOT_SUPPORT_LOCALE_TYPE:23},CORE_ERROR_CODES_EXTEND_POINT=24;function createCoreError(e){return createCompileError(e,null,void 0)}function getLocale(e,t){return null!=t.locale?resolveLocale(t.locale):resolveLocale(e.locale)}let _resolveLocale;function resolveLocale(e){if(isString(e))return e;if(isFunction(e)){if(e.resolvedOnce&&null!=_resolveLocale)return _resolveLocale;if("Function"===e.constructor.name){const t=e();if(isPromise(t))throw Error(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE);return _resolveLocale=t}throw Error(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION)}throw Error(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE)}function fallbackWithSimple(e,t,r){return[...new Set([r,...isArray(t)?t:isObject(t)?Object.keys(t).filter((e=>"default"!==e)):isString(t)?[t]:[r]])]}function fallbackWithLocaleChain(e,t,r){const a=isString(r)?r:DEFAULT_LOCALE,n=e;let s;isObject(t)?(n.__localeChainObjectCache||(n.__localeChainObjectCache=new WeakMap),s=n.__localeChainObjectCache.get(t),s||(s=new Map,n.__localeChainObjectCache.set(t,s))):(n.__localeChainCache||(n.__localeChainCache=new Map),s=n.__localeChainCache.get(t),s||(s=new Map,n.__localeChainCache.set(t,s)));const o=s.get(a);if(o)return o;const i=[];let l=[r];for(;isArray(l);)l=appendBlockToChain(i,l,t);const c=isArray(t)||!isPlainObject(t)?t:t.default?t.default:null;return l=isString(c)?[c]:c,isArray(l)&&appendBlockToChain(i,l,!1),s.set(a,i),i}function appendBlockToChain(e,t,r){let a=!0;for(let n=0;n<t.length&&isBoolean(a);n++){const s=t[n];isString(s)&&(a=appendLocaleToChain(e,t[n],r))}return a}function appendLocaleToChain(e,t,r){let a;const n=t.split("-");do{a=appendItemToChain(e,n.join("-"),r),n.splice(-1,1)}while(n.length&&!0===a);return a}function appendItemToChain(e,t,r){let a=!1;if(!e.includes(t)&&(a=!0,t)){a="!"!==t[t.length-1];const n=t.replace(/!/g,"");e.push(n),(isArray(r)||isPlainObject(r))&&r[n]&&(a=r[n])}return a}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;const pathStateMachine=[];pathStateMachine[0]={w:[0],i:[3,0],"[":[4],o:[7]},pathStateMachine[1]={w:[1],".":[2],"[":[4],o:[7]},pathStateMachine[2]={w:[2],i:[3,0],0:[3,0]},pathStateMachine[3]={i:[3,0],0:[3,0],w:[1,1],".":[2,1],"[":[4,1],o:[7,1]},pathStateMachine[4]={"'":[5,0],'"':[6,0],"[":[4,2],"]":[1,3],o:8,l:[4,0]},pathStateMachine[5]={"'":[4,0],o:8,l:[5,0]},pathStateMachine[6]={'"':[4,0],o:8,l:[6,0]};const literalValueRE=/^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;function isLiteral(e){return literalValueRE.test(e)}function stripQuotes(e){const t=e.charCodeAt(0);return t!==e.charCodeAt(e.length-1)||34!==t&&39!==t?e:e.slice(1,-1)}function getPathCharType(e){if(null==e)return"o";switch(e.charCodeAt(0)){case 91:case 93:case 46:case 34:case 39:return e;case 95:case 36:case 45:return"i";case 9:case 10:case 13:case 160:case 65279:case 8232:case 8233:return"w"}return"i"}function formatSubPath(e){const t=e.trim();return("0"!==e.charAt(0)||!isNaN(parseInt(e)))&&(isLiteral(t)?stripQuotes(t):"*"+t)}function parse(e){const t=[];let r,a,n,s,o,i,l,c=-1,u=0,m=0;const _=[];function g(){const t=e[c+1];if(5===u&&"'"===t||6===u&&'"'===t)return c++,n="\\"+t,_[0](),!0}for(_[0]=()=>{void 0===a?a=n:a+=n},_[1]=()=>{void 0!==a&&(t.push(a),a=void 0)},_[2]=()=>{_[0](),m++},_[3]=()=>{if(m>0)m--,u=4,_[0]();else{if(m=0,void 0===a)return!1;if(a=formatSubPath(a),!1===a)return!1;_[1]()}};null!==u;)if(c++,r=e[c],"\\"!==r||!g()){if(s=getPathCharType(r),l=pathStateMachine[u],o=l[s]||l.l||8,8===o)return;if(u=o[0],void 0!==o[1]&&(i=_[o[1]],i&&(n=r,!1===i())))return;if(7===u)return t}}const cache=new Map;function resolveWithKeyValue(e,t){return isObject(e)?getOwn(e,t):null}function resolveValue(e,t){if(!isObject(e))return null;let r=cache.get(t);if(r||(r=parse(t),r&&cache.set(t,r)),!r)return null;const a=r.length;let n=e,s=0;for(;s<a;){const e=r[s];if(AST_NODE_PROPS_KEYS.includes(e)&&isMessageAST(n))return null;if(!isObject(n))return null;if(!hasOwn(n,e))return null;const t=n[e];if(void 0===t)return null;if(isFunction(n))return null;n=t,s++}return n}const CoreWarnCodes={NOT_FOUND_KEY:1,FALLBACK_TO_TRANSLATE:2,CANNOT_FORMAT_NUMBER:3,FALLBACK_TO_NUMBER_FORMAT:4,CANNOT_FORMAT_DATE:5,FALLBACK_TO_DATE_FORMAT:6,EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER:7,INVALID_NUMBER_ARGUMENT:8,INVALID_DATE_ARGUMENT:9},CORE_WARN_CODES_EXTEND_POINT=10,warnMessages={[CoreWarnCodes.NOT_FOUND_KEY]:"Not found '{key}' key in '{locale}' locale {resource}.",[CoreWarnCodes.FALLBACK_TO_TRANSLATE]:"Fall back to translate '{key}' key with '{target}' locale.",[CoreWarnCodes.CANNOT_FORMAT_NUMBER]:"Cannot format a number value due to not supported Intl.NumberFormat.",[CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT]:"Fall back to number format '{key}' key with '{target}' locale.",[CoreWarnCodes.CANNOT_FORMAT_DATE]:"Cannot format a date value due to not supported Intl.DateTimeFormat.",[CoreWarnCodes.FALLBACK_TO_DATE_FORMAT]:"Fall back to datetime format '{key}' key with '{target}' locale.",[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.",[CoreWarnCodes.INVALID_NUMBER_ARGUMENT]:"Invalid argument for number formatting: expected a number but received '{value}'.",[CoreWarnCodes.INVALID_DATE_ARGUMENT]:"Invalid argument for datetime formatting: expected a Date, number, or ISO string but received '{value}'."};function getWarnMessage(e,...t){return format$1(warnMessages[e],...t)}const VERSION="11.4.18",NOT_REOSLVED=-1,DEFAULT_LOCALE="en-US",MISSING_RESOLVE_VALUE="",capitalize=e=>`${e.charAt(0).toLocaleUpperCase()}${e.substr(1)}`;function getDefaultLinkedModifiers(){return{upper:(e,t)=>"text"===t&&isString(e)?e.toUpperCase():"vnode"===t&&isObject(e)&&"__v_isVNode"in e?e.children.toUpperCase():e,lower:(e,t)=>"text"===t&&isString(e)?e.toLowerCase():"vnode"===t&&isObject(e)&&"__v_isVNode"in e?e.children.toLowerCase():e,capitalize:(e,t)=>"text"===t&&isString(e)?capitalize(e):"vnode"===t&&isObject(e)&&"__v_isVNode"in e?capitalize(e.children):e}}let _compiler,_resolver,_fallbacker;function registerMessageCompiler(e){_compiler=e}function registerMessageResolver(e){_resolver=e}function registerLocaleFallbacker(e){_fallbacker=e}let _additionalMeta=null;const setAdditionalMeta=e=>{_additionalMeta=e},getAdditionalMeta=()=>_additionalMeta;let _fallbackContext=null;const setFallbackContext=e=>{_fallbackContext=e},getFallbackContext=()=>_fallbackContext;let _cid=0;function createCoreContext(e={}){const t=isFunction(e.onWarn)?e.onWarn:warn,r=isString(e.version)?e.version:VERSION,a=isString(e.locale)||isFunction(e.locale)?e.locale:DEFAULT_LOCALE,n=isFunction(a)?DEFAULT_LOCALE:a,s=isArray(e.fallbackLocale)||isPlainObject(e.fallbackLocale)||isString(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:n,o=isPlainObject(e.messages)?e.messages:createResources(n),i=isPlainObject(e.datetimeFormats)?e.datetimeFormats:createResources(n),l=isPlainObject(e.numberFormats)?e.numberFormats:createResources(n),c=assign(create(),e.modifiers,getDefaultLinkedModifiers()),u=e.pluralRules||create(),m=isFunction(e.missing)?e.missing:null,_=!isBoolean(e.missingWarn)&&!isRegExp(e.missingWarn)||e.missingWarn,g=!isBoolean(e.fallbackWarn)&&!isRegExp(e.fallbackWarn)||e.fallbackWarn,f=!!e.fallbackFormat,E=!!e.unresolving,p=isFunction(e.postTranslation)?e.postTranslation:null,O=isPlainObject(e.processor)?e.processor:null,d=!isBoolean(e.warnHtmlMessage)||e.warnHtmlMessage,C=!!e.escapeParameter,T=isFunction(e.messageCompiler)?e.messageCompiler:_compiler,S=isFunction(e.messageResolver)?e.messageResolver:_resolver||resolveWithKeyValue,A=isFunction(e.localeFallbacker)?e.localeFallbacker:_fallbacker||fallbackWithSimple,h=isObject(e.fallbackContext)?e.fallbackContext:void 0,P=e,b=isObject(P.__datetimeFormatters)?P.__datetimeFormatters:new Map,N=isObject(P.__numberFormatters)?P.__numberFormatters:new Map,M=isObject(P.__meta)?P.__meta:{};_cid++;const L={version:r,cid:_cid,locale:a,fallbackLocale:s,messages:o,modifiers:c,pluralRules:u,missing:m,missingWarn:_,fallbackWarn:g,fallbackFormat:f,unresolving:E,postTranslation:p,processor:O,warnHtmlMessage:d,escapeParameter:C,messageCompiler:T,messageResolver:S,localeFallbacker:A,fallbackContext:h,onWarn:t,__meta:M};return L.datetimeFormats=i,L.numberFormats=l,L.__datetimeFormatters=b,L.__numberFormatters=N,L}const createResources=e=>({[e]:create()});function isTranslateFallbackWarn(e,t){return e instanceof RegExp?e.test(t):e}function isTranslateMissingWarn(e,t){return e instanceof RegExp?e.test(t):e}function handleMissing(e,t,r,a,n){const{missing:s,onWarn:o}=e;if(null!==s){const a=s(e,r,t,n);return isString(a)?a:t}return t}function invalidateLocaleChainCache(e,t){const r=e;isObject(t)?r.__localeChainObjectCache?.delete(t):r.__localeChainCache?.delete(t)}function updateFallbackLocale(e,t,r){invalidateLocaleChainCache(e,r),e.fallbackContext&&invalidateLocaleChainCache(e.fallbackContext,r),e.localeFallbacker(e,r,t)}function isAlmostSameLocale(e,t){return e!==t&&e.split("-")[0]===t.split("-")[0]}function isImplicitFallback(e,t){const r=t.indexOf(e);if(-1===r)return!1;for(let a=r+1;a<t.length;a++)if(isAlmostSameLocale(e,t[a]))return!0;return!1}function resolveFormatLocale(e,t,r,a,n,s,o){const{fallbackLocale:i,localeFallbacker:l,onWarn:c}=e,u=l(e,i,r);for(let m=0;m<u.length;m++){const r=u[m],s=getOwn(getOwn(a,r)||{},t);if(isPlainObject(s)&&isString(r))return r;handleMissing(e,t,r,n,o)}return null}function getFormatterCacheKey(e,t,r){let a=`${e}__${t}`;return isPlainObject(r)&&!isEmptyObject(r)&&(a=`${a}__${JSON.stringify(r)}`),a}function clearFormatCache(e,t,r){for(const a in r){const r=`${t}__${a}`;for(const t of e.keys())(t===r||t.startsWith(`${r}__`))&&e.delete(t)}}function parseFormatArgs(e,t,r,a){const[,n,s,o]=e;let i=r;return isString(n)?t.key=n:isPlainObject(n)&&Object.keys(n).forEach((e=>{a.includes(e)?i[e]=n[e]:t[e]=n[e]})),isString(s)?t.locale=s:isPlainObject(s)&&(i=s),isPlainObject(o)&&(i=o),i}function datetime(e,...t){const{datetimeFormats:r,unresolving:a,onWarn:n}=e,{__datetimeFormatters:s}=e;if(!isString(t[0])&&!isDate(t[0])&&!isNumber(t[0]))return"";const[o,i,l,c]=parseDateTimeArgs(...t),u=isBoolean(l.missingWarn)?l.missingWarn:e.missingWarn,m=isBoolean(l.fallbackWarn)?l.fallbackWarn:e.fallbackWarn,_=!!l.part,g=getLocale(e,l);if(!isString(o)||""===o){const e=new Intl.DateTimeFormat(g.replace(/!/g,""),c);return _?e.formatToParts(i):e.format(i)}const f=resolveFormatLocale(e,o,g,r,u,m,"datetime format");if(!isString(f))return a?-1:o;const E=r[f][o],p=getFormatterCacheKey(f,o,c);let O=s.get(p);return O||(O=new Intl.DateTimeFormat(f,assign({},E,c)),s.set(p,O)),_?O.formatToParts(i):O.format(i)}const DATETIME_FORMAT_OPTIONS_KEYS=["localeMatcher","weekday","era","year","month","day","hour","minute","second","timeZoneName","formatMatcher","hour12","timeZone","dateStyle","timeStyle","calendar","dayPeriod","numberingSystem","hourCycle","fractionalSecondDigits"];function parseDateTimeArgs(...e){const[t]=e,r=create(),a=create();let n;if(isString(t)){const e=t.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/);if(!e)throw Error(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT);const r=e[3]?e[3].trim().startsWith("T")?`${e[1].trim()}${e[3].trim()}`:`${e[1].trim()}T${e[3].trim()}`:e[1].trim();n=new Date(r);try{n.toISOString()}catch{throw Error(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT)}}else if(isDate(t)){if(isNaN(t.getTime()))throw Error(CoreErrorCodes.INVALID_DATE_ARGUMENT);n=t}else{if(!isNumber(t))throw Error(CoreErrorCodes.INVALID_ARGUMENT);n=t}const s=parseFormatArgs(e,r,a,DATETIME_FORMAT_OPTIONS_KEYS);return[r.key||"",n,r,s]}function clearDateTimeFormat(e,t,r){clearFormatCache(e.__datetimeFormatters,t,r)}function number(e,...t){const{numberFormats:r,unresolving:a,onWarn:n}=e,{__numberFormatters:s}=e;if(!isNumber(t[0]))return"";const[o,i,l,c]=parseNumberArgs(...t),u=isBoolean(l.missingWarn)?l.missingWarn:e.missingWarn,m=isBoolean(l.fallbackWarn)?l.fallbackWarn:e.fallbackWarn,_=!!l.part,g=getLocale(e,l);if(!isString(o)||""===o){const e=new Intl.NumberFormat(g.replace(/!/g,""),c);return _?e.formatToParts(i):e.format(i)}const f=resolveFormatLocale(e,o,g,r,u,m,"number format");if(!isString(f))return a?-1:o;const E=r[f][o],p=getFormatterCacheKey(f,o,c);let O=s.get(p);return O||(O=new Intl.NumberFormat(f,assign({},E,c)),s.set(p,O)),_?O.formatToParts(i):O.format(i)}const NUMBER_FORMAT_OPTIONS_KEYS=["localeMatcher","style","currency","currencyDisplay","currencySign","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits","compactDisplay","notation","signDisplay","unit","unitDisplay","roundingMode","roundingPriority","roundingIncrement","trailingZeroDisplay"];function parseNumberArgs(...e){const[t]=e,r=create(),a=create();if(!isNumber(t))throw Error(CoreErrorCodes.INVALID_ARGUMENT);const n=t,s=parseFormatArgs(e,r,a,NUMBER_FORMAT_OPTIONS_KEYS);return[r.key||"",n,r,s]}function clearNumberFormat(e,t,r){clearFormatCache(e.__numberFormatters,t,r)}const DEFAULT_MODIFIER=e=>e,DEFAULT_MESSAGE=e=>"",DEFAULT_MESSAGE_DATA_TYPE="text",DEFAULT_NORMALIZE=e=>0===e.length?"":join(e),DEFAULT_INTERPOLATE=toDisplayString;function pluralDefault(e,t){return e=Math.abs(e),2===t?1===e?0:1:Math.min(e,2)}function getPluralIndex(e){const t=isNumber(e.pluralIndex)?e.pluralIndex:-1;return isNumber(e.named?.count)?e.named.count:isNumber(e.named?.n)?e.named.n:t}function createMessageContext(e={}){const t=e.locale,r=getPluralIndex(e),a=isString(t)&&e.pluralRules&&isFunction(getOwn(e.pluralRules,t))?e.pluralRules[t]:pluralDefault,n=a===pluralDefault?void 0:pluralDefault,s=e.list||[],o=e.named||create(),i=isNumber(e.pluralIndex),l=t=>{const r=isObjectPrototypeKey(t)?getOwn(o,t):o[t];return!i||r||"count"!==t&&"n"!==t?r:e.pluralIndex};function c(t,r){const a=isFunction(e.messages)?e.messages(t,!!r):!!isObject(e.messages)&&e.messages[t];return a||(e.parent?e.parent.message(t):DEFAULT_MESSAGE)}const u=isFunction(e.processor?.normalize)?e.processor.normalize:DEFAULT_NORMALIZE,m=isFunction(e.processor?.interpolate)?e.processor.interpolate:DEFAULT_INTERPOLATE,_={list:e=>s[e],named:l,plural:e=>e[a(r,e.length,n)],linked:(t,...r)=>{const[a,n]=r;let s="text",o="";1===r.length?isObject(a)?(o=a.modifier||o,s=a.type||s):isString(a)&&(o=a||o):2===r.length&&(isString(a)&&(o=a||o),isString(n)&&(s=n||s));const i=c(t,!0)(_),l=""===i||void 0===i?t:i,u="vnode"===s&&isArray(l)&&o?l[0]:l;if(!o)return u;const m=(g=o,e.modifiers?getOwn(e.modifiers,g):DEFAULT_MODIFIER);var g;return isFunction(m)?m(u,s):u},message:c,type:isString(e.processor?.type)?e.processor.type:DEFAULT_MESSAGE_DATA_TYPE,interpolate:m,normalize:u,values:assign(create(),s,o,i?{count:l("count"),n:l("n")}:{})};return _}const NOOP_MESSAGE_FUNCTION=()=>"",isMessageFunction=e=>isFunction(e),isMessageFormat=e=>isString(e)||isMessageAST(e)||isMessageFunction(e);function translate(e,...t){const{fallbackFormat:r,postTranslation:a,unresolving:n,messageCompiler:s,fallbackLocale:o,messages:i}=e,[l,c]=parseTranslateArgs(...t),u=isBoolean(c.missingWarn)?c.missingWarn:e.missingWarn,m=isBoolean(c.fallbackWarn)?c.fallbackWarn:e.fallbackWarn,_=isBoolean(c.escapeParameter)?c.escapeParameter:e.escapeParameter,g=!!c.resolvedMessage,f=isString(c.default)||isBoolean(c.default)?isBoolean(c.default)?s?l:()=>l:c.default:r?s?l:()=>l:null,E=r||null!=f&&(isString(f)||isFunction(f)),p=getLocale(e,c);_&&escapeParams(c);let[O,d,C]=g?[l,p,getOwn(i,p)||create()]:resolveMessageFormat(e,l,p,o,m,u),T=O,S=l;if(g||isMessageFormat(T)||E&&(T=f,S=T),!(g||isMessageFormat(T)&&isString(d)))return n?-1:l;let A=!1;const h=isMessageFunction(T)?T:compileMessageFormat(e,l,d,T,S,(()=>{A=!0}));if(A)return T;const P=evaluateMessage(e,h,createMessageContext(getMessageContextOptions(e,d,C,c)));let b=a?a(P,l):P;return _&&isString(b)&&(b=sanitizeTranslatedHtml(b)),b}function escapeParams(e){if(isArray(e.list)&&(e.list=e.list.map((e=>isString(e)?escapeHtml(e):e))),isObject(e.named)){const t=e.named,r=create();for(const e of Object.keys(t)){const a=t[e];r[e]=isString(a)?escapeHtml(a):a}e.named=r}}function resolveMessageFormat(e,t,r,a,n,s){const{messages:o,onWarn:i,messageResolver:l,localeFallbacker:c}=e,u=c(e,a,r);let m,_=create(),g=null;for(let f=0;f<u.length&&(m=u[f],_=getOwn(o,m)||create(),null===(g=l(_,t))&&(g=getOwn(_,t)),!isMessageFormat(g));f++)if(!isImplicitFallback(m,u)){const r=handleMissing(e,t,m,s,"translate");r!==t&&(g=r)}return[g,m,_]}function compileMessageFormat(e,t,r,a,n,s){const{messageCompiler:o,warnHtmlMessage:i}=e;if(isMessageFunction(a)){const e=a;return e.locale=e.locale||r,e.key=e.key||t,e}if(null==o){const e=()=>a;return e.locale=r,e.key=t,e}const l=o(a,getCompileContext(e,r,n,a,i,s));return l.locale=r,l.key=t,l.source=a,l}function evaluateMessage(e,t,r){return t(r)}function parseTranslateArgs(...e){const[t,r,a]=e,n=create();if(!(isString(t)||isNumber(t)||isMessageFunction(t)||isMessageAST(t)))throw Error(CoreErrorCodes.INVALID_ARGUMENT);const s=isNumber(t)?String(t):(isMessageFunction(t),t);return isNumber(r)?n.plural=r:isString(r)?n.default=r:isPlainObject(r)&&!isEmptyObject(r)?n.named=r:isArray(r)&&(n.list=r),isNumber(a)?n.plural=a:isString(a)?n.default=a:isPlainObject(a)&&assign(n,a),[s,n]}function getCompileContext(e,t,r,a,n,s){return{locale:t,key:r,warnHtmlMessage:n,onError:e=>{throw s&&s(e),e},onCacheKey:e=>generateFormatCacheKey(t,r,e)}}function getMessageContextOptions(e,t,r,a){const{modifiers:n,pluralRules:s,messageResolver:o,fallbackLocale:i,fallbackWarn:l,missingWarn:c,fallbackContext:u}=e,m={locale:t,modifiers:n,pluralRules:s,messages:(a,n)=>{let s=o(r,a);if(null==s&&(u||n)){const[r,,n]=resolveMessageFormat(u||e,a,t,i,l,c);s=r??o(n,a)}if(isString(s)||isMessageAST(s)){let r=!1;const n=compileMessageFormat(e,a,t,s,a,(()=>{r=!0}));return r?NOOP_MESSAGE_FUNCTION:n}return isMessageFunction(s)?s:NOOP_MESSAGE_FUNCTION}};return e.processor&&(m.processor=e.processor),a.list&&(m.list=a.list),a.named&&(m.named=a.named),isNumber(a.plural)&&(m.pluralIndex=a.plural),m}registerMessageCompiler(compile),registerMessageResolver(resolveValue),registerLocaleFallbacker(fallbackWithLocaleChain);export{AST_NODE_PROPS_KEYS,CORE_ERROR_CODES_EXTEND_POINT,CORE_WARN_CODES_EXTEND_POINT,CompileErrorCodes,CoreErrorCodes,CoreWarnCodes,DATETIME_FORMAT_OPTIONS_KEYS,DEFAULT_LOCALE,DEFAULT_MESSAGE_DATA_TYPE,MISSING_RESOLVE_VALUE,NOT_REOSLVED,NUMBER_FORMAT_OPTIONS_KEYS,VERSION,clearCompileCache,clearDateTimeFormat,clearNumberFormat,compile,createCompileError,createCoreContext,createCoreError,createMessageContext,datetime,fallbackWithLocaleChain,fallbackWithSimple,getAdditionalMeta,getDevToolsHook,getFallbackContext,getLocale,getWarnMessage,handleMissing,initI18nDevTools,isAlmostSameLocale,isImplicitFallback,isMessageAST,isMessageFormat,isMessageFunction,isTranslateFallbackWarn,isTranslateMissingWarn,number,parse,parseDateTimeArgs,parseNumberArgs,parseTranslateArgs,registerLocaleFallbacker,registerMessageCompiler,registerMessageResolver,resolveLocale,resolveValue,resolveWithKeyValue,setAdditionalMeta,setDevToolsHook,setFallbackContext,translate,translateDevTools,updateFallbackLocale};
6
+ const RE_ARGS=/\{([0-9a-zA-Z]+)\}/g;function format$1(e,...t){return 1===t.length&&isObject(t[0])&&(t=t[0]),t&&t.hasOwnProperty||(t={}),e.replace(RE_ARGS,((e,r)=>t.hasOwnProperty(r)?t[r]:""))}const generateFormatCacheKey=(e,t,r)=>friendlyJSONstringify({l:e,k:t,s:r}),friendlyJSONstringify=e=>JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029").replace(/\u0027/g,"\\u0027"),isNumber=e=>"number"==typeof e&&isFinite(e),isDate=e=>"[object Date]"===toTypeString(e),isRegExp=e=>"[object RegExp]"===toTypeString(e),isEmptyObject=e=>isPlainObject(e)&&0===Object.keys(e).length,assign=Object.assign,_create=Object.create,create=(e=null)=>_create(e),hasOwnProperty=Object.prototype.hasOwnProperty;function hasOwn(e,t){return hasOwnProperty.call(e,t)}function getOwn(e,t){const r=e[t];return hasOwn(e,t)?r:void 0}function isObjectPrototypeKey(e){return hasOwn(Object.prototype,e)}const isArray=Array.isArray,isFunction=e=>"function"==typeof e,isString=e=>"string"==typeof e,isBoolean=e=>"boolean"==typeof e,isObject=e=>null!==e&&"object"==typeof e,isPromise=e=>isObject(e)&&isFunction(e.then)&&isFunction(e.catch),objectToString=Object.prototype.toString,toTypeString=e=>objectToString.call(e),isPlainObject=e=>"[object Object]"===toTypeString(e),toDisplayString=e=>null==e?"":isArray(e)||isPlainObject(e)&&e.toString===objectToString?JSON.stringify(e,null,2):String(e);function join(e,t=""){return e.reduce(((e,r,n)=>0===n?e+r:e+t+r),"")}function warn(e,t){"undefined"!=typeof console&&(console.warn("[intlify] "+e),t&&console.warn(t.stack))}function escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/\//g,"&#x2F;").replace(/=/g,"&#x3D;")}function escapeAttributeValue(e){return e.replace(/&(?![a-z0-9#]{2,6};)/gi,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const javascriptSchemePattern=/^javascript:/i,urlAttributePattern=/^(?:href|xlink:href|src|action|formaction)$/i,numericCharacterReferencePattern=/&#(?:x([0-9a-f]+)|(\d+));?/gi,namedWhitespaceCharacterReferencePattern=/&(?:Tab|NewLine);/g,colonCharacterReferencePattern=/&colon;?/gi,controlOrWhitespacePattern=/[\u0000-\u0020\u007f-\u009f]/g,eventHandlerPattern=/^on\w/i,srcdocPattern=/^srcdoc$/i,dangerousElementPattern=/^(?:base|animate|set|script|plaintext)$/i,textContentElementPattern=/^(?:iframe|noembed|noframes|noscript|style|textarea|title|xmp)$/i,tagStartPattern=/<(\/?)([a-z][^\t\n\f\r />]*)/iy,tagStepPattern=/([\t\n\f\r /]*)(?:(>)|([^\t\n\f\r />][^\t\n\f\r />=]*)(?:[\t\n\f\r ]*=[\t\n\f\r ]*(?:(["'])([\s\S]*?)(\4|$)|([^\t\n\f\r >]*)))?)/y,commentPattern=/<!--(?:>|->|[\s\S]*?--!?>)/y;function decodeNumericCharacterReference(e,t,r){const n=t||r;if(!n)return e;const a=Number.parseInt(n,t?16:10);return a<=127?String.fromCharCode(a):e}function hasJavascriptScheme(e){const t=e.replace(numericCharacterReferencePattern,decodeNumericCharacterReference).replace(namedWhitespaceCharacterReferencePattern,"").replace(colonCharacterReferencePattern,":").replace(controlOrWhitespacePattern,"");return javascriptSchemePattern.test(t)}function sanitizeStyleValue(e){const t=/url\s*\(/gi;let r,n="",a=0;for(;null!==(r=t.exec(e));){const s=r.index,o=t.lastIndex-1;let i=o+1,l=1,c=null;for(;i<e.length;i++){const t=e[i];if(c)t===c&&(c=null);else if('"'===t||"'"===t)c=t;else if("("===t)l++;else if(")"===t&&(l--,0===l))break}if(0!==l)break;const u=e.slice(o+1,i).trim(),m=u.startsWith('"')&&u.endsWith('"')||u.startsWith("'")&&u.endsWith("'")?u.slice(1,-1).trim():u;n+=e.slice(a,s),n+=hasJavascriptScheme(m)?"url(about:blank)":e.slice(s,i+1),a=i+1}return n+e.slice(a)}function sanitizeAttributeValue(e,t){if(urlAttributePattern.test(e)&&hasJavascriptScheme(t))return"about:blank";return escapeAttributeValue("style"===e.toLowerCase()?sanitizeStyleValue(t):t)}function escapeLessThan(e){return e.replace(/</g,"&lt;")}function serializeAttribute(e,t,r,n){let a=e;if(eventHandlerPattern.test(e)?(n.eventHandler=!0,a=`&#111;n${e.slice(2)}`):srcdocPattern.test(e)&&(n.srcdoc=!0,a=`&#115;${e.slice(1)}`),void 0===t)return a;const s=r||"";return`${a}=${s}${sanitizeAttributeValue(e,t)}${s}`}function readTag(e,t,r){tagStartPattern.lastIndex=t;const n=tagStartPattern.exec(e);if(!n)return;const[,a,s]=n;let o,i=n[0];for(tagStepPattern.lastIndex=tagStartPattern.lastIndex;o=tagStepPattern.exec(e);){const[n,l,c,u,m,f,_,g]=o;if(c){const r=tagStepPattern.lastIndex;return[a?e.slice(t,r):i+n,s,r]}if(m&&!_)break;if(!a){i+=l+serializeAttribute(u,m?f:g,m,r)}}return[i,s,-1]}function findTextContentEnd(e,t,r){for(let n=e.indexOf("</",t);-1!==n;n=e.indexOf("</",n+2)){const t=readTag(e,n,{});if(t&&t[1].toLowerCase()===r.toLowerCase())return-1===t[2]?-1:n}return-1}function sanitizeTranslatedHtml(e){const t={};let r,n="",a=0;for(;-1!==(r=e.indexOf("<",a));){n+=e.slice(a,r),a=r+1;const s=readTag(e,r,t);if(s){const[o,i,l]=s;if(-1===l){t.unclosed=!0,n+=escapeLessThan(e.slice(r)),a=e.length;break}if(a=l,"/"===o[1])n+=o;else if(dangerousElementPattern.test(i))t.element=!0,n+=escapeLessThan(o);else if(textContentElementPattern.test(i)){const r=findTextContentEnd(e,l,i);-1===r?(t.unclosed=!0,n+=escapeLessThan(o)):(n+=o+escapeLessThan(e.slice(l,r)),a=r)}else n+=o}else commentPattern.lastIndex=r,commentPattern.test(e)?(n+=e.slice(r,commentPattern.lastIndex),a=commentPattern.lastIndex):(e.startsWith("\x3c!--",r)&&(t.unclosed=!0),n+="&lt;")}return n+=e.slice(a),n}const CompileErrorCodes={EXPECTED_TOKEN:1,INVALID_TOKEN_IN_PLACEHOLDER:2,UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER:3,UNKNOWN_ESCAPE_SEQUENCE:4,INVALID_UNICODE_ESCAPE_SEQUENCE:5,UNBALANCED_CLOSING_BRACE:6,UNTERMINATED_CLOSING_BRACE:7,EMPTY_PLACEHOLDER:8,NOT_ALLOW_NEST_PLACEHOLDER:9,INVALID_LINKED_FORMAT:10,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,UNHANDLED_CODEGEN_NODE_TYPE:15,UNHANDLED_MINIFIER_NODE_TYPE:16},COMPILE_ERROR_CODES_EXTEND_POINT=17;function createCompileError(e,t,r={}){const{domain:n,messages:a,args:s}=r,o=new SyntaxError(String(e));return o.code=e,t&&(o.location=t),o.domain=n,o}function isMessageAST(e){return isObject(e)&&0===resolveType(e)&&(hasOwn(e,"b")||hasOwn(e,"body"))}const PROPS_BODY=["b","body"];function resolveBody(e){return resolveProps(e,PROPS_BODY)}const PROPS_CASES=["c","cases"];function resolveCases(e){return resolveProps(e,PROPS_CASES,[])}const PROPS_STATIC=["s","static"];function resolveStatic(e){return resolveProps(e,PROPS_STATIC)}const PROPS_ITEMS=["i","items"];function resolveItems(e){return resolveProps(e,PROPS_ITEMS,[])}const PROPS_TYPE=["t","type"];function resolveType(e){return resolveProps(e,PROPS_TYPE)}const PROPS_VALUE=["v","value"];function resolveValue$1(e,t){const r=resolveProps(e,PROPS_VALUE);if(null!=r)return r;throw createUnhandleNodeError(t)}const PROPS_MODIFIER=["m","modifier"];function resolveLinkedModifier(e){return resolveProps(e,PROPS_MODIFIER)}const PROPS_KEY=["k","key"];function resolveLinkedKey(e){const t=resolveProps(e,PROPS_KEY);if(t)return t;throw createUnhandleNodeError(6)}function resolveProps(e,t,r){for(let n=0;n<t.length;n++){const r=t[n];if(hasOwn(e,r)&&null!=e[r])return e[r]}return r}const AST_NODE_PROPS_KEYS=[...PROPS_BODY,...PROPS_CASES,...PROPS_STATIC,...PROPS_ITEMS,...PROPS_KEY,...PROPS_MODIFIER,...PROPS_VALUE,...PROPS_TYPE];function createUnhandleNodeError(e){return new Error(`unhandled node type: ${e}`)}function format(e){return t=>formatParts(t,e)}function formatParts(e,t){const r=resolveBody(t);if(null==r)throw createUnhandleNodeError(0);if(1===resolveType(r)){const t=resolveCases(r);return e.plural(t.reduce(((t,r)=>[...t,formatMessageParts(e,r)]),[]))}return formatMessageParts(e,r)}function formatMessageParts(e,t){const r=resolveStatic(t);if(null!=r)return"text"===e.type?r:e.normalize([r]);{const r=resolveItems(t).reduce(((t,r)=>[...t,formatMessagePart(e,r)]),[]);return e.normalize(r)}}function formatMessagePart(e,t){const r=resolveType(t);switch(r){case 3:case 9:case 7:case 8:return resolveValue$1(t,r);case 4:{const n=t;if(hasOwn(n,"k")&&n.k)return e.interpolate(e.named(n.k));if(hasOwn(n,"key")&&n.key)return e.interpolate(e.named(n.key));throw createUnhandleNodeError(r)}case 5:{const n=t;if(hasOwn(n,"i")&&isNumber(n.i))return e.interpolate(e.list(n.i));if(hasOwn(n,"index")&&isNumber(n.index))return e.interpolate(e.list(n.index));throw createUnhandleNodeError(r)}case 6:{const r=t,n=resolveLinkedModifier(r),a=resolveLinkedKey(r);return e.linked(formatMessagePart(e,a),n?formatMessagePart(e,n):void 0,e.type)}default:throw new Error(`unhandled node on format message part: ${r}`)}}let compileCache=create();function clearCompileCache(){compileCache=create()}function compile(e,t){{if(!isMessageAST(e))return()=>e;const t=e.cacheKey;if(t){const r=compileCache[t];return r||(compileCache[t]=format(e))}return format(e)}}let devtools=null;function setDevToolsHook(e){devtools=e}function getDevToolsHook(){return devtools}function initI18nDevTools(e,t,r){devtools&&devtools.emit("i18n:init",{timestamp:Date.now(),i18n:e,version:t,meta:r})}const translateDevTools=createDevToolsHook("function:translate");function createDevToolsHook(e){return t=>devtools&&devtools.emit(e,t)}const CoreErrorCodes={INVALID_ARGUMENT:17,INVALID_DATE_ARGUMENT:18,INVALID_ISO_DATE_ARGUMENT:19,NOT_SUPPORT_NON_STRING_MESSAGE:20,NOT_SUPPORT_LOCALE_PROMISE_VALUE:21,NOT_SUPPORT_LOCALE_ASYNC_FUNCTION:22,NOT_SUPPORT_LOCALE_TYPE:23},CORE_ERROR_CODES_EXTEND_POINT=24;function createCoreError(e){return createCompileError(e,null,void 0)}function getLocale(e,t){return null!=t.locale?resolveLocale(t.locale):resolveLocale(e.locale)}let _resolveLocale;function resolveLocale(e){if(isString(e))return e;if(isFunction(e)){if(e.resolvedOnce&&null!=_resolveLocale)return _resolveLocale;if("Function"===e.constructor.name){const t=e();if(isPromise(t))throw Error(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE);return _resolveLocale=t}throw Error(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION)}throw Error(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE)}function fallbackWithSimple(e,t,r){return[...new Set([r,...isArray(t)?t:isObject(t)?Object.keys(t).filter((e=>"default"!==e)):isString(t)?[t]:[r]])]}function fallbackWithLocaleChain(e,t,r){const n=isString(r)?r:DEFAULT_LOCALE,a=e;let s;isObject(t)?(a.__localeChainObjectCache||(a.__localeChainObjectCache=new WeakMap),s=a.__localeChainObjectCache.get(t),s||(s=new Map,a.__localeChainObjectCache.set(t,s))):(a.__localeChainCache||(a.__localeChainCache=new Map),s=a.__localeChainCache.get(t),s||(s=new Map,a.__localeChainCache.set(t,s)));const o=s.get(n);if(o)return o;const i=[];let l=[r];for(;isArray(l);)l=appendBlockToChain(i,l,t);const c=isArray(t)||!isPlainObject(t)?t:t.default?t.default:null;return l=isString(c)?[c]:c,isArray(l)&&appendBlockToChain(i,l,!1),s.set(n,i),i}function appendBlockToChain(e,t,r){let n=!0;for(let a=0;a<t.length&&isBoolean(n);a++){const s=t[a];isString(s)&&(n=appendLocaleToChain(e,t[a],r))}return n}function appendLocaleToChain(e,t,r){let n;const a=t.split("-");do{n=appendItemToChain(e,a.join("-"),r),a.splice(-1,1)}while(a.length&&!0===n);return n}function appendItemToChain(e,t,r){let n=!1;if(!e.includes(t)&&(n=!0,t)){n="!"!==t[t.length-1];const a=t.replace(/!/g,"");e.push(a),(isArray(r)||isPlainObject(r))&&r[a]&&(n=r[a])}return n}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;const pathStateMachine=[];pathStateMachine[0]={w:[0],i:[3,0],"[":[4],o:[7]},pathStateMachine[1]={w:[1],".":[2],"[":[4],o:[7]},pathStateMachine[2]={w:[2],i:[3,0],0:[3,0]},pathStateMachine[3]={i:[3,0],0:[3,0],w:[1,1],".":[2,1],"[":[4,1],o:[7,1]},pathStateMachine[4]={"'":[5,0],'"':[6,0],"[":[4,2],"]":[1,3],o:8,l:[4,0]},pathStateMachine[5]={"'":[4,0],o:8,l:[5,0]},pathStateMachine[6]={'"':[4,0],o:8,l:[6,0]};const literalValueRE=/^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;function isLiteral(e){return literalValueRE.test(e)}function stripQuotes(e){const t=e.charCodeAt(0);return t!==e.charCodeAt(e.length-1)||34!==t&&39!==t?e:e.slice(1,-1)}function getPathCharType(e){if(null==e)return"o";switch(e.charCodeAt(0)){case 91:case 93:case 46:case 34:case 39:return e;case 95:case 36:case 45:return"i";case 9:case 10:case 13:case 160:case 65279:case 8232:case 8233:return"w"}return"i"}function formatSubPath(e){const t=e.trim();return("0"!==e.charAt(0)||!isNaN(parseInt(e)))&&(isLiteral(t)?stripQuotes(t):"*"+t)}function parse(e){const t=[];let r,n,a,s,o,i,l,c=-1,u=0,m=0;const f=[];function _(){const t=e[c+1];if(5===u&&"'"===t||6===u&&'"'===t)return c++,a="\\"+t,f[0](),!0}for(f[0]=()=>{void 0===n?n=a:n+=a},f[1]=()=>{void 0!==n&&(t.push(n),n=void 0)},f[2]=()=>{f[0](),m++},f[3]=()=>{if(m>0)m--,u=4,f[0]();else{if(m=0,void 0===n)return!1;if(n=formatSubPath(n),!1===n)return!1;f[1]()}};null!==u;)if(c++,r=e[c],"\\"!==r||!_()){if(s=getPathCharType(r),l=pathStateMachine[u],o=l[s]||l.l||8,8===o)return;if(u=o[0],void 0!==o[1]&&(i=f[o[1]],i&&(a=r,!1===i())))return;if(7===u)return t}}const cache=new Map;function resolveWithKeyValue(e,t){return isObject(e)?getOwn(e,t):null}function resolveValue(e,t){if(!isObject(e))return null;let r=cache.get(t);if(r||(r=parse(t),r&&cache.set(t,r)),!r)return null;const n=r.length;let a=e,s=0;for(;s<n;){const e=r[s];if(AST_NODE_PROPS_KEYS.includes(e)&&isMessageAST(a))return null;if(!isObject(a))return null;if(!hasOwn(a,e))return null;const t=a[e];if(void 0===t)return null;if(isFunction(a))return null;a=t,s++}return a}const CoreWarnCodes={NOT_FOUND_KEY:1,FALLBACK_TO_TRANSLATE:2,CANNOT_FORMAT_NUMBER:3,FALLBACK_TO_NUMBER_FORMAT:4,CANNOT_FORMAT_DATE:5,FALLBACK_TO_DATE_FORMAT:6,EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER:7,INVALID_NUMBER_ARGUMENT:8,INVALID_DATE_ARGUMENT:9},CORE_WARN_CODES_EXTEND_POINT=10,warnMessages={[CoreWarnCodes.NOT_FOUND_KEY]:"Not found '{key}' key in '{locale}' locale {resource}.",[CoreWarnCodes.FALLBACK_TO_TRANSLATE]:"Fall back to translate '{key}' key with '{target}' locale.",[CoreWarnCodes.CANNOT_FORMAT_NUMBER]:"Cannot format a number value due to not supported Intl.NumberFormat.",[CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT]:"Fall back to number format '{key}' key with '{target}' locale.",[CoreWarnCodes.CANNOT_FORMAT_DATE]:"Cannot format a date value due to not supported Intl.DateTimeFormat.",[CoreWarnCodes.FALLBACK_TO_DATE_FORMAT]:"Fall back to datetime format '{key}' key with '{target}' locale.",[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.",[CoreWarnCodes.INVALID_NUMBER_ARGUMENT]:"Invalid argument for number formatting: expected a number but received '{value}'.",[CoreWarnCodes.INVALID_DATE_ARGUMENT]:"Invalid argument for datetime formatting: expected a Date, number, or ISO string but received '{value}'."};function getWarnMessage(e,...t){return format$1(warnMessages[e],...t)}const VERSION="11.4.19",NOT_REOSLVED=-1,DEFAULT_LOCALE="en-US",MISSING_RESOLVE_VALUE="",capitalize=e=>`${e.charAt(0).toLocaleUpperCase()}${e.substr(1)}`;function getDefaultLinkedModifiers(){return{upper:(e,t)=>"text"===t&&isString(e)?e.toUpperCase():"vnode"===t&&isObject(e)&&"__v_isVNode"in e?e.children.toUpperCase():e,lower:(e,t)=>"text"===t&&isString(e)?e.toLowerCase():"vnode"===t&&isObject(e)&&"__v_isVNode"in e?e.children.toLowerCase():e,capitalize:(e,t)=>"text"===t&&isString(e)?capitalize(e):"vnode"===t&&isObject(e)&&"__v_isVNode"in e?capitalize(e.children):e}}let _compiler,_resolver,_fallbacker;function registerMessageCompiler(e){_compiler=e}function registerMessageResolver(e){_resolver=e}function registerLocaleFallbacker(e){_fallbacker=e}let _additionalMeta=null;const setAdditionalMeta=e=>{_additionalMeta=e},getAdditionalMeta=()=>_additionalMeta;let _fallbackContext=null;const setFallbackContext=e=>{_fallbackContext=e},getFallbackContext=()=>_fallbackContext;let _cid=0;function createCoreContext(e={}){const t=isFunction(e.onWarn)?e.onWarn:warn,r=isString(e.version)?e.version:VERSION,n=isString(e.locale)||isFunction(e.locale)?e.locale:DEFAULT_LOCALE,a=isFunction(n)?DEFAULT_LOCALE:n,s=isArray(e.fallbackLocale)||isPlainObject(e.fallbackLocale)||isString(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:a,o=isPlainObject(e.messages)?e.messages:createResources(a),i=isPlainObject(e.datetimeFormats)?e.datetimeFormats:createResources(a),l=isPlainObject(e.numberFormats)?e.numberFormats:createResources(a),c=assign(create(),e.modifiers,getDefaultLinkedModifiers()),u=e.pluralRules||create(),m=isFunction(e.missing)?e.missing:null,f=!isBoolean(e.missingWarn)&&!isRegExp(e.missingWarn)||e.missingWarn,_=!isBoolean(e.fallbackWarn)&&!isRegExp(e.fallbackWarn)||e.fallbackWarn,g=!!e.fallbackFormat,E=!!e.unresolving,p=isFunction(e.postTranslation)?e.postTranslation:null,O=isPlainObject(e.processor)?e.processor:null,d=!isBoolean(e.warnHtmlMessage)||e.warnHtmlMessage,C=!!e.escapeParameter,T=isFunction(e.messageCompiler)?e.messageCompiler:_compiler,S=isFunction(e.messageResolver)?e.messageResolver:_resolver||resolveWithKeyValue,A=isFunction(e.localeFallbacker)?e.localeFallbacker:_fallbacker||fallbackWithSimple,P=isObject(e.fallbackContext)?e.fallbackContext:void 0,h=e,N=isObject(h.__datetimeFormatters)?h.__datetimeFormatters:new Map,b=isObject(h.__numberFormatters)?h.__numberFormatters:new Map,L=isObject(h.__meta)?h.__meta:{};_cid++;const M={version:r,cid:_cid,locale:n,fallbackLocale:s,messages:o,modifiers:c,pluralRules:u,missing:m,missingWarn:f,fallbackWarn:_,fallbackFormat:g,unresolving:E,postTranslation:p,processor:O,warnHtmlMessage:d,escapeParameter:C,messageCompiler:T,messageResolver:S,localeFallbacker:A,fallbackContext:P,onWarn:t,__meta:L};return M.datetimeFormats=i,M.numberFormats=l,M.__datetimeFormatters=N,M.__numberFormatters=b,M}const createResources=e=>({[e]:create()});function isTranslateFallbackWarn(e,t){return e instanceof RegExp?e.test(t):e}function isTranslateMissingWarn(e,t){return e instanceof RegExp?e.test(t):e}function handleMissing(e,t,r,n,a){const{missing:s,onWarn:o}=e;if(null!==s){const n=s(e,r,t,a);return isString(n)?n:t}return t}function invalidateLocaleChainCache(e,t){const r=e;isObject(t)?r.__localeChainObjectCache?.delete(t):r.__localeChainCache?.delete(t)}function updateFallbackLocale(e,t,r){invalidateLocaleChainCache(e,r),e.fallbackContext&&invalidateLocaleChainCache(e.fallbackContext,r),e.localeFallbacker(e,r,t)}function isAlmostSameLocale(e,t){return e!==t&&e.split("-")[0]===t.split("-")[0]}function isImplicitFallback(e,t){const r=t.indexOf(e);if(-1===r)return!1;for(let n=r+1;n<t.length;n++)if(isAlmostSameLocale(e,t[n]))return!0;return!1}function resolveFormatLocale(e,t,r,n,a,s,o){const{fallbackLocale:i,localeFallbacker:l,onWarn:c}=e,u=l(e,i,r);for(let m=0;m<u.length;m++){const r=u[m],s=getOwn(getOwn(n,r)||{},t);if(isPlainObject(s)&&isString(r))return r;handleMissing(e,t,r,a,o)}return null}function getFormatterCacheKey(e,t,r){let n=`${e}__${t}`;return isPlainObject(r)&&!isEmptyObject(r)&&(n=`${n}__${JSON.stringify(r)}`),n}function clearFormatCache(e,t,r){for(const n in r){const r=`${t}__${n}`;for(const t of e.keys())(t===r||t.startsWith(`${r}__`))&&e.delete(t)}}function parseFormatArgs(e,t,r,n){const[,a,s,o]=e;let i=r;return isString(a)?t.key=a:isPlainObject(a)&&Object.keys(a).forEach((e=>{n.includes(e)?i[e]=a[e]:t[e]=a[e]})),isString(s)?t.locale=s:isPlainObject(s)&&(i=s),isPlainObject(o)&&(i=o),i}function datetime(e,...t){const{datetimeFormats:r,unresolving:n,onWarn:a}=e,{__datetimeFormatters:s}=e;if(!isString(t[0])&&!isDate(t[0])&&!isNumber(t[0]))return"";const[o,i,l,c]=parseDateTimeArgs(...t),u=isBoolean(l.missingWarn)?l.missingWarn:e.missingWarn,m=isBoolean(l.fallbackWarn)?l.fallbackWarn:e.fallbackWarn,f=!!l.part,_=getLocale(e,l);if(!isString(o)||""===o){const e=new Intl.DateTimeFormat(_.replace(/!/g,""),c);return f?e.formatToParts(i):e.format(i)}const g=resolveFormatLocale(e,o,_,r,u,m,"datetime format");if(!isString(g))return n?-1:o;const E=r[g][o],p=getFormatterCacheKey(g,o,c);let O=s.get(p);return O||(O=new Intl.DateTimeFormat(g,assign({},E,c)),s.set(p,O)),f?O.formatToParts(i):O.format(i)}const DATETIME_FORMAT_OPTIONS_KEYS=["localeMatcher","weekday","era","year","month","day","hour","minute","second","timeZoneName","formatMatcher","hour12","timeZone","dateStyle","timeStyle","calendar","dayPeriod","numberingSystem","hourCycle","fractionalSecondDigits"];function parseDateTimeArgs(...e){const[t]=e,r=create(),n=create();let a;if(isString(t)){const e=t.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/);if(!e)throw Error(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT);const r=e[3]?e[3].trim().startsWith("T")?`${e[1].trim()}${e[3].trim()}`:`${e[1].trim()}T${e[3].trim()}`:e[1].trim();a=new Date(r);try{a.toISOString()}catch{throw Error(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT)}}else if(isDate(t)){if(isNaN(t.getTime()))throw Error(CoreErrorCodes.INVALID_DATE_ARGUMENT);a=t}else{if(!isNumber(t))throw Error(CoreErrorCodes.INVALID_ARGUMENT);a=t}const s=parseFormatArgs(e,r,n,DATETIME_FORMAT_OPTIONS_KEYS);return[r.key||"",a,r,s]}function clearDateTimeFormat(e,t,r){clearFormatCache(e.__datetimeFormatters,t,r)}function number(e,...t){const{numberFormats:r,unresolving:n,onWarn:a}=e,{__numberFormatters:s}=e;if(!isNumber(t[0]))return"";const[o,i,l,c]=parseNumberArgs(...t),u=isBoolean(l.missingWarn)?l.missingWarn:e.missingWarn,m=isBoolean(l.fallbackWarn)?l.fallbackWarn:e.fallbackWarn,f=!!l.part,_=getLocale(e,l);if(!isString(o)||""===o){const e=new Intl.NumberFormat(_.replace(/!/g,""),c);return f?e.formatToParts(i):e.format(i)}const g=resolveFormatLocale(e,o,_,r,u,m,"number format");if(!isString(g))return n?-1:o;const E=r[g][o],p=getFormatterCacheKey(g,o,c);let O=s.get(p);return O||(O=new Intl.NumberFormat(g,assign({},E,c)),s.set(p,O)),f?O.formatToParts(i):O.format(i)}const NUMBER_FORMAT_OPTIONS_KEYS=["localeMatcher","style","currency","currencyDisplay","currencySign","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits","compactDisplay","notation","signDisplay","unit","unitDisplay","roundingMode","roundingPriority","roundingIncrement","trailingZeroDisplay"];function parseNumberArgs(...e){const[t]=e,r=create(),n=create();if(!isNumber(t))throw Error(CoreErrorCodes.INVALID_ARGUMENT);const a=t,s=parseFormatArgs(e,r,n,NUMBER_FORMAT_OPTIONS_KEYS);return[r.key||"",a,r,s]}function clearNumberFormat(e,t,r){clearFormatCache(e.__numberFormatters,t,r)}const DEFAULT_MODIFIER=e=>e,DEFAULT_MESSAGE=e=>"",DEFAULT_MESSAGE_DATA_TYPE="text",DEFAULT_NORMALIZE=e=>0===e.length?"":join(e),DEFAULT_INTERPOLATE=toDisplayString;function pluralDefault(e,t){return e=Math.abs(e),2===t?1===e?0:1:Math.min(e,2)}function getPluralIndex(e){const t=isNumber(e.pluralIndex)?e.pluralIndex:-1;return isNumber(e.named?.count)?e.named.count:isNumber(e.named?.n)?e.named.n:t}function createMessageContext(e={}){const t=e.locale,r=getPluralIndex(e),n=isString(t)&&e.pluralRules&&isFunction(getOwn(e.pluralRules,t))?e.pluralRules[t]:pluralDefault,a=n===pluralDefault?void 0:pluralDefault,s=e.list||[],o=e.named||create(),i=isNumber(e.pluralIndex),l=t=>{const r=isObjectPrototypeKey(t)?getOwn(o,t):o[t];return!i||r||"count"!==t&&"n"!==t?r:e.pluralIndex};function c(t,r){const n=isFunction(e.messages)?e.messages(t,!!r):!!isObject(e.messages)&&e.messages[t];return n||(e.parent?e.parent.message(t):DEFAULT_MESSAGE)}const u=isFunction(e.processor?.normalize)?e.processor.normalize:DEFAULT_NORMALIZE,m=isFunction(e.processor?.interpolate)?e.processor.interpolate:DEFAULT_INTERPOLATE,f={list:e=>s[e],named:l,plural:e=>e[n(r,e.length,a)],linked:(t,...r)=>{const[n,a]=r;let s="text",o="";1===r.length?isObject(n)?(o=n.modifier||o,s=n.type||s):isString(n)&&(o=n||o):2===r.length&&(isString(n)&&(o=n||o),isString(a)&&(s=a||s));const i=c(t,!0)(f),l=""===i||void 0===i?t:i,u="vnode"===s&&isArray(l)&&o?l[0]:l;if(!o)return u;const m=(_=o,e.modifiers?getOwn(e.modifiers,_):DEFAULT_MODIFIER);var _;return isFunction(m)?m(u,s):u},message:c,type:isString(e.processor?.type)?e.processor.type:DEFAULT_MESSAGE_DATA_TYPE,interpolate:m,normalize:u,values:assign(create(),s,o,i?{count:l("count"),n:l("n")}:{})};return f}const NOOP_MESSAGE_FUNCTION=()=>"",isMessageFunction=e=>isFunction(e),isMessageFormat=e=>isString(e)||isMessageAST(e)||isMessageFunction(e);function translate(e,...t){const{fallbackFormat:r,postTranslation:n,unresolving:a,messageCompiler:s,fallbackLocale:o,messages:i}=e,[l,c]=parseTranslateArgs(...t),u=isBoolean(c.missingWarn)?c.missingWarn:e.missingWarn,m=isBoolean(c.fallbackWarn)?c.fallbackWarn:e.fallbackWarn,f=isBoolean(c.escapeParameter)?c.escapeParameter:e.escapeParameter,_=!!c.resolvedMessage,g=isString(c.default)||isBoolean(c.default)?isBoolean(c.default)?s?l:()=>l:c.default:r?s?l:()=>l:null,E=r||null!=g&&(isString(g)||isFunction(g)),p=getLocale(e,c);f&&escapeParams(c);let[O,d,C]=_?[l,p,getOwn(i,p)||create()]:resolveMessageFormat(e,l,p,o,m,u),T=O,S=l;if(_||isMessageFormat(T)||E&&(T=g,S=T),!(_||isMessageFormat(T)&&isString(d)))return a?-1:l;let A=!1;const P=isMessageFunction(T)?T:compileMessageFormat(e,l,d,T,S,(()=>{A=!0}));if(A)return T;const h=evaluateMessage(e,P,createMessageContext(getMessageContextOptions(e,d,C,c)));let N=n?n(h,l):h;return f&&isString(N)&&(N=sanitizeTranslatedHtml(N)),N}function escapeParams(e){if(isArray(e.list)&&(e.list=e.list.map((e=>isString(e)?escapeHtml(e):e))),isObject(e.named)){const t=e.named,r=create();for(const e of Object.keys(t)){const n=t[e];r[e]=isString(n)?escapeHtml(n):n}e.named=r}}function resolveMessageFormat(e,t,r,n,a,s){const{messages:o,onWarn:i,messageResolver:l,localeFallbacker:c}=e,u=c(e,n,r);let m,f=create(),_=null;for(let g=0;g<u.length&&(m=u[g],f=getOwn(o,m)||create(),null===(_=l(f,t))&&(_=getOwn(f,t)),!isMessageFormat(_));g++)if(!isImplicitFallback(m,u)){const r=handleMissing(e,t,m,s,"translate");r!==t&&(_=r)}return[_,m,f]}function compileMessageFormat(e,t,r,n,a,s){const{messageCompiler:o,warnHtmlMessage:i}=e;if(isMessageFunction(n)){const e=n;return e.locale=e.locale||r,e.key=e.key||t,e}if(null==o){const e=()=>n;return e.locale=r,e.key=t,e}const l=o(n,getCompileContext(e,r,a,n,i,s));return l.locale=r,l.key=t,l.source=n,l}function evaluateMessage(e,t,r){return t(r)}function parseTranslateArgs(...e){const[t,r,n]=e,a=create();if(!(isString(t)||isNumber(t)||isMessageFunction(t)||isMessageAST(t)))throw Error(CoreErrorCodes.INVALID_ARGUMENT);const s=isNumber(t)?String(t):(isMessageFunction(t),t);return isNumber(r)?a.plural=r:isString(r)?a.default=r:isPlainObject(r)&&!isEmptyObject(r)?a.named=r:isArray(r)&&(a.list=r),isNumber(n)?a.plural=n:isString(n)?a.default=n:isPlainObject(n)&&assign(a,n),[s,a]}function getCompileContext(e,t,r,n,a,s){return{locale:t,key:r,warnHtmlMessage:a,onError:e=>{throw s&&s(e),e},onCacheKey:e=>generateFormatCacheKey(t,r,e)}}function getMessageContextOptions(e,t,r,n){const{modifiers:a,pluralRules:s,messageResolver:o,fallbackLocale:i,fallbackWarn:l,missingWarn:c,fallbackContext:u}=e,m={locale:t,modifiers:a,pluralRules:s,messages:(n,a)=>{let s=o(r,n);if(null==s&&(u||a)){const[r,,a]=resolveMessageFormat(u||e,n,t,i,l,c);s=r??o(a,n)}if(isString(s)||isMessageAST(s)){let r=!1;const a=compileMessageFormat(e,n,t,s,n,(()=>{r=!0}));return r?NOOP_MESSAGE_FUNCTION:a}return isMessageFunction(s)?s:NOOP_MESSAGE_FUNCTION}};return e.processor&&(m.processor=e.processor),n.list&&(m.list=n.list),n.named&&(m.named=n.named),isNumber(n.plural)&&(m.pluralIndex=n.plural),m}registerMessageCompiler(compile),registerMessageResolver(resolveValue),registerLocaleFallbacker(fallbackWithLocaleChain);export{AST_NODE_PROPS_KEYS,CORE_ERROR_CODES_EXTEND_POINT,CORE_WARN_CODES_EXTEND_POINT,CompileErrorCodes,CoreErrorCodes,CoreWarnCodes,DATETIME_FORMAT_OPTIONS_KEYS,DEFAULT_LOCALE,DEFAULT_MESSAGE_DATA_TYPE,MISSING_RESOLVE_VALUE,NOT_REOSLVED,NUMBER_FORMAT_OPTIONS_KEYS,VERSION,clearCompileCache,clearDateTimeFormat,clearNumberFormat,compile,createCompileError,createCoreContext,createCoreError,createMessageContext,datetime,fallbackWithLocaleChain,fallbackWithSimple,getAdditionalMeta,getDevToolsHook,getFallbackContext,getLocale,getWarnMessage,handleMissing,initI18nDevTools,isAlmostSameLocale,isImplicitFallback,isMessageAST,isMessageFormat,isMessageFunction,isTranslateFallbackWarn,isTranslateMissingWarn,number,parse,parseDateTimeArgs,parseNumberArgs,parseTranslateArgs,registerLocaleFallbacker,registerMessageCompiler,registerMessageResolver,resolveLocale,resolveValue,resolveWithKeyValue,setAdditionalMeta,setDevToolsHook,setFallbackContext,translate,translateDevTools,updateFallbackLocale};
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * core v11.4.18
2
+ * core v11.4.19
3
3
  * (c) 2026 kazuya kawaguchi
4
4
  * Released under the MIT License.
5
5
  */
@@ -193,19 +193,26 @@ var IntlifyCore = (function (exports) {
193
193
  const colonCharacterReferencePattern = /&colon;?/gi;
194
194
  // eslint-disable-next-line no-control-regex -- URL scheme normalization requires the full control range
195
195
  const controlOrWhitespacePattern = /[\u0000-\u0020\u007f-\u009f]/g;
196
- const eventHandlerPattern = /(?:^|[\s"'<>/])on\w+\s*=\s*["']?[^"'>]+["']?/i;
197
- const eventHandlerAttributePattern = /(^|[\s"'<>/])on(\w+\s*=)/gi;
196
+ const eventHandlerPattern = /^on\w/i;
198
197
  // `srcdoc` holds a whole HTML document: its value is entity-decoded and then parsed again,
199
198
  // so neither escaping the value nor neutralizing `on*` inside it makes it inert
200
- const srcdocPattern = /(?:^|[\s"'<>/])srcdoc\s*=/i;
201
- const srcdocAttributePattern = /(^|[\s"'<>/])s(rcdoc\s*=)/gi;
199
+ const srcdocPattern = /^srcdoc$/i;
202
200
  // `<base>` changes how the page resolves every relative URL after it, and SVG `<animate>` and `<set>`
203
201
  // can set `href` of an SVG `<a>` through `values` or `to`, which the URL check does not look at.
204
202
  // `<script>` does not run when inserted with `innerHTML`, but it runs when the HTML is rendered
205
- // on the server (SSR) and the browser parses it as part of the page
206
- const dangerousElementPattern = /<(?:base|animate|set|script)(?=[\s/>]|$)/i;
207
- const dangerousElementStartTagPattern = /<(base|animate|set|script)(?=[\s/>]|$)/gi;
208
- const unquotedUrlAttributePattern = /(^|[\s"'<>/])((?:href|xlink:href|src|action|formaction)\s*=\s*)([^\s"'=<>`]+)/gi;
203
+ // on the server (SSR) and the browser parses it as part of the page.
204
+ // `<plaintext>` turns the rest of the page into text
205
+ const dangerousElementPattern = /^(?:base|animate|set|script|plaintext)$/i;
206
+ // The content of these elements is text up to their end tag when they are HTML elements, and markup when
207
+ // they are SVG or MathML elements. Their content is turned into text, so that it reads the same in both
208
+ const textContentElementPattern = /^(?:iframe|noembed|noframes|noscript|style|textarea|title|xmp)$/i;
209
+ // The rules of the HTML tokenizer for tags, comments, and the end of a tag that is not closed (`$`):
210
+ // - `<` or `</`, and the tag name
211
+ const tagStartPattern = /<(\/?)([a-z][^\t\n\f\r />]*)/iy;
212
+ // - whitespace and `/`, and then `>` or an attribute: its name, and its value in quotes or without quotes
213
+ const tagStepPattern = /([\t\n\f\r /]*)(?:(>)|([^\t\n\f\r />][^\t\n\f\r />=]*)(?:[\t\n\f\r ]*=[\t\n\f\r ]*(?:(["'])([\s\S]*?)(\4|$)|([^\t\n\f\r >]*)))?)/y;
214
+ // - a comment, which ends with `-->` or `--!>`, or with `>` or `->` right after `<!--`
215
+ const commentPattern = /<!--(?:>|->|[\s\S]*?--!?>)/y;
209
216
  function decodeNumericCharacterReference(match, hex, decimal) {
210
217
  const digits = hex || decimal;
211
218
  if (!digits) {
@@ -277,42 +284,167 @@ var IntlifyCore = (function (exports) {
277
284
  const sanitizedValue = attrName.toLowerCase() === 'style' ? sanitizeStyleValue(value) : value;
278
285
  return escapeAttributeValue(sanitizedValue);
279
286
  }
287
+ function escapeLessThan(text) {
288
+ return text.replace(/</g, '&lt;');
289
+ }
290
+ function serializeAttribute(attrName, value, quote, neutralized) {
291
+ // Character references are not decoded in attribute names, so escaping a character renames the attribute
292
+ let name = attrName;
293
+ if (eventHandlerPattern.test(attrName)) {
294
+ neutralized.eventHandler = true;
295
+ name = `&#111;n${attrName.slice(2)}`;
296
+ }
297
+ else if (srcdocPattern.test(attrName)) {
298
+ neutralized.srcdoc = true;
299
+ name = `&#115;${attrName.slice(1)}`;
300
+ }
301
+ if (value === undefined) {
302
+ return name;
303
+ }
304
+ // An unquoted value stays unquoted: it has no whitespace or `>`, and escaping does not add them
305
+ const valueQuote = quote || '';
306
+ return `${name}=${valueQuote}${sanitizeAttributeValue(attrName, value)}${valueQuote}`;
307
+ }
308
+ /**
309
+ * Read a tag with the rules of the HTML tokenizer.
310
+ * A start tag is written again with its attributes sanitized, and an end tag is kept as it is
311
+ *
312
+ * @param html - The HTML
313
+ * @param start - The index of `<`
314
+ * @param neutralized - What has been neutralized
315
+ * @returns The tag, the tag name, and the index after the tag (-1 when the tag is not closed),
316
+ * or `undefined` when `<` does not start a tag
317
+ */
318
+ function readTag(html, start, neutralized) {
319
+ tagStartPattern.lastIndex = start;
320
+ const tagStart = tagStartPattern.exec(html);
321
+ if (!tagStart) {
322
+ return;
323
+ }
324
+ const [, slash, tagName] = tagStart;
325
+ let tag = tagStart[0];
326
+ let step;
327
+ tagStepPattern.lastIndex = tagStartPattern.lastIndex;
328
+ while ((step = tagStepPattern.exec(html))) {
329
+ const [raw, separator, close, attrName, quote, quotedValue, closingQuote, unquotedValue] = step;
330
+ if (close) {
331
+ const end = tagStepPattern.lastIndex;
332
+ // browsers ignore the attributes of end tags
333
+ return [slash ? html.slice(start, end) : tag + raw, tagName, end];
334
+ }
335
+ if (quote && !closingQuote) {
336
+ break;
337
+ }
338
+ if (!slash) {
339
+ const value = quote ? quotedValue : unquotedValue;
340
+ tag += separator + serializeAttribute(attrName, value, quote, neutralized);
341
+ }
342
+ }
343
+ return [tag, tagName, -1];
344
+ }
345
+ /**
346
+ * Find the end tag of an element whose content is text, as the HTML tokenizer does:
347
+ * the first `</` followed by the tag name, and by whitespace, `/` or `>`
348
+ *
349
+ * @returns The index of the end tag, or -1 when it is not found or not closed in the string
350
+ */
351
+ function findTextContentEnd(html, from, tagName) {
352
+ for (let index = html.indexOf('</', from); index !== -1; index = html.indexOf('</', index + 2)) {
353
+ const endTag = readTag(html, index, {});
354
+ if (endTag && endTag[1].toLowerCase() === tagName.toLowerCase()) {
355
+ return endTag[2] === -1 ? -1 : index;
356
+ }
357
+ }
358
+ return -1;
359
+ }
360
+ /**
361
+ * Sanitize the translated HTML
362
+ *
363
+ * @remarks
364
+ * Tags are read with the rules of the HTML tokenizer, so that the sanitizer and browsers agree on
365
+ * where each tag and each attribute starts and ends, and every attribute of every start tag is checked.
366
+ * What is still open at the end of the string (a tag, a comment, or an element whose content is text,
367
+ * like `<textarea>`) becomes text: on the server (SSR), the rest of the page follows the translation,
368
+ * and it would be read as a part of what is open
369
+ *
370
+ * @param html - The translated HTML
371
+ * @returns The sanitized HTML
372
+ */
280
373
  function sanitizeTranslatedHtml(html) {
281
- // Escape dangerous characters in attribute values
282
- // Process attributes with double quotes
283
- html = html.replace(/([\w:-]+)\s*=\s*"([^"]*)"/g, (_, attrName, attrValue) => `${attrName}="${sanitizeAttributeValue(attrName, attrValue)}"`);
284
- // Process attributes with single quotes
285
- html = html.replace(/([\w:-]+)\s*=\s*'([^']*)'/g, (_, attrName, attrValue) => `${attrName}='${sanitizeAttributeValue(attrName, attrValue)}'`);
286
- // Detect and neutralize event handler attributes
287
- if (eventHandlerPattern.test(html)) {
288
- {
374
+ const neutralized = {};
375
+ let result = '';
376
+ let index = 0;
377
+ let lessThan;
378
+ while ((lessThan = html.indexOf('<', index)) !== -1) {
379
+ result += html.slice(index, lessThan);
380
+ index = lessThan + 1;
381
+ const read = readTag(html, lessThan, neutralized);
382
+ if (read) {
383
+ const [tag, tagName, end] = read;
384
+ if (end === -1) {
385
+ neutralized.unclosed = true;
386
+ result += escapeLessThan(html.slice(lessThan));
387
+ index = html.length;
388
+ break;
389
+ }
390
+ index = end;
391
+ if (tag[1] === '/') {
392
+ result += tag;
393
+ }
394
+ else if (dangerousElementPattern.test(tagName)) {
395
+ // the start tag becomes text
396
+ neutralized.element = true;
397
+ result += escapeLessThan(tag);
398
+ }
399
+ else if (textContentElementPattern.test(tagName)) {
400
+ const contentEnd = findTextContentEnd(html, end, tagName);
401
+ if (contentEnd === -1) {
402
+ // the start tag becomes text, and the content is read as HTML, as browsers do then
403
+ neutralized.unclosed = true;
404
+ result += escapeLessThan(tag);
405
+ }
406
+ else {
407
+ result += tag + escapeLessThan(html.slice(end, contentEnd));
408
+ index = contentEnd;
409
+ }
410
+ }
411
+ else {
412
+ result += tag;
413
+ }
414
+ continue;
415
+ }
416
+ commentPattern.lastIndex = lessThan;
417
+ if (commentPattern.test(html)) {
418
+ result += html.slice(lessThan, commentPattern.lastIndex);
419
+ index = commentPattern.lastIndex;
420
+ continue;
421
+ }
422
+ if (html.startsWith('<!--', lessThan)) {
423
+ neutralized.unclosed = true;
424
+ }
425
+ // `<!DOCTYPE`, `<![CDATA[`, `<?`, `</` without a tag name, `<` at the end and any other `<` become text
426
+ result += '&lt;';
427
+ }
428
+ result += html.slice(index);
429
+ {
430
+ if (neutralized.eventHandler) {
289
431
  warn('Potentially dangerous event handlers detected in translation. ' +
290
432
  'Consider removing onclick, onerror, etc. from your translation messages.');
291
433
  }
292
- // Neutralize event handler attributes by escaping 'on'
293
- html = html.replace(eventHandlerAttributePattern, '$1&#111;n$2');
294
- }
295
- // Detect and neutralize `srcdoc` attributes
296
- if (srcdocPattern.test(html)) {
297
- {
434
+ if (neutralized.srcdoc) {
298
435
  warn('Potentially dangerous srcdoc attribute detected in translation. ' +
299
436
  'Consider removing srcdoc from your translation messages.');
300
437
  }
301
- // Neutralize `srcdoc` by escaping 's': character references are not decoded in attribute names
302
- html = html.replace(srcdocAttributePattern, '$1&#115;$2');
303
- }
304
- // Detect and neutralize `<base>`, `<animate>`, `<set>` and `<script>` elements
305
- if (dangerousElementPattern.test(html)) {
306
- {
307
- warn('Potentially dangerous element (<base>, <animate>, <set> or <script>) ' +
438
+ if (neutralized.element) {
439
+ warn('Potentially dangerous element (<base>, <animate>, <set>, <script> or <plaintext>) ' +
308
440
  'detected in translation. Consider removing it from your translation messages.');
309
441
  }
310
- // Neutralize these elements by escaping '<': the start tag becomes text
311
- html = html.replace(dangerousElementStartTagPattern, '&lt;$1');
442
+ if (neutralized.unclosed) {
443
+ warn('Unclosed tag, comment or element (such as <textarea>) detected in translation. ' +
444
+ 'Consider closing it in your translation messages.');
445
+ }
312
446
  }
313
- // Disable javascript: URLs in unquoted attributes
314
- html = html.replace(unquotedUrlAttributePattern, (match, boundary, prefix, attrValue) => hasJavascriptScheme(attrValue) ? `${boundary}${prefix}about:blank` : match);
315
- return html;
447
+ return result;
316
448
  }
317
449
 
318
450
  const CompileErrorCodes = {
@@ -1102,7 +1234,7 @@ var IntlifyCore = (function (exports) {
1102
1234
  * Intlify core-base version
1103
1235
  * @internal
1104
1236
  */
1105
- const VERSION = '11.4.18';
1237
+ const VERSION = '11.4.19';
1106
1238
  const NOT_REOSLVED = -1;
1107
1239
  const DEFAULT_LOCALE = 'en-US';
1108
1240
  const MISSING_RESOLVE_VALUE = '';