local m=script.Parent.Parent return function(Y)local n=require(m.Bundles)local k=n.data local h=n.themeSystem local P=n.Fusion local A=P.New local L=P.Children local u=P.Value local K=P.Computed local X=P.Observer local V=require(m.simpleElements)local S=V.UICorner local s=V.UIPadding local g=V.UITextSizeConstraint local p=require(m.utilities)local c=p.get local O=p.animate local l=p.getStringBounds local o=p.customFont local G=p.typecheck local b,J=G(Y,{Title="";Visible=false,Body=""},{Y.Visible and""or"\086\105\115\105\098\108\101"})assert(b,table.concat(J,"\n"))local N=k.find("\115\101\108\101\099\116\101\100\084\097\098")local t=k.find("\115\101\097\114\099\104\084\101\120\116")local j=k.add(Y)local a=Y.Parent local F=Y.Title local U=Y.Body local E=Y.Visible or u(true)local v=u(c(N.string)==(c(j.tab)).uid);(X(N.string)):onChange(function()v:set(c(N.string)==(c(j.tab)).uid)end)local z=O(function()return c(v)and 0 or 1 end,40,1)local B=u(0)task.spawn(function()B:set((l(c(U),{Font=o("\077\111\110\116\115\101\114\114\097\116",Enum.FontWeight.Medium),Size=12;Width=math.round((c(a)).AbsoluteSize.X)})).Y)end);(c(a)).Changed:Connect(function(m)if m:lower()=="\097\098\115\111\108\117\116\101\115\105\122\101"then B:set((l(c(U),{Font=o("\077\111\110\116\115\101\114\114\097\116",Enum.FontWeight.Medium),Size=12,Width=math.round((c(a)).AbsoluteSize.X)})).Y)end end);(X(U)):onChange(function()B:set((l(c(U),{Font=o("\077\111\110\116\115\101\114\114\097\116",Enum.FontWeight.Bold);Size=12;Width=math.round((c(a)).AbsoluteSize.X)})).Y)end);(A("\070\114\097\109\101"))({Visible=K(function()if c(t.string)~=""and(not string.find((c(F)):lower(),(c(t.string)):lower())and not string.find((c(U)):lower(),(c(t.string)):lower()))or not c(E)then return false end return true end),BackgroundColor3=h.background2,Parent=a;BackgroundTransparency=z;Size=K(function()return UDim2.new(1,0,0,36+c(B))end);AutomaticSize=Enum.AutomaticSize.Y,[L]={S(6),s(6),(A("\084\101\120\116\076\097\098\101\108"))({Name="\084\105\116\108\101";RichText=true,Size=UDim2.new(1,0,0,18),BackgroundTransparency=1,TextTransparency=z,TextXAlignment=Enum.TextXAlignment.Left;TextYAlignment=Enum.TextYAlignment.Top;TextScaled=true,TextSize=18;FontFace=o("\077\111\110\116\115\101\114\114\097\116",Enum.FontWeight.Bold);TextColor3=h.text;Text=F,[L]={g(1,18)}});(A("\084\101\120\116\076\097\098\101\108"))({Name="\066\111\100\121";TextWrapped=true;RichText=true;Position=UDim2.fromOffset(4,20);BackgroundTransparency=1;TextTransparency=z;TextXAlignment=Enum.TextXAlignment.Left;TextYAlignment=Enum.TextYAlignment.Top;TextSize=12;FontFace=o("\077\111\110\116\115\101\114\114\097\116",Enum.FontWeight.Medium),TextColor3=h.text2;Text=U;Size=K(function()return UDim2.new(1,-4,0,c(B))end)})}})local e={}function e.SetBody(Y,m)local n,k=G({SetBody=m},{SetBody=""})assert(n,table.concat(k,"\n"))U:set(m)end function e.SetTitle(Y,m)local n,k=G({SetTitle=m},{SetTitle=""})assert(n,table.concat(k,"\n"))F:set(m)end function e.Visible(m)E:set(true)end function e.Invisible(m)E:set(false)end return e end
local darius = script.Parent.Parent

