"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RapidReanimation = void 0;
const add_minion_to_board_1 = require("../../../simulation/add-minion-to-board");
const utils_1 = require("../../../utils");
exports.RapidReanimation = {
    startOfCombatTiming: 'pre-combat',
    cardIds: ["BG25_HERO_103p"],
    startOfCombat: (trinket, input) => {
        for (const heroPower of input.playerEntity.heroPowers) {
            if (exports.RapidReanimation.cardIds.includes(heroPower.cardId) && heroPower.used) {
                const minionThatWillDie = input.playerBoard
                    .filter((m) => m.enchantments.some((e) => e.cardId === "BG25_HERO_103pe"))
                    .sort((a, b) => b.enchantments.find((e) => e.cardId === "BG25_HERO_103pe")
                    .originEntityId -
                    a.enchantments.find((e) => e.cardId === "BG25_HERO_103pe").originEntityId || b.entityId - a.entityId)[0];
                if (minionThatWillDie) {
                    const rapidReanimationIndexFromLeft = input.playerBoard.indexOf(minionThatWillDie);
                    const minionToCopy = (0, utils_1.copyEntity)(minionThatWillDie);
                    heroPower.info = minionToCopy;
                    heroPower.info2 = input.playerBoard.length - 1 - rapidReanimationIndexFromLeft;
                    (0, add_minion_to_board_1.removeAurasFromSelf)(minionToCopy, input.playerBoard, input.playerEntity, input.gameState);
                    minionThatWillDie.definitelyDead = true;
                    input.gameState.spectator.registerPowerTarget(input.playerEntity, minionThatWillDie, input.playerBoard, input.playerEntity, input.opponentEntity);
                    return { hasTriggered: true, shouldRecomputeCurrentAttacker: true };
                }
            }
        }
    },
};
//# sourceMappingURL=rapid-reanimation.js.map