local R=script.Parent.Parent.Parent.utils local D=require(R.animate)local o=require(R.unwrap)local N=script.Parent.Parent.Parent.packages local G=require(N.fusion)local I=require(N.states)local m=script.Parent.Parent.Parent.storage local U=require(m.theme)local P=require(m.constants)local q=P._VERSION local u=P._BRANCH local B=G.Children local H=G.Observer local a=G.OnChange local E=G.OnEvent local V=G.Ref local J=G.Value local C=G.New return function()local R=J(UDim2.new(.5,0,0,100))local N=J()local G=J()local m=J(1)local P=H(I.CommandBarOpened)P:onChange(function()if o(I.CommandBarOpened)then m:set(1)R:set(UDim2.new(.5,0,0,130));(o(N)):CaptureFocus()end end)local T=(C("\067\097\110\118\097\115\071\114\111\117\112"))({[V]=G;Name="\067\111\109\109\097\110\100\066\097\114",GroupTransparency=D(function()return o(I.CommandBarOpened)and 0 or 1 end,30,1.2),AnchorPoint=Vector2.new(.5,.5);BackgroundColor3=U.bar_background,BorderColor3=Color3.fromRGB(0,0,0),BorderSizePixel=0,Position=D(function()return R:get()end,30,1.2);Size=UDim2.fromOffset(517,80),[B]={(C("\085\073\083\099\097\108\101"))({Scale=m});(C("\085\073\067\111\114\110\101\114"))({Name="\085\073\067\111\114\110\101\114",CornerRadius=UDim.new(0,10)});(C("\085\073\083\116\114\111\107\101"))({Name="\085\073\083\116\114\111\107\101";Color=U.bar_accent;Thickness=2,Transparency=1}),(C("\070\114\097\109\101"))({Name="\068\114\097\103",BackgroundColor3=U.bar_top,BorderColor3=Color3.fromRGB(0,0,0),BorderSizePixel=0;Size=UDim2.new(1,0,0,40),[B]={(C("\070\114\097\109\101"))({Name="\070\114\097\109\101";AnchorPoint=Vector2.new(0,1),BackgroundColor3=U.bar_accent,BorderColor3=Color3.fromRGB(0,0,0),BorderSizePixel=0,Position=UDim2.fromScale(0,1),Size=UDim2.new(1,0,0,1)}),(C("\084\101\120\116\076\097\098\101\108"))({Name="\084\101\120\116\076\097\098\101\108";FontFace=Font.new("\114\098\120\097\115\115\101\116\105\100\058\047\047\049\050\049\056\055\051\054\053\051\054\052",Enum.FontWeight.Bold,Enum.FontStyle.Normal);Text="\082\117\110",TextColor3=Color3.fromRGB(255,255,255),TextSize=15;TextXAlignment=Enum.TextXAlignment.Left;BackgroundColor3=Color3.fromRGB(255,255,255),BackgroundTransparency=1;BorderColor3=Color3.fromRGB(0,0,0);BorderSizePixel=0;Size=UDim2.new(1,0,0,40),ZIndex=3;[B]={(C("\085\073\080\097\100\100\105\110\103"))({Name="\085\073\080\097\100\100\105\110\103";PaddingLeft=UDim.new(0,15)})}}),(C("\084\101\120\116\076\097\098\101\108"))({Name="\084\101\120\116\076\097\098\101\108";FontFace=Font.new("\114\098\120\097\115\115\101\116\105\100\058\047\047\049\050\049\056\055\051\054\053\051\054\052",Enum.FontWeight.Medium,Enum.FontStyle.Normal);Text=q..("-"..u),TextColor3=Color3.fromRGB(223,223,223);TextSize=15,TextXAlignment=Enum.TextXAlignment.Right,BackgroundColor3=Color3.fromRGB(255,255,255),BackgroundTransparency=1,BorderColor3=Color3.fromRGB(0,0,0),BorderSizePixel=0;Size=UDim2.new(1,0,0,40);ZIndex=3;[B]={(C("\085\073\080\097\100\100\105\110\103"))({Name="\085\073\080\097\100\100\105\110\103";PaddingRight=UDim.new(0,15)})}})}});(C("\084\101\120\116\076\097\098\101\108"))({Name="\080\114\101\100\105\099\116\105\111\110";FontFace=Font.new("\114\098\120\097\115\115\101\116\105\100\058\047\047\049\050\049\056\055\051\054\053\051\054\052",Enum.FontWeight.Medium,Enum.FontStyle.Normal),LineHeight=1.1,Text=I.PredictionText;TextColor3=Color3.fromRGB(109,109,109),TextSize=15,TextXAlignment=Enum.TextXAlignment.Left,Active=true,AnchorPoint=Vector2.new(0,1);BackgroundColor3=Color3.fromRGB(255,255,255);BackgroundTransparency=1;BorderColor3=Color3.fromRGB(0,0,0);BorderSizePixel=0;Position=UDim2.fromScale(0,1);Selectable=true,Size=UDim2.new(1,0,1,-40),[B]={(C("\085\073\080\097\100\100\105\110\103"))({PaddingLeft=UDim.new(0,35)}),(C("\073\109\097\103\101\076\097\098\101\108"))({Name="\073\109\097\103\101",Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\052\051\056\055\050\049\049\048\048\050";AnchorPoint=Vector2.new(.5,.5);BackgroundColor3=Color3.fromRGB(255,255,255),BackgroundTransparency=1;BorderColor3=Color3.fromRGB(0,0,0);BorderSizePixel=0,Position=UDim2.new(0,-15,.5,0);Size=UDim2.fromOffset(16,16),Visible=false,ZIndex=7})}});(C("\084\101\120\116\066\111\120"))({[V]=N;Name="\073\110\112\117\116";CursorPosition=-1;FontFace=Font.new("\114\098\120\097\115\115\101\116\105\100\058\047\047\049\050\049\056\055\051\054\053\051\054\052",Enum.FontWeight.Medium,Enum.FontStyle.Normal);LineHeight=1.1,PlaceholderText="\069\110\116\101\114 \099\111\109\109\097\110\100 \111\114 \115\101\097\114\099\104 \104\101\114\101\046\046\046",PlaceholderColor3=Color3.fromRGB(119,119,119),Text="",TextColor3=Color3.fromRGB(211,211,211);TextSize=15;TextXAlignment=Enum.TextXAlignment.Left;AnchorPoint=Vector2.new(0,1);BackgroundColor3=Color3.fromRGB(255,255,255);BackgroundTransparency=1;BorderColor3=Color3.fromRGB(0,0,0),BorderSizePixel=0;Position=UDim2.fromScale(0,1);Size=UDim2.new(1,0,1,-40),[E("\070\111\099\117\115\076\111\115\116")]=function()I.ToExecute:set((o(N)).Text);(o(N)).Text=""I.CommandBarOpened:set(false)R:set(UDim2.new(.5,0,0,160))task.wait(.2)m:set(0)R:set(UDim2.new(.5,0,0,100))end;[a("\084\101\120\116")]=function()I.CommandBarText:set((o(N)).Text)end,[B]={(C("\085\073\080\097\100\100\105\110\103"))({Name="\085\073\080\097\100\100\105\110\103";PaddingLeft=UDim.new(0,35)});(C("\073\109\097\103\101\076\097\098\101\108"))({Name="\073\109\097\103\101";Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\052\051\056\055\050\049\049\048\048\050";AnchorPoint=Vector2.new(.5,.5),BackgroundColor3=Color3.fromRGB(255,255,255),BackgroundTransparency=1,BorderColor3=Color3.fromRGB(0,0,0),BorderSizePixel=0;Position=UDim2.new(0,-15,.5,0),Size=UDim2.fromOffset(16,16);ZIndex=7})}})}})return T end
--[[
	File: button.lua
	Creates a button in the window
]]

