local SmartCast_Res=nil;
local tonumber=tonumber
local _

function HealBot_Init_retSmartCast_Res()
    return SmartCast_Res
end

function HealBot_InitGetSpellData(spell)

    if ( not spell ) then return end
    
   -- name, rank, icon, cost, isFunnel, powerType, castTime, minRange, maxRange 
    local _, _, _, HB_mana, _, _, msCast, _, _ = GetSpellInfo(spell)

    local hbCastTime=tonumber(msCast or 0);
    if hbCastTime>999 then hbCastTime=HealBot_Comm_round(hbCastTime/1000,2) end
    HealBot_Spells[spell].CastTime=hbCastTime;
    if HB_mana then
        HealBot_Spells[spell].Mana=tonumber(HB_mana);
    end
    HealBot_InitClearSpellNils(spell)
end

function HealBot_InitClearSpellNils(spell)
    if not HealBot_Spells[spell].CastTime then
        HealBot_Spells[spell].CastTime=0;
    end
    if not HealBot_Spells[spell].Mana then
        HealBot_Spells[spell].Mana=10*UnitLevel("player");
    end
end

function HealBot_FindSpellRangeCast(id)

    if ( not id ) then return; end

    local spell, _, _, HB_mana, _, _, msCast, _, _ = HealBot_GetSpellName(id);
    if spell==HEALBOT_HOLY_WORD_SERENITY then 
        id=HealBot_GetSpellId(HEALBOT_HOLY_WORD_CHASTISE)
        _, _, _, HB_mana, _, _, msCast, _, _ = HealBot_GetSpellName(id);
    end
    
    HealBot_Spells[spell]={}
    HealBot_InitClearSpellNils(spell)
    local hbCastTime=tonumber(msCast or 0);
    if hbCastTime>999 then hbCastTime=HealBot_Comm_round(hbCastTime/1000,2) end
    if ( not spell ) then return; end
    HealBot_Spells[spell].CastTime=hbCastTime;
    if not HB_mana then
        HealBot_Spells[spell].Mana=10*UnitLevel("player");
    else
        HealBot_Spells[spell].Mana=tonumber(HB_mana);
    end
end

function HealBot_Init_Spells_Defaults()
    local i = GetSpecialization()
    local sID = 0
    if i then
        sID = GetSpecializationInfo(i,false,false) 
    end
  if HealBot_Data["PCLASSTRIM"]==HealBot_Class_En[HEALBOT_PALADIN] then
-- PALADIN
    HealBot_Spells = {
    --    [HEALBOT_HOLY_LIGHT]                = {},
    };
    
    local _, talent = GetTalentRowSelectionInfo(1)
    if talent and talent==1 then
        HealBot_Spells[HEALBOT_SPEED_OF_LIGHT]          = {}
    end
    
    local _, talent = GetTalentRowSelectionInfo(3)
    if talent then
        if talent==8 then
            HealBot_Spells[HEALBOT_ETERNAL_FLAME]       = {}
        elseif talent==9 then
            HealBot_Spells[HEALBOT_SACRED_SHIELD]       = {}
        end
    end

    local _, talent = GetTalentRowSelectionInfo(4)
    if talent and talent==10 then
        HealBot_Spells[HEALBOT_HAND_OF_PURITY]          = {}
    end
    
    local _, talent = GetTalentRowSelectionInfo(6)
    if talent then
        if talent==16 then
            HealBot_Spells[HEALBOT_HOLY_PRISM]          = {}
        elseif talent==18 then
            HealBot_Spells[HEALBOT_EXECUTION_SENTENCE]  = {}
        end
    end

    if sID==65 then  -- Holy
    --    HealBot_Spells[HEALBOT_HOLY_LIGHT]              = {}
    elseif sID==66 then  -- Protection

    elseif sID==70 then  -- Retribution
        
    end
  end

  if HealBot_Data["PCLASSTRIM"]==HealBot_Class_En[HEALBOT_DRUID] then
