import { type CountryCode } from "libphonenumber-js/min/es6"; import type { PhoneFieldCountry, PhoneFieldCountryCode, PhoneFieldCountryMap, PhoneFieldFormValue, PhoneFieldLang, PhoneFieldParseOptions, PhoneFieldValue } from "./types.js"; /** * Normalizes a BCP 47 locale (string or array) to a single canonical locale string. Returns `"en"` when missing or invalid. */ export declare function normalizeLang(lang?: PhoneFieldLang): string; /** * Returns a cached map of ISO2 → PhoneFieldCountry for the given locale. Used for country names and sorting. */ export declare function getCountriesMap(lang?: PhoneFieldLang): PhoneFieldCountryMap; /** * Whether a national significant number is valid for this exact region. * Detection alone attributes numbers in shared plans (Åland, Isle of Man, * Christmas Island, Vatican City…) to the main country, which would make * correct numbers for those territories impossible to validate. */ export declare function isValidForCountry(country: CountryCode, nationalNumber: string): boolean; /** Default country code used when none is specified (e.g. "US"). */ export declare const DEFAULT_COUNTRY: CountryCode; /** Returns the default countries map for locale "en". */ export declare function getDefaultCountriesMap(): PhoneFieldCountryMap; /** Strips all non-digit characters from a string. */ export declare function onlyDigits(value: string): string; /** Parses a strict international input while preserving ordinary national input behavior. */ export declare function parseInternationalInput(value: string): import("libphonenumber-js/min").PhoneNumber | undefined; /** * Filters a countries map to the given ISO2 codes, or returns all countries if none provided. * @throws If the resulting list is empty. */ export declare function toAvailableCountries(countriesMap: PhoneFieldCountryMap, countries?: readonly PhoneFieldCountryCode[]): PhoneFieldCountry[]; /** * Splits countries into a pinned "preferred" group and the remaining "all" group. * Preferred countries keep the given order and are not repeated below. * Returns `null` when nothing is pinned. */ export declare function toCountryGroups(availableCountries: readonly PhoneFieldCountry[], preferredCountries?: readonly PhoneFieldCountryCode[]): ({ id: "preferred"; items: PhoneFieldCountry[]; } | { id: "all"; items: PhoneFieldCountry[]; })[] | null; /** * Whether a national or `+` international number has more digits than any * number in the given country can have. */ export declare function isTooLong(country: PhoneFieldCountry, rawNumber: string): boolean; /** * Resolves an ISO2 code to a country from the available list. Falls back to US if present, else first country. * @throws If availableCountries is empty. */ export declare function resolveCountry(availableCountries: readonly PhoneFieldCountry[], iso2?: CountryCode): PhoneFieldCountry; /** * Builds a PhoneFieldValue from country, raw national number string, and formatOnType flag. * When formatOnType is true, national number is formatted as-you-type. */ export declare function buildValue(country: PhoneFieldCountry, rawNumber: string, formatOnType: boolean): PhoneFieldValue; /** Default search text for a country (name, iso2, dialCode) used by the combobox. */ export declare function defaultCountrySearchText(country: PhoneFieldCountry): string; /** * Parses a PhoneFieldValue or E.164 string into a libphonenumber PhoneNumber. * Use for formatNational(), formatInternational(), getURI(). Options.defaultCountry for national-number strings. */ export declare function parsePhoneField(value: string | PhoneFieldValue, options?: PhoneFieldParseOptions): import("libphonenumber-js/min").PhoneNumber | undefined; /** * Returns whether the value is a valid phone number. Accepts PhoneFieldValue or E.164 string. * Options.defaultCountry for national-number strings. */ export declare function isValidPhoneField(value: string | PhoneFieldValue, options?: PhoneFieldParseOptions): boolean; /** Type guard: true if the value has the PhoneFieldValue shape. */ export declare function isPhoneFieldValue(value: unknown): value is PhoneFieldValue; /** Returns the minimal payload written to a hidden form control. */ export declare function toFormValue(value: PhoneFieldValue): PhoneFieldFormValue; /** * Validates a minimal serialized form payload and rebuilds a canonical PhoneFieldValue. * Legacy full-value JSON is accepted, but client-supplied derived fields are ignored. */ export declare function fromFormData(formData: FormData, name: string): PhoneFieldValue | null;