return function(property)
    local bundles = require(darius.Bundles)
    local data = bundles.data
    local theme = bundles.themeSystem
    local fusion = bundles.Fusion   
        local new = fusion.New
        local children = fusion.Children
        local value = fusion.Value
        local computed = fusion.Computed
        local observe = fusion.Observer

	local simpleElements = require(darius.simpleElements)
	local UICorner = simpleElements.UICorner
	local UIPadding = simpleElements.UIPadding
	local UITextSizeConstraint = simpleElements.UITextSizeConstraint

    local utilities = require(darius.utilities)
    local get = utilities.get
    local animate = utilities.animate
    local getStringBounds = utilities.getStringBounds
    local customFont = utilities.customFont
	local typecheck = utilities.typecheck

	-- Typecheck

	local didPass, failedItems = typecheck(property,{
		Title = "",
		Visible = false,
		Body = ""
	},{
		property.Visible and "" or "Visible",
	})
	assert(didPass, table.concat(failedItems, "\n"))

	-- Data

	local selectedTab = data.find("selectedTab")
	local searchText = data.find("searchText")
	local paragraph = data.add(property)

	-- Properties

	local _parent = property.Parent
	local title = property.Title
	local body = property.Body
	local visible = property.Visible or value(true)

	-- Variables

	local isSelected = value(get(selectedTab.string) == get(paragraph.tab).uid)
	observe(selectedTab.string):onChange(function()
		isSelected:set(get(selectedTab.string) == get(paragraph.tab).uid)
	end)
	local selectedAnimation = animate(function()
		return get(isSelected) and 0 or 1
	end, 40, 1)
	local ySize = value(0)
	task.spawn(function()
		ySize:set(getStringBounds(get(body),{
			Font = customFont("Montserrat", Enum.FontWeight.Medium),
			Size = 12,
			Width = math.round(get(_parent).AbsoluteSize.X)
		}).Y)
	end)
	get(_parent).Changed:Connect(function(changedProperty)
		if changedProperty:lower() == "absolutesize" then
			ySize:set(getStringBounds(get(body),{
				Font = customFont("Montserrat", Enum.FontWeight.Medium),
                Size = 12,
                Width = math.round(get(_parent).AbsoluteSize.X)
			}).Y)
		end
	end)
	observe(body):onChange(function()
		ySize:set(getStringBounds(get(body),{
			Font = customFont("Montserrat", Enum.FontWeight.Bold),
            Size = 12,
            Width = math.round(get(_parent).AbsoluteSize.X)
		}).Y)
	end)


	-- Paragraph

	new "Frame" {
		Visible = computed(function()
			if get(searchText.string) ~= "" and not string.find(get(title):lower(), get(searchText.string):lower()) and not string.find(get(body):lower(), get(searchText.string):lower()) or not get(visible) then
				return false
			end
			return true
		end),
		BackgroundColor3 = theme.background2,
		Parent = _parent,
		BackgroundTransparency = selectedAnimation,
		Size = computed(function()
			return UDim2.new(1,0,0,36 + get(ySize))
		end),
		AutomaticSize = Enum.AutomaticSize.Y,

		[children] = {
			UICorner(6),
			UIPadding(6),
			new "TextLabel" {
				Name = "Title",
				RichText = true,
				Size = UDim2.new(1,0,0,18),
				BackgroundTransparency = 1,
				TextTransparency = selectedAnimation,
				TextXAlignment = Enum.TextXAlignment.Left,
				TextYAlignment = Enum.TextYAlignment.Top,
				TextScaled = true,
				TextSize = 18,
                FontFace = customFont("Montserrat", Enum.FontWeight.Bold),

				TextColor3 = theme.text,
				Text = title,

				[children] = {
					UITextSizeConstraint(1,18)
				}
			},
			new "TextLabel" {
				Name = "Body",
				TextWrapped = true,
				RichText = true,
				Position = UDim2.fromOffset(4,20),
				BackgroundTransparency = 1,
				TextTransparency = selectedAnimation,
				TextXAlignment = Enum.TextXAlignment.Left,
				TextYAlignment = Enum.TextYAlignment.Top,
				TextSize = 12,
				FontFace = customFont("Montserrat", Enum.FontWeight.Medium),

				TextColor3 = theme.text2,
				Text = body,
				Size = computed(function()
					return UDim2.new(1,-4,0,get(ySize))
				end)
			}
		}
	}

	local returnFunctions = {}
	function returnFunctions:SetBody(newBody)
		local _didPass, _failedItems = typecheck({['SetBody'] = newBody}, {SetBody = ""})
		assert(_didPass, table.concat(_failedItems, "\n"))

		body:set(newBody)
	end
	function returnFunctions:SetTitle(newTitle)
		local _didPass, _failedItems = typecheck({['SetTitle'] = newTitle}, {SetTitle = ""})
		assert(_didPass, table.concat(_failedItems, "\n"))

		title:set(newTitle)
	end
	function returnFunctions:Visible()
		visible:set(true)
	end
	function returnFunctions:Invisible()
		visible:set(false)
	end
	return returnFunctions
end