import { SOUND_TYPES } from "../soundTypes.js";

const DATA_FULL = {
    "CORE_MAGIC": [
        {
            "id": "20",
            "name": "Fire Spell",
            type: SOUND_TYPES.ONESHOT
        },
        {
            "id": "21",
            "name": "Ice Spell",
            type: SOUND_TYPES.ONESHOT
        },
        {
            "id": "22",
            "name": "Lightning Spell",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "CORE_MELEE": [
        {
            "id": "1035",
            "name": "Sword Clash",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "CORE_RANGED": [
        {
            "id": "1039",
            "name": "Bow Fire",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "CORE_BRAWL": [
        {
            "id": "3743648",
            "name": "Unarmed Strike",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "CORE_HIT": [
        {
            "id": "3743656",
            "name": "Flesh Impact",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "CORE_CRIT": [
        {
            "id": "3743655",
            "name": "Critical Hit A",
            type: SOUND_TYPES.ONESHOT
        },
        {
            "id": "3743652",
            "name": "Critical Hit B",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "CORE_FUMBLE": [
        {
            "id": "375612",
            "name": "Fumble / Fail",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "CORE_MISS": [
        {
            "id": "3743648",
            "name": "Swing / Miss A",
            type: SOUND_TYPES.ONESHOT
        },
        {
            "id": "3743654",
            "name": "Swing / Miss B",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "CORE_WHOOSH": [
        {
            "id": "3743653",
            "name": "Weapon Swing",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "CORE_PAIN_MASCULINE": [
        {
            "id": "42589",
            "name": "Pain (Masculine)",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "CORE_PAIN_FEMININE": [
        {
            "id": "762",
            "name": "Pain (Feminine)",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "CORE_DEATH_MASCULINE": [
        {
            "id": "2638210",
            "name": "Death Scream",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "CORE_DEATH_FEMININE": [
        {
            "id": "2638210",
            "name": "Death Scream",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "PC_DEATH": [
        {
            "id": "2638210",
            "name": "PC Death (Default)",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "CORE_MONSTER_PAIN": [
        {
            "id": "3743632",
            "name": "Monster Growl/Pain",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "CORE_MONSTER_DEATH": [
        {
            "id": "3590",
            "name": "Monster Death",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "BLOODY_HIT": [
        {
            "id": "3743656",
            "name": "Flesh Impact (Bloody)",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "MONSTER_GENERIC": [
        {
            "id": "3743632",
            "name": "Monster Generic",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "CORE_HEAL": [
        {
            "id": "3652",
            "name": "Healing Spell",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "CORE_RECOVERY": [],
    "CORE_AMBIANCE_INDOOR": [
        {
            "id": "748294",
            "name": "Dungeon Ambience",
            type: SOUND_TYPES.MOOD
        }
    ],
    "CORE_AMBIANCE_OUTDOOR": [
        {
            "id": "65",
            "name": "Stormy Outdoors",
            type: SOUND_TYPES.MOOD
        }
    ],
    "DAGGERHEART_HOPE": [
        {
            "id": "3652",
            "name": "Positive Chime",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "DAGGERHEART_FEAR": [
        {
            "id": "762",
            "name": "Negative Chord",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "DAGGERHEART_FEAR_HIGH": [
        {
            "id": "762",
            "name": "Fear Spikes (High)",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "DAGGERHEART_FEAR_MED": [
        {
            "id": "762",
            "name": "Fear Spikes (Med)",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "DAGGERHEART_FEAR_LOW": [
        {
            "id": "762",
            "name": "Fear Spikes (Low)",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "DAGGERHEART_HOPE_USE": [
        {
            "id": "3652",
            "name": "Hope Token",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "DAGGERHEART_FEAR_USE": [
        {
            "id": "762",
            "name": "Fear Token",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "DAGGERHEART_STRESS": [
        {
            "id": "375612",
            "name": "Stress Crack",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "DAGGERHEART_ARMOR_USE": [
        {
            "id": "1035",
            "name": "Armor Deflection",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "DAGGERHEART_ARMOR_REPAIR": [
        {
            "id": "1035",
            "name": "Armor Repair",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "ATTACK_SWORD_SLASH": [
        {
            "id": "1035",
            "name": "Sword Slash",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "ATTACK_DAGGER_SLASH": [
        {
            "id": "3743648",
            "name": "Dagger Slash",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "ATTACK_BOW_FIRE": [
        {
            "id": "1039",
            "name": "Bow Fire",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "ATTACK_CROSSBOW_FIRE": [
        {
            "id": "1039",
            "name": "Crossbow Fire",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "ATTACK_BLUDGEON_SWING": [
        {
            "id": "1035",
            "name": "Bludgeon Swing",
            type: SOUND_TYPES.ONESHOT
        }
    ],
    "WHOOSH": [
        {
            "id": "3743653",
            "name": "Weapon Swing",
            type: SOUND_TYPES.ONESHOT
        }
    ]
};

// Helper to filter keys
function filterForSystem(data, systemId) {
    if (systemId === "dnd5e") {
        // Exclude Daggerheart specific keys
        return Object.keys(data)
            .filter(key => !key.startsWith("DAGGERHEART_"))
            .reduce((obj, key) => {
                obj[key] = data[key];
                return obj;
            }, {});
    }
    // For Daggerheart (or others), include everything for now
    // 'daggerheart' system uses all keys (Base + Daggerheart extensions)
    return data;
}

// Filter for Core/Free (Only CORE_ and DAGGERHEART_)
const DATA_CORE = Object.keys(DATA_FULL)
    .filter(key => key.startsWith("CORE_") || key.startsWith("DAGGERHEART_"))
    .reduce((obj, key) => {
        obj[key] = DATA_FULL[key];
        return obj;
    }, {});

// Generate Presets
const DND5E_FULL = filterForSystem(DATA_FULL, "dnd5e");
const DND5E_CORE = filterForSystem(DATA_CORE, "dnd5e"); // DATA_CORE is already filtered to CORE+DAGGERHEART, this removes DAGGERHEART

const DAGGERHEART_FULL = filterForSystem(DATA_FULL, "daggerheart");
const DAGGERHEART_CORE = filterForSystem(DATA_CORE, "daggerheart");


export const SYRINSCAPE_PRESETS = {
    "dnd5e_full": DND5E_FULL,
    "dnd5e_core": DND5E_CORE,
    "daggerheart_full": DAGGERHEART_FULL,
    "daggerheart_core": DAGGERHEART_CORE,
    "daggerheart_empty": {},
    "dnd5e_empty": {},

    // Fallbacks
    "full": DATA_FULL,
    "core": DATA_CORE,
    "empty": {}
};

// Legacy Export
export const SYRINSCAPE_DEFAULTS = DATA_FULL;
