@intlify/core-base
Advanced tools
Comparing version 9.3.0-beta.1 to 9.3.0-beta.2
@@ -1,1608 +0,1 @@ | ||
/*! | ||
* core-base v9.3.0-beta.1 | ||
* (c) 2022 kazuya kawaguchi | ||
* Released under the MIT License. | ||
*/ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var messageCompiler = require('@intlify/message-compiler'); | ||
var shared = require('@intlify/shared'); | ||
var devtoolsIf = require('@intlify/devtools-if'); | ||
const pathStateMachine = []; | ||
pathStateMachine[0 /* BEFORE_PATH */] = { | ||
["w" /* WORKSPACE */]: [0 /* BEFORE_PATH */], | ||
["i" /* IDENT */]: [3 /* IN_IDENT */, 0 /* APPEND */], | ||
["[" /* LEFT_BRACKET */]: [4 /* IN_SUB_PATH */], | ||
["o" /* END_OF_FAIL */]: [7 /* AFTER_PATH */] | ||
}; | ||
pathStateMachine[1 /* IN_PATH */] = { | ||
["w" /* WORKSPACE */]: [1 /* IN_PATH */], | ||
["." /* DOT */]: [2 /* BEFORE_IDENT */], | ||
["[" /* LEFT_BRACKET */]: [4 /* IN_SUB_PATH */], | ||
["o" /* END_OF_FAIL */]: [7 /* AFTER_PATH */] | ||
}; | ||
pathStateMachine[2 /* BEFORE_IDENT */] = { | ||
["w" /* WORKSPACE */]: [2 /* BEFORE_IDENT */], | ||
["i" /* IDENT */]: [3 /* IN_IDENT */, 0 /* APPEND */], | ||
["0" /* ZERO */]: [3 /* IN_IDENT */, 0 /* APPEND */] | ||
}; | ||
pathStateMachine[3 /* IN_IDENT */] = { | ||
["i" /* IDENT */]: [3 /* IN_IDENT */, 0 /* APPEND */], | ||
["0" /* ZERO */]: [3 /* IN_IDENT */, 0 /* APPEND */], | ||
["w" /* WORKSPACE */]: [1 /* IN_PATH */, 1 /* PUSH */], | ||
["." /* DOT */]: [2 /* BEFORE_IDENT */, 1 /* PUSH */], | ||
["[" /* LEFT_BRACKET */]: [4 /* IN_SUB_PATH */, 1 /* PUSH */], | ||
["o" /* END_OF_FAIL */]: [7 /* AFTER_PATH */, 1 /* PUSH */] | ||
}; | ||
pathStateMachine[4 /* IN_SUB_PATH */] = { | ||
["'" /* SINGLE_QUOTE */]: [5 /* IN_SINGLE_QUOTE */, 0 /* APPEND */], | ||
["\"" /* DOUBLE_QUOTE */]: [6 /* IN_DOUBLE_QUOTE */, 0 /* APPEND */], | ||
["[" /* LEFT_BRACKET */]: [ | ||
4 /* IN_SUB_PATH */, | ||
2 /* INC_SUB_PATH_DEPTH */ | ||
], | ||
["]" /* RIGHT_BRACKET */]: [1 /* IN_PATH */, 3 /* PUSH_SUB_PATH */], | ||
["o" /* END_OF_FAIL */]: 8 /* ERROR */, | ||
["l" /* ELSE */]: [4 /* IN_SUB_PATH */, 0 /* APPEND */] | ||
}; | ||
pathStateMachine[5 /* IN_SINGLE_QUOTE */] = { | ||
["'" /* SINGLE_QUOTE */]: [4 /* IN_SUB_PATH */, 0 /* APPEND */], | ||
["o" /* END_OF_FAIL */]: 8 /* ERROR */, | ||
["l" /* ELSE */]: [5 /* IN_SINGLE_QUOTE */, 0 /* APPEND */] | ||
}; | ||
pathStateMachine[6 /* IN_DOUBLE_QUOTE */] = { | ||
["\"" /* DOUBLE_QUOTE */]: [4 /* IN_SUB_PATH */, 0 /* APPEND */], | ||
["o" /* END_OF_FAIL */]: 8 /* ERROR */, | ||
["l" /* ELSE */]: [6 /* IN_DOUBLE_QUOTE */, 0 /* APPEND */] | ||
}; | ||
/** | ||
* Check if an expression is a literal value. | ||
*/ | ||
const literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/; | ||
function isLiteral(exp) { | ||
return literalValueRE.test(exp); | ||
} | ||
/** | ||
* Strip quotes from a string | ||
*/ | ||
function stripQuotes(str) { | ||
const a = str.charCodeAt(0); | ||
const b = str.charCodeAt(str.length - 1); | ||
return a === b && (a === 0x22 || a === 0x27) ? str.slice(1, -1) : str; | ||
} | ||
/** | ||
* Determine the type of a character in a keypath. | ||
*/ | ||
function getPathCharType(ch) { | ||
if (ch === undefined || ch === null) { | ||
return "o" /* END_OF_FAIL */; | ||
} | ||
const code = ch.charCodeAt(0); | ||
switch (code) { | ||
case 0x5b: // [ | ||
case 0x5d: // ] | ||
case 0x2e: // . | ||
case 0x22: // " | ||
case 0x27: // ' | ||
return ch; | ||
case 0x5f: // _ | ||
case 0x24: // $ | ||
case 0x2d: // - | ||
return "i" /* IDENT */; | ||
case 0x09: // Tab (HT) | ||
case 0x0a: // Newline (LF) | ||
case 0x0d: // Return (CR) | ||
case 0xa0: // No-break space (NBSP) | ||
case 0xfeff: // Byte Order Mark (BOM) | ||
case 0x2028: // Line Separator (LS) | ||
case 0x2029: // Paragraph Separator (PS) | ||
return "w" /* WORKSPACE */; | ||
} | ||
return "i" /* IDENT */; | ||
} | ||
/** | ||
* Format a subPath, return its plain form if it is | ||
* a literal string or number. Otherwise prepend the | ||
* dynamic indicator (*). | ||
*/ | ||
function formatSubPath(path) { | ||
const trimmed = path.trim(); | ||
// invalid leading 0 | ||
if (path.charAt(0) === '0' && isNaN(parseInt(path))) { | ||
return false; | ||
} | ||
return isLiteral(trimmed) | ||
? stripQuotes(trimmed) | ||
: "*" /* ASTARISK */ + trimmed; | ||
} | ||
/** | ||
* Parse a string path into an array of segments | ||
*/ | ||
function parse(path) { | ||
const keys = []; | ||
let index = -1; | ||
let mode = 0 /* BEFORE_PATH */; | ||
let subPathDepth = 0; | ||
let c; | ||
let key; // eslint-disable-line | ||
let newChar; | ||
let type; | ||
let transition; | ||
let action; | ||
let typeMap; | ||
const actions = []; | ||
actions[0 /* APPEND */] = () => { | ||
if (key === undefined) { | ||
key = newChar; | ||
} | ||
else { | ||
key += newChar; | ||
} | ||
}; | ||
actions[1 /* PUSH */] = () => { | ||
if (key !== undefined) { | ||
keys.push(key); | ||
key = undefined; | ||
} | ||
}; | ||
actions[2 /* INC_SUB_PATH_DEPTH */] = () => { | ||
actions[0 /* APPEND */](); | ||
subPathDepth++; | ||
}; | ||
actions[3 /* PUSH_SUB_PATH */] = () => { | ||
if (subPathDepth > 0) { | ||
subPathDepth--; | ||
mode = 4 /* IN_SUB_PATH */; | ||
actions[0 /* APPEND */](); | ||
} | ||
else { | ||
subPathDepth = 0; | ||
if (key === undefined) { | ||
return false; | ||
} | ||
key = formatSubPath(key); | ||
if (key === false) { | ||
return false; | ||
} | ||
else { | ||
actions[1 /* PUSH */](); | ||
} | ||
} | ||
}; | ||
function maybeUnescapeQuote() { | ||
const nextChar = path[index + 1]; | ||
if ((mode === 5 /* IN_SINGLE_QUOTE */ && | ||
nextChar === "'" /* SINGLE_QUOTE */) || | ||
(mode === 6 /* IN_DOUBLE_QUOTE */ && | ||
nextChar === "\"" /* DOUBLE_QUOTE */)) { | ||
index++; | ||
newChar = '\\' + nextChar; | ||
actions[0 /* APPEND */](); | ||
return true; | ||
} | ||
} | ||
while (mode !== null) { | ||
index++; | ||
c = path[index]; | ||
if (c === '\\' && maybeUnescapeQuote()) { | ||
continue; | ||
} | ||
type = getPathCharType(c); | ||
typeMap = pathStateMachine[mode]; | ||
transition = typeMap[type] || typeMap["l" /* ELSE */] || 8 /* ERROR */; | ||
// check parse error | ||
if (transition === 8 /* ERROR */) { | ||
return; | ||
} | ||
mode = transition[0]; | ||
if (transition[1] !== undefined) { | ||
action = actions[transition[1]]; | ||
if (action) { | ||
newChar = c; | ||
if (action() === false) { | ||
return; | ||
} | ||
} | ||
} | ||
// check parse finish | ||
if (mode === 7 /* AFTER_PATH */) { | ||
return keys; | ||
} | ||
} | ||
} | ||
// path token cache | ||
const cache = new Map(); | ||
/** | ||
* key-value message resolver | ||
* | ||
* @remarks | ||
* Resolves messages with the key-value structure. Note that messages with a hierarchical structure such as objects cannot be resolved | ||
* | ||
* @param obj - A target object to be resolved with path | ||
* @param path - A {@link Path | path} to resolve the value of message | ||
* | ||
* @returns A resolved {@link PathValue | path value} | ||
* | ||
* @VueI18nGeneral | ||
*/ | ||
function resolveWithKeyValue(obj, path) { | ||
return shared.isObject(obj) ? obj[path] : null; | ||
} | ||
/** | ||
* message resolver | ||
* | ||
* @remarks | ||
* Resolves messages. messages with a hierarchical structure such as objects can be resolved. This resolver is used in VueI18n as default. | ||
* | ||
* @param obj - A target object to be resolved with path | ||
* @param path - A {@link Path | path} to resolve the value of message | ||
* | ||
* @returns A resolved {@link PathValue | path value} | ||
* | ||
* @VueI18nGeneral | ||
*/ | ||
function resolveValue(obj, path) { | ||
// check object | ||
if (!shared.isObject(obj)) { | ||
return null; | ||
} | ||
// parse path | ||
let hit = cache.get(path); | ||
if (!hit) { | ||
hit = parse(path); | ||
if (hit) { | ||
cache.set(path, hit); | ||
} | ||
} | ||
// check hit | ||
if (!hit) { | ||
return null; | ||
} | ||
// resolve path value | ||
const len = hit.length; | ||
let last = obj; | ||
let i = 0; | ||
while (i < len) { | ||
const val = last[hit[i]]; | ||
if (val === undefined) { | ||
return null; | ||
} | ||
last = val; | ||
i++; | ||
} | ||
return last; | ||
} | ||
const DEFAULT_MODIFIER = (str) => str; | ||
const DEFAULT_MESSAGE = (ctx) => ''; // eslint-disable-line | ||
const DEFAULT_MESSAGE_DATA_TYPE = 'text'; | ||
const DEFAULT_NORMALIZE = (values) => values.length === 0 ? '' : values.join(''); | ||
const DEFAULT_INTERPOLATE = shared.toDisplayString; | ||
function pluralDefault(choice, choicesLength) { | ||
choice = Math.abs(choice); | ||
if (choicesLength === 2) { | ||
// prettier-ignore | ||
return choice | ||
? choice > 1 | ||
? 1 | ||
: 0 | ||
: 1; | ||
} | ||
return choice ? Math.min(choice, 2) : 0; | ||
} | ||
function getPluralIndex(options) { | ||
// prettier-ignore | ||
const index = shared.isNumber(options.pluralIndex) | ||
? options.pluralIndex | ||
: -1; | ||
// prettier-ignore | ||
return options.named && (shared.isNumber(options.named.count) || shared.isNumber(options.named.n)) | ||
? shared.isNumber(options.named.count) | ||
? options.named.count | ||
: shared.isNumber(options.named.n) | ||
? options.named.n | ||
: index | ||
: index; | ||
} | ||
function normalizeNamed(pluralIndex, props) { | ||
if (!props.count) { | ||
props.count = pluralIndex; | ||
} | ||
if (!props.n) { | ||
props.n = pluralIndex; | ||
} | ||
} | ||
function createMessageContext(options = {}) { | ||
const locale = options.locale; | ||
const pluralIndex = getPluralIndex(options); | ||
const pluralRule = shared.isObject(options.pluralRules) && | ||
shared.isString(locale) && | ||
shared.isFunction(options.pluralRules[locale]) | ||
? options.pluralRules[locale] | ||
: pluralDefault; | ||
const orgPluralRule = shared.isObject(options.pluralRules) && | ||
shared.isString(locale) && | ||
shared.isFunction(options.pluralRules[locale]) | ||
? pluralDefault | ||
: undefined; | ||
const plural = (messages) => { | ||
return messages[pluralRule(pluralIndex, messages.length, orgPluralRule)]; | ||
}; | ||
const _list = options.list || []; | ||
const list = (index) => _list[index]; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const _named = options.named || {}; | ||
shared.isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named); | ||
const named = (key) => _named[key]; | ||
function message(key) { | ||
// prettier-ignore | ||
const msg = shared.isFunction(options.messages) | ||
? options.messages(key) | ||
: shared.isObject(options.messages) | ||
? options.messages[key] | ||
: false; | ||
return !msg | ||
? options.parent | ||
? options.parent.message(key) // resolve from parent messages | ||
: DEFAULT_MESSAGE | ||
: msg; | ||
} | ||
const _modifier = (name) => options.modifiers | ||
? options.modifiers[name] | ||
: DEFAULT_MODIFIER; | ||
const normalize = shared.isPlainObject(options.processor) && shared.isFunction(options.processor.normalize) | ||
? options.processor.normalize | ||
: DEFAULT_NORMALIZE; | ||
const interpolate = shared.isPlainObject(options.processor) && | ||
shared.isFunction(options.processor.interpolate) | ||
? options.processor.interpolate | ||
: DEFAULT_INTERPOLATE; | ||
const type = shared.isPlainObject(options.processor) && shared.isString(options.processor.type) | ||
? options.processor.type | ||
: DEFAULT_MESSAGE_DATA_TYPE; | ||
const linked = (key, ...args) => { | ||
const [arg1, arg2] = args; | ||
let type = 'text'; | ||
let modifier = ''; | ||
if (args.length === 1) { | ||
if (shared.isObject(arg1)) { | ||
modifier = arg1.modifier || modifier; | ||
type = arg1.type || type; | ||
} | ||
else if (shared.isString(arg1)) { | ||
modifier = arg1 || modifier; | ||
} | ||
} | ||
else if (args.length === 2) { | ||
if (shared.isString(arg1)) { | ||
modifier = arg1 || modifier; | ||
} | ||
if (shared.isString(arg2)) { | ||
type = arg2 || type; | ||
} | ||
} | ||
let msg = message(key)(ctx); | ||
// The message in vnode resolved with linked are returned as an array by processor.nomalize | ||
if (type === 'vnode' && shared.isArray(msg) && modifier) { | ||
msg = msg[0]; | ||
} | ||
return modifier ? _modifier(modifier)(msg, type) : msg; | ||
}; | ||
const ctx = { | ||
["list" /* LIST */]: list, | ||
["named" /* NAMED */]: named, | ||
["plural" /* PLURAL */]: plural, | ||
["linked" /* LINKED */]: linked, | ||
["message" /* MESSAGE */]: message, | ||
["type" /* TYPE */]: type, | ||
["interpolate" /* INTERPOLATE */]: interpolate, | ||
["normalize" /* NORMALIZE */]: normalize | ||
}; | ||
return ctx; | ||
} | ||
let devtools = null; | ||
function setDevToolsHook(hook) { | ||
devtools = hook; | ||
} | ||
function getDevToolsHook() { | ||
return devtools; | ||
} | ||
function initI18nDevTools(i18n, version, meta) { | ||
// TODO: queue if devtools is undefined | ||
devtools && | ||
devtools.emit(devtoolsIf.IntlifyDevToolsHooks.I18nInit, { | ||
timestamp: Date.now(), | ||
i18n, | ||
version, | ||
meta | ||
}); | ||
} | ||
const translateDevTools = /* #__PURE__*/ createDevToolsHook(devtoolsIf.IntlifyDevToolsHooks.FunctionTranslate); | ||
function createDevToolsHook(hook) { | ||
return (payloads) => devtools && devtools.emit(hook, payloads); | ||
} | ||
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, | ||
__EXTEND_POINT__: 7 | ||
}; | ||
/** @internal */ | ||
const warnMessages = { | ||
[CoreWarnCodes.NOT_FOUND_KEY]: `Not found '{key}' key in '{locale}' locale messages.`, | ||
[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.` | ||
}; | ||
function getWarnMessage(code, ...args) { | ||
return shared.format(warnMessages[code], ...args); | ||
} | ||
/** | ||
* Fallback with simple implemenation | ||
* | ||
* @remarks | ||
* A fallback locale function implemented with a simple fallback algorithm. | ||
* | ||
* Basically, it returns the value as specified in the `fallbackLocale` props, and is processed with the fallback inside intlify. | ||
* | ||
* @param ctx - A {@link CoreContext | context} | ||
* @param fallback - A {@link FallbackLocale | fallback locale} | ||
* @param start - A starting {@link Locale | locale} | ||
* | ||
* @returns Fallback locales | ||
* | ||
* @VueI18nGeneral | ||
*/ | ||
function fallbackWithSimple(ctx, fallback, start // eslint-disable-line @typescript-eslint/no-unused-vars | ||
) { | ||
// prettier-ignore | ||
return [...new Set([ | ||
start, | ||
...(shared.isArray(fallback) | ||
? fallback | ||
: shared.isObject(fallback) | ||
? Object.keys(fallback) | ||
: shared.isString(fallback) | ||
? [fallback] | ||
: [start]) | ||
])]; | ||
} | ||
/** | ||
* Fallback with locale chain | ||
* | ||
* @remarks | ||
* A fallback locale function implemented with a fallback chain algorithm. It's used in VueI18n as default. | ||
* | ||
* @param ctx - A {@link CoreContext | context} | ||
* @param fallback - A {@link FallbackLocale | fallback locale} | ||
* @param start - A starting {@link Locale | locale} | ||
* | ||
* @returns Fallback locales | ||
* | ||
* @VueI18nSee [Fallbacking](../guide/essentials/fallback) | ||
* | ||
* @VueI18nGeneral | ||
*/ | ||
function fallbackWithLocaleChain(ctx, fallback, start) { | ||
const startLocale = shared.isString(start) ? start : DEFAULT_LOCALE; | ||
const context = ctx; | ||
if (!context.__localeChainCache) { | ||
context.__localeChainCache = new Map(); | ||
} | ||
let chain = context.__localeChainCache.get(startLocale); | ||
if (!chain) { | ||
chain = []; | ||
// first block defined by start | ||
let block = [start]; | ||
// while any intervening block found | ||
while (shared.isArray(block)) { | ||
block = appendBlockToChain(chain, block, fallback); | ||
} | ||
// prettier-ignore | ||
// last block defined by default | ||
const defaults = shared.isArray(fallback) || !shared.isPlainObject(fallback) | ||
? fallback | ||
: fallback['default'] | ||
? fallback['default'] | ||
: null; | ||
// convert defaults to array | ||
block = shared.isString(defaults) ? [defaults] : defaults; | ||
if (shared.isArray(block)) { | ||
appendBlockToChain(chain, block, false); | ||
} | ||
context.__localeChainCache.set(startLocale, chain); | ||
} | ||
return chain; | ||
} | ||
function appendBlockToChain(chain, block, blocks) { | ||
let follow = true; | ||
for (let i = 0; i < block.length && shared.isBoolean(follow); i++) { | ||
const locale = block[i]; | ||
if (shared.isString(locale)) { | ||
follow = appendLocaleToChain(chain, block[i], blocks); | ||
} | ||
} | ||
return follow; | ||
} | ||
function appendLocaleToChain(chain, locale, blocks) { | ||
let follow; | ||
const tokens = locale.split('-'); | ||
do { | ||
const target = tokens.join('-'); | ||
follow = appendItemToChain(chain, target, blocks); | ||
tokens.splice(-1, 1); | ||
} while (tokens.length && follow === true); | ||
return follow; | ||
} | ||
function appendItemToChain(chain, target, blocks) { | ||
let follow = false; | ||
if (!chain.includes(target)) { | ||
follow = true; | ||
if (target) { | ||
follow = target[target.length - 1] !== '!'; | ||
const locale = target.replace(/!/g, ''); | ||
chain.push(locale); | ||
if ((shared.isArray(blocks) || shared.isPlainObject(blocks)) && | ||
blocks[locale] // eslint-disable-line @typescript-eslint/no-explicit-any | ||
) { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
follow = blocks[locale]; | ||
} | ||
} | ||
} | ||
return follow; | ||
} | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/** | ||
* Intlify core-base version | ||
* @internal | ||
*/ | ||
const VERSION = '9.3.0-beta.1'; | ||
const NOT_REOSLVED = -1; | ||
const DEFAULT_LOCALE = 'en-US'; | ||
const MISSING_RESOLVE_VALUE = ''; | ||
const capitalize = (str) => `${str.charAt(0).toLocaleUpperCase()}${str.substr(1)}`; | ||
function getDefaultLinkedModifiers() { | ||
return { | ||
upper: (val, type) => { | ||
// prettier-ignore | ||
return type === 'text' && shared.isString(val) | ||
? val.toUpperCase() | ||
: type === 'vnode' && shared.isObject(val) && '__v_isVNode' in val | ||
? val.children.toUpperCase() | ||
: val; | ||
}, | ||
lower: (val, type) => { | ||
// prettier-ignore | ||
return type === 'text' && shared.isString(val) | ||
? val.toLowerCase() | ||
: type === 'vnode' && shared.isObject(val) && '__v_isVNode' in val | ||
? val.children.toLowerCase() | ||
: val; | ||
}, | ||
capitalize: (val, type) => { | ||
// prettier-ignore | ||
return (type === 'text' && shared.isString(val) | ||
? capitalize(val) | ||
: type === 'vnode' && shared.isObject(val) && '__v_isVNode' in val | ||
? capitalize(val.children) | ||
: val); | ||
} | ||
}; | ||
} | ||
let _compiler; | ||
function registerMessageCompiler(compiler) { | ||
_compiler = compiler; | ||
} | ||
let _resolver; | ||
/** | ||
* Register the message resolver | ||
* | ||
* @param resolver - A {@link MessageResolver} function | ||
* | ||
* @VueI18nGeneral | ||
*/ | ||
function registerMessageResolver(resolver) { | ||
_resolver = resolver; | ||
} | ||
let _fallbacker; | ||
/** | ||
* Register the locale fallbacker | ||
* | ||
* @param fallbacker - A {@link LocaleFallbacker} function | ||
* | ||
* @VueI18nGeneral | ||
*/ | ||
function registerLocaleFallbacker(fallbacker) { | ||
_fallbacker = fallbacker; | ||
} | ||
// Additional Meta for Intlify DevTools | ||
let _additionalMeta = null; | ||
const setAdditionalMeta = (meta) => { | ||
_additionalMeta = meta; | ||
}; | ||
const getAdditionalMeta = () => _additionalMeta; | ||
let _fallbackContext = null; | ||
const setFallbackContext = (context) => { | ||
_fallbackContext = context; | ||
}; | ||
const getFallbackContext = () => _fallbackContext; | ||
// ID for CoreContext | ||
let _cid = 0; | ||
function createCoreContext(options = {}) { | ||
// setup options | ||
const version = shared.isString(options.version) ? options.version : VERSION; | ||
const locale = shared.isString(options.locale) ? options.locale : DEFAULT_LOCALE; | ||
const fallbackLocale = shared.isArray(options.fallbackLocale) || | ||
shared.isPlainObject(options.fallbackLocale) || | ||
shared.isString(options.fallbackLocale) || | ||
options.fallbackLocale === false | ||
? options.fallbackLocale | ||
: locale; | ||
const messages = shared.isPlainObject(options.messages) | ||
? options.messages | ||
: { [locale]: {} }; | ||
const datetimeFormats = shared.isPlainObject(options.datetimeFormats) | ||
? options.datetimeFormats | ||
: { [locale]: {} } | ||
; | ||
const numberFormats = shared.isPlainObject(options.numberFormats) | ||
? options.numberFormats | ||
: { [locale]: {} } | ||
; | ||
const modifiers = shared.assign({}, options.modifiers || {}, getDefaultLinkedModifiers()); | ||
const pluralRules = options.pluralRules || {}; | ||
const missing = shared.isFunction(options.missing) ? options.missing : null; | ||
const missingWarn = shared.isBoolean(options.missingWarn) || shared.isRegExp(options.missingWarn) | ||
? options.missingWarn | ||
: true; | ||
const fallbackWarn = shared.isBoolean(options.fallbackWarn) || shared.isRegExp(options.fallbackWarn) | ||
? options.fallbackWarn | ||
: true; | ||
const fallbackFormat = !!options.fallbackFormat; | ||
const unresolving = !!options.unresolving; | ||
const postTranslation = shared.isFunction(options.postTranslation) | ||
? options.postTranslation | ||
: null; | ||
const processor = shared.isPlainObject(options.processor) ? options.processor : null; | ||
const warnHtmlMessage = shared.isBoolean(options.warnHtmlMessage) | ||
? options.warnHtmlMessage | ||
: true; | ||
const escapeParameter = !!options.escapeParameter; | ||
const messageCompiler = shared.isFunction(options.messageCompiler) | ||
? options.messageCompiler | ||
: _compiler; | ||
const messageResolver = shared.isFunction(options.messageResolver) | ||
? options.messageResolver | ||
: _resolver || resolveWithKeyValue; | ||
const localeFallbacker = shared.isFunction(options.localeFallbacker) | ||
? options.localeFallbacker | ||
: _fallbacker || fallbackWithSimple; | ||
const fallbackContext = shared.isObject(options.fallbackContext) | ||
? options.fallbackContext | ||
: undefined; | ||
const onWarn = shared.isFunction(options.onWarn) ? options.onWarn : shared.warn; | ||
// setup internal options | ||
const internalOptions = options; | ||
const __datetimeFormatters = shared.isObject(internalOptions.__datetimeFormatters) | ||
? internalOptions.__datetimeFormatters | ||
: new Map() | ||
; | ||
const __numberFormatters = shared.isObject(internalOptions.__numberFormatters) | ||
? internalOptions.__numberFormatters | ||
: new Map() | ||
; | ||
const __meta = shared.isObject(internalOptions.__meta) ? internalOptions.__meta : {}; | ||
_cid++; | ||
const context = { | ||
version, | ||
cid: _cid, | ||
locale, | ||
fallbackLocale, | ||
messages, | ||
modifiers, | ||
pluralRules, | ||
missing, | ||
missingWarn, | ||
fallbackWarn, | ||
fallbackFormat, | ||
unresolving, | ||
postTranslation, | ||
processor, | ||
warnHtmlMessage, | ||
escapeParameter, | ||
messageCompiler, | ||
messageResolver, | ||
localeFallbacker, | ||
fallbackContext, | ||
onWarn, | ||
__meta | ||
}; | ||
{ | ||
context.datetimeFormats = datetimeFormats; | ||
context.numberFormats = numberFormats; | ||
context.__datetimeFormatters = __datetimeFormatters; | ||
context.__numberFormatters = __numberFormatters; | ||
} | ||
// for vue-devtools timeline event | ||
{ | ||
context.__v_emitter = | ||
internalOptions.__v_emitter != null | ||
? internalOptions.__v_emitter | ||
: undefined; | ||
} | ||
// NOTE: experimental !! | ||
{ | ||
initI18nDevTools(context, version, __meta); | ||
} | ||
return context; | ||
} | ||
/** @internal */ | ||
function isTranslateFallbackWarn(fallback, key) { | ||
return fallback instanceof RegExp ? fallback.test(key) : fallback; | ||
} | ||
/** @internal */ | ||
function isTranslateMissingWarn(missing, key) { | ||
return missing instanceof RegExp ? missing.test(key) : missing; | ||
} | ||
/** @internal */ | ||
function handleMissing(context, key, locale, missingWarn, type) { | ||
const { missing, onWarn } = context; | ||
// for vue-devtools timeline event | ||
{ | ||
const emitter = context.__v_emitter; | ||
if (emitter) { | ||
emitter.emit("missing" /* MISSING */, { | ||
locale, | ||
key, | ||
type, | ||
groupId: `${type}:${key}` | ||
}); | ||
} | ||
} | ||
if (missing !== null) { | ||
const ret = missing(context, locale, key, type); | ||
return shared.isString(ret) ? ret : key; | ||
} | ||
else { | ||
if (isTranslateMissingWarn(missingWarn, key)) { | ||
onWarn(getWarnMessage(CoreWarnCodes.NOT_FOUND_KEY, { key, locale })); | ||
} | ||
return key; | ||
} | ||
} | ||
/** @internal */ | ||
function updateFallbackLocale(ctx, locale, fallback) { | ||
const context = ctx; | ||
context.__localeChainCache = new Map(); | ||
ctx.localeFallbacker(ctx, fallback, locale); | ||
} | ||
/* eslint-enable @typescript-eslint/no-explicit-any */ | ||
const RE_HTML_TAG = /<\/?[\w\s="/.':;#-\/]+>/; | ||
const WARN_MESSAGE = `Detected HTML in '{source}' message. Recommend not using HTML messages to avoid XSS.`; | ||
function checkHtmlMessage(source, options) { | ||
const warnHtmlMessage = shared.isBoolean(options.warnHtmlMessage) | ||
? options.warnHtmlMessage | ||
: true; | ||
if (warnHtmlMessage && RE_HTML_TAG.test(source)) { | ||
shared.warn(shared.format(WARN_MESSAGE, { source })); | ||
} | ||
} | ||
const defaultOnCacheKey = (source) => source; | ||
let compileCache = Object.create(null); | ||
function clearCompileCache() { | ||
compileCache = Object.create(null); | ||
} | ||
function compileToFunction(source, options = {}) { | ||
{ | ||
// check HTML message | ||
checkHtmlMessage(source, options); | ||
// check caches | ||
const onCacheKey = options.onCacheKey || defaultOnCacheKey; | ||
const key = onCacheKey(source); | ||
const cached = compileCache[key]; | ||
if (cached) { | ||
return cached; | ||
} | ||
// compile error detecting | ||
let occurred = false; | ||
const onError = options.onError || messageCompiler.defaultOnError; | ||
options.onError = (err) => { | ||
occurred = true; | ||
onError(err); | ||
}; | ||
// compile | ||
const { code } = messageCompiler.baseCompile(source, options); | ||
// evaluate function | ||
const msg = new Function(`return ${code}`)(); | ||
// if occurred compile error, don't cache | ||
return !occurred ? (compileCache[key] = msg) : msg; | ||
} | ||
} | ||
let code = messageCompiler.CompileErrorCodes.__EXTEND_POINT__; | ||
const inc = () => ++code; | ||
const CoreErrorCodes = { | ||
INVALID_ARGUMENT: code, | ||
INVALID_DATE_ARGUMENT: inc(), | ||
INVALID_ISO_DATE_ARGUMENT: inc(), | ||
__EXTEND_POINT__: inc() // 18 | ||
}; | ||
function createCoreError(code) { | ||
return messageCompiler.createCompileError(code, null, { messages: errorMessages } ); | ||
} | ||
/** @internal */ | ||
const errorMessages = { | ||
[CoreErrorCodes.INVALID_ARGUMENT]: 'Invalid arguments', | ||
[CoreErrorCodes.INVALID_DATE_ARGUMENT]: 'The date provided is an invalid Date object.' + | ||
'Make sure your Date represents a valid date.', | ||
[CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT]: 'The argument provided is not a valid ISO date string' | ||
}; | ||
const NOOP_MESSAGE_FUNCTION = () => ''; | ||
const isMessageFunction = (val) => shared.isFunction(val); | ||
// implementation of `translate` function | ||
function translate(context, ...args) { | ||
const { fallbackFormat, postTranslation, unresolving, messageCompiler, fallbackLocale, messages } = context; | ||
const [key, options] = parseTranslateArgs(...args); | ||
const missingWarn = shared.isBoolean(options.missingWarn) | ||
? options.missingWarn | ||
: context.missingWarn; | ||
const fallbackWarn = shared.isBoolean(options.fallbackWarn) | ||
? options.fallbackWarn | ||
: context.fallbackWarn; | ||
const escapeParameter = shared.isBoolean(options.escapeParameter) | ||
? options.escapeParameter | ||
: context.escapeParameter; | ||
const resolvedMessage = !!options.resolvedMessage; | ||
// prettier-ignore | ||
const defaultMsgOrKey = shared.isString(options.default) || shared.isBoolean(options.default) // default by function option | ||
? !shared.isBoolean(options.default) | ||
? options.default | ||
: (!messageCompiler ? () => key : key) | ||
: fallbackFormat // default by `fallbackFormat` option | ||
? (!messageCompiler ? () => key : key) | ||
: ''; | ||
const enableDefaultMsg = fallbackFormat || defaultMsgOrKey !== ''; | ||
const locale = shared.isString(options.locale) ? options.locale : context.locale; | ||
// escape params | ||
escapeParameter && escapeParams(options); | ||
// resolve message format | ||
// eslint-disable-next-line prefer-const | ||
let [formatScope, targetLocale, message] = !resolvedMessage | ||
? resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) | ||
: [ | ||
key, | ||
locale, | ||
messages[locale] || {} | ||
]; | ||
// NOTE: | ||
// Fix to work around `ssrTransfrom` bug in Vite. | ||
// https://github.com/vitejs/vite/issues/4306 | ||
// To get around this, use temporary variables. | ||
// https://github.com/nuxt/framework/issues/1461#issuecomment-954606243 | ||
let format = formatScope; | ||
// if you use default message, set it as message format! | ||
let cacheBaseKey = key; | ||
if (!resolvedMessage && | ||
!(shared.isString(format) || isMessageFunction(format))) { | ||
if (enableDefaultMsg) { | ||
format = defaultMsgOrKey; | ||
cacheBaseKey = format; | ||
} | ||
} | ||
// checking message format and target locale | ||
if (!resolvedMessage && | ||
(!(shared.isString(format) || isMessageFunction(format)) || | ||
!shared.isString(targetLocale))) { | ||
return unresolving ? NOT_REOSLVED : key; | ||
} | ||
if (shared.isString(format) && context.messageCompiler == null) { | ||
shared.warn(`The message format compilation is not supported in this build. ` + | ||
`Because message compiler isn't included. ` + | ||
`You need to pre-compilation all message format. ` + | ||
`So translate function return '${key}'.`); | ||
return key; | ||
} | ||
// setup compile error detecting | ||
let occurred = false; | ||
const errorDetector = () => { | ||
occurred = true; | ||
}; | ||
// compile message format | ||
const msg = !isMessageFunction(format) | ||
? compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, errorDetector) | ||
: format; | ||
// if occurred compile error, return the message format | ||
if (occurred) { | ||
return format; | ||
} | ||
// evaluate message with context | ||
const ctxOptions = getMessageContextOptions(context, targetLocale, message, options); | ||
const msgContext = createMessageContext(ctxOptions); | ||
const messaged = evaluateMessage(context, msg, msgContext); | ||
// if use post translation option, proceed it with handler | ||
const ret = postTranslation | ||
? postTranslation(messaged, key) | ||
: messaged; | ||
// NOTE: experimental !! | ||
{ | ||
// prettier-ignore | ||
const payloads = { | ||
timestamp: Date.now(), | ||
key: shared.isString(key) | ||
? key | ||
: isMessageFunction(format) | ||
? format.key | ||
: '', | ||
locale: targetLocale || (isMessageFunction(format) | ||
? format.locale | ||
: ''), | ||
format: shared.isString(format) | ||
? format | ||
: isMessageFunction(format) | ||
? format.source | ||
: '', | ||
message: ret | ||
}; | ||
payloads.meta = shared.assign({}, context.__meta, getAdditionalMeta() || {}); | ||
translateDevTools(payloads); | ||
} | ||
return ret; | ||
} | ||
function escapeParams(options) { | ||
if (shared.isArray(options.list)) { | ||
options.list = options.list.map(item => shared.isString(item) ? shared.escapeHtml(item) : item); | ||
} | ||
else if (shared.isObject(options.named)) { | ||
Object.keys(options.named).forEach(key => { | ||
if (shared.isString(options.named[key])) { | ||
options.named[key] = shared.escapeHtml(options.named[key]); | ||
} | ||
}); | ||
} | ||
} | ||
function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) { | ||
const { messages, onWarn, messageResolver: resolveValue, localeFallbacker } = context; | ||
const locales = localeFallbacker(context, fallbackLocale, locale); // eslint-disable-line @typescript-eslint/no-explicit-any | ||
let message = {}; | ||
let targetLocale; | ||
let format = null; | ||
let from = locale; | ||
let to = null; | ||
const type = 'translate'; | ||
for (let i = 0; i < locales.length; i++) { | ||
targetLocale = to = locales[i]; | ||
if (locale !== targetLocale && | ||
isTranslateFallbackWarn(fallbackWarn, key)) { | ||
onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_TRANSLATE, { | ||
key, | ||
target: targetLocale | ||
})); | ||
} | ||
// for vue-devtools timeline event | ||
if (locale !== targetLocale) { | ||
const emitter = context.__v_emitter; | ||
if (emitter) { | ||
emitter.emit("fallback" /* FALBACK */, { | ||
type, | ||
key, | ||
from, | ||
to, | ||
groupId: `${type}:${key}` | ||
}); | ||
} | ||
} | ||
message = | ||
messages[targetLocale] || {}; | ||
// for vue-devtools timeline event | ||
let start = null; | ||
let startTag; | ||
let endTag; | ||
if (shared.inBrowser) { | ||
start = window.performance.now(); | ||
startTag = 'intlify-message-resolve-start'; | ||
endTag = 'intlify-message-resolve-end'; | ||
shared.mark && shared.mark(startTag); | ||
} | ||
if ((format = resolveValue(message, key)) === null) { | ||
// if null, resolve with object key path | ||
format = message[key]; // eslint-disable-line @typescript-eslint/no-explicit-any | ||
} | ||
// for vue-devtools timeline event | ||
if (shared.inBrowser) { | ||
const end = window.performance.now(); | ||
const emitter = context.__v_emitter; | ||
if (emitter && start && format) { | ||
emitter.emit("message-resolve" /* MESSAGE_RESOLVE */, { | ||
type: "message-resolve" /* MESSAGE_RESOLVE */, | ||
key, | ||
message: format, | ||
time: end - start, | ||
groupId: `${type}:${key}` | ||
}); | ||
} | ||
if (startTag && endTag && shared.mark && shared.measure) { | ||
shared.mark(endTag); | ||
shared.measure('intlify message resolve', startTag, endTag); | ||
} | ||
} | ||
if (shared.isString(format) || shared.isFunction(format)) | ||
break; | ||
const missingRet = handleMissing(context, // eslint-disable-line @typescript-eslint/no-explicit-any | ||
key, targetLocale, missingWarn, type); | ||
if (missingRet !== key) { | ||
format = missingRet; | ||
} | ||
from = to; | ||
} | ||
return [format, targetLocale, message]; | ||
} | ||
function compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, errorDetector) { | ||
const { messageCompiler, warnHtmlMessage } = context; | ||
if (isMessageFunction(format)) { | ||
const msg = format; | ||
msg.locale = msg.locale || targetLocale; | ||
msg.key = msg.key || key; | ||
return msg; | ||
} | ||
if (messageCompiler == null) { | ||
const msg = (() => format); | ||
msg.locale = targetLocale; | ||
msg.key = key; | ||
return msg; | ||
} | ||
// for vue-devtools timeline event | ||
let start = null; | ||
let startTag; | ||
let endTag; | ||
if (shared.inBrowser) { | ||
start = window.performance.now(); | ||
startTag = 'intlify-message-compilation-start'; | ||
endTag = 'intlify-message-compilation-end'; | ||
shared.mark && shared.mark(startTag); | ||
} | ||
const msg = messageCompiler(format, getCompileOptions(context, targetLocale, cacheBaseKey, format, warnHtmlMessage, errorDetector)); | ||
// for vue-devtools timeline event | ||
if (shared.inBrowser) { | ||
const end = window.performance.now(); | ||
const emitter = context.__v_emitter; | ||
if (emitter && start) { | ||
emitter.emit("message-compilation" /* MESSAGE_COMPILATION */, { | ||
type: "message-compilation" /* MESSAGE_COMPILATION */, | ||
message: format, | ||
time: end - start, | ||
groupId: `${'translate'}:${key}` | ||
}); | ||
} | ||
if (startTag && endTag && shared.mark && shared.measure) { | ||
shared.mark(endTag); | ||
shared.measure('intlify message compilation', startTag, endTag); | ||
} | ||
} | ||
msg.locale = targetLocale; | ||
msg.key = key; | ||
msg.source = format; | ||
return msg; | ||
} | ||
function evaluateMessage(context, msg, msgCtx) { | ||
// for vue-devtools timeline event | ||
let start = null; | ||
let startTag; | ||
let endTag; | ||
if (shared.inBrowser) { | ||
start = window.performance.now(); | ||
startTag = 'intlify-message-evaluation-start'; | ||
endTag = 'intlify-message-evaluation-end'; | ||
shared.mark && shared.mark(startTag); | ||
} | ||
const messaged = msg(msgCtx); | ||
// for vue-devtools timeline event | ||
if (shared.inBrowser) { | ||
const end = window.performance.now(); | ||
const emitter = context.__v_emitter; | ||
if (emitter && start) { | ||
emitter.emit("message-evaluation" /* MESSAGE_EVALUATION */, { | ||
type: "message-evaluation" /* MESSAGE_EVALUATION */, | ||
value: messaged, | ||
time: end - start, | ||
groupId: `${'translate'}:${msg.key}` | ||
}); | ||
} | ||
if (startTag && endTag && shared.mark && shared.measure) { | ||
shared.mark(endTag); | ||
shared.measure('intlify message evaluation', startTag, endTag); | ||
} | ||
} | ||
return messaged; | ||
} | ||
/** @internal */ | ||
function parseTranslateArgs(...args) { | ||
const [arg1, arg2, arg3] = args; | ||
const options = {}; | ||
if (!shared.isString(arg1) && !shared.isNumber(arg1) && !isMessageFunction(arg1)) { | ||
throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); | ||
} | ||
// prettier-ignore | ||
const key = shared.isNumber(arg1) | ||
? String(arg1) | ||
: isMessageFunction(arg1) | ||
? arg1 | ||
: arg1; | ||
if (shared.isNumber(arg2)) { | ||
options.plural = arg2; | ||
} | ||
else if (shared.isString(arg2)) { | ||
options.default = arg2; | ||
} | ||
else if (shared.isPlainObject(arg2) && !shared.isEmptyObject(arg2)) { | ||
options.named = arg2; | ||
} | ||
else if (shared.isArray(arg2)) { | ||
options.list = arg2; | ||
} | ||
if (shared.isNumber(arg3)) { | ||
options.plural = arg3; | ||
} | ||
else if (shared.isString(arg3)) { | ||
options.default = arg3; | ||
} | ||
else if (shared.isPlainObject(arg3)) { | ||
shared.assign(options, arg3); | ||
} | ||
return [key, options]; | ||
} | ||
function getCompileOptions(context, locale, key, source, warnHtmlMessage, errorDetector) { | ||
return { | ||
warnHtmlMessage, | ||
onError: (err) => { | ||
errorDetector && errorDetector(err); | ||
{ | ||
const message = `Message compilation error: ${err.message}`; | ||
const codeFrame = err.location && | ||
shared.generateCodeFrame(source, err.location.start.offset, err.location.end.offset); | ||
const emitter = context.__v_emitter; | ||
if (emitter) { | ||
emitter.emit("compile-error" /* COMPILE_ERROR */, { | ||
message: source, | ||
error: err.message, | ||
start: err.location && err.location.start.offset, | ||
end: err.location && err.location.end.offset, | ||
groupId: `${'translate'}:${key}` | ||
}); | ||
} | ||
console.error(codeFrame ? `${message}\n${codeFrame}` : message); | ||
} | ||
}, | ||
onCacheKey: (source) => shared.generateFormatCacheKey(locale, key, source) | ||
}; | ||
} | ||
function getMessageContextOptions(context, locale, message, options) { | ||
const { modifiers, pluralRules, messageResolver: resolveValue, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context; | ||
const resolveMessage = (key) => { | ||
let val = resolveValue(message, key); | ||
// fallback to root context | ||
if (val == null && fallbackContext) { | ||
const [, , message] = resolveMessageFormat(fallbackContext, key, locale, fallbackLocale, fallbackWarn, missingWarn); | ||
val = resolveValue(message, key); | ||
} | ||
if (shared.isString(val)) { | ||
let occurred = false; | ||
const errorDetector = () => { | ||
occurred = true; | ||
}; | ||
const msg = compileMessageFormat(context, key, locale, val, key, errorDetector); | ||
return !occurred | ||
? msg | ||
: NOOP_MESSAGE_FUNCTION; | ||
} | ||
else if (isMessageFunction(val)) { | ||
return val; | ||
} | ||
else { | ||
// TODO: should be implemented warning message | ||
return NOOP_MESSAGE_FUNCTION; | ||
} | ||
}; | ||
const ctxOptions = { | ||
locale, | ||
modifiers, | ||
pluralRules, | ||
messages: resolveMessage | ||
}; | ||
if (context.processor) { | ||
ctxOptions.processor = context.processor; | ||
} | ||
if (options.list) { | ||
ctxOptions.list = options.list; | ||
} | ||
if (options.named) { | ||
ctxOptions.named = options.named; | ||
} | ||
if (shared.isNumber(options.plural)) { | ||
ctxOptions.pluralIndex = options.plural; | ||
} | ||
return ctxOptions; | ||
} | ||
const intlDefined = typeof Intl !== 'undefined'; | ||
const Availabilities = { | ||
dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== 'undefined', | ||
numberFormat: intlDefined && typeof Intl.NumberFormat !== 'undefined' | ||
}; | ||
// implementation of `datetime` function | ||
function datetime(context, ...args) { | ||
const { datetimeFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; | ||
const { __datetimeFormatters } = context; | ||
if (!Availabilities.dateTimeFormat) { | ||
onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_DATE)); | ||
return MISSING_RESOLVE_VALUE; | ||
} | ||
const [key, value, options, overrides] = parseDateTimeArgs(...args); | ||
const missingWarn = shared.isBoolean(options.missingWarn) | ||
? options.missingWarn | ||
: context.missingWarn; | ||
const fallbackWarn = shared.isBoolean(options.fallbackWarn) | ||
? options.fallbackWarn | ||
: context.fallbackWarn; | ||
const part = !!options.part; | ||
const locale = shared.isString(options.locale) ? options.locale : context.locale; | ||
const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any | ||
fallbackLocale, locale); | ||
if (!shared.isString(key) || key === '') { | ||
return new Intl.DateTimeFormat(locale, overrides).format(value); | ||
} | ||
// resolve format | ||
let datetimeFormat = {}; | ||
let targetLocale; | ||
let format = null; | ||
let from = locale; | ||
let to = null; | ||
const type = 'datetime format'; | ||
for (let i = 0; i < locales.length; i++) { | ||
targetLocale = to = locales[i]; | ||
if (locale !== targetLocale && | ||
isTranslateFallbackWarn(fallbackWarn, key)) { | ||
onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_DATE_FORMAT, { | ||
key, | ||
target: targetLocale | ||
})); | ||
} | ||
// for vue-devtools timeline event | ||
if (locale !== targetLocale) { | ||
const emitter = context.__v_emitter; | ||
if (emitter) { | ||
emitter.emit("fallback" /* FALBACK */, { | ||
type, | ||
key, | ||
from, | ||
to, | ||
groupId: `${type}:${key}` | ||
}); | ||
} | ||
} | ||
datetimeFormat = | ||
datetimeFormats[targetLocale] || {}; | ||
format = datetimeFormat[key]; | ||
if (shared.isPlainObject(format)) | ||
break; | ||
handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any | ||
from = to; | ||
} | ||
// checking format and target locale | ||
if (!shared.isPlainObject(format) || !shared.isString(targetLocale)) { | ||
return unresolving ? NOT_REOSLVED : key; | ||
} | ||
let id = `${targetLocale}__${key}`; | ||
if (!shared.isEmptyObject(overrides)) { | ||
id = `${id}__${JSON.stringify(overrides)}`; | ||
} | ||
let formatter = __datetimeFormatters.get(id); | ||
if (!formatter) { | ||
formatter = new Intl.DateTimeFormat(targetLocale, shared.assign({}, format, overrides)); | ||
__datetimeFormatters.set(id, formatter); | ||
} | ||
return !part ? formatter.format(value) : formatter.formatToParts(value); | ||
} | ||
/** @internal */ | ||
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' | ||
]; | ||
/** @internal */ | ||
function parseDateTimeArgs(...args) { | ||
const [arg1, arg2, arg3, arg4] = args; | ||
const options = {}; | ||
let overrides = {}; | ||
let value; | ||
if (shared.isString(arg1)) { | ||
// Only allow ISO strings - other date formats are often supported, | ||
// but may cause different results in different browsers. | ||
const matches = arg1.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/); | ||
if (!matches) { | ||
throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); | ||
} | ||
// Some browsers can not parse the iso datetime separated by space, | ||
// this is a compromise solution by replace the 'T'/' ' with 'T' | ||
const dateTime = matches[3] | ||
? matches[3].trim().startsWith('T') | ||
? `${matches[1].trim()}${matches[3].trim()}` | ||
: `${matches[1].trim()}T${matches[3].trim()}` | ||
: matches[1].trim(); | ||
value = new Date(dateTime); | ||
try { | ||
// This will fail if the date is not valid | ||
value.toISOString(); | ||
} | ||
catch (e) { | ||
throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); | ||
} | ||
} | ||
else if (shared.isDate(arg1)) { | ||
if (isNaN(arg1.getTime())) { | ||
throw createCoreError(CoreErrorCodes.INVALID_DATE_ARGUMENT); | ||
} | ||
value = arg1; | ||
} | ||
else if (shared.isNumber(arg1)) { | ||
value = arg1; | ||
} | ||
else { | ||
throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); | ||
} | ||
if (shared.isString(arg2)) { | ||
options.key = arg2; | ||
} | ||
else if (shared.isPlainObject(arg2)) { | ||
Object.keys(arg2).forEach(key => { | ||
if (DATETIME_FORMAT_OPTIONS_KEYS.includes(key)) { | ||
overrides[key] = arg2[key]; | ||
} | ||
else { | ||
options[key] = arg2[key]; | ||
} | ||
}); | ||
} | ||
if (shared.isString(arg3)) { | ||
options.locale = arg3; | ||
} | ||
else if (shared.isPlainObject(arg3)) { | ||
overrides = arg3; | ||
} | ||
if (shared.isPlainObject(arg4)) { | ||
overrides = arg4; | ||
} | ||
return [options.key || '', value, options, overrides]; | ||
} | ||
/** @internal */ | ||
function clearDateTimeFormat(ctx, locale, format) { | ||
const context = ctx; | ||
for (const key in format) { | ||
const id = `${locale}__${key}`; | ||
if (!context.__datetimeFormatters.has(id)) { | ||
continue; | ||
} | ||
context.__datetimeFormatters.delete(id); | ||
} | ||
} | ||
// implementation of `number` function | ||
function number(context, ...args) { | ||
const { numberFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; | ||
const { __numberFormatters } = context; | ||
if (!Availabilities.numberFormat) { | ||
onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_NUMBER)); | ||
return MISSING_RESOLVE_VALUE; | ||
} | ||
const [key, value, options, overrides] = parseNumberArgs(...args); | ||
const missingWarn = shared.isBoolean(options.missingWarn) | ||
? options.missingWarn | ||
: context.missingWarn; | ||
const fallbackWarn = shared.isBoolean(options.fallbackWarn) | ||
? options.fallbackWarn | ||
: context.fallbackWarn; | ||
const part = !!options.part; | ||
const locale = shared.isString(options.locale) ? options.locale : context.locale; | ||
const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any | ||
fallbackLocale, locale); | ||
if (!shared.isString(key) || key === '') { | ||
return new Intl.NumberFormat(locale, overrides).format(value); | ||
} | ||
// resolve format | ||
let numberFormat = {}; | ||
let targetLocale; | ||
let format = null; | ||
let from = locale; | ||
let to = null; | ||
const type = 'number format'; | ||
for (let i = 0; i < locales.length; i++) { | ||
targetLocale = to = locales[i]; | ||
if (locale !== targetLocale && | ||
isTranslateFallbackWarn(fallbackWarn, key)) { | ||
onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT, { | ||
key, | ||
target: targetLocale | ||
})); | ||
} | ||
// for vue-devtools timeline event | ||
if (locale !== targetLocale) { | ||
const emitter = context.__v_emitter; | ||
if (emitter) { | ||
emitter.emit("fallback" /* FALBACK */, { | ||
type, | ||
key, | ||
from, | ||
to, | ||
groupId: `${type}:${key}` | ||
}); | ||
} | ||
} | ||
numberFormat = | ||
numberFormats[targetLocale] || {}; | ||
format = numberFormat[key]; | ||
if (shared.isPlainObject(format)) | ||
break; | ||
handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any | ||
from = to; | ||
} | ||
// checking format and target locale | ||
if (!shared.isPlainObject(format) || !shared.isString(targetLocale)) { | ||
return unresolving ? NOT_REOSLVED : key; | ||
} | ||
let id = `${targetLocale}__${key}`; | ||
if (!shared.isEmptyObject(overrides)) { | ||
id = `${id}__${JSON.stringify(overrides)}`; | ||
} | ||
let formatter = __numberFormatters.get(id); | ||
if (!formatter) { | ||
formatter = new Intl.NumberFormat(targetLocale, shared.assign({}, format, overrides)); | ||
__numberFormatters.set(id, formatter); | ||
} | ||
return !part ? formatter.format(value) : formatter.formatToParts(value); | ||
} | ||
/** @internal */ | ||
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' | ||
]; | ||
/** @internal */ | ||
function parseNumberArgs(...args) { | ||
const [arg1, arg2, arg3, arg4] = args; | ||
const options = {}; | ||
let overrides = {}; | ||
if (!shared.isNumber(arg1)) { | ||
throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); | ||
} | ||
const value = arg1; | ||
if (shared.isString(arg2)) { | ||
options.key = arg2; | ||
} | ||
else if (shared.isPlainObject(arg2)) { | ||
Object.keys(arg2).forEach(key => { | ||
if (NUMBER_FORMAT_OPTIONS_KEYS.includes(key)) { | ||
overrides[key] = arg2[key]; | ||
} | ||
else { | ||
options[key] = arg2[key]; | ||
} | ||
}); | ||
} | ||
if (shared.isString(arg3)) { | ||
options.locale = arg3; | ||
} | ||
else if (shared.isPlainObject(arg3)) { | ||
overrides = arg3; | ||
} | ||
if (shared.isPlainObject(arg4)) { | ||
overrides = arg4; | ||
} | ||
return [options.key || '', value, options, overrides]; | ||
} | ||
/** @internal */ | ||
function clearNumberFormat(ctx, locale, format) { | ||
const context = ctx; | ||
for (const key in format) { | ||
const id = `${locale}__${key}`; | ||
if (!context.__numberFormatters.has(id)) { | ||
continue; | ||
} | ||
context.__numberFormatters.delete(id); | ||
} | ||
} | ||
exports.CompileErrorCodes = messageCompiler.CompileErrorCodes; | ||
exports.createCompileError = messageCompiler.createCompileError; | ||
exports.CoreErrorCodes = CoreErrorCodes; | ||
exports.CoreWarnCodes = CoreWarnCodes; | ||
exports.DATETIME_FORMAT_OPTIONS_KEYS = DATETIME_FORMAT_OPTIONS_KEYS; | ||
exports.DEFAULT_LOCALE = DEFAULT_LOCALE; | ||
exports.DEFAULT_MESSAGE_DATA_TYPE = DEFAULT_MESSAGE_DATA_TYPE; | ||
exports.MISSING_RESOLVE_VALUE = MISSING_RESOLVE_VALUE; | ||
exports.NOT_REOSLVED = NOT_REOSLVED; | ||
exports.NUMBER_FORMAT_OPTIONS_KEYS = NUMBER_FORMAT_OPTIONS_KEYS; | ||
exports.VERSION = VERSION; | ||
exports.clearCompileCache = clearCompileCache; | ||
exports.clearDateTimeFormat = clearDateTimeFormat; | ||
exports.clearNumberFormat = clearNumberFormat; | ||
exports.compileToFunction = compileToFunction; | ||
exports.createCoreContext = createCoreContext; | ||
exports.createCoreError = createCoreError; | ||
exports.createMessageContext = createMessageContext; | ||
exports.datetime = datetime; | ||
exports.fallbackWithLocaleChain = fallbackWithLocaleChain; | ||
exports.fallbackWithSimple = fallbackWithSimple; | ||
exports.getAdditionalMeta = getAdditionalMeta; | ||
exports.getDevToolsHook = getDevToolsHook; | ||
exports.getFallbackContext = getFallbackContext; | ||
exports.getWarnMessage = getWarnMessage; | ||
exports.handleMissing = handleMissing; | ||
exports.initI18nDevTools = initI18nDevTools; | ||
exports.isMessageFunction = isMessageFunction; | ||
exports.isTranslateFallbackWarn = isTranslateFallbackWarn; | ||
exports.isTranslateMissingWarn = isTranslateMissingWarn; | ||
exports.number = number; | ||
exports.parse = parse; | ||
exports.parseDateTimeArgs = parseDateTimeArgs; | ||
exports.parseNumberArgs = parseNumberArgs; | ||
exports.parseTranslateArgs = parseTranslateArgs; | ||
exports.registerLocaleFallbacker = registerLocaleFallbacker; | ||
exports.registerMessageCompiler = registerMessageCompiler; | ||
exports.registerMessageResolver = registerMessageResolver; | ||
exports.resolveValue = resolveValue; | ||
exports.resolveWithKeyValue = resolveWithKeyValue; | ||
exports.setAdditionalMeta = setAdditionalMeta; | ||
exports.setDevToolsHook = setDevToolsHook; | ||
exports.setFallbackContext = setFallbackContext; | ||
exports.translate = translate; | ||
exports.translateDevTools = translateDevTools; | ||
exports.updateFallbackLocale = updateFallbackLocale; | ||
module.exports = require('../dist/core-base.cjs') |
@@ -1,1362 +0,1 @@ | ||
/*! | ||
* core-base v9.3.0-beta.1 | ||
* (c) 2022 kazuya kawaguchi | ||
* Released under the MIT License. | ||
*/ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var messageCompiler = require('@intlify/message-compiler'); | ||
var shared = require('@intlify/shared'); | ||
var devtoolsIf = require('@intlify/devtools-if'); | ||
const pathStateMachine = []; | ||
pathStateMachine[0 /* BEFORE_PATH */] = { | ||
["w" /* WORKSPACE */]: [0 /* BEFORE_PATH */], | ||
["i" /* IDENT */]: [3 /* IN_IDENT */, 0 /* APPEND */], | ||
["[" /* LEFT_BRACKET */]: [4 /* IN_SUB_PATH */], | ||
["o" /* END_OF_FAIL */]: [7 /* AFTER_PATH */] | ||
}; | ||
pathStateMachine[1 /* IN_PATH */] = { | ||
["w" /* WORKSPACE */]: [1 /* IN_PATH */], | ||
["." /* DOT */]: [2 /* BEFORE_IDENT */], | ||
["[" /* LEFT_BRACKET */]: [4 /* IN_SUB_PATH */], | ||
["o" /* END_OF_FAIL */]: [7 /* AFTER_PATH */] | ||
}; | ||
pathStateMachine[2 /* BEFORE_IDENT */] = { | ||
["w" /* WORKSPACE */]: [2 /* BEFORE_IDENT */], | ||
["i" /* IDENT */]: [3 /* IN_IDENT */, 0 /* APPEND */], | ||
["0" /* ZERO */]: [3 /* IN_IDENT */, 0 /* APPEND */] | ||
}; | ||
pathStateMachine[3 /* IN_IDENT */] = { | ||
["i" /* IDENT */]: [3 /* IN_IDENT */, 0 /* APPEND */], | ||
["0" /* ZERO */]: [3 /* IN_IDENT */, 0 /* APPEND */], | ||
["w" /* WORKSPACE */]: [1 /* IN_PATH */, 1 /* PUSH */], | ||
["." /* DOT */]: [2 /* BEFORE_IDENT */, 1 /* PUSH */], | ||
["[" /* LEFT_BRACKET */]: [4 /* IN_SUB_PATH */, 1 /* PUSH */], | ||
["o" /* END_OF_FAIL */]: [7 /* AFTER_PATH */, 1 /* PUSH */] | ||
}; | ||
pathStateMachine[4 /* IN_SUB_PATH */] = { | ||
["'" /* SINGLE_QUOTE */]: [5 /* IN_SINGLE_QUOTE */, 0 /* APPEND */], | ||
["\"" /* DOUBLE_QUOTE */]: [6 /* IN_DOUBLE_QUOTE */, 0 /* APPEND */], | ||
["[" /* LEFT_BRACKET */]: [ | ||
4 /* IN_SUB_PATH */, | ||
2 /* INC_SUB_PATH_DEPTH */ | ||
], | ||
["]" /* RIGHT_BRACKET */]: [1 /* IN_PATH */, 3 /* PUSH_SUB_PATH */], | ||
["o" /* END_OF_FAIL */]: 8 /* ERROR */, | ||
["l" /* ELSE */]: [4 /* IN_SUB_PATH */, 0 /* APPEND */] | ||
}; | ||
pathStateMachine[5 /* IN_SINGLE_QUOTE */] = { | ||
["'" /* SINGLE_QUOTE */]: [4 /* IN_SUB_PATH */, 0 /* APPEND */], | ||
["o" /* END_OF_FAIL */]: 8 /* ERROR */, | ||
["l" /* ELSE */]: [5 /* IN_SINGLE_QUOTE */, 0 /* APPEND */] | ||
}; | ||
pathStateMachine[6 /* IN_DOUBLE_QUOTE */] = { | ||
["\"" /* DOUBLE_QUOTE */]: [4 /* IN_SUB_PATH */, 0 /* APPEND */], | ||
["o" /* END_OF_FAIL */]: 8 /* ERROR */, | ||
["l" /* ELSE */]: [6 /* IN_DOUBLE_QUOTE */, 0 /* APPEND */] | ||
}; | ||
/** | ||
* Check if an expression is a literal value. | ||
*/ | ||
const literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/; | ||
function isLiteral(exp) { | ||
return literalValueRE.test(exp); | ||
} | ||
/** | ||
* Strip quotes from a string | ||
*/ | ||
function stripQuotes(str) { | ||
const a = str.charCodeAt(0); | ||
const b = str.charCodeAt(str.length - 1); | ||
return a === b && (a === 0x22 || a === 0x27) ? str.slice(1, -1) : str; | ||
} | ||
/** | ||
* Determine the type of a character in a keypath. | ||
*/ | ||
function getPathCharType(ch) { | ||
if (ch === undefined || ch === null) { | ||
return "o" /* END_OF_FAIL */; | ||
} | ||
const code = ch.charCodeAt(0); | ||
switch (code) { | ||
case 0x5b: // [ | ||
case 0x5d: // ] | ||
case 0x2e: // . | ||
case 0x22: // " | ||
case 0x27: // ' | ||
return ch; | ||
case 0x5f: // _ | ||
case 0x24: // $ | ||
case 0x2d: // - | ||
return "i" /* IDENT */; | ||
case 0x09: // Tab (HT) | ||
case 0x0a: // Newline (LF) | ||
case 0x0d: // Return (CR) | ||
case 0xa0: // No-break space (NBSP) | ||
case 0xfeff: // Byte Order Mark (BOM) | ||
case 0x2028: // Line Separator (LS) | ||
case 0x2029: // Paragraph Separator (PS) | ||
return "w" /* WORKSPACE */; | ||
} | ||
return "i" /* IDENT */; | ||
} | ||
/** | ||
* Format a subPath, return its plain form if it is | ||
* a literal string or number. Otherwise prepend the | ||
* dynamic indicator (*). | ||
*/ | ||
function formatSubPath(path) { | ||
const trimmed = path.trim(); | ||
// invalid leading 0 | ||
if (path.charAt(0) === '0' && isNaN(parseInt(path))) { | ||
return false; | ||
} | ||
return isLiteral(trimmed) | ||
? stripQuotes(trimmed) | ||
: "*" /* ASTARISK */ + trimmed; | ||
} | ||
/** | ||
* Parse a string path into an array of segments | ||
*/ | ||
function parse(path) { | ||
const keys = []; | ||
let index = -1; | ||
let mode = 0 /* BEFORE_PATH */; | ||
let subPathDepth = 0; | ||
let c; | ||
let key; // eslint-disable-line | ||
let newChar; | ||
let type; | ||
let transition; | ||
let action; | ||
let typeMap; | ||
const actions = []; | ||
actions[0 /* APPEND */] = () => { | ||
if (key === undefined) { | ||
key = newChar; | ||
} | ||
else { | ||
key += newChar; | ||
} | ||
}; | ||
actions[1 /* PUSH */] = () => { | ||
if (key !== undefined) { | ||
keys.push(key); | ||
key = undefined; | ||
} | ||
}; | ||
actions[2 /* INC_SUB_PATH_DEPTH */] = () => { | ||
actions[0 /* APPEND */](); | ||
subPathDepth++; | ||
}; | ||
actions[3 /* PUSH_SUB_PATH */] = () => { | ||
if (subPathDepth > 0) { | ||
subPathDepth--; | ||
mode = 4 /* IN_SUB_PATH */; | ||
actions[0 /* APPEND */](); | ||
} | ||
else { | ||
subPathDepth = 0; | ||
if (key === undefined) { | ||
return false; | ||
} | ||
key = formatSubPath(key); | ||
if (key === false) { | ||
return false; | ||
} | ||
else { | ||
actions[1 /* PUSH */](); | ||
} | ||
} | ||
}; | ||
function maybeUnescapeQuote() { | ||
const nextChar = path[index + 1]; | ||
if ((mode === 5 /* IN_SINGLE_QUOTE */ && | ||
nextChar === "'" /* SINGLE_QUOTE */) || | ||
(mode === 6 /* IN_DOUBLE_QUOTE */ && | ||
nextChar === "\"" /* DOUBLE_QUOTE */)) { | ||
index++; | ||
newChar = '\\' + nextChar; | ||
actions[0 /* APPEND */](); | ||
return true; | ||
} | ||
} | ||
while (mode !== null) { | ||
index++; | ||
c = path[index]; | ||
if (c === '\\' && maybeUnescapeQuote()) { | ||
continue; | ||
} | ||
type = getPathCharType(c); | ||
typeMap = pathStateMachine[mode]; | ||
transition = typeMap[type] || typeMap["l" /* ELSE */] || 8 /* ERROR */; | ||
// check parse error | ||
if (transition === 8 /* ERROR */) { | ||
return; | ||
} | ||
mode = transition[0]; | ||
if (transition[1] !== undefined) { | ||
action = actions[transition[1]]; | ||
if (action) { | ||
newChar = c; | ||
if (action() === false) { | ||
return; | ||
} | ||
} | ||
} | ||
// check parse finish | ||
if (mode === 7 /* AFTER_PATH */) { | ||
return keys; | ||
} | ||
} | ||
} | ||
// path token cache | ||
const cache = new Map(); | ||
/** | ||
* key-value message resolver | ||
* | ||
* @remarks | ||
* Resolves messages with the key-value structure. Note that messages with a hierarchical structure such as objects cannot be resolved | ||
* | ||
* @param obj - A target object to be resolved with path | ||
* @param path - A {@link Path | path} to resolve the value of message | ||
* | ||
* @returns A resolved {@link PathValue | path value} | ||
* | ||
* @VueI18nGeneral | ||
*/ | ||
function resolveWithKeyValue(obj, path) { | ||
return shared.isObject(obj) ? obj[path] : null; | ||
} | ||
/** | ||
* message resolver | ||
* | ||
* @remarks | ||
* Resolves messages. messages with a hierarchical structure such as objects can be resolved. This resolver is used in VueI18n as default. | ||
* | ||
* @param obj - A target object to be resolved with path | ||
* @param path - A {@link Path | path} to resolve the value of message | ||
* | ||
* @returns A resolved {@link PathValue | path value} | ||
* | ||
* @VueI18nGeneral | ||
*/ | ||
function resolveValue(obj, path) { | ||
// check object | ||
if (!shared.isObject(obj)) { | ||
return null; | ||
} | ||
// parse path | ||
let hit = cache.get(path); | ||
if (!hit) { | ||
hit = parse(path); | ||
if (hit) { | ||
cache.set(path, hit); | ||
} | ||
} | ||
// check hit | ||
if (!hit) { | ||
return null; | ||
} | ||
// resolve path value | ||
const len = hit.length; | ||
let last = obj; | ||
let i = 0; | ||
while (i < len) { | ||
const val = last[hit[i]]; | ||
if (val === undefined) { | ||
return null; | ||
} | ||
last = val; | ||
i++; | ||
} | ||
return last; | ||
} | ||
const DEFAULT_MODIFIER = (str) => str; | ||
const DEFAULT_MESSAGE = (ctx) => ''; // eslint-disable-line | ||
const DEFAULT_MESSAGE_DATA_TYPE = 'text'; | ||
const DEFAULT_NORMALIZE = (values) => values.length === 0 ? '' : values.join(''); | ||
const DEFAULT_INTERPOLATE = shared.toDisplayString; | ||
function pluralDefault(choice, choicesLength) { | ||
choice = Math.abs(choice); | ||
if (choicesLength === 2) { | ||
// prettier-ignore | ||
return choice | ||
? choice > 1 | ||
? 1 | ||
: 0 | ||
: 1; | ||
} | ||
return choice ? Math.min(choice, 2) : 0; | ||
} | ||
function getPluralIndex(options) { | ||
// prettier-ignore | ||
const index = shared.isNumber(options.pluralIndex) | ||
? options.pluralIndex | ||
: -1; | ||
// prettier-ignore | ||
return options.named && (shared.isNumber(options.named.count) || shared.isNumber(options.named.n)) | ||
? shared.isNumber(options.named.count) | ||
? options.named.count | ||
: shared.isNumber(options.named.n) | ||
? options.named.n | ||
: index | ||
: index; | ||
} | ||
function normalizeNamed(pluralIndex, props) { | ||
if (!props.count) { | ||
props.count = pluralIndex; | ||
} | ||
if (!props.n) { | ||
props.n = pluralIndex; | ||
} | ||
} | ||
function createMessageContext(options = {}) { | ||
const locale = options.locale; | ||
const pluralIndex = getPluralIndex(options); | ||
const pluralRule = shared.isObject(options.pluralRules) && | ||
shared.isString(locale) && | ||
shared.isFunction(options.pluralRules[locale]) | ||
? options.pluralRules[locale] | ||
: pluralDefault; | ||
const orgPluralRule = shared.isObject(options.pluralRules) && | ||
shared.isString(locale) && | ||
shared.isFunction(options.pluralRules[locale]) | ||
? pluralDefault | ||
: undefined; | ||
const plural = (messages) => { | ||
return messages[pluralRule(pluralIndex, messages.length, orgPluralRule)]; | ||
}; | ||
const _list = options.list || []; | ||
const list = (index) => _list[index]; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const _named = options.named || {}; | ||
shared.isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named); | ||
const named = (key) => _named[key]; | ||
function message(key) { | ||
// prettier-ignore | ||
const msg = shared.isFunction(options.messages) | ||
? options.messages(key) | ||
: shared.isObject(options.messages) | ||
? options.messages[key] | ||
: false; | ||
return !msg | ||
? options.parent | ||
? options.parent.message(key) // resolve from parent messages | ||
: DEFAULT_MESSAGE | ||
: msg; | ||
} | ||
const _modifier = (name) => options.modifiers | ||
? options.modifiers[name] | ||
: DEFAULT_MODIFIER; | ||
const normalize = shared.isPlainObject(options.processor) && shared.isFunction(options.processor.normalize) | ||
? options.processor.normalize | ||
: DEFAULT_NORMALIZE; | ||
const interpolate = shared.isPlainObject(options.processor) && | ||
shared.isFunction(options.processor.interpolate) | ||
? options.processor.interpolate | ||
: DEFAULT_INTERPOLATE; | ||
const type = shared.isPlainObject(options.processor) && shared.isString(options.processor.type) | ||
? options.processor.type | ||
: DEFAULT_MESSAGE_DATA_TYPE; | ||
const linked = (key, ...args) => { | ||
const [arg1, arg2] = args; | ||
let type = 'text'; | ||
let modifier = ''; | ||
if (args.length === 1) { | ||
if (shared.isObject(arg1)) { | ||
modifier = arg1.modifier || modifier; | ||
type = arg1.type || type; | ||
} | ||
else if (shared.isString(arg1)) { | ||
modifier = arg1 || modifier; | ||
} | ||
} | ||
else if (args.length === 2) { | ||
if (shared.isString(arg1)) { | ||
modifier = arg1 || modifier; | ||
} | ||
if (shared.isString(arg2)) { | ||
type = arg2 || type; | ||
} | ||
} | ||
let msg = message(key)(ctx); | ||
// The message in vnode resolved with linked are returned as an array by processor.nomalize | ||
if (type === 'vnode' && shared.isArray(msg) && modifier) { | ||
msg = msg[0]; | ||
} | ||
return modifier ? _modifier(modifier)(msg, type) : msg; | ||
}; | ||
const ctx = { | ||
["list" /* LIST */]: list, | ||
["named" /* NAMED */]: named, | ||
["plural" /* PLURAL */]: plural, | ||
["linked" /* LINKED */]: linked, | ||
["message" /* MESSAGE */]: message, | ||
["type" /* TYPE */]: type, | ||
["interpolate" /* INTERPOLATE */]: interpolate, | ||
["normalize" /* NORMALIZE */]: normalize | ||
}; | ||
return ctx; | ||
} | ||
let devtools = null; | ||
function setDevToolsHook(hook) { | ||
devtools = hook; | ||
} | ||
function getDevToolsHook() { | ||
return devtools; | ||
} | ||
function initI18nDevTools(i18n, version, meta) { | ||
// TODO: queue if devtools is undefined | ||
devtools && | ||
devtools.emit(devtoolsIf.IntlifyDevToolsHooks.I18nInit, { | ||
timestamp: Date.now(), | ||
i18n, | ||
version, | ||
meta | ||
}); | ||
} | ||
const translateDevTools = /* #__PURE__*/ createDevToolsHook(devtoolsIf.IntlifyDevToolsHooks.FunctionTranslate); | ||
function createDevToolsHook(hook) { | ||
return (payloads) => devtools && devtools.emit(hook, payloads); | ||
} | ||
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, | ||
__EXTEND_POINT__: 7 | ||
}; | ||
/** @internal */ | ||
const warnMessages = { | ||
[CoreWarnCodes.NOT_FOUND_KEY]: `Not found '{key}' key in '{locale}' locale messages.`, | ||
[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.` | ||
}; | ||
function getWarnMessage(code, ...args) { | ||
return shared.format(warnMessages[code], ...args); | ||
} | ||
/** | ||
* Fallback with simple implemenation | ||
* | ||
* @remarks | ||
* A fallback locale function implemented with a simple fallback algorithm. | ||
* | ||
* Basically, it returns the value as specified in the `fallbackLocale` props, and is processed with the fallback inside intlify. | ||
* | ||
* @param ctx - A {@link CoreContext | context} | ||
* @param fallback - A {@link FallbackLocale | fallback locale} | ||
* @param start - A starting {@link Locale | locale} | ||
* | ||
* @returns Fallback locales | ||
* | ||
* @VueI18nGeneral | ||
*/ | ||
function fallbackWithSimple(ctx, fallback, start // eslint-disable-line @typescript-eslint/no-unused-vars | ||
) { | ||
// prettier-ignore | ||
return [...new Set([ | ||
start, | ||
...(shared.isArray(fallback) | ||
? fallback | ||
: shared.isObject(fallback) | ||
? Object.keys(fallback) | ||
: shared.isString(fallback) | ||
? [fallback] | ||
: [start]) | ||
])]; | ||
} | ||
/** | ||
* Fallback with locale chain | ||
* | ||
* @remarks | ||
* A fallback locale function implemented with a fallback chain algorithm. It's used in VueI18n as default. | ||
* | ||
* @param ctx - A {@link CoreContext | context} | ||
* @param fallback - A {@link FallbackLocale | fallback locale} | ||
* @param start - A starting {@link Locale | locale} | ||
* | ||
* @returns Fallback locales | ||
* | ||
* @VueI18nSee [Fallbacking](../guide/essentials/fallback) | ||
* | ||
* @VueI18nGeneral | ||
*/ | ||
function fallbackWithLocaleChain(ctx, fallback, start) { | ||
const startLocale = shared.isString(start) ? start : DEFAULT_LOCALE; | ||
const context = ctx; | ||
if (!context.__localeChainCache) { | ||
context.__localeChainCache = new Map(); | ||
} | ||
let chain = context.__localeChainCache.get(startLocale); | ||
if (!chain) { | ||
chain = []; | ||
// first block defined by start | ||
let block = [start]; | ||
// while any intervening block found | ||
while (shared.isArray(block)) { | ||
block = appendBlockToChain(chain, block, fallback); | ||
} | ||
// prettier-ignore | ||
// last block defined by default | ||
const defaults = shared.isArray(fallback) || !shared.isPlainObject(fallback) | ||
? fallback | ||
: fallback['default'] | ||
? fallback['default'] | ||
: null; | ||
// convert defaults to array | ||
block = shared.isString(defaults) ? [defaults] : defaults; | ||
if (shared.isArray(block)) { | ||
appendBlockToChain(chain, block, false); | ||
} | ||
context.__localeChainCache.set(startLocale, chain); | ||
} | ||
return chain; | ||
} | ||
function appendBlockToChain(chain, block, blocks) { | ||
let follow = true; | ||
for (let i = 0; i < block.length && shared.isBoolean(follow); i++) { | ||
const locale = block[i]; | ||
if (shared.isString(locale)) { | ||
follow = appendLocaleToChain(chain, block[i], blocks); | ||
} | ||
} | ||
return follow; | ||
} | ||
function appendLocaleToChain(chain, locale, blocks) { | ||
let follow; | ||
const tokens = locale.split('-'); | ||
do { | ||
const target = tokens.join('-'); | ||
follow = appendItemToChain(chain, target, blocks); | ||
tokens.splice(-1, 1); | ||
} while (tokens.length && follow === true); | ||
return follow; | ||
} | ||
function appendItemToChain(chain, target, blocks) { | ||
let follow = false; | ||
if (!chain.includes(target)) { | ||
follow = true; | ||
if (target) { | ||
follow = target[target.length - 1] !== '!'; | ||
const locale = target.replace(/!/g, ''); | ||
chain.push(locale); | ||
if ((shared.isArray(blocks) || shared.isPlainObject(blocks)) && | ||
blocks[locale] // eslint-disable-line @typescript-eslint/no-explicit-any | ||
) { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
follow = blocks[locale]; | ||
} | ||
} | ||
} | ||
return follow; | ||
} | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/** | ||
* Intlify core-base version | ||
* @internal | ||
*/ | ||
const VERSION = '9.3.0-beta.1'; | ||
const NOT_REOSLVED = -1; | ||
const DEFAULT_LOCALE = 'en-US'; | ||
const MISSING_RESOLVE_VALUE = ''; | ||
const capitalize = (str) => `${str.charAt(0).toLocaleUpperCase()}${str.substr(1)}`; | ||
function getDefaultLinkedModifiers() { | ||
return { | ||
upper: (val, type) => { | ||
// prettier-ignore | ||
return type === 'text' && shared.isString(val) | ||
? val.toUpperCase() | ||
: type === 'vnode' && shared.isObject(val) && '__v_isVNode' in val | ||
? val.children.toUpperCase() | ||
: val; | ||
}, | ||
lower: (val, type) => { | ||
// prettier-ignore | ||
return type === 'text' && shared.isString(val) | ||
? val.toLowerCase() | ||
: type === 'vnode' && shared.isObject(val) && '__v_isVNode' in val | ||
? val.children.toLowerCase() | ||
: val; | ||
}, | ||
capitalize: (val, type) => { | ||
// prettier-ignore | ||
return (type === 'text' && shared.isString(val) | ||
? capitalize(val) | ||
: type === 'vnode' && shared.isObject(val) && '__v_isVNode' in val | ||
? capitalize(val.children) | ||
: val); | ||
} | ||
}; | ||
} | ||
let _compiler; | ||
function registerMessageCompiler(compiler) { | ||
_compiler = compiler; | ||
} | ||
let _resolver; | ||
/** | ||
* Register the message resolver | ||
* | ||
* @param resolver - A {@link MessageResolver} function | ||
* | ||
* @VueI18nGeneral | ||
*/ | ||
function registerMessageResolver(resolver) { | ||
_resolver = resolver; | ||
} | ||
let _fallbacker; | ||
/** | ||
* Register the locale fallbacker | ||
* | ||
* @param fallbacker - A {@link LocaleFallbacker} function | ||
* | ||
* @VueI18nGeneral | ||
*/ | ||
function registerLocaleFallbacker(fallbacker) { | ||
_fallbacker = fallbacker; | ||
} | ||
// Additional Meta for Intlify DevTools | ||
let _additionalMeta = null; | ||
const setAdditionalMeta = (meta) => { | ||
_additionalMeta = meta; | ||
}; | ||
const getAdditionalMeta = () => _additionalMeta; | ||
let _fallbackContext = null; | ||
const setFallbackContext = (context) => { | ||
_fallbackContext = context; | ||
}; | ||
const getFallbackContext = () => _fallbackContext; | ||
// ID for CoreContext | ||
let _cid = 0; | ||
function createCoreContext(options = {}) { | ||
// setup options | ||
const version = shared.isString(options.version) ? options.version : VERSION; | ||
const locale = shared.isString(options.locale) ? options.locale : DEFAULT_LOCALE; | ||
const fallbackLocale = shared.isArray(options.fallbackLocale) || | ||
shared.isPlainObject(options.fallbackLocale) || | ||
shared.isString(options.fallbackLocale) || | ||
options.fallbackLocale === false | ||
? options.fallbackLocale | ||
: locale; | ||
const messages = shared.isPlainObject(options.messages) | ||
? options.messages | ||
: { [locale]: {} }; | ||
const datetimeFormats = shared.isPlainObject(options.datetimeFormats) | ||
? options.datetimeFormats | ||
: { [locale]: {} } | ||
; | ||
const numberFormats = shared.isPlainObject(options.numberFormats) | ||
? options.numberFormats | ||
: { [locale]: {} } | ||
; | ||
const modifiers = shared.assign({}, options.modifiers || {}, getDefaultLinkedModifiers()); | ||
const pluralRules = options.pluralRules || {}; | ||
const missing = shared.isFunction(options.missing) ? options.missing : null; | ||
const missingWarn = shared.isBoolean(options.missingWarn) || shared.isRegExp(options.missingWarn) | ||
? options.missingWarn | ||
: true; | ||
const fallbackWarn = shared.isBoolean(options.fallbackWarn) || shared.isRegExp(options.fallbackWarn) | ||
? options.fallbackWarn | ||
: true; | ||
const fallbackFormat = !!options.fallbackFormat; | ||
const unresolving = !!options.unresolving; | ||
const postTranslation = shared.isFunction(options.postTranslation) | ||
? options.postTranslation | ||
: null; | ||
const processor = shared.isPlainObject(options.processor) ? options.processor : null; | ||
const warnHtmlMessage = shared.isBoolean(options.warnHtmlMessage) | ||
? options.warnHtmlMessage | ||
: true; | ||
const escapeParameter = !!options.escapeParameter; | ||
const messageCompiler = shared.isFunction(options.messageCompiler) | ||
? options.messageCompiler | ||
: _compiler; | ||
const messageResolver = shared.isFunction(options.messageResolver) | ||
? options.messageResolver | ||
: _resolver || resolveWithKeyValue; | ||
const localeFallbacker = shared.isFunction(options.localeFallbacker) | ||
? options.localeFallbacker | ||
: _fallbacker || fallbackWithSimple; | ||
const fallbackContext = shared.isObject(options.fallbackContext) | ||
? options.fallbackContext | ||
: undefined; | ||
const onWarn = shared.isFunction(options.onWarn) ? options.onWarn : shared.warn; | ||
// setup internal options | ||
const internalOptions = options; | ||
const __datetimeFormatters = shared.isObject(internalOptions.__datetimeFormatters) | ||
? internalOptions.__datetimeFormatters | ||
: new Map() | ||
; | ||
const __numberFormatters = shared.isObject(internalOptions.__numberFormatters) | ||
? internalOptions.__numberFormatters | ||
: new Map() | ||
; | ||
const __meta = shared.isObject(internalOptions.__meta) ? internalOptions.__meta : {}; | ||
_cid++; | ||
const context = { | ||
version, | ||
cid: _cid, | ||
locale, | ||
fallbackLocale, | ||
messages, | ||
modifiers, | ||
pluralRules, | ||
missing, | ||
missingWarn, | ||
fallbackWarn, | ||
fallbackFormat, | ||
unresolving, | ||
postTranslation, | ||
processor, | ||
warnHtmlMessage, | ||
escapeParameter, | ||
messageCompiler, | ||
messageResolver, | ||
localeFallbacker, | ||
fallbackContext, | ||
onWarn, | ||
__meta | ||
}; | ||
{ | ||
context.datetimeFormats = datetimeFormats; | ||
context.numberFormats = numberFormats; | ||
context.__datetimeFormatters = __datetimeFormatters; | ||
context.__numberFormatters = __numberFormatters; | ||
} | ||
return context; | ||
} | ||
/** @internal */ | ||
function isTranslateFallbackWarn(fallback, key) { | ||
return fallback instanceof RegExp ? fallback.test(key) : fallback; | ||
} | ||
/** @internal */ | ||
function isTranslateMissingWarn(missing, key) { | ||
return missing instanceof RegExp ? missing.test(key) : missing; | ||
} | ||
/** @internal */ | ||
function handleMissing(context, key, locale, missingWarn, type) { | ||
const { missing, onWarn } = context; | ||
if (missing !== null) { | ||
const ret = missing(context, locale, key, type); | ||
return shared.isString(ret) ? ret : key; | ||
} | ||
else { | ||
return key; | ||
} | ||
} | ||
/** @internal */ | ||
function updateFallbackLocale(ctx, locale, fallback) { | ||
const context = ctx; | ||
context.__localeChainCache = new Map(); | ||
ctx.localeFallbacker(ctx, fallback, locale); | ||
} | ||
/* eslint-enable @typescript-eslint/no-explicit-any */ | ||
const defaultOnCacheKey = (source) => source; | ||
let compileCache = Object.create(null); | ||
function clearCompileCache() { | ||
compileCache = Object.create(null); | ||
} | ||
function compileToFunction(source, options = {}) { | ||
{ | ||
// check caches | ||
const onCacheKey = options.onCacheKey || defaultOnCacheKey; | ||
const key = onCacheKey(source); | ||
const cached = compileCache[key]; | ||
if (cached) { | ||
return cached; | ||
} | ||
// compile error detecting | ||
let occurred = false; | ||
const onError = options.onError || messageCompiler.defaultOnError; | ||
options.onError = (err) => { | ||
occurred = true; | ||
onError(err); | ||
}; | ||
// compile | ||
const { code } = messageCompiler.baseCompile(source, options); | ||
// evaluate function | ||
const msg = new Function(`return ${code}`)(); | ||
// if occurred compile error, don't cache | ||
return !occurred ? (compileCache[key] = msg) : msg; | ||
} | ||
} | ||
let code = messageCompiler.CompileErrorCodes.__EXTEND_POINT__; | ||
const inc = () => ++code; | ||
const CoreErrorCodes = { | ||
INVALID_ARGUMENT: code, | ||
INVALID_DATE_ARGUMENT: inc(), | ||
INVALID_ISO_DATE_ARGUMENT: inc(), | ||
__EXTEND_POINT__: inc() // 18 | ||
}; | ||
function createCoreError(code) { | ||
return messageCompiler.createCompileError(code, null, undefined); | ||
} | ||
/** @internal */ | ||
({ | ||
[CoreErrorCodes.INVALID_ARGUMENT]: 'Invalid arguments', | ||
[CoreErrorCodes.INVALID_DATE_ARGUMENT]: 'The date provided is an invalid Date object.' + | ||
'Make sure your Date represents a valid date.', | ||
[CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT]: 'The argument provided is not a valid ISO date string' | ||
}); | ||
const NOOP_MESSAGE_FUNCTION = () => ''; | ||
const isMessageFunction = (val) => shared.isFunction(val); | ||
// implementation of `translate` function | ||
function translate(context, ...args) { | ||
const { fallbackFormat, postTranslation, unresolving, messageCompiler, fallbackLocale, messages } = context; | ||
const [key, options] = parseTranslateArgs(...args); | ||
const missingWarn = shared.isBoolean(options.missingWarn) | ||
? options.missingWarn | ||
: context.missingWarn; | ||
const fallbackWarn = shared.isBoolean(options.fallbackWarn) | ||
? options.fallbackWarn | ||
: context.fallbackWarn; | ||
const escapeParameter = shared.isBoolean(options.escapeParameter) | ||
? options.escapeParameter | ||
: context.escapeParameter; | ||
const resolvedMessage = !!options.resolvedMessage; | ||
// prettier-ignore | ||
const defaultMsgOrKey = shared.isString(options.default) || shared.isBoolean(options.default) // default by function option | ||
? !shared.isBoolean(options.default) | ||
? options.default | ||
: (!messageCompiler ? () => key : key) | ||
: fallbackFormat // default by `fallbackFormat` option | ||
? (!messageCompiler ? () => key : key) | ||
: ''; | ||
const enableDefaultMsg = fallbackFormat || defaultMsgOrKey !== ''; | ||
const locale = shared.isString(options.locale) ? options.locale : context.locale; | ||
// escape params | ||
escapeParameter && escapeParams(options); | ||
// resolve message format | ||
// eslint-disable-next-line prefer-const | ||
let [formatScope, targetLocale, message] = !resolvedMessage | ||
? resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) | ||
: [ | ||
key, | ||
locale, | ||
messages[locale] || {} | ||
]; | ||
// NOTE: | ||
// Fix to work around `ssrTransfrom` bug in Vite. | ||
// https://github.com/vitejs/vite/issues/4306 | ||
// To get around this, use temporary variables. | ||
// https://github.com/nuxt/framework/issues/1461#issuecomment-954606243 | ||
let format = formatScope; | ||
// if you use default message, set it as message format! | ||
let cacheBaseKey = key; | ||
if (!resolvedMessage && | ||
!(shared.isString(format) || isMessageFunction(format))) { | ||
if (enableDefaultMsg) { | ||
format = defaultMsgOrKey; | ||
cacheBaseKey = format; | ||
} | ||
} | ||
// checking message format and target locale | ||
if (!resolvedMessage && | ||
(!(shared.isString(format) || isMessageFunction(format)) || | ||
!shared.isString(targetLocale))) { | ||
return unresolving ? NOT_REOSLVED : key; | ||
} | ||
// setup compile error detecting | ||
let occurred = false; | ||
const errorDetector = () => { | ||
occurred = true; | ||
}; | ||
// compile message format | ||
const msg = !isMessageFunction(format) | ||
? compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, errorDetector) | ||
: format; | ||
// if occurred compile error, return the message format | ||
if (occurred) { | ||
return format; | ||
} | ||
// evaluate message with context | ||
const ctxOptions = getMessageContextOptions(context, targetLocale, message, options); | ||
const msgContext = createMessageContext(ctxOptions); | ||
const messaged = evaluateMessage(context, msg, msgContext); | ||
// if use post translation option, proceed it with handler | ||
const ret = postTranslation | ||
? postTranslation(messaged, key) | ||
: messaged; | ||
return ret; | ||
} | ||
function escapeParams(options) { | ||
if (shared.isArray(options.list)) { | ||
options.list = options.list.map(item => shared.isString(item) ? shared.escapeHtml(item) : item); | ||
} | ||
else if (shared.isObject(options.named)) { | ||
Object.keys(options.named).forEach(key => { | ||
if (shared.isString(options.named[key])) { | ||
options.named[key] = shared.escapeHtml(options.named[key]); | ||
} | ||
}); | ||
} | ||
} | ||
function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) { | ||
const { messages, onWarn, messageResolver: resolveValue, localeFallbacker } = context; | ||
const locales = localeFallbacker(context, fallbackLocale, locale); // eslint-disable-line @typescript-eslint/no-explicit-any | ||
let message = {}; | ||
let targetLocale; | ||
let format = null; | ||
const type = 'translate'; | ||
for (let i = 0; i < locales.length; i++) { | ||
targetLocale = locales[i]; | ||
message = | ||
messages[targetLocale] || {}; | ||
if ((format = resolveValue(message, key)) === null) { | ||
// if null, resolve with object key path | ||
format = message[key]; // eslint-disable-line @typescript-eslint/no-explicit-any | ||
} | ||
if (shared.isString(format) || shared.isFunction(format)) | ||
break; | ||
const missingRet = handleMissing(context, // eslint-disable-line @typescript-eslint/no-explicit-any | ||
key, targetLocale, missingWarn, type); | ||
if (missingRet !== key) { | ||
format = missingRet; | ||
} | ||
} | ||
return [format, targetLocale, message]; | ||
} | ||
function compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, errorDetector) { | ||
const { messageCompiler, warnHtmlMessage } = context; | ||
if (isMessageFunction(format)) { | ||
const msg = format; | ||
msg.locale = msg.locale || targetLocale; | ||
msg.key = msg.key || key; | ||
return msg; | ||
} | ||
if (messageCompiler == null) { | ||
const msg = (() => format); | ||
msg.locale = targetLocale; | ||
msg.key = key; | ||
return msg; | ||
} | ||
const msg = messageCompiler(format, getCompileOptions(context, targetLocale, cacheBaseKey, format, warnHtmlMessage, errorDetector)); | ||
msg.locale = targetLocale; | ||
msg.key = key; | ||
msg.source = format; | ||
return msg; | ||
} | ||
function evaluateMessage(context, msg, msgCtx) { | ||
const messaged = msg(msgCtx); | ||
return messaged; | ||
} | ||
/** @internal */ | ||
function parseTranslateArgs(...args) { | ||
const [arg1, arg2, arg3] = args; | ||
const options = {}; | ||
if (!shared.isString(arg1) && !shared.isNumber(arg1) && !isMessageFunction(arg1)) { | ||
throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); | ||
} | ||
// prettier-ignore | ||
const key = shared.isNumber(arg1) | ||
? String(arg1) | ||
: isMessageFunction(arg1) | ||
? arg1 | ||
: arg1; | ||
if (shared.isNumber(arg2)) { | ||
options.plural = arg2; | ||
} | ||
else if (shared.isString(arg2)) { | ||
options.default = arg2; | ||
} | ||
else if (shared.isPlainObject(arg2) && !shared.isEmptyObject(arg2)) { | ||
options.named = arg2; | ||
} | ||
else if (shared.isArray(arg2)) { | ||
options.list = arg2; | ||
} | ||
if (shared.isNumber(arg3)) { | ||
options.plural = arg3; | ||
} | ||
else if (shared.isString(arg3)) { | ||
options.default = arg3; | ||
} | ||
else if (shared.isPlainObject(arg3)) { | ||
shared.assign(options, arg3); | ||
} | ||
return [key, options]; | ||
} | ||
function getCompileOptions(context, locale, key, source, warnHtmlMessage, errorDetector) { | ||
return { | ||
warnHtmlMessage, | ||
onError: (err) => { | ||
errorDetector && errorDetector(err); | ||
{ | ||
throw err; | ||
} | ||
}, | ||
onCacheKey: (source) => shared.generateFormatCacheKey(locale, key, source) | ||
}; | ||
} | ||
function getMessageContextOptions(context, locale, message, options) { | ||
const { modifiers, pluralRules, messageResolver: resolveValue, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context; | ||
const resolveMessage = (key) => { | ||
let val = resolveValue(message, key); | ||
// fallback to root context | ||
if (val == null && fallbackContext) { | ||
const [, , message] = resolveMessageFormat(fallbackContext, key, locale, fallbackLocale, fallbackWarn, missingWarn); | ||
val = resolveValue(message, key); | ||
} | ||
if (shared.isString(val)) { | ||
let occurred = false; | ||
const errorDetector = () => { | ||
occurred = true; | ||
}; | ||
const msg = compileMessageFormat(context, key, locale, val, key, errorDetector); | ||
return !occurred | ||
? msg | ||
: NOOP_MESSAGE_FUNCTION; | ||
} | ||
else if (isMessageFunction(val)) { | ||
return val; | ||
} | ||
else { | ||
// TODO: should be implemented warning message | ||
return NOOP_MESSAGE_FUNCTION; | ||
} | ||
}; | ||
const ctxOptions = { | ||
locale, | ||
modifiers, | ||
pluralRules, | ||
messages: resolveMessage | ||
}; | ||
if (context.processor) { | ||
ctxOptions.processor = context.processor; | ||
} | ||
if (options.list) { | ||
ctxOptions.list = options.list; | ||
} | ||
if (options.named) { | ||
ctxOptions.named = options.named; | ||
} | ||
if (shared.isNumber(options.plural)) { | ||
ctxOptions.pluralIndex = options.plural; | ||
} | ||
return ctxOptions; | ||
} | ||
// implementation of `datetime` function | ||
function datetime(context, ...args) { | ||
const { datetimeFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; | ||
const { __datetimeFormatters } = context; | ||
const [key, value, options, overrides] = parseDateTimeArgs(...args); | ||
const missingWarn = shared.isBoolean(options.missingWarn) | ||
? options.missingWarn | ||
: context.missingWarn; | ||
shared.isBoolean(options.fallbackWarn) | ||
? options.fallbackWarn | ||
: context.fallbackWarn; | ||
const part = !!options.part; | ||
const locale = shared.isString(options.locale) ? options.locale : context.locale; | ||
const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any | ||
fallbackLocale, locale); | ||
if (!shared.isString(key) || key === '') { | ||
return new Intl.DateTimeFormat(locale, overrides).format(value); | ||
} | ||
// resolve format | ||
let datetimeFormat = {}; | ||
let targetLocale; | ||
let format = null; | ||
const type = 'datetime format'; | ||
for (let i = 0; i < locales.length; i++) { | ||
targetLocale = locales[i]; | ||
datetimeFormat = | ||
datetimeFormats[targetLocale] || {}; | ||
format = datetimeFormat[key]; | ||
if (shared.isPlainObject(format)) | ||
break; | ||
handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any | ||
} | ||
// checking format and target locale | ||
if (!shared.isPlainObject(format) || !shared.isString(targetLocale)) { | ||
return unresolving ? NOT_REOSLVED : key; | ||
} | ||
let id = `${targetLocale}__${key}`; | ||
if (!shared.isEmptyObject(overrides)) { | ||
id = `${id}__${JSON.stringify(overrides)}`; | ||
} | ||
let formatter = __datetimeFormatters.get(id); | ||
if (!formatter) { | ||
formatter = new Intl.DateTimeFormat(targetLocale, shared.assign({}, format, overrides)); | ||
__datetimeFormatters.set(id, formatter); | ||
} | ||
return !part ? formatter.format(value) : formatter.formatToParts(value); | ||
} | ||
/** @internal */ | ||
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' | ||
]; | ||
/** @internal */ | ||
function parseDateTimeArgs(...args) { | ||
const [arg1, arg2, arg3, arg4] = args; | ||
const options = {}; | ||
let overrides = {}; | ||
let value; | ||
if (shared.isString(arg1)) { | ||
// Only allow ISO strings - other date formats are often supported, | ||
// but may cause different results in different browsers. | ||
const matches = arg1.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/); | ||
if (!matches) { | ||
throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); | ||
} | ||
// Some browsers can not parse the iso datetime separated by space, | ||
// this is a compromise solution by replace the 'T'/' ' with 'T' | ||
const dateTime = matches[3] | ||
? matches[3].trim().startsWith('T') | ||
? `${matches[1].trim()}${matches[3].trim()}` | ||
: `${matches[1].trim()}T${matches[3].trim()}` | ||
: matches[1].trim(); | ||
value = new Date(dateTime); | ||
try { | ||
// This will fail if the date is not valid | ||
value.toISOString(); | ||
} | ||
catch (e) { | ||
throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); | ||
} | ||
} | ||
else if (shared.isDate(arg1)) { | ||
if (isNaN(arg1.getTime())) { | ||
throw createCoreError(CoreErrorCodes.INVALID_DATE_ARGUMENT); | ||
} | ||
value = arg1; | ||
} | ||
else if (shared.isNumber(arg1)) { | ||
value = arg1; | ||
} | ||
else { | ||
throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); | ||
} | ||
if (shared.isString(arg2)) { | ||
options.key = arg2; | ||
} | ||
else if (shared.isPlainObject(arg2)) { | ||
Object.keys(arg2).forEach(key => { | ||
if (DATETIME_FORMAT_OPTIONS_KEYS.includes(key)) { | ||
overrides[key] = arg2[key]; | ||
} | ||
else { | ||
options[key] = arg2[key]; | ||
} | ||
}); | ||
} | ||
if (shared.isString(arg3)) { | ||
options.locale = arg3; | ||
} | ||
else if (shared.isPlainObject(arg3)) { | ||
overrides = arg3; | ||
} | ||
if (shared.isPlainObject(arg4)) { | ||
overrides = arg4; | ||
} | ||
return [options.key || '', value, options, overrides]; | ||
} | ||
/** @internal */ | ||
function clearDateTimeFormat(ctx, locale, format) { | ||
const context = ctx; | ||
for (const key in format) { | ||
const id = `${locale}__${key}`; | ||
if (!context.__datetimeFormatters.has(id)) { | ||
continue; | ||
} | ||
context.__datetimeFormatters.delete(id); | ||
} | ||
} | ||
// implementation of `number` function | ||
function number(context, ...args) { | ||
const { numberFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; | ||
const { __numberFormatters } = context; | ||
const [key, value, options, overrides] = parseNumberArgs(...args); | ||
const missingWarn = shared.isBoolean(options.missingWarn) | ||
? options.missingWarn | ||
: context.missingWarn; | ||
shared.isBoolean(options.fallbackWarn) | ||
? options.fallbackWarn | ||
: context.fallbackWarn; | ||
const part = !!options.part; | ||
const locale = shared.isString(options.locale) ? options.locale : context.locale; | ||
const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any | ||
fallbackLocale, locale); | ||
if (!shared.isString(key) || key === '') { | ||
return new Intl.NumberFormat(locale, overrides).format(value); | ||
} | ||
// resolve format | ||
let numberFormat = {}; | ||
let targetLocale; | ||
let format = null; | ||
const type = 'number format'; | ||
for (let i = 0; i < locales.length; i++) { | ||
targetLocale = locales[i]; | ||
numberFormat = | ||
numberFormats[targetLocale] || {}; | ||
format = numberFormat[key]; | ||
if (shared.isPlainObject(format)) | ||
break; | ||
handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any | ||
} | ||
// checking format and target locale | ||
if (!shared.isPlainObject(format) || !shared.isString(targetLocale)) { | ||
return unresolving ? NOT_REOSLVED : key; | ||
} | ||
let id = `${targetLocale}__${key}`; | ||
if (!shared.isEmptyObject(overrides)) { | ||
id = `${id}__${JSON.stringify(overrides)}`; | ||
} | ||
let formatter = __numberFormatters.get(id); | ||
if (!formatter) { | ||
formatter = new Intl.NumberFormat(targetLocale, shared.assign({}, format, overrides)); | ||
__numberFormatters.set(id, formatter); | ||
} | ||
return !part ? formatter.format(value) : formatter.formatToParts(value); | ||
} | ||
/** @internal */ | ||
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' | ||
]; | ||
/** @internal */ | ||
function parseNumberArgs(...args) { | ||
const [arg1, arg2, arg3, arg4] = args; | ||
const options = {}; | ||
let overrides = {}; | ||
if (!shared.isNumber(arg1)) { | ||
throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); | ||
} | ||
const value = arg1; | ||
if (shared.isString(arg2)) { | ||
options.key = arg2; | ||
} | ||
else if (shared.isPlainObject(arg2)) { | ||
Object.keys(arg2).forEach(key => { | ||
if (NUMBER_FORMAT_OPTIONS_KEYS.includes(key)) { | ||
overrides[key] = arg2[key]; | ||
} | ||
else { | ||
options[key] = arg2[key]; | ||
} | ||
}); | ||
} | ||
if (shared.isString(arg3)) { | ||
options.locale = arg3; | ||
} | ||
else if (shared.isPlainObject(arg3)) { | ||
overrides = arg3; | ||
} | ||
if (shared.isPlainObject(arg4)) { | ||
overrides = arg4; | ||
} | ||
return [options.key || '', value, options, overrides]; | ||
} | ||
/** @internal */ | ||
function clearNumberFormat(ctx, locale, format) { | ||
const context = ctx; | ||
for (const key in format) { | ||
const id = `${locale}__${key}`; | ||
if (!context.__numberFormatters.has(id)) { | ||
continue; | ||
} | ||
context.__numberFormatters.delete(id); | ||
} | ||
} | ||
exports.CompileErrorCodes = messageCompiler.CompileErrorCodes; | ||
exports.createCompileError = messageCompiler.createCompileError; | ||
exports.CoreErrorCodes = CoreErrorCodes; | ||
exports.CoreWarnCodes = CoreWarnCodes; | ||
exports.DATETIME_FORMAT_OPTIONS_KEYS = DATETIME_FORMAT_OPTIONS_KEYS; | ||
exports.DEFAULT_LOCALE = DEFAULT_LOCALE; | ||
exports.DEFAULT_MESSAGE_DATA_TYPE = DEFAULT_MESSAGE_DATA_TYPE; | ||
exports.MISSING_RESOLVE_VALUE = MISSING_RESOLVE_VALUE; | ||
exports.NOT_REOSLVED = NOT_REOSLVED; | ||
exports.NUMBER_FORMAT_OPTIONS_KEYS = NUMBER_FORMAT_OPTIONS_KEYS; | ||
exports.VERSION = VERSION; | ||
exports.clearCompileCache = clearCompileCache; | ||
exports.clearDateTimeFormat = clearDateTimeFormat; | ||
exports.clearNumberFormat = clearNumberFormat; | ||
exports.compileToFunction = compileToFunction; | ||
exports.createCoreContext = createCoreContext; | ||
exports.createCoreError = createCoreError; | ||
exports.createMessageContext = createMessageContext; | ||
exports.datetime = datetime; | ||
exports.fallbackWithLocaleChain = fallbackWithLocaleChain; | ||
exports.fallbackWithSimple = fallbackWithSimple; | ||
exports.getAdditionalMeta = getAdditionalMeta; | ||
exports.getDevToolsHook = getDevToolsHook; | ||
exports.getFallbackContext = getFallbackContext; | ||
exports.getWarnMessage = getWarnMessage; | ||
exports.handleMissing = handleMissing; | ||
exports.initI18nDevTools = initI18nDevTools; | ||
exports.isMessageFunction = isMessageFunction; | ||
exports.isTranslateFallbackWarn = isTranslateFallbackWarn; | ||
exports.isTranslateMissingWarn = isTranslateMissingWarn; | ||
exports.number = number; | ||
exports.parse = parse; | ||
exports.parseDateTimeArgs = parseDateTimeArgs; | ||
exports.parseNumberArgs = parseNumberArgs; | ||
exports.parseTranslateArgs = parseTranslateArgs; | ||
exports.registerLocaleFallbacker = registerLocaleFallbacker; | ||
exports.registerMessageCompiler = registerMessageCompiler; | ||
exports.registerMessageResolver = registerMessageResolver; | ||
exports.resolveValue = resolveValue; | ||
exports.resolveWithKeyValue = resolveWithKeyValue; | ||
exports.setAdditionalMeta = setAdditionalMeta; | ||
exports.setDevToolsHook = setDevToolsHook; | ||
exports.setFallbackContext = setFallbackContext; | ||
exports.translate = translate; | ||
exports.translateDevTools = translateDevTools; | ||
exports.updateFallbackLocale = updateFallbackLocale; | ||
module.exports = require('../dist/core-base.prod.cjs') |
/*! | ||
* core-base v9.3.0-beta.1 | ||
* core-base v9.3.0-beta.2 | ||
* (c) 2022 kazuya kawaguchi | ||
* Released under the MIT License. | ||
*/ | ||
var IntlifyCoreBase=function(e){"use strict";const t=/\{([0-9a-zA-Z]+)\}/g;const n=e=>JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029").replace(/\u0027/g,"\\u0027"),r=e=>"number"==typeof e&&isFinite(e),o=e=>"[object RegExp]"===_(e),a=e=>k(e)&&0===Object.keys(e).length;function s(e,t){"undefined"!=typeof console&&(console.warn("[intlify] "+e),t&&console.warn(t.stack))}const c=Object.assign;function l(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const u=Array.isArray,i=e=>"function"==typeof e,f=e=>"string"==typeof e,m=e=>"boolean"==typeof e,p=e=>null!==e&&"object"==typeof e,d=Object.prototype.toString,_=e=>d.call(e),k=e=>"[object Object]"===_(e),h={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,__EXTEND_POINT__:15};function g(e,t,n={}){const{domain:r,messages:o,args:a}=n,s=new SyntaxError(String(e));return s.code=e,t&&(s.location=t),s.domain=r,s}function T(e){throw e}function b(e,t,n){const r={start:e,end:t};return null!=n&&(r.source=n),r}const E=" ",L="\n",y=String.fromCharCode(8232),N=String.fromCharCode(8233);function C(e){const t=e;let n=0,r=1,o=1,a=0;const s=e=>"\r"===t[e]&&t[e+1]===L,c=e=>t[e]===N,l=e=>t[e]===y,u=e=>s(e)||(e=>t[e]===L)(e)||c(e)||l(e),i=e=>s(e)||c(e)||l(e)?L:t[e];function f(){return a=0,u(n)&&(r++,o=0),s(n)&&n++,n++,o++,t[n]}return{index:()=>n,line:()=>r,column:()=>o,peekOffset:()=>a,charAt:i,currentChar:()=>i(n),currentPeek:()=>i(n+a),next:f,peek:function(){return s(n+a)&&a++,a++,t[n+a]},reset:function(){n=0,r=1,o=1,a=0},resetPeek:function(e=0){a=e},skipToPeek:function(){const e=n+a;for(;e!==n;)f();a=0}}}const A=void 0;function O(e,t={}){const n=!1!==t.location,r=C(e),o=()=>r.index(),a=()=>{return e=r.line(),t=r.column(),n=r.index(),{line:e,column:t,offset:n};var e,t,n},s=a(),c=o(),l={currentType:14,offset:c,startLoc:s,endLoc:s,lastType:14,lastOffset:c,lastStartLoc:s,lastEndLoc:s,braceNest:0,inLinked:!1,text:""},u=()=>l,{onError:i}=t;function f(e,t,r){e.endLoc=a(),e.currentType=t;const o={type:t};return n&&(o.loc=b(e.startLoc,e.endLoc)),null!=r&&(o.value=r),o}const m=e=>f(e,14);function p(e,t){return e.currentChar()===t?(e.next(),t):(a(),"")}function d(e){let t="";for(;e.currentPeek()===E||e.currentPeek()===L;)t+=e.currentPeek(),e.peek();return t}function _(e){const t=d(e);return e.skipToPeek(),t}function k(e){if(e===A)return!1;const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||95===t}function h(e,t){const{currentType:n}=t;if(2!==n)return!1;d(e);const r=function(e){if(e===A)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}("-"===e.currentPeek()?e.peek():e.currentPeek());return e.resetPeek(),r}function g(e){d(e);const t="|"===e.currentPeek();return e.resetPeek(),t}function T(e,t=!0){const n=(t=!1,r="",o=!1)=>{const a=e.currentPeek();return"{"===a?"%"!==r&&t:"@"!==a&&a?"%"===a?(e.peek(),n(t,"%",!0)):"|"===a?!("%"!==r&&!o)||!(r===E||r===L):a===E?(e.peek(),n(!0,E,o)):a!==L||(e.peek(),n(!0,L,o)):"%"===r||t},r=n();return t&&e.resetPeek(),r}function y(e,t){const n=e.currentChar();return n===A?A:t(n)?(e.next(),n):null}function N(e){return y(e,(e=>{const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t}))}function O(e){return y(e,(e=>{const t=e.charCodeAt(0);return t>=48&&t<=57}))}function x(e){return y(e,(e=>{const t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}))}function v(e){let t="",n="";for(;t=O(e);)n+=t;return n}function I(e){let t="";for(;;){const n=e.currentChar();if("{"===n||"}"===n||"@"===n||"|"===n||!n)break;if("%"===n){if(!T(e))break;t+=n,e.next()}else if(n===E||n===L)if(T(e))t+=n,e.next();else{if(g(e))break;t+=n,e.next()}else t+=n,e.next()}return t}function S(e){const t=e.currentChar();switch(t){case"\\":case"'":return e.next(),`\\${t}`;case"u":return F(e,t,4);case"U":return F(e,t,6);default:return a(),""}}function F(e,t,n){p(e,t);let r="";for(let t=0;t<n;t++){const t=x(e);if(!t){a(),e.currentChar();break}r+=t}return`\\${t}${r}`}function P(e){_(e);const t=p(e,"|");return _(e),t}function D(e,t){let n=null;switch(e.currentChar()){case"{":return t.braceNest>=1&&a(),e.next(),n=f(t,2,"{"),_(e),t.braceNest++,n;case"}":return t.braceNest>0&&2===t.currentType&&a(),e.next(),n=f(t,3,"}"),t.braceNest--,t.braceNest>0&&_(e),t.inLinked&&0===t.braceNest&&(t.inLinked=!1),n;case"@":return t.braceNest>0&&a(),n=M(e,t)||m(t),t.braceNest=0,n;default:let r=!0,o=!0,s=!0;if(g(e))return t.braceNest>0&&a(),n=f(t,1,P(e)),t.braceNest=0,t.inLinked=!1,n;if(t.braceNest>0&&(5===t.currentType||6===t.currentType||7===t.currentType))return a(),t.braceNest=0,w(e,t);if(r=function(e,t){const{currentType:n}=t;if(2!==n)return!1;d(e);const r=k(e.currentPeek());return e.resetPeek(),r}(e,t))return n=f(t,5,function(e){_(e);let t="",n="";for(;t=N(e);)n+=t;return e.currentChar()===A&&a(),n}(e)),_(e),n;if(o=h(e,t))return n=f(t,6,function(e){_(e);let t="";return"-"===e.currentChar()?(e.next(),t+=`-${v(e)}`):t+=v(e),e.currentChar()===A&&a(),t}(e)),_(e),n;if(s=function(e,t){const{currentType:n}=t;if(2!==n)return!1;d(e);const r="'"===e.currentPeek();return e.resetPeek(),r}(e,t))return n=f(t,7,function(e){_(e),p(e,"'");let t="",n="";const r=e=>"'"!==e&&e!==L;for(;t=y(e,r);)n+="\\"===t?S(e):t;const o=e.currentChar();return o===L||o===A?(a(),o===L&&(e.next(),p(e,"'")),n):(p(e,"'"),n)}(e)),_(e),n;if(!r&&!o&&!s)return n=f(t,13,function(e){_(e);let t="",n="";const r=e=>"{"!==e&&"}"!==e&&e!==E&&e!==L;for(;t=y(e,r);)n+=t;return n}(e)),a(),n.value,_(e),n}return n}function M(e,t){const{currentType:n}=t;let r=null;const o=e.currentChar();switch(8!==n&&9!==n&&12!==n&&10!==n||o!==L&&o!==E||a(),o){case"@":return e.next(),r=f(t,8,"@"),t.inLinked=!0,r;case".":return _(e),e.next(),f(t,9,".");case":":return _(e),e.next(),f(t,10,":");default:return g(e)?(r=f(t,1,P(e)),t.braceNest=0,t.inLinked=!1,r):function(e,t){const{currentType:n}=t;if(8!==n)return!1;d(e);const r="."===e.currentPeek();return e.resetPeek(),r}(e,t)||function(e,t){const{currentType:n}=t;if(8!==n&&12!==n)return!1;d(e);const r=":"===e.currentPeek();return e.resetPeek(),r}(e,t)?(_(e),M(e,t)):function(e,t){const{currentType:n}=t;if(9!==n)return!1;d(e);const r=k(e.currentPeek());return e.resetPeek(),r}(e,t)?(_(e),f(t,12,function(e){let t="",n="";for(;t=N(e);)n+=t;return n}(e))):function(e,t){const{currentType:n}=t;if(10!==n)return!1;const r=()=>{const t=e.currentPeek();return"{"===t?k(e.peek()):!("@"===t||"%"===t||"|"===t||":"===t||"."===t||t===E||!t)&&(t===L?(e.peek(),r()):k(t))},o=r();return e.resetPeek(),o}(e,t)?(_(e),"{"===o?D(e,t)||r:f(t,11,function(e){const t=(n=!1,r)=>{const o=e.currentChar();return"{"!==o&&"%"!==o&&"@"!==o&&"|"!==o&&o?o===E?r:o===L?(r+=o,e.next(),t(n,r)):(r+=o,e.next(),t(!0,r)):r};return t(!1,"")}(e))):(8===n&&a(),t.braceNest=0,t.inLinked=!1,w(e,t))}}function w(e,t){let n={type:14};if(t.braceNest>0)return D(e,t)||m(t);if(t.inLinked)return M(e,t)||m(t);switch(e.currentChar()){case"{":return D(e,t)||m(t);case"}":return a(),e.next(),f(t,3,"}");case"@":return M(e,t)||m(t);default:if(g(e))return n=f(t,1,P(e)),t.braceNest=0,t.inLinked=!1,n;const{isModulo:r,hasSpace:o}=function(e){const t=d(e),n="%"===e.currentPeek()&&"{"===e.peek();return e.resetPeek(),{isModulo:n,hasSpace:t.length>0}}(e);if(r)return o?f(t,0,I(e)):f(t,4,function(e){_(e);return"%"!==e.currentChar()&&a(),e.next(),"%"}(e));if(T(e))return f(t,0,I(e))}return n}return{nextToken:function(){const{currentType:e,offset:t,startLoc:n,endLoc:s}=l;return l.lastType=e,l.lastOffset=t,l.lastStartLoc=n,l.lastEndLoc=s,l.offset=o(),l.startLoc=a(),r.currentChar()===A?f(l,14):w(r,l)},currentOffset:o,currentPosition:a,context:u}}const x=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function v(e,t,n){switch(e){case"\\\\":return"\\";case"\\'":return"'";default:{const e=parseInt(t||n,16);return e<=55295||e>=57344?String.fromCodePoint(e):"�"}}}function I(e={}){const t=!1!==e.location,{onError:n}=e;function r(e,n,r){const o={type:e,start:n,end:n};return t&&(o.loc={start:r,end:r}),o}function o(e,n,r,o){e.end=n,o&&(e.type=o),t&&e.loc&&(e.loc.end=r)}function a(e,t){const n=e.context(),a=r(3,n.offset,n.startLoc);return a.value=t,o(a,e.currentOffset(),e.currentPosition()),a}function s(e,t){const n=e.context(),{lastOffset:a,lastStartLoc:s}=n,c=r(5,a,s);return c.index=parseInt(t,10),e.nextToken(),o(c,e.currentOffset(),e.currentPosition()),c}function l(e,t){const n=e.context(),{lastOffset:a,lastStartLoc:s}=n,c=r(4,a,s);return c.key=t,e.nextToken(),o(c,e.currentOffset(),e.currentPosition()),c}function u(e,t){const n=e.context(),{lastOffset:a,lastStartLoc:s}=n,c=r(9,a,s);return c.value=t.replace(x,v),e.nextToken(),o(c,e.currentOffset(),e.currentPosition()),c}function i(e){const t=e.context(),n=r(6,t.offset,t.startLoc);let a=e.nextToken();if(9===a.type){const t=function(e){const t=e.nextToken(),n=e.context(),{lastOffset:a,lastStartLoc:s}=n,c=r(8,a,s);return 12!==t.type?(n.lastStartLoc,c.value="",o(c,a,s),{nextConsumeToken:t,node:c}):(null==t.value&&(n.lastStartLoc,S(t)),c.value=t.value||"",o(c,e.currentOffset(),e.currentPosition()),{node:c})}(e);n.modifier=t.node,a=t.nextConsumeToken||e.nextToken()}switch(10!==a.type&&(t.lastStartLoc,S(a)),a=e.nextToken(),2===a.type&&(a=e.nextToken()),a.type){case 11:null==a.value&&(t.lastStartLoc,S(a)),n.key=function(e,t){const n=e.context(),a=r(7,n.offset,n.startLoc);return a.value=t,o(a,e.currentOffset(),e.currentPosition()),a}(e,a.value||"");break;case 5:null==a.value&&(t.lastStartLoc,S(a)),n.key=l(e,a.value||"");break;case 6:null==a.value&&(t.lastStartLoc,S(a)),n.key=s(e,a.value||"");break;case 7:null==a.value&&(t.lastStartLoc,S(a)),n.key=u(e,a.value||"");break;default:t.lastStartLoc;const c=e.context(),i=r(7,c.offset,c.startLoc);return i.value="",o(i,c.offset,c.startLoc),n.key=i,o(n,c.offset,c.startLoc),{nextConsumeToken:a,node:n}}return o(n,e.currentOffset(),e.currentPosition()),{node:n}}function f(e){const t=e.context(),n=r(2,1===t.currentType?e.currentOffset():t.offset,1===t.currentType?t.endLoc:t.startLoc);n.items=[];let c=null;do{const r=c||e.nextToken();switch(c=null,r.type){case 0:null==r.value&&(t.lastStartLoc,S(r)),n.items.push(a(e,r.value||""));break;case 6:null==r.value&&(t.lastStartLoc,S(r)),n.items.push(s(e,r.value||""));break;case 5:null==r.value&&(t.lastStartLoc,S(r)),n.items.push(l(e,r.value||""));break;case 7:null==r.value&&(t.lastStartLoc,S(r)),n.items.push(u(e,r.value||""));break;case 8:const o=i(e);n.items.push(o.node),c=o.nextConsumeToken||null}}while(14!==t.currentType&&1!==t.currentType);return o(n,1===t.currentType?t.lastOffset:e.currentOffset(),1===t.currentType?t.lastEndLoc:e.currentPosition()),n}function m(e){const t=e.context(),{offset:n,startLoc:a}=t,s=f(e);return 14===t.currentType?s:function(e,t,n,a){const s=e.context();let c=0===a.items.length;const l=r(1,t,n);l.cases=[],l.cases.push(a);do{const t=f(e);c||(c=0===t.items.length),l.cases.push(t)}while(14!==s.currentType);return o(l,e.currentOffset(),e.currentPosition()),l}(e,n,a,s)}return{parse:function(n){const a=O(n,c({},e)),s=a.context(),l=r(0,s.offset,s.startLoc);return t&&l.loc&&(l.loc.source=n),l.body=m(a),14!==s.currentType&&(s.lastStartLoc,n[s.offset]),o(l,a.currentOffset(),a.currentPosition()),l}}}function S(e){if(14===e.type)return"EOF";const t=(e.value||"").replace(/\r?\n/gu,"\\n");return t.length>10?t.slice(0,9)+"…":t}function F(e,t){for(let n=0;n<e.length;n++)P(e[n],t)}function P(e,t){switch(e.type){case 1:F(e.cases,t),t.helper("plural");break;case 2:F(e.items,t);break;case 6:P(e.key,t),t.helper("linked"),t.helper("type");break;case 5:t.helper("interpolate"),t.helper("list");break;case 4:t.helper("interpolate"),t.helper("named")}}function D(e,t={}){const n=function(e,t={}){const n={ast:e,helpers:new Set};return{context:()=>n,helper:e=>(n.helpers.add(e),e)}}(e);n.helper("normalize"),e.body&&P(e.body,n);const r=n.context();e.helpers=Array.from(r.helpers)}function M(e,t){const{helper:n}=e;switch(t.type){case 0:!function(e,t){t.body?M(e,t.body):e.push("null")}(e,t);break;case 1:!function(e,t){const{helper:n,needIndent:r}=e;if(t.cases.length>1){e.push(`${n("plural")}([`),e.indent(r());const o=t.cases.length;for(let n=0;n<o&&(M(e,t.cases[n]),n!==o-1);n++)e.push(", ");e.deindent(r()),e.push("])")}}(e,t);break;case 2:!function(e,t){const{helper:n,needIndent:r}=e;e.push(`${n("normalize")}([`),e.indent(r());const o=t.items.length;for(let n=0;n<o&&(M(e,t.items[n]),n!==o-1);n++)e.push(", ");e.deindent(r()),e.push("])")}(e,t);break;case 6:!function(e,t){const{helper:n}=e;e.push(`${n("linked")}(`),M(e,t.key),t.modifier?(e.push(", "),M(e,t.modifier),e.push(", _type")):e.push(", undefined, _type"),e.push(")")}(e,t);break;case 8:case 7:case 9:case 3:e.push(JSON.stringify(t.value),t);break;case 5:e.push(`${n("interpolate")}(${n("list")}(${t.index}))`,t);break;case 4:e.push(`${n("interpolate")}(${n("named")}(${JSON.stringify(t.key)}))`,t)}}function w(e,t={}){const n=c({},t),r=I(n).parse(e);return D(r,n),((e,t={})=>{const n=f(t.mode)?t.mode:"normal",r=f(t.filename)?t.filename:"message.intl",o=!!t.sourceMap,a=null!=t.breakLineCode?t.breakLineCode:"arrow"===n?";":"\n",s=t.needIndent?t.needIndent:"arrow"!==n,c=e.helpers||[],l=function(e,t){const{sourceMap:n,filename:r,breakLineCode:o,needIndent:a}=t,s={source:e.loc.source,filename:r,code:"",column:1,line:1,offset:0,map:void 0,breakLineCode:o,needIndent:a,indentLevel:0};function c(e,t){s.code+=e}function l(e,t=!0){const n=t?o:"";c(a?n+" ".repeat(e):n)}return{context:()=>s,push:c,indent:function(e=!0){const t=++s.indentLevel;e&&l(t)},deindent:function(e=!0){const t=--s.indentLevel;e&&l(t)},newline:function(){l(s.indentLevel)},helper:e=>`_${e}`,needIndent:()=>s.needIndent}}(e,{mode:n,filename:r,sourceMap:o,breakLineCode:a,needIndent:s});l.push("normal"===n?"function __msg__ (ctx) {":"(ctx) => {"),l.indent(s),c.length>0&&(l.push(`const { ${c.map((e=>`${e}: _${e}`)).join(", ")} } = ctx`),l.newline()),l.push("return "),M(l,e),l.deindent(s),l.push("}");const{code:u,map:i}=l.context();return{ast:e,code:u,map:i?i.toJSON():void 0}})(r,n)}const R=[];R[0]={w:[0],i:[3,0],"[":[4],o:[7]},R[1]={w:[1],".":[2],"[":[4],o:[7]},R[2]={w:[2],i:[3,0],0:[3,0]},R[3]={i:[3,0],0:[3,0],w:[1,1],".":[2,1],"[":[4,1],o:[7,1]},R[4]={"'":[5,0],'"':[6,0],"[":[4,2],"]":[1,3],o:8,l:[4,0]},R[5]={"'":[4,0],o:8,l:[5,0]},R[6]={'"':[4,0],o:8,l:[6,0]};const W=/^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;function U(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 $(e){const t=e.trim();return("0"!==e.charAt(0)||!isNaN(parseInt(e)))&&(n=t,W.test(n)?function(e){const t=e.charCodeAt(0);return t!==e.charCodeAt(e.length-1)||34!==t&&39!==t?e:e.slice(1,-1)}(t):"*"+t);var n}function V(e){const t=[];let n,r,o,a,s,c,l,u=-1,i=0,f=0;const m=[];function p(){const t=e[u+1];if(5===i&&"'"===t||6===i&&'"'===t)return u++,o="\\"+t,m[0](),!0}for(m[0]=()=>{void 0===r?r=o:r+=o},m[1]=()=>{void 0!==r&&(t.push(r),r=void 0)},m[2]=()=>{m[0](),f++},m[3]=()=>{if(f>0)f--,i=4,m[0]();else{if(f=0,void 0===r)return!1;if(r=$(r),!1===r)return!1;m[1]()}};null!==i;)if(u++,n=e[u],"\\"!==n||!p()){if(a=U(n),l=R[i],s=l[a]||l.l||8,8===s)return;if(i=s[0],void 0!==s[1]&&(c=m[s[1]],c&&(o=n,!1===c())))return;if(7===i)return t}}const K=new Map;function j(e,t){return p(e)?e[t]:null}const G=e=>e,B=e=>"",H="text",Y=e=>0===e.length?"":e.join(""),X=e=>null==e?"":u(e)||k(e)&&e.toString===d?JSON.stringify(e,null,2):String(e);function z(e,t){return e=Math.abs(e),2===t?e?e>1?1:0:1:e?Math.min(e,2):0}function J(e={}){const t=e.locale,n=function(e){const t=r(e.pluralIndex)?e.pluralIndex:-1;return e.named&&(r(e.named.count)||r(e.named.n))?r(e.named.count)?e.named.count:r(e.named.n)?e.named.n:t:t}(e),o=p(e.pluralRules)&&f(t)&&i(e.pluralRules[t])?e.pluralRules[t]:z,a=p(e.pluralRules)&&f(t)&&i(e.pluralRules[t])?z:void 0,s=e.list||[],c=e.named||{};r(e.pluralIndex)&&function(e,t){t.count||(t.count=e),t.n||(t.n=e)}(n,c);function l(t){const n=i(e.messages)?e.messages(t):!!p(e.messages)&&e.messages[t];return n||(e.parent?e.parent.message(t):B)}const m=k(e.processor)&&i(e.processor.normalize)?e.processor.normalize:Y,d=k(e.processor)&&i(e.processor.interpolate)?e.processor.interpolate:X,_={list:e=>s[e],named:e=>c[e],plural:e=>e[o(n,e.length,a)],linked:(t,...n)=>{const[r,o]=n;let a="text",s="";1===n.length?p(r)?(s=r.modifier||s,a=r.type||a):f(r)&&(s=r||s):2===n.length&&(f(r)&&(s=r||s),f(o)&&(a=o||a));let c=l(t)(_);return"vnode"===a&&u(c)&&s&&(c=c[0]),s?(i=s,e.modifiers?e.modifiers[i]:G)(c,a):c;var i},message:l,type:k(e.processor)&&f(e.processor.type)?e.processor.type:H,interpolate:d,normalize:m};return _}const Z="i18n:init";let Q=null;const q=ee("function:translate");function ee(e){return t=>Q&&Q.emit(e,t)}const te={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,__EXTEND_POINT__:7},ne={[te.NOT_FOUND_KEY]:"Not found '{key}' key in '{locale}' locale messages.",[te.FALLBACK_TO_TRANSLATE]:"Fall back to translate '{key}' key with '{target}' locale.",[te.CANNOT_FORMAT_NUMBER]:"Cannot format a number value due to not supported Intl.NumberFormat.",[te.FALLBACK_TO_NUMBER_FORMAT]:"Fall back to number format '{key}' key with '{target}' locale.",[te.CANNOT_FORMAT_DATE]:"Cannot format a date value due to not supported Intl.DateTimeFormat.",[te.FALLBACK_TO_DATE_FORMAT]:"Fall back to datetime format '{key}' key with '{target}' locale."};function re(e,t,n){return[...new Set([n,...u(t)?t:p(t)?Object.keys(t):f(t)?[t]:[n]])]}function oe(e,t,n){let r=!0;for(let o=0;o<t.length&&m(r);o++){const a=t[o];f(a)&&(r=ae(e,t[o],n))}return r}function ae(e,t,n){let r;const o=t.split("-");do{r=se(e,o.join("-"),n),o.splice(-1,1)}while(o.length&&!0===r);return r}function se(e,t,n){let r=!1;if(!e.includes(t)&&(r=!0,t)){r="!"!==t[t.length-1];const o=t.replace(/!/g,"");e.push(o),(u(n)||k(n))&&n[o]&&(r=n[o])}return r}const ce="9.3.0-beta.1",le="en-US",ue=e=>`${e.charAt(0).toLocaleUpperCase()}${e.substr(1)}`;let ie,fe,me;let pe=null;let de=null;let _e=0;function ke(e,t,n,r,o){const{missing:a,onWarn:s}=e;if(null!==a){const r=a(e,n,t,o);return f(r)?r:t}return t}const he=e=>e;let ge=Object.create(null);let Te=h.__EXTEND_POINT__;const be=()=>++Te,Ee={INVALID_ARGUMENT:Te,INVALID_DATE_ARGUMENT:be(),INVALID_ISO_DATE_ARGUMENT:be(),__EXTEND_POINT__:be()};const Le=()=>"",ye=e=>i(e);function Ne(e,t,n,r,o,a){const{messages:s,onWarn:c,messageResolver:l,localeFallbacker:u}=e,m=u(e,r,n);let p,d={},_=null;for(let n=0;n<m.length&&(p=m[n],d=s[p]||{},null===(_=l(d,t))&&(_=d[t]),!f(_)&&!i(_));n++){const n=ke(e,t,p,0,"translate");n!==t&&(_=n)}return[_,p,d]}function Ce(e,t,r,o,a,s){const{messageCompiler:c,warnHtmlMessage:l}=e;if(ye(o)){const e=o;return e.locale=e.locale||r,e.key=e.key||t,e}if(null==c){const e=()=>o;return e.locale=r,e.key=t,e}const u=c(o,function(e,t,r,o,a,s){return{warnHtmlMessage:a,onError:e=>{throw s&&s(e),e},onCacheKey:e=>((e,t,r)=>n({l:e,k:t,s:r}))(t,r,e)}}(0,r,a,0,l,s));return u.locale=r,u.key=t,u.source=o,u}function Ae(...e){const[t,n,o]=e,s={};if(!f(t)&&!r(t)&&!ye(t))throw Error(Ee.INVALID_ARGUMENT);const l=r(t)?String(t):(ye(t),t);return r(n)?s.plural=n:f(n)?s.default=n:k(n)&&!a(n)?s.named=n:u(n)&&(s.list=n),r(o)?s.plural=o:f(o)?s.default=o:k(o)&&c(s,o),[l,s]}const Oe=["localeMatcher","weekday","era","year","month","day","hour","minute","second","timeZoneName","formatMatcher","hour12","timeZone","dateStyle","timeStyle","calendar","dayPeriod","numberingSystem","hourCycle","fractionalSecondDigits"];function xe(...e){const[t,n,o,a]=e,s={};let c,l={};if(f(t)){const e=t.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/);if(!e)throw Error(Ee.INVALID_ISO_DATE_ARGUMENT);const n=e[3]?e[3].trim().startsWith("T")?`${e[1].trim()}${e[3].trim()}`:`${e[1].trim()}T${e[3].trim()}`:e[1].trim();c=new Date(n);try{c.toISOString()}catch(e){throw Error(Ee.INVALID_ISO_DATE_ARGUMENT)}}else if("[object Date]"===_(t)){if(isNaN(t.getTime()))throw Error(Ee.INVALID_DATE_ARGUMENT);c=t}else{if(!r(t))throw Error(Ee.INVALID_ARGUMENT);c=t}return f(n)?s.key=n:k(n)&&Object.keys(n).forEach((e=>{Oe.includes(e)?l[e]=n[e]:s[e]=n[e]})),f(o)?s.locale=o:k(o)&&(l=o),k(a)&&(l=a),[s.key||"",c,s,l]}const ve=["localeMatcher","style","currency","currencyDisplay","currencySign","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits","compactDisplay","notation","signDisplay","unit","unitDisplay","roundingMode","roundingPriority","roundingIncrement","trailingZeroDisplay"];function Ie(...e){const[t,n,o,a]=e,s={};let c={};if(!r(t))throw Error(Ee.INVALID_ARGUMENT);const l=t;return f(n)?s.key=n:k(n)&&Object.keys(n).forEach((e=>{ve.includes(e)?c[e]=n[e]:s[e]=n[e]})),f(o)?s.locale=o:k(o)&&(c=o),k(a)&&(c=a),[s.key||"",l,s,c]}return e.CompileErrorCodes=h,e.CoreErrorCodes=Ee,e.CoreWarnCodes=te,e.DATETIME_FORMAT_OPTIONS_KEYS=Oe,e.DEFAULT_LOCALE=le,e.DEFAULT_MESSAGE_DATA_TYPE=H,e.MISSING_RESOLVE_VALUE="",e.NOT_REOSLVED=-1,e.NUMBER_FORMAT_OPTIONS_KEYS=ve,e.VERSION=ce,e.clearCompileCache=function(){ge=Object.create(null)},e.clearDateTimeFormat=function(e,t,n){const r=e;for(const e in n){const n=`${t}__${e}`;r.__datetimeFormatters.has(n)&&r.__datetimeFormatters.delete(n)}},e.clearNumberFormat=function(e,t,n){const r=e;for(const e in n){const n=`${t}__${e}`;r.__numberFormatters.has(n)&&r.__numberFormatters.delete(n)}},e.compileToFunction=function(e,t={}){{const n=(t.onCacheKey||he)(e),r=ge[n];if(r)return r;let o=!1;const a=t.onError||T;t.onError=e=>{o=!0,a(e)};const{code:s}=w(e,t),c=new Function(`return ${s}`)();return o?c:ge[n]=c}},e.createCompileError=g,e.createCoreContext=function(e={}){const t=f(e.version)?e.version:ce,n=f(e.locale)?e.locale:le,r=u(e.fallbackLocale)||k(e.fallbackLocale)||f(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:n,a=k(e.messages)?e.messages:{[n]:{}},l=k(e.datetimeFormats)?e.datetimeFormats:{[n]:{}},d=k(e.numberFormats)?e.numberFormats:{[n]:{}},_=c({},e.modifiers||{},{upper:(e,t)=>"text"===t&&f(e)?e.toUpperCase():"vnode"===t&&p(e)&&"__v_isVNode"in e?e.children.toUpperCase():e,lower:(e,t)=>"text"===t&&f(e)?e.toLowerCase():"vnode"===t&&p(e)&&"__v_isVNode"in e?e.children.toLowerCase():e,capitalize:(e,t)=>"text"===t&&f(e)?ue(e):"vnode"===t&&p(e)&&"__v_isVNode"in e?ue(e.children):e}),h=e.pluralRules||{},g=i(e.missing)?e.missing:null,T=!m(e.missingWarn)&&!o(e.missingWarn)||e.missingWarn,b=!m(e.fallbackWarn)&&!o(e.fallbackWarn)||e.fallbackWarn,E=!!e.fallbackFormat,L=!!e.unresolving,y=i(e.postTranslation)?e.postTranslation:null,N=k(e.processor)?e.processor:null,C=!m(e.warnHtmlMessage)||e.warnHtmlMessage,A=!!e.escapeParameter,O=i(e.messageCompiler)?e.messageCompiler:ie,x=i(e.messageResolver)?e.messageResolver:fe||j,v=i(e.localeFallbacker)?e.localeFallbacker:me||re,I=p(e.fallbackContext)?e.fallbackContext:void 0,S=i(e.onWarn)?e.onWarn:s,F=e,P=p(F.__datetimeFormatters)?F.__datetimeFormatters:new Map,D=p(F.__numberFormatters)?F.__numberFormatters:new Map,M=p(F.__meta)?F.__meta:{};_e++;const w={version:t,cid:_e,locale:n,fallbackLocale:r,messages:a,modifiers:_,pluralRules:h,missing:g,missingWarn:T,fallbackWarn:b,fallbackFormat:E,unresolving:L,postTranslation:y,processor:N,warnHtmlMessage:C,escapeParameter:A,messageCompiler:O,messageResolver:x,localeFallbacker:v,fallbackContext:I,onWarn:S,__meta:M};return w.datetimeFormats=l,w.numberFormats=d,w.__datetimeFormatters=P,w.__numberFormatters=D,w},e.createCoreError=function(e){return g(e,null,void 0)},e.createMessageContext=J,e.datetime=function(e,...t){const{datetimeFormats:n,unresolving:r,fallbackLocale:o,onWarn:s,localeFallbacker:l}=e,{__datetimeFormatters:u}=e,[i,p,d,_]=xe(...t);m(d.missingWarn)?d.missingWarn:e.missingWarn,m(d.fallbackWarn)?d.fallbackWarn:e.fallbackWarn;const h=!!d.part,g=f(d.locale)?d.locale:e.locale,T=l(e,o,g);if(!f(i)||""===i)return new Intl.DateTimeFormat(g,_).format(p);let b,E={},L=null;for(let t=0;t<T.length&&(b=T[t],E=n[b]||{},L=E[i],!k(L));t++)ke(e,i,b,0,"datetime format");if(!k(L)||!f(b))return r?-1:i;let y=`${b}__${i}`;a(_)||(y=`${y}__${JSON.stringify(_)}`);let N=u.get(y);return N||(N=new Intl.DateTimeFormat(b,c({},L,_)),u.set(y,N)),h?N.formatToParts(p):N.format(p)},e.fallbackWithLocaleChain=function(e,t,n){const r=f(n)?n:le,o=e;o.__localeChainCache||(o.__localeChainCache=new Map);let a=o.__localeChainCache.get(r);if(!a){a=[];let e=[n];for(;u(e);)e=oe(a,e,t);const s=u(t)||!k(t)?t:t.default?t.default:null;e=f(s)?[s]:s,u(e)&&oe(a,e,!1),o.__localeChainCache.set(r,a)}return a},e.fallbackWithSimple=re,e.getAdditionalMeta=()=>pe,e.getDevToolsHook=function(){return Q},e.getFallbackContext=()=>de,e.getWarnMessage=function(e,...n){return function(e,...n){return 1===n.length&&p(n[0])&&(n=n[0]),n&&n.hasOwnProperty||(n={}),e.replace(t,((e,t)=>n.hasOwnProperty(t)?n[t]:""))}(ne[e],...n)},e.handleMissing=ke,e.initI18nDevTools=function(e,t,n){Q&&Q.emit(Z,{timestamp:Date.now(),i18n:e,version:t,meta:n})},e.isMessageFunction=ye,e.isTranslateFallbackWarn=function(e,t){return e instanceof RegExp?e.test(t):e},e.isTranslateMissingWarn=function(e,t){return e instanceof RegExp?e.test(t):e},e.number=function(e,...t){const{numberFormats:n,unresolving:r,fallbackLocale:o,onWarn:s,localeFallbacker:l}=e,{__numberFormatters:u}=e,[i,p,d,_]=Ie(...t);m(d.missingWarn)?d.missingWarn:e.missingWarn,m(d.fallbackWarn)?d.fallbackWarn:e.fallbackWarn;const h=!!d.part,g=f(d.locale)?d.locale:e.locale,T=l(e,o,g);if(!f(i)||""===i)return new Intl.NumberFormat(g,_).format(p);let b,E={},L=null;for(let t=0;t<T.length&&(b=T[t],E=n[b]||{},L=E[i],!k(L));t++)ke(e,i,b,0,"number format");if(!k(L)||!f(b))return r?-1:i;let y=`${b}__${i}`;a(_)||(y=`${y}__${JSON.stringify(_)}`);let N=u.get(y);return N||(N=new Intl.NumberFormat(b,c({},L,_)),u.set(y,N)),h?N.formatToParts(p):N.format(p)},e.parse=V,e.parseDateTimeArgs=xe,e.parseNumberArgs=Ie,e.parseTranslateArgs=Ae,e.registerLocaleFallbacker=function(e){me=e},e.registerMessageCompiler=function(e){ie=e},e.registerMessageResolver=function(e){fe=e},e.resolveValue=function(e,t){if(!p(e))return null;let n=K.get(t);if(n||(n=V(t),n&&K.set(t,n)),!n)return null;const r=n.length;let o=e,a=0;for(;a<r;){const e=o[n[a]];if(void 0===e)return null;o=e,a++}return o},e.resolveWithKeyValue=j,e.setAdditionalMeta=e=>{pe=e},e.setDevToolsHook=function(e){Q=e},e.setFallbackContext=e=>{de=e},e.translate=function(e,...t){const{fallbackFormat:n,postTranslation:o,unresolving:a,messageCompiler:s,fallbackLocale:c,messages:i}=e,[d,_]=Ae(...t),k=m(_.missingWarn)?_.missingWarn:e.missingWarn,h=m(_.fallbackWarn)?_.fallbackWarn:e.fallbackWarn,g=m(_.escapeParameter)?_.escapeParameter:e.escapeParameter,T=!!_.resolvedMessage,b=f(_.default)||m(_.default)?m(_.default)?s?d:()=>d:_.default:n?s?d:()=>d:"",E=n||""!==b,L=f(_.locale)?_.locale:e.locale;g&&function(e){u(e.list)?e.list=e.list.map((e=>f(e)?l(e):e)):p(e.named)&&Object.keys(e.named).forEach((t=>{f(e.named[t])&&(e.named[t]=l(e.named[t]))}))}(_);let[y,N,C]=T?[d,L,i[L]||{}]:Ne(e,d,L,c,h,k),A=y,O=d;if(T||f(A)||ye(A)||E&&(A=b,O=A),!(T||(f(A)||ye(A))&&f(N)))return a?-1:d;let x=!1;const v=ye(A)?A:Ce(e,d,N,A,O,(()=>{x=!0}));if(x)return A;const I=function(e,t,n,o){const{modifiers:a,pluralRules:s,messageResolver:c,fallbackLocale:l,fallbackWarn:u,missingWarn:i,fallbackContext:m}=e,p=r=>{let o=c(n,r);if(null==o&&m){const[,,e]=Ne(m,r,t,l,u,i);o=c(e,r)}if(f(o)){let n=!1;const a=Ce(e,r,t,o,r,(()=>{n=!0}));return n?Le:a}return ye(o)?o:Le},d={locale:t,modifiers:a,pluralRules:s,messages:p};e.processor&&(d.processor=e.processor);o.list&&(d.list=o.list);o.named&&(d.named=o.named);r(o.plural)&&(d.pluralIndex=o.plural);return d}(e,N,C,_),S=function(e,t,n){return t(n)}(0,v,J(I));return o?o(S,d):S},e.translateDevTools=q,e.updateFallbackLocale=function(e,t,n){e.__localeChainCache=new Map,e.localeFallbacker(e,n,t)},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
var IntlifyCoreBase=function(e){"use strict";const t=/\{([0-9a-zA-Z]+)\}/g;const n=e=>JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029").replace(/\u0027/g,"\\u0027"),r=e=>"number"==typeof e&&isFinite(e),o=e=>"[object RegExp]"===_(e),a=e=>k(e)&&0===Object.keys(e).length;function s(e,t){"undefined"!=typeof console&&(console.warn("[intlify] "+e),t&&console.warn(t.stack))}const c=Object.assign;function l(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const u=Array.isArray,i=e=>"function"==typeof e,f=e=>"string"==typeof e,m=e=>"boolean"==typeof e,p=e=>null!==e&&"object"==typeof e,d=Object.prototype.toString,_=e=>d.call(e),k=e=>"[object Object]"===_(e),h={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,__EXTEND_POINT__:15};function g(e,t,n={}){const{domain:r,messages:o,args:a}=n,s=new SyntaxError(String(e));return s.code=e,t&&(s.location=t),s.domain=r,s}function T(e){throw e}function b(e,t,n){const r={start:e,end:t};return null!=n&&(r.source=n),r}const E=" ",L="\n",y=String.fromCharCode(8232),N=String.fromCharCode(8233);function C(e){const t=e;let n=0,r=1,o=1,a=0;const s=e=>"\r"===t[e]&&t[e+1]===L,c=e=>t[e]===N,l=e=>t[e]===y,u=e=>s(e)||(e=>t[e]===L)(e)||c(e)||l(e),i=e=>s(e)||c(e)||l(e)?L:t[e];function f(){return a=0,u(n)&&(r++,o=0),s(n)&&n++,n++,o++,t[n]}return{index:()=>n,line:()=>r,column:()=>o,peekOffset:()=>a,charAt:i,currentChar:()=>i(n),currentPeek:()=>i(n+a),next:f,peek:function(){return s(n+a)&&a++,a++,t[n+a]},reset:function(){n=0,r=1,o=1,a=0},resetPeek:function(e=0){a=e},skipToPeek:function(){const e=n+a;for(;e!==n;)f();a=0}}}const A=void 0;function O(e,t={}){const n=!1!==t.location,r=C(e),o=()=>r.index(),a=()=>{return e=r.line(),t=r.column(),n=r.index(),{line:e,column:t,offset:n};var e,t,n},s=a(),c=o(),l={currentType:14,offset:c,startLoc:s,endLoc:s,lastType:14,lastOffset:c,lastStartLoc:s,lastEndLoc:s,braceNest:0,inLinked:!1,text:""},u=()=>l,{onError:i}=t;function f(e,t,r){e.endLoc=a(),e.currentType=t;const o={type:t};return n&&(o.loc=b(e.startLoc,e.endLoc)),null!=r&&(o.value=r),o}const m=e=>f(e,14);function p(e,t){return e.currentChar()===t?(e.next(),t):(a(),"")}function d(e){let t="";for(;e.currentPeek()===E||e.currentPeek()===L;)t+=e.currentPeek(),e.peek();return t}function _(e){const t=d(e);return e.skipToPeek(),t}function k(e){if(e===A)return!1;const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||95===t}function h(e,t){const{currentType:n}=t;if(2!==n)return!1;d(e);const r=function(e){if(e===A)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}("-"===e.currentPeek()?e.peek():e.currentPeek());return e.resetPeek(),r}function g(e){d(e);const t="|"===e.currentPeek();return e.resetPeek(),t}function T(e,t=!0){const n=(t=!1,r="",o=!1)=>{const a=e.currentPeek();return"{"===a?"%"!==r&&t:"@"!==a&&a?"%"===a?(e.peek(),n(t,"%",!0)):"|"===a?!("%"!==r&&!o)||!(r===E||r===L):a===E?(e.peek(),n(!0,E,o)):a!==L||(e.peek(),n(!0,L,o)):"%"===r||t},r=n();return t&&e.resetPeek(),r}function y(e,t){const n=e.currentChar();return n===A?A:t(n)?(e.next(),n):null}function N(e){return y(e,(e=>{const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t}))}function O(e){return y(e,(e=>{const t=e.charCodeAt(0);return t>=48&&t<=57}))}function x(e){return y(e,(e=>{const t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}))}function v(e){let t="",n="";for(;t=O(e);)n+=t;return n}function I(e){let t="";for(;;){const n=e.currentChar();if("{"===n||"}"===n||"@"===n||"|"===n||!n)break;if("%"===n){if(!T(e))break;t+=n,e.next()}else if(n===E||n===L)if(T(e))t+=n,e.next();else{if(g(e))break;t+=n,e.next()}else t+=n,e.next()}return t}function S(e){const t=e.currentChar();switch(t){case"\\":case"'":return e.next(),`\\${t}`;case"u":return F(e,t,4);case"U":return F(e,t,6);default:return a(),""}}function F(e,t,n){p(e,t);let r="";for(let t=0;t<n;t++){const t=x(e);if(!t){a(),e.currentChar();break}r+=t}return`\\${t}${r}`}function P(e){_(e);const t=p(e,"|");return _(e),t}function D(e,t){let n=null;switch(e.currentChar()){case"{":return t.braceNest>=1&&a(),e.next(),n=f(t,2,"{"),_(e),t.braceNest++,n;case"}":return t.braceNest>0&&2===t.currentType&&a(),e.next(),n=f(t,3,"}"),t.braceNest--,t.braceNest>0&&_(e),t.inLinked&&0===t.braceNest&&(t.inLinked=!1),n;case"@":return t.braceNest>0&&a(),n=M(e,t)||m(t),t.braceNest=0,n;default:let r=!0,o=!0,s=!0;if(g(e))return t.braceNest>0&&a(),n=f(t,1,P(e)),t.braceNest=0,t.inLinked=!1,n;if(t.braceNest>0&&(5===t.currentType||6===t.currentType||7===t.currentType))return a(),t.braceNest=0,w(e,t);if(r=function(e,t){const{currentType:n}=t;if(2!==n)return!1;d(e);const r=k(e.currentPeek());return e.resetPeek(),r}(e,t))return n=f(t,5,function(e){_(e);let t="",n="";for(;t=N(e);)n+=t;return e.currentChar()===A&&a(),n}(e)),_(e),n;if(o=h(e,t))return n=f(t,6,function(e){_(e);let t="";return"-"===e.currentChar()?(e.next(),t+=`-${v(e)}`):t+=v(e),e.currentChar()===A&&a(),t}(e)),_(e),n;if(s=function(e,t){const{currentType:n}=t;if(2!==n)return!1;d(e);const r="'"===e.currentPeek();return e.resetPeek(),r}(e,t))return n=f(t,7,function(e){_(e),p(e,"'");let t="",n="";const r=e=>"'"!==e&&e!==L;for(;t=y(e,r);)n+="\\"===t?S(e):t;const o=e.currentChar();return o===L||o===A?(a(),o===L&&(e.next(),p(e,"'")),n):(p(e,"'"),n)}(e)),_(e),n;if(!r&&!o&&!s)return n=f(t,13,function(e){_(e);let t="",n="";const r=e=>"{"!==e&&"}"!==e&&e!==E&&e!==L;for(;t=y(e,r);)n+=t;return n}(e)),a(),n.value,_(e),n}return n}function M(e,t){const{currentType:n}=t;let r=null;const o=e.currentChar();switch(8!==n&&9!==n&&12!==n&&10!==n||o!==L&&o!==E||a(),o){case"@":return e.next(),r=f(t,8,"@"),t.inLinked=!0,r;case".":return _(e),e.next(),f(t,9,".");case":":return _(e),e.next(),f(t,10,":");default:return g(e)?(r=f(t,1,P(e)),t.braceNest=0,t.inLinked=!1,r):function(e,t){const{currentType:n}=t;if(8!==n)return!1;d(e);const r="."===e.currentPeek();return e.resetPeek(),r}(e,t)||function(e,t){const{currentType:n}=t;if(8!==n&&12!==n)return!1;d(e);const r=":"===e.currentPeek();return e.resetPeek(),r}(e,t)?(_(e),M(e,t)):function(e,t){const{currentType:n}=t;if(9!==n)return!1;d(e);const r=k(e.currentPeek());return e.resetPeek(),r}(e,t)?(_(e),f(t,12,function(e){let t="",n="";for(;t=N(e);)n+=t;return n}(e))):function(e,t){const{currentType:n}=t;if(10!==n)return!1;const r=()=>{const t=e.currentPeek();return"{"===t?k(e.peek()):!("@"===t||"%"===t||"|"===t||":"===t||"."===t||t===E||!t)&&(t===L?(e.peek(),r()):k(t))},o=r();return e.resetPeek(),o}(e,t)?(_(e),"{"===o?D(e,t)||r:f(t,11,function(e){const t=(n=!1,r)=>{const o=e.currentChar();return"{"!==o&&"%"!==o&&"@"!==o&&"|"!==o&&o?o===E?r:o===L?(r+=o,e.next(),t(n,r)):(r+=o,e.next(),t(!0,r)):r};return t(!1,"")}(e))):(8===n&&a(),t.braceNest=0,t.inLinked=!1,w(e,t))}}function w(e,t){let n={type:14};if(t.braceNest>0)return D(e,t)||m(t);if(t.inLinked)return M(e,t)||m(t);switch(e.currentChar()){case"{":return D(e,t)||m(t);case"}":return a(),e.next(),f(t,3,"}");case"@":return M(e,t)||m(t);default:if(g(e))return n=f(t,1,P(e)),t.braceNest=0,t.inLinked=!1,n;const{isModulo:r,hasSpace:o}=function(e){const t=d(e),n="%"===e.currentPeek()&&"{"===e.peek();return e.resetPeek(),{isModulo:n,hasSpace:t.length>0}}(e);if(r)return o?f(t,0,I(e)):f(t,4,function(e){_(e);return"%"!==e.currentChar()&&a(),e.next(),"%"}(e));if(T(e))return f(t,0,I(e))}return n}return{nextToken:function(){const{currentType:e,offset:t,startLoc:n,endLoc:s}=l;return l.lastType=e,l.lastOffset=t,l.lastStartLoc=n,l.lastEndLoc=s,l.offset=o(),l.startLoc=a(),r.currentChar()===A?f(l,14):w(r,l)},currentOffset:o,currentPosition:a,context:u}}const x=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function v(e,t,n){switch(e){case"\\\\":return"\\";case"\\'":return"'";default:{const e=parseInt(t||n,16);return e<=55295||e>=57344?String.fromCodePoint(e):"�"}}}function I(e={}){const t=!1!==e.location,{onError:n}=e;function r(e,n,r){const o={type:e,start:n,end:n};return t&&(o.loc={start:r,end:r}),o}function o(e,n,r,o){e.end=n,o&&(e.type=o),t&&e.loc&&(e.loc.end=r)}function a(e,t){const n=e.context(),a=r(3,n.offset,n.startLoc);return a.value=t,o(a,e.currentOffset(),e.currentPosition()),a}function s(e,t){const n=e.context(),{lastOffset:a,lastStartLoc:s}=n,c=r(5,a,s);return c.index=parseInt(t,10),e.nextToken(),o(c,e.currentOffset(),e.currentPosition()),c}function l(e,t){const n=e.context(),{lastOffset:a,lastStartLoc:s}=n,c=r(4,a,s);return c.key=t,e.nextToken(),o(c,e.currentOffset(),e.currentPosition()),c}function u(e,t){const n=e.context(),{lastOffset:a,lastStartLoc:s}=n,c=r(9,a,s);return c.value=t.replace(x,v),e.nextToken(),o(c,e.currentOffset(),e.currentPosition()),c}function i(e){const t=e.context(),n=r(6,t.offset,t.startLoc);let a=e.nextToken();if(9===a.type){const t=function(e){const t=e.nextToken(),n=e.context(),{lastOffset:a,lastStartLoc:s}=n,c=r(8,a,s);return 12!==t.type?(n.lastStartLoc,c.value="",o(c,a,s),{nextConsumeToken:t,node:c}):(null==t.value&&(n.lastStartLoc,S(t)),c.value=t.value||"",o(c,e.currentOffset(),e.currentPosition()),{node:c})}(e);n.modifier=t.node,a=t.nextConsumeToken||e.nextToken()}switch(10!==a.type&&(t.lastStartLoc,S(a)),a=e.nextToken(),2===a.type&&(a=e.nextToken()),a.type){case 11:null==a.value&&(t.lastStartLoc,S(a)),n.key=function(e,t){const n=e.context(),a=r(7,n.offset,n.startLoc);return a.value=t,o(a,e.currentOffset(),e.currentPosition()),a}(e,a.value||"");break;case 5:null==a.value&&(t.lastStartLoc,S(a)),n.key=l(e,a.value||"");break;case 6:null==a.value&&(t.lastStartLoc,S(a)),n.key=s(e,a.value||"");break;case 7:null==a.value&&(t.lastStartLoc,S(a)),n.key=u(e,a.value||"");break;default:t.lastStartLoc;const c=e.context(),i=r(7,c.offset,c.startLoc);return i.value="",o(i,c.offset,c.startLoc),n.key=i,o(n,c.offset,c.startLoc),{nextConsumeToken:a,node:n}}return o(n,e.currentOffset(),e.currentPosition()),{node:n}}function f(e){const t=e.context(),n=r(2,1===t.currentType?e.currentOffset():t.offset,1===t.currentType?t.endLoc:t.startLoc);n.items=[];let c=null;do{const r=c||e.nextToken();switch(c=null,r.type){case 0:null==r.value&&(t.lastStartLoc,S(r)),n.items.push(a(e,r.value||""));break;case 6:null==r.value&&(t.lastStartLoc,S(r)),n.items.push(s(e,r.value||""));break;case 5:null==r.value&&(t.lastStartLoc,S(r)),n.items.push(l(e,r.value||""));break;case 7:null==r.value&&(t.lastStartLoc,S(r)),n.items.push(u(e,r.value||""));break;case 8:const o=i(e);n.items.push(o.node),c=o.nextConsumeToken||null}}while(14!==t.currentType&&1!==t.currentType);return o(n,1===t.currentType?t.lastOffset:e.currentOffset(),1===t.currentType?t.lastEndLoc:e.currentPosition()),n}function m(e){const t=e.context(),{offset:n,startLoc:a}=t,s=f(e);return 14===t.currentType?s:function(e,t,n,a){const s=e.context();let c=0===a.items.length;const l=r(1,t,n);l.cases=[],l.cases.push(a);do{const t=f(e);c||(c=0===t.items.length),l.cases.push(t)}while(14!==s.currentType);return o(l,e.currentOffset(),e.currentPosition()),l}(e,n,a,s)}return{parse:function(n){const a=O(n,c({},e)),s=a.context(),l=r(0,s.offset,s.startLoc);return t&&l.loc&&(l.loc.source=n),l.body=m(a),14!==s.currentType&&(s.lastStartLoc,n[s.offset]),o(l,a.currentOffset(),a.currentPosition()),l}}}function S(e){if(14===e.type)return"EOF";const t=(e.value||"").replace(/\r?\n/gu,"\\n");return t.length>10?t.slice(0,9)+"…":t}function F(e,t){for(let n=0;n<e.length;n++)P(e[n],t)}function P(e,t){switch(e.type){case 1:F(e.cases,t),t.helper("plural");break;case 2:F(e.items,t);break;case 6:P(e.key,t),t.helper("linked"),t.helper("type");break;case 5:t.helper("interpolate"),t.helper("list");break;case 4:t.helper("interpolate"),t.helper("named")}}function D(e,t={}){const n=function(e,t={}){const n={ast:e,helpers:new Set};return{context:()=>n,helper:e=>(n.helpers.add(e),e)}}(e);n.helper("normalize"),e.body&&P(e.body,n);const r=n.context();e.helpers=Array.from(r.helpers)}function M(e,t){const{helper:n}=e;switch(t.type){case 0:!function(e,t){t.body?M(e,t.body):e.push("null")}(e,t);break;case 1:!function(e,t){const{helper:n,needIndent:r}=e;if(t.cases.length>1){e.push(`${n("plural")}([`),e.indent(r());const o=t.cases.length;for(let n=0;n<o&&(M(e,t.cases[n]),n!==o-1);n++)e.push(", ");e.deindent(r()),e.push("])")}}(e,t);break;case 2:!function(e,t){const{helper:n,needIndent:r}=e;e.push(`${n("normalize")}([`),e.indent(r());const o=t.items.length;for(let n=0;n<o&&(M(e,t.items[n]),n!==o-1);n++)e.push(", ");e.deindent(r()),e.push("])")}(e,t);break;case 6:!function(e,t){const{helper:n}=e;e.push(`${n("linked")}(`),M(e,t.key),t.modifier?(e.push(", "),M(e,t.modifier),e.push(", _type")):e.push(", undefined, _type"),e.push(")")}(e,t);break;case 8:case 7:case 9:case 3:e.push(JSON.stringify(t.value),t);break;case 5:e.push(`${n("interpolate")}(${n("list")}(${t.index}))`,t);break;case 4:e.push(`${n("interpolate")}(${n("named")}(${JSON.stringify(t.key)}))`,t)}}function w(e,t={}){const n=c({},t),r=I(n).parse(e);return D(r,n),((e,t={})=>{const n=f(t.mode)?t.mode:"normal",r=f(t.filename)?t.filename:"message.intl",o=!!t.sourceMap,a=null!=t.breakLineCode?t.breakLineCode:"arrow"===n?";":"\n",s=t.needIndent?t.needIndent:"arrow"!==n,c=e.helpers||[],l=function(e,t){const{sourceMap:n,filename:r,breakLineCode:o,needIndent:a}=t,s={source:e.loc.source,filename:r,code:"",column:1,line:1,offset:0,map:void 0,breakLineCode:o,needIndent:a,indentLevel:0};function c(e,t){s.code+=e}function l(e,t=!0){const n=t?o:"";c(a?n+" ".repeat(e):n)}return{context:()=>s,push:c,indent:function(e=!0){const t=++s.indentLevel;e&&l(t)},deindent:function(e=!0){const t=--s.indentLevel;e&&l(t)},newline:function(){l(s.indentLevel)},helper:e=>`_${e}`,needIndent:()=>s.needIndent}}(e,{mode:n,filename:r,sourceMap:o,breakLineCode:a,needIndent:s});l.push("normal"===n?"function __msg__ (ctx) {":"(ctx) => {"),l.indent(s),c.length>0&&(l.push(`const { ${c.map((e=>`${e}: _${e}`)).join(", ")} } = ctx`),l.newline()),l.push("return "),M(l,e),l.deindent(s),l.push("}");const{code:u,map:i}=l.context();return{ast:e,code:u,map:i?i.toJSON():void 0}})(r,n)}const R=[];R[0]={w:[0],i:[3,0],"[":[4],o:[7]},R[1]={w:[1],".":[2],"[":[4],o:[7]},R[2]={w:[2],i:[3,0],0:[3,0]},R[3]={i:[3,0],0:[3,0],w:[1,1],".":[2,1],"[":[4,1],o:[7,1]},R[4]={"'":[5,0],'"':[6,0],"[":[4,2],"]":[1,3],o:8,l:[4,0]},R[5]={"'":[4,0],o:8,l:[5,0]},R[6]={'"':[4,0],o:8,l:[6,0]};const W=/^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;function U(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 $(e){const t=e.trim();return("0"!==e.charAt(0)||!isNaN(parseInt(e)))&&(n=t,W.test(n)?function(e){const t=e.charCodeAt(0);return t!==e.charCodeAt(e.length-1)||34!==t&&39!==t?e:e.slice(1,-1)}(t):"*"+t);var n}function V(e){const t=[];let n,r,o,a,s,c,l,u=-1,i=0,f=0;const m=[];function p(){const t=e[u+1];if(5===i&&"'"===t||6===i&&'"'===t)return u++,o="\\"+t,m[0](),!0}for(m[0]=()=>{void 0===r?r=o:r+=o},m[1]=()=>{void 0!==r&&(t.push(r),r=void 0)},m[2]=()=>{m[0](),f++},m[3]=()=>{if(f>0)f--,i=4,m[0]();else{if(f=0,void 0===r)return!1;if(r=$(r),!1===r)return!1;m[1]()}};null!==i;)if(u++,n=e[u],"\\"!==n||!p()){if(a=U(n),l=R[i],s=l[a]||l.l||8,8===s)return;if(i=s[0],void 0!==s[1]&&(c=m[s[1]],c&&(o=n,!1===c())))return;if(7===i)return t}}const K=new Map;function j(e,t){return p(e)?e[t]:null}const G=e=>e,B=e=>"",H="text",Y=e=>0===e.length?"":e.join(""),X=e=>null==e?"":u(e)||k(e)&&e.toString===d?JSON.stringify(e,null,2):String(e);function z(e,t){return e=Math.abs(e),2===t?e?e>1?1:0:1:e?Math.min(e,2):0}function J(e={}){const t=e.locale,n=function(e){const t=r(e.pluralIndex)?e.pluralIndex:-1;return e.named&&(r(e.named.count)||r(e.named.n))?r(e.named.count)?e.named.count:r(e.named.n)?e.named.n:t:t}(e),o=p(e.pluralRules)&&f(t)&&i(e.pluralRules[t])?e.pluralRules[t]:z,a=p(e.pluralRules)&&f(t)&&i(e.pluralRules[t])?z:void 0,s=e.list||[],c=e.named||{};r(e.pluralIndex)&&function(e,t){t.count||(t.count=e),t.n||(t.n=e)}(n,c);function l(t){const n=i(e.messages)?e.messages(t):!!p(e.messages)&&e.messages[t];return n||(e.parent?e.parent.message(t):B)}const m=k(e.processor)&&i(e.processor.normalize)?e.processor.normalize:Y,d=k(e.processor)&&i(e.processor.interpolate)?e.processor.interpolate:X,_={list:e=>s[e],named:e=>c[e],plural:e=>e[o(n,e.length,a)],linked:(t,...n)=>{const[r,o]=n;let a="text",s="";1===n.length?p(r)?(s=r.modifier||s,a=r.type||a):f(r)&&(s=r||s):2===n.length&&(f(r)&&(s=r||s),f(o)&&(a=o||a));let c=l(t)(_);return"vnode"===a&&u(c)&&s&&(c=c[0]),s?(i=s,e.modifiers?e.modifiers[i]:G)(c,a):c;var i},message:l,type:k(e.processor)&&f(e.processor.type)?e.processor.type:H,interpolate:d,normalize:m};return _}const Z="i18n:init";let Q=null;const q=ee("function:translate");function ee(e){return t=>Q&&Q.emit(e,t)}const te={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,__EXTEND_POINT__:7},ne={[te.NOT_FOUND_KEY]:"Not found '{key}' key in '{locale}' locale messages.",[te.FALLBACK_TO_TRANSLATE]:"Fall back to translate '{key}' key with '{target}' locale.",[te.CANNOT_FORMAT_NUMBER]:"Cannot format a number value due to not supported Intl.NumberFormat.",[te.FALLBACK_TO_NUMBER_FORMAT]:"Fall back to number format '{key}' key with '{target}' locale.",[te.CANNOT_FORMAT_DATE]:"Cannot format a date value due to not supported Intl.DateTimeFormat.",[te.FALLBACK_TO_DATE_FORMAT]:"Fall back to datetime format '{key}' key with '{target}' locale."};function re(e,t,n){return[...new Set([n,...u(t)?t:p(t)?Object.keys(t):f(t)?[t]:[n]])]}function oe(e,t,n){let r=!0;for(let o=0;o<t.length&&m(r);o++){const a=t[o];f(a)&&(r=ae(e,t[o],n))}return r}function ae(e,t,n){let r;const o=t.split("-");do{r=se(e,o.join("-"),n),o.splice(-1,1)}while(o.length&&!0===r);return r}function se(e,t,n){let r=!1;if(!e.includes(t)&&(r=!0,t)){r="!"!==t[t.length-1];const o=t.replace(/!/g,"");e.push(o),(u(n)||k(n))&&n[o]&&(r=n[o])}return r}const ce="9.3.0-beta.2",le="en-US",ue=e=>`${e.charAt(0).toLocaleUpperCase()}${e.substr(1)}`;let ie,fe,me;let pe=null;let de=null;let _e=0;function ke(e,t,n,r,o){const{missing:a,onWarn:s}=e;if(null!==a){const r=a(e,n,t,o);return f(r)?r:t}return t}const he=e=>e;let ge=Object.create(null);let Te=h.__EXTEND_POINT__;const be=()=>++Te,Ee={INVALID_ARGUMENT:Te,INVALID_DATE_ARGUMENT:be(),INVALID_ISO_DATE_ARGUMENT:be(),__EXTEND_POINT__:be()};const Le=()=>"",ye=e=>i(e);function Ne(e,t,n,r,o,a){const{messages:s,onWarn:c,messageResolver:l,localeFallbacker:u}=e,m=u(e,r,n);let p,d={},_=null;for(let n=0;n<m.length&&(p=m[n],d=s[p]||{},null===(_=l(d,t))&&(_=d[t]),!f(_)&&!i(_));n++){const n=ke(e,t,p,0,"translate");n!==t&&(_=n)}return[_,p,d]}function Ce(e,t,r,o,a,s){const{messageCompiler:c,warnHtmlMessage:l}=e;if(ye(o)){const e=o;return e.locale=e.locale||r,e.key=e.key||t,e}if(null==c){const e=()=>o;return e.locale=r,e.key=t,e}const u=c(o,function(e,t,r,o,a,s){return{warnHtmlMessage:a,onError:e=>{throw s&&s(e),e},onCacheKey:e=>((e,t,r)=>n({l:e,k:t,s:r}))(t,r,e)}}(0,r,a,0,l,s));return u.locale=r,u.key=t,u.source=o,u}function Ae(...e){const[t,n,o]=e,s={};if(!f(t)&&!r(t)&&!ye(t))throw Error(Ee.INVALID_ARGUMENT);const l=r(t)?String(t):(ye(t),t);return r(n)?s.plural=n:f(n)?s.default=n:k(n)&&!a(n)?s.named=n:u(n)&&(s.list=n),r(o)?s.plural=o:f(o)?s.default=o:k(o)&&c(s,o),[l,s]}const Oe=["localeMatcher","weekday","era","year","month","day","hour","minute","second","timeZoneName","formatMatcher","hour12","timeZone","dateStyle","timeStyle","calendar","dayPeriod","numberingSystem","hourCycle","fractionalSecondDigits"];function xe(...e){const[t,n,o,a]=e,s={};let c,l={};if(f(t)){const e=t.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/);if(!e)throw Error(Ee.INVALID_ISO_DATE_ARGUMENT);const n=e[3]?e[3].trim().startsWith("T")?`${e[1].trim()}${e[3].trim()}`:`${e[1].trim()}T${e[3].trim()}`:e[1].trim();c=new Date(n);try{c.toISOString()}catch(e){throw Error(Ee.INVALID_ISO_DATE_ARGUMENT)}}else if("[object Date]"===_(t)){if(isNaN(t.getTime()))throw Error(Ee.INVALID_DATE_ARGUMENT);c=t}else{if(!r(t))throw Error(Ee.INVALID_ARGUMENT);c=t}return f(n)?s.key=n:k(n)&&Object.keys(n).forEach((e=>{Oe.includes(e)?l[e]=n[e]:s[e]=n[e]})),f(o)?s.locale=o:k(o)&&(l=o),k(a)&&(l=a),[s.key||"",c,s,l]}const ve=["localeMatcher","style","currency","currencyDisplay","currencySign","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits","compactDisplay","notation","signDisplay","unit","unitDisplay","roundingMode","roundingPriority","roundingIncrement","trailingZeroDisplay"];function Ie(...e){const[t,n,o,a]=e,s={};let c={};if(!r(t))throw Error(Ee.INVALID_ARGUMENT);const l=t;return f(n)?s.key=n:k(n)&&Object.keys(n).forEach((e=>{ve.includes(e)?c[e]=n[e]:s[e]=n[e]})),f(o)?s.locale=o:k(o)&&(c=o),k(a)&&(c=a),[s.key||"",l,s,c]}return e.CompileErrorCodes=h,e.CoreErrorCodes=Ee,e.CoreWarnCodes=te,e.DATETIME_FORMAT_OPTIONS_KEYS=Oe,e.DEFAULT_LOCALE=le,e.DEFAULT_MESSAGE_DATA_TYPE=H,e.MISSING_RESOLVE_VALUE="",e.NOT_REOSLVED=-1,e.NUMBER_FORMAT_OPTIONS_KEYS=ve,e.VERSION=ce,e.clearCompileCache=function(){ge=Object.create(null)},e.clearDateTimeFormat=function(e,t,n){const r=e;for(const e in n){const n=`${t}__${e}`;r.__datetimeFormatters.has(n)&&r.__datetimeFormatters.delete(n)}},e.clearNumberFormat=function(e,t,n){const r=e;for(const e in n){const n=`${t}__${e}`;r.__numberFormatters.has(n)&&r.__numberFormatters.delete(n)}},e.compileToFunction=function(e,t={}){{const n=(t.onCacheKey||he)(e),r=ge[n];if(r)return r;let o=!1;const a=t.onError||T;t.onError=e=>{o=!0,a(e)};const{code:s}=w(e,t),c=new Function(`return ${s}`)();return o?c:ge[n]=c}},e.createCompileError=g,e.createCoreContext=function(e={}){const t=f(e.version)?e.version:ce,n=f(e.locale)?e.locale:le,r=u(e.fallbackLocale)||k(e.fallbackLocale)||f(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:n,a=k(e.messages)?e.messages:{[n]:{}},l=k(e.datetimeFormats)?e.datetimeFormats:{[n]:{}},d=k(e.numberFormats)?e.numberFormats:{[n]:{}},_=c({},e.modifiers||{},{upper:(e,t)=>"text"===t&&f(e)?e.toUpperCase():"vnode"===t&&p(e)&&"__v_isVNode"in e?e.children.toUpperCase():e,lower:(e,t)=>"text"===t&&f(e)?e.toLowerCase():"vnode"===t&&p(e)&&"__v_isVNode"in e?e.children.toLowerCase():e,capitalize:(e,t)=>"text"===t&&f(e)?ue(e):"vnode"===t&&p(e)&&"__v_isVNode"in e?ue(e.children):e}),h=e.pluralRules||{},g=i(e.missing)?e.missing:null,T=!m(e.missingWarn)&&!o(e.missingWarn)||e.missingWarn,b=!m(e.fallbackWarn)&&!o(e.fallbackWarn)||e.fallbackWarn,E=!!e.fallbackFormat,L=!!e.unresolving,y=i(e.postTranslation)?e.postTranslation:null,N=k(e.processor)?e.processor:null,C=!m(e.warnHtmlMessage)||e.warnHtmlMessage,A=!!e.escapeParameter,O=i(e.messageCompiler)?e.messageCompiler:ie,x=i(e.messageResolver)?e.messageResolver:fe||j,v=i(e.localeFallbacker)?e.localeFallbacker:me||re,I=p(e.fallbackContext)?e.fallbackContext:void 0,S=i(e.onWarn)?e.onWarn:s,F=e,P=p(F.__datetimeFormatters)?F.__datetimeFormatters:new Map,D=p(F.__numberFormatters)?F.__numberFormatters:new Map,M=p(F.__meta)?F.__meta:{};_e++;const w={version:t,cid:_e,locale:n,fallbackLocale:r,messages:a,modifiers:_,pluralRules:h,missing:g,missingWarn:T,fallbackWarn:b,fallbackFormat:E,unresolving:L,postTranslation:y,processor:N,warnHtmlMessage:C,escapeParameter:A,messageCompiler:O,messageResolver:x,localeFallbacker:v,fallbackContext:I,onWarn:S,__meta:M};return w.datetimeFormats=l,w.numberFormats=d,w.__datetimeFormatters=P,w.__numberFormatters=D,w},e.createCoreError=function(e){return g(e,null,void 0)},e.createMessageContext=J,e.datetime=function(e,...t){const{datetimeFormats:n,unresolving:r,fallbackLocale:o,onWarn:s,localeFallbacker:l}=e,{__datetimeFormatters:u}=e,[i,p,d,_]=xe(...t);m(d.missingWarn)?d.missingWarn:e.missingWarn,m(d.fallbackWarn)?d.fallbackWarn:e.fallbackWarn;const h=!!d.part,g=f(d.locale)?d.locale:e.locale,T=l(e,o,g);if(!f(i)||""===i)return new Intl.DateTimeFormat(g,_).format(p);let b,E={},L=null;for(let t=0;t<T.length&&(b=T[t],E=n[b]||{},L=E[i],!k(L));t++)ke(e,i,b,0,"datetime format");if(!k(L)||!f(b))return r?-1:i;let y=`${b}__${i}`;a(_)||(y=`${y}__${JSON.stringify(_)}`);let N=u.get(y);return N||(N=new Intl.DateTimeFormat(b,c({},L,_)),u.set(y,N)),h?N.formatToParts(p):N.format(p)},e.fallbackWithLocaleChain=function(e,t,n){const r=f(n)?n:le,o=e;o.__localeChainCache||(o.__localeChainCache=new Map);let a=o.__localeChainCache.get(r);if(!a){a=[];let e=[n];for(;u(e);)e=oe(a,e,t);const s=u(t)||!k(t)?t:t.default?t.default:null;e=f(s)?[s]:s,u(e)&&oe(a,e,!1),o.__localeChainCache.set(r,a)}return a},e.fallbackWithSimple=re,e.getAdditionalMeta=()=>pe,e.getDevToolsHook=function(){return Q},e.getFallbackContext=()=>de,e.getWarnMessage=function(e,...n){return function(e,...n){return 1===n.length&&p(n[0])&&(n=n[0]),n&&n.hasOwnProperty||(n={}),e.replace(t,((e,t)=>n.hasOwnProperty(t)?n[t]:""))}(ne[e],...n)},e.handleMissing=ke,e.initI18nDevTools=function(e,t,n){Q&&Q.emit(Z,{timestamp:Date.now(),i18n:e,version:t,meta:n})},e.isMessageFunction=ye,e.isTranslateFallbackWarn=function(e,t){return e instanceof RegExp?e.test(t):e},e.isTranslateMissingWarn=function(e,t){return e instanceof RegExp?e.test(t):e},e.number=function(e,...t){const{numberFormats:n,unresolving:r,fallbackLocale:o,onWarn:s,localeFallbacker:l}=e,{__numberFormatters:u}=e,[i,p,d,_]=Ie(...t);m(d.missingWarn)?d.missingWarn:e.missingWarn,m(d.fallbackWarn)?d.fallbackWarn:e.fallbackWarn;const h=!!d.part,g=f(d.locale)?d.locale:e.locale,T=l(e,o,g);if(!f(i)||""===i)return new Intl.NumberFormat(g,_).format(p);let b,E={},L=null;for(let t=0;t<T.length&&(b=T[t],E=n[b]||{},L=E[i],!k(L));t++)ke(e,i,b,0,"number format");if(!k(L)||!f(b))return r?-1:i;let y=`${b}__${i}`;a(_)||(y=`${y}__${JSON.stringify(_)}`);let N=u.get(y);return N||(N=new Intl.NumberFormat(b,c({},L,_)),u.set(y,N)),h?N.formatToParts(p):N.format(p)},e.parse=V,e.parseDateTimeArgs=xe,e.parseNumberArgs=Ie,e.parseTranslateArgs=Ae,e.registerLocaleFallbacker=function(e){me=e},e.registerMessageCompiler=function(e){ie=e},e.registerMessageResolver=function(e){fe=e},e.resolveValue=function(e,t){if(!p(e))return null;let n=K.get(t);if(n||(n=V(t),n&&K.set(t,n)),!n)return null;const r=n.length;let o=e,a=0;for(;a<r;){const e=o[n[a]];if(void 0===e)return null;o=e,a++}return o},e.resolveWithKeyValue=j,e.setAdditionalMeta=e=>{pe=e},e.setDevToolsHook=function(e){Q=e},e.setFallbackContext=e=>{de=e},e.translate=function(e,...t){const{fallbackFormat:n,postTranslation:o,unresolving:a,messageCompiler:s,fallbackLocale:c,messages:i}=e,[d,_]=Ae(...t),k=m(_.missingWarn)?_.missingWarn:e.missingWarn,h=m(_.fallbackWarn)?_.fallbackWarn:e.fallbackWarn,g=m(_.escapeParameter)?_.escapeParameter:e.escapeParameter,T=!!_.resolvedMessage,b=f(_.default)||m(_.default)?m(_.default)?s?d:()=>d:_.default:n?s?d:()=>d:"",E=n||""!==b,L=f(_.locale)?_.locale:e.locale;g&&function(e){u(e.list)?e.list=e.list.map((e=>f(e)?l(e):e)):p(e.named)&&Object.keys(e.named).forEach((t=>{f(e.named[t])&&(e.named[t]=l(e.named[t]))}))}(_);let[y,N,C]=T?[d,L,i[L]||{}]:Ne(e,d,L,c,h,k),A=y,O=d;if(T||f(A)||ye(A)||E&&(A=b,O=A),!(T||(f(A)||ye(A))&&f(N)))return a?-1:d;let x=!1;const v=ye(A)?A:Ce(e,d,N,A,O,(()=>{x=!0}));if(x)return A;const I=function(e,t,n,o){const{modifiers:a,pluralRules:s,messageResolver:c,fallbackLocale:l,fallbackWarn:u,missingWarn:i,fallbackContext:m}=e,p=r=>{let o=c(n,r);if(null==o&&m){const[,,e]=Ne(m,r,t,l,u,i);o=c(e,r)}if(f(o)){let n=!1;const a=Ce(e,r,t,o,r,(()=>{n=!0}));return n?Le:a}return ye(o)?o:Le},d={locale:t,modifiers:a,pluralRules:s,messages:p};e.processor&&(d.processor=e.processor);o.list&&(d.list=o.list);o.named&&(d.named=o.named);r(o.plural)&&(d.pluralIndex=o.plural);return d}(e,N,C,_),S=function(e,t,n){return t(n)}(0,v,J(I));return o?o(S,d):S},e.translateDevTools=q,e.updateFallbackLocale=function(e,t,n){e.__localeChainCache=new Map,e.localeFallbacker(e,n,t)},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); |
'use strict' | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./dist/core-base.cjs.prod.js') | ||
module.exports = require('./dist/core-base.prod.cjs') | ||
} else { | ||
module.exports = require('./dist/core-base.cjs.js') | ||
module.exports = require('./dist/core-base.cjs') | ||
} |
{ | ||
"name": "@intlify/core-base", | ||
"version": "9.3.0-beta.1", | ||
"version": "9.3.0-beta.2", | ||
"description": "@intlify/core-base", | ||
@@ -28,7 +28,6 @@ "keywords": [ | ||
"index.js", | ||
"index.mjs", | ||
"dist" | ||
], | ||
"main": "index.js", | ||
"module": "dist/core-base.esm-bundler.mjs", | ||
"module": "dist/core-base.mjs", | ||
"unpkg": "dist/core-base.global.js", | ||
@@ -38,6 +37,6 @@ "jsdelivr": "dist/core-base.global.js", | ||
"dependencies": { | ||
"@intlify/devtools-if": "9.3.0-beta.1", | ||
"@intlify/message-compiler": "9.3.0-beta.1", | ||
"@intlify/shared": "9.3.0-beta.1", | ||
"@intlify/vue-devtools": "9.3.0-beta.1" | ||
"@intlify/devtools-if": "9.3.0-beta.2", | ||
"@intlify/message-compiler": "9.3.0-beta.2", | ||
"@intlify/shared": "9.3.0-beta.2", | ||
"@intlify/vue-devtools": "9.3.0-beta.2" | ||
}, | ||
@@ -50,4 +49,4 @@ "engines": { | ||
"formats": [ | ||
"esm-bundler", | ||
"esm-browser", | ||
"mjs", | ||
"browser", | ||
"cjs", | ||
@@ -59,10 +58,18 @@ "global" | ||
".": { | ||
"import": { | ||
"node": "./index.mjs", | ||
"default": "./dist/core-base.esm-bundler.mjs" | ||
}, | ||
"require": "./index.js" | ||
"import": "./dist/core-base.mjs", | ||
"browser": "./dist/core-base.esm-browser.js", | ||
"node": { | ||
"import": { | ||
"production": "./dist/core-base.prod.cjs", | ||
"development": "./dist/core-base.mjs", | ||
"default": "./dist/core-base.mjs" | ||
}, | ||
"require": { | ||
"production": "./dist/core-base.prod.cjs", | ||
"development": "./dist/core-base.cjs", | ||
"default": "./index.js" | ||
} | ||
} | ||
}, | ||
"./dist/*": "./dist/*", | ||
"./index.mjs": "./index.mjs", | ||
"./package.json": "./package.json" | ||
@@ -69,0 +76,0 @@ }, |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
493078
15
11630
4
+ Added@intlify/devtools-if@9.3.0-beta.2(transitive)
+ Added@intlify/message-compiler@9.3.0-beta.2(transitive)
+ Added@intlify/shared@9.3.0-beta.2(transitive)
+ Added@intlify/vue-devtools@9.3.0-beta.2(transitive)
- Removed@intlify/devtools-if@9.3.0-beta.1(transitive)
- Removed@intlify/message-compiler@9.3.0-beta.1(transitive)
- Removed@intlify/shared@9.3.0-beta.1(transitive)
- Removed@intlify/vue-devtools@9.3.0-beta.1(transitive)
Updated@intlify/shared@9.3.0-beta.2