-- Decompiled with the Synapse X Luau decompiler.


local l__Parent__1 = script.Parent;
local v2 = require(l__Parent__1:WaitForChild("MessageLabelCreator"));
local v3 = require(l__Parent__1:WaitForChild("CurveUtil"));
local v4 = require(game:GetService("Chat"):WaitForChild("ClientChatModules"):WaitForChild("ChatSettings"));
local v5 = false;
local v6, v7 = pcall(function()
	return settings():IsUserFeatureEnabled("UserFixChatMessageLogPerformance");
end);
if v6 then
	v5 = v7;
end;
local v8 = {};
v8.__index = v8;
local u1 = {
	ScrollBarThickness = 4
};
function v8.Destroy(p1)
	p1.GuiObject:Destroy();
	p1.Destroyed = true;
end;
function v8.SetActive(p2, p3)
	p2.GuiObject.Visible = p3;
end;
function v8.UpdateMessageFiltered(p4, p5)
	local v9 = nil;
	local v10 = 1;
	local l__MessageObjectLog__11 = p4.MessageObjectLog;
	while v10 <= #l__MessageObjectLog__11 do
		local v12 = l__MessageObjectLog__11[v10];
		if v12.ID == p5.ID then
			v9 = v12;
			break;
		end;
		v10 = v10 + 1;	
	end;
	if v9 then
		local v13 = p4:IsScrolledDown();
		v9.UpdateTextFunction(p5);
		if not v5 then
			p4:ReorderAllMessages();
			return;
		end;
	else
		return;
	end;
	p4:PositionMessageLabelInWindow(v9, v13);
end;
local u2 = v2.new();
function v8.AddMessage(p6, p7)
	p6:WaitUntilParentedCorrectly();
	local v14 = u2:CreateMessageLabel(p7, p6.CurrentChannelName);
	if v14 == nil then
		return;
	end;
	table.insert(p6.MessageObjectLog, v14);
	p6:PositionMessageLabelInWindow(v14);
end;
function v8.AddMessageAtIndex(p8, p9, p10)
	local v15 = u2:CreateMessageLabel(p9, p8.CurrentChannelName);
	if v15 == nil then
		return;
	end;
	table.insert(p8.MessageObjectLog, p10, v15);
	local v16 = p8:IsScrolledDown();
	p8:ReorderAllMessages();
	if v16 then
		p8.Scroller.CanvasPosition = Vector2.new(0, math.max(0, p8.Scroller.CanvasSize.Y.Offset - p8.Scroller.AbsoluteSize.Y));
	end;
end;
function v8.RemoveLastMessage(p11)
	p11:WaitUntilParentedCorrectly();
	local v17 = p11.MessageObjectLog[1];
	local v18 = UDim2.new(0, 0, 0, v17.BaseFrame.AbsoluteSize.Y);
	v17:Destroy();
	table.remove(p11.MessageObjectLog, 1);
	if not v5 then
		for v19, v20 in pairs(p11.MessageObjectLog) do
			v20.BaseFrame.Position = v20.BaseFrame.Position - v18;
		end;
		p11.Scroller.CanvasSize = p11.Scroller.CanvasSize - v18;
	end;
end;
function v8.IsScrolledDown(p12)
	local v21 = nil;
	local v22 = nil;
	local v23 = nil;
	v21 = p12.Scroller.CanvasSize.Y.Offset;
	v22 = p12.Scroller.AbsoluteWindowSize.Y;
	v23 = p12.Scroller.CanvasPosition.Y;
	if v5 then
		local v24 = true;
		if not (v21 < v22) then
			v24 = v22 - 5 <= v21 + v23;
		end;
		return v24;
	end;
	local v25 = true;
	if not (v21 < v22) then
		v25 = v21 - v23 <= v22 + 5;
	end;
	return v25;
end;
function v8.PositionMessageLabelInWindow(p13, p14, p15)
	p13:WaitUntilParentedCorrectly();
	local l__BaseFrame__26 = p14.BaseFrame;
	if v5 then
		if p15 == nil then
			p15 = p13:IsScrolledDown();
		end;
		l__BaseFrame__26.LayoutOrder = p14.ID;
	else
		l__BaseFrame__26.Parent = p13.Scroller;
		l__BaseFrame__26.Position = UDim2.new(0, 0, 0, p13.Scroller.CanvasSize.Y.Offset);
	end;
	l__BaseFrame__26.Size = UDim2.new(1, 0, 0, p14.GetHeightFunction(p13.Scroller.AbsoluteSize.X));
	if v5 then
		l__BaseFrame__26.Parent = p13.Scroller;
	end;
	if p14.BaseMessage then
		if v5 then
			for v27 = 1, 10 do
				if p14.BaseMessage.TextFits then
					break;
				end;
				l__BaseFrame__26.Size = UDim2.new(1, 0, 0, p14.GetHeightFunction(p13.Scroller.AbsoluteSize.X - v27));
			end;
		else
			local v28 = p13.Scroller.AbsoluteSize.X;
			local v29 = math.min(p13.Scroller.AbsoluteSize.X - 10, 0);
			while not p14.BaseMessage.TextFits do
				v28 = v28 - 1;
				if v28 < v29 then
					break;
				end;
				l__BaseFrame__26.Size = UDim2.new(1, 0, 0, p14.GetHeightFunction(v28));			
			end;
		end;
	end;
	if v5 then
		if not p15 then
			return;
		end;
	else
		p15 = p13:IsScrolledDown();
		p13.Scroller.CanvasSize = p13.Scroller.CanvasSize + UDim2.new(0, 0, 0, l__BaseFrame__26.Size.Y.Offset);
		if p15 then
			p13.Scroller.CanvasPosition = Vector2.new(0, math.max(0, p13.Scroller.CanvasSize.Y.Offset - p13.Scroller.AbsoluteSize.Y));
		end;
		return;
	end;
	p13.Scroller.CanvasPosition = Vector2.new(0, math.max(0, p13.Scroller.CanvasSize.Y.Offset - p13.Scroller.AbsoluteSize.Y));
