@fanee/core 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":["bidiChars","#ctx","#source","#litKeys","#bidiIsolation","#localeMatcher","#locales","#dir","#message","#functions","#createContext"],"sources":["../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/cst/names.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/data-model/from-cst.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/errors.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/data-model/parse.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/data-model/visit.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/data-model/validate.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/dir-utils.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/functions/utils.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/functions/number.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/functions/currency.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/functions/datetime.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/functions/offset.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/functions/percent.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/functions/string.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/functions/unit.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/functions/index.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/message-value.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/functions/fallback.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/functions/unknown.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/resolve/function-context.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/resolve/resolve-function-ref.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/resolve/resolve-expression.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/resolve/resolve-variable.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/resolve/resolve-value.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/resolve/format-markup.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/select-pattern.js","../../../node_modules/.bun/messageformat@4.0.0/node_modules/messageformat/lib/messageformat.js","../src/translator.ts","../src/state.ts","../src/runtime.ts","../src/i18n.ts"],"sourcesContent":["const bidiChars = /^[\\u061c\\u200e\\u200f\\u2066-\\u2069]+/;\nconst nameChars = /^[-.+0-9A-Z_a-z\\u{a1}-\\u{61b}\\u{61d}-\\u{167f}\\u{1681}-\\u{1fff}\\u{200b}-\\u{200d}\\u{2010}-\\u{2027}\\u{2030}-\\u{205e}\\u{2060}-\\u{2065}\\u{206a}-\\u{2fff}\\u{3001}-\\u{d7ff}\\u{e000}-\\u{fdcf}\\u{fdf0}-\\u{fffd}\\u{10000}-\\u{1fffd}\\u{20000}-\\u{2fffd}\\u{30000}-\\u{3fffd}\\u{40000}-\\u{4fffd}\\u{50000}-\\u{5fffd}\\u{60000}-\\u{6fffd}\\u{70000}-\\u{7fffd}\\u{80000}-\\u{8fffd}\\u{90000}-\\u{9fffd}\\u{a0000}-\\u{afffd}\\u{b0000}-\\u{bfffd}\\u{c0000}-\\u{cfffd}\\u{d0000}-\\u{dfffd}\\u{e0000}-\\u{efffd}\\u{f0000}-\\u{ffffd}\\u{100000}-\\u{10fffd}]+/u;\nconst notNameStart = /^[-.0-9]/;\nexport function parseNameValue(source, start) {\n let pos = start;\n const startBidi = source.slice(pos).match(bidiChars);\n if (startBidi)\n pos += startBidi[0].length;\n const match = source.slice(pos).match(nameChars);\n if (!match)\n return null;\n const name = match[0];\n if (notNameStart.test(name))\n return null;\n pos += name.length;\n const endBidi = source.slice(pos).match(bidiChars);\n if (endBidi)\n pos += endBidi[0].length;\n return { value: name.normalize(), end: pos };\n}\nexport function isValidUnquotedLiteral(str) {\n const match = str.match(nameChars);\n return !!match && match[0].length === str.length;\n}\nexport const parseUnquotedLiteralValue = (source, start) => source.slice(start).match(nameChars)?.[0] ?? '';\n","import { MessageSyntaxError } from \"../errors.js\";\n/**\n * Shared symbol used as a key on message data model nodes\n * to reference their CST source.\n *\n * Only set on message data model nodes when parsed by {@link messageFromCST}.\n */\nexport const cstKey = Symbol.for('CST');\n/**\n * Convert a CST message structure into its data model representation.\n *\n * In the returned {@link Model.Message},\n * all nodes include a reference to their source {@link CST} node\n * as a {@link cstKey} symbol-keyed property.\n */\nexport function messageFromCST(msg) {\n for (const error of msg.errors)\n throw error;\n const declarations = msg.declarations\n ? msg.declarations.map(asDeclaration)\n : [];\n if (msg.type === 'select') {\n return {\n type: 'select',\n declarations,\n selectors: msg.selectors.map(sel => asValue(sel)),\n variants: msg.variants.map(variant => ({\n keys: variant.keys.map(key => key.type === '*' ? { type: '*', [cstKey]: key } : asValue(key)),\n value: asPattern(variant.value),\n [cstKey]: variant\n })),\n [cstKey]: msg\n };\n }\n else {\n return {\n type: 'message',\n declarations,\n pattern: asPattern(msg.pattern),\n [cstKey]: msg\n };\n }\n}\nfunction asDeclaration(decl) {\n switch (decl.type) {\n case 'input': {\n const value = asExpression(decl.value, false);\n if (value.arg?.type !== 'variable') {\n const { start, end } = decl.value;\n throw new MessageSyntaxError('parse-error', start, end);\n }\n return {\n type: 'input',\n name: value.arg.name,\n value: value,\n [cstKey]: decl\n };\n }\n case 'local':\n return {\n type: 'local',\n name: asValue(decl.target).name,\n value: asExpression(decl.value, false),\n [cstKey]: decl\n };\n default:\n throw new MessageSyntaxError('parse-error', decl.start, decl.end);\n }\n}\nconst asPattern = (pattern) => pattern.body.map(el => el.type === 'text' ? el.value : asExpression(el, true));\nfunction asExpression(exp, allowMarkup) {\n if (exp.type === 'expression') {\n if (allowMarkup && exp.markup) {\n const cm = exp.markup;\n const name = asName(cm.name);\n const kind = cm.open.value === '/' ? 'close' : cm.close ? 'standalone' : 'open';\n const markup = { type: 'markup', kind, name };\n if (cm.options.length)\n markup.options = asOptions(cm.options);\n if (exp.attributes.length) {\n markup.attributes = asAttributes(exp.attributes);\n }\n markup[cstKey] = exp;\n return markup;\n }\n const arg = exp.arg ? asValue(exp.arg) : undefined;\n let functionRef;\n const ca = exp.functionRef;\n if (ca) {\n if (ca.type === 'function') {\n functionRef = { type: 'function', name: asName(ca.name) };\n if (ca.options.length)\n functionRef.options = asOptions(ca.options);\n }\n else {\n throw new MessageSyntaxError('parse-error', exp.start, exp.end);\n }\n }\n let expression = arg\n ? { type: 'expression', arg }\n : undefined;\n if (functionRef) {\n functionRef[cstKey] = ca;\n if (expression)\n expression.functionRef = functionRef;\n else\n expression = { type: 'expression', functionRef: functionRef };\n }\n if (expression) {\n if (exp.attributes.length) {\n expression.attributes = asAttributes(exp.attributes);\n }\n expression[cstKey] = exp;\n return expression;\n }\n }\n throw new MessageSyntaxError('parse-error', exp.start, exp.end);\n}\nfunction asOptions(options) {\n const map = {};\n for (const opt of options) {\n const name = asName(opt.name);\n if (Object.hasOwn(map, name)) {\n throw new MessageSyntaxError('duplicate-option-name', opt.start, opt.end);\n }\n map[name] = asValue(opt.value);\n }\n return map;\n}\nfunction asAttributes(attributes) {\n const map = {};\n for (const attr of attributes) {\n const name = asName(attr.name);\n if (Object.hasOwn(map, name)) {\n throw new MessageSyntaxError('duplicate-attribute', attr.start, attr.end);\n }\n map[name] = attr.value ? asValue(attr.value) : true;\n }\n return map;\n}\nfunction asName(id) {\n switch (id.length) {\n case 1:\n return id[0].value;\n case 3:\n return `${id[0].value}:${id[2].value}`;\n default:\n throw new MessageSyntaxError('parse-error', id[0]?.start ?? -1, id.at(-1)?.end ?? -1);\n }\n}\nfunction asValue(value) {\n switch (value.type) {\n case 'literal':\n return { type: 'literal', value: value.value, [cstKey]: value };\n case 'variable':\n return { type: 'variable', name: value.name, [cstKey]: value };\n default:\n throw new MessageSyntaxError('parse-error', value.start, value.end);\n }\n}\n","import { cstKey } from \"./data-model/from-cst.js\";\n/**\n * Base error class used by MessageFormat\n *\n * @category Errors\n */\nexport class MessageError extends Error {\n type;\n constructor(type, message) {\n super(message);\n this.type = type;\n }\n}\n/**\n * Errors in the message syntax.\n *\n * @category Errors\n */\nexport class MessageSyntaxError extends MessageError {\n start;\n end;\n /** @private */\n constructor(type, start, end, expected) {\n let message = expected ? `Missing ${expected}` : type;\n if (start >= 0)\n message += ` at ${start}`;\n super(type, message);\n this.start = start;\n this.end = end ?? start + 1;\n }\n}\n/**\n * Errors in the message data model.\n *\n * @category Errors\n */\nexport class MessageDataModelError extends MessageSyntaxError {\n /** @private */\n constructor(type, node) {\n const { start, end } = node[cstKey] ?? { start: -1, end: -1 };\n super(type, start, end);\n }\n}\n/**\n * Message runtime resolution errors\n *\n * @category Errors\n */\nexport class MessageResolutionError extends MessageError {\n source;\n cause;\n constructor(type, message, source, cause) {\n super(type, message);\n this.source = source;\n if (cause !== undefined)\n this.cause = cause;\n }\n}\n/**\n * Message runtime resolution errors\n *\n * @category Errors\n */\nexport class MessageFunctionError extends MessageError {\n source;\n cause;\n constructor(type, message) {\n super(type, message);\n this.source = '�';\n }\n}\n","import { parseNameValue, parseUnquotedLiteralValue } from \"../cst/names.js\";\nimport { MessageSyntaxError } from \"../errors.js\";\nconst bidiChars = new Set('\\u061C\\u200E\\u200F\\u2066\\u2067\\u2068\\u2069');\nconst whitespaceChars = new Set('\\t\\n\\r \\u3000');\n//// Parser State ////\nlet pos;\nlet source;\n//// Utilities & Error Wrappers ////\n// These indirections allow for the function names to be mangled,\n// while keeping the error class name intact.\nconst MissingSyntax = (pos, expected) => new MessageSyntaxError('missing-syntax', pos, pos + expected.length, expected);\nconst SyntaxError = (...args) => new MessageSyntaxError(...args);\nfunction expect(searchString, consume) {\n if (source.startsWith(searchString, pos)) {\n if (consume)\n pos += searchString.length;\n }\n else {\n throw MissingSyntax(pos, searchString);\n }\n}\nexport function parseMessage(source_) {\n pos = 0;\n source = source_;\n const decl = declarations();\n if (source.startsWith('.match', pos))\n return selectMessage(decl);\n const quoted = decl.length > 0 || source.startsWith('{{', pos);\n if (!quoted && pos > 0)\n pos = 0;\n const pattern_ = pattern(quoted);\n if (quoted) {\n ws();\n if (pos < source.length) {\n throw SyntaxError('extra-content', pos, source.length);\n }\n }\n return { type: 'message', declarations: decl, pattern: pattern_ };\n}\nfunction selectMessage(declarations) {\n pos += 6; // '.match'\n ws(true);\n const selectors = [];\n while (source[pos] === '$') {\n selectors.push(variable());\n ws(true);\n }\n if (selectors.length === 0)\n throw SyntaxError('empty-token', pos);\n const variants = [];\n while (pos < source.length) {\n variants.push(variant());\n ws();\n }\n return { type: 'select', declarations, selectors, variants };\n}\nfunction variant() {\n const keys = [];\n while (pos < source.length) {\n ws(keys.length ? '{' : false);\n const next = source[pos];\n if (next === '{')\n break;\n if (next === '*') {\n keys.push({ type: '*' });\n pos += 1;\n }\n else {\n const key = literal(true);\n key.value = key.value.normalize();\n keys.push(key);\n }\n }\n return { keys, value: pattern(true) };\n}\nfunction pattern(quoted) {\n if (quoted) {\n if (source.startsWith('{{', pos))\n pos += 2;\n else\n throw MissingSyntax(pos, '{{');\n }\n const pattern = [];\n loop: while (pos < source.length) {\n switch (source[pos]) {\n case '{': {\n pattern.push(expression(true));\n break;\n }\n case '}':\n if (!quoted)\n throw SyntaxError('parse-error', pos);\n break loop;\n default: {\n pattern.push(text());\n }\n }\n }\n if (quoted) {\n if (source.startsWith('}}', pos))\n pos += 2;\n else\n throw MissingSyntax(pos, '}}');\n }\n return pattern;\n}\nfunction declarations() {\n const declarations = [];\n ws();\n loop: while (source[pos] === '.') {\n const keyword = source.substr(pos, 6);\n switch (keyword) {\n case '.input':\n declarations.push(inputDeclaration());\n break;\n case '.local':\n declarations.push(localDeclaration());\n break;\n case '.match':\n break loop;\n default:\n throw SyntaxError('parse-error', pos);\n }\n ws();\n }\n return declarations;\n}\nfunction inputDeclaration() {\n pos += 6; // '.input'\n ws();\n expect('{', false);\n const valueStart = pos;\n const value = expression(false);\n if (value.type === 'expression' && value.arg?.type === 'variable') {\n // @ts-expect-error TS isn't catching that value is Expression<VariableRef>\n return { type: 'input', name: value.arg.name, value };\n }\n throw SyntaxError('bad-input-expression', valueStart, pos);\n}\nfunction localDeclaration() {\n pos += 6; // '.local'\n ws(true);\n expect('$', true);\n const name_ = name();\n ws();\n expect('=', true);\n ws();\n expect('{', false);\n const value = expression(false);\n return { type: 'local', name: name_, value };\n}\nfunction expression(allowMarkup) {\n const start = pos;\n pos += 1; // '{'\n ws();\n const arg = value(false);\n if (arg)\n ws('}');\n const sigil = source[pos];\n let functionRef;\n let markup;\n switch (sigil) {\n case '@':\n case '}':\n break;\n case ':': {\n pos += 1; // ':'\n functionRef = { type: 'function', name: identifier() };\n const options_ = options();\n if (options_)\n functionRef.options = options_;\n break;\n }\n case '#':\n case '/': {\n if (arg || !allowMarkup)\n throw SyntaxError('parse-error', pos);\n pos += 1; // '#' or '/'\n const kind = sigil === '#' ? 'open' : 'close';\n markup = { type: 'markup', kind, name: identifier() };\n const options_ = options();\n if (options_)\n markup.options = options_;\n break;\n }\n default:\n throw SyntaxError('parse-error', pos);\n }\n const attributes_ = attributes();\n if (markup?.kind === 'open' && source[pos] === '/') {\n markup.kind = 'standalone';\n pos += 1; // '/'\n }\n expect('}', true);\n if (functionRef) {\n const exp = arg\n ? { type: 'expression', arg, functionRef: functionRef }\n : { type: 'expression', functionRef: functionRef };\n if (attributes_)\n exp.attributes = attributes_;\n return exp;\n }\n if (markup) {\n if (attributes_)\n markup.attributes = attributes_;\n return markup;\n }\n if (!arg)\n throw SyntaxError('empty-token', start, pos);\n return attributes_\n ? { type: 'expression', arg, attributes: attributes_ }\n : { type: 'expression', arg };\n}\n/** Requires and consumes leading and trailing whitespace. */\nfunction options() {\n ws('/}');\n const options = {};\n let isEmpty = true;\n while (pos < source.length) {\n const next = source[pos];\n if (next === '@' || next === '/' || next === '}')\n break;\n const start = pos;\n const name_ = identifier();\n if (Object.hasOwn(options, name_)) {\n throw SyntaxError('duplicate-option-name', start, pos);\n }\n ws();\n expect('=', true);\n ws();\n options[name_] = value(true);\n isEmpty = false;\n ws('/}');\n }\n return isEmpty ? null : options;\n}\nfunction attributes() {\n const attributes = {};\n let isEmpty = true;\n while (source[pos] === '@') {\n const start = pos;\n pos += 1; // '@'\n const name_ = identifier();\n if (Object.hasOwn(attributes, name_)) {\n throw SyntaxError('duplicate-attribute', start, pos);\n }\n ws('=/}');\n if (source[pos] === '=') {\n pos += 1; // '='\n ws();\n attributes[name_] = literal(true);\n ws('/}');\n }\n else {\n attributes[name_] = true;\n }\n isEmpty = false;\n }\n return isEmpty ? null : attributes;\n}\nfunction text() {\n let value = '';\n let i = pos;\n loop: for (; i < source.length; ++i) {\n switch (source[i]) {\n case '\\\\': {\n const esc = source[i + 1];\n if (!'\\\\{|}'.includes(esc))\n throw SyntaxError('bad-escape', i, i + 2);\n value += source.substring(pos, i) + esc;\n i += 1;\n pos = i + 1;\n break;\n }\n case '{':\n case '}':\n break loop;\n }\n }\n value += source.substring(pos, i);\n pos = i;\n return value;\n}\nfunction value(required) {\n return source[pos] === '$' ? variable() : literal(required);\n}\nfunction variable() {\n pos += 1; // '$'\n return { type: 'variable', name: name() };\n}\nfunction literal(required) {\n if (source[pos] === '|')\n return quotedLiteral();\n const value = parseUnquotedLiteralValue(source, pos);\n if (!value) {\n if (required)\n throw SyntaxError('empty-token', pos);\n else\n return undefined;\n }\n pos += value.length;\n return { type: 'literal', value };\n}\nfunction quotedLiteral() {\n pos += 1; // '|'\n let value = '';\n for (let i = pos; i < source.length; ++i) {\n switch (source[i]) {\n case '\\\\': {\n const esc = source[i + 1];\n if (!'\\\\{|}'.includes(esc))\n throw SyntaxError('bad-escape', i, i + 2);\n value += source.substring(pos, i) + esc;\n i += 1;\n pos = i + 1;\n break;\n }\n case '|':\n value += source.substring(pos, i);\n pos = i + 1;\n return { type: 'literal', value };\n }\n }\n throw MissingSyntax(source.length, '|');\n}\nfunction identifier() {\n const name_ = name();\n if (source[pos] === ':') {\n pos += 1;\n return name_ + ':' + name();\n }\n return name_;\n}\nfunction name() {\n const name = parseNameValue(source, pos);\n if (!name)\n throw SyntaxError('empty-token', pos);\n pos = name.end;\n return name.value;\n}\nfunction ws(req = false) {\n let next = source[pos];\n let hasWS = false;\n if (req) {\n while (bidiChars.has(next))\n next = source[++pos];\n while (whitespaceChars.has(next)) {\n next = source[++pos];\n hasWS = true;\n }\n }\n while (bidiChars.has(next) || whitespaceChars.has(next))\n next = source[++pos];\n if (req && !hasWS && (req === true || !req.includes(source[pos]))) {\n throw MissingSyntax(pos, \"' '\");\n }\n}\n","/**\n * Apply visitor functions to message nodes.\n *\n * The visitors are applied in source order, starting from the root.\n * Visitors for nodes that contain other nodes may return a callback function\n * that will be called with no arguments when exiting the node.\n *\n * If set, the `node` visitor is called for all {@link Node} values\n * for which an explicit visitor is not defined.\n *\n * Many visitors will be called with additional arguments\n * identifying some of the context for the visited node.\n *\n * @category Message Data Model\n */\nexport function visit(msg, visitors) {\n const { node, pattern } = visitors;\n const { functionRef = node, attributes = null, declaration = node, expression = node, key = node, markup = node, options = null, value = node, variant = node } = visitors;\n const handleOptions = (options_, context) => {\n if (options_) {\n const end = options?.(options_, context);\n if (value) {\n for (const value_ of Object.values(options_)) {\n value(value_, context, 'option');\n }\n }\n end?.();\n }\n };\n const handleAttributes = (attributes_, context) => {\n if (attributes_) {\n const end = attributes?.(attributes_, context);\n if (value) {\n for (const value_ of Object.values(attributes_)) {\n if (value_ !== true)\n value(value_, context, 'attribute');\n }\n }\n end?.();\n }\n };\n const handleElement = (exp, context) => {\n if (typeof exp === 'object') {\n let end;\n switch (exp.type) {\n case 'expression': {\n end = expression?.(exp, context);\n if (exp.arg)\n value?.(exp.arg, context, 'arg');\n if (exp.functionRef) {\n const endA = functionRef?.(exp.functionRef, context, exp.arg);\n handleOptions(exp.functionRef.options, context);\n endA?.();\n }\n handleAttributes(exp.attributes, context);\n break;\n }\n case 'markup': {\n end = markup?.(exp, context);\n handleOptions(exp.options, context);\n handleAttributes(exp.attributes, context);\n break;\n }\n }\n end?.();\n }\n };\n const handlePattern = (pat) => {\n const end = pattern?.(pat);\n for (const el of pat)\n handleElement(el, 'placeholder');\n end?.();\n };\n for (const decl of msg.declarations) {\n const end = declaration?.(decl);\n if (decl.value)\n handleElement(decl.value, 'declaration');\n end?.();\n }\n if (msg.type === 'message') {\n handlePattern(msg.pattern);\n }\n else {\n if (value)\n for (const sel of msg.selectors)\n value(sel, 'selector', 'arg');\n for (const vari of msg.variants) {\n const end = variant?.(vari);\n if (key)\n vari.keys.forEach(key);\n handlePattern(vari.value);\n end?.();\n }\n }\n}\n","import { MessageDataModelError } from \"../errors.js\";\nimport { visit } from \"./visit.js\";\n/**\n * Ensure that the `msg` data model is _valid_, calling `onError` on errors.\n * If `onError` is not defined, a {@link MessageDataModelError} will be thrown on error.\n *\n * Detects the following errors:\n *\n * - `'key-mismatch'`: **Variant Key Mismatch**<br>\n * The number of keys on a _variant_ does not equal the number of _selectors_.\n *\n * - `'missing-fallback'`: **Missing Fallback Variant**<br>\n * The message does not include a _variant_ with only catch-all keys.\n *\n * - `'missing-selector-annotation'`: **Missing Selector Annotation**<br>\n * A _selector_ does not contains a _variable_ that directly or indirectly\n * reference a _declaration_ with a _function_.\n *\n * - `'duplicate-declaration'`: **Duplicate Declaration**<br>\n * A _variable_ appears in two _declarations_.\n *\n * - `'duplicate-variant'`: **Duplicate Variant**<br>\n * The same list of _keys_ is used for more than one _variant_.\n *\n * @category Message Data Model\n * @returns The sets of runtime `functions` and `variables` used by the message.\n */\nexport function validate(msg, onError = (type, node) => {\n throw new MessageDataModelError(type, node);\n}) {\n let selectorCount = 0;\n let missingFallback = null;\n /** Tracks directly & indirectly annotated variables for `missing-selector-annotation` */\n const annotated = new Set();\n /** Tracks declared variables for `duplicate-declaration` */\n const declared = new Set();\n const functions = new Set();\n const localVars = new Set();\n const variables = new Set();\n const variants = new Set();\n let setArgAsDeclared = true;\n visit(msg, {\n declaration(decl) {\n // Skip all ReservedStatement\n if (!decl.name)\n return undefined;\n if (decl.value.functionRef ||\n (decl.type === 'local' &&\n decl.value.arg?.type === 'variable' &&\n annotated.has(decl.value.arg.name))) {\n annotated.add(decl.name);\n }\n if (decl.type === 'local')\n localVars.add(decl.name);\n setArgAsDeclared = decl.type === 'local';\n return () => {\n if (declared.has(decl.name))\n onError('duplicate-declaration', decl);\n else\n declared.add(decl.name);\n };\n },\n expression({ functionRef }) {\n if (functionRef)\n functions.add(functionRef.name);\n },\n value(value, context, position) {\n if (value.type !== 'variable')\n return;\n variables.add(value.name);\n switch (context) {\n case 'declaration':\n if (position !== 'arg' || setArgAsDeclared) {\n declared.add(value.name);\n }\n break;\n case 'selector':\n selectorCount += 1;\n missingFallback = value;\n if (!annotated.has(value.name)) {\n onError('missing-selector-annotation', value);\n }\n }\n },\n variant(variant) {\n const { keys } = variant;\n if (keys.length !== selectorCount)\n onError('key-mismatch', variant);\n const strKeys = JSON.stringify(keys.map(key => (key.type === 'literal' ? key.value : 0)));\n if (variants.has(strKeys))\n onError('duplicate-variant', variant);\n else\n variants.add(strKeys);\n missingFallback &&= keys.every(key => key.type === '*') ? null : variant;\n }\n });\n if (missingFallback)\n onError('missing-fallback', missingFallback);\n for (const lv of localVars)\n variables.delete(lv);\n return { functions, variables };\n}\n","export const LRI = '\\u2066';\nexport const RLI = '\\u2067';\nexport const FSI = '\\u2068';\nexport const PDI = '\\u2069';\n// Data source: RECOMMENDED and LIMITED_USE scripts from\n// https://github.com/unicode-org/cldr/blob/1a914d1/common/properties/scriptMetadata.txt\nconst RTL = 'Adlm,Arab,Hebr,Mand,Nkoo,Rohg,Syrc,Thaa';\n/** Get a default text direction for `locale`. */\nexport function getLocaleDir(locale) {\n if (locale) {\n try {\n if (typeof locale === 'string')\n locale = new Intl.Locale(locale);\n // @ts-expect-error -- New feature, API changed during Stage 3\n const info = locale.getTextInfo?.() ?? locale.textInfo;\n if (info?.direction)\n return info.direction;\n const script = locale.maximize().script;\n if (script)\n return RTL.includes(script) ? 'rtl' : 'ltr';\n }\n catch {\n // Use 'auto' on error\n }\n }\n return 'auto';\n}\n","/**\n * Utility function for custom functions.\n * Cast a value as a Boolean,\n * unwrapping objects using their `valueOf()` methods.\n * Also accepts `'true'` and `'false'`.\n * Throws a `RangeError` for invalid inputs.\n */\nexport function asBoolean(value) {\n if (value && typeof value === 'object')\n value = value.valueOf();\n if (typeof value === 'boolean')\n return value;\n if (value && typeof value === 'object')\n value = String(value);\n if (value === 'true')\n return true;\n if (value === 'false')\n return false;\n throw new RangeError('Not a boolean');\n}\n/**\n * Utility function for custom functions.\n * Cast a value as a non-negative integer,\n * unwrapping objects using their `valueOf()` methods.\n * Also accepts JSON string reprentations of integers.\n * Throws a `RangeError` for invalid inputs.\n *\n * The default functions use this to validate _digit size options_.\n */\nexport function asPositiveInteger(value) {\n if (value && typeof value === 'object')\n value = value.valueOf();\n if (value && typeof value === 'object')\n value = String(value);\n if (typeof value === 'string' && /^(0|[1-9][0-9]*)$/.test(value)) {\n value = Number(value);\n }\n if (typeof value === 'number' && value >= 0 && Number.isInteger(value)) {\n return value;\n }\n throw new RangeError('Not a positive integer');\n}\n/**\n * Utility function for custom functions.\n * Cast a value as a string,\n * unwrapping objects using their `valueOf()` methods.\n * Throws a `RangeError` for invalid inputs.\n */\nexport function asString(value) {\n if (value && typeof value === 'object')\n value = value.valueOf();\n if (typeof value === 'string')\n return value;\n if (value && typeof value === 'object')\n return String(value);\n throw new RangeError('Not a string');\n}\n","import { getLocaleDir } from \"../dir-utils.js\";\nimport { MessageFunctionError } from \"../errors.js\";\nimport { asPositiveInteger, asString } from \"./utils.js\";\nexport function readNumericOperand(value) {\n let options = undefined;\n if (typeof value === 'object') {\n const valueOf = value?.valueOf;\n if (typeof valueOf === 'function') {\n options = value.options;\n value = valueOf.call(value);\n }\n }\n if (typeof value === 'string') {\n try {\n value = JSON.parse(value);\n }\n catch {\n // handled below\n }\n }\n if (typeof value !== 'bigint' && typeof value !== 'number') {\n throw new MessageFunctionError('bad-operand', 'Input is not numeric');\n }\n return { value, options };\n}\nexport function getMessageNumber(ctx, value, options, canSelect) {\n let { dir, locales } = ctx;\n // @ts-expect-error We may have been a bit naughty earlier.\n if (options.useGrouping === 'never')\n options.useGrouping = false;\n if (canSelect &&\n 'select' in options &&\n !ctx.literalOptionKeys.has('select')) {\n ctx.onError('bad-option', 'The option select may only be set by a literal value');\n canSelect = false;\n }\n let locale;\n let nf;\n let cat;\n let str;\n return {\n type: 'number',\n get dir() {\n if (dir == null) {\n locale ??= Intl.NumberFormat.supportedLocalesOf(locales, options)[0];\n dir = getLocaleDir(locale);\n }\n return dir;\n },\n get options() {\n return { ...options };\n },\n selectKey: canSelect\n ? keys => {\n let numVal = value;\n if (options.style === 'percent') {\n if (typeof numVal === 'bigint')\n numVal *= 100n;\n else\n numVal *= 100;\n }\n const str = String(numVal);\n if (keys.has(str))\n return str;\n if (options.select === 'exact')\n return null;\n const pluralOpt = options.select\n ? { ...options, select: undefined, type: options.select }\n : options;\n // Intl.PluralRules needs a number, not bigint\n cat ??= new Intl.PluralRules(locales, pluralOpt).select(Number(numVal));\n return keys.has(cat) ? cat : null;\n }\n : undefined,\n toParts() {\n nf ??= new Intl.NumberFormat(locales, options);\n const parts = nf.formatToParts(value);\n locale ??= nf.resolvedOptions().locale;\n dir ??= getLocaleDir(locale);\n return dir === 'ltr' || dir === 'rtl'\n ? [{ type: 'number', dir, locale, parts }]\n : [{ type: 'number', locale, parts }];\n },\n toString() {\n nf ??= new Intl.NumberFormat(locales, options);\n str ??= nf.format(value);\n return str;\n },\n valueOf: () => value\n };\n}\nexport function number(ctx, exprOpt, operand) {\n const input = readNumericOperand(operand);\n const value = input.value;\n const options = Object.assign({}, input.options, {\n localeMatcher: ctx.localeMatcher,\n style: 'decimal'\n });\n for (const [name, optval] of Object.entries(exprOpt)) {\n if (optval === undefined)\n continue;\n try {\n switch (name) {\n case 'minimumIntegerDigits':\n case 'minimumFractionDigits':\n case 'maximumFractionDigits':\n case 'minimumSignificantDigits':\n case 'maximumSignificantDigits':\n case 'roundingIncrement':\n // @ts-expect-error TS types don't know about roundingIncrement\n options[name] = asPositiveInteger(optval);\n break;\n case 'roundingMode':\n case 'roundingPriority':\n case 'select': // Called 'type' in Intl.PluralRules\n case 'signDisplay':\n case 'trailingZeroDisplay':\n case 'useGrouping':\n // @ts-expect-error Let Intl.NumberFormat construction fail\n options[name] = asString(optval);\n }\n }\n catch {\n ctx.onError('bad-option', `Value ${optval} is not valid for :number option ${name}`);\n }\n }\n return getMessageNumber(ctx, value, options, true);\n}\nexport function integer(ctx, exprOpt, operand) {\n const input = readNumericOperand(operand);\n const value = Number.isFinite(input.value)\n ? Math.round(input.value)\n : input.value;\n const options = Object.assign({}, input.options, {\n //localeMatcher: ctx.localeMatcher,\n maximumFractionDigits: 0,\n minimumFractionDigits: undefined,\n minimumSignificantDigits: undefined,\n style: 'decimal'\n });\n for (const [name, optval] of Object.entries(exprOpt)) {\n if (optval === undefined)\n continue;\n try {\n switch (name) {\n case 'minimumIntegerDigits':\n case 'maximumSignificantDigits':\n options[name] = asPositiveInteger(optval);\n break;\n case 'select': // Called 'type' in Intl.PluralRules\n case 'signDisplay':\n case 'useGrouping':\n // @ts-expect-error Let Intl.NumberFormat construction fail\n options[name] = asString(optval);\n }\n }\n catch {\n ctx.onError('bad-option', `Value ${optval} is not valid for :integer option ${name}`);\n }\n }\n return getMessageNumber(ctx, value, options, true);\n}\n","import { MessageFunctionError } from \"../errors.js\";\nimport { getMessageNumber, readNumericOperand } from \"./number.js\";\nimport { asPositiveInteger, asString } from \"./utils.js\";\n/**\n * `currency` accepts as input numerical values as well as\n * objects wrapping a numerical value that also include a `currency` property.\n *\n * @beta\n */\nexport function currency(ctx, exprOpt, operand) {\n const input = readNumericOperand(operand);\n const options = Object.assign({}, input.options, {\n localeMatcher: ctx.localeMatcher,\n style: 'currency'\n });\n for (const [name, optval] of Object.entries(exprOpt)) {\n if (optval === undefined)\n continue;\n try {\n switch (name) {\n case 'currency':\n case 'currencySign':\n case 'roundingMode':\n case 'roundingPriority':\n case 'trailingZeroDisplay':\n case 'useGrouping':\n // @ts-expect-error Let Intl.NumberFormat construction fail\n options[name] = asString(optval);\n break;\n case 'minimumIntegerDigits':\n case 'minimumSignificantDigits':\n case 'maximumSignificantDigits':\n case 'roundingIncrement':\n // @ts-expect-error TS types don't know about roundingIncrement\n options[name] = asPositiveInteger(optval);\n break;\n case 'currencyDisplay': {\n const strval = asString(optval);\n if (strval === 'never') {\n ctx.onError('unsupported-operation', 'Currency display \"never\" is not yet supported');\n }\n else {\n // @ts-expect-error Let Intl.NumberFormat construction fail\n options[name] = strval;\n }\n break;\n }\n case 'fractionDigits': {\n const strval = asString(optval);\n if (strval === 'auto') {\n options.minimumFractionDigits = undefined;\n options.maximumFractionDigits = undefined;\n }\n else {\n const numval = asPositiveInteger(strval);\n options.minimumFractionDigits = numval;\n options.maximumFractionDigits = numval;\n }\n break;\n }\n }\n }\n catch {\n ctx.onError('bad-option', `Value ${optval} is not valid for :currency option ${name}`);\n }\n }\n if (!options.currency) {\n throw new MessageFunctionError('bad-operand', 'A currency code is required for :currency');\n }\n return getMessageNumber(ctx, input.value, options, false);\n}\n","import { getLocaleDir } from \"../dir-utils.js\";\nimport { MessageFunctionError } from \"../errors.js\";\nimport { asBoolean, asString } from \"./utils.js\";\nconst dateFieldsValues = new Set([\n 'weekday',\n 'day-weekday',\n 'month-day',\n 'month-day-weekday',\n 'year-month-day',\n 'year-month-day-weekday'\n]);\nconst dateLengthValues = new Set(['long', 'medium', 'short']);\nconst timePrecisionValues = new Set(['hour', 'minute', 'second']);\nconst timeZoneStyleValues = new Set(['long', 'short']);\n/**\n * The function `:datetime` is used to format a date/time value.\n * Its formatted result will always include both the date and the time, and optionally a timezone.\n *\n * @beta\n */\nexport const datetime = (ctx, options, operand) => dateTimeImplementation('datetime', ctx, options, operand);\n/**\n * The function `:date` is used to format the date portion of date/time values.\n *\n * @beta\n */\nexport const date = (ctx, options, operand) => dateTimeImplementation('date', ctx, options, operand);\n/**\n * The function `:time` is used to format the time portion of date/time values.\n * Its formatted result will always include the time, and optionally a timezone.\n *\n * @beta\n */\nexport const time = (ctx, options, operand) => dateTimeImplementation('time', ctx, options, operand);\nfunction dateTimeImplementation(functionName, ctx, exprOpt, operand) {\n const options = {\n localeMatcher: ctx.localeMatcher\n };\n let value = operand;\n if (typeof value === 'object' && value !== null) {\n const opt = value.options;\n if (opt) {\n options.calendar = opt.calendar;\n if (functionName !== 'date')\n options.hour12 = opt.hour12;\n options.timeZone = opt.timeZone;\n }\n if (typeof value.valueOf === 'function')\n value = value.valueOf();\n }\n switch (typeof value) {\n case 'number':\n case 'string':\n value = new Date(value);\n }\n if (!(value instanceof Date) || isNaN(value.getTime())) {\n throw new MessageFunctionError('bad-operand', 'Input is not a valid date');\n }\n // Override options\n if (exprOpt.calendar !== undefined) {\n try {\n options.calendar = asString(exprOpt.calendar);\n }\n catch {\n ctx.onError('bad-option', `Invalid :${functionName} calendar option value`);\n }\n }\n if (exprOpt.hour12 !== undefined && functionName !== 'date') {\n try {\n options.hour12 = asBoolean(exprOpt.hour12);\n }\n catch {\n ctx.onError('bad-option', `Invalid :${functionName} hour12 option value`);\n }\n }\n if (exprOpt.timeZone !== undefined) {\n let tz;\n try {\n tz = asString(exprOpt.timeZone);\n }\n catch {\n ctx.onError('bad-option', `Invalid :${functionName} timeZone option value`);\n }\n if (tz === 'input') {\n if (options.timeZone === undefined) {\n ctx.onError('bad-operand', `Missing input timeZone value for :${functionName}`);\n }\n }\n else if (tz !== undefined) {\n if (options.timeZone !== undefined && tz !== options.timeZone) {\n // Use fallback value for expression\n throw new MessageFunctionError('bad-option', 'Time zone conversion is not supported');\n }\n options.timeZone = tz;\n }\n }\n // Date formatting options\n if (functionName !== 'time') {\n const dfName = functionName === 'date' ? 'fields' : 'dateFields';\n const dlName = functionName === 'date' ? 'length' : 'dateLength';\n const dateFieldsValue = readStringOption(ctx, exprOpt, dfName, dateFieldsValues) ??\n 'year-month-day';\n const dateLength = readStringOption(ctx, exprOpt, dlName, dateLengthValues);\n const dateFields = new Set(dateFieldsValue.split('-'));\n if (dateFields.has('year'))\n options.year = 'numeric';\n if (dateFields.has('month')) {\n options.month =\n dateLength === 'long'\n ? 'long'\n : dateLength === 'short'\n ? 'numeric'\n : 'short';\n }\n if (dateFields.has('day'))\n options.day = 'numeric';\n if (dateFields.has('weekday')) {\n options.weekday = dateLength === 'long' ? 'long' : 'short';\n }\n }\n // Time formatting options\n if (functionName !== 'date') {\n const tpName = functionName === 'time' ? 'precision' : 'timePrecision';\n switch (readStringOption(ctx, exprOpt, tpName, timePrecisionValues)) {\n case 'hour':\n options.hour = 'numeric';\n break;\n case 'second':\n options.hour = 'numeric';\n options.minute = 'numeric';\n options.second = 'numeric';\n break;\n default:\n options.hour = 'numeric';\n options.minute = 'numeric';\n }\n options.timeZoneName = readStringOption(ctx, exprOpt, 'timeZoneStyle', timeZoneStyleValues);\n }\n // Resolved value\n const dtf = new Intl.DateTimeFormat(ctx.locales, options);\n let dir = ctx.dir;\n let locale;\n let str;\n return {\n type: 'datetime',\n get dir() {\n if (dir == null) {\n locale ??= dtf.resolvedOptions().locale;\n dir = getLocaleDir(locale);\n }\n return dir;\n },\n get options() {\n return { ...options };\n },\n toParts() {\n const parts = dtf.formatToParts(value);\n locale ??= dtf.resolvedOptions().locale;\n dir ??= getLocaleDir(locale);\n return dir === 'ltr' || dir === 'rtl'\n ? [{ type: 'datetime', dir, locale, parts }]\n : [{ type: 'datetime', locale, parts }];\n },\n toString() {\n str ??= dtf.format(value);\n return str;\n },\n valueOf: () => value\n };\n}\nfunction readStringOption(ctx, options, name, allowed) {\n const value = options[name];\n if (value !== undefined) {\n try {\n const str = asString(value);\n if (allowed && !allowed.has(str))\n throw Error();\n return str;\n }\n catch {\n ctx.onError('bad-option', `Invalid value for ${name} option`);\n }\n }\n return undefined;\n}\n","import { MessageFunctionError } from \"../errors.js\";\nimport { number, readNumericOperand } from \"./number.js\";\nimport { asPositiveInteger } from \"./utils.js\";\n/**\n * `offset` accepts a numeric value as input and adds or subtracts an integer value from it\n *\n * @beta\n */\nexport function offset(ctx, exprOpt, operand) {\n let { value, options } = readNumericOperand(operand);\n let add;\n try {\n add = 'add' in exprOpt ? asPositiveInteger(exprOpt.add) : -1;\n }\n catch {\n throw new MessageFunctionError('bad-option', `Value ${exprOpt.add} is not valid for :offset option add`);\n }\n let sub;\n try {\n sub = 'subtract' in exprOpt ? asPositiveInteger(exprOpt.subtract) : -1;\n }\n catch {\n throw new MessageFunctionError('bad-option', `Value ${exprOpt.subtract} is not valid for :offset option subtract`);\n }\n if (add < 0 === sub < 0) {\n const msg = 'Exactly one of \"add\" or \"subtract\" is required as an :offset option';\n throw new MessageFunctionError('bad-option', msg);\n }\n const delta = add < 0 ? -sub : add;\n if (typeof value === 'number')\n value += delta;\n else\n value += BigInt(delta);\n return number(ctx, {}, { valueOf: () => value, options });\n}\n","import { getMessageNumber, readNumericOperand } from \"./number.js\";\nimport { asPositiveInteger, asString } from \"./utils.js\";\n/**\n * The function `:percent` is a selector and formatter for percent values.\n *\n * @beta\n */\nexport function percent(ctx, exprOpt, operand) {\n const input = readNumericOperand(operand);\n const options = Object.assign({}, input.options, {\n localeMatcher: ctx.localeMatcher,\n style: 'percent'\n });\n for (const [name, optval] of Object.entries(exprOpt)) {\n if (optval === undefined)\n continue;\n try {\n switch (name) {\n case 'roundingMode':\n case 'roundingPriority':\n case 'signDisplay':\n case 'trailingZeroDisplay':\n case 'useGrouping':\n // @ts-expect-error Let Intl.NumberFormat construction fail\n options[name] = asString(optval);\n break;\n case 'minimumFractionDigits':\n case 'maximumFractionDigits':\n case 'minimumSignificantDigits':\n case 'maximumSignificantDigits':\n options[name] = asPositiveInteger(optval);\n break;\n }\n }\n catch {\n ctx.onError('bad-option', `Value ${optval} is not valid for :percent option ${name}`);\n }\n }\n return getMessageNumber(ctx, input.value, options, true);\n}\n","export function string(ctx, _options, operand) {\n const str = operand === undefined ? '' : String(operand);\n const selStr = str.normalize();\n return {\n type: 'string',\n dir: ctx.dir ?? 'auto',\n selectKey: keys => (keys.has(selStr) ? selStr : null),\n toParts() {\n const { dir } = ctx;\n const locale = ctx.locales[0];\n return dir === 'ltr' || dir === 'rtl'\n ? [{ type: 'string', dir, locale, value: str }]\n : [{ type: 'string', locale, value: str }];\n },\n toString: () => str,\n valueOf: () => str\n };\n}\n","import { MessageError, MessageFunctionError } from \"../errors.js\";\nimport { getMessageNumber, readNumericOperand } from \"./number.js\";\nimport { asPositiveInteger, asString } from \"./utils.js\";\n/**\n * `unit` accepts as input numerical values as well as\n * objects wrapping a numerical value that also include a `unit` property.\n *\n * @beta\n */\nexport function unit(ctx, exprOpt, operand) {\n const input = readNumericOperand(operand);\n const options = Object.assign({}, input.options, {\n localeMatcher: ctx.localeMatcher,\n style: 'unit'\n });\n for (const [name, optval] of Object.entries(exprOpt)) {\n if (optval === undefined)\n continue;\n try {\n switch (name) {\n case 'signDisplay':\n case 'roundingMode':\n case 'roundingPriority':\n case 'trailingZeroDisplay':\n case 'unit':\n case 'unitDisplay':\n case 'useGrouping':\n // @ts-expect-error Let Intl.NumberFormat construction fail\n options[name] = asString(optval);\n break;\n case 'minimumIntegerDigits':\n case 'minimumFractionDigits':\n case 'maximumFractionDigits':\n case 'minimumSignificantDigits':\n case 'maximumSignificantDigits':\n case 'roundingIncrement':\n // @ts-expect-error TS types don't know about roundingIncrement\n options[name] = asPositiveInteger(optval);\n break;\n }\n }\n catch (error) {\n if (error instanceof MessageError) {\n ctx.onError(error);\n }\n else {\n ctx.onError('bad-option', `Value ${optval} is not valid for :currency option ${name}`);\n }\n }\n }\n if (!options.unit) {\n throw new MessageFunctionError('bad-operand', 'A unit identifier is required for :unit');\n }\n return getMessageNumber(ctx, input.value, options, false);\n}\n","/**\n * Implementations for :number, :string, and other default functions,\n * along with some utilities for building custom function handlers.\n *\n * ```js\n * import { MessageFormat } from 'messageformat';\n * import { DraftFunctions } from 'messageformat/functions';\n *\n * const mf = new MessageFormat(locale, msgSrc, { functions: DraftFunctions });\n * ```\n *\n * @module\n */\nexport { getLocaleDir } from \"../dir-utils.js\";\nexport { asBoolean, asPositiveInteger, asString } from \"./utils.js\";\nimport { currency } from \"./currency.js\";\nimport { date, datetime, time } from \"./datetime.js\";\nimport { integer, number } from \"./number.js\";\nimport { offset } from \"./offset.js\";\nimport { percent } from \"./percent.js\";\nimport { string } from \"./string.js\";\nimport { unit } from \"./unit.js\";\n/**\n * Functions classified as REQUIRED by the\n * {@link https://www.unicode.org/reports/tr35/tr35-76/tr35-messageFormat.html#contents-of-part-9-messageformat | LDML 48 MessageFormat specification}.\n */\nexport let DefaultFunctions = {\n /**\n * Supports formatting and selection as defined in LDML 48 for the\n * {@link https://www.unicode.org/reports/tr35/tr35-76/tr35-messageFormat.html#the-integer-function | :integer function}.\n *\n * The `operand` must be a number, BigInt, or string representing a JSON number,\n * or an object wrapping such a value, with a `valueOf()` accessor and an optional `options` object.\n */\n integer,\n /**\n * Supports formatting and selection as defined in LDML 48 for the\n * {@link https://www.unicode.org/reports/tr35/tr35-76/tr35-messageFormat.html#the-number-function | :number function}.\n *\n * The `operand` must be a number, BigInt, or string representing a JSON number,\n * or an object wrapping such a value, with a `valueOf()` accessor and an optional `options` object.\n */\n number,\n /**\n * Supports formatting and selection as defined in LDML 48 for the\n * {@link https://www.unicode.org/reports/tr35/tr35-76/tr35-messageFormat.html#the-offset-function | :offset function}.\n *\n * The `operand` must be a number, BigInt, or string representing a JSON number,\n * or an object wrapping such a value, with a `valueOf()` accessor and an optional `options` object.\n */\n offset,\n /**\n * Supports formatting and selection as defined in LDML 48 for the\n * {@link https://www.unicode.org/reports/tr35/tr35-76/tr35-messageFormat.html#the-string-function | :string function}.\n *\n * The `operand` must be a stringifiable value.\n * An `undefined` value is resolved as an empty string.\n */\n string\n};\nDefaultFunctions = Object.freeze(Object.assign(Object.create(null), DefaultFunctions));\n/**\n * Functions classified as DRAFT by the\n * {@link https://www.unicode.org/reports/tr35/tr35-76/tr35-messageFormat.html#contents-of-part-9-messageformat | LDML 48 MessageFormat specification}.\n *\n * These are liable to change, and are **_not_** covered by any stability guarantee.\n *\n * ```js\n * import { MessageFormat } from 'messageformat';\n * import { DraftFunctions } from 'messageformat/functions';\n *\n * const mf = new MessageFormat(locale, msgsrc, { functions: DraftFunctions });\n * ```\n *\n * @beta\n */\nexport let DraftFunctions = {\n /**\n * Supports formatting as defined in LDML 48 for the\n * {@link https://www.unicode.org/reports/tr35/tr35-76/tr35-messageFormat.html#the-currency-function | :currency function}.\n *\n * The `operand` must be a number, BigInt, or string representing a JSON number,\n * or an object wrapping such a value, with a `valueOf()` accessor and an optional `options` object.\n *\n * The `currency` option must be provided by either the operand's `options` or the `exprOpt` expression options.\n */\n currency,\n /**\n * Supports formatting as defined in LDML 48 for the\n * {@link https://www.unicode.org/reports/tr35/tr35-76/tr35-messageFormat.html#the-date-function | :date function}.\n *\n * The `operand` must be a Date, number, or string representing a date,\n * or an object wrapping such a value, with a `valueOf()` accessor and an optional `options` object.\n */\n date,\n /**\n * Supports formatting as defined in LDML 48 for the\n * {@link https://www.unicode.org/reports/tr35/tr35-76/tr35-messageFormat.html#the-datetime-function | :datetime function}.\n *\n * The `operand` must be a Date, number, or string representing a date,\n * or an object wrapping such a value, with a `valueOf()` accessor and an optional `options` object.\n */\n datetime,\n /**\n * Supports formatting as defined in LDML 48 for the\n * {@link https://www.unicode.org/reports/tr35/tr35-76/tr35-messageFormat.html#the-percent-function | :percent function}.\n *\n * The `operand` must be a number, BigInt, or string representing a JSON number,\n * or an object wrapping such a value, with a `valueOf()` accessor and an optional `options` object.\n */\n percent,\n /**\n * Supports formatting as defined in LDML 48 for the\n * {@link https://www.unicode.org/reports/tr35/tr35-76/tr35-messageFormat.html#the-time-function | :time function}.\n *\n * The `operand` must be a Date, number, or string representing a date,\n * or an object wrapping such a value, with a `valueOf()` accessor and an optional `options` object.\n */\n time,\n /**\n * Supports formatting as defined in LDML 48 for the\n * {@link https://www.unicode.org/reports/tr35/tr35-76/tr35-messageFormat.html#the-unit-function | :unit function}.\n *\n * The `operand` must be a number, BigInt, or string representing a JSON number,\n * or an object wrapping such a value, with a `valueOf()` accessor and an optional `options` object.\n *\n * The `unit` option must be provided by either the operand's `options` or the `exprOpt` expression options.\n */\n unit\n};\nDraftFunctions = Object.freeze(Object.assign(Object.create(null), DraftFunctions));\n","export const BIDI_ISOLATE = Symbol('bidi-isolate');\n","export const fallback = (source = '�') => ({\n type: 'fallback',\n source,\n toParts: () => [{ type: 'fallback', source }],\n toString: () => `{${source}}`\n});\n","export const unknown = (source, input) => ({\n type: 'unknown',\n source,\n dir: 'auto',\n toParts: () => [{ type: 'unknown', value: input }],\n toString: () => String(input),\n valueOf: () => input\n});\n","import { MessageFunctionError } from \"../errors.js\";\nimport { getValueSource, resolveValue } from \"./resolve-value.js\";\nexport class MessageFunctionContext {\n #ctx;\n #litKeys;\n #source;\n dir;\n id;\n constructor(ctx, source, options) {\n this.#ctx = ctx;\n this.#source = source;\n this.dir = undefined;\n const dirOpt = options && Object.hasOwn(options, 'u:dir') ? options['u:dir'] : undefined;\n if (dirOpt) {\n const dir = String(resolveValue(ctx, dirOpt));\n if (dir === 'ltr' || dir === 'rtl' || dir === 'auto') {\n this.dir = dir;\n }\n else if (dir !== 'inherit') {\n const error = new MessageFunctionError('bad-option', 'Unsupported value for u:dir option');\n error.source = getValueSource(dirOpt);\n ctx.onError(error);\n }\n }\n const idOpt = options && Object.hasOwn(options, 'u:id') ? options['u:id'] : undefined;\n this.id = idOpt ? String(resolveValue(ctx, idOpt)) : undefined;\n if (options) {\n this.#litKeys = new Set();\n for (const [key, value] of Object.entries(options)) {\n if (value.type === 'literal')\n this.#litKeys.add(key);\n }\n }\n }\n get literalOptionKeys() {\n return new Set(this.#litKeys);\n }\n get localeMatcher() {\n return this.#ctx.localeMatcher;\n }\n get locales() {\n return this.#ctx.locales.map(String);\n }\n onError(error, message) {\n let mfError;\n if (error instanceof MessageFunctionError) {\n mfError = error;\n }\n else if (typeof error === 'string' && typeof message === 'string') {\n mfError = new MessageFunctionError(error, message);\n }\n else {\n mfError = new MessageFunctionError('function-error', String(error));\n mfError.cause = error;\n }\n mfError.source = this.#source;\n this.#ctx.onError(mfError);\n }\n}\n","import { MessageError, MessageResolutionError } from \"../errors.js\";\nimport { fallback } from \"../functions/fallback.js\";\nimport { BIDI_ISOLATE } from \"../message-value.js\";\nimport { MessageFunctionContext } from \"./function-context.js\";\nimport { getValueSource, resolveValue } from \"./resolve-value.js\";\nexport function resolveFunctionRef(ctx, operand, { name, options }) {\n const fnSource = `:${name}`;\n const source = getValueSource(operand) ?? fnSource;\n try {\n const fnInput = operand ? [resolveValue(ctx, operand)] : [];\n const rf = ctx.functions[name];\n if (!rf) {\n throw new MessageResolutionError('unknown-function', `Unknown function ${fnSource}`, source);\n }\n const msgCtx = new MessageFunctionContext(ctx, source, options);\n const opt = resolveOptions(ctx, options);\n const res = rf(msgCtx, opt, ...fnInput);\n if (res === null ||\n typeof res !== 'object' ||\n typeof res.type !== 'string') {\n throw new MessageResolutionError('bad-function-result', `Function ${fnSource} did not return a MessageValue`, source);\n }\n const override = { source };\n if (msgCtx.dir) {\n override.dir = msgCtx.dir;\n override[BIDI_ISOLATE] = true;\n }\n if (msgCtx.id && typeof res.toParts === 'function') {\n override.toParts = () => {\n const parts = res.toParts();\n for (const part of parts)\n part.id = msgCtx.id;\n return parts;\n };\n }\n return { ...res, ...override };\n }\n catch (error) {\n ctx.onError(error instanceof MessageError\n ? error\n : new MessageResolutionError('bad-function-result', String(error), source, error));\n return fallback(source);\n }\n}\nfunction resolveOptions(ctx, options) {\n const opt = Object.create(null);\n if (options) {\n for (const [name, value] of Object.entries(options)) {\n if (!name.startsWith('u:'))\n opt[name] = resolveValue(ctx, value);\n }\n }\n return opt;\n}\n","import { string } from \"../functions/string.js\";\nimport { MessageFunctionContext } from \"./function-context.js\";\nimport { resolveFunctionRef } from \"./resolve-function-ref.js\";\nimport { resolveVariableRef } from \"./resolve-variable.js\";\nexport function resolveExpression(ctx, { arg, functionRef }) {\n if (functionRef) {\n return resolveFunctionRef(ctx, arg, functionRef);\n }\n switch (arg?.type) {\n case 'literal': {\n const source = `|${arg.value}|`;\n const msgCtx = new MessageFunctionContext(ctx, source);\n const msgStr = string(msgCtx, {}, arg.value);\n msgStr.source = source;\n return msgStr;\n }\n case 'variable':\n return resolveVariableRef(ctx, arg);\n default:\n // @ts-expect-error - should never happen\n throw new Error(`Unsupported expression: ${arg?.type}`);\n }\n}\n","import { MessageResolutionError } from \"../errors.js\";\nimport { fallback } from \"../functions/fallback.js\";\nimport { unknown } from \"../functions/unknown.js\";\nimport { MessageFunctionContext } from \"./function-context.js\";\nimport { resolveExpression } from \"./resolve-expression.js\";\n/**\n * Declarations aren't resolved until they're requierd,\n * and their resolution order matters for variable resolution.\n * This internal class is used to store any required data,\n * and to allow for `instanceof` detection.\n *\n * @internal\n */\nexport class UnresolvedExpression {\n expression;\n scope;\n constructor(expression, scope) {\n this.expression = expression;\n this.scope = scope;\n }\n}\nconst isScope = (scope) => scope !== null && (typeof scope === 'object' || typeof scope === 'function');\n/**\n * Looks for the longest matching `.` delimited starting substring of name.\n * @returns `undefined` if value not found\n */\nfunction getValue(scope, name) {\n if (isScope(scope)) {\n if (name in scope)\n return scope[name];\n const parts = name.split('.');\n for (let i = parts.length - 1; i > 0; --i) {\n const head = parts.slice(0, i).join('.');\n if (head in scope) {\n const tail = parts.slice(i).join('.');\n return getValue(scope[head], tail);\n }\n }\n for (const [key, value] of Object.entries(scope)) {\n if (key.normalize() === name)\n return value;\n }\n }\n return undefined;\n}\n/**\n * Get the raw value of a variable.\n * Resolves declarations as necessary\n *\n * @internal\n * @returns `unknown` or `any` for input values;\n * `MessageValue` for `.input` and `.local` declaration values.\n */\nexport function lookupVariableRef(ctx, { name }) {\n const value = getValue(ctx.scope, name);\n if (value === undefined) {\n const source = '$' + name;\n const msg = `Variable not available: ${source}`;\n ctx.onError(new MessageResolutionError('unresolved-variable', msg, source));\n }\n else if (value instanceof UnresolvedExpression) {\n const local = resolveExpression(value.scope ? { ...ctx, scope: value.scope } : ctx, value.expression);\n ctx.scope[name] = local;\n ctx.localVars.add(local);\n return local;\n }\n return value;\n}\nexport function resolveVariableRef(ctx, ref) {\n const source = '$' + ref.name;\n const value = lookupVariableRef(ctx, ref);\n if (value === undefined)\n return fallback(source);\n let type = typeof value;\n if (type === 'object') {\n const mv = value;\n if (mv.type === 'fallback')\n return fallback(source);\n if (ctx.localVars.has(mv)) {\n mv.source = source;\n return mv;\n }\n if (value instanceof Number)\n type = 'number';\n else if (value instanceof String)\n type = 'string';\n }\n let msgFn;\n switch (type) {\n case 'bigint':\n case 'number':\n msgFn = ctx.functions.number;\n break;\n case 'string':\n msgFn = ctx.functions.string;\n break;\n default:\n return unknown(source, value);\n }\n const msgCtx = new MessageFunctionContext(ctx, source);\n const mv = msgFn(msgCtx, {}, value);\n mv.source = source;\n return mv;\n}\n","import { lookupVariableRef } from \"./resolve-variable.js\";\nexport function resolveValue(ctx, value) {\n switch (value.type) {\n case 'literal':\n return value.value;\n case 'variable':\n return lookupVariableRef(ctx, value);\n default:\n // @ts-expect-error - should never happen\n throw new Error(`Unsupported value: ${value.type}`);\n }\n}\nexport function getValueSource(value) {\n switch (value?.type) {\n case 'literal':\n return ('|' + value.value.replaceAll('\\\\', '\\\\\\\\').replaceAll('|', '\\\\|') + '|');\n case 'variable':\n return '$' + value.name;\n default:\n return undefined;\n }\n}\n","import { MessageFunctionError } from \"../errors.js\";\nimport { getValueSource, resolveValue } from \"./resolve-value.js\";\nexport function formatMarkup(ctx, { kind, name, options }) {\n const part = { type: 'markup', kind, name };\n const entries = options ? Object.entries(options) : null;\n if (entries?.length) {\n part.options = {};\n for (const [name, value] of entries) {\n if (name === 'u:dir') {\n const error = new MessageFunctionError('bad-option', `The option ${name} is not valid for markup`);\n error.source = getValueSource(value);\n ctx.onError(error);\n }\n else {\n let rv = resolveValue(ctx, value);\n if (typeof rv === 'object' && typeof rv?.valueOf === 'function') {\n rv = rv.valueOf();\n }\n if (name === 'u:id')\n part.id = String(rv);\n else\n part.options[name] = rv;\n }\n }\n }\n return part;\n}\n","import { MessageResolutionError } from \"./errors.js\";\nimport { resolveVariableRef } from \"./resolve/resolve-variable.js\";\nexport function selectPattern(context, message) {\n if (message.type === 'message')\n return message.pattern;\n // message.type === 'select'\n const ctx = message.selectors.map(sel => {\n const selector = resolveVariableRef(context, sel);\n let selectKey;\n if (typeof selector.selectKey === 'function') {\n selectKey = selector.selectKey.bind(selector);\n }\n else {\n const msg = 'Selector does not support selection';\n context.onError(new MessageResolutionError('bad-selector', msg, selector.source));\n selectKey = () => null;\n }\n return {\n selectKey,\n source: selector.source,\n best: null,\n keys: null\n };\n });\n let candidates = message.variants;\n loop: for (let i = 0; i < ctx.length; ++i) {\n const sc = ctx[i];\n if (!sc.keys) {\n sc.keys = new Set();\n for (const { keys } of candidates) {\n const key = keys[i];\n if (!key)\n break loop; // key-mismatch error\n if (key.type !== '*')\n sc.keys.add(key.value);\n }\n }\n try {\n sc.best = sc.keys.size ? sc.selectKey(sc.keys) : null;\n }\n catch (error) {\n const msg = 'Selection failed';\n context.onError(new MessageResolutionError('bad-selector', msg, sc.source, error));\n sc.selectKey = () => null;\n sc.best = null;\n }\n // Leave out all candidate variants that aren't the best,\n // or only the catchall ones, if nothing else matches.\n candidates = candidates.filter(v => {\n const k = v.keys[i];\n if (k.type === '*')\n return sc.best == null;\n return sc.best === k.value;\n });\n // If we've run out of candidates,\n // drop the previous best key of the preceding selector,\n // reset all subsequent key sets,\n // and restart the loop.\n if (candidates.length === 0) {\n if (i === 0)\n break; // No match; should not happen\n const prev = ctx[i - 1];\n if (prev.best == null)\n prev.keys?.clear();\n else\n prev.keys?.delete(prev.best);\n for (let j = i; j < ctx.length; ++j)\n ctx[j].keys = null;\n candidates = message.variants;\n i = -1;\n }\n }\n const res = candidates[0];\n if (!res) {\n // This should not be possible with a valid message.\n const msg = 'No variant was selected!?';\n context.onError(new MessageResolutionError('no-match', msg, '.match'));\n return [];\n }\n return res.value;\n}\n","import { parseMessage } from \"./data-model/parse.js\";\nimport { validate } from \"./data-model/validate.js\";\nimport { FSI, LRI, PDI, RLI, getLocaleDir } from \"./dir-utils.js\";\nimport { MessageFunctionError } from \"./errors.js\";\nimport { DefaultFunctions } from \"./functions/index.js\";\nimport { BIDI_ISOLATE } from \"./message-value.js\";\nimport { formatMarkup } from \"./resolve/format-markup.js\";\nimport { resolveExpression } from \"./resolve/resolve-expression.js\";\nimport { UnresolvedExpression } from \"./resolve/resolve-variable.js\";\nimport { selectPattern } from \"./select-pattern.js\";\n/**\n * A message formatter for that implements the\n * {@link https://www.unicode.org/reports/tr35/tr35-76/tr35-messageFormat.html#contents-of-part-9-messageformat | LDML 48 MessageFormat}\n * specification as well as the {@link https://github.com/tc39/proposal-intl-messageformat/ | TC39 Intl.MessageFormat proposal}.\n *\n * @category Formatting\n * @typeParam T - The `type` used by custom message functions, if any.\n * These extend the {@link DefaultFunctions | default functions}.\n * @typeParam P - The formatted-parts `type` used by any custom message values.\n */\nexport class MessageFormat {\n #bidiIsolation;\n #dir;\n #localeMatcher;\n #locales;\n #message;\n #functions;\n constructor(locales, source, options) {\n this.#bidiIsolation = options?.bidiIsolation !== 'none';\n this.#localeMatcher = options?.localeMatcher ?? 'best fit';\n this.#locales = Array.isArray(locales)\n ? locales.map(lc => new Intl.Locale(lc))\n : locales\n ? [new Intl.Locale(locales)]\n : [];\n this.#dir = options?.dir ?? getLocaleDir(this.#locales[0]);\n this.#message = typeof source === 'string' ? parseMessage(source) : source;\n validate(this.#message);\n this.#functions = options?.functions\n ? Object.assign(Object.create(null), DefaultFunctions, options.functions)\n : DefaultFunctions;\n }\n /**\n * Format a message to a string.\n *\n * ```js\n * import { MessageFormat } from 'messageformat';\n * import { DraftFunctions } from 'messageformat/functions';\n *\n * const msg = 'Hello {$user.name}, today is {$date :date style=long}';\n * const mf = new MessageFormat('en', msg, { functions: DraftFunctions });\n * mf.format({ user: { name: 'Kat' }, date: new Date('2025-03-01') });\n * ```\n *\n * ```js\n * 'Hello Kat, today is March 1, 2025'\n * ```\n *\n * @param msgParams - Values that may be referenced by `$`-prefixed variable references.\n * To refer to an inner property of an object value,\n * use `.` as a separator; in case of conflict, the longest starting substring wins.\n * @param onError - Called in case of error.\n * If not set, errors are by default logged as warnings.\n */\n format(msgParams, onError) {\n const ctx = this.#createContext(msgParams, onError);\n let res = '';\n for (const elem of selectPattern(ctx, this.#message)) {\n if (typeof elem === 'string') {\n res += elem;\n }\n else if (elem.type === 'markup') {\n // Handle errors, but discard results\n formatMarkup(ctx, elem);\n }\n else {\n let mv;\n try {\n mv = resolveExpression(ctx, elem);\n if (typeof mv.toString === 'function') {\n if (this.#bidiIsolation &&\n (this.#dir !== 'ltr' || mv.dir !== 'ltr' || mv[BIDI_ISOLATE])) {\n const pre = mv.dir === 'ltr' ? LRI : mv.dir === 'rtl' ? RLI : FSI;\n res += pre + mv.toString() + PDI;\n }\n else {\n res += mv.toString();\n }\n }\n else {\n const error = new MessageFunctionError('not-formattable', 'Message part is not formattable');\n error.source = mv.source;\n throw error;\n }\n }\n catch (error) {\n ctx.onError(error);\n const errStr = `{${mv?.source ?? '�'}}`;\n res += this.#bidiIsolation ? FSI + errStr + PDI : errStr;\n }\n }\n }\n return res;\n }\n /**\n * Format a message to a sequence of parts.\n *\n * ```js\n * import { MessageFormat } from 'messageformat';\n * import { DraftFunctions } from 'messageformat/functions';\n *\n * const msg = 'Hello {$user.name}, today is {$date :date style=long}';\n * const mf = new MessageFormat('en', msg, { functions: DraftFunctions });\n * mf.formatToParts({ user: { name: 'Kat' }, date: new Date('2025-03-01') });\n * ```\n *\n * ```js\n * [\n * { type: 'text', value: 'Hello ' },\n * { type: 'bidiIsolation', value: '\\u2068' },\n * { type: 'string', locale: 'en', value: 'Kat' },\n * { type: 'bidiIsolation', value: '\\u2069' },\n * { type: 'text', value: ', today is ' },\n * {\n * type: 'datetime',\n * dir: 'ltr',\n * locale: 'en',\n * parts: [\n * { type: 'month', value: 'March' },\n * { type: 'literal', value: ' ' },\n * { type: 'day', value: '1' },\n * { type: 'literal', value: ', ' },\n * { type: 'year', value: '2025' }\n * ]\n * }\n * ]\n * ```\n *\n * @param msgParams - Values that may be referenced by `$`-prefixed variable references.\n * To refer to an inner property of an object value,\n * use `.` as a separator; in case of conflict, the longest starting substring wins.\n * @param onError - Called in case of error.\n * If not set, errors are by default logged as warnings.\n */\n formatToParts(msgParams, onError) {\n const ctx = this.#createContext(msgParams, onError);\n const parts = [];\n for (const elem of selectPattern(ctx, this.#message)) {\n if (typeof elem === 'string') {\n parts.push({ type: 'text', value: elem });\n }\n else if (elem.type === 'markup') {\n parts.push(formatMarkup(ctx, elem));\n }\n else {\n let mv;\n try {\n mv = resolveExpression(ctx, elem);\n if (typeof mv.toParts === 'function') {\n // Let's presume that parts that look like MessageNumberPart or MessageStringPart are such.\n const mp = mv.toParts();\n if (this.#bidiIsolation &&\n (this.#dir !== 'ltr' || mv.dir !== 'ltr' || mv[BIDI_ISOLATE])) {\n const pre = mv.dir === 'ltr' ? LRI : mv.dir === 'rtl' ? RLI : FSI;\n parts.push({ type: 'bidiIsolation', value: pre }, ...mp, {\n type: 'bidiIsolation',\n value: PDI\n });\n }\n else {\n parts.push(...mp);\n }\n }\n else {\n const error = new MessageFunctionError('not-formattable', 'Message part is not formattable');\n error.source = mv.source;\n throw error;\n }\n }\n catch (error) {\n ctx.onError(error);\n const fb = {\n type: 'fallback',\n source: mv?.source ?? '�'\n };\n if (this.#bidiIsolation) {\n parts.push({ type: 'bidiIsolation', value: FSI }, fb, {\n type: 'bidiIsolation',\n value: PDI\n });\n }\n else {\n parts.push(fb);\n }\n }\n }\n }\n return parts;\n }\n #createContext(msgParams, onError = (error) => {\n // Emit warning for errors by default\n try {\n process.emitWarning(error);\n }\n catch {\n console.warn(error);\n }\n }) {\n const scope = { ...msgParams };\n for (const decl of this.#message.declarations) {\n scope[decl.name] = new UnresolvedExpression(decl.value, decl.type === 'input' ? (msgParams ?? {}) : undefined);\n }\n const ctx = {\n onError,\n localeMatcher: this.#localeMatcher,\n locales: this.#locales,\n localVars: new WeakSet(),\n functions: this.#functions,\n scope\n };\n return ctx;\n }\n}\n","import { MessageFormat } from \"messageformat\";\nimport { DraftFunctions } from \"messageformat/functions\";\nimport type { TranslateOptions, Locale, NamespaceResources, MessageFormattingMode } from \"./types\";\n\nconst cache = new Map<string, Map<string, MessageFormat<string, string>>>();\n\nfunction getOrCreateMessageFormat(\n\tlocale: string,\n\tkey: string,\n\tmessage: string\n): MessageFormat<string, string> {\n\tlet localeCache = cache.get(locale);\n\tif (!localeCache) {\n\t\tlocaleCache = new Map();\n\t\tcache.set(locale, localeCache);\n\t}\n\n\tlet mf = localeCache.get(key);\n\tif (mf) {\n\t\treturn mf;\n\t}\n\tmf = new MessageFormat([locale], message, { functions: DraftFunctions });\n\tlocaleCache.set(key, mf);\n\treturn mf;\n}\n\nexport function defaultTranslate(\n\tmsg: string,\n\toptions?: TranslateOptions\n): string {\n\tif (!options?.vars || Object.keys(options.vars).length === 0) {\n\t\treturn msg;\n\t}\n\n\tif (options.formatting === \"identity\") {\n\t\treturn msg;\n\t}\n\n\tconst { locale, vars } = options;\n\tconst mf = getOrCreateMessageFormat(locale, msg, msg);\n\n\treturn mf.format(vars, (error) => {\n\t\tconsole.warn(`[fanee] Failed to format message: ${error}`);\n\t});\n}\n\nexport function createTranslationFunction(\n\tresources: NamespaceResources | undefined,\n\tlocale: Locale,\n\tdefaultLocale: Locale,\n\tformatting: MessageFormattingMode,\n\ttranslate: (msg: string, options?: TranslateOptions) => string\n): (key: string, vars?: Record<string, unknown>) => string {\n\treturn (key: string, vars?: Record<string, unknown>): string => {\n\t\tif (!resources) {\n\t\t\treturn key;\n\t\t}\n\n\t\tlet localeData = resources[locale];\n\t\tif (!localeData) {\n\t\t\tlocaleData = resources[defaultLocale];\n\t\t\tif (!localeData) {\n\t\t\t\treturn key;\n\t\t\t}\n\t\t}\n\n\t\tconst value = localeData[key];\n\t\tif (value === undefined) {\n\t\t\treturn key;\n\t\t}\n\n\t\tif (vars === undefined || Object.keys(vars).length === 0) {\n\t\t\treturn value;\n\t\t}\n\n\t\treturn translate(value, { locale, vars, formatting });\n\t};\n}\n","import type { FaneeState } from \"./types\";\nimport { defaultTranslate } from \"./translator\";\n\nexport function defaultState(): FaneeState {\n\treturn {\n\t\tresources: {},\n\t\tdefaultLocale: \"en\",\n\t\tcurrentLocale: \"en\",\n\t\tbaseNamespace: \"\",\n\t\tformatting: \"mf2\",\n\t\ttranslate: defaultTranslate,\n\t};\n}\n","import type {\n\tFaneeState,\n\tLocale,\n\tMessageKey,\n\tTranslateContext,\n\tTranslateFunction,\n\tTranslationsByLocale,\n\tNamespaceResources,\n\tBundleResources,\n} from \"./types\";\nimport { defaultState } from \"./state\";\nimport { createTranslationFunction } from \"./translator\";\n\nexport class FaneeRuntime {\n\tprivate state: FaneeState;\n\tprivate queue: Promise<void>;\n\n\tconstructor() {\n\t\tthis.state = defaultState();\n\t\tthis.queue = Promise.resolve();\n\t}\n\n\tuse(\n\t\tfn: (state: FaneeState) => FaneeState | Promise<FaneeState>\n\t): this {\n\t\tthis.queue = this.queue.then(async () => {\n\t\t\tthis.state = await fn(this.state);\n\t\t});\n\t\treturn this;\n\t}\n\n\tconfig(patch: Partial<FaneeState>): this {\n\t\tthis.queue = this.queue.then(async () => {\n\t\t\tthis.state = { ...this.state, ...patch };\n\t\t});\n\t\treturn this;\n\t}\n\n\t// biome-ignore lint/suspicious/noThenProperty: intentional thenable for await support\n\tthen<TResult1 = void, TResult2 = never>(\n\t\tonfulfilled?:\n\t\t\t// biome-ignore lint/suspicious/noConfusingVoidType: matches Promise<void> queue resolution\n\t\t\t| ((value: void) => TResult1 | PromiseLike<TResult1>)\n\t\t\t| null,\n\t\tonrejected?:\n\t\t\t| ((reason: unknown) => TResult2 | PromiseLike<TResult2>)\n\t\t\t| null\n\t): Promise<TResult1 | TResult2> {\n\t\treturn this.queue.then(onfulfilled, onrejected);\n\t}\n\n\tprivate resolveContext(context?: Partial<TranslateContext>) {\n const { currentLocale, baseNamespace } = this.state;\n \n const locale = context?.locale ?? currentLocale;\n const ns = context?.namespace \n ? (baseNamespace ? `${baseNamespace}:${context.namespace}` : context.namespace)\n : baseNamespace;\n\n return { locale, ns };\n }\n\n private getTranslationFunction(ns: string, locale: Locale): TranslateFunction {\n const { resources, defaultLocale, formatting, translate } = this.state;\n const nsResources = resources[ns];\n\n if (!nsResources) {\n return (k: MessageKey) => k;\n }\n\n return createTranslationFunction(\n nsResources,\n locale,\n defaultLocale,\n formatting,\n translate\n );\n }\n\n t(context?: Partial<TranslateContext>): TranslateFunction {\n const { locale, ns } = this.resolveContext(context);\n return this.getTranslationFunction(ns, locale as Locale);\n }\n\n tAll(key: MessageKey, vars?: Record<string, unknown>): TranslationsByLocale {\n const { baseNamespace, resources } = this.state;\n const nsResources = resources[baseNamespace];\n const result: TranslationsByLocale = {};\n\n if (!nsResources) {\n return result;\n }\n\n for (const loc of Object.keys(nsResources)) {\n const t = this.getTranslationFunction(baseNamespace, loc as Locale);\n result[loc as Locale] = t(key, vars);\n }\n\n return result;\n }\n\n\tgetLocale(): Locale {\n\t\treturn this.state.currentLocale;\n\t}\n\n\tgetLocales(): Locale[] {\n\t\tconst locales = new Set<Locale>();\n\t\tfor (const resource of Object.values(this.state.resources)) {\n\t\t\tfor (const locale of Object.keys(resource)) {\n\t\t\t\tlocales.add(locale as Locale);\n\t\t\t}\n\t\t}\n\t\treturn Array.from(locales).sort();\n\t}\n\n\tgetAllTranslations(): BundleResources {\n\t\treturn this.state.resources;\n\t}\n\n\tgetTranslationsForNamespace(\n\t\tns: string\n\t): NamespaceResources | undefined {\n\t\treturn this.state.resources[ns];\n\t}\n\n\tready(): Promise<void> {\n\t\treturn this.queue;\n\t}\n\n\tsetLocale(locale: Locale) {\n\t\tthis.state.currentLocale = locale;\n\t}\n}\n","import { FaneeRuntime } from \"./runtime\";\n\nexport const i18n = new FaneeRuntime();\n"],"x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26],"mappings":"AAAA,MAAMA,EAAY,sCACZ,EAAY,8fACZ,EAAe,WACrB,SAAgB,EAAe,EAAQ,EAAO,CAC1C,IAAI,EAAM,EACJ,EAAY,EAAO,MAAM,CAAG,CAAC,CAAC,MAAMA,CAAS,EAC/C,IACA,GAAO,EAAU,EAAE,CAAC,QACxB,IAAM,EAAQ,EAAO,MAAM,CAAG,CAAC,CAAC,MAAM,CAAS,EAC/C,GAAI,CAAC,EACD,OAAO,KACX,IAAM,EAAO,EAAM,GACnB,GAAI,EAAa,KAAK,CAAI,EACtB,OAAO,KACX,GAAO,EAAK,OACZ,IAAM,EAAU,EAAO,MAAM,CAAG,CAAC,CAAC,MAAMA,CAAS,EAGjD,OAFI,IACA,GAAO,EAAQ,EAAE,CAAC,QACf,CAAE,MAAO,EAAK,UAAU,EAAG,IAAK,CAAI,CAC/C,CAKA,MAAa,GAA6B,EAAQ,IAAU,EAAO,MAAM,CAAK,CAAC,CAAC,MAAM,CAAS,CAAC,GAAG,IAAM,GCjB5F,EAAS,OAAO,IAAI,KAAK,ECDtC,IAAa,EAAb,cAAkC,KAAM,CACpC,KACA,YAAY,EAAM,EAAS,CACvB,MAAM,CAAO,EACb,KAAK,KAAO,CAChB,CACJ,EAMa,EAAb,cAAwC,CAAa,CACjD,MACA,IAEA,YAAY,EAAM,EAAO,EAAK,EAAU,CACpC,IAAI,EAAU,EAAW,WAAW,IAAa,EAC7C,GAAS,IACT,GAAW,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