function Table.deepCopy(Z,w)w=w or{}if w[Z]then return w[Z]end if type(Z)=="\116\097\098\108\101"then local z={}w[Z]=z for Z,A in pairs(Z)do z[Table.deepCopy(Z,w)]=Table.deepCopy(A,w)end return setmetatable(z,Table.deepCopy(getmetatable(Z),w))else return Z end end
--[=[
	Deep copies a table including metatables

	@param target table -- Table to deep copy
	@param _context table? -- Cntext to deepCopy the value in
	@return table -- Result
]=]
function Table.deepCopy(target, _context)
	_context = _context or {}
	if _context[target] then
		return _context[target]
	end

	if type(target) == "table" then
		local new = {}
		_context[target] = new
		for index, value in pairs(target) do
			new[Table.deepCopy(index, _context)] = Table.deepCopy(value, _context)
		end
		return setmetatable(new, Table.deepCopy(getmetatable(target), _context))
	else
		return target
	end
end
