local assets = {
  colorsync = {
    id = 6,
    content = "if not lOS.userID then\
    self.color = colors.red\
    self.border.color = colors.black\
elseif lOS.cloudSync then\
    self.color = colors.orange\
    self.border.color = colors.red\
elseif self.color == colors.orange then\
    self.color = colors.blue\
    self.border.color = colors.cyan\
end",
    name = "colorsync",
  },
  [ "open_folder.lua" ] = {
    id = 1,
    content = "lOS.execute(\"LevelOS/explorer.lua User/Cloud\")",
    name = "open_folder.lua",
  },
  [ "sync_click.lua" ] = {
    id = 7,
    content = "while true do\
    e = {os.pullEvent()}\
    if e[1] == \"mouse_click\" or e[1] == \"mouse_up\" then\
        if e[3] >= self.x1 and e[4] >= self.y1 and e[3] <= self.x2 and e[4] <= self.y2 then\
            if e[1] == \"mouse_click\" then\
                self.oldcolor = self.txtcolor\
                self.txtcolor = colors.lightBlue\
            else\
                --shell.run(\"pastebin run 4DaaHGRP\")\
                if not lOS.cloudSync then\
                    lOS.cloudTimer = 30\
                end\
            end\
        end\
        if e[1] == \"mouse_up\" and self.oldcolor then\
            self.txtcolor = self.oldcolor\
            self.oldcolor = nil\
        end\
    end\
end",
    name = "sync_click.lua",
  },
  colorsync2 = {
    id = 8,
    content = "if not lOS.userID then\
    self.color = colors.red\
    self.txt = \" Offline\"\
elseif lOS.cloudSync then\
    self.color = colors.orange\
    self.txt = \" Syncing...\"\
elseif self.color == colors.orange then\
    self.color = colors.blue\
    self.txt = \"LevelCloud\"\
end",
    name = "colorsync2",
  },
  [ "log.lua" ] = {
    id = 3,
    content = "local c = 0\
local scr = 0\
local scroll = 0\
local lasty = 0\
term.setBackgroundColor(colors.gray)\
term.clear()\
while true do\
    if scr ~= scroll or #lOS.cloudLog ~= c or lOS.cloudSync then\
        c = #lOS.cloudLog\
        if c > 40 then\
            for t=1,c-40 do\
                table.remove(lOS.cloudLog,t)\
            end\
        end\
        scr = scroll\
        c = #lOS.cloudLog\
        local l  = lOS.cloudLog\
        term.setBackgroundColor(colors.gray)\
        term.clear()\
        local y = 2-scroll\
        for t=c,1,-1 do\
            term.setCursorPos(1,y)\
            if l[t].action == \"Upload\" then\
                term.setTextColor(colors.blue)\
                term.write(\"\\24 \")\
            elseif l[t].action == \"Download\" then\
                term.setTextColor(colors.lime)\
                term.write(\"\\25 \")\
            elseif l[t].action == \"Deleted\" then\
                term.setTextColor(colors.red)\
                term.write(\"× \")\
            end\
            term.setTextColor(colors.white)\
            term.write(fs.getName(l[t].destination))\
            y = y+1\
            local dif = os.epoch(\"utc\")-l[t].timestamp\
            dif = math.floor(dif/1000)\
            term.setTextColor(colors.lightGray)\
            term.setCursorPos(1,y)\
            if dif <= 0 then\
                term.write(\"Just now\")\
            elseif dif == 1 then\
                term.write(\"1 second ago\")\
            elseif dif < 60 then\
                term.write(dif..\" seconds ago\")\
            elseif dif < 3600 then\
                term.write(math.floor(dif/60)..\" minute(s) ago\")\
            elseif dif < 86400 then\
                term.write(math.floor(dif/3600)..\" hour(s) ago\")\
            else\
                term.write(math.floor(dif/86400)..\" day(s) ago\")\
            end\
            y = y+1\
            term.setCursorPos(1,y)\
            term.setTextColor(colors.lightGray)\
            term.write(\"In \")\
            term.setTextColor(colors.cyan)\
            local loc = fs.getDir(l[t].destination)\
            if loc == \"\" then loc = \"Cloud\" end\
            term.write(loc)\
            term.setTextColor(colors.white)\
            y = y+2\
        end\
        lasty = y\
    end\
    e = {os.pullEvent()}\
    if e[1] == \"mouse_scroll\" and e[3] >= self.x1 and e[4] >= self.y1 and e[3] <= self.x2 and e[4] <= self.y2 then\
        if scroll+e[2] >= 0 then\
            scroll = scroll+e[2]\
        end\
    end\
end",
    name = "log.lua",
  },
  [ "resync.lua" ] = {
    id = 5,
    content = "if not lOS.cloudSync then\
    --shell.run(\"pastebin run 4DaaHGRP\")\
    lOS.cloudTimer = 30\
end",
    name = "resync.lua",
  },
  [ "coroclick.lua" ] = {
    id = 2,
    content = "while true do\
    e = {os.pullEvent()}\
    if e[1] == \"mouse_click\" or e[1] == \"mouse_up\" then\
        if e[3] >= self.x1 and e[4] >= self.y1 and e[3] <= self.x2 and e[4] <= self.y2 then\
            if e[1] == \"mouse_click\" then\
                self.oldcolor = self.txtcolor\
                self.txtcolor = colors.lightBlue\
            else\
                -- stupid bitch\
                --self.color = self.oldcolor or self.color\
            end\
        end\
        if e[1] == \"mouse_up\" and self.oldcolor then\
            self.txtcolor = self.oldcolor\
            self.oldcolor = nil\
        end\
    end\
end",
    name = "coroclick.lua",
  },
  [ "log_out.lua" ] = {
    id = 4,
    content = "if not lOS.cloudSync then\
    lUtils.logout()\
    lOS.cloudTimer = 30\
end",
    name = "log_out.lua",
  },
  [ "close_click.lua" ] = {
    id = 9,
    content = "local function dClose()\
while true do\
    local e = {os.pullEvent()}\
    --local x1,y1 = LevelOS.self.window.win.getPosition()\
    --local w,h = LevelOS.self.window.win.getSize()\
    --local x2,y2 = x1+(w-1),y1+(h-1)\
    if e[1] == \"mouse_up\" and e[3] == self.x1 and e[4] == self.y1 then\
        shapescape.exit()\
    --elseif e[1] == \"mouse_click\" and (e[3] < x1 or e[4] < y1 or e[3] > x2 or e[4] > y2) then\
    --elseif lOS.wins[#lOS.wins] ~= LevelOS.self.window then\
        --shapescape.exit()\
    end\
end\
end\
local ok,err = pcall(dClose)\
self.txt = err",
    name = "close_click.lua",
  },
  [ "init.lua" ] = {
    id = 0,
    content = "if not self.init then\
    if not fs.exists(\"LevelOS/startup/LevelCloud.lua\") then\
        --LevelOS.maximize()\
        term.setBackgroundColor(colors.white)\
        term.clear()\
        os.queueEvent(\"term_resize\")\
        os.pullEvent()\
        local a = {lUtils.popup(\"LevelCloud\",\"Do you want to install LevelCloud?\",27,9,{\"Install\",\"Cancel\"})}\
        if a[1] and a[3] == \"Install\" then\
            local oterm = term.current()\
            local nterm = window.create(term.current(),1,1,51,19,false)\
            term.redirect(nterm)\
            shell.run(\"pastebin run dpvaHXd0 TtdGcKJr LevelOS/startup/LevelCloud.lua\")\
            term.redirect(oterm)\
            local b = {lUtils.popup(\"LevelCloud\",\"LevelCloud installed. Please reboot to synchronize.\",27,9,{\"Reboot\",\"Later\"})}\
            if b[1] and b[3] == \"Reboot\" then\
                lOS.save()\
                os.reboot()\
            end\
        end\
        shapescape.exit()\
    end\
    local w,h = lOS.wAll.getSize()\
    local th = 14\
    if h > 32 then\
        th = 25\
    end\
    LevelOS.self.window.win.reposition(w-30,h-(th+1),25,th)\
    LevelOS.setWin(25,th,\"borderless\")\
    \
    self.init = true\
end",
    name = "init.lua",
  },
}

