ImageButton.defaultProps={BackgroundTransparency=1;BorderSizePixel=0,Size=UDim2.new(1,0,1,0),Image=""}function ImageButton.render(r)local H=Support.CloneTable(r.props)local o=r.state if H.AspectRatio then local r=new("\085\073\065\115\112\101\099\116\082\097\116\105\111\067\111\110\115\116\114\097\105\110\116",{AspectRatio=H.AspectRatio})H[Roact.Children]=Support.Merge({AspectRatio=r},H[Roact.Children]or{})if H.DominantAxis=="\087\105\100\116\104"then H.SizeConstraint="\082\101\108\097\116\105\118\101\088\088"if typeof(H.Width)=="\085\068\105\109"then H.Height=UDim.new(H.Width.Scale/H.AspectRatio,0)else H.Size=UDim2.new(H.Size.X,UDim.new(H.Size.X.Scale/H.AspectRatio,0))end elseif H.DominantAxis=="\072\101\105\103\104\116"then H.SizeConstraint="\082\101\108\097\116\105\118\101\089\089"if typeof(H.Height)=="\085\068\105\109"then H.Width=UDim.new(H.Height.Scale*H.AspectRatio,0)else H.Size=UDim2.new(UDim.new(H.Size.Y.Scale*H.AspectRatio,0),H.Size.Y)end end end if H.Layout=="\076\105\115\116"then local o=new("\085\073\076\105\115\116\076\097\121\111\117\116",{FillDirection=H.LayoutDirection,Padding=H.LayoutPadding,HorizontalAlignment=H.HorizontalAlignment,VerticalAlignment=H.VerticalAlignment;SortOrder=H.SortOrder or"\076\097\121\111\117\116\079\114\100\101\114",[Roact.Ref]=function(H)r:UpdateContentSize(H)end,[Roact.Change.AbsoluteContentSize]=function(H)r:UpdateContentSize(H)end})H.Size=r:GetSize()H[Roact.Children]=Support.Merge({Layout=o},H[Roact.Children])end if type(H.ImageColor)=="\115\116\114\105\110\103"then local r,o,S=(H.ImageColor:lower()):match("\035\063\040\046\046\041\040\046\046\041\040\046\046\041")H.ImageColor3=Color3.fromRGB(tonumber(r,16),tonumber(o,16),tonumber(S,16))end H.AspectRatio=nil H.DominantAxis=nil H.Layout=nil H.LayoutDirection=nil H.LayoutPadding=nil H.HorizontalAlignment=nil H.VerticalAlignment=nil H.HorizontalPadding=nil H.VerticalPadding=nil H.SortOrder=nil H.Width=nil H.Height=nil H.ImageColor=nil return new("\073\109\097\103\101\066\117\116\116\111\110",H)end function ImageButton.GetSize(H,r)local o=H.props local S=o.Size=="\087\082\065\080\095\067\079\078\084\069\078\084"or o.Width=="\087\082\065\080\095\067\079\078\084\069\078\084"local d=o.Size=="\087\082\065\080\095\067\079\078\084\069\078\084"or o.Height=="\087\082\065\080\095\067\079\078\084\069\078\084"local R=S or d local h=UDim2.new(0,o.HorizontalPadding or 0,0,o.VerticalPadding or 0)return h+UDim2.new((r and S)and UDim.new(0,r.X)or typeof(o.Width)=="\085\068\105\109"and o.Width or o.Size.X,(r and d)and UDim.new(0,r.Y)or typeof(o.Height)=="\085\068\105\109"and o.Height or o.Size.Y)end function ImageButton.UpdateContentSize(H,r)if not(r and r.Parent)then return end r.Parent.Size=H:GetSize(r.AbsoluteContentSize)end return ImageButton
-- Set defaults
ImageButton.defaultProps = {
	BackgroundTransparency = 1,
	BorderSizePixel = 0,
	Size = UDim2.new(1, 0, 1, 0),
	Image = "",
}

