local M=script.Parent.Parent local D=require(M:WaitForChild("\067\104\097\116\083\101\116\116\105\110\103\115"))local K=require(M:WaitForChild("\067\104\097\116\067\111\110\115\116\097\110\116\115"))local W=require(script.Parent:WaitForChild("\085\116\105\108"))function CreateMeCommandMessageLabel(M,K)local f=M.Message local P=M.ExtraData or{}local p=P.Font or Enum.Font.SourceSansItalic local w=P.TextSize or D.ChatWindowTextSize local j=Color3.new(1,1,1)local x=P.ChannelColor or j local A=0 local e,l=W:CreateBaseMessage("",p,w,j)local R=nil if K~=M.OriginalChannel then local D=string.format("\123\037\115\125",M.OriginalChannel)R=W:AddChannelButtonToBaseMessage(l,x,D,M.OriginalChannel)A=W:GetNumberOfSpaces(D,p,w)+1 end local function g(D)if M.IsFiltered then l.Text=W:CreateLeadingSpaces(A)..(D.FromSpeaker..(" "..string.sub(D.Message,5)))else local M=D.MessageLengthUtf8 or D.MessageLength local K=(utf8.len(utf8.nfcnormalize(D.FromSpeaker))+M)-4 l.Text=W:CreateLeadingSpaces(A)..string.rep("\095",K)end end g(M)local function d(M)return W:GetMessageHeight(l,e,M)end local c={}c[l]={TextTransparency={FadedIn=0;FadedOut=1},TextStrokeTransparency={FadedIn=.75,FadedOut=1}}if R then c[R]={TextTransparency={FadedIn=0;FadedOut=1};TextStrokeTransparency={FadedIn=.75;FadedOut=1}}end local Y,s,X=W:CreateFadeFunctions(c)return{[W.KEY_BASE_FRAME]=e,[W.KEY_BASE_MESSAGE]=l;[W.KEY_UPDATE_TEXT_FUNC]=g,[W.KEY_GET_HEIGHT]=d,[W.KEY_FADE_IN]=Y,[W.KEY_FADE_OUT]=s,[W.KEY_UPDATE_ANIMATION]=X}end return{[W.KEY_MESSAGE_TYPE]=K.MessageTypeMeCommand;[W.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
}
