import { Temporal } from "./temporal.js";
/** A maximal run of digits in a formatted text, as UTF-16 offsets. */
export interface DigitRun {
  readonly start: number;
  readonly end: number;
  readonly text: string;
}
/**
 * The digit runs of `text`, walked by code point: Adlam, Chakma and other digit sets lie outside
 * the Basic Multilingual Plane.
 */
export declare function digitRuns(text: string, digits: ReadonlySet<string>): DigitRun[];
/** Forget every digit set and reference formatter (a replaced `Intl`, a test seam). */
export declare function forgetWeekYearText(): void;
/** The digits 0 to 9 of a numbering system, by value. */
export declare function digitsOf(numberingSystem: string): readonly string[];
/** The set of a numbering system's digit characters. */
export declare function digitSetOf(numberingSystem: string): ReadonlySet<string>;
/**
 * A root-locale formatter that prints the year alone in a calendar: its single digit run at a date
 * is the calendar's year as ICU counts it, the same calendar arithmetic that prints the month and
 * the day beside the year in the formatter under test.
 */
export interface Reference {
  readonly format: Intl.DateTimeFormat;
  readonly digits: ReadonlySet<string>;
}
/** The reference for a calendar, numbering system and time zone, built once. */
export declare function referenceFor(calendar: string, numberingSystem: string, timeZone: string): Reference;
/** The calendar year the reference prints at `ms`, or `null` when it prints no single number. */
export declare function referenceYear(reference: Reference, ms: number): string | null;
/** An era-and-year text with its year removed, so two eras compare by name alone. */
export declare function withoutYear(text: string, digits: ReadonlySet<string>): string;
/**
 * The calendar year of a mid-year date, the anchor every probe date is counted from. The year is
 * the computation calendar's (`ethioaa` for `coptic` and `ethiopic`, `computationCalendarId`): the
 * polyfill (0.5.1) throws "Era am ... was not matched by any era" for every `coptic` and
 * `ethiopic` date. Probe years are only counted from it and passed to `dateIn`, never printed.
 */
export declare function anchorYear(calendar: string): number;
/** The date `month` / `day` of `year` in a calendar, `year` counted as `anchorYear` counts it. */
export declare function dateIn(calendar: string, year: number, month: number, day: number): Temporal.PlainDate;
/**
 * The indexes of the digit runs that hold the year, or `null` when the run count changes between
 * the three probe dates.
 *
 * A year run is equal a week apart in mid-January and different in the first following year whose
 * 15 January falls on the same weekday: equal weekdays keep a weekday name with digits (luy `J4`)
 * out of the set.
 *
 * @param runsAt the formatter's digit runs at a date
 */
export declare function yearRunIndexes(calendar: string, runsAt: (date: Temporal.PlainDate) => DigitRun[]): number[] | null;
/** How a year run is written: `full` or the last `two` digits, and any number glued to it. */
export interface YearStyle {
  readonly kind: "full" | "two";
  /** Where the year sits in a run that also holds another number, else `undefined`. */
  readonly glued?: "start" | "end";
  /** The length of the other number in a glued run. */
  readonly rest?: number;
}
/** The kind of field a digit run holds, found by moving one field at a time. */
export type RunLabel = "year" | "day" | "month" | "hour" | "minute" | "second" | "fractionalSecond" | "literal" | "text";
/** What `analyse` reads from a formatter once, so a repair never re-reads it. */
export interface WeekYearAnalysis {
  readonly calendar: string;
  readonly timeZone: string;
  readonly numberingSystem: string;
  readonly digits: ReadonlySet<string>;
  readonly reference: Reference;
  /** Digit run indexes that hold the year. */
  readonly yearRuns: readonly number[];
  /** How each year run is written, in the order of `yearRuns`. */
  readonly styles: readonly YearStyle[];
  /** The field each digit run holds. */
  readonly labels: readonly RunLabel[];
  /** The digit run count of the formatter's text. */
  readonly count: number;
  /** The text with the digits of names that hold them on some dates only hidden (`createNameMask`). */
  readonly mask: (text: string, ms: number) => string;
}
/**
 * Read a formatter's digit runs once: which hold the year, how each is written, and what field
 * every other one holds. Only `format` is called, on the formatter itself, in its zone and with its
 * time fields, and its text read through `mask`. `null` when the run count changes between probe
 * dates.
 */
export declare function analyse(format: (ms: number) => string, resolved: Intl.ResolvedDateTimeFormatOptions, mask: (text: string, ms: number) => string): WeekYearAnalysis | null;
/** One year run replaced in a text. */
export interface YearEdit {
  /** The run in the native text. */
  readonly from: number;
  readonly to: number;
  /** The span of the year in the repaired text. */
  readonly start: number;
  readonly end: number;
  readonly value: string;
}
/** A text with every year run holding the calendar year. */
export interface RepairedText {
  readonly text: string;
  readonly edits: readonly YearEdit[];
  readonly runs: readonly DigitRun[];
}
/**
 * `text` with every year run holding the calendar year, or `null` when the run count differs from
 * the analysis (the text has a shape it did not read: the data canary fails on any such date, so a
 * CLDR change that causes one is caught, not shipped).
 */
export declare function repairText(analysis: WeekYearAnalysis, text: string, ms: number): RepairedText | null;
/**
 * Native parts with each year run written as the `year` part holding the calendar year. WebKit
 * types the week-year `unknown`; a part that holds more than the run (a year glued to another
 * number) keeps its type and has the run's slice replaced.
 *
 * @returns the patched parts, or `null` when a run is split across parts or the patched parts do
 * not read as the repaired text
 */
export declare function patchYearParts(parts: readonly Intl.DateTimeFormatPart[], repaired: RepairedText): Intl.DateTimeFormatPart[] | null;
/** The first of the three digit-run checks `weekYearGuard.ts` makes at a boundary. */
export type BoundaryCheck = "ok" | "bad" | "shape";
/**
 * Whether every year run at `date` still reads as it does at the inside date `mid`, where the
 * calendar year is the same.
 *
 * A run printing the week-year differs at a year boundary; a run printing the calendar year does
 * not. A year glued to another number is compared by the year inside it: the boundary run must hold
 * the boundary date's calendar year in the same form (full or last two digits).
 */
export declare function checkYearRuns(yearRuns: readonly number[], at: readonly DigitRun[], mid: readonly DigitRun[], yearAt: string | null, yearMid: string | null): boolean;