local C=script.Parent.Parent.Parent local U=C.Parent local Z=require(C.Theme)local b=Z.WithTheme local p=require(C.Utility.GetTextSize)local w=require(U.Sift)local m=require(U.t)local O=require(U.Roact)local M=O.createElement local r=require(C.App.Surface.RoundedSurface)local W=O.PureComponent:extend(script.Name)W.defaultProps={Size=UDim2.new(1,0,0,62)}function W.render(C)local U=C.props return b(function(C)local Z=U.Icon and C[U.Icon]local b=C[Z and Z.Color or"\099\111\108\111\114\115\047\070\105\108\108\095\067\111\108\111\114\047\084\101\120\116\047\080\114\105\109\097\114\121"]local w=U.Icon and M("\073\109\097\103\101\076\097\098\101\108",{AnchorPoint=Vector2.new(.5,.5);BackgroundTransparency=1,Image=Z.Image,ImageColor3=b.Color;ImageRectOffset=Z.ImageRectOffset,ImageRectSize=Z.ImageRectSize,ImageTransparency=b.Transparency;Position=UDim2.fromScale(.5,.5),Size=UDim2.fromOffset(Z.ImageRectSize.X,Z.ImageRectSize.Y)})or nil local m=w and M("\070\114\097\109\101",{BackgroundTransparency=1,LayoutOrder=1;Size=UDim2.fromOffset(16,16)},w)local O=C["\099\111\108\111\114\115\047\070\105\108\108\095\067\111\108\111\114\047\084\101\120\116\047\080\114\105\109\097\114\121"]local W=C["\102\111\110\116\115\047\066\111\100\121"]local V,X=p(U.Heading,W.Font,W.Size)local i=U.Heading and M("\084\101\120\116\076\097\098\101\108",{AutomaticSize=not V and Enum.AutomaticSize.XY or Enum.AutomaticSize.None;BackgroundTransparency=1,FontFace=W.Font,LayoutOrder=1,LineHeight=W.LineHeight;Size=UDim2.fromOffset(X.X,X.Y);Text=U.Heading;TextColor3=O.Color,TextTransparency=O.Transparency,TextSize=W.Size})or nil local l=C["\099\111\108\111\114\115\047\070\105\108\108\095\067\111\108\111\114\047\084\101\120\116\047\083\101\099\111\110\100\097\114\121"]local n=C["\102\111\110\116\115\047\067\097\112\116\105\111\110"]local o,x=p(U.Caption,n.Font,n.Size)local G=U.Caption and M("\084\101\120\116\076\097\098\101\108",{AutomaticSize=not o and Enum.AutomaticSize.XY or Enum.AutomaticSize.None;BackgroundTransparency=1,FontFace=n.Font;LayoutOrder=2,LineHeight=n.LineHeight;Size=UDim2.fromOffset(x.X,x.Y);Text=U.Caption;TextColor3=l.Color;TextTransparency=l.Transparency,TextSize=n.Size})or nil local A=M("\070\114\097\109\101",{AutomaticSize=Enum.AutomaticSize.XY;BackgroundTransparency=1;Size=UDim2.fromScale(0,0),LayoutOrder=2},{Heading=i;Caption=G;Layout=M("\085\073\076\105\115\116\076\097\121\111\117\116",{FillDirection=Enum.FillDirection.Vertical,HorizontalAlignment=Enum.HorizontalAlignment.Left,SortOrder=Enum.SortOrder.LayoutOrder,VerticalAlignment=Enum.VerticalAlignment.Center})})local k=M("\070\114\097\109\101",{AutomaticSize=Enum.AutomaticSize.X;BackgroundTransparency=1;Size=UDim2.fromScale(0,1)},{Icon=m,Text=A;Layout=M("\085\073\076\105\115\116\076\097\121\111\117\116",{Padding=UDim.new(0,16);FillDirection=Enum.FillDirection.Horizontal,HorizontalAlignment=Enum.HorizontalAlignment.Left,SortOrder=Enum.SortOrder.LayoutOrder,VerticalAlignment=Enum.VerticalAlignment.Center});Padding=M("\085\073\080\097\100\100\105\110\103",{PaddingLeft=UDim.new(0,15);PaddingTop=UDim.new(0,13),PaddingBottom=UDim.new(0,13)})})local E=C["\099\111\108\111\114\115\047\070\105\108\108\095\067\111\108\111\114\047\083\117\098\116\108\101\047\084\101\114\116\105\097\114\121"]return M(r,{BackgroundColor=E;BackgroundTransparency=0;CornerRadius=UDim.new(0,3),Size=U.Size;LayoutOrder=1,ShowTopLeftCorner=true;ShowTopRightCorner=true,ShowBottomLeftCorner=not U.Expanded,ShowBottomRightCorner=not U.Expanded},k)end)end return W
-- Expander: An expandable list collector

local Winro = script.Parent.Parent.Parent
local Packages = Winro.Parent

local Theme = require(Winro.Theme)
local WithTheme = Theme.WithTheme

local GetTextSize = require(Winro.Utility.GetTextSize)

local Sift = require(Packages.Sift)
local t = require(Packages.t)
local Roact = require(Packages.Roact)
local new = Roact.createElement

local RoundedSurface = require(Winro.App.Surface.RoundedSurface)

local Expander = Roact.PureComponent:extend(script.Name)

Expander.defaultProps = {
	Size = UDim2.new(1, 0, 0, 62), --- @defaultProp
}

