local m=script.Parent.Parent return function(Y)local n=require(m.Bundles)local k=n.themeSystem local h=n.Fusion local P=h.New local A=h.OnEvent local L=h.Children local u=h.Value local K=h.Computed local X=require(m.utilities)local V=X.get local S=X.animate local s=X.getStringBounds local g=X.customFont local p=X.typecheck local c=require(m.simpleElements)local O=c.UICorner local l=c.UIPadding local o=c.UIListLayout local G=Enum.SortOrder local b=Enum.FillDirection local J=Enum.HorizontalAlignment local N=Enum.VerticalAlignment local t,j=p(Y,{Title="";Body="",Duration=1;Image="";ImageColor=Color3.fromRGB(0,0,0),Buttons={}},{Y.Image and""or"\073\109\097\103\101",Y.ImageColor and""or"\073\109\097\103\101\067\111\108\111\114",Y.Buttons and""or"\066\117\116\116\111\110\115"})assert(t,table.concat(j,"\n"))local a=u(Y.Title)local F=u(Y.Body)local U=u(Y.Duration)local E=u(Y.Image or"")local v=Y.ImageColor and u(Y.ImageColor)or k.text local z=u(Y.Buttons or{})local B=u(false)local e=u(false)local d=u("")local R=u(250)local function Z(m,Y)local n=1 for m=1,m,1 do n=n*10 end local k=tostring(math.round(Y*n)/n)local h=string.split(k,"\046")if#h==1 then local Y=""for m=1,m,1 do Y=Y.."\048"end k=k..("\046"..Y)end return k end local M local C={}for m,Y in V(z)do local n,h=p({Button=Y},{Button={}})assert(n,table.concat(h,"\n"))n,h=p(Y,{Name="";Callback=function() end})assert(n,table.concat(h,"\n"))local u=Y.Name local K=Y.Callback local X=(P("\084\101\120\116\066\117\116\116\111\110"))({Size=UDim2.new(1/#V(z),-2,1,-4),TextSize=14,Text=u;FontFace=g("\077\111\110\116\115\101\114\114\097\116",Enum.FontWeight.Bold);BackgroundColor3=k.notificationButton;TextColor3=k.text,[A("\065\099\116\105\118\097\116\101\100")]=function()task.spawn(K)e:set(false)task.wait(.4)B:set(false)task.wait(2)M:Destroy()end,[L]={O(4)}})table.insert(C,X)end M=(P("\070\114\097\109\101"))({Parent=Y.Parent,BackgroundTransparency=1;Size=UDim2.fromOffset(V(R),0),AutomaticSize=Enum.AutomaticSize.Y,[L]={l(5,0,0,0),(P("\084\101\120\116\066\117\116\116\111\110"))({BackgroundTransparency=1;Size=UDim2.fromScale(1,1),[A("\065\099\116\105\118\097\116\101\100")]=function()e:set(false)task.wait(.4)B:set(false)M:Destroy()end});(P("\070\114\097\109\101"))({Size=UDim2.fromScale(1,0);BackgroundColor3=k.background,AutomaticSize=Enum.AutomaticSize.Y;Position=S(function()return UDim2.fromScale(V(e)and 0 or 1.2,0)end,30,1);[L]={o(G.LayoutOrder,b.Horizontal,J.Left,N.Center,UDim.new(0,4));l(0,4);O(4);(P("\070\114\097\109\101"))({Visible=V(E)~=""and true or false;Size=UDim2.new(0,24,1,0);BackgroundTransparency=1;[L]={(P("\073\109\097\103\101\076\097\098\101\108"))({Size=UDim2.fromOffset(24,24),AnchorPoint=Vector2.new(.5,.5);Position=UDim2.fromScale(.5,.5);BackgroundTransparency=1,Image=E,ImageColor3=v})}});(P("\070\114\097\109\101"))({Size=UDim2.new(1,V(E)~=""and-28 or 0,0,0);BackgroundTransparency=1,AutomaticSize=Enum.AutomaticSize.Y;[L]={l(2,0);o(G.LayoutOrder,b.Vertical,J.Left,N.Top);(P("\084\101\120\116\076\097\098\101\108"))({Size=UDim2.new(1,0,0,16),BackgroundTransparency=1,FontFace=g("\077\111\110\116\115\101\114\114\097\116",Enum.FontWeight.Bold),TextXAlignment=Enum.TextXAlignment.Left,TextSize=16,RichText=true,TextColor3=k.text;Text=a});(P("\084\101\120\116\076\097\098\101\108"))({Size=UDim2.new(1,0,0,1);AutomaticSize=Enum.AutomaticSize.Y;Position=UDim2.fromOffset(8,25);BackgroundTransparency=1;FontFace=g("\077\111\110\116\115\101\114\114\097\116",Enum.FontWeight.Medium),TextSize=14,TextXAlignment=Enum.TextXAlignment.Left;TextYAlignment=Enum.TextYAlignment.Top;TextWrapped=true;RichText=true,TextColor3=k.text2;Text=F});(P("\070\114\097\109\101"))({Visible=K(function()return#V(z)>0 and true or false end),Size=UDim2.new(1,0,0,26);BackgroundTransparency=1,[L]={o(G.LayoutOrder,b.Horizontal,J.Center,N.Center,UDim.new(0,2)),C}}),(P("\084\101\120\116\076\097\098\101\108"))({Size=UDim2.new(1,0,0,10),FontFace=g("\077\111\110\116\115\101\114\114\097\116",Enum.FontWeight.Medium),Text=d;TextColor3=k.text,TextSize=10;BackgroundTransparency=1;TextXAlignment=Enum.TextXAlignment.Right})}})}})}})task.delay(.4,function()e:set(true)end)task.spawn(function()repeat task.wait()until V(e)local m=tick()local Y repeat Y=tick()-m d:set(Z(1,math.clamp(Y,0,V(U))))task.wait()until Y>V(U)end)task.spawn(function()B:set(true)repeat task.wait()until V(e)task.wait(V(U))task.wait(.2)e:set(false)task.wait(.4)B:set(false)task.wait(2)M:Destroy()end)end
local darius = script.Parent.Parent
return function(property)
    local bundles = require(darius.Bundles)
    local theme = bundles.themeSystem
    local Fusion = bundles.Fusion
        local new = Fusion.New
        local onevent = Fusion.OnEvent
        local children = Fusion.Children
        local value = Fusion.Value
        local computed = Fusion.Computed

    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

    local simpleElements = require(darius.simpleElements)
    local UICorner = simpleElements.UICorner
    local UIPadding = simpleElements.UIPadding
    local UIListLayout = simpleElements.UIListLayout
    local SO = Enum.SortOrder
    local FD = Enum.FillDirection
    local HA = Enum.HorizontalAlignment
    local VA = Enum.VerticalAlignment

    -- Typecheck

    local didPass, failedItems = typecheck(property, {
        Title = "",
        Body = "",
        Duration = 1,
        Image = "",
        ImageColor = Color3.fromRGB(0,0,0),
        Buttons = {}
    }, {
        property.Image and "" or "Image",
        property.ImageColor and "" or "ImageColor",
        property.Buttons and "" or "Buttons"
    })
    assert(didPass, table.concat(failedItems, "\n"))

    -- Properties

    local title = value(property.Title)
    local body = value(property.Body)
    local duration = value(property.Duration)
    local image = value(property.Image or "")
    local imageColor = property.ImageColor and value(property.ImageColor) or theme.text
    local buttons = value(property.Buttons or {})

    -- Variables

    local loaded = value(false)
    local resized = value(false)
    local tickText = value("")
    local width = value(250)
    local function roundTo(decimal, number)
        local point = 1
        for _=1,decimal do
            point = point*10
        end
        local stringed = tostring(math.round(number*point)/point)
        local tstringed = string.split(stringed, ".")
        if #tstringed == 1 then
            local zeros = ""
            for i=1,decimal do
                zeros = zeros.."0"
            end
            stringed = stringed.."."..zeros
        end
        return stringed
    end

    -- Instances
    local newNotification

    local buttonInstances = {}
    for _,buttonInfo in get(buttons) do
        local _didPass, _failedItems = typecheck({Button = buttonInfo}, {Button = {}})
        assert(_didPass, table.concat(_failedItems, "\n"))
        _didPass, _failedItems = typecheck(buttonInfo, {Name = "", Callback = function()end})
        assert(_didPass, table.concat(_failedItems, "\n"))

        local name = buttonInfo.Name
        local callback = buttonInfo.Callback
        local instance = new "TextButton" {
            Size = UDim2.new(1/#get(buttons), -2, 1, -4),
            TextSize = 14,
            Text = name,
            FontFace = customFont("Montserrat", Enum.FontWeight.Bold),
            BackgroundColor3 = theme.notificationButton,
            TextColor3 = theme.text,

            [onevent "Activated"] = function()
                task.spawn(callback)
                resized:set(false)
                task.wait(0.4)
                loaded:set(false)
                task.wait(2)
                newNotification:Destroy()
            end,

            [children] = {
                UICorner(4)
            }
        }
        table.insert(buttonInstances, instance)
    end

    newNotification = new "Frame" {
        Parent = property.Parent,
        BackgroundTransparency = 1,
        Size = UDim2.fromOffset(get(width), 0),
        AutomaticSize = Enum.AutomaticSize.Y,

        [children] = {
            UIPadding(5,0,0,0),
            new "TextButton" {
                BackgroundTransparency = 1,
                Size = UDim2.fromScale(1,1),

                [onevent "Activated"] = function()
                    resized:set(false)
                    task.wait(0.4)
                    loaded:set(false)
                    newNotification:Destroy()
                end
            },
            new "Frame" {
                Size = UDim2.fromScale(1,0),
                BackgroundColor3 = theme.background,
                AutomaticSize = Enum.AutomaticSize.Y,
                Position = animate(function()
                    return UDim2.fromScale(get(resized) and 0 or 1.2, 0)
                end,30,1),

                [children] = {
                    UIListLayout(SO.LayoutOrder,FD.Horizontal,HA.Left,VA.Center,UDim.new(0,4)),
                    UIPadding(0,4),
                    UICorner(4),
                    new "Frame" {
                        Visible = get(image) ~= "" and true or false,
                        Size = UDim2.new(0,24,1,0),
                        BackgroundTransparency = 1,

                        [children] = {
                            new "ImageLabel" {
                                Size = UDim2.fromOffset(24,24),
                                AnchorPoint = Vector2.new(0.5,0.5),
                                Position = UDim2.fromScale(0.5,0.5),
                                BackgroundTransparency = 1,
                                Image = image,
                                ImageColor3 = imageColor
                            }
                        }
                    },
                    new "Frame" {
                        Size = UDim2.new(1,get(image) ~= "" and -28 or 0,0,0),
                        BackgroundTransparency = 1,
                        AutomaticSize = Enum.AutomaticSize.Y,

                        [children] = {
                            UIPadding(2,0),
                            UIListLayout(SO.LayoutOrder,FD.Vertical,HA.Left,VA.Top),
                            new "TextLabel" {
                                Size = UDim2.new(1,0,0,16),
                                BackgroundTransparency = 1,
                                FontFace = customFont("Montserrat", Enum.FontWeight.Bold),
                                TextXAlignment = Enum.TextXAlignment.Left,
                                TextSize = 16,
                                RichText = true,

                                TextColor3 = theme.text,
                                Text = title
                            },
                            new "TextLabel" {
                                Size = UDim2.new(1,0,0,1),
                                AutomaticSize = Enum.AutomaticSize.Y,
                                Position = UDim2.fromOffset(8,25),
                                BackgroundTransparency = 1,
                                FontFace = customFont("Montserrat", Enum.FontWeight.Medium),
                                TextSize = 14,
                                TextXAlignment = Enum.TextXAlignment.Left,
                                TextYAlignment = Enum.TextYAlignment.Top,
                                TextWrapped = true,
                                RichText = true,

                                TextColor3 = theme.text2,
                                Text = body
                            },
                            new "Frame" {
                                Visible = computed(function()
                                    return #get(buttons) > 0 and true or false
                                end),
                                Size = UDim2.new(1,0,0,26),
                                BackgroundTransparency = 1,

                                [children] = {
                                    UIListLayout(SO.LayoutOrder,FD.Horizontal,HA.Center,VA.Center,UDim.new(0,2)),
                                    buttonInstances
                                }
                            },
                            new "TextLabel" {
                                Size = UDim2.new(1,0,0,10),
                                FontFace = customFont("Montserrat", Enum.FontWeight.Medium),
                                Text = tickText,
                                TextColor3 = theme.text,
                                TextSize = 10,
                                BackgroundTransparency = 1,
                                TextXAlignment = Enum.TextXAlignment.Right
                            }
                        }
                    }
                }

            }
        }
    }

    task.delay(0.4,function()
        resized:set(true)
    end)
    task.spawn(function()
        repeat task.wait() until get(resized)
        local startTick = tick()
        local endTick
        repeat
            endTick = tick() - startTick
            tickText:set(roundTo(1,math.clamp(endTick,0,get(duration))))
            task.wait()
        until endTick > get(duration)
    end)
    task.spawn(function()
        loaded:set(true)
        repeat task.wait() until get(resized)
        task.wait(get(duration))
        task.wait(0.2)
        resized:set(false)
        task.wait(0.4)
        loaded:set(false)
        task.wait(2)
        newNotification:Destroy()
    end)
end