-- LidPanels_Compat.lua
-- Centralized API wrappers for future expansion changes.

_G.LIDPANELS_Compat = _G.LIDPANELS_Compat or {}
local C = _G.LIDPANELS_Compat

function C.GetNumClasses()
  return GetNumClasses and GetNumClasses() or 0
end

function C.GetClassInfo(classID)
  if GetClassInfo then
    return GetClassInfo(classID)
  end
  return nil
end

function C.GetNumSpecializationsForClassID(classID)
  return GetNumSpecializationsForClassID and GetNumSpecializationsForClassID(classID) or 0
end

function C.GetSpecializationInfoForClassID(classID, specIndex)
  if GetSpecializationInfoForClassID then
    return GetSpecializationInfoForClassID(classID, specIndex)
  end
  return nil
end

function C.GetNumSpecializations()
  return GetNumSpecializations and GetNumSpecializations() or 0
end

function C.GetSpecializationInfo(index)
  if GetSpecializationInfo then
    return GetSpecializationInfo(index)
  end
  return nil
end

function C.GetSpecializationInfoByID(specID)
  if GetSpecializationInfoByID then
    return GetSpecializationInfoByID(specID)
  end
  return nil
end

function C.GetCharacterList()
  local fn = _G.LIDPANELS_GetCharacterList
  if fn then
    return fn()
  end
  return {}
end

function C.GetCharacterKey()
  local fn = _G.LIDPANELS_GetCharacterKey
  if fn then
    return fn()
  end
  return nil
end

function C.After(delay, fn)
  if C_Timer and C_Timer.After then
    C_Timer.After(delay, fn)
    return
  end
  if not fn then return end
  local t = 0
  local f = CreateFrame("Frame")
  f:SetScript("OnUpdate", function(self, elapsed)
    t = t + elapsed
    if t >= delay then
      self:SetScript("OnUpdate", nil)
      self:Hide()
      fn()
    end
  end)
end
