-- Define the function to open or close the window with gene-alike effect

local function toggleWindow(icon)
	local windowName = icon.Name

	-- Find the corresponding frame in the AppManager using the window name
	local window = appManager:FindFirstChild(windowName)
	if window then
		if window.Visible == false then
			-- Close other windows
			for _, child in ipairs(appManager:GetChildren()) do
				if child:IsA("Frame") and child.Visible then
					child.Visible = false
				end
			end

			dockShelf.Visible = false
			wallShelf.Visible = false

			-- Set the initial position of the window to be relative to the button
			window.Position = UDim2.new(0.319, 0, 0.331, 0)

			-- Set the initial size of the window to be zero
			window.Size = UDim2.new(0, 100, 0, 100)

			-- Show the window and tween its position and size
			window.Visible = true

			-- Determine the tween speed based on the uiSpeedSetting
			local tweenSpeed = ClipSettings.settings.uiSpeedSetting and uiSpeedUser.Value or ClipSettings.uiSpeed

			-- Create a new tween with the appropriate tweenSpeed
			local tweenInfo = TweenInfo.new(tweenSpeed, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
			TweenService:Create(window, tweenInfo, {Position = UDim2.new(-0.007, 0, 0, 0), Size = UDim2.new(1.007, 0, 1, 0)}):Play()
		end
	end
end
