/** * Shared types and constants for the libphonenumber polyfill. */ import type { VegaCountryCode } from '../../types/flag.type'; /** Shape of a single format rule inside a country metadata entry. */ export declare type FormatRule = [ /** pattern - regex source matching the national number */ string, /** replacement - e.g. '($1) $2-$3' */ string, /** leadingDigitsPatterns - array of regex sources for matching leading digits */ string[], /** nationalPrefixFormattingRule (optional) - e.g. '0$1' */ string?, /** domesticCarrierCodeFormattingRule (optional) */ (string | number)?, /** internationalFormat (optional) */ string? ]; /** * Country metadata tuple. * * Index mapping (metadata version 4): * [0] callingCode * [1] international direct dialing pattern * [2] validation regex source (generalDesc) * [3] possible lengths * [4] format rules (or 0/undefined) * [5] trunk prefix (or 0/undefined) * [6..9] various national prefix fields * [10] leadingDigits for country-in-calling-code disambiguation (or 0) * [11] types array (or 0) */ export declare type CountryMetadata = [ string, // [0] callingCode string | 0, string, number[], // [3] possibleLengths FormatRule[] | 0, ...unknown[] ]; export interface MetadataJson { version: number; countryCallingCode: Record; countries: Record; } /** Result of populating a formatting template with digits. */ export interface PopulatedTemplateResult { /** The template string with digits filled in. */ filled: string; /** The index of the last populated placeholder. */ lastPosition: number; } export interface ParsePhoneNumberOptions { defaultCountry?: VegaCountryCode; /** When false, the entire input must be a phone number (no extraction). */ extract?: boolean; } /** Placeholder character used in formatting templates. */ export declare const DIGIT_PLACEHOLDER: string; /** Dummy digit used to generate formatting templates. */ export declare const DUMMY_DIGIT: string; /** Maximum possible national number length. */ export declare const LONGEST_NATIONAL_NUMBER_LENGTH: number; /** Minimum digits before progressive leading-digits matching kicks in. */ export declare const MIN_LEADING_DIGITS_LENGTH: number; /** * Pattern that matches national prefix formatting rules that are just "$1" * or "($1)" — i.e. rules that don't actually prepend a national prefix digit. */ export declare const FIRST_GROUP_ONLY_PREFIX_PATTERN: RegExp; /** Error code thrown when the input does not contain a valid phone number. */ export declare const PARSE_ERROR_NOT_A_NUMBER: string; /** Error code thrown when the country cannot be determined from the input. */ export declare const PARSE_ERROR_INVALID_COUNTRY: string;