local d=script.Parent.Parent local D=require(d:WaitForChild("\067\104\097\116\083\101\116\116\105\110\103\115"))local P=require(d:WaitForChild("\067\104\097\116\067\111\110\115\116\097\110\116\115"))local q=require(script.Parent:WaitForChild("\085\116\105\108"))function CreateMeCommandMessageLabel(d,P)local B=d.Message local y=d.ExtraData or{}local b=y.Font or Enum.Font.SourceSansItalic local R=y.TextSize or D.ChatWindowTextSize local m=Color3.new(1,1,1)local l=y.ChannelColor or m local S=0 local r,h=q:CreateBaseMessage("",b,R,m)local E=nil if P~=d.OriginalChannel then local D=string.format("\123\037\115\125",d.OriginalChannel)E=q:AddChannelButtonToBaseMessage(h,l,D,d.OriginalChannel)S=q:GetNumberOfSpaces(D,b,R)+1 end local function W(D)if d.IsFiltered then h.Text=q:CreateLeadingSpaces(S)..(D.FromSpeaker..(" "..string.sub(D.Message,5)))else local d=D.MessageLengthUtf8 or D.MessageLength local P=(utf8.len(utf8.nfcnormalize(D.FromSpeaker))+d)-4 h.Text=q:CreateLeadingSpaces(S)..string.rep("\095",P)end end W(d)local function s(d)return q:GetMessageHeight(h,r,d)end local G={}G[h]={TextTransparency={FadedIn=0;FadedOut=1};TextStrokeTransparency={FadedIn=.75,FadedOut=1}}if E then G[E]={TextTransparency={FadedIn=0,FadedOut=1},TextStrokeTransparency={FadedIn=.75,FadedOut=1}}end local f,c,N=q:CreateFadeFunctions(G)return{[q.KEY_BASE_FRAME]=r,[q.KEY_BASE_MESSAGE]=h,[q.KEY_UPDATE_TEXT_FUNC]=W;[q.KEY_GET_HEIGHT]=s;[q.KEY_FADE_IN]=f;[q.KEY_FADE_OUT]=c;[q.KEY_UPDATE_ANIMATION]=N}end return{[q.KEY_MESSAGE_TYPE]=P.MessageTypeMeCommand,[q.KEY_CREATOR_FUNCTION]=CreateMeCommandMessageLabel}
--!nonstrict
--	// FileName: MeCommandMessage.lua
--	// Written by: TheGamer101
--	// Description: Create a message label for a me command message.

local clientChatModules = script.Parent.Parent
local ChatSettings = require(clientChatModules:WaitForChild("ChatSettings"))
local ChatConstants = require(clientChatModules:WaitForChild("ChatConstants"))
local util = require(script.Parent:WaitForChild("Util"))

function CreateMeCommandMessageLabel(messageData, channelName)
	local message = messageData.Message
	local extraData = messageData.ExtraData or {}
	local useFont = extraData.Font or Enum.Font.SourceSansItalic
	local useTextSize = extraData.TextSize or ChatSettings.ChatWindowTextSize
	local useChatColor = Color3.new(1, 1, 1)
	local useChannelColor = extraData.ChannelColor or useChatColor
	local numNeededSpaces = 0

	local BaseFrame, BaseMessage = util:CreateBaseMessage("", useFont, useTextSize, useChatColor)
	local ChannelButton = nil

	if channelName ~= messageData.OriginalChannel then
		local formatChannelName = string.format("{%s}", messageData.OriginalChannel)
		ChannelButton = util:AddChannelButtonToBaseMessage(BaseMessage, useChannelColor, formatChannelName, messageData.OriginalChannel)
		numNeededSpaces = util:GetNumberOfSpaces(formatChannelName, useFont, useTextSize) + 1
	end

	local function UpdateTextFunction(messageObject)
		if messageData.IsFiltered then
			BaseMessage.Text = util:CreateLeadingSpaces(numNeededSpaces) .. messageObject.FromSpeaker .. " " .. string.sub(messageObject.Message, 5)
		else
			local messageLength = messageObject.MessageLengthUtf8 or messageObject.MessageLength
			local formattedMessageLength = utf8.len(utf8.nfcnormalize(messageObject.FromSpeaker)) + messageLength - 4
			BaseMessage.Text = util:CreateLeadingSpaces(numNeededSpaces) .. string.rep("_", formattedMessageLength)
		end
	end

	UpdateTextFunction(messageData)

	local function GetHeightFunction(xSize)
		return util:GetMessageHeight(BaseMessage, BaseFrame, xSize)
	end

	local FadeParmaters = {}
	FadeParmaters[BaseMessage] = {
		TextTransparency = {FadedIn = 0, FadedOut = 1},
		TextStrokeTransparency = {FadedIn = 0.75, FadedOut = 1}
	}

	if ChannelButton then
		FadeParmaters[ChannelButton] = {
			TextTransparency = {FadedIn = 0, FadedOut = 1},
			TextStrokeTransparency = {FadedIn = 0.75, FadedOut = 1}
		}
	end

	local FadeInFunction, FadeOutFunction, UpdateAnimFunction = util:CreateFadeFunctions(FadeParmaters)

	return {
		[util.KEY_BASE_FRAME] = BaseFrame,
		[util.KEY_BASE_MESSAGE] = BaseMessage,
		[util.KEY_UPDATE_TEXT_FUNC] = UpdateTextFunction,
		[util.KEY_GET_HEIGHT] = GetHeightFunction,
		[util.KEY_FADE_IN] = FadeInFunction,
		[util.KEY_FADE_OUT] = FadeOutFunction,
		[util.KEY_UPDATE_ANIMATION] = UpdateAnimFunction
	}
end

return {
	[util.KEY_MESSAGE_TYPE] = ChatConstants.MessageTypeMeCommand,
	[util.KEY_CREATOR_FUNCTION] = CreateMeCommandMessageLabel
}