function Expander:render()
	local props = self.props

	-- ////////// Expander
	return WithTheme(function(Theme)
		
		-- ////////// LeftContent/Icon

		local IconImageStyle = props.Icon and Theme[props.Icon]
		local IconStyle = Theme[IconImageStyle and IconImageStyle.Color or 'colors/Fill_Color/Text/Primary']

		local IconImage = props.Icon and new('ImageLabel', {
			AnchorPoint = Vector2.new(0.5, 0.5),
			BackgroundTransparency = 1,
			Image = IconImageStyle.Image,
			ImageColor3 = IconStyle.Color,
			ImageRectOffset = IconImageStyle.ImageRectOffset,
			ImageRectSize = IconImageStyle.ImageRectSize,
			ImageTransparency = IconStyle.Transparency,
			Position = UDim2.fromScale(0.5, 0.5),
			Size = UDim2.fromOffset(IconImageStyle.ImageRectSize.X, IconImageStyle.ImageRectSize.Y),
		}) or nil

		local Icon = IconImage and new('Frame', {
			BackgroundTransparency = 1,
			LayoutOrder = 1,
			Size = UDim2.fromOffset(16, 16),
		}, IconImage)

		-- ////////// LeftContent/Text/Heading

		local HeadingTextStyle = Theme['colors/Fill_Color/Text/Primary']
		local HeadingFontStyle = Theme['fonts/Body']

		local GotHeadingTextSize, HeadingTextSize = GetTextSize(
			props.Heading,
			HeadingFontStyle.Font,
			HeadingFontStyle.Size
		)

		local Heading = props.Heading and new('TextLabel', {
			AutomaticSize = (not GotHeadingTextSize) and Enum.AutomaticSize.XY or Enum.AutomaticSize.None,
			BackgroundTransparency = 1,
			FontFace = HeadingFontStyle.Font,
			LayoutOrder = 1,
			LineHeight = HeadingFontStyle.LineHeight,
			Size = UDim2.fromOffset(HeadingTextSize.X, HeadingTextSize.Y),
			Text = props.Heading,
			TextColor3 = HeadingTextStyle.Color,
			TextTransparency = HeadingTextStyle.Transparency,
			TextSize = HeadingFontStyle.Size,
		}) or nil
		
		-- ////////// LeftContent/Text/Caption

		local CaptionTextStyle = Theme['colors/Fill_Color/Text/Secondary']
		local CaptionFontStyle = Theme['fonts/Caption']

		local GotCaptionTextSize, CaptionTextSize = GetTextSize(
			props.Caption,
			CaptionFontStyle.Font,
			CaptionFontStyle.Size
		)
		
		local Caption = props.Caption and new('TextLabel', {
			AutomaticSize = (not GotCaptionTextSize) and Enum.AutomaticSize.XY or Enum.AutomaticSize.None,
			BackgroundTransparency = 1,
			FontFace = CaptionFontStyle.Font,
			LayoutOrder = 2,
			LineHeight = CaptionFontStyle.LineHeight,
			Size = UDim2.fromOffset(CaptionTextSize.X, CaptionTextSize.Y),
			Text = props.Caption,
			TextColor3 = CaptionTextStyle.Color,
			TextTransparency = CaptionTextStyle.Transparency,
			TextSize = CaptionFontStyle.Size,
		}) or nil

		-- ////////// LeftContent/Text

		local Text = new('Frame', {
			AutomaticSize = Enum.AutomaticSize.XY,
			BackgroundTransparency = 1,
			Size = UDim2.fromScale(0, 0),
			LayoutOrder = 2,
		}, {
			Heading = Heading,
			Caption = Caption,

			Layout = new('UIListLayout', {
				FillDirection = Enum.FillDirection.Vertical,
				HorizontalAlignment = Enum.HorizontalAlignment.Left,
				SortOrder = Enum.SortOrder.LayoutOrder,
				VerticalAlignment = Enum.VerticalAlignment.Center,
			}),
		})

		-- ////////// LeftContent

		local LeftContent = new('Frame', {
			AutomaticSize = Enum.AutomaticSize.X,
			BackgroundTransparency = 1,
			Size = UDim2.fromScale(0, 1),
		}, {
			Icon = Icon,
			Text = Text,

			Layout = new('UIListLayout', {
				Padding = UDim.new(0, 16),
				FillDirection = Enum.FillDirection.Horizontal,
				HorizontalAlignment = Enum.HorizontalAlignment.Left,
				SortOrder = Enum.SortOrder.LayoutOrder,
				VerticalAlignment = Enum.VerticalAlignment.Center,
			}),
			Padding = new('UIPadding', {
				PaddingLeft = UDim.new(0, 15),
				PaddingTop = UDim.new(0, 13),
				PaddingBottom = UDim.new(0, 13),
			}),
		})

		-- ////////// RightContent/
		
		-- ////////// Expander

		local ExpanderStyle = Theme['colors/Fill_Color/Subtle/Tertiary']

		return new(RoundedSurface, {
			BackgroundColor = ExpanderStyle,
			BackgroundTransparency = 0,
			CornerRadius = UDim.new(0, 3),
			Size = props.Size,
			LayoutOrder = 1,
			ShowTopLeftCorner = true,
			ShowTopRightCorner = true,
			ShowBottomLeftCorner = not props.Expanded,
			ShowBottomRightCorner = not props.Expanded,
		}, LeftContent)
	end)
end

return Expander
