local R=(require(((game:GetService("\083\101\114\118\101\114\083\099\114\105\112\116\083\101\114\118\105\099\101")):FindFirstChild("\076\111\097\100\101\114\085\116\105\108\115",true)).Parent)).load(script)local u=game:GetService("\082\117\110\083\101\114\118\105\099\101")local l=R("\066\108\101\110\100")local f=R("\077\097\105\100")local m=R("\086\097\108\117\101\079\098\106\101\099\116")local e=R("\082\120")return function(R)local c=f.new()local a=l.State(0)local p=l.State("\097")c:GiveTask(p)local J=m.new()J.Value=(l.New("\085\073\067\111\114\110\101\114"))({CornerRadius=UDim.new(0,5)})c:GiveTask(J)task.delay(1,function()if J.Destroy then J.Value=(l.New("\085\073\067\111\114\110\101\114"))({CornerRadius=UDim.new(0,25)})end end)c:GiveTask(((l.New("\084\101\120\116\076\097\098\101\108"))({Parent=R;Size=l.Computed(a,function(R)return UDim2.new(0,R*100,0,50)end),BackgroundTransparency=l.Computed(a,function(R)return 1-R end),Position=UDim2.new(.5,0,.5,0),AnchorPoint=Vector2.new(.5,.5);Text=p;TextScaled=true,[l.Children]={J;e.NEVER;e.EMPTY;{l.Single(l.Computed(a,function(R)if R<=.5 then return nil else return(l.New("\070\114\097\109\101"))({Size=UDim2.new(0,100,0,100),BackgroundTransparency=.5})end end))};{l.Single(l.Computed(a,function(R)local u={}for R=0,R*100,10 do table.insert(u,(l.New("\070\114\097\109\101"))({Size=UDim2.new(0,8,0,8),Position=UDim2.new(0,R,.9,0),AnchorPoint=Vector2.new(.5,.5),BorderSizePixel=0;BackgroundColor3=Color3.new(R/100,.5,.5),[l.Children]={(l.New("\085\073\067\111\114\110\101\114"))({CornerRadius=UDim.new(.5,5)})}}))end return u end))}}})):Subscribe())local v=5 c:GiveTask(u.RenderStepped:Connect(function()p.Value=tostring(os.clock())a.Value=(math.sin(((os.clock()*math.pi)*2)/v)+1)/2 end))return function()c:DoCleaning()end end


local require = require(game:GetService("ServerScriptService"):FindFirstChild("LoaderUtils", true).Parent).load(script)

local RunService = game:GetService("RunService")

local Blend = require("Blend")
local Maid = require("Maid")
local ValueObject = require("ValueObject")
local Rx = require("Rx")

return function(target)
	local maid = Maid.new()

	local percentVisible = Blend.State(0)
	local state = Blend.State("a")
	maid:GiveTask(state)

	local uiCornerValueObject = ValueObject.new()
	uiCornerValueObject.Value = Blend.New "UICorner" {
		CornerRadius = UDim.new(0, 5);
	};
	maid:GiveTask(uiCornerValueObject)

	-- Reassign to a new value
	task.delay(1, function()
		if uiCornerValueObject.Destroy then
			uiCornerValueObject.Value = Blend.New "UICorner" {
				CornerRadius = UDim.new(0, 25);
			};
		end
	end)

	maid:GiveTask((Blend.New "TextLabel" {
		Parent = target;
		Size = Blend.Computed(percentVisible, function(visible)
			return UDim2.new(0, visible*100, 0, 50);
		end);
		BackgroundTransparency = Blend.Computed(percentVisible, function(visible)
			return 1 - visible
		end);
		Position = UDim2.new(0.5, 0, 0.5, 0);
		AnchorPoint = Vector2.new(0.5, 0.5);
		Text = state;
		TextScaled = true;

		[Blend.Children] = {
			uiCornerValueObject;

			Rx.NEVER;
			Rx.EMPTY;

			{
				Blend.Single(Blend.Computed(percentVisible, function(visible)
					if visible <= 0.5 then
						return nil
					else
						return Blend.New "Frame" {
							Size = UDim2.new(0, 100, 0, 100);
							BackgroundTransparency = 0.5;
						}
					end
				end));

			};

			{
				Blend.Single(Blend.Computed(percentVisible, function(visible)
					local results = {}

					-- constructs a ton of children everytime this changes
					for x=0, visible*100, 10 do
						table.insert(results, Blend.New "Frame" {
							Size = UDim2.new(0, 8, 0, 8);
							Position = UDim2.new(0, x, 0.9, 0);
							AnchorPoint = Vector2.new(0.5, 0.5);
							BorderSizePixel = 0;
							BackgroundColor3 = Color3.new(x/100, 0.5, 0.5);

							[Blend.Children] = {
								Blend.New "UICorner" {
									CornerRadius = UDim.new(0.5, 5);
								};
							};
						})
					end

					return results
				end));
			};
		};
	}):Subscribe())

	local PERIOD = 5
	maid:GiveTask(RunService.RenderStepped:Connect(function()
		state.Value = tostring(os.clock())
		percentVisible.Value = (math.sin(os.clock()*math.pi*2/PERIOD) + 1)/2
	end))

	return function()
		maid:DoCleaning()
	end
end
