local C=require(script.Parent.Parent.Shared.Util)local O={Validate=function(C)return C~=nil end;Parse=function(C)return tostring(C)end}local V={Transform=function(C)return tonumber(C)end;Validate=function(C)return C~=nil end;Parse=function(C)return C end}local L={Transform=function(C)return tonumber(C)end,Validate=function(C)return C~=nil and C==math.floor(C),"\079\110\108\121 \119\104\111\108\101 \110\117\109\098\101\114\115 \097\114\101 \118\097\108\105\100\046"end,Parse=function(C)return C end}local j={Transform=function(C)return tonumber(C)end,Validate=function(C)return C~=nil and(C==math.floor(C)and C>0),"\079\110\108\121 \112\111\115\105\116\105\118\101 \119\104\111\108\101 \110\117\109\098\101\114\115 \097\114\101 \118\097\108\105\100\046"end,Parse=function(C)return C end}local W={Transform=function(C)return tonumber(C)end;Validate=function(C)return C~=nil and(C==math.floor(C)and C>=0),"\079\110\108\121 \110\111\110-\110\101\103\097\116\105\118\101 \119\104\111\108\101 \110\117\109\098\101\114\115 \097\114\101 \118\097\108\105\100\046"end;Parse=function(C)return C end}local y={Transform=function(C)return tonumber(C)end,Validate=function(C)return C~=nil and(C==math.floor(C)and(C>=0 and C<=255)),"\079\110\108\121 \098\121\116\101\115 \097\114\101 \118\097\108\105\100\046"end;Parse=function(C)return C end}local I={Transform=function(C)return tonumber(C)end,Validate=function(C)return C~=nil and(C==math.floor(C)and(C>=0 and C<=9)),"\079\110\108\121 \100\105\103\105\116\115 \097\114\101 \118\097\108\105\100\046"end;Parse=function(C)return C end}local U do local O=C.MakeDictionary({"\116\114\117\101","\116","\121\101\115";"\121";"\111\110";"\101\110\097\098\108\101";"\101\110\097\098\108\101\100","\049","\043"})local V=C.MakeDictionary({"\102\097\108\115\101";"\102","\110\111";"\110","\111\102\102","\100\105\115\097\098\108\101";"\100\105\115\097\098\108\101\100","\048","-"})U={Transform=function(C)return C:lower()end,Validate=function(C)return O[C]~=nil or V[C]~=nil,"\080\108\101\097\115\101 \117\115\101 \116\114\117\101\047\121\101\115\047\111\110 \111\114 \102\097\108\115\101\047\110\111\047\111\102\102\046"end;Parse=function(C)if O[C]then return true elseif V[C]then return false else return nil end end}end return function(f)f:RegisterType("\115\116\114\105\110\103",O)f:RegisterType("\110\117\109\098\101\114",V)f:RegisterType("\105\110\116\101\103\101\114",L)f:RegisterType("\112\111\115\105\116\105\118\101\073\110\116\101\103\101\114",j)f:RegisterType("\110\111\110\078\101\103\097\116\105\118\101\073\110\116\101\103\101\114",W)f:RegisterType("\098\121\116\101",y)f:RegisterType("\100\105\103\105\116",I)f:RegisterType("\098\111\111\108\101\097\110",U)f:RegisterType("\115\116\114\105\110\103\115",C.MakeListableType(O))f:RegisterType("\110\117\109\098\101\114\115",C.MakeListableType(V))f:RegisterType("\105\110\116\101\103\101\114\115",C.MakeListableType(L))f:RegisterType("\112\111\115\105\116\105\118\101\073\110\116\101\103\101\114\115",C.MakeListableType(j))f:RegisterType("\110\111\110\078\101\103\097\116\105\118\101\073\110\116\101\103\101\114\115",C.MakeListableType(W))f:RegisterType("\098\121\116\101\115",C.MakeListableType(y))f:RegisterType("\100\105\103\105\116\115",C.MakeListableType(I))f:RegisterType("\098\111\111\108\101\097\110\115",C.MakeListableType(U))end
local Util = require(script.Parent.Parent.Shared.Util)

local stringType = {
	Validate = function (value)
		return value ~= nil
	end;

	Parse = function (value)
		return tostring(value)
	end;
}

local numberType = {
	Transform = function (text)
		return tonumber(text)
	end;

	Validate = function (value)
		return value ~= nil
	end;

	Parse = function (value)
		return value
	end;
}

local intType = {
	Transform = function (text)
		return tonumber(text)
	end;

	Validate = function (value)
		return value ~= nil and value == math.floor(value), "Only whole numbers are valid."
	end;

	Parse = function (value)
		return value
	end
}

local positiveIntType = {
	Transform = function (text)
		return tonumber(text)
	end,

	Validate = function (value)
		return value ~= nil and value == math.floor(value) and value > 0, "Only positive whole numbers are valid."
	end,

	Parse = function (value)
		return value
	end,
}

local nonNegativeIntType = {
	Transform = function (text)
		return tonumber(text)
	end,

	Validate = function (value)
		return value ~= nil and value == math.floor(value) and value >= 0, "Only non-negative whole numbers are valid."
	end,

	Parse = function (value)
		return value
	end,
}

local byteType = {
	Transform = function (text)
		return tonumber(text)
	end,

	Validate = function (value)
		return value ~= nil and value == math.floor(value) and value >= 0 and value <= 255, "Only bytes are valid."
	end,

	Parse = function (value)
		return value
	end,
}

local digitType = {
	Transform = function (text)
		return tonumber(text)
	end,

	Validate = function (value)
		return value ~= nil and value == math.floor(value) and value >= 0 and value <= 9, "Only digits are valid."
	end,

	Parse = function (value)
		return value
	end,
}

local boolType do
	local truthy = Util.MakeDictionary({"true", "t", "yes", "y", "on", "enable", "enabled", "1", "+"});
	local falsy = Util.MakeDictionary({"false"; "f"; "no"; "n"; "off"; "disable"; "disabled"; "0"; "-"});

	boolType = {
		Transform = function (text)
			return text:lower()
		end;

		Validate = function (value)
			return truthy[value] ~= nil or falsy[value] ~= nil, "Please use true/yes/on or false/no/off."
		end;

		Parse = function (value)
			if truthy[value] then
				return true
			elseif falsy[value] then
				return false
			else
				return nil
			end
		end;
	}
end

return function (cmdr)
	cmdr:RegisterType("string", stringType)
	cmdr:RegisterType("number", numberType)
	cmdr:RegisterType("integer", intType)
	cmdr:RegisterType("positiveInteger", positiveIntType)
	cmdr:RegisterType("nonNegativeInteger", nonNegativeIntType)
	cmdr:RegisterType("byte", byteType)
	cmdr:RegisterType("digit", digitType)
	cmdr:RegisterType("boolean", boolType)

	cmdr:RegisterType("strings", Util.MakeListableType(stringType))
	cmdr:RegisterType("numbers", Util.MakeListableType(numberType))
	cmdr:RegisterType("integers", Util.MakeListableType(intType))
	cmdr:RegisterType("positiveIntegers", Util.MakeListableType(positiveIntType))
	cmdr:RegisterType("nonNegativeIntegers", Util.MakeListableType(nonNegativeIntType))
	cmdr:RegisterType("bytes", Util.MakeListableType(byteType))
	cmdr:RegisterType("digits", Util.MakeListableType(digitType))
	cmdr:RegisterType("booleans", Util.MakeListableType(boolType))
end
