-------------------------------------------------------------------------------
-- SpatialParadox.lua
-- 12.1: tracked as a buff GROUP on the player via the tracker's
-- AuraContainer slot, mirroring Time Spiral. Spatial Paradox can land as one
-- of two auras — the caster's own cast (406732) or the linked-ally buff
-- (406789) — and a Preservation Evoker can briefly have BOTH at once. Each ID
-- gets its OWN Tracked Buffs row/checkbox (owner decision 2026-08-09,
-- replacing the old collapsed single-entry design), but the display stays
-- capped to ONE frame via config.singleActive (hard
-- SetAuraGroupMaxFrameCount(1) in ApplyGroupAssignments) — when both auras
-- are up, the engine surfaces one.
--
-- PTR-VERIFY (buff IDs): 406732 is the Evoker cast. 406789 is the suspected
-- ally-side aura — verify OUT OF COMBAT on PTR (aura data is readable OOC)
-- with a friendly Evoker; if the ally buff carries a different spellID, fix it
-- in SPELLS below.
-------------------------------------------------------------------------------
local addonName, ns = ...

local DISPLAY_ICON_SPELL = 406732

-- One row per buff ID. The two auras share the in-game name, so the self-cast
-- row is suffixed "(Self)" to keep the list unambiguous. key = the row's own
-- ID (locale-stable).
local SPELLS = {
    {
        key  = 406732,
        name = "Spatial Paradox (Self)",
        ids  = { 406732 }, -- Evoker's own cast
    },
    {
        key  = 406789,
        name = "Spatial Paradox",
        ids  = { 406789 }, -- Linked-ally buff (PTR-VERIFY 406789)
    },
}

local allIDs = {}
local defaultSpells = {}
for _, sp in ipairs(SPELLS) do
    defaultSpells[sp.key] = true
    for _, id in ipairs(sp.ids) do
        allIDs[#allIDs + 1] = id
    end
end

ns.RegisterTracker("spatial", {
    dbPrefix     = "",
    displaySpell = DISPLAY_ICON_SPELL, -- Spatial Paradox icon for previews/tree
    buffSpellIDs = allIDs,
    spellList    = SPELLS,
    -- Only one Spatial Paradox display at a time even when both auras are up:
    -- hard-caps the group to 1 frame (ApplyGroupAssignments) and keeps
    -- Tracker Type labels Icon/Bar rather than pluralizing to Icons/Bars.
    singleActive = true,
    -- Bundled voice clip (Media\Audio\Voice_Spatial.ogg); no per-spell name clips.
    hasVoiceClips = false,

    voiceClip = "Interface\\AddOns\\BuzzardAuras\\Media\\Audio\\Voice_Spatial.ogg",

    -- Group-level voice callout (Time Spiral pattern): a Sound element in
    -- "Voice" mode plays this fixed clip on every tracked ID. A single option
    -- (no user choice) whose `file` maps to Media\Audio\Voice_Spatial.ogg — this is
    -- what makes the spellList sound path resolve to the fixed clip rather than
    -- looking for per-spell name clips (which this tracker has none of).
    voiceOptions = {
        { value = "Spatial", name = "Spatial Paradox", file = "Spatial" },
    },

    frameSuffix  = "SpatialParadox",
    label        = "Spatial Paradox",
    defaultPos   = { "CENTER", "CENTER", 0, 0 },

    -- 12.1 preset (see Innervate for the sparse-table rationale).
    -- Circle #E6BF1A @ 85%.
    preset = {
        { style = "circle", circleRadius = 60, ringTexture = "Ring_20px",
          color = { 0.901961, 0.749020, 0.101961, 0.85 } },
        { style = "sound", soundType = "voice", soundChannel = "Master" },
    },

    defaults = {
        enabled        = true,
        barCircleColor = { 0.9, 0.75, 0.1, 1.0 },
        spells         = defaultSpells,
    },

    -- Applicable on every spec — the aura filter simply never matches if the
    -- buff can't land on you. (The old "Enable for DPS Evoker" opt-out was
    -- removed on 12.1; Conditions → Spec covers that if a user wants it.)
})

ns.DISPLAY_ICON_SPELL = DISPLAY_ICON_SPELL
