local f=import("\046\046\047\097\115\115\105\103\110")local O=import("\046\046\047\116\121\112\101\075\101\121")local d={}setmetatable(d,{__tostring=function()return"\085\068\105\109"end})local r={}local b={}b[O]="\085\068\105\109"function b.__index(O,f)local d=(getmetatable(O)).internal if d[f]~=nil then return d[f]end if r[f]~=nil then return r[f]end error(string.format("\037\115 \105\115 \110\111\116 \097 \118\097\108\105\100 \109\101\109\098\101\114 \111\102 \085\068\105\109",tostring(f)),2)end function b.__add(O,f)return d.new(O.Scale+f.Scale,O.Offset+f.Offset)end function b.__eq(O,f)return O.Scale==f.Scale and O.Offset==f.Offset end function d.new(...)if select("\035",...)==0 then return d.new(0,0)end local O,r=...if type(O)~="\110\117\109\098\101\114"or type(r)~="\110\117\109\098\101\114"then error("\085\068\105\109\046\110\101\119 \109\117\115\116 \116\097\107\101 \105\110 \050 \110\117\109\098\101\114\115",2)end local m={Scale=O;Offset=r}local Q=newproxy(true)f(getmetatable(Q),b);(getmetatable(Q)).internal=m return Q end return d
local assign = import("../assign")
local typeKey = import("../typeKey")

local UDim = {}

setmetatable(UDim, {
	__tostring = function()
		return "UDim"
	end,
})

local prototype = {}

local metatable = {}
metatable[typeKey] = "UDim"

function metatable:__index(key)
	local internal = getmetatable(self).internal

	if internal[key] ~= nil then
		return internal[key]
	end

	if prototype[key] ~= nil then
		return prototype[key]
	end

	error(string.format("%s is not a valid member of UDim", tostring(key)), 2)
end

function metatable:__add(other)
	return UDim.new(self.Scale + other.Scale, self.Offset + other.Offset)
end

function metatable:__eq(other)
	return self.Scale == other.Scale and self.Offset == other.Offset
end

function UDim.new(...)
	if select("#", ...) == 0 then
		return UDim.new(0, 0)
	end

	local Scale, Offset = ...
	if type(Scale) ~= "number" or type(Offset) ~= "number" then
		error("UDim.new must take in 2 numbers", 2)
	end

	local internalInstance = {
		Scale = Scale,
		Offset = Offset,
	}

	local instance = newproxy(true)

	assign(getmetatable(instance), metatable)
	getmetatable(instance).internal = internalInstance

	return instance
end

return UDim
