import { G as GrammaticalFeatures, F as FallbackRequest, I as InflectionFallback, L as LanguagePack } from './pack-u-LoPClV.js'; export { A as ArticleRequest, D as Definiteness, a as Derivation, b as GrammaticalCase, c as GrammaticalGender, d as GrammaticalNumber, e as GrammaticalPerson, f as InflectWarning, g as InflectionContext, h as InflectionResult, P as PartOfSpeech, W as WarningCode, i as WarningHandler, n as normalizeFeatures, o as onWarning } from './pack-u-LoPClV.js'; /** * Template AST. * * Exported as part of the public API so alternative renderers (for example a * future MessageFormat 2 adapter) can reuse the parser. */ /** Literal text. */ interface TextNode { kind: "text"; value: string; } /** A `{name}` placeholder. */ interface VariableNode { kind: "var"; name: string; } /** * A `^[body](key: value; …)` inflection span. `features` holds the raw * string annotations — they are normalized per-locale at format time. */ interface InflectNode { kind: "inflect"; body: (TextNode | VariableNode)[]; features: Record; } /** Any template node. */ type TemplateNode = TextNode | VariableNode | InflectNode; /** A parsed template. */ interface Template { nodes: TemplateNode[]; } /** Values usable as template arguments. Numbers are stringified. */ type TemplateArgs = Record; /** * Seed the oracle cache directly (used by tests and by applications that * want to pre-store known answers, e.g. from a server response). */ declare function seedOracle(locale: string, request: FallbackRequest, form: string): void; /** Clear the oracle cache (test isolation). */ declare function clearOracle(): void; /** * Inflect a phrase synchronously using rules, lexicon and any cached * fallback answers. Unknown locales return the phrase unchanged (with a * warning) — this function never throws on user input. * * @example * ```ts * import "i18n-inflect/hu"; * inflect("hu", "kőr ász", { case: "instrumental" }); // "kőr ásszal" * ``` */ declare function inflect(locale: string, phrase: string, features?: GrammaticalFeatures): string; /** * Like {@link inflect}, but may await the registered fallback (e.g. the * neural module) for words the rules were unsure about. Falls back to the * best synchronous answer when no fallback is registered or it fails. */ declare function inflectAsync(locale: string, phrase: string, features?: GrammaticalFeatures): Promise; /** * Warm up the fallback for a locale (loads the neural session, if one is * registered). Safe to call unconditionally — resolves immediately when * there is nothing to preload. */ declare function preload(locale: string): Promise; /** * Whitespace-preserving phrase tokenization shared by the language packs. * * A phrase is split into alternating word/separator parts so packs can * rewrite individual words (head noun, article, adjectives) and reassemble * the phrase without disturbing its original spacing. */ /** A phrase split into parts; `words[i]` sits between separators. */ interface SplitPhrase { /** The word tokens, in order. */ words: string[]; /** * All parts (words and whitespace runs) in original order. Rewriting * `parts[wordIndexes[i]]` and joining reproduces the phrase. */ parts: string[]; /** Index into `parts` for each entry of `words`. */ wordIndexes: number[]; } /** Split a phrase, keeping whitespace runs as separate parts. */ declare function splitPhrase(phrase: string): SplitPhrase; /** Reassemble a phrase after rewriting some of its `parts`. */ declare function joinPhrase(split: SplitPhrase): string; /** * Split a token into its core and trailing punctuation * (`"ász!"` → `["ász", "!"]`) so suffixes attach to the word itself. */ declare function splitTrailingPunctuation(token: string): [core: string, punctuation: string]; /** True when `word`'s first letter is uppercase (locale-independent check). */ declare function isCapitalized(word: string): boolean; /** Capitalize the first letter of `word`. */ declare function capitalize(word: string): string; /** * Reduce a BCP 47 tag to its primary language subtag: `"hu-HU"` → `"hu"`. * Falls back to naive splitting when `Intl.Locale` rejects the input. */ declare function resolveLocale(locale: string): string; /** Register (or replace) a language pack. */ declare function registerLanguage(pack: LanguagePack): void; /** Register (or replace) a fallback oracle for its locale. */ declare function registerFallback(fallback: InflectionFallback): void; /** Look up the pack serving a locale (accepts full BCP 47 tags). */ declare function getLanguage(locale: string): LanguagePack | undefined; /** Look up the fallback serving a locale (accepts full BCP 47 tags). */ declare function getFallback(locale: string): InflectionFallback | undefined; /** List the registered language subtags (mainly for diagnostics/tests). */ declare function registeredLocales(): string[]; /** * Remove every registered pack and fallback. * * Intended for test isolation only — applications never need this. */ declare function resetRegistry(): void; /** Parse a template string (memoized on the source string). */ declare function parseTemplate(source: string): Template; /** * i18n-inflect — grammatical inflection and agreement for i18n. * * ```ts * import { format } from "i18n-inflect"; * import "i18n-inflect/hu"; // registers the Hungarian pack * * format("hu", "Nyertél ^[a {card}](case: instrumental)!", { card: "kőr ász" }); * // → "Nyertél a kőr ásszal!" * ``` * * @packageDocumentation */ /** * Format a template with Apple-style inflection spans. * * `^[body](key: value; …)` spans are interpolated (`{var}` placeholders * first) and then inflected by the locale's language pack. Synchronous: * uses rules, lexicon and previously cached fallback answers only. * * Never throws on malformed templates or unknown locales — it degrades to * plain interpolated text and reports via {@link onWarning}. * * @example * ```ts * format("en", "You drew ^[a {c}](article: indefinite)", { c: "ace" }); * // → "You drew an ace" * ``` */ declare function format(locale: string, template: string, args?: TemplateArgs): string; /** * Like {@link format}, but spans may await the registered fallback (e.g. * the neural module) for words the rules were unsure about. Results are * cached, so subsequent synchronous {@link format} calls with the same * words return the corrected forms too. */ declare function formatAsync(locale: string, template: string, args?: TemplateArgs): Promise; export { FallbackRequest, GrammaticalFeatures, type InflectNode, InflectionFallback, LanguagePack, type SplitPhrase, type Template, type TemplateArgs, type TemplateNode, type TextNode, type VariableNode, capitalize, clearOracle, format, formatAsync, getFallback, getLanguage, inflect, inflectAsync, isCapitalized, joinPhrase, parseTemplate, preload, registerFallback, registerLanguage, registeredLocales, resetRegistry, resolveLocale, seedOracle, splitPhrase, splitTrailingPunctuation };