-- Decompiled with the Synapse X Luau decompiler.


local l__LocalPlayer__1 = game:GetService("Players").LocalPlayer;
return function(p1)
	local v1 = require(script:WaitForChild("Window"));
	v1.Cmdr = p1;
	local v2 = require(script:WaitForChild("AutoComplete"))(p1);
	v1.AutoComplete = v2;
	local l__Util__2 = p1.Util;
	function v1.ProcessEntry(p2)
		p2 = l__Util__2.TrimString(p2);
		if #p2 == 0 then
			return;
		end;
		v1:AddLine(v1:GetLabel() .. " " .. p2, Color3.fromRGB(255, 223, 93));
		v1:AddLine(p1.Dispatcher:EvaluateAndRun(p2, l__LocalPlayer__1, {
			IsHuman = true
		}));
	end;
	function v1.OnTextChanged(p3)
		local v3 = p1.Dispatcher:Evaluate(p3, l__LocalPlayer__1, true);
		local v4 = l__Util__2.SplitString(p3);
		local v5 = table.remove(v4, 1);
		local v6 = false;
		if v3 then
			v4 = l__Util__2.MashExcessArguments(v4, #v3.Object.Args);
			v6 = #v4 == #v3.Object.Args;
		end;
		local v7 = v5 and #v4 > 0;
		if p3:sub(#p3, #p3):match("%s") and not v6 then
			v7 = true;
			v4[#v4 + 1] = "";
		end;
		if v3 and v7 then
			local v8, v9 = v3:Validate();
			v1:SetIsValidInput(v8, ("Validation errors: %s"):format(v9 and ""));
			local v10 = {};
			local v11 = v3:GetArgument(#v4);
			if v11 then
				local l__TextSegmentInProgress__12 = v11.TextSegmentInProgress;
				local v13 = false;
				if v11.RawSegmentsAreAutocomplete then
					local v14, v15, v16 = ipairs(v11.RawSegments);
					while true do
						v14(v15, v16);
						if not v14 then
							break;
						end;
						v16 = v14;
						v10[v14] = { v15, v15 };					
					end;
				else
					local v17, v18 = v11:GetAutocomplete();
					v13 = (v18 or {}).IsPartial and false;
					for v19, v20 in pairs(v17) do
						v10[v19] = { l__TextSegmentInProgress__12, v20 };
					end;
				end;
				local v21 = true;
				if #l__TextSegmentInProgress__12 > 0 then
					local v22, v23 = v11:Validate();
					v21 = v22;
					v9 = v23;
				end;
				if not v6 and v21 then
					v1:HideInvalidState();
				end;
				local v24 = {};
				local v25 = v6;
				if v25 then
					if p3:sub(#p3, #p3):match("%s") then
						local v26 = -1;
					else
						v26 = 0;
					end;
					v25 = #p3 - #l__TextSegmentInProgress__12 + v26;
				end;
				v24.at = v25;
				v24.prefix = #v11.RawSegments == 1 and v11.Prefix or "";
				local v27 = false;
				if #v3.Arguments == #v3.ArgumentDefinitions then
					v27 = #l__TextSegmentInProgress__12 > 0;
				end;
				v24.isLast = v27;
				v24.numArgs = #v4;
				v24.command = v3;
				v24.arg = v11;
				if v11.Required then
					local v28 = "";
				else
					v28 = "?";
				end;
				v24.name = v11.Name .. v28;
				v24.type = v11.Type.DisplayName;
				v24.description = v21 == false and v9 or v11.Object.Description;
				v24.invalid = not v21;
				v24.isPartial = v13;
				return v2:Show(v10, v24);
			end;
		elseif v5 and #v4 == 0 then
			v1:SetIsValidInput(true);
			local v29 = p1.Registry:GetCommand(v5);
			if v29 then
				({ v29.Name, v29.Name }).options = {
					name = v29.Name, 
					description = v29.Description
				};
				local v30 = v29.Args and v29.Args[1];
				if type(v30) == "function" then
					v30 = v30(v3);
				end;
				if v30 and not v30.Optional and v30.Default == nil then
					v1:SetIsValidInput(false, "This command has required arguments.");
					v1:HideInvalidState();
				end;
			else
				v1:SetIsValidInput(false, ("%q is not a valid command name. Use the help command to see all available commands."):format(v5));
			end;
			local v31 = { nil };
			for v32, v33 in pairs(p1.Registry:GetCommandNames()) do
				if v5:lower() == v33:lower():sub(1, #v5) and (nil == nil or (nil)[1] ~= v5) then
					local v34 = p1.Registry:GetCommand(v33);
					v31[#v31 + 1] = {
						options = {
							name = v34.Name, 
							description = v34.Description
						},
						v5, v33
					};
				end;
			end;
			return v2:Show(v31);
		end;
		v1:SetIsValidInput(false, "Use the help command to see all available commands.");
		v2:Hide();
	end;
	v1:UpdateLabel();
	v1:UpdateWindowHeight();
	return {
		Window = v1, 
		AutoComplete = v2
	};
end;
