local h=game:GetService("\084\101\120\116\083\101\114\118\105\099\101")local z=script.Parent.Parent.Vendor local r=require(z.Roact)local k=require(z.StudioComponents)local P=require(script.Parent.Slider)local x=k.Label local w=k.TextInput local D=r.Component:extend("\083\099\097\108\101\083\108\105\100\101\114")D.defaultProps={Title="\083\099\097\108\101",onChanged=function() end}function D.init(h)h:setState({value=h.props.value or 0})h.updateValue=function(z)z=tonumber(z)if z==nil then return end if z>1 or z<0 then return end h:setState({value=z})h.props.onChanged(z)end end function D.render(z)local k=h:GetTextSize(z.props.Title,14,Enum.Font.SourceSans,Vector2.new(200,20))return r.createElement("\070\114\097\109\101",{BackgroundTransparency=1,Size=UDim2.new(1,0,0,30);Position=z.props.Position},{Layout=r.createElement("\085\073\076\105\115\116\076\097\121\111\117\116",{Padding=UDim.new(0,5),FillDirection=Enum.FillDirection.Horizontal,SortOrder=Enum.SortOrder.LayoutOrder}),Label=r.createElement(x,{Size=UDim2.fromOffset(k.X,20),LayoutOrder=0;Text=z.props.Title;TextXAlignment=Enum.TextXAlignment.Left;TextTruncate=Enum.TextTruncate.AtEnd}),InputHolder=r.createElement("\070\114\097\109\101",{Size=UDim2.new(0,40,0,24),LayoutOrder=1;BackgroundTransparency=1},{Input=r.createElement(w,{ClearTextOnFocus=false,PlaceholderText="\048";Text=z.state.value,OnChanged=z.updateValue})});Slider=r.createElement(P,{Size=UDim2.new(0,200,0,20);LayoutOrder=2;Min=0,Max=1,Value=z.state.value;OnChange=function(h)local r=100.0 h=math.floor(h*r+.5)/r z.updateValue(h)end})})end return D
local TextService = game:GetService("TextService")

local Vendor = script.Parent.Parent.Vendor

local Roact = require(Vendor.Roact)
local StudioComponents = require(Vendor.StudioComponents)

local Slider = require(script.Parent.Slider)
local Label = StudioComponents.Label
local TextInput = StudioComponents.TextInput

local ScaleSlider = Roact.Component:extend("ScaleSlider")

ScaleSlider.defaultProps = {
	Title = "Scale",
	onChanged = function() end
}

function ScaleSlider:init()
	self:setState({ value = self.props.value or 0 })

	self.updateValue = function(newValue)
		newValue = tonumber(newValue)

		if newValue == nil then
			return
		end

		if newValue > 1 or newValue < 0 then
			return
		end

		self:setState({ value = newValue })

		self.props.onChanged(newValue)
	end
end

function ScaleSlider:render()
	local labelSize = TextService:GetTextSize(self.props.Title, 14, Enum.Font.SourceSans, Vector2.new(200, 20))

	return Roact.createElement("Frame", {
		BackgroundTransparency = 1,
		Size = UDim2.new(1, 0, 0, 30),
		Position = self.props.Position
	}, {
		Layout = Roact.createElement("UIListLayout", {
			Padding = UDim.new(0, 5),
			FillDirection = Enum.FillDirection.Horizontal,
			SortOrder = Enum.SortOrder.LayoutOrder
		}),
		Label = Roact.createElement(Label, {
			Size = UDim2.fromOffset(labelSize.X, 20),
			LayoutOrder = 0,
			Text = self.props.Title,
			TextXAlignment = Enum.TextXAlignment.Left,
			TextTruncate = Enum.TextTruncate.AtEnd,
		}),
		InputHolder = Roact.createElement("Frame", {
			Size = UDim2.new(0, 40, 0, 24),
			LayoutOrder = 1,
			BackgroundTransparency = 1,
		}, {
			Input = Roact.createElement(TextInput, {
				ClearTextOnFocus = false,
				PlaceholderText = "0",
				Text = self.state.value,
				OnChanged = self.updateValue
			}),
		}),
		Slider = Roact.createElement(Slider, {
			Size = UDim2.new(0, 200, 0, 20),
			LayoutOrder = 2,
			Min = 0,
			Max = 1,
			Value = self.state.value,
			OnChange = function(value)
				local mult = 10^2
  				value = math.floor(value * mult + 0.5) / mult
				self.updateValue(value)
			end
		})
	})
end

return ScaleSlider