local k=game:GetService("\083\101\114\118\101\114\083\116\111\114\097\103\101")local t={__type="\067\111\110\102\105\103\077\097\110\097\103\101\114";Loaded=false;ConfigValues={}}local Z={__index=t}function t._getConfigs(Z,t)local F=function(t)local Z=k:FindFirstChild(t)if Z~=nil then return require(Z)end end local D,J=pcall(F,t)if D then return J end return{}end function t.Init(Z,k,t)if t==nil then k=k or"\067\111\110\102\105\103\117\114\097\116\105\111\110\115"t=Z:_getConfigs(k)end for k,t in pairs(t)do Z.ConfigValues[k]=t end Z.Loaded=true return Z.Loaded end function t.GetConfigValueOrDefault(Z,k,t)if not Z.Loaded then Z:Init()end if Z.ConfigValues[k]~=nil then return Z.ConfigValues[k]elseif t~=nil then return t end return nil end function t.GetFeatureEnabled(t,k)if not t.Loaded then t:Init()end if t:GetConfigValueOrDefault("\070\101\097\116\117\114\101\070\108\097\103\115")~=nil then local Z=t:GetConfigValueOrDefault("\070\101\097\116\117\114\101\070\108\097\103\115")if Z[k]~=nil then return Z[k]end end return false end function t.new()local k=setmetatable({},Z)return k end return t
local ServerStorage = game:GetService("ServerStorage")

local moduleProto = {
    __type = "ConfigManager",
    Loaded = false,
    ConfigValues = {}
}

local configManagerMeta = { __index = moduleProto }

function moduleProto:_getConfigs(filename)
    local loadConfigFunc = function(configFilename)
        local foundConfigModule = ServerStorage:FindFirstChild(configFilename)
        if foundConfigModule ~= nil then
            return require(foundConfigModule)
        end
    end
    local success, loadConfigResult = pcall(loadConfigFunc, filename)

    if success then
        return loadConfigResult
    end
    return {}
end

function moduleProto:Init(configFilename, configTable)
    if configTable == nil then
        configFilename = configFilename or "Configurations"
        configTable = self:_getConfigs(configFilename)
    end
    for key, value in pairs(configTable) do
        self.ConfigValues[key] = value
    end
    self.Loaded = true
    return self.Loaded
end

function moduleProto:GetConfigValueOrDefault(configKey, defaultToReturn)
    if not self.Loaded then
        self:Init()
    end
    if self.ConfigValues[configKey] ~= nil then
        return self.ConfigValues[configKey]
    elseif defaultToReturn ~= nil then
        return defaultToReturn
    end
    return nil
end

function moduleProto:GetFeatureEnabled(featureKey)
    if not self.Loaded then
        self:Init()
    end
    if self:GetConfigValueOrDefault("FeatureFlags") ~= nil then
        local featureFlags = self:GetConfigValueOrDefault("FeatureFlags")

        if featureFlags[featureKey] ~= nil then
            return featureFlags[featureKey]
        end
    end
    return false
end

function moduleProto.new()
	local self = setmetatable({}, configManagerMeta)
	return self
end

return moduleProto