local M=game:GetService("\084\101\120\116\083\101\114\118\105\099\101")local B=script.Parent.Parent local f=require(B.Packages.Flipper)local e=require(B.Creator)local D=e.New return function(B,f)f=f or false local A={}A.Input=D("\084\101\120\116\066\111\120",{FontFace=Font.new("\114\098\120\097\115\115\101\116\058\047\047\102\111\110\116\115\047\102\097\109\105\108\105\101\115\047\071\111\116\104\097\109\083\083\109\046\106\115\111\110");TextColor3=Color3.fromRGB(200,200,200);TextSize=14;TextXAlignment=Enum.TextXAlignment.Left,TextYAlignment=Enum.TextYAlignment.Center,BackgroundColor3=Color3.fromRGB(255,255,255);AutomaticSize=Enum.AutomaticSize.Y;BackgroundTransparency=1,Size=UDim2.fromScale(1,1);Position=UDim2.fromOffset(10,0);ThemeTag={TextColor3="\084\101\120\116",PlaceholderColor3="\083\117\098\084\101\120\116"}})A.Container=D("\070\114\097\109\101",{BackgroundTransparency=1;ClipsDescendants=true;Position=UDim2.new(0,6,0,0);Size=UDim2.new(1,-12,1,0)},{A.Input})A.Indicator=D("\070\114\097\109\101",{Size=UDim2.new(1,-4,0,1);Position=UDim2.new(0,2,1,0);AnchorPoint=Vector2.new(0,1);BackgroundTransparency=f and.5 or 0;ThemeTag={BackgroundColor3=f and"\073\110\112\117\116\073\110\100\105\099\097\116\111\114"or"\068\105\097\108\111\103\073\110\112\117\116\076\105\110\101"}})A.Frame=D("\070\114\097\109\101",{Size=UDim2.new(0,0,0,30),BackgroundTransparency=f and.9 or 0;Parent=B,ThemeTag={BackgroundColor3=f and"\073\110\112\117\116"or"\068\105\097\108\111\103\073\110\112\117\116"}},{D("\085\073\067\111\114\110\101\114",{CornerRadius=UDim.new(0,4)}),D("\085\073\083\116\114\111\107\101",{ApplyStrokeMode=Enum.ApplyStrokeMode.Border,Transparency=f and.5 or.65;ThemeTag={Color=f and"\073\110\069\108\101\109\101\110\116\066\111\114\100\101\114"or"\068\105\097\108\111\103\066\117\116\116\111\110\066\111\114\100\101\114"}});A.Indicator;A.Container})local function n()local B=2 local f=A.Container.AbsoluteSize.X if not A.Input:IsFocused()or A.Input.TextBounds.X<=f-2*B then A.Input.Position=UDim2.new(0,B,0,0)else local e=A.Input.CursorPosition if e~=-1 then local D=string.sub(A.Input.Text,1,e-1)local n=(M:GetTextSize(D,A.Input.TextSize,A.Input.Font,Vector2.new(math.huge,math.huge))).X local H=A.Input.Position.X.Offset+n if H<B then A.Input.Position=UDim2.fromOffset(B-n,0)elseif H>(f-B)-1 then A.Input.Position=UDim2.fromOffset(((f-n)-B)-1,0)end end end end task.spawn(n)e.AddSignal(A.Input:GetPropertyChangedSignal("\084\101\120\116"),n)e.AddSignal(A.Input:GetPropertyChangedSignal("\067\117\114\115\111\114\080\111\115\105\116\105\111\110"),n)e.AddSignal(A.Input.Focused,function()n()A.Indicator.Size=UDim2.new(1,-2,0,2)A.Indicator.Position=UDim2.new(0,1,1,0)A.Indicator.BackgroundTransparency=0 e.OverrideTag(A.Frame,{BackgroundColor3=f and"\073\110\112\117\116\070\111\099\117\115\101\100"or"\068\105\097\108\111\103\072\111\108\100\101\114"})e.OverrideTag(A.Indicator,{BackgroundColor3="\065\099\099\101\110\116"})end)e.AddSignal(A.Input.FocusLost,function()n()A.Indicator.Size=UDim2.new(1,-4,0,1)A.Indicator.Position=UDim2.new(0,2,1,0)A.Indicator.BackgroundTransparency=.5 e.OverrideTag(A.Frame,{BackgroundColor3=f and"\073\110\112\117\116"or"\068\105\097\108\111\103\073\110\112\117\116"})e.OverrideTag(A.Indicator,{BackgroundColor3=f and"\073\110\112\117\116\073\110\100\105\099\097\116\111\114"or"\068\105\097\108\111\103\073\110\112\117\116\076\105\110\101"})end)return A end
local TextService = game:GetService("TextService")
local Root = script.Parent.Parent
local Flipper = require(Root.Packages.Flipper)
local Creator = require(Root.Creator)
local New = Creator.New

