local z=(script:FindFirstAncestor("\067\109\100\114\065\100\100\105\116\105\111\110\115")).Packages local A=require(z.Roact)local Y=NumberSequence.new({NumberSequenceKeypoint.new(0,1),NumberSequenceKeypoint.new(.499,1),NumberSequenceKeypoint.new(.501,0),NumberSequenceKeypoint.new(1,0)})local m=A.PureComponent:extend("\082\097\100\105\097\108\080\114\111\103\114\101\115\115")m.defaultProps={Clockwise=true}function m.render(z)local m=z.props.ImageSize local W=z.props.Clockwise and z.props.Value:map(function(z)return(z-.5)*360 end)or angle:map(function(z)return-z*360 end)local a=z.props.Value:map(function(z)return z<.5 end)local H=z.props.Value:map(function(z)return z>.5 end)return A.createElement("\070\114\097\109\101",{Size=z.props.Size;Position=z.props.Position,AnchorPoint=z.props.AnchorPoint;Rotation=z.props.Rotation;BackgroundTransparency=1},{Left=A.createElement("\073\109\097\103\101\076\097\098\101\108",{Image=z.props.Image,ImageColor3=z.props.ImageColor3,ImageTransparency=z.props.ImageTransparency,ImageRectSize=Vector2.new(m.X/2,m.Y);Size=UDim2.new(.5,0,1,0);BackgroundTransparency=1,Visible=not z.props.Clockwise or H},{Gradient=A.createElement("\085\073\071\114\097\100\105\101\110\116",{Offset=Vector2.new(.5,0),Transparency=Y,Enabled=z.props.Clockwise and true or a,Rotation=W})}),Right=A.createElement("\073\109\097\103\101\076\097\098\101\108",{Image=z.props.Image;ImageColor3=z.props.ImageColor3,ImageTransparency=z.props.ImageTransparency,ImageRectSize=Vector2.new(m.X/2,m.Y);ImageRectOffset=Vector2.new(m.X/2,0);Size=UDim2.new(.5,0,1,0),Position=UDim2.new(.5,0,0,0),BackgroundTransparency=1,Visible=z.props.Clockwise or H},{Gradient=A.createElement("\085\073\071\114\097\100\105\101\110\116",{Offset=Vector2.new(-0.5,0);Transparency=Y,Enabled=z.props.Clockwise and a or true;Rotation=W})})})end return m
local Packages = script:FindFirstAncestor("CmdrAdditions").Packages

local Roact = require(Packages.Roact)

local TRANSPARENCY_SEQUENCE = NumberSequence.new({
	NumberSequenceKeypoint.new(0, 1),
	NumberSequenceKeypoint.new(0.5 - 0.001, 1),
	NumberSequenceKeypoint.new(0.5 + 0.001, 0),
	NumberSequenceKeypoint.new(1, 0)
})

local RadialProgress = Roact.PureComponent:extend("RadialProgress")

RadialProgress.defaultProps = {
	Clockwise = true
}

function RadialProgress:render()
	local imageSize = self.props.ImageSize

	local gradientRotation = self.props.Clockwise and self.props.Value:map(function(value)
		return (value - 0.5) * 360
	end) or angle:map(function(value)
		return -value * 360
	end)

	local isUnderHalf = self.props.Value:map(function(value) return value < 0.5 end)
	local isOverHalf = self.props.Value:map(function(value) return value > 0.5 end)

	return Roact.createElement("Frame", {
		Size = self.props.Size,
		Position = self.props.Position,
		AnchorPoint = self.props.AnchorPoint,
		Rotation = self.props.Rotation,

		BackgroundTransparency = 1
	}, {
		Left = Roact.createElement("ImageLabel", {
			Image = self.props.Image,
			ImageColor3 = self.props.ImageColor3,
			ImageTransparency = self.props.ImageTransparency,
			ImageRectSize = Vector2.new(imageSize.X / 2, imageSize.Y),

			Size = UDim2.new(0.5, 0, 1, 0),
			
			BackgroundTransparency = 1,

			Visible = not self.props.Clockwise or isOverHalf
		}, {
			Gradient = Roact.createElement("UIGradient", {
				Offset = Vector2.new(0.5, 0),
				Transparency = TRANSPARENCY_SEQUENCE,
				-- The image itself will not be visible if under half, so we can just keep this enabled
				Enabled = self.props.Clockwise and true or isUnderHalf,
				Rotation = gradientRotation
			})
		}),

		Right = Roact.createElement("ImageLabel", {
			Image = self.props.Image,
			ImageColor3 = self.props.ImageColor3,
			ImageTransparency = self.props.ImageTransparency,
			ImageRectSize = Vector2.new(imageSize.X / 2, imageSize.Y),
			ImageRectOffset = Vector2.new(imageSize.X / 2, 0),

			Size = UDim2.new(0.5, 0, 1, 0),
			Position = UDim2.new(0.5, 0, 0, 0),
			
			BackgroundTransparency = 1,

			Visible = self.props.Clockwise or isOverHalf
		}, {
			Gradient = Roact.createElement("UIGradient", {
				Offset = Vector2.new(-0.5, 0),
				Transparency = TRANSPARENCY_SEQUENCE,
				Enabled = self.props.Clockwise and isUnderHalf or true,
				Rotation = gradientRotation
			})
		})
	})
end

return RadialProgress