local D=Enum local o=(require(script.Enum)).new local m=newproxy(true)local c=getmetatable(m)local f={}local R={}function f.new(D,m)local c=o(D,m)R[D]=c return c end function f.GetStandardEnums(o)return D end function f.FromValue(m,D,o)for D,m in ipairs(m[D]:GetEnumItems())do if m.Value==o then return m end end end function f.Find(m,o)local c,f=pcall(function()return R[o]or D[o]end)if c then return f end return nil end c.__metatable="\084\104\101 \109\101\116\097\116\097\098\108\101 \105\115 \108\111\099\107\101\100"c.__tostring=function()return"\069\110\117\109\115"end function c.__index(o,m)return f[m]or R[m]or D[m]end function c.__newindex(D,o)error(o.." \099\097\110\110\111\116 \098\101 \097\115\115\105\103\110\101\100 \116\111",2)end return m
local RBX_ENUM = Enum

local newEnum = require(script.Enum).new

--[=[
    @class Enums
    Entry-point for the Enum library.
]=]
local Enums = newproxy(true)
local meta = getmetatable(Enums)
local methods = {}
local enums = {}

--[=[
    @within Enums
    @return Enum
    Creates a new Enum. Overwrites existing Enums including Roblox Enums.
]=]
function methods.new(enumName, enumItemsList)
    -- If an enum with the same name is used it is overwritten
    local enum = newEnum(enumName, enumItemsList)
    enums[enumName] = enum
    return enum
end

--[=[
    @within Enums
    @return Enum
    Returns the standard Roblox Enum table defined globally. This is useful for
    when this library is imported under the name `Enum`.
]=]
function methods:GetStandardEnums()
    return RBX_ENUM
end

--[=[
    @within Enums
    @param enumName string -- The name of the Enum.
    @param enumValue any -- The value of the EnumItem.
    @return EnumItem
    Given an Enum's name and the EnumItem's value, returns the EnumItem.
]=]
function methods:FromValue(enumName, enumValue)
    for _,enumItem in ipairs(self[enumName]:GetEnumItems()) do
        if enumItem.Value == enumValue then
            return enumItem
        end
    end
end

--[=[
    @within Enums
    @param enumName string -- The name of the Enum.
    @return Enum
    Safe way of checking if an Enum exists and returns it if it does.
]=]
function methods:Find(enumName)
    local success, enum = pcall(function()
        return enums[enumName] or RBX_ENUM[enumName]
    end)

    if success then
        return enum
    end

    return nil
end

meta.__metatable = "The metatable is locked"
meta.__tostring = function()
    return "Enums"
end

function meta.__index(_, enumName)
    return methods[enumName] or enums[enumName] or RBX_ENUM[enumName]
end

function meta.__newindex(_, i)
    error(i.. " cannot be assigned to", 2)
end

return Enums