end;
function v8.ReorderAllMessages(p16)
	p16:WaitUntilParentedCorrectly();
	if p16.GuiObject.AbsoluteSize.Y < 1 then
		return;
	end;
	p16.Scroller.CanvasSize = UDim2.new(0, 0, 0, 0);
	for v30, v31 in pairs(p16.MessageObjectLog) do
		p16:PositionMessageLabelInWindow(v31);
	end;
	if not p16:IsScrolledDown() then
		p16.Scroller.CanvasPosition = p16.Scroller.CanvasPosition;
	end;
end;
function v8.Clear(p17)
	for v32, v33 in pairs(p17.MessageObjectLog) do
		v33:Destroy();
	end;
	p17.MessageObjectLog = {};
	if not v5 then
		p17.Scroller.CanvasSize = UDim2.new(0, 0, 0, 0);
	end;
end;
function v8.SetCurrentChannelName(p18, p19)
	p18.CurrentChannelName = p19;
end;
function v8.FadeOutBackground(p20, p21)

end;
function v8.FadeInBackground(p22, p23)

end;
function v8.FadeOutText(p24, p25)
	for v34 = 1, #p24.MessageObjectLog do
		if p24.MessageObjectLog[v34].FadeOutFunction then
			p24.MessageObjectLog[v34].FadeOutFunction(p25, v3);
		end;
	end;
end;
function v8.FadeInText(p26, p27)
	for v35 = 1, #p26.MessageObjectLog do
		if p26.MessageObjectLog[v35].FadeInFunction then
			p26.MessageObjectLog[v35].FadeInFunction(p27, v3);
		end;
	end;
end;
function v8.Update(p28, p29)
	for v36 = 1, #p28.MessageObjectLog do
		if p28.MessageObjectLog[v36].UpdateAnimFunction then
			p28.MessageObjectLog[v36].UpdateAnimFunction(p29, v3);
		end;
	end;
end;
function v8.WaitUntilParentedCorrectly(p30)
	while not p30.GuiObject:IsDescendantOf(game:GetService("Players").LocalPlayer) do
		p30.GuiObject.AncestryChanged:wait();	
	end;
end;
local function u3()
	local v37 = Instance.new("Frame");
	v37.Selectable = false;
	v37.Size = UDim2.new(1, 0, 1, 0);
	v37.BackgroundTransparency = 1;
	local v38 = Instance.new("ScrollingFrame");
	v38.Selectable = v4.GamepadNavigationEnabled;
	v38.Name = "Scroller";
	v38.BackgroundTransparency = 1;
	v38.BorderSizePixel = 0;
	v38.Position = UDim2.new(0, 0, 0, 3);
	v38.Size = UDim2.new(1, -4, 1, -6);
	v38.CanvasSize = UDim2.new(0, 0, 0, 0);
	v38.ScrollBarThickness = u1.ScrollBarThickness;
	v38.Active = false;
	v38.Parent = v37;
	local v39 = nil;
	if v5 then
		v39 = Instance.new("UIListLayout");
		v39.SortOrder = Enum.SortOrder.LayoutOrder;
		v39.Parent = v38;
	end;
	return v37, v38, v39;
end;
function u1.new()
	local v40 = setmetatable({}, v8);
	v40.Destroyed = false;
	local v41, v42, v43 = u3();
	v40.GuiObject = v41;
	v40.Scroller = v42;
	v40.Layout = v43;
	v40.MessageObjectLog = {};
	v40.Name = "MessageLogDisplay";
	v40.GuiObject.Name = "Frame_" .. v40.Name;
	v40.CurrentChannelName = "";
	v40.GuiObject:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
		spawn(function()
			v40:ReorderAllMessages();
		end);
	end);
	if v5 then
		local u4 = true;
		v40.Layout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
			local l__AbsoluteContentSize__44 = v40.Layout.AbsoluteContentSize;
			v40.Scroller.CanvasSize = UDim2.new(0, 0, 0, l__AbsoluteContentSize__44.Y);
			if u4 then
				v40.Scroller.CanvasPosition = Vector2.new(0, l__AbsoluteContentSize__44.Y - v40.Scroller.AbsoluteWindowSize.Y);
			end;
		end);
		v40.Scroller:GetPropertyChangedSignal("CanvasPosition"):Connect(function()
			u4 = v40:IsScrolledDown();
		end);
	end;
	return v40;
end;
return u1;