-- DRUID
    HealBot_Spells = {
        [HEALBOT_REJUVENATION]          = {HoT=HEALBOT_REJUVENATION},
        [HEALBOT_REGROWTH]              = {HoT=HEALBOT_REGROWTH},
        [HEALBOT_LIFEBLOOM]             = {HoT=HEALBOT_LIFEBLOOM},
        [HEALBOT_WILD_GROWTH]           = {HoT=HEALBOT_WILD_GROWTH}, 
    };
    
    local _, talent = GetTalentRowSelectionInfo(2)
    if talent and talent==6 then
        HealBot_Spells[HEALBOT_CENARION_WARD]       = {CastTime = 0,   Mana = 148}
    end
    
    if sID==102 then  -- Balanced
    elseif sID==103 then  -- Feral
    elseif sID==104 then  -- Guardian
    elseif sID==105 then  -- Restoration
    end
    
  end

  if HealBot_Data["PCLASSTRIM"]==HealBot_Class_En[HEALBOT_PRIEST] then
-- PRIEST
    HealBot_Spells = {
        [HEALBOT_RENEW]                 = {HoT=HEALBOT_RENEW}, 
    };
    
    local _, talent = GetTalentRowSelectionInfo(4)
    if talent and talent==10 then
        HealBot_Spells[HEALBOT_DESPERATE_PRAYER]    = {CastTime = 0,   Mana =   7}
    end
    
    local _, talent = GetTalentRowSelectionInfo(6)
    if talent and talent==16 then
        HealBot_Spells[HEALBOT_CASCADE]             = {CastTime = 0,   Mana =   9}
    end
    
    if sID==256 then -- Disp

    elseif sID==257 then -- Holy
        HealBot_Spells[HEALBOT_HOLY_WORD_SERENITY]  = {id = 88684,  CastTime = 0,   Mana =   0}
    elseif sID==258 then -- Shadow

    end
    
  end

  if HealBot_Data["PCLASSTRIM"]==HealBot_Class_En[HEALBOT_SHAMAN] then
-- SHAMAN
    HealBot_Spells = {
        [HEALBOT_RIPTIDE]               = {HoT=HEALBOT_RIPTIDE},
    };
    
    if sID==262 then  -- Elemental
        
    elseif sID==263 then  -- Enhancement
    
    elseif sID==264 then  -- Restoration
          --HealBot_Spells[HEALBOT_HEALING_WAVE]            = {}
    end
  end

  if HealBot_Data["PCLASSTRIM"]==HealBot_Class_En[HEALBOT_MONK] then
--  Monk
        --HealBot_Spells[HEALBOT_DETOX] = {}

    if sID==268 then  -- Brewmaster
        
    elseif sID==269 then  -- Windwalker

    elseif sID==270 then  -- Mistweaver
        --HealBot_Spells[HEALBOT_LIFE_COCOON]     = {}
    end
  end

  if HealBot_Data["PCLASSTRIM"]==HealBot_Class_En[HEALBOT_HUNTER] then
--  Hunter
    HealBot_Spells = {
        [HEALBOT_MENDPET] = {}, 
    };
  end
  
  if HealBot_Data["PCLASSTRIM"]==HealBot_Class_En[HEALBOT_MAGE] then
--  Mage
    HealBot_Spells = {
        [HEALBOT_FROST_ARMOR] = {}, 
    };
  end

end


function HealBot_Init_SmartCast()
    if HealBot_Data["PCLASSTRIM"]=="PRIE" then
        SmartCast_Res=HEALBOT_RESURRECTION;
    elseif HealBot_Data["PCLASSTRIM"]=="DRUI" then
        SmartCast_Res=HEALBOT_REVIVE;
    elseif HealBot_Data["PCLASSTRIM"]=="MONK" then
        SmartCast_Res=HEALBOT_RESUSCITATE;
    elseif HealBot_Data["PCLASSTRIM"]=="PALA" then
        SmartCast_Res=HEALBOT_REDEMPTION;
    elseif HealBot_Data["PCLASSTRIM"]=="SHAM" then
        SmartCast_Res=HEALBOT_ANCESTRALSPIRIT;
    end
end
