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