local C=script.Parent.Parent.Parent.Parent local U=C.Parent local Z=require(C.Theme)local b=Z.WithTheme local p=Z.ApplyDescription local w=Z.RegisterStateAction local m=require(U.Sift)local O=require(U.t)local M=require(U.Roact)local r=M.createElement local W=script.Parent local V=require(W.Descriptions.TextInputDescriptions)local X="\115\116\121\108\101\115\047\065\110\105\109\097\116\105\111\110\083\112\114\105\110\103\080\097\114\097\109\115\047\067\111\110\116\114\111\108\047\073\110\112\117\116\047\066\117\116\116\111\110\047\067\111\108\111\114"local i="\115\116\121\108\101\115\047\065\110\105\109\097\116\105\111\110\083\112\114\105\110\103\080\097\114\097\109\115\047\067\111\110\116\114\111\108\047\073\110\112\117\116\047\066\117\116\116\111\110\047\084\114\097\110\115\112\097\114\101\110\099\121"local l=M.PureComponent:extend(script.Name)l.StyleBindings={"\066\117\116\116\111\110";"\072\105\103\104\108\105\103\104\116";"\083\116\114\111\107\101","\084\101\120\116"}l.defaultProps={Text=O.optional(O.string);Native=O.optional(O.table),[M.Children]=O.optional(O.table),[M.Event.Activated]=O.optional(O.callback);[M.Event.MouseButton1Down]=O.optional(O.callback),[M.Event.MouseButton1Up]=O.optional(O.callback),[M.Event.MouseEnter]=O.optional(O.callback),[M.Event.MouseLeave]=O.optional(O.callback)}l.validateProps=O.strictInterface({})function l.init(C)local U=C.props C.Text,C.SetText=M.createBinding(U.Text)for U,Z in pairs(C.StyleBindings)do C[Z],C["\083\101\116"..Z]=M.createBinding({})end w(C,M.Event.Activated,nil)w(C,M.Event.MouseButton1Down,"\080\114\101\115\115\101\100")w(C,M.Event.MouseButton1Up,"\072\111\118\101\114")w(C,M.Event.MouseEnter,"\072\111\118\101\114")w(C,M.Event.MouseLeave,"\082\101\115\116")C:setState({State="\082\101\115\116"})end function l.willUnmount(C)for U,Z in pairs(C.StyleBindings)do local b=C[Z.."\077\111\116\111\114"]if b then pcall(b.destroy,b)C[Z.."\077\111\116\111\114"]=nil end end end function l.ApplyDescription(Z,C,U)return p(Z,C,U,U[X],U[i])end function l.render(C)local U=C.props local Z=C.state return b(function(C)if Z.State=="\070\111\099\117\115\101\100"then end end)end return l
-- TextInput: A string input component, a textbox

local Winro = script.Parent.Parent.Parent.Parent
local Packages = Winro.Parent

local Theme = require(Winro.Theme)
local WithTheme = Theme.WithTheme
local ApplyDescription = Theme.ApplyDescription
local RegisterStateAction = Theme.RegisterStateAction

local Sift = require(Packages.Sift)
local t = require(Packages.t)
local Roact = require(Packages.Roact)
local new = Roact.createElement

local TextRoot = script.Parent
local Descriptions = require(TextRoot.Descriptions.TextInputDescriptions)

local TEXTINPUT_COLOR_ANIMATION_SPRING_SETTINGS = "styles/AnimationSpringParams/Control/Input/Button/Color"
local TEXTINPUT_TRANSPARENCY_ANIMATION_SPRING_SETTINGS = "styles/AnimationSpringParams/Control/Input/Button/Transparency"

local TextInput = Roact.PureComponent:extend(script.Name)

TextInput.StyleBindings = {
	'Button',
	'Highlight',
	'Stroke',
	'Text',
}

TextInput.defaultProps = {

	--- @prop @optional Text string Current text
	Text = t.optional(t.string),

	--- @prop @optional Native table The native props
	Native = t.optional(t.table),

	--- @prop @optional [Roact.Children] table Child contents
	[Roact.Children] = t.optional(t.table),

	--- @prop @optional [Roact.Event.Activated] function Roact.Event.Activated
	[Roact.Event.Activated] = t.optional(t.callback),

	--- @prop @optional [Roact.Event.MouseButton1Down] function Roact.Event.MouseButton1Down
	[Roact.Event.MouseButton1Down] = t.optional(t.callback),

	--- @prop @optional [Roact.Event.MouseButton1Up] function Roact.Event.MouseButton1Up
	[Roact.Event.MouseButton1Up] = t.optional(t.callback),

	--- @prop @optional [Roact.Event.MouseEnter] function Roact.Event.MouseEnter
	[Roact.Event.MouseEnter] = t.optional(t.callback),

	--- @prop @optional [Roact.Event.MouseLeave] function Roact.Event.MouseLeave
	[Roact.Event.MouseLeave] = t.optional(t.callback),
}

TextInput.validateProps = t.strictInterface({

})

function TextInput:init()
	local props = self.props

	-- Text value binding
	self.Text, self.SetText = Roact.createBinding(props.Text)

	-- Create Style Bindings
	for _, StyleBinding in pairs(self.StyleBindings) do
		self[StyleBinding], self['Set' .. StyleBinding] = Roact.createBinding({})
	end

	-- Actions
	RegisterStateAction(self, Roact.Event.Activated, nil)
	RegisterStateAction(self, Roact.Event.MouseButton1Down, 'Pressed')
	RegisterStateAction(self, Roact.Event.MouseButton1Up, 'Hover')
	RegisterStateAction(self, Roact.Event.MouseEnter, 'Hover')
	RegisterStateAction(self, Roact.Event.MouseLeave, 'Rest')

	-- Initial State
	self:setState({
		State = 'Rest',
	})
end

function TextInput:willUnmount()

	-- Clear motors for each style binding
	for _, StyleBinding in pairs(self.StyleBindings) do

		-- Look for a motor
		local Motor = self[StyleBinding .. 'Motor']

		-- Remove motor if found
		if Motor then
			pcall(Motor.destroy, Motor)
			self[StyleBinding .. 'Motor'] = nil
		end
	end
end

function TextInput:ApplyDescription(Description, Theme)
	return ApplyDescription(self, Description, Theme,  Theme[TEXTINPUT_COLOR_ANIMATION_SPRING_SETTINGS], Theme[TEXTINPUT_TRANSPARENCY_ANIMATION_SPRING_SETTINGS])
end

function TextInput:render()
	local props = self.props
	local state = self.state

	return WithTheme(function(Theme)
		
		-- Apply description
		if state.State == 'Focused' then
			
		end
	end)
end

return TextInput
