local T=script:FindFirstAncestorWhichIsA("\080\108\117\103\105\110")local g=require(T:FindFirstChild("\076\105\103\104\116\101\114",true))local u=g("\079\117\116\108\101\116")local a=g("\070\097\099\116\111\114\121")local l=g("\071\105\116\072\117\098")local S=game:GetService("\076\111\103\083\101\114\118\105\099\101")local M=game:GetService("\082\117\110\083\101\114\118\105\099\101")local G=u.CreateToolbar()G.ClickableWhenViewportHidden=true u.Prompt(u.Permissions.Http)u.Prompt(u.Permissions.Script)u.Template("\068\101\108\105\118\101\114",{Path=false,Source=false;Enabled=true,Register=false;Logs={}})local r=S.MessageOut:Connect(function(T,g)if g~=Enum.MessageType.MessageOutput then return end if a.Running then if string.lower(T)=="\062 \061\'\102\105\120\'"or string.lower(T)=="\062 --\102\105\120"then a.Running=false l.CURRENT=nil else return end end if string.sub(T,1,3)=="\062 \061"then T=string.sub(T,4)M.Heartbeat:Wait()elseif string.sub(T,1,4)=="\062 --"then T=string.sub(T,5)else return end if not a.Possible(T)then return end a.Running=true a.Execute(T)a.Running=false end)T.Unloading:Connect(function()r:Disconnect()end)G.Click:Connect(function()print("\062 --\097\098\111\117\116")if not u:Get("\069\110\097\098\108\101\100")then u:Set("\069\110\097\098\108\101\100",true)end G:SetActive(false)end)
--[=[
	@Author: Gavin "Mullets" Rosenthal
	@Desc: Deliver, a Roblox command line interface plugin to deliver content, commands, and simplicity within Roblox studio.
]=]

--[=[
[DOCUMENTATION]:
	https://mullets-gavin.github.io/Deliver/
	Visit the documentation site for commands & help.
	
[LICENSE]:
	MIT License
	
	Copyright (c) 2020 Mullet Mafia Dev
	
	Permission is hereby granted, free of charge, to any person obtaining a copy
	of this software and associated documentation files (the "Software"), to deal
	in the Software without restriction, including without limitation the rights
	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the Software is
	furnished to do so, subject to the following conditions:
	
	The above copyright notice and this permission notice shall be included in all
	copies or substantial portions of the Software.
	
	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
	SOFTWARE.
]=]

local plugin = script:FindFirstAncestorWhichIsA("Plugin")
local require = require(plugin:FindFirstChild("Lighter", true))

local Outlet = require("Outlet")
local Factory = require("Factory")
local GitHub = require("GitHub")

local LogService = game:GetService("LogService")
local RunService = game:GetService("RunService")

local Toggle = Outlet.CreateToolbar()
Toggle.ClickableWhenViewportHidden = true

Outlet.Prompt(Outlet.Permissions.Http)
Outlet.Prompt(Outlet.Permissions.Script)
Outlet.Template("Deliver", {
	["Path"] = false,
	["Source"] = false,
	["Enabled"] = true,
	["Register"] = false,
	["Logs"] = {},
})

local Event = LogService.MessageOut:Connect(function(str, enum)
	if enum ~= Enum.MessageType.MessageOutput then
		return
	end

	if Factory.Running then
		if string.lower(str) == "> ='fix'" or string.lower(str) == "> --fix" then
			Factory.Running = false
			GitHub.CURRENT = nil
		else
			return
		end
	end

	if string.sub(str, 1, 3) == "> =" then
		str = string.sub(str, 4)
		RunService.Heartbeat:Wait()
	elseif string.sub(str, 1, 4) == "> --" then
		str = string.sub(str, 5)
	else
		return
	end

	if not Factory.Possible(str) then
		return
	end

	Factory.Running = true
	Factory.Execute(str)
	Factory.Running = false
end)

plugin.Unloading:Connect(function()
	Event:Disconnect()
end)

Toggle.Click:Connect(function()
	print("> --about")

	if not Outlet:Get("Enabled") then
		Outlet:Set("Enabled", true)
	end

	Toggle:SetActive(false)
end)
