function Util.ParsePrefixedUnionType(o,M)local U=Util.SplitStringSimple(o)local k={}for o=1,#U,2 do k[#k+1]={prefix=U[o-1]or"";type=U[o]}end table.sort(k,function(o,M)return#o.prefix>#M.prefix end)for o=1,#k,1 do local U=k[o]if M:sub(1,#U.prefix)==U.prefix then return U.type,M:sub(#U.prefix+1),U.prefix end end end
--- Parses a prefixed union type argument (such as %Team)
function Util.ParsePrefixedUnionType(typeValue, rawValue)
	local split = Util.SplitStringSimple(typeValue)

	-- Check prefixes in order from longest to shortest
	local types = {}
	for i = 1, #split, 2 do
		types[#types + 1] = {
			prefix = split[i - 1] or "",
			type = split[i],
		}
	end

	table.sort(types, function(a, b)
		return #a.prefix > #b.prefix
	end)

	for i = 1, #types do
		local t = types[i]

		if rawValue:sub(1, #t.prefix) == t.prefix then
			return t.type, rawValue:sub(#t.prefix + 1), t.prefix
		end
	end
end
