local U=Vector2.new(math.huge,math.huge)function TextBox.getSize(Z)if not(Z.props.Width or Z.props.Height or Z.props.Size=="\087\082\065\080\095\067\079\078\084\069\078\084")then return Z.props.Size end local f,Q if typeof(Z.props.Width)=="\085\068\105\109"then f=Z.props.Width elseif typeof(Z.props.Height)=="\085\068\105\109"then Q=Z.props.Height end local K=Z.props.TextSize if Z.props.TextScaled and Z.AbsoluteSize then K=Z.AbsoluteSize.Y end local G=TextService:GetTextSize(Z.props.Text,K,Z.props.Font,U)if not f and(Z.props.Width=="\087\082\065\080\095\067\079\078\084\069\078\084"or Z.props.Size=="\087\082\065\080\095\067\079\078\084\069\078\084")then f=UDim.new(0,G.X)end if not Q and(Z.props.Height=="\087\082\065\080\095\067\079\078\084\069\078\084"or Z.props.Size=="\087\082\065\080\095\067\079\078\084\069\078\084")then Q=UDim.new(0,G.Y)end return UDim2.new(f or Z.props.Size and Z.props.Size.X or UDim.new(),Q or Z.props.Size and Z.props.Size.Y or UDim.new())end function TextBox.updateSize(U)local Z=U:getSize()local f=U.props.TextScaled and(U.AbsoluteSize and U.AbsoluteSize.Y)or U.props.TextSize if U.state.Size~=Z or U.state.TextSize~=f then U:setState({Size=Z;TextSize=f})end end function TextBox.init(U)U.Updating=true U.state={Size=UDim2.new(),TextSize=0}end function TextBox.willUpdate(f,U,Z)f.Updating=true end function TextBox.render(U)local Z=Support.Merge({},U.props,{Size=U.state.Size;TextSize=U.state.TextSize;TextScaled=false,[Roact.Ref]=function(Z)U.AbsoluteSize=Z and Z.AbsoluteSize or U.AbsoluteSize end;[Roact.Change.AbsoluteSize]=function(Z)U.AbsoluteSize=Z.AbsoluteSize if not U.Updating then U:updateSize()end end})if type(Z.TextColor)=="\115\116\114\105\110\103"then local U,f,Q=(Z.TextColor:lower()):match("\035\063\040\046\046\041\040\046\046\041\040\046\046\041")Z.TextColor3=Color3.fromRGB(tonumber(U,16),tonumber(f,16),tonumber(Q,16))end local f=Support.Merge({},U.props[Roact.Children])Z.Width=nil Z.Height=nil Z.Bold=nil Z.TextColor=nil Z[Roact.Children]=nil if U.props.Bold then local U=Support.CloneTable(Z)U.Size=UDim2.new(1,0,1,0)U.Position=nil U.TextScaled=true U.AnchorPoint=nil f.Bold=new(TextBox,U)end return new("\084\101\120\116\066\111\120",Z,f)end function TextBox.didMount(U)U.Updating=nil U:updateSize()end function TextBox.didUpdate(f,U,Z)f.Updating=nil f:updateSize()end return TextBox
-- Constants
local INFINITE_BOUNDS = Vector2.new(math.huge, math.huge)

function TextBox:getSize()
	-- Return size directly if fixed
	if not (self.props.Width or self.props.Height or self.props.Size == "WRAP_CONTENT") then
		return self.props.Size
	end

	-- Get fixed sizes for individual axes
	local Width, Height
	if typeof(self.props.Width) == "UDim" then
		Width = self.props.Width
	elseif typeof(self.props.Height) == "UDim" then
		Height = self.props.Height
	end

	-- Get text size from height if autoscaled
	local TextSize = self.props.TextSize
	if self.props.TextScaled and self.AbsoluteSize then
		TextSize = self.AbsoluteSize.Y
	end

	-- Calculate content bounds
	local Bounds = TextService:GetTextSize(self.props.Text, TextSize, self.props.Font, INFINITE_BOUNDS)

	-- Set width and height based on content if requested
	if not Width and (self.props.Width == "WRAP_CONTENT" or self.props.Size == "WRAP_CONTENT") then
		Width = UDim.new(0, Bounds.X)
	end
	if not Height and (self.props.Height == "WRAP_CONTENT" or self.props.Size == "WRAP_CONTENT") then
		Height = UDim.new(0, Bounds.Y)
	end

	-- Return the calculated size
	return UDim2.new(
		Width or (self.props.Size and self.props.Size.X) or UDim.new(),
		Height or (self.props.Size and self.props.Size.Y) or UDim.new()
	)
end

function TextBox:updateSize()
	-- Calculate new size
	local Size = self:getSize()
	local TextSize = self.props.TextScaled and (self.AbsoluteSize and self.AbsoluteSize.Y) or self.props.TextSize

	-- Check if state is outdated
	if self.state.Size ~= Size or self.state.TextSize ~= TextSize then
		-- Update state
		self:setState({
			Size = Size,
			TextSize = TextSize,
		})
	end
end

function TextBox:init()
	self.Updating = true
	self.state = {
		Size = UDim2.new(),
		TextSize = 0,
	}
end

function TextBox:willUpdate(nextProps, nextState)
	self.Updating = true
end

function TextBox:render()
	local props = Support.Merge({}, self.props, {

		-- Override size
		Size = self.state.Size,
		TextSize = self.state.TextSize,
		TextScaled = false,

		-- Get initial size
		[Roact.Ref] = function(rbx)
			self.AbsoluteSize = rbx and rbx.AbsoluteSize or self.AbsoluteSize
		end,

		-- Track size changes
		[Roact.Change.AbsoluteSize] = function(rbx)
			self.AbsoluteSize = rbx.AbsoluteSize
			if not self.Updating then
				self:updateSize()
			end
		end,
	})

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

	-- Separate children from props
	local children = Support.Merge({}, self.props[Roact.Children])

	-- Clear invalid props
	props.Width = nil
	props.Height = nil
	props.Bold = nil
	props.TextColor = nil
	props[Roact.Children] = nil

	-- Add a bold layer if specified
	if self.props.Bold then
		local BoldProps = Support.CloneTable(props)
		BoldProps.Size = UDim2.new(1, 0, 1, 0)
		BoldProps.Position = nil
		BoldProps.TextScaled = true
		BoldProps.AnchorPoint = nil
		children.Bold = new(TextBox, BoldProps)
	end

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

function TextBox:didMount()
	self.Updating = nil
	self:updateSize()
end

function TextBox:didUpdate(previousProps, previousState)
	self.Updating = nil
	self:updateSize()
end

return TextBox
