--local Service = require(script.Parent)


local currentTestingService = nil

function this.new()
	if not currentTestingService then
		local self = {}--Service.new() -- change this to "local self = {}" Nvm I did it for you
		setmetatable(self,this)
		
		return self	
	end
	return currentTestingService -- return cached TestingService
end

function this:GetEnvironment()
	local Environment = "Release"
	if game:GetService("RunService"):IsStudio() then
		Environment = "Debug"
	end
	return Environment
end


function this:GetFlags()
	return script.Flags[self:GetEnvironment()]:GetChildren()
end

function this:GetEnabledFlags() -- returns flags that are turned on for the environment
	local EnabledFlags = {}
	for i,v in pairs(self:GetFlags()) do
		if v.Value == true then
			EnabledFlags[v.Name] = true -- For example -> if EnabledFlags["SecretFeature1"] then ...
		end
	end
	return EnabledFlags
end
	
function this:GetDisabledFlags() -- returns flags that are turned off for the environment
	local DisabledFlags = {}
	for i,v in pairs(self:GetFlags()) do
		if v.Value == false then
			DisabledFlags[v.Name] = true -- For example -> if DisabledFlags["SecretFeature1"] then ...
		end
	end
	return DisabledFlags
end
	
function this:IsFlagEnabled(FlagName) -- it's not exactly efficient and direct referencing
	-- would be faster, but we're trying to prevent errors here!
	-- FindFirstChild would be more efficient and scan quicker but it really doesn't make that much of a difference here
	-- I don't expect anybody to be calling this function frame by frame. Just cache the result ¯\_(ツ)_/¯
	local EnabledFlags = self:GetEnabledFlags()
	if EnabledFlags[FlagName] then
		return true
	end
	return false
end

return this
