local NS = rawget(_G, "MCDVoiceCooldownNS") or {}
_G.MCDVoiceCooldownNS = NS

NS.Core = NS.Core or {}
NS.Core.NotifierBridge = NS.Core.NotifierBridge or {}

local Bridge = NS.Core.NotifierBridge

local function GetNotifier()
    return (NS.Core and NS.Core.Notifier) or NS.Notifier
end

function Bridge:GetNotifier()
    return GetNotifier()
end

function Bridge:NormalizeSoundPath(path)
    local notifier = GetNotifier()
    if notifier and type(notifier.NormalizeSoundPath) == "function" then
        return notifier:NormalizeSoundPath(path)
    end
    local utils = NS.Utils or {}
    if utils.CanonicalPath then
        return utils.CanonicalPath(path)
    end
    return tostring(path or ""):gsub("/", "\\")
end

function Bridge:ResolveEntrySoundPath(entry)
    local notifier = GetNotifier()
    if notifier and type(notifier.ResolveEntrySoundPath) == "function" then
        return notifier:ResolveEntrySoundPath(entry)
    end
    return self:NormalizeSoundPath(type(entry) == "table" and entry.soundPath or entry)
end

function Bridge:PlayReadyNotification(cfg)
    local notifier = GetNotifier()
    if notifier and type(notifier.PlayReadyNotification) == "function" then
        return notifier:PlayReadyNotification(cfg)
    end
    return false
end

function Bridge:PlayCastSuccessNotification(cfg)
    local notifier = GetNotifier()
    if notifier and type(notifier.PlayCastSuccessNotification) == "function" then
        return notifier:PlayCastSuccessNotification(cfg)
    end
    return false
end