-- < Utils >
local Utils = script.Parent.Parent.Parent.utils
local animate = require(Utils.animate)
local unwrap = require(Utils.unwrap)

-- < Packages >
local Packages = script.Parent.Parent.Parent.packages
local Fusion = require(Packages.fusion)
local States = require(Packages.states)

-- < Storage >
local Storage = script.Parent.Parent.Parent.storage
local Theme = require(Storage.theme)

local Constants = require(Storage.constants)
local VERSION = Constants._VERSION
local BRANCH = Constants._BRANCH

-- < Variables >
local Children = Fusion.Children
local Observer = Fusion.Observer
local OnChange = Fusion.OnChange
local OnEvent = Fusion.OnEvent
local Ref = Fusion.Ref
local Value = Fusion.Value
local New = Fusion.New

-- < Component >
return function()
	local commandbarPos = Value(UDim2.new(0.5, 0, 0, 100))

	local textboxRef = Value()
	local commandbarRef = Value()
	local commandbarScale = Value(1)

	local openedStateObserver = Observer(States.CommandBarOpened)

	openedStateObserver:onChange(function()
		if unwrap(States.CommandBarOpened) then
			commandbarScale:set(1)
			commandbarPos:set(UDim2.new(0.5, 0, 0, 130))

			unwrap(textboxRef):CaptureFocus()
		end
	end)

	local CommandBar = New("CanvasGroup")({
		[Ref] = commandbarRef,

		Name = "CommandBar",
		GroupTransparency = animate(function()
			return unwrap(States.CommandBarOpened) and 0 or 1
		end, 30, 1.2),
		AnchorPoint = Vector2.new(0.5, 0.5),
		BackgroundColor3 = Theme.bar_background,
		BorderColor3 = Color3.fromRGB(0, 0, 0),
		BorderSizePixel = 0,
		Position = animate(function()
			return commandbarPos:get()
		end, 30, 1.2),
		Size = UDim2.fromOffset(517, 80),

		[Children] = {
			New("UIScale")({
				Scale = commandbarScale,
			}),

			New("UICorner")({
				Name = "UICorner",
				CornerRadius = UDim.new(0, 10),
			}),

			New("UIStroke")({
				Name = "UIStroke",
				Color = Theme.bar_accent,
				Thickness = 2,
				Transparency = 1,
			}),

			New("Frame")({
				Name = "Drag",
				BackgroundColor3 = Theme.bar_top,
				BorderColor3 = Color3.fromRGB(0, 0, 0),
				BorderSizePixel = 0,
				Size = UDim2.new(1, 0, 0, 40),

				[Children] = {
					New("Frame")({
						Name = "Frame",
						AnchorPoint = Vector2.new(0, 1),
						BackgroundColor3 = Theme.bar_accent,
						BorderColor3 = Color3.fromRGB(0, 0, 0),
						BorderSizePixel = 0,
						Position = UDim2.fromScale(0, 1),
						Size = UDim2.new(1, 0, 0, 1),
					}),

					New("TextLabel")({
						Name = "TextLabel",
						FontFace = Font.new("rbxassetid://12187365364", Enum.FontWeight.Bold, Enum.FontStyle.Normal),
						Text = "Run",
						TextColor3 = Color3.fromRGB(255, 255, 255),
						TextSize = 15,
						TextXAlignment = Enum.TextXAlignment.Left,
						BackgroundColor3 = Color3.fromRGB(255, 255, 255),
						BackgroundTransparency = 1,
						BorderColor3 = Color3.fromRGB(0, 0, 0),
						BorderSizePixel = 0,
						Size = UDim2.new(1, 0, 0, 40),
						ZIndex = 3,

						[Children] = {
							New("UIPadding")({
								Name = "UIPadding",
								PaddingLeft = UDim.new(0, 15),
							}),
						},
					}),

					New("TextLabel")({
						Name = "TextLabel",
						FontFace = Font.new("rbxassetid://12187365364", Enum.FontWeight.Medium, Enum.FontStyle.Normal),
						Text = VERSION .. "-" .. BRANCH,
						TextColor3 = Color3.fromRGB(223, 223, 223),
						TextSize = 15,
						TextXAlignment = Enum.TextXAlignment.Right,
						BackgroundColor3 = Color3.fromRGB(255, 255, 255),
						BackgroundTransparency = 1,
						BorderColor3 = Color3.fromRGB(0, 0, 0),
						BorderSizePixel = 0,
						Size = UDim2.new(1, 0, 0, 40),
						ZIndex = 3,

						[Children] = {
							New("UIPadding")({
								Name = "UIPadding",
								PaddingRight = UDim.new(0, 15),
							}),
						},
					}),
				},
			}),

			New("TextLabel")({
				Name = "Prediction",
				FontFace = Font.new("rbxassetid://12187365364", Enum.FontWeight.Medium, Enum.FontStyle.Normal),
				LineHeight = 1.1,
				Text = States.PredictionText,
				TextColor3 = Color3.fromRGB(109, 109, 109),
				TextSize = 15,
				TextXAlignment = Enum.TextXAlignment.Left,
				Active = true,
				AnchorPoint = Vector2.new(0, 1),
				BackgroundColor3 = Color3.fromRGB(255, 255, 255),
				BackgroundTransparency = 1,
				BorderColor3 = Color3.fromRGB(0, 0, 0),
				BorderSizePixel = 0,
				Position = UDim2.fromScale(0, 1),
				Selectable = true,
				Size = UDim2.new(1, 0, 1, -40),

				[Children] = {
					New("UIPadding")({
						PaddingLeft = UDim.new(0, 35),
					}),

					New("ImageLabel")({
						Name = "Image",
						Image = "rbxassetid://14387211002",
						AnchorPoint = Vector2.new(0.5, 0.5),
						BackgroundColor3 = Color3.fromRGB(255, 255, 255),
						BackgroundTransparency = 1,
						BorderColor3 = Color3.fromRGB(0, 0, 0),
						BorderSizePixel = 0,
						Position = UDim2.new(0, -15, 0.5, 0),
						Size = UDim2.fromOffset(16, 16),
						Visible = false,
						ZIndex = 7,
					}),
				},
			}),

			New("TextBox")({
				[Ref] = textboxRef,

				Name = "Input",
				CursorPosition = -1,
				FontFace = Font.new("rbxassetid://12187365364", Enum.FontWeight.Medium, Enum.FontStyle.Normal),
				LineHeight = 1.1,
				PlaceholderText = "Enter command or search here...",
				PlaceholderColor3 = Color3.fromRGB(119, 119, 119),
				Text = "",
				TextColor3 = Color3.fromRGB(211, 211, 211),
				TextSize = 15,
				TextXAlignment = Enum.TextXAlignment.Left,
				AnchorPoint = Vector2.new(0, 1),
				BackgroundColor3 = Color3.fromRGB(255, 255, 255),
				BackgroundTransparency = 1,
				BorderColor3 = Color3.fromRGB(0, 0, 0),
				BorderSizePixel = 0,
				Position = UDim2.fromScale(0, 1),
				Size = UDim2.new(1, 0, 1, -40),

				[OnEvent("FocusLost")] = function()
					States.ToExecute:set(unwrap(textboxRef).Text)
					unwrap(textboxRef).Text = ""
					States.CommandBarOpened:set(false)

					commandbarPos:set(UDim2.new(0.5, 0, 0, 160))
					task.wait(0.2)
					commandbarScale:set(0)
					commandbarPos:set(UDim2.new(0.5, 0, 0, 100))
				end,

				[OnChange("Text")] = function()
					States.CommandBarText:set(unwrap(textboxRef).Text)
				end,

				[Children] = {
					New("UIPadding")({
						Name = "UIPadding",
						PaddingLeft = UDim.new(0, 35),
					}),

					New("ImageLabel")({
						Name = "Image",
						Image = "rbxassetid://14387211002",
						AnchorPoint = Vector2.new(0.5, 0.5),
						BackgroundColor3 = Color3.fromRGB(255, 255, 255),
						BackgroundTransparency = 1,
						BorderColor3 = Color3.fromRGB(0, 0, 0),
						BorderSizePixel = 0,
						Position = UDim2.new(0, -15, 0.5, 0),
						Size = UDim2.fromOffset(16, 16),
						ZIndex = 7,
					}),
				},
			}),
		},
	})

	return CommandBar
end