function ImageButton:render()
	local props = Support.CloneTable(self.props)
	local state = self.state

	-- Include aspect ratio constraint if specified
	if props.AspectRatio then
		local Constraint = new("UIAspectRatioConstraint", {
			AspectRatio = props.AspectRatio,
		})

		-- Insert constraint into children
		props[Roact.Children] = Support.Merge({ AspectRatio = Constraint }, props[Roact.Children] or {})

		-- Base height off width using the aspect ratio
		if props.DominantAxis == "Width" then
			props.SizeConstraint = "RelativeXX"
			if typeof(props.Width) == "UDim" then
				props.Height = UDim.new(props.Width.Scale / props.AspectRatio, 0)
			else
				props.Size = UDim2.new(props.Size.X, UDim.new(props.Size.X.Scale / props.AspectRatio, 0))
			end

		-- Base width off height using the aspect ratio
		elseif props.DominantAxis == "Height" then
			props.SizeConstraint = "RelativeYY"
			if typeof(props.Height) == "UDim" then
				props.Width = UDim.new(props.Height.Scale * props.AspectRatio, 0)
			else
				props.Size = UDim2.new(UDim.new(props.Size.Y.Scale * props.AspectRatio, 0), props.Size.Y)
			end
		end
	end

	-- Include list layout if specified
	if props.Layout == "List" then
		local Layout = new("UIListLayout", {
			FillDirection = props.LayoutDirection,
			Padding = props.LayoutPadding,
			HorizontalAlignment = props.HorizontalAlignment,
			VerticalAlignment = props.VerticalAlignment,
			SortOrder = props.SortOrder or "LayoutOrder",
			[Roact.Ref] = function(rbx)
				self:UpdateContentSize(rbx)
			end,
			[Roact.Change.AbsoluteContentSize] = function(rbx)
				self:UpdateContentSize(rbx)
			end,
		})

		-- Update size
		props.Size = self:GetSize()

		-- Insert layout into children
		props[Roact.Children] = Support.Merge({ Layout = Layout }, props[Roact.Children])
	end

	-- Parse hex colors
	if type(props.ImageColor) == "string" then
		local R, G, B = props.ImageColor:lower():match("#?(..)(..)(..)")
		props.ImageColor3 = Color3.fromRGB(tonumber(R, 16), tonumber(G, 16), tonumber(B, 16))
	end

	-- Filter out custom properties
	props.AspectRatio = nil
	props.DominantAxis = nil
	props.Layout = nil
	props.LayoutDirection = nil
	props.LayoutPadding = nil
	props.HorizontalAlignment = nil
	props.VerticalAlignment = nil
	props.HorizontalPadding = nil
	props.VerticalPadding = nil
	props.SortOrder = nil
	props.Width = nil
	props.Height = nil
	props.ImageColor = nil

	-- Display component in wrapper
	return new("ImageButton", props)
end

function ImageButton:GetSize(ContentSize)
	local props = self.props

	-- Determine dynamic dimensions
	local DynamicWidth = props.Size == "WRAP_CONTENT" or props.Width == "WRAP_CONTENT"
	local DynamicHeight = props.Size == "WRAP_CONTENT" or props.Height == "WRAP_CONTENT"
	local DynamicSize = DynamicWidth or DynamicHeight

	-- Get padding from props
	local Padding = UDim2.new(0, props.HorizontalPadding or 0, 0, props.VerticalPadding or 0)

	-- Calculate size based on content if dynamic
	return Padding
		+ UDim2.new(
			(ContentSize and DynamicWidth) and UDim.new(0, ContentSize.X)
				or (typeof(props.Width) == "UDim" and props.Width or props.Size.X),
			(ContentSize and DynamicHeight) and UDim.new(0, ContentSize.Y)
				or (typeof(props.Height) == "UDim" and props.Height or props.Size.Y)
		)
end

function ImageButton:UpdateContentSize(Layout)
	if not (Layout and Layout.Parent) then
		return
	end

	-- Set container size based on content
	Layout.Parent.Size = self:GetSize(Layout.AbsoluteContentSize)
end

return ImageButton
