"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBaseCardId = exports.AllCardsService = void 0;
const card_ids_1 = require("../card-ids");
const public_api_1 = require("../public-api");
const cards_for_deckbuilding_service_1 = require("./cards-for-deckbuilding.service");
const utils_1 = require("./utils");
const MIRRORS = ['https://static.zerotoheroes.com/data/cards', 'https://static.firestoneapp.com/data/cards'];
class AllCardsService {
    constructor() {
        this.cache = {};
        this.cacheDbfId = {};
    }
    getCard(id, errorWhenUndefined = true) {
        var _a, _b;
        return (_b = (_a = this.cache[id]) !== null && _a !== void 0 ? _a : this.cacheDbfId[id]) !== null && _b !== void 0 ? _b : {};
    }
    getMultipleCards(ids) {
        return ids.map((id) => this.getCard(id));
    }
    getCardFromDbfId(dbfId) {
        var _a;
        return (_a = this.cacheDbfId[dbfId]) !== null && _a !== void 0 ? _a : {};
    }
    getCardsFromDbfIds(dbfIds) {
        return dbfIds.map((dbfId) => this.getCardFromDbfId(dbfId));
    }
    getCards() {
        return Object.values(this.cache);
    }
    initializeCardsDbFromCards(allCards) {
        this.cache = {};
        this.cacheDbfId = {};
        if (!(allCards === null || allCards === void 0 ? void 0 : allCards.length)) {
            console.error('[all-cards] cannot init with empty cards');
        }
        else {
            for (const card of allCards) {
                if (card.id) {
                    this.cache[card.id] = card;
                }
                if (card.dbfId) {
                    this.cacheDbfId[card.dbfId] = card;
                }
            }
        }
        this.deckbuilding = new cards_for_deckbuilding_service_1.CardsForDeckbuildingService();
        this.deckbuilding.init(this);
    }
    async initializeCardsDb(version = '', cardsFile = 'cards_enUS.gz.json') {
        for (const mirror of MIRRORS) {
            try {
                const allCards = await this.loadCards(mirror, cardsFile, version);
                if (!!(allCards === null || allCards === void 0 ? void 0 : allCards.length)) {
                    this.initializeCardsDbFromCards(allCards);
                    return;
                }
            }
            catch (e) {
                console.error('[all-cards] could not load cards from mirror', mirror, e.message);
            }
        }
    }
    getRootCardId(cardId) {
        var _a, _b, _c, _d;
        const card = this.getCard(cardId);
        const dbfId = (_c = (_b = (_a = card === null || card === void 0 ? void 0 : card.counterpartCards) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : card === null || card === void 0 ? void 0 : card.deckDuplicateDbfId) !== null && _c !== void 0 ? _c : card === null || card === void 0 ? void 0 : card.dbfId;
        return (_d = this.getCard(dbfId)) === null || _d === void 0 ? void 0 : _d.id;
    }
    normalizeDeckList(decklist) {
        return this.deckbuilding.normalizeDeckList(decklist, this);
    }
    normalizeSideboard(sideboard, format) {
        return this.deckbuilding.normalizeSideboard(sideboard, format, this);
    }
    getBaseCardDbfIdForDeckbuilding(cardIdOrDbfId, format) {
        return this.deckbuilding.getBaseCardDbfIdForDeckbuilding(cardIdOrDbfId, format, this);
    }
    getBaseCardIdForDeckbuilding(cardIdOrDbfId, format) {
        return this.deckbuilding.getBaseCardIdForDeckbuilding(cardIdOrDbfId, format, this);
    }
    async loadCards(baseUrl, cardsFile, version) {
        const versionString = !!(version === null || version === void 0 ? void 0 : version.length) ? `?v=${version}` : '';
        const url = `${baseUrl}/${cardsFile}${versionString}`;
        let cardsStr = await this.getCardsStr(url);
        if (!!(cardsStr === null || cardsStr === void 0 ? void 0 : cardsStr.length) && !cardsStr.startsWith('<')) {
            return JSON.parse(cardsStr);
        }
        console.warn('[all-cards] could not load cards, defaulting to split');
        const numberOfSplits = 5;
        const result = [];
        try {
            for (let i = 0; i < numberOfSplits; i++) {
                const splitUrl = `${baseUrl}/split/${cardsFile}.${i}${versionString}`;
                console.log('[all-cards] loading split', splitUrl);
                cardsStr = await utils_1.httpWithRetries(splitUrl, 1);
                if (!!(cardsStr === null || cardsStr === void 0 ? void 0 : cardsStr.length) && !cardsStr.startsWith('<')) {
                    const splitCards = JSON.parse(cardsStr);
                    console.log('loaded split cards', splitCards === null || splitCards === void 0 ? void 0 : splitCards.length);
                    result.push(...splitCards);
                }
                else {
                    throw new Error(`Could not load split cards from ${splitUrl}`);
                }
            }
            if (!!(result === null || result === void 0 ? void 0 : result.length)) {
                return result;
            }
        }
        catch (e) {
            console.error('[all-cards] could not load split cards', e.message);
        }
        const urlNoAudio = `${baseUrl}/no_audio/${cardsFile}${versionString}`;
        console.warn('[all-cards] could not load cards, defaulting to no_audio', urlNoAudio);
        cardsStr = await utils_1.httpWithRetries(urlNoAudio, 1);
        if (!!(cardsStr === null || cardsStr === void 0 ? void 0 : cardsStr.length) && !cardsStr.startsWith('<')) {
            return JSON.parse(cardsStr);
        }
        return [];
    }
    async getCardsStr(url) {
        return await utils_1.httpWithRetries(url, 1);
    }
}
exports.AllCardsService = AllCardsService;
const getBaseCardId = (cardId, allCards) => {
    if (!cardId) {
        return null;
    }
    switch (cardId) {
        case card_ids_1.CardIds.LesserSpinelSpellstone_SpinelSpellstoneToken_TOY_825t:
        case card_ids_1.CardIds.LesserSpinelSpellstone_GreaterSpinelSpellstoneToken_TOY_825t2:
            return card_ids_1.CardIds.LesserSpinelSpellstone_TOY_825;
        case card_ids_1.CardIds.LesserJasperSpellstone_JasperSpellstoneToken:
        case card_ids_1.CardIds.LesserJasperSpellstone_GreaterJasperSpellstoneToken:
            return card_ids_1.CardIds.LesserJasperSpellstone_CORE_LOOT_051;
        case card_ids_1.CardIds.LesserEmeraldSpellstone_EmeraldSpellstoneToken:
        case card_ids_1.CardIds.LesserEmeraldSpellstone_GreaterEmeraldSpellstoneToken:
            return card_ids_1.CardIds.LesserEmeraldSpellstone_CORE_FB_Champs_LOOT_080;
        case card_ids_1.CardIds.LesserDiamondSpellstone_DiamondSpellstoneToken:
        case card_ids_1.CardIds.LesserDiamondSpellstone_GreaterDiamondSpellstoneToken:
            return card_ids_1.CardIds.LesserDiamondSpellstone_CORE_LOOT_507;
        case card_ids_1.CardIds.LesserAmethystSpellstone_AmethystSpellstoneToken:
        case card_ids_1.CardIds.LesserAmethystSpellstone_GreaterAmethystSpellstoneToken:
            return card_ids_1.CardIds.LesserAmethystSpellstone_CORE_LOOT_043;
        case card_ids_1.CardIds.LesserOpalSpellstone_OpalSpellstoneToken_TOY_645t:
        case card_ids_1.CardIds.LesserOpalSpellstone_GreaterOpalSpellstoneToken_TOY_645t1:
            return card_ids_1.CardIds.LesserOpalSpellstone_TOY_645;
        case 'LOOT_103t1':
        case 'LOOT_103t2':
            return 'LOOT_103';
        case 'LOOT_043t2':
        case 'LOOT_043t3':
            return 'LOOT_043';
        case 'LOOT_051t1':
        case 'LOOT_051t2':
            return 'LOOT_051';
        case 'LOOT_064t1':
        case 'LOOT_064t2':
            return 'LOOT_064';
        case 'LOOT_080t2':
        case 'LOOT_080t3':
            return 'LOOT_080';
        case 'LOOT_091t1':
        case 'LOOT_091t2':
            return 'LOOT_091';
        case 'LOOT_203t2':
        case 'LOOT_203t3':
            return 'LOOT_203';
        case 'LOOT_503t':
        case 'LOOT_503t2':
            return 'LOOT_503';
        case 'LOOT_507t':
        case 'LOOT_507t2':
            return 'LOOT_507';
        case 'FB_Champs_LOOT_080t2':
        case 'FB_Champs_LOOT_080t3':
            return 'FB_Champs_LOOT_080';
        case 'LOOT_278t1':
            return 'LOOT_278';
        case 'LOOT_278t2':
            return 'LOOT_278';
        case 'LOOT_278t3':
            return 'LOOT_278';
        case 'LOOT_278t4':
            return 'LOOT_278';
        case 'LOOT_285t':
            return 'LOOT_285';
        case 'LOOT_285t2':
            return 'LOOT_285';
        case 'LOOT_285t3':
            return 'LOOT_285';
        case 'LOOT_285t4':
            return 'LOOT_285';
        case 'LOOT_286t1':
            return 'LOOT_286';
        case 'LOOT_286t2':
            return 'LOOT_286';
        case 'LOOT_286t3':
            return 'LOOT_286';
        case 'LOOT_286t4':
            return 'LOOT_286';
        case 'DAL_366t1':
            return 'DAL_366';
        case 'DAL_366t2':
            return 'DAL_366';
        case 'DAL_366t3':
            return 'DAL_366';
        case 'DAL_366t4':
            return 'DAL_366';
        case card_ids_1.CardIds.GalakrondTheTempest_GalakrondTheApocalypseToken:
        case card_ids_1.CardIds.GalakrondTheTempest_GalakrondAzerothsEndToken:
            return card_ids_1.CardIds.GalakrondTheTempest;
        case card_ids_1.CardIds.GalakrondTheWretched_GalakrondTheApocalypseToken:
        case card_ids_1.CardIds.GalakrondTheWretched_GalakrondAzerothsEndToken:
            return card_ids_1.CardIds.GalakrondTheWretched;
        case card_ids_1.CardIds.GalakrondTheUnspeakable_GalakrondTheApocalypseToken:
        case card_ids_1.CardIds.GalakrondTheUnspeakable_GalakrondAzerothsEndToken:
            return card_ids_1.CardIds.GalakrondTheUnspeakable;
        case card_ids_1.CardIds.GalakrondTheNightmare_GalakrondTheApocalypseToken:
        case card_ids_1.CardIds.GalakrondTheNightmare_GalakrondAzerothsEndToken:
            return card_ids_1.CardIds.GalakrondTheNightmare;
        case card_ids_1.CardIds.GalakrondTheUnbreakable_GalakrondTheApocalypseToken:
        case card_ids_1.CardIds.GalakrondTheUnbreakable_GalakrondAzerothsEndToken:
            return card_ids_1.CardIds.GalakrondTheUnbreakable;
        case 'DMF_054t':
            return 'DMF_054';
        case 'DMF_061t':
            return 'DMF_061';
        case 'DMF_064t':
            return 'DMF_064';
        case 'DMF_073t':
            return 'DMF_073';
        case 'DMF_078t':
            return 'DMF_078';
        case 'DMF_080t':
            return 'DMF_080';
        case 'DMF_082t':
            return 'DMF_082';
        case 'DMF_083t':
            return 'DMF_083';
        case 'DMF_090t':
            return 'DMF_090';
        case 'DMF_101t':
            return 'DMF_101';
        case 'DMF_105t':
            return 'DMF_105';
        case 'DMF_117t':
            return 'DMF_117';
        case 'DMF_117t2':
            return 'DMF_117';
        case 'DMF_118t':
            return 'DMF_118';
        case 'DMF_124t':
            return 'DMF_124';
        case 'DMF_163t':
            return 'DMF_163';
        case 'DMF_174t':
            return 'DMF_174';
        case 'DMF_184t':
            return 'DMF_184';
        case 'DMF_186a':
            return 'DMF_186';
        case 'DMF_244t':
            return 'DMF_244';
        case 'DMF_247t':
            return 'DMF_247';
        case 'DMF_248t':
            return 'DMF_248';
        case 'DMF_517a':
            return 'DMF_517';
        case 'DMF_526a':
            return 'DMF_526';
        case 'DMF_701t':
            return 'DMF_701';
        case 'DMF_703t':
            return 'DMF_703';
        case 'DMF_730t':
            return 'DMF_730';
        case 'DMF_526a':
            return 'DMF_526';
        case card_ids_1.CardIds.DreamingDrake_DreamingDrakeToken:
            return card_ids_1.CardIds.DreamingDrake;
        case card_ids_1.CardIds.LibramOfJudgment_LibramOfJudgmentToken:
            return card_ids_1.CardIds.LibramOfJudgment;
        case card_ids_1.CardIds.LuckysoulHoarder_LuckysoulHoarderToken:
            return card_ids_1.CardIds.LuckysoulHoarder;
        case card_ids_1.CardIds.NitroboostPoison_NitroboostPoisonToken:
            return card_ids_1.CardIds.NitroboostPoison;
        case card_ids_1.CardIds.TameBeastRank1_TameBeastRank2Token:
        case card_ids_1.CardIds.TameBeastRank1_TameBeastRank3Token:
            return card_ids_1.CardIds.TameBeastRank1;
        case card_ids_1.CardIds.ChainLightningRank1_ChainLightningRank2Token:
        case card_ids_1.CardIds.ChainLightningRank1_ChainLightningRank3Token:
            return card_ids_1.CardIds.ChainLightningRank1;
        case card_ids_1.CardIds.FlurryRank1_FlurryRank2Token:
        case card_ids_1.CardIds.FlurryRank1_FlurryRank3Token:
            return card_ids_1.CardIds.FlurryRank1;
        case card_ids_1.CardIds.CondemnRank1_CondemnRank2Token:
        case card_ids_1.CardIds.CondemnRank1_CondemnRank3Token:
            return card_ids_1.CardIds.CondemnRank1;
        case card_ids_1.CardIds.WickedStabRank1_WickedStabRank2Token:
        case card_ids_1.CardIds.WickedStabRank1_WickedStabRank3Token:
            return card_ids_1.CardIds.WickedStabRank1;
        case card_ids_1.CardIds.LivingSeedRank1_LivingSeedRank2Token:
        case card_ids_1.CardIds.LivingSeedRank1_LivingSeedRank3Token:
            return card_ids_1.CardIds.LivingSeedRank1;
        case card_ids_1.CardIds.ConvictionRank1_ConvictionRank2Token:
        case card_ids_1.CardIds.ConvictionRank1_ConvictionRank3Token:
            return card_ids_1.CardIds.ConvictionRank1;
        case card_ids_1.CardIds.ConditioningRank1_ConditioningRank2Token:
        case card_ids_1.CardIds.ConditioningRank1_ConditioningRank3Token:
            return card_ids_1.CardIds.ConditioningRank1;
        case card_ids_1.CardIds.FuryRank1_FuryRank2Token:
        case card_ids_1.CardIds.FuryRank1_FuryRank3Token:
            return card_ids_1.CardIds.FuryRank1;
        case card_ids_1.CardIds.ImpSwarmRank1_ImpSwarmRank2Token:
        case card_ids_1.CardIds.ImpSwarmRank1_ImpSwarmRank3Token:
            return card_ids_1.CardIds.ImpSwarmRank1;
        case card_ids_1.CardIds.MischievousImp_MischievousImpToken:
            return card_ids_1.CardIds.MischievousImp;
        case card_ids_1.CardIds.ImpKingRafaam_ImpKingRafaamToken:
            return card_ids_1.CardIds.ImpKingRafaam_REV_789;
        case card_ids_1.CardIds.StonebornAccuser_StonebornAccuserToken:
            return card_ids_1.CardIds.StonebornAccuser;
        case card_ids_1.CardIds.Murlocula_MurloculaToken:
            return card_ids_1.CardIds.Murlocula;
        case card_ids_1.CardIds.FamishedFool_FamishedFoolToken:
            return card_ids_1.CardIds.FamishedFool;
        case card_ids_1.CardIds.SinfueledGolem_SinfueledGolemToken:
            return card_ids_1.CardIds.SinfueledGolem;
        case card_ids_1.CardIds.InsatiableDevourer_InsatiableDevourerToken:
            return card_ids_1.CardIds.InsatiableDevourer;
        case card_ids_1.CardIds.SireDenathrius_SireDenathriusToken:
            return card_ids_1.CardIds.SireDenathrius_REV_906;
        case card_ids_1.CardIds.PriestOfTheDeceased_PriestOfTheDeceasedToken:
            return card_ids_1.CardIds.PriestOfTheDeceased;
        case card_ids_1.CardIds.ArtificerXymox_ArtificerXymoxToken:
            return card_ids_1.CardIds.ArtificerXymox_REV_937;
        case card_ids_1.CardIds.BuffetBiggun_BuffetBiggunToken:
            return card_ids_1.CardIds.BuffetBiggun;
        case card_ids_1.CardIds.ImbuedAxe_ImbuedAxeToken:
            return card_ids_1.CardIds.ImbuedAxe;
        case card_ids_1.CardIds.CleanTheScene_CleanTheSceneToken:
            return card_ids_1.CardIds.CleanTheScene;
        case card_ids_1.CardIds.ConvincingDisguise_ConvincingDisguiseToken:
            return card_ids_1.CardIds.ConvincingDisguise;
        case card_ids_1.CardIds.PlotOfSin_PlotOfSinToken:
            return card_ids_1.CardIds.PlotOfSin;
        case card_ids_1.CardIds.AllFelBreaksLoose_AllFelBreaksLooseToken:
            return card_ids_1.CardIds.AllFelBreaksLoose;
        case card_ids_1.CardIds.Shadehound_ShadehoundToken:
            return card_ids_1.CardIds.Shadehound;
        case card_ids_1.CardIds.TotemicEvidence_TotemicEvidenceToken:
            return card_ids_1.CardIds.TotemicEvidence;
        case card_ids_1.CardIds.SylvanasTheAccused_SylvanasTheAccusedToken:
            return card_ids_1.CardIds.SylvanasTheAccused;
        case card_ids_1.CardIds.RemixedDispenseOBot_ChillingDispenseOBotToken:
        case card_ids_1.CardIds.RemixedDispenseOBot_MerchDispenseOBotToken:
        case card_ids_1.CardIds.RemixedDispenseOBot_MoneyDispenseOBotToken:
        case card_ids_1.CardIds.RemixedDispenseOBot_MysteryDispenseOBotToken:
            return card_ids_1.CardIds.RemixedDispenseOBot;
        case card_ids_1.CardIds.RemixedRhapsody_AngstyRhapsodyToken:
        case card_ids_1.CardIds.RemixedRhapsody_ResoundingRhapsodyToken:
        case card_ids_1.CardIds.RemixedRhapsody_EmotionalRhapsodyToken:
        case card_ids_1.CardIds.RemixedRhapsody_WailingRhapsodyToken:
            return card_ids_1.CardIds.RemixedRhapsody;
        case card_ids_1.CardIds.RemixedTotemcarver_LoudTotemcarverToken:
        case card_ids_1.CardIds.RemixedTotemcarver_BluesyTotemcarverToken:
        case card_ids_1.CardIds.RemixedTotemcarver_BlazingTotemcarverToken:
        case card_ids_1.CardIds.RemixedTotemcarver_KaraokeTotemcarverToken:
            return card_ids_1.CardIds.RemixedTotemcarver;
        case card_ids_1.CardIds.RemixedMusician_CathedralMusicianToken:
        case card_ids_1.CardIds.RemixedMusician_TropicalMusicianToken:
        case card_ids_1.CardIds.RemixedMusician_RomanticMusicianToken:
        case card_ids_1.CardIds.RemixedMusician_NoiseMusicianToken:
            return card_ids_1.CardIds.RemixedMusician;
        case card_ids_1.CardIds.RemixedTuningFork_SharpenedTuningForkToken:
        case card_ids_1.CardIds.RemixedTuningFork_ReinforcedTuningForkToken:
        case card_ids_1.CardIds.RemixedTuningFork_CurvedTuningForkToken:
        case card_ids_1.CardIds.RemixedTuningFork_BackupTuningForkToken:
            return card_ids_1.CardIds.RemixedTuningFork;
        case card_ids_1.CardIds.BellowingFlames_BellowingFlamesToken:
            return card_ids_1.CardIds.BellowingFlames;
        case card_ids_1.CardIds.ChampionOfStorms_StormCycloneToken_TTN_801t2:
            return card_ids_1.CardIds.ChampionOfStorms_StormCycloneToken_TTN_801t1;
        case card_ids_1.CardIds.CreationProtocol_CreationProtocolToken:
            return card_ids_1.CardIds.CreationProtocol;
        case card_ids_1.CardIds.DiscipleOfSargeras_DiscipleOfSargerasToken:
            return card_ids_1.CardIds.DiscipleOfSargeras;
        case card_ids_1.CardIds.EmbraceOfNature_EmbraceOfNatureToken:
            return card_ids_1.CardIds.EmbraceOfNature;
        case card_ids_1.CardIds.Eulogizer_EulogizerToken:
            return card_ids_1.CardIds.Eulogizer;
        case card_ids_1.CardIds.LabConstructor_LabConstructorToken:
            return card_ids_1.CardIds.LabConstructor;
        case card_ids_1.CardIds.MechagnomeGuide_MechagnomeGuideToken:
            return card_ids_1.CardIds.MechagnomeGuide;
        case card_ids_1.CardIds.MoltenRune_MoltenRuneToken:
            return card_ids_1.CardIds.MoltenRune;
        case card_ids_1.CardIds.StormGiant_StormGiantToken:
            return card_ids_1.CardIds.StormGiant;
        case card_ids_1.CardIds.TitanforgedTraps_TitanforgedTrapsToken:
            return card_ids_1.CardIds.TitanforgedTraps;
        case card_ids_1.CardIds.TyrsTears_TyrsTearsToken:
            return card_ids_1.CardIds.TyrsTears;
        case card_ids_1.CardIds.WatcherOfTheSun_WatcherOfTheSunToken:
            return card_ids_1.CardIds.WatcherOfTheSun;
        case card_ids_1.CardIds.WeightOfTheWorld_WeightOfTheWorldToken:
            return card_ids_1.CardIds.WeightOfTheWorld;
        case card_ids_1.CardIds.Xb488Disposalbot_Xb488DisposalbotToken:
            return card_ids_1.CardIds.Xb488Disposalbot;
        case card_ids_1.CardIds.MuscleOTron_MuscleOTronToken_YOG_525t:
            return card_ids_1.CardIds.MuscleOTron_YOG_525;
        case card_ids_1.CardIds.Sanitize_SanitizeToken_YOG_502t:
            return card_ids_1.CardIds.Sanitize_YOG_502;
        case card_ids_1.CardIds.FromTheScrapheap_SparkbotToken_TTN_719t:
        case card_ids_1.CardIds.FromTheScrapheap_SparkbotToken_TTN_719t1:
        case card_ids_1.CardIds.FromTheScrapheap_SparkbotToken_TTN_719t2:
        case card_ids_1.CardIds.FromTheScrapheap_SparkbotToken_TTN_719t3:
        case card_ids_1.CardIds.FromTheScrapheap_SparkbotToken_TTN_719t4:
        case card_ids_1.CardIds.FromTheScrapheap_SparkbotToken_TTN_719t5:
        case card_ids_1.CardIds.FromTheScrapheap_SparkbotToken_TTN_719t6:
        case card_ids_1.CardIds.FromTheScrapheap_SparkbotToken_TTN_719t7:
            return card_ids_1.CardIds.DroneDeconstructor;
        case card_ids_1.CardIds.ElementalInspiration_PrimordialVortexToken_TTN_480t1:
        case card_ids_1.CardIds.ElementalInspiration_PrimordialVortexToken_TTN_480t2:
        case card_ids_1.CardIds.ElementalInspiration_PrimordialVortexToken_TTN_480t3:
        case card_ids_1.CardIds.ElementalInspiration_PrimordialVortexToken_TTN_480t4:
        case card_ids_1.CardIds.ElementalInspiration_PrimordialVortexToken_TTN_480t5:
        case card_ids_1.CardIds.ElementalInspiration_PrimordialVortexToken_TTN_480t6:
        case card_ids_1.CardIds.ElementalInspiration_PrimordialVortexToken_TTN_480t7:
            return card_ids_1.CardIds.ElementalInspiration_PrimordialVortexToken_TTN_480t;
        case card_ids_1.CardIds.ForestSeedlings_ForestBlossomsToken:
            return card_ids_1.CardIds.ForestSeedlings;
        case card_ids_1.CardIds.FrostLotusSeedling_FrostLotusBlossomToken:
            return card_ids_1.CardIds.FrostLotusSeedling;
        case card_ids_1.CardIds.UngoroBrochure_DalaranBrochureToken_WORK_050t:
            return card_ids_1.CardIds.UngoroBrochure_WORK_050;
        case card_ids_1.CardIds.SilvermoonBrochure_GilneasBrochureToken_WORK_017t:
            return card_ids_1.CardIds.SilvermoonBrochure_WORK_017;
        case card_ids_1.CardIds.IcecrownBrochure_BlackrockBrochureToken_WORK_030t:
            return card_ids_1.CardIds.IcecrownBrochure_WORK_030;
        case card_ids_1.CardIds.SiegeTank_SiegeTankDeployedToken_SC_413t:
            return card_ids_1.CardIds.SiegeTank_SC_413;
        case card_ids_1.CardIds.Hellion_HellbatToken_SC_412t:
            return card_ids_1.CardIds.Hellion_SC_412;
        case card_ids_1.CardIds.Thor_ThorExplosivePayloadToken_SC_414t:
            return card_ids_1.CardIds.Thor_SC_414;
        case card_ids_1.CardIds.WishOfTheNewMoon_WishOfTheFullMoonToken_EDR_460t:
            return card_ids_1.CardIds.WishOfTheNewMoon_EDR_460;
    }
    if (cardId.startsWith(card_ids_1.CardIds.TransferStudent)) {
        return card_ids_1.CardIds.TransferStudent;
    }
    if (cardId.startsWith(card_ids_1.CardIds.ZilliaxDeluxe3000_TOY_330)) {
        return card_ids_1.CardIds.ZilliaxDeluxe3000_TOY_330;
    }
    const refCard = allCards.getCard(cardId);
    if (public_api_1.hasMechanic(refCard, public_api_1.GameTag.SHATTERED)) {
        const baseCardId = cardId.replace(/t\d*$/, '');
        if (baseCardId !== cardId) {
            return baseCardId;
        }
    }
    return cardId;
};
exports.getBaseCardId = getBaseCardId;
//# sourceMappingURL=all-cards.service.js.map