import { Id, InputStage, SeedOrdering, Stage } from 'brackets-model';
import { Storage, ParticipantSlot } from '../../types';
import { BracketsManager } from '../..';
/**
 * Creates a stage.
 *
 * @param this Instance of BracketsManager.
 * @param stage The stage to create.
 */
export declare function create(this: BracketsManager, stage: InputStage): Promise<Stage>;
export declare class StageCreator {
    private storage;
    private stage;
    private readonly seedOrdering;
    private updateMode;
    private enableByesInUpdate;
    private currentStageId;
    /**
     * Creates an instance of StageCreator, which will handle the creation of the stage.
     *
     * @param storage The implementation of Storage.
     * @param stage The stage to create.
     */
    constructor(storage: Storage, stage: InputStage);
    /**
     * Run the creation process.
     */
    run(): Promise<Stage>;
    /**
     * Enables the update mode.
     *
     * @param stageId ID of the stage.
     * @param enableByes Whether to use BYEs or TBDs for `null` values in an input seeding.
     */
    setExisting(stageId: Id, enableByes: boolean): void;
    /**
     * Creates a round-robin stage.
     *
     * Group count must be given. It will distribute participants in groups and rounds.
     */
    private roundRobin;
    /**
     * Creates a single elimination stage.
     *
     * One bracket and optionally a consolation final between semi-final losers.
     */
    private singleElimination;
    /**
     * Creates a double elimination stage.
     *
     * One upper bracket (winner bracket, WB), one lower bracket (loser bracket, LB) and optionally a grand final
     * between the winner of both bracket, which can be simple or double.
     */
    private doubleElimination;
    /**
     * Creates a double elimination stage with skip first round option.
     *
     * @param stageId ID of the stage.
     * @param slots A list of slots.
     */
    private createDoubleEliminationSkipFirstRound;
    /**
     * Creates a double elimination stage.
     *
     * @param stageId ID of the stage.
     * @param slots A list of slots.
     */
    private createDoubleElimination;
    /**
     * Creates a round-robin group.
     *
     * This will make as many rounds as needed to let each participant match every other once.
     *
     * @param stageId ID of the parent stage.
     * @param groupNumber Number of the group in the stage.
     * @param slots A list of slots.
     */
    private createRoundRobinGroup;
    /**
     * Creates a standard bracket, which is the only one in single elimination and the upper one in double elimination.
     *
     * This will make as many rounds as needed to end with one winner.
     *
     * @param stageId ID of the parent stage.
     * @param groupNumber Number of the group in the stage.
     * @param slots A list of slots.
     */
    private createStandardBracket;
    /**
     * Creates a lower bracket, alternating between major and minor rounds.
     *
     * - A major round is a regular round.
     * - A minor round matches the previous (major) round's winners against upper bracket losers of the corresponding round.
     *
     * @param stageId ID of the parent stage.
     * @param groupNumber Number of the group in the stage.
     * @param losers One list of losers per upper bracket round.
     */
    private createLowerBracket;
    /**
     * Creates a bracket with rounds that only have 1 match each. Used for finals.
     *
     * @param stageId ID of the parent stage.
     * @param groupNumber Number of the group in the stage.
     * @param duels A list of duels.
     * @param overrides Optional overrides.
     */
    private createUniqueMatchBracket;
    /**
     * Creates a round, which contain matches.
     *
     * @param stageId ID of the parent stage.
     * @param groupId ID of the parent group.
     * @param roundNumber Number in the group.
     * @param matchCount Duel/match count.
     * @param duels A list of duels.
     * @param matchNumberStart Optionally give the starting point for the match numbers. Starts at 1 by default.
     */
    private createRound;
    /**
     * Creates a match, possibly with match games.
     *
     * - If `childCount` is 0, then there is no children. The score of the match is directly its intrinsic score.
     * - If `childCount` is greater than 0, then the score of the match will automatically be calculated based on its child games.
     *
     * @param stageId ID of the parent stage.
     * @param groupId ID of the parent group.
     * @param roundId ID of the parent round.
     * @param matchNumber Number in the round.
     * @param opponents The two opponents matching against each other.
     * @param childCount Child count for this match (number of games).
     */
    private createMatch;
    /**
     * Gets the duels for the current round based on the previous one. No ordering is done, it must be done beforehand for the first round.
     *
     * @param previousDuels Duels of the previous round.
     * @param currentDuelCount Count of duels (matches) in the current round.
     */
    private getCurrentDuels;
    /**
     * Returns a list of slots.
     * - If `seeding` was given, inserts them in the storage.
     * - If `size` was given, only returns a list of empty slots.
     *
     * @param positions An optional list of positions (seeds) for a manual ordering.
     */
    getSlots(positions?: number[]): Promise<ParticipantSlot[]>;
    /**
     * Returns the list of slots with a seeding containing names. Participants may be added to database.
     *
     * @param seeding The seeding (names).
     * @param positions An optional list of positions (seeds) for a manual ordering.
     */
    private getSlotsUsingNames;
    /**
     * Returns the list of slots with a seeding containing IDs. No database mutation.
     *
     * @param seeding The seeding (IDs).
     * @param positions An optional list of positions (seeds) for a manual ordering.
     */
    private getSlotsUsingIds;
    /**
     * Gets the current stage number based on existing stages.
     */
    private getStageNumber;
    /**
     * Safely gets `matchesChildCount` in the stage input settings.
     */
    private getMatchesChildCount;
    /**
     * Safely gets an ordering by its index in the stage input settings.
     *
     * @param orderingIndex Index of the ordering.
     * @param stageType A value indicating if the method should be a group method or not.
     * @param defaultMethod The default method to use if not given.
     */
    private getOrdering;
    /**
     * Gets the duels in groups for a round-robin stage.
     */
    private getRoundRobinGroups;
    /**
     * Returns the ordering method for the groups in a round-robin stage.
     */
    getRoundRobinOrdering(): SeedOrdering;
    /**
     * Returns the ordering method for the first round of the upper bracket of an elimination stage.
     */
    getStandardBracketFirstRoundOrdering(): SeedOrdering;
    /**
     * Safely gets the only major ordering for the lower bracket.
     *
     * @param participantCount Number of participants in the stage.
     */
    private getMajorOrdering;
    /**
     * Safely gets a minor ordering for the lower bracket by its index.
     *
     * @param participantCount Number of participants in the stage.
     * @param index Index of the minor round.
     * @param minorRoundCount Number of minor rounds.
     */
    private getMinorOrdering;
    /**
     * Inserts a stage or finds an existing one.
     *
     * @param stage The stage to insert.
     */
    private insertStage;
    /**
     * Inserts a group or finds an existing one.
     *
     * @param group The group to insert.
     */
    private insertGroup;
    /**
     * Inserts a round or finds an existing one.
     *
     * @param round The round to insert.
     */
    private insertRound;
    /**
     * Inserts a match or updates an existing one.
     *
     * @param match The match to insert.
     * @param existing An existing match corresponding to the current one.
     */
    private insertMatch;
    /**
     * Inserts a match game or finds an existing one (and updates it).
     *
     * @param matchGame The match game to insert.
     */
    private insertMatchGame;
    /**
     * Inserts missing participants.
     *
     * @param participants The list of participants to process.
     */
    private registerParticipants;
    /**
     * Creates a new stage.
     */
    private createStage;
    /**
     * Creates a consolation final for the semi final losers of an upper bracket (single or double elimination).
     *
     * @param stageId ID of the stage.
     * @param losers The semi final losers who will play the consolation final.
     * @param overrides Optional overrides.
     */
    private createConsolationFinal;
    /**
     * Creates a grand final (none, simple or double) for winners of both bracket in a double elimination stage.
     *
     * @param stageId ID of the stage.
     * @param winnerWb The winner of the winner bracket.
     * @param winnerLb The winner of the loser bracket.
     */
    private createGrandFinal;
    /**
     * Ensures that the seed ordering list is stored even if it was not given in the first place.
     *
     * @param stageId ID of the stage.
     */
    private ensureSeedOrdering;
}
//# sourceMappingURL=creator.d.ts.map