local nAssets = {}
for key,value in pairs(assets) do nAssets[key] = value nAssets[assets[key].id] = assets[key] end
assets = nAssets
nAssets = nil

local slides = {
  {
    y = 20,
    x = 61,
    h = 19,
    w = 51,
    objs = {
      {
        txt = "helo am veri cool",
        type = "text",
        color = 0,
        y2 = 17,
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        x1 = 27,
        y1 = 17,
        x2 = 44,
        border = {
          color = 0,
          type = 1,
        },
        input = false,
        txtcolor = 1,
      },
      {
        type = "rect",
        x2 = 51,
        y2 = 19,
        y1 = 1,
        x1 = 1,
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = 0,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        ox2 = 0,
        color = 128,
        border = {
          color = 256,
          type = 1,
        },
        snap = {
          Top = "Snap top",
          Right = "Snap right",
          Left = "Snap left",
          Bottom = "Snap bottom",
        },
        oy2 = 0,
      },
      {
        type = "window",
        border = {
          color = 0,
          type = 1,
        },
        x2 = 50,
        y2 = 16,
        y1 = 4,
        x1 = 2,
        ox2 = 1,
        color = 32768,
        oy2 = 3,
        snap = {
          Top = "Snap top",
          Right = "Snap right",
          Left = "Snap left",
          Bottom = "Snap bottom",
        },
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = 3,
          },
        },
      },
      {
        type = "rect",
        x2 = 51,
        y2 = 3,
        border = {
          color = 512,
          type = 1,
        },
        x1 = 1,
        y1 = 1,
        ox2 = 0,
        color = 2048,
        snap = {
          Top = "Snap top",
          Right = "Snap right",
          Left = "Snap left",
          Bottom = "Snap top",
        },
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = 6,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
      },
      {
        x2 = 32,
        y2 = 2,
        x1 = 21,
        ox1 = 5,
        txt = "LevelCloud",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = 8,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        txtcolor = 1,
        ox2 = -6,
        border = {
          color = 0,
          type = 1,
        },
        input = false,
        color = 2048,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        y1 = 2,
      },
      {
        color = 128,
        y2 = 19,
        border = {
          color = 256,
          type = 1,
        },
        x1 = 1,
        oy1 = 2,
        type = "rect",
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        ox2 = 0,
        y1 = 17,
        x2 = 51,
        snap = {
          Top = "Snap bottom",
          Right = "Snap right",
          Left = "Snap left",
          Bottom = "Snap bottom",
        },
        oy2 = 0,
      },
      {
        x2 = 13,
        y2 = 18,
        x1 = 3,
        oy1 = 1,
        txt = "Open folder",
        type = "text",
        oy2 = 1,
        txtcolor = 512,
        border = {
          color = 0,
          type = 1,
        },
        event = {
          mouse_up = {
            [ 2 ] = 1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = 2,
          },
        },
        input = false,
        color = 128,
        snap = {
          Top = "Snap bottom",
          Right = "Snap left",
          Left = "Snap left",
          Bottom = "Snap bottom",
        },
        y1 = 18,
      },
      {
        color = 128,
        y2 = 18,
        x1 = 43,
        ox1 = 8,
        oy1 = 1,
        txt = "Log out",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = 4,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = 2,
          },
        },
        ox2 = 2,
        txtcolor = 512,
        border = {
          color = 0,
          type = 1,
        },
        x2 = 49,
        input = false,
        y1 = 18,
        snap = {
          Top = "Snap bottom",
          Right = "Snap right",
          Left = "Snap right",
          Bottom = "Snap bottom",
        },
        oy2 = 1,
      },
      {
        x2 = 49,
        y2 = 2,
        x1 = 49,
        ox1 = 2,
        txt = "",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = 7,
          },
        },
        txtcolor = 1,
        ox2 = 2,
        y1 = 2,
        input = false,
        color = 0,
        snap = {
          Top = "Snap top",
          Right = "Snap right",
          Left = "Snap right",
          Bottom = "Snap top",
        },
        border = {
          color = 0,
          type = 1,
        },
      },
      {
        x2 = 3,
        y2 = 2,
        y1 = 2,
        x1 = 3,
        txt = "×",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = 9,
          },
        },
        txtcolor = 1,
        input = false,
        color = 0,
        snap = {
          Top = "Snap top",
          Right = "Snap left",
          Left = "Snap left",
          Bottom = "Snap top",
        },
        border = {
          color = 0,
          type = 1,
        },
      },
    },
    c = 1,
  },
  {
    y = 20,
    x = 61,
    h = 19,
    w = 51,
    objs = {},
    c = 2,
  },
}

for s=1,#slides do
		local slide = slides[s]
		for o=1,#slide.objs do
			local obj = slide.objs[o]
			for key,value in pairs(obj.event) do
				if assets[ value[2] ] then
					lUtils.shapescape.addScript(obj,value[2],key,assets,LevelOS,slides)
				else
					obj.event[key] = {function() end,-1}
				end
			end
		end
	end

		local tArgs = {...}
	if tArgs[1] and tArgs[1] == "load" then
		return {assets=assets,slides=slides}
	end

	
	lUtils.shapescape.run(slides)