local z=import("\046\046\047\097\115\115\105\103\110")local r=import("\046\046\047\116\121\112\101\075\101\121")local f={}setmetatable(f,{__tostring=function()return"\085\068\105\109"end})local H={}local w={}w[r]="\085\068\105\109"function w.__index(r,z)local f=(getmetatable(r)).internal if f[z]~=nil then return f[z]end if H[z]~=nil then return H[z]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(z)),2)end function w.__add(r,z)return f.new(r.Scale+z.Scale,r.Offset+z.Offset)end function w.__eq(r,z)return r.Scale==z.Scale and r.Offset==z.Offset end function f.new(...)if select("\035",...)==0 then return f.new(0,0)end local r,H=...if type(r)~="\110\117\109\098\101\114"or type(H)~="\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 q={Scale=r;Offset=H}local k=newproxy(true)z(getmetatable(k),w);(getmetatable(k)).internal=q return k end return f
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
