/** * Pick the best match between a list of supported locales and a list of * requested locales, using BCP-47 best-match semantics: * * 1. Exact match — if any `requested` entry equals a `supported` entry * after canonicalisation. * 2. Prefix match — if a `requested` tag is a parent of a `supported` tag * (e.g. requested `pt` matches supported `pt-BR`). * 3. Parent match — if a `requested` tag's BCP-47 parents include a * `supported` tag (e.g. requested `pt-PT` matches supported `pt`). * * **Casing:** comparison is case-insensitive — both `supported` and * `requested` tags are canonicalised internally (language lowercase, region * uppercase, script titlecase, per the convention browsers and `Intl.*` * emit). The **returned** locale preserves the original casing of the * matching `supported` entry — so `negotiateLocale(['PT-br'], ['pt-BR'])` * returns `'PT-br'`, not the canonical form. * * Returns the matching `supported` entry, or `undefined` if nothing matches. * * Pure utility — does not mutate `Ilingo` state. Compose with * `ilingo.setLocale(negotiateLocale(supported, requested) ?? defaultLocale)`. * * @example * negotiateLocale(['en', 'pt-BR'], ['pt-PT', 'pt', 'en']); * // → 'pt-BR' (requested 'pt' is a parent of supported 'pt-BR') * * negotiateLocale(['en', 'de'], ['fr', 'es']); * // → undefined */ export declare function negotiateLocale(supported: string[], requested: string[]): string | undefined; /** * Parse an HTTP `Accept-Language` header into an ordered list of locale tags, * sorted by quality (`q=`) descending. Tags lacking a `q=` parameter default * to `q=1.0` (RFC 9110). * * Tags with `q=0` are dropped per RFC 9110 § 12.5.4 — `q=0` means * "not acceptable", so a client that says `de;q=0` is explicitly rejecting * German and we must not negotiate to it. Invalid q-values (NaN or outside * `0..1`) cause the tag to be dropped as well. * * The `*` wildcard is dropped — callers that want a fallback should pass it * separately to `negotiateLocale`'s `requested` argument. * * @example * parseAcceptLanguage('en-US,en;q=0.9,de;q=0.8'); * // → ['en-US', 'en', 'de'] * * parseAcceptLanguage('pt-PT;q=0.7, pt;q=0.5, *;q=0.1'); * // → ['pt-PT', 'pt'] * * parseAcceptLanguage('en, fr;q=0, de;q=0.8'); * // → ['en', 'de'] (French explicitly rejected) */ export declare function parseAcceptLanguage(header: string): string[];