return function(Parent, Acrylic)
	Acrylic = Acrylic or false
	local Textbox = {}

	Textbox.Input = New("TextBox", {
		FontFace = Font.new("rbxasset://fonts/families/GothamSSm.json"),
		TextColor3 = Color3.fromRGB(200, 200, 200),
		TextSize = 14,
		TextXAlignment = Enum.TextXAlignment.Left,
		TextYAlignment = Enum.TextYAlignment.Center,
		BackgroundColor3 = Color3.fromRGB(255, 255, 255),
		AutomaticSize = Enum.AutomaticSize.Y,
		BackgroundTransparency = 1,
		Size = UDim2.fromScale(1, 1),
		Position = UDim2.fromOffset(10, 0),
		ThemeTag = {
			TextColor3 = "Text",
			PlaceholderColor3 = "SubText",
		},
	})

	Textbox.Container = New("Frame", {
		BackgroundTransparency = 1,
		ClipsDescendants = true,
		Position = UDim2.new(0, 6, 0, 0),
		Size = UDim2.new(1, -12, 1, 0),
	}, {
		Textbox.Input,
	})

	Textbox.Indicator = New("Frame", {
		Size = UDim2.new(1, -4, 0, 1),
		Position = UDim2.new(0, 2, 1, 0),
		AnchorPoint = Vector2.new(0, 1),
		BackgroundTransparency = Acrylic and 0.5 or 0,
		ThemeTag = {
			BackgroundColor3 = Acrylic and "InputIndicator" or "DialogInputLine",
		},
	})

	Textbox.Frame = New("Frame", {
		Size = UDim2.new(0, 0, 0, 30),
		BackgroundTransparency = Acrylic and 0.9 or 0,
		Parent = Parent,
		ThemeTag = {
			BackgroundColor3 = Acrylic and "Input" or "DialogInput",
		},
	}, {
		New("UICorner", {
			CornerRadius = UDim.new(0, 4),
		}),
		New("UIStroke", {
			ApplyStrokeMode = Enum.ApplyStrokeMode.Border,
			Transparency = Acrylic and 0.5 or 0.65,
			ThemeTag = {
				Color = Acrylic and "InElementBorder" or "DialogButtonBorder",
			},
		}),
		Textbox.Indicator,
		Textbox.Container,
	})

	local function Update()
		local PADDING = 2
		local Reveal = Textbox.Container.AbsoluteSize.X

		if not Textbox.Input:IsFocused() or Textbox.Input.TextBounds.X <= Reveal - 2 * PADDING then
			Textbox.Input.Position = UDim2.new(0, PADDING, 0, 0)
		else
			local Cursor = Textbox.Input.CursorPosition
			if Cursor ~= -1 then
				local subtext = string.sub(Textbox.Input.Text, 1, Cursor - 1)
				local width = TextService:GetTextSize(
					subtext,
					Textbox.Input.TextSize,
					Textbox.Input.Font,
					Vector2.new(math.huge, math.huge)
				).X

				local CurrentCursorPos = Textbox.Input.Position.X.Offset + width
				if CurrentCursorPos < PADDING then
					Textbox.Input.Position = UDim2.fromOffset(PADDING - width, 0)
				elseif CurrentCursorPos > Reveal - PADDING - 1 then
					Textbox.Input.Position = UDim2.fromOffset(Reveal - width - PADDING - 1, 0)
				end
			end
		end
	end

	task.spawn(Update)

	Creator.AddSignal(Textbox.Input:GetPropertyChangedSignal("Text"), Update)
	Creator.AddSignal(Textbox.Input:GetPropertyChangedSignal("CursorPosition"), Update)

	Creator.AddSignal(Textbox.Input.Focused, function()
		Update()
		Textbox.Indicator.Size = UDim2.new(1, -2, 0, 2)
		Textbox.Indicator.Position = UDim2.new(0, 1, 1, 0)
		Textbox.Indicator.BackgroundTransparency = 0
		Creator.OverrideTag(Textbox.Frame, { BackgroundColor3 = Acrylic and "InputFocused" or "DialogHolder" })
		Creator.OverrideTag(Textbox.Indicator, { BackgroundColor3 = "Accent" })
	end)

	Creator.AddSignal(Textbox.Input.FocusLost, function()
		Update()
		Textbox.Indicator.Size = UDim2.new(1, -4, 0, 1)
		Textbox.Indicator.Position = UDim2.new(0, 2, 1, 0)
		Textbox.Indicator.BackgroundTransparency = 0.5
		Creator.OverrideTag(Textbox.Frame, { BackgroundColor3 = Acrylic and "Input" or "DialogInput" })
		Creator.OverrideTag(Textbox.Indicator, { BackgroundColor3 = Acrylic and "InputIndicator" or "DialogInputLine" })
	end)

	return Textbox
end
