local a={debugger=true,version=1}local b;local c={}local d={}local e=term.current()local f=string.sub;local g={[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"}local h={basaltBG=colors.lightGray,basaltFG=colors.black,FrameBG=colors.gray,FrameFG=colors.black,ButtonBG=colors.gray,ButtonFG=colors.black,CheckboxBG=colors.gray,CheckboxFG=colors.black,InputBG=colors.gray,InputFG=colors.black,textfieldBG=colors.gray,textfieldFG=colors.black,listBG=colors.gray,listFG=colors.black,dropdownBG=colors.gray,dropdownFG=colors.black,radioBG=colors.gray,radioFG=colors.black,selectionBG=colors.black,selectionFG=colors.lightGray}local i={{"\32\32\32\137\156\148\158\159\148\135\135\144\159\139\32\136\157\32\159\139\32\32\143\32\32\143\32\32\32\32\32\32\32\32\147\148\150\131\148\32\32\32\151\140\148\151\140\147","\32\32\32\149\132\149\136\156\149\144\32\133\139\159\129\143\159\133\143\159\133\138\32\133\138\32\133\32\32\32\32\32\32\150\150\129\137\156\129\32\32\32\133\131\129\133\131\132","\32\32\32\130\131\32\130\131\32\32\129\32\32\32\32\130\131\32\130\131\32\32\32\32\143\143\143\32\32\32\32\32\32\130\129\32\130\135\32\32\32\32\131\32\32\131\32\131","\139\144\32\32\143\148\135\130\144\149\32\149\150\151\149\158\140\129\32\32\32\135\130\144\135\130\144\32\149\32\32\139\32\159\148\32\32\32\32\159\32\144\32\148\32\147\131\132","\159\135\129\131\143\149\143\138\144\138\32\133\130\149\149\137\155\149\159\143\144\147\130\132\32\149\32\147\130\132\131\159\129\139\151\129\148\32\32\139\131\135\133\32\144\130\151\32","\32\32\32\32\32\32\130\135\32\130\32\129\32\129\129\131\131\32\130\131\129\140\141\132\32\129\32\32\129\32\32\32\32\32\32\32\131\131\129\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\159\154\133\133\133\144\152\141\132\133\151\129\136\153\32\32\154\32\159\134\129\130\137\144\159\32\144\32\148\32\32\32\32\32\32\32\32\32\32\32\151\129","\32\32\32\32\133\32\32\32\32\145\145\132\141\140\132\151\129\144\150\146\129\32\32\32\138\144\32\32\159\133\136\131\132\131\151\129\32\144\32\131\131\129\32\144\32\151\129\32","\32\32\32\32\129\32\32\32\32\130\130\32\32\129\32\129\32\129\130\129\129\32\32\32\32\130\129\130\129\32\32\32\32\32\32\32\32\133\32\32\32\32\32\129\32\129\32\32","\150\156\148\136\149\32\134\131\148\134\131\148\159\134\149\136\140\129\152\131\32\135\131\149\150\131\148\150\131\148\32\148\32\32\148\32\32\152\129\143\143\144\130\155\32\134\131\148","\157\129\149\32\149\32\152\131\144\144\131\148\141\140\149\144\32\149\151\131\148\32\150\32\150\131\148\130\156\133\32\144\32\32\144\32\130\155\32\143\143\144\32\152\129\32\134\32","\130\131\32\131\131\129\131\131\129\130\131\32\32\32\129\130\131\32\130\131\32\32\129\32\130\131\32\130\129\32\32\129\32\32\133\32\32\32\129\32\32\32\130\32\32\32\129\32","\150\140\150\137\140\148\136\140\132\150\131\132\151\131\148\136\147\129\136\147\129\150\156\145\138\143\149\130\151\32\32\32\149\138\152\129\149\32\32\157\152\149\157\144\149\150\131\148","\149\143\142\149\32\149\149\32\149\149\32\144\149\32\149\149\32\32\149\32\32\149\32\149\149\32\149\32\149\32\144\32\149\149\130\148\149\32\32\149\32\149\149\130\149\149\32\149","\130\131\129\129\32\129\131\131\32\130\131\32\131\131\32\131\131\129\129\32\32\130\131\32\129\32\129\130\131\32\130\131\32\129\32\129\131\131\129\129\32\129\129\32\129\130\131\32","\136\140\132\150\131\148\136\140\132\153\140\129\131\151\129\149\32\149\149\32\149\149\32\149\137\152\129\137\152\129\131\156\133\149\131\32\150\32\32\130\148\32\152\137\144\32\32\32","\149\32\32\149\159\133\149\32\149\144\32\149\32\149\32\149\32\149\150\151\129\138\155\149\150\130\148\32\149\32\152\129\32\149\32\32\32\150\32\32\149\32\32\32\32\32\32\32","\129\32\32\130\129\129\129\32\129\130\131\32\32\129\32\130\131\32\32\129\32\129\32\129\129\32\129\32\129\32\131\131\129\130\131\32\32\32\129\130\131\32\32\32\32\140\140\132","\32\154\32\159\143\32\149\143\32\159\143\32\159\144\149\159\143\32\159\137\145\159\143\144\149\143\32\32\145\32\32\32\145\149\32\144\32\149\32\143\159\32\143\143\32\159\143\32","\32\32\32\152\140\149\151\32\149\149\32\145\149\130\149\157\140\133\32\149\32\154\143\149\151\32\149\32\149\32\144\32\149\149\153\32\32\149\32\149\133\149\149\32\149\149\32\149","\32\32\32\130\131\129\131\131\32\130\131\32\130\131\129\130\131\129\32\129\32\140\140\129\129\32\129\32\129\32\137\140\129\130\32\129\32\130\32\129\32\129\129\32\129\130\131\32","\144\143\32\159\144\144\144\143\32\159\143\144\159\138\32\144\32\144\144\32\144\144\32\144\144\32\144\144\32\144\143\143\144\32\150\129\32\149\32\130\150\32\134\137\134\134\131\148","\136\143\133\154\141\149\151\32\129\137\140\144\32\149\32\149\32\149\154\159\133\149\148\149\157\153\32\154\143\149\159\134\32\130\148\32\32\149\32\32\151\129\32\32\32\32\134\32","\133\32\32\32\32\133\129\32\32\131\131\32\32\130\32\130\131\129\32\129\32\130\131\129\129\32\129\140\140\129\131\131\129\32\130\129\32\129\32\130\129\32\32\32\32\32\129\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32","\32\32\32\32\145\32\159\139\32\151\131\132\155\143\132\134\135\145\32\149\32\158\140\129\130\130\32\152\147\155\157\134\32\32\144\144\32\32\32\32\32\32\152\131\155\131\131\129","\32\32\32\32\149\32\149\32\145\148\131\32\149\32\149\140\157\132\32\148\32\137\155\149\32\32\32\149\154\149\137\142\32\153\153\32\131\131\149\131\131\129\149\135\145\32\32\32","\32\32\32\32\129\32\130\135\32\131\131\129\134\131\132\32\129\32\32\129\32\131\131\32\32\32\32\130\131\129\32\32\32\32\129\129\32\32\32\32\32\32\130\131\129\32\32\32","\150\150\32\32\148\32\134\32\32\132\32\32\134\32\32\144\32\144\150\151\149\32\32\32\32\32\32\145\32\32\152\140\144\144\144\32\133\151\129\133\151\129\132\151\129\32\145\32","\130\129\32\131\151\129\141\32\32\142\32\32\32\32\32\149\32\149\130\149\149\32\143\32\32\32\32\142\132\32\154\143\133\157\153\132\151\150\148\151\158\132\151\150\148\144\130\148","\32\32\32\140\140\132\32\32\32\32\32\32\32\32\32\151\131\32\32\129\129\32\32\32\32\134\32\32\32\32\32\32\32\129\129\32\129\32\129\129\130\129\129\32\129\130\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\150\151\129\150\131\132\140\143\144\143\141\145\137\140\148\141\141\144\157\142\32\159\140\32\151\134\32\157\141\32","\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\151\151\32\154\143\132\157\140\32\157\140\32\157\140\32\157\140\32\32\149\32\32\149\32\32\149\32\32\149\32","\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\131\129\32\134\32\131\131\129\131\131\129\131\131\129\131\131\129\130\131\32\130\131\32\130\131\32\130\131\32","\151\131\148\152\137\145\155\140\144\152\142\145\153\140\132\153\137\32\154\142\144\155\159\132\150\156\148\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\136\32\151\140\132","\151\32\149\151\155\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\152\137\144\157\129\149\149\32\149\149\32\149\149\32\149\149\32\149\130\150\32\32\157\129\149\32\149","\131\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\129\32\130\131\32\133\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\159\159\144\152\140\144\156\143\32\159\141\129\153\140\132\157\141\32\130\145\32\32\147\32\136\153\32\130\146\32","\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\149\157\134\154\143\132\157\140\133\157\140\133\157\140\133\157\140\133\32\149\32\32\149\32\32\149\32\32\149\32","\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\130\131\32\134\32\130\131\129\130\131\129\130\131\129\130\131\129\32\129\32\32\129\32\32\129\32\32\129\32","\159\134\144\137\137\32\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\32\132\32\159\143\32\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\138\32\146\130\144","\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\131\147\129\138\134\149\149\32\149\149\32\149\149\32\149\149\32\149\154\143\149\32\157\129\154\143\149","\130\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\129\130\131\129\130\131\129\130\131\129\140\140\129\130\131\32\140\140\129"},{[[000110000110110000110010101000000010000000100101]],[[000000110110000000000010101000000010000000100101]],[[000000000000000000000000000000000000000000000000]],[[100010110100000010000110110000010100000100000110]],[[000000110000000010110110000110000000000000110000]],[[000000000000000000000000000000000000000000000000]],[[000000110110000010000000100000100000000000000010]],[[000000000110110100010000000010000000000000000100]],[[000000000000000000000000000000000000000000000000]],[[010000000000100110000000000000000000000110010000]],[[000000000000000000000000000010000000010110000000]],[[000000000000000000000000000000000000000000000000]],[[011110110000000100100010110000000100000000000000]],[[000000000000000000000000000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[110000110110000000000000000000010100100010000000]],[[000010000000000000110110000000000100010010000000]],[[000000000000000000000000000000000000000000000000]],[[010110010110100110110110010000000100000110110110]],[[000000000000000000000110000000000110000000000000]],[[000000000000000000000000000000000000000000000000]],[[010100010110110000000000000000110000000010000000]],[[110110000000000000110000110110100000000010000000]],[[000000000000000000000000000000000000000000000000]],[[000100011111000100011111000100011111000100011111]],[[000000000000100100100100011011011011111111111111]],[[000000000000000000000000000000000000000000000000]],[[000100011111000100011111000100011111000100011111]],[[000000000000100100100100011011011011111111111111]],[[100100100100100100100100100100100100100100100100]],[[000000110100110110000010000011110000000000011000]],[[000000000100000000000010000011000110000000001000]],[[000000000000000000000000000000000000000000000000]],[[010000100100000000000000000100000000010010110000]],[[000000000000000000000000000000110110110110110000]],[[000000000000000000000000000000000000000000000000]],[[110110110110110110000000110110110110110110110110]],[[000000000000000000000110000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[000000000000110110000110010000000000000000010010]],[[000010000000000000000000000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[110110110110110110110000110110110110000000000000]],[[000000000000000000000110000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[110110110110110110110000110000000000000000010000]],[[000000000000000000000000100000000000000110000110]],[[000000000000000000000000000000000000000000000000]]}}local j={}local k={}do local l=0;local m=#i[1]local n=#i[1][1]for o=1,m,3 do for p=1,n,3 do local q=string.char(l)local r={}r[1]=i[1][o]:sub(p,p+2)r[2]=i[1][o+1]:sub(p,p+2)r[3]=i[1][o+2]:sub(p,p+2)local s={}s[1]=i[2][o]:sub(p,p+2)s[2]=i[2][o+1]:sub(p,p+2)s[3]=i[2][o+2]:sub(p,p+2)k[q]={r,s}l=l+1 end end;j[1]=k end;local function t(u,v)local w={["0"]="1",["1"]="0"}if u<=#j then return true end;for x=#j+1,u do local y={}local z=j[x-1]for l=0,255 do local q=string.char(l)local r={}local s={}local A=z[q][1]local B=z[q][2]for o=1,#A do local C,D,E,F,G,H={},{},{},{},{},{}for p=1,#A[1]do local I=k[A[o]:sub(p,p)][1]table.insert(C,I[1])table.insert(D,I[2])table.insert(E,I[3])local J=k[A[o]:sub(p,p)][2]if B[o]:sub(p,p)=="1"then table.insert(F,J[1]:gsub("[01]",w))table.insert(G,J[2]:gsub("[01]",w))table.insert(H,J[3]:gsub("[01]",w))else table.insert(F,J[1])table.insert(G,J[2])table.insert(H,J[3])end end;table.insert(r,table.concat(C))table.insert(r,table.concat(D))table.insert(r,table.concat(E))table.insert(s,table.concat(F))table.insert(s,table.concat(G))table.insert(s,table.concat(H))end;y[q]={r,s}if v then v="Font"..x.."Yeld"..l;os.queueEvent(v)os.pullEvent(v)end end;j[x]=y end;return true end;t(3,false)local function K(L,M,N,O,P)if not type(M)=="string"then error("Not a String",3)end;print(g,N)local Q=type(N)=="string"and N:sub(1,1)or g[N]or error("Wrong Front Color",3)local R=type(O)=="string"and O:sub(1,1)or g[O]or error("Wrong Back Color",3)local S=j[L]or error("Wrong font size selected",3)if M==""then return{{""},{""},{""}}end;local T={}for o in M:gmatch('.')do table.insert(T,o)end;local U={}local m=#S[T[1]][1]for V=1,m do local W={}for o=1,#T do W[o]=S[T[o]]and S[T[o]][1][V]or""end;U[V]=table.concat(W)end;local X={}local Y={}local Z={["0"]=Q,["1"]=R}local _={["0"]=R,["1"]=Q}for V=1,m do local a0={}local a1={}for o=1,#T do local a2=S[T[o]]and S[T[o]][2][V]or""a0[o]=a2:gsub("[01]",P and{["0"]=N:sub(o,o),["1"]=O:sub(o,o)}or Z)a1[o]=a2:gsub("[01]",P and{["0"]=O:sub(o,o),["1"]=N:sub(o,o)}or _)end;X[V]=table.concat(a0)Y[V]=table.concat(a1)end;return{U,X,Y}end;local function a3()local a4=e;local a5,m=a4.getSize()local a6={}local a7={}local a8={}local a9={}local aa={}local ab={}local ac;local ad={}local function ae()ac=(" "):rep(a5)for af=0,15 do local ag=2^af;local ah=g[ag]ad[ag]=ah:rep(a5)end end;ae()local function ai()local aj=ac;local ak=ad[colors.white]local al=ad[colors.black]for am=1,m do a6[am]=f(a6[am]==nil and aj or a6[am]..aj:sub(1,a5-a6[am]:len()),1,a5)a8[am]=f(a8[am]==nil and ak or a8[am]..ak:sub(1,a5-a8[am]:len()),1,a5)a7[am]=f(a7[am]==nil and al or a7[am]..al:sub(1,a5-a7[am]:len()),1,a5)end end;ai()local function an(ao,ap,aq)if ap>=1 and ap<=m then if ao+aq:len()>0 and ao<=a5 then local ar=a6[ap]local as;local at=ao+#aq-1;if ao<1 then local au=1-ao+1;local av=a5-ao+1;aq=f(aq,au,av)elseif at>a5 then local av=a5-ao+1;aq=f(aq,1,av)end;if ao>1 then local av=ao-1;as=f(ar,1,av)..aq else as=aq end;if at=1 and ap<=m then if ao+ax:len()>0 and ao<=a5 then local ar=a7[ap]local as;local at=ao+#ax-1;if ao<1 then ax=f(ax,1-ao+1,a5-ao+1)elseif at>a5 then ax=f(ax,1,a5-ao+1)end;if ao>1 then as=f(ar,1,ao-1)..ax else as=ax end;if at=1 and ap<=m then if ao+ax:len()>0 and ao<=a5 then local ar=a8[ap]local as;local at=ao+#ax-1;if ao<1 then local au=1-ao+1;local av=a5-ao+1;ax=f(ax,au,av)elseif at>a5 then local av=a5-ao+1;ax=f(ax,1,av)end;if ao>1 then local av=ao-1;as=f(ar,1,av)..ax else as=ax end;if at1 then while#bf>2 do table.sort(bf,function(bp,bq)return bp[2]>bq[2]end)local br,bs=be(bf),#bf;local bt,bu=bf[bs][1],bf[br][1]for o=1,6 do if bj[o]==bt then bj[o]=bu;bf[br][2]=bf[br][2]+1 end end;bf[bs]=nil end;local bv=128;for o=1,#bj-1 do if bj[o]~=bj[6]then bv=bv+2^(o-1)end end;return string.char(bv),bb[bf[1][1]==bj[6]and bf[2][1]or bf[1][1]],bb[bj[6]]else return"\128",bb[bj[1]],bb[bj[1]]end end;local bw,a5,m,aA={{},{},{}},0,#b6+#b6%3,b7 or colors.black;for o=1,#b6 do if#b6[o]>a5 then a5=#b6[o]end end;for ap=0,m-1,3 do local bx,by,bz,bA={},{},{},1;for ao=0,a5-1,2 do local bj,bk={},{}for bB=1,3 do for bC=1,2 do bj[#bj+1]=b6[ap+bB]and b6[ap+bB][ao+bC]and(b6[ap+bB][ao+bC]==0 and aA or b6[ap+bB][ao+bC])or aA;bk[bj[#bj]]=bk[bj[#bj]]and bk[bj[#bj]]+1 or 1 end end;bx[bA],by[bA],bz[bA]=bi(bj,bk)bA=bA+1 end;bw[1][#bw[1]+1],bw[2][#bw[2]+1],bw[3][#bw[3]+1]=table.concat(bx),table.concat(by),table.concat(bz)end;bw.width,bw.height=#bw[1][1],#bw[1]return bw end;local function bD(bE)local bF="Object"local aO;local bG=1;local bH="left"local bI="top"local bJ=false;local bK=false;local bL=true;local bM=aH()local bN={x=1,y=1,width=1,height=1,bgColor=colors.black,fgColor=colors.white,name=bE or"Object",parent=nil,show=function(self)bK=true;bL=true;return self end,hide=function(self)bK=false;bL=true;return self end,isVisible=function(self)return bK end,getZIndex=function(self)return bG end,setFocus=function(self)if self.parent~=nil then self.parent:setFocusedObject(self)end;return self end,setZIndex=function(self,aJ)bG=aJ;if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end;return self end,getType=function(self)return bF end,getName=function(self)return self.name end,remove=function(self)if self.parent~=nil then self.parent:removeObject(self)end;return self end,setParent=function(self,bO)if bO.getType~=nil and bO:getType()=="Frame"then self:remove()bO:addObject(self)if self.draw then self:show()end end;return self end,setValue=function(self,bP)if aO~=bP then aO=bP;bL=true;self:valueChangedHandler()end;return self end,getValue=function(self)return aO end,getVisualChanged=function(self)return bL end,setVisualChanged=function(self,bQ)bL=bQ or true;return self end,getEventSystem=function(self)return bM end,getParent=function(self)return self.parent end,setPosition=function(self,bR,bS,bT)if bT then self.x,self.y=self.x+bR,self.y+bS else self.x,self.y=bR,bS end;bL=true;return self end,getPosition=function(self)return self.x,self.y end,getVisibility=function(self)return bK end,setVisibility=function(self,bU)bK=bU or not bK;bL=true;return self end,setSize=function(self,a5,m)self.width,self.height=a5,m;bL=true;return self end,getHeight=function(self)return self.height end,getWidth=function(self)return self.width end,getSize=function(self)return self.width,self.height end,setBackground=function(self,bV)self.bgColor=bV;bL=true;return self end,getBackground=function(self)return self.bgColor end,setForeground=function(self,bV)self.fgColor=bV;bL=true;return self end,getForeground=function(self)return self.fgColor end,draw=function(self)if bK then return true end;return false end,getAbsolutePosition=function(self,ao,ap)if ao==nil then ao=self.x end;if ap==nil then ap=self.y end;if self.parent~=nil then local bW,bX=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())ao=bW+ao-1;ap=bX+ap-1 end;return ao,ap end,getAnchorPosition=function(self,ao,ap,bY)if ao==nil then ao=self.x end;if ap==nil then ap=self.y end;if bH=="right"then ao=self.parent.width-ao-self.width+2 end;if bI=="bottom"then ap=self.parent.height-ap-self.height+2 end;local bZ,b_=self:getOffset()if bJ or bY then return ao,ap end;return ao+bZ,ap+b_ end,getOffset=function(self)if self.parent~=nil and bJ==false then return self.parent:getFrameOffset()end;return 0,0 end,ignoreOffset=function(self,c0)bJ=c0 or true;return self end,setAnchor=function(self,...)for aN,aO in pairs(table.pack(...))do if aO=="right"or aO=="left"then bH=aO end;if aO=="top"or aO=="bottom"then bI=aO end end;bL=true;return self end,getAnchor=function(self)return bH,bI end,onChange=function(self,aM)self:registerEvent("value_changed",aM)return self end,onClick=function(self,aM)self:registerEvent("mouse_click",aM)return self end,onEvent=function(self,aM)self:registerEvent("custom_event_handler",aM)return self end,onClickUp=function(self,aM)self:registerEvent("mouse_up",aM)return self end,onKey=function(self,aM)self:registerEvent("key",aM)self:registerEvent("char",aM)return self end,onKeyUp=function(self,aM)self:registerEvent("key_up",aM)return self end,onBackgroundKey=function(self,aM)self:registerEvent("background_key",aM)self:registerEvent("background_char",aM)return self end,onBackgroundKeyUp=function(self,aM)self:registerEvent("background_key_up",aM)return self end,isFocused=function(self)if self.parent~=nil then return self.parent:getFocusedObject()==self end;return false end,onGetFocus=function(self,aM)self:registerEvent("get_focus",aM)return self end,onLoseFocus=function(self,aM)self:registerEvent("lose_focus",aM)return self end,registerEvent=function(self,aK,aM)return bM:registerEvent(aK,aM)end,removeEvent=function(self,aK,aJ)return bM:removeEvent(aK,aJ)end,sendEvent=function(self,aK,...)return bM:sendEvent(aK,self,...)end,mouseClickHandler=function(self,aK,c1,ao,ap)local c2,c3=self:getAbsolutePosition(self:getAnchorPosition())if c2<=ao and c2+self.width>ao and c3<=ap and c3+self.height>ap and bK then if self.parent~=nil then self.parent:setFocusedObject(self)end;bM:sendEvent(aK,self,aK,c1,ao,ap)return true end;return false end,keyHandler=function(self,aK,bo)if self:isFocused()then bM:sendEvent(aK,self,aK,bo)return true end;return false end,backgroundKeyHandler=function(self,aK,bo)bM:sendEvent("background_"..aK,self,aK,bo)end,valueChangedHandler=function(self)bM:sendEvent("value_changed",self)end,eventHandler=function(self,aK,c4,c5,c6,c7)bM:sendEvent("custom_event_handler",self,aK,c4,c5,c6,c7)end,getFocusHandler=function(self)bM:sendEvent("get_focus",self)end,loseFocusHandler=function(self)bM:sendEvent("lose_focus",self)end}bN.__index=bN;return bN end;local function c8(bE)local bN={}local bF="Animation"local c9;local ca={}local aJ=1;local cb=0;local cc;local function cd()if ca[aJ]~=nil then ca[aJ].f(bN,aJ)end;aJ=aJ+1;if ca[aJ]~=nil then if ca[aJ].t>0 then c9=os.startTimer(ca[aJ].t)else cd()end end end;bN={name=bE,getType=function(self)return bF end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,add=function(self,aM,ce)cc=aM;table.insert(ca,{f=aM,t=ce or cb})return self end,wait=function(self,ce)cb=ce;return self end,rep=function(self,cf)for ao=1,cf do table.insert(ca,{f=cc,t=cb})end;return self end,clear=function(self)ca={}cc=nil;cb=0;aJ=1;return self end,play=function(self)aJ=1;if ca[aJ]~=nil then if ca[aJ].t>0 then c9=os.startTimer(ca[aJ].t)else cd()end end;return self end,cancel=function(self)os.cancelTimer(c9)return self end,eventHandler=function(self,aK,cg)if aK=="timer"and cg==c9 then if ca[aJ]~=nil then cd()end end end}bN.__index=bN;return bN end;local function ch(bE)local ci=bD(bE)local bF="Button"ci:setValue("Button")ci:setZIndex(5)ci.width=8;ci.bgColor=h.ButtonBG;ci.fgColor=h.ButtonFG;local cj="center"local ck="center"local bN={getType=function(self)return bF end,setHorizontalAlign=function(self,cl)cj=cl end,setVerticalAlign=function(self,cl)ck=cl end,setText=function(self,aq)ci:setValue(aq)return self end,draw=function(self)if ci.draw(self)then if self.parent~=nil then local cm,cn=self:getAnchorPosition()local co=b1(self.height,ck)self.parent:drawBackgroundBox(cm,cn,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cm,cn,self.width,self.height,self.fgColor)self.parent:drawTextBox(cm,cn,self.width,self.height," ")for af=1,self.height do if af==co then self.parent:setText(cm,cn+af-1,aY(self:getValue(),self.width,cj))end end end end end}return setmetatable(bN,ci)end;local function cp(bE)local ci=bD(bE)local bF="Checkbox"ci:setZIndex(5)ci:setValue(false)ci.width=1;ci.height=1;ci.bgColor=h.CheckboxBG;ci.fgColor=h.CheckboxFG;local bN={symbol="\42",getType=function(self)return bF end,mouseClickHandler=function(self,aK,c1,ao,ap)if ci.mouseClickHandler(self,aK,c1,ao,ap)then if aK=="mouse_click"and c1==1 then if self:getValue()~=true and self:getValue()~=false then self:setValue(false)else self:setValue(not self:getValue())end end;return true end;return false end,draw=function(self)if ci.draw(self)then if self.parent~=nil then local cm,cn=self:getAnchorPosition()local co=b1(self.height,"center")self.parent:drawBackgroundBox(cm,cn,self.width,self.height,self.bgColor)for af=1,self.height do if af==co then if self:getValue()==true then self.parent:writeText(cm,cn+af-1,aY(self.symbol,self.width,"center"),self.bgColor,self.fgColor)else self.parent:writeText(cm,cn+af-1,aY(" ",self.width,"center"),self.bgColor,self.fgColor)end end end end end end}return setmetatable(bN,ci)end;local function cq(bE)local ci=bD(bE)local bF="Dropdown"ci.width=12;ci.height=1;ci.bgColor=h.dropdownBG;ci.fgColor=h.dropdownFG;ci:setZIndex(6)local cr={}local cs=h.selectionBG;local ct=h.selectionFG;local cu=true;local cv="left"local cw=0;local cx=16;local cy=6;local cz="\16"local cA="\31"local cB=1;local bN={getType=function(self)return bF end,setIndexOffset=function(self,cC)cw=cC;return self end,getIndexOffset=function(self)return cw end,addItem=function(self,aq,aA,aB,...)table.insert(cr,{text=aq,bgCol=aA or self.bgColor,fgCol=aB or self.fgColor,args={...}})return self end,removeItem=function(self,aJ)table.remove(cr,aJ)return self end,getItem=function(self,aJ)return cr[aJ]end,getItemIndex=function(self)local cD=self:getValue()for bo,aO in pairs(cr)do if aO==cD then return bo end end end,clear=function(self)cr={}self:setValue({})return self end,getItemCount=function(self)return#cr end,editItem=function(self,aJ,aq,aA,aB,...)table.remove(cr,aJ)table.insert(cr,aJ,{text=aq,bgCol=aA or self.bgColor,fgCol=aB or self.fgColor,args={...}})return self end,selectItem=function(self,aJ)self:setValue(cr[aJ]or{})return self end,setSelectedItem=function(self,aA,aB,cE)cs=aA or self.bgColor;ct=aB or self.fgColor;cu=cE;return self end,setDropdownSize=function(self,a5,m)cx,cy=a5,m;return self end,mouseClickHandler=function(self,aK,c1,ao,ap)if cB==2 then local cm,cn=self:getAbsolutePosition(self:getAnchorPosition())if aK=="mouse_click"then if c1==1 then if#cr>0 then for af=1,cy do if cr[af+cw]~=nil then if cm<=ao and cm+cx>ao and cn+af==ap then self:setValue(cr[af+cw])return true end end end end end end;if aK=="mouse_scroll"then cw=cw+c1;if cw<0 then cw=0 end;if c1==1 then if#cr>cy then if cw>#cr-cy then cw=#cr-cy end else cw=cr-1 end end;return true end;self:setVisualChanged()end;if ci.mouseClickHandler(self,aK,c1,ao,ap)then cB=2 else cB=1 end end,draw=function(self)if ci.draw(self)then local cm,cn=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(cm,cn,self.width,self.height,self.bgColor)if#cr>=1 then if self:getValue()~=nil then if self:getValue().text~=nil then if cB==1 then self.parent:writeText(cm,cn,aY(self:getValue().text,self.width,cv):sub(1,self.width-1)..cz,self.bgColor,self.fgColor)else self.parent:writeText(cm,cn,aY(self:getValue().text,self.width,cv):sub(1,self.width-1)..cA,self.bgColor,self.fgColor)end end end;if cB==2 then for af=1,cy do if cr[af+cw]~=nil then if cr[af+cw]==self:getValue()then if cu then self.parent:writeText(cm,cn+af,aY(cr[af+cw].text,cx,cv),cs,ct)else self.parent:writeText(cm,cn+af,aY(cr[af+cw].text,cx,cv),cr[af+cw].bgCol,cr[af+cw].fgCol)end else self.parent:writeText(cm,cn+af,aY(cr[af+cw].text,cx,cv),cr[af+cw].bgCol,cr[af+cw].fgCol)end end end end end end end end}return setmetatable(bN,ci)end;local function cF(bE)local ci=bD(bE)local bF="Image"ci:setZIndex(2)local cG;local cH;local cI=false;local function b5()local b8={[0]={8,4,3,6,5},{4,14,8,7},{6,10,8,7},{9,11,8,0},{1,14,8,0},{13,12,8,0},{2,10,8,0},{15,8,10,11,12,14},{0,7,1,9,2,13},{3,11,8,7},{2,6,7,15},{9,3,7,15},{13,5,7,15},{5,12,8,7},{1,4,7,15},{7,10,11,12,14}}local b9,ba,bb={},{},{}for o=0,15 do ba[2^o]=o end;do local bc="0123456789abcdef"for o=1,16 do b9[bc:sub(o,o)]=o-1;b9[o-1]=bc:sub(o,o)bb[bc:sub(o,o)]=2^(o-1)bb[2^(o-1)]=bc:sub(o,o)local bd=b8[o-1]for o=1,#bd do bd[o]=2^bd[o]end end end;local function be(bf)local bg=b8[ba[bf[#bf][1]]]for p=1,#bg do local bh=bg[p]for o=1,#bf-1 do if bf[o][1]==bh then return o end end end;return 1 end;local function bi(bj,bk)if not bk then local bl={}bk={}for o=1,6 do local bm=bj[o]local bn=bk[bm]bk[bm],bl[o]=bn and bn+1 or 1,bm end;bj=bl end;local bf={}for bo,aO in pairs(bk)do bf[#bf+1]={bo,aO}end;if#bf>1 then while#bf>2 do table.sort(bf,function(bp,bq)return bp[2]>bq[2]end)local br,bs=be(bf),#bf;local bt,bu=bf[bs][1],bf[br][1]for o=1,6 do if bj[o]==bt then bj[o]=bu;bf[br][2]=bf[br][2]+1 end end;bf[bs]=nil end;local bv=128;for o=1,#bj-1 do if bj[o]~=bj[6]then bv=bv+2^(o-1)end end;return string.char(bv),bb[bf[1][1]==bj[6]and bf[2][1]or bf[1][1]],bb[bj[6]]else return"\128",bb[bj[1]],bb[bj[1]]end end;local bw,a5,m,aA={{},{},{}},0,#cG+#cG%3,ci.bgColor or colors.black;for o=1,#cG do if#cG[o]>a5 then a5=#cG[o]end end;for ap=0,m-1,3 do local bx,by,bz,bA={},{},{},1;for ao=0,a5-1,2 do local bj,bk={},{}for bB=1,3 do for bC=1,2 do bj[#bj+1]=cG[ap+bB]and cG[ap+bB][ao+bC]and(cG[ap+bB][ao+bC]==0 and aA or cG[ap+bB][ao+bC])or aA;bk[bj[#bj]]=bk[bj[#bj]]and bk[bj[#bj]]+1 or 1 end end;bx[bA],by[bA],bz[bA]=bi(bj,bk)bA=bA+1 end;bw[1][#bw[1]+1],bw[2][#bw[2]+1],bw[3][#bw[3]+1]=table.concat(bx),table.concat(by),table.concat(bz)end;bw.width,bw.height=#bw[1][1],#bw[1]cH=bw end;local bN={getType=function(self)return bF end,loadImage=function(self,aS)cG=paintutils.loadImage(aS)cI=false;return self end,loadBlittleImage=function(self,aS)cI=true;return self end,shrink=function(self)b5()cI=true;return self end,draw=function(self)if ci.draw(self)then if self.parent~=nil then if cG~=nil then local cm,cn=self:getAnchorPosition()if cI then local b4,cJ,cK=cH[1],cH[2],cH[3]for o=1,cH.height do local cL=b4[o]if type(cL)=="string"then self.parent:setText(cm,cn+o-1,cL)self.parent:setFG(cm,cn+o-1,cJ[o])self.parent:setBG(cm,cn+o-1,cK[o])elseif type(cL)=="table"then self.parent:setText(cm,cn+o-1,cL[2])self.parent:setFG(cm,cn+o-1,cJ[o])self.parent:setBG(cm,cn+o-1,cK[o])end end else for bS=1,math.min(#cG,self.height)do local cM=cG[bS]for bR=1,math.min(#cM,self.width)do if cM[bR]>0 then self.parent:drawBackgroundBox(cm+bR-1,cn+bS-1,1,1,cM[bR])end end end end end end end end}return setmetatable(bN,ci)end;local function cN(bE)local ci=bD(bE)local bF="Input"local cO="text"local cP=0;ci:setZIndex(5)ci:setValue("")ci.width=10;ci.height=1;ci.bgColor=h.InputBG;ci.fgColor=h.InputFG;local cQ=1;local cR=1;local cS=""local cT;local cU;local cV=cS;local cW=false;local bN={getType=function(self)return bF end,setInputType=function(self,cX)if cX=="password"or cX=="number"or cX=="text"then cO=cX end;return self end,setDefaultText=function(self,aq,cY,cZ)cS=aq;cT=cZ or cT;cU=cY or cU;if self:isFocused()then cV=""else cV=cS end;return self end,getInputType=function(self)return cO end,setValue=function(self,c_)ci.setValue(self,tostring(c_))if not cW then cQ=tostring(c_):len()+1 end;return self end,getValue=function(self)local c_=ci.getValue(self)return cO=="number"and tonumber(c_)or c_ end,setInputLimit=function(self,d0)cP=tonumber(d0)or cP;return self end,getInputLimit=function(self)return cP end,getFocusHandler=function(self)ci.getFocusHandler(self)if self.parent~=nil then local cm,cn=self:getAnchorPosition()cV=""if self.parent~=nil then self.parent:setCursor(true,cm+cQ-cR,cn,self.fgColor)end end end,loseFocusHandler=function(self)ci.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)cV=cS end end,keyHandler=function(self,aK,bo)if ci.keyHandler(self,aK,bo)then cW=true;if aK=="key"then if bo==keys.backspace then local aq=tostring(ci.getValue())if cQ>1 then self:setValue(aq:sub(1,cQ-2)..aq:sub(cQ,aq:len()))if cQ>1 then cQ=cQ-1 end;if cR>1 then if cQd1 then cQ=d1+1 end;if cQ<1 then cQ=1 end;if cQ=self.width+cR then cR=cQ-self.width+1 end;if cR<1 then cR=1 end end;if bo==keys.left then cQ=cQ-1;if cQ>=1 then if cQ=self.width+cR then cR=cQ end end;if cQ<1 then cQ=1 end;if cR<1 then cR=1 end end end;if aK=="char"then local aq=ci.getValue()if aq:len()=self.width+cR then cR=cR+1 end end end;local cm,cn=self:getAnchorPosition()local c_=tostring(ci.getValue())local d3=(cQ<=c_:len()and cQ-1 or c_:len())-(cR-1)if d3>self.x+self.width-1 then d3=self.x+self.width-1 end;if self.parent~=nil then self.parent:setCursor(true,cm+d3,cn,self.fgColor)end;cW=false end end,mouseClickHandler=function(self,aK,c1,ao,ap)if ci.mouseClickHandler(self,aK,c1,ao,ap)then if aK=="mouse_click"and c1==1 then end;return true end;return false end,draw=function(self)if ci.draw(self)then if self.parent~=nil then local cm,cn=self:getAnchorPosition()local co=b1(self.height,"center")self.parent:drawBackgroundBox(cm,cn,self.width,self.height,self.bgColor)for af=1,self.height do if af==co then local c_=tostring(ci.getValue())local cZ=self.bgColor;local cY=self.fgColor;local aq;if c_:len()<=0 then aq=cV;cZ=cT or cZ;cY=cU or cY end;aq=cV;if c_~=""then aq=c_ end;aq=aq:sub(cR,self.width+cR-1)local d4=self.width-aq:len()if d4<0 then d4=0 end;if cO=="password"and c_~=""then aq=string.rep("*",aq:len())end;aq=aq..string.rep(" ",d4)self.parent:writeText(cm,cn+af-1,aq,cZ,cY)end end end end end}return setmetatable(bN,ci)end;local function d5(bE)local ci=bD(bE)local bF="Label"ci:setZIndex(3)ci.fgColor=colors.white;ci.bgcolor=colors.black;local d6=true;ci:setValue("")local cj="left"local ck="top"local d7=0;local bN={getType=function(self)return bF end,setText=function(self,aq)aq=tostring(aq)ci:setValue(aq)if d6 then self.width=aq:len()end;return self end,setTextAlign=function(self,d8,d9)cj=d8 or cj;ck=d9 or ck;self:setVisualChanged()return self end,setFontSize=function(self,u)if u>0 and u<=4 then d7=u-1 or 0 end;return self end,getFontSize=function(self)return d7+1 end,setSize=function(self,a5,m)ci.setSize(self,a5,m)d6=false;self:setVisualChanged()return self end,draw=function(self)if ci.draw(self)then if self.parent~=nil then local cm,cn=self:getAnchorPosition()local co=b1(self.height,ck)self.parent:drawBackgroundBox(cm,cn,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cm,cn,self.width,self.height,self.fgColor)self.parent:drawTextBox(cm,cn,self.width,self.height," ")if d7==0 then for af=1,self.height do if af==co then self.parent:writeText(cm,cn+af-1,aY(self:getValue(),self.width,cj),self.bgColor,self.fgColor)end end else local da=K(d7,self:getValue(),self.fgColor,self.bgColor)for af=1,self.height do if af==co then local db,dc=self.parent:getSize()local dd,de=#da[1][1],#da[1]cm=cm or math.floor((db-dd)/2)+1;cn=cn or math.floor((dc-de)/2)+1;for o=1,de do self.parent:setFG(cm,cn+o+af-2,aY(da[2][o],self.width,cj))self.parent:setBG(cm,cn+o+af-2,aY(da[3][o],self.width,cj,g[self.bgColor]))self.parent:setText(cm,cn+o+af-2,aY(da[1][o],self.width,cj))end end end end end end end}return setmetatable(bN,ci)end;local function df(bE)local ci=bD(bE)local bF="List"ci.width=16;ci.height=6;ci.bgColor=h.listBG;ci.fgColor=h.listFG;ci:setZIndex(5)local cr={}local cs=h.selectionBG;local ct=h.selectionFG;local cu=true;local cv="left"local cw=0;local dg=true;local bN={getType=function(self)return bF end,addItem=function(self,aq,aA,aB,...)table.insert(cr,{text=aq,bgCol=aA or self.bgColor,fgCol=aB or self.fgColor,args={...}})if#cr==1 then self:setValue(cr[1])end;return self end,setIndexOffset=function(self,cC)cw=cC;return self end,getIndexOffset=function(self)return cw end,removeItem=function(self,aJ)table.remove(cr,aJ)return self end,getItem=function(self,aJ)return cr[aJ]end,getItemIndex=function(self)local cD=self:getValue()for bo,aO in pairs(cr)do if aO==cD then return bo end end end,clear=function(self)cr={}self:setValue({})return self end,getItemCount=function(self)return#cr end,editItem=function(self,aJ,aq,aA,aB,...)table.remove(cr,aJ)table.insert(cr,aJ,{text=aq,bgCol=aA or self.bgColor,fgCol=aB or self.fgColor,args={...}})return self end,selectItem=function(self,aJ)self:setValue(cr[aJ]or{})return self end,setSelectedItem=function(self,aA,aB,cE)cs=aA or self.bgColor;ct=aB or self.fgColor;cu=cE;return self end,setScrollable=function(self,dh)dg=dh;return self end,mouseClickHandler=function(self,aK,c1,ao,ap)local cm,cn=self:getAbsolutePosition(self:getAnchorPosition())if cm<=ao and cm+self.width>ao and cn<=ap and cn+self.height>ap and self:isVisible()then if aK=="mouse_click"or aK=="mouse_drag"then if c1==1 then if#cr>0 then for af=1,self.height do if cr[af+cw]~=nil then if cm<=ao and cm+self.width>ao and cn+af-1==ap then self:setValue(cr[af+cw])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,ao,ap,cr[af+cw])end end end end end end;if aK=="mouse_scroll"and dg then cw=cw+c1;if cw<0 then cw=0 end;if c1>=1 then if#cr>self.height then if cw>#cr-self.height then cw=#cr-self.height end;if cw>=#cr then cw=#cr-1 end else cw=cw-1 end end end;self:setVisualChanged()return true end end,draw=function(self)if ci.draw(self)then if self.parent~=nil then local cm,cn=self:getAnchorPosition()self.parent:drawBackgroundBox(cm,cn,self.width,self.height,self.bgColor)for af=1,self.height do if cr[af+cw]~=nil then if cr[af+cw]==self:getValue()then if cu then self.parent:writeText(cm,cn+af-1,aY(cr[af+cw].text,self.width,cv),cs,ct)else self.parent:writeText(cm,cn+af-1,aY(cr[af+cw].text,self.width,cv),cr[af+cw].bgCol,cr[af+cw].fgCol)end else self.parent:writeText(cm,cn+af-1,aY(cr[af+cw].text,self.width,cv),cr[af+cw].bgCol,cr[af+cw].fgCol)end end end end end end}return setmetatable(bN,ci)end;local function di(bE)local ci=bD(bE)local bF="Menubar"local bN={}ci.width=30;ci.height=1;ci.bgColor=colors.gray;ci.fgColor=colors.lightGray;ci:setZIndex(5)local cr={}local cs=h.selectionBG;local ct=h.selectionFG;local cu=true;local cv="left"local dj=0;local d4=2;local dg=false;local function dk()local dl=0;local bR=1;for af=1,#cr do if bR+cr[af].text:len()+d4*2>bN.w then dl=dl+cr[af].text:len()+d4*2 end;bR=bR+cr[af].text:len()+d4*2 end;return dl end;bN={getType=function(self)return bF end,addItem=function(self,aq,aA,aB,...)table.insert(cr,{text=aq,bgCol=aA or self.bgColor,fgCol=aB or self.fgColor,args={...}})if#cr==1 then self:setValue(cr[1])end;return self end,getItemIndex=function(self)local cD=self:getValue()for bo,aO in pairs(cr)do if aO==cD then return bo end end end,clear=function(self)cr={}self:setValue({})return self end,setSpace=function(self,dm)d4=dm or d4;return self end,setButtonOffset=function(self,b0)dj=b0 or 0;if dj<0 then dj=0 end;local dl=dk()if dj>dl then dj=dl end;return self end,setScrollable=function(self,dh)dg=dh;return self end,removeItem=function(self,aJ)table.remove(cr,aJ)return self end,getItem=function(self,aJ)return cr[aJ]end,getItemCount=function(self)return#cr end,editItem=function(self,aJ,aq,aA,aB,...)table.remove(cr,aJ)table.insert(cr,aJ,{text=aq,bgCol=aA or self.bgColor,fgCol=aB or self.fgColor,args={...}})return self end,selectItem=function(self,aJ)self:setValue(cr[aJ]or{})return self end,setSelectedItem=function(self,aA,aB,cE)cs=aA or self.bgColor;ct=aB or self.fgColor;cu=cE;return self end,mouseClickHandler=function(self,aK,c1,ao,ap)local c2,c3=self:getAbsolutePosition(self:getAnchorPosition())if c2<=ao and c2+self.width>ao and c3<=ap and c3+self.height>ap and self:isVisible()then if self.parent~=nil then self.parent:setFocusedObject(self)end;if aK=="mouse_click"then local bR=1;for af=1+dj,#cr do if cr[af]~=nil then if bR+cr[af].text:len()+d4*2<=self.width then if c2+bR-1<=ao and c2+bR-1+cr[af].text:len()+d4*2>ao and c3==ap then self:setValue(cr[af])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,ao,ap,cr[af])end;bR=bR+cr[af].text:len()+d4*2 else break end end end end;if aK=="mouse_scroll"and dg then dj=dj+c1;if dj<0 then dj=0 end;local dl=dk()if dj>dl then dj=dl end end;return true end;return false end,draw=function(self)if ci.draw(self)then if self.parent~=nil then local cm,cn=self:getAnchorPosition()self.parent:drawBackgroundBox(cm,cn,self.width,self.height,self.bgColor)local bR=0;for aN,aO in pairs(cr)do if bR+aO.text:len()+d4*2<=self.width then if aO==self:getValue()then self.parent:writeText(cm+bR-1+-dj,cn,aY((" "):rep(d4)..aO.text..(" "):rep(d4),aO.text:len()+d4*2,cv),cs or aO.bgCol,ct or aO.fgCol)else self.parent:writeText(cm+bR-1+-dj,cn,aY((" "):rep(d4)..aO.text..(" "):rep(d4),aO.text:len()+d4*2,cv),aO.bgCol,aO.fgCol)end;bR=bR+aO.text:len()+d4*2 else if bR=1 and ds>=1 and dr<=a5 and ds<=m then else end end;local function dz(dA,dB,dC)local dD=dr;local at=dD+#dA-1;if ds>=1 and ds<=m then if dD<=a5 and at>=1 then if dD==1 and at==a5 then a6[ds]=dA;a8[ds]=dB;a7[ds]=dC else local dE,dF,dG;if dD<1 then local dH=1-dD+1;local dI=a5-dD+1;dE=f(dA,dH,dI)dF=f(dB,dH,dI)dG=f(dC,dH,dI)elseif at>a5 then local dI=a5-dD+1;dE=f(dA,1,dI)dF=f(dB,1,dI)dG=f(dC,1,dI)else dE=dA;dF=dB;dG=dC end;local dJ=a6[ds]local dK=a8[ds]local dL=a7[ds]local dM,dN,dO;if dD>1 then local dP=dD-1;dM=f(dJ,1,dP)..dE;dN=f(dK,1,dP)..dF;dO=f(dL,1,dP)..dG else dM=dE;dN=dF;dO=dG end;if at=1 and ap<=m then a6[eb]=a6[ap]a7[eb]=a7[ap]a8[eb]=a8[ap]else a6[eb]=e8;a8[eb]=e9;a7[eb]=ea end end end;if dv then dy()end end,isColor=function()return e.isColor()end,isColour=function()return e.isColor()end,write=function(aq)aq=tostring(aq)if dv then dz(aq,g[dt]:rep(aq:len()),g[b7]:rep(aq:len()))end end,clearLine=function()if dv then an(1,ds,(" "):rep(a5))aw(1,ds,g[b7]:rep(a5))ay(1,ds,g[dt]:rep(a5))end;if dv then dy()end end,clear=function()for af=1,m do an(1,af,(" "):rep(a5))aw(1,af,g[b7]:rep(a5))ay(1,af,g[dt]:rep(a5))end;if dv then dy()end end,blit=function(aq,ec,ed)if type(aq)~="string"then error("bad argument #1 (expected string, got "..type(aq)..")",2)end;if type(ec)~="string"then error("bad argument #2 (expected string, got "..type(ec)..")",2)end;if type(ed)~="string"then error("bad argument #3 (expected string, got "..type(ed)..")",2)end;if#ec~=#aq or#ed~=#aq then error("Arguments must be the same length",2)end;if dv then dz(aq,ec,ed)end end}return e3 end;ci.width=30;ci.height=12;local ee=dq(1,1,ci.width,ci.height)local ef;local eg=false;local eh={}bN={getType=function(self)return bF end,show=function(self)ci.show(self)ee.setBackgroundColor(self.bgColor)ee.setTextColor(self.fgColor)ee.basalt_setVisible(true)return self end,hide=function(self)ci.hide(self)ee.basalt_setVisible(false)return self end,setPosition=function(self,ao,ap,bT)ci.setPosition(self,ao,ap,bT)ee.basalt_reposition(self:getAnchorPosition())return self end,getBasaltWindow=function()return ee end,getBasaltProcess=function()return ef end,setSize=function(self,a5,m)ci.setSize(self,a5,m)ee.basalt_resize(self.width,self.height)return self end,getStatus=function(self)if ef~=nil then return ef:getStatus()end;return"inactive"end,execute=function(self,aS,...)ef=aQ:new(aS,ee,...)ee.setBackgroundColor(colors.black)ee.setTextColor(colors.white)ee.clear()ee.setCursorPos(1,1)ef:resume()eg=false;return self end,stop=function(self)if ef~=nil then if not ef:isDead()then ef:resume("terminate")if ef:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end;return self end,pause=function(self,ei)eg=ei or not eg;if ef~=nil then if not ef:isDead()then if not eg then self:injectEvents(eh)eh={}end end end;return self end,isPaused=function(self)return eg end,injectEvent=function(self,aK,c4,c5,c6,c7,ej)if ef~=nil then if not ef:isDead()then if eg==false or ej then ef:resume(aK,c4,c5,c6,c7)else table.insert(eh,{event=aK,args={c4,c5,c6,c7}})end end end;return self end,getQueuedEvents=function(self)return eh end,updateQueuedEvents=function(self,aI)eh=aI or eh;return self end,injectEvents=function(self,aI)if ef~=nil then if not ef:isDead()then for aN,aO in pairs(aI)do ef:resume(aO.event,table.unpack(aO.args))end end end;return self end,mouseClickHandler=function(self,aK,c1,ao,ap)if ci.mouseClickHandler(self,aK,c1,ao,ap)then if ef==nil then return false end;if not ef:isDead()then if not eg then local ek,el=self:getAbsolutePosition(self:getAnchorPosition(nil,nil,true))ef:resume(aK,c1,ao-ek+1,ap-el+1)end end;return true end end,keyHandler=function(self,aK,bo)ci.keyHandler(self,aK,bo)if self:isFocused()then if ef==nil then return false end;if not ef:isDead()then if not eg then if self.draw then ef:resume(aK,bo)end end end end end,getFocusHandler=function(self)ci.getFocusHandler(self)if ef~=nil then if not ef:isDead()then if not eg then if self.parent~=nil then local em,en=ee.getCursorPos()local cm,cn=self:getAnchorPosition()if self.parent~=nil then if cm+em-1>=1 and cm+em-1<=cm+self.width-1 and en+cn-1>=1 and en+cn-1<=cn+self.height-1 then self.parent:setCursor(ee.getCursorBlink(),cm+em-1,en+cn-1,ee.getTextColor())end end end end end end end,loseFocusHandler=function(self)ci.loseFocusHandler(self)if ef~=nil then if not ef:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end,eventHandler=function(self,aK,c4,c5,c6,c7)if ef==nil then return end;if not ef:isDead()then if not eg then if aK~="mouse_click"and aK~="mouse_up"and aK~="mouse_scroll"and aK~="mouse_drag"and aK~="key_up"and aK~="key"and aK~="char"and aK~="terminate"then ef:resume(aK,c4,c5,c6,c7)end;if self:isFocused()then local cm,cn=self:getAnchorPosition()local em,en=ee.getCursorPos()if self.parent~=nil then if cm+em-1>=1 and cm+em-1<=cm+self.width-1 and en+cn-1>=1 and en+cn-1<=cn+self.height-1 then self.parent:setCursor(ee.getCursorBlink(),cm+em-1,en+cn-1,ee.getTextColor())end end;if aK=="terminate"and self:isFocused()then self:stop()end end else if aK~="mouse_click"and aK~="mouse_up"and aK~="mouse_scroll"and aK~="mouse_drag"and aK~="key_up"and aK~="key"and aK~="char"and aK~="terminate"then table.insert(eh,{event=aK,args={c4,c5,c6,c7}})end end end end,draw=function(self)if ci.draw(self)then if self.parent~=nil then local cm,cn=self:getAnchorPosition()ee.basalt_reposition(cm,cn)self.parent:drawBackgroundBox(cm,cn,self.width,self.height,self.bgColor)ee.basalt_update()end end end}return setmetatable(bN,ci)end;local function eo(bE)local ci=bD(bE)local bF="Progressbar"local ep=0;ci:setZIndex(5)ci:setValue(false)ci.width=25;ci.height=1;ci.bgColor=h.CheckboxBG;ci.fgColor=h.CheckboxFG;local eq=colors.black;local er=""local es=colors.white;local et=""local eu=0;local bN={getType=function(self)return bF end,setDirection=function(self,ev)eu=ev;return self end,setProgressBar=function(self,bV,aC,ew)eq=bV or eq;er=aC or er;es=ew or es;return self end,setBackgroundSymbol=function(self,aC)et=aC:sub(1,1)return self end,setProgress=function(self,aO)if aO>=0 and aO<=100 and ep~=aO then ep=aO;self:setValue(ep)if ep==100 then self:progressDoneHandler()end end;return self end,getProgress=function(self)return ep end,onProgressDone=function(self,x)self:registerEvent("progress_done",x)return self end,progressDoneHandler=function(self)self:sendEvent("progress_done")end,draw=function(self)if ci.draw(self)then if self.parent~=nil then local cm,cn=self:getAnchorPosition()self.parent:drawBackgroundBox(cm,cn,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cm,cn,self.width,self.height,self.fgColor)self.parent:drawTextBox(cm,cn,self.width,self.height,et)if eu==1 then self.parent:drawBackgroundBox(cm,cn,self.width,self.height/100*ep,eq)self.parent:drawForegroundBox(cm,cn,self.width,self.height/100*ep,es)self.parent:drawTextBox(cm,cn,self.width,self.height/100*ep,er)elseif eu==2 then self.parent:drawBackgroundBox(cm,cn+math.ceil(self.height-self.height/100*ep),self.width,self.height/100*ep,eq)self.parent:drawForegroundBox(cm,cn+math.ceil(self.height-self.height/100*ep),self.width,self.height/100*ep,es)self.parent:drawTextBox(cm,cn+math.ceil(self.height-self.height/100*ep),self.width,self.height/100*ep,er)elseif eu==3 then self.parent:drawBackgroundBox(cm+math.ceil(self.width-self.width/100*ep),cn,self.width/100*ep,self.height,eq)self.parent:drawForegroundBox(cm+math.ceil(self.width-self.width/100*ep),cn,self.width/100*ep,self.height,es)self.parent:drawTextBox(cm+math.ceil(self.width-self.width/100*ep),cn,self.width/100*ep,self.height,er)else self.parent:drawBackgroundBox(cm,cn,self.width/100*ep,self.height,eq)self.parent:drawForegroundBox(cm,cn,self.width/100*ep,self.height,es)self.parent:drawTextBox(cm,cn,self.width/100*ep,self.height,er)end end end end}return setmetatable(bN,ci)end;local function ex(bE)local ci=bD(bE)local bF="Radio"ci.width=8;ci.bgColor=h.listBG;ci.fgColor=h.listFG;ci:setZIndex(5)local cr={}local cs=h.selectionBG;local ct=h.selectionFG;local ey=ci.bgColor;local ez=ci.fgColor;local cu=true;local aC="\7"local cv="left"local bN={getType=function(self)return bF end,addItem=function(self,aq,ao,ap,aA,aB,...)table.insert(cr,{x=ao or 1,y=ap or 1,text=aq,bgCol=aA or self.bgColor,fgCol=aB or self.fgColor,args={...}})if#cr==1 then self:setValue(cr[1])end;return self end,removeItem=function(self,aJ)table.remove(cr,aJ)return self end,getItem=function(self,aJ)return cr[aJ]end,getItemIndex=function(self)local cD=self:getValue()for bo,aO in pairs(cr)do if aO==cD then return bo end end end,clear=function(self)cr={}self:setValue({})return self end,getItemCount=function(self)return#cr end,editItem=function(self,aJ,aq,ao,ap,aA,aB,...)table.remove(cr,aJ)table.insert(cr,aJ,{x=ao or 1,y=ap or 1,text=aq,bgCol=aA or self.bgColor,fgCol=aB or self.fgColor,args={...}})return self end,selectItem=function(self,aJ)self:setValue(cr[aJ]or{})return self end,setSelectedItem=function(self,aA,aB,eA,eB,cE)cs=aA or cs;ct=aB or ct;ey=eA or ey;ez=eB or ez;cu=cE;return self end,mouseClickHandler=function(self,aK,c1,ao,ap)local cm,cn=self:getAbsolutePosition(self:getAnchorPosition())if aK=="mouse_click"then if c1==1 then if#cr>0 then for aN,aO in pairs(cr)do if cm+aO.x-1<=ao and cm+aO.x-1+aO.text:len()+2>=ao and cn+aO.y-1==ap then self:setValue(aO)if self.parent~=nil then self.parent:setFocusedObject(self)end;self:setVisualChanged()return true end end end end end;return false end,draw=function(self)if ci.draw(self)then if self.parent~=nil then local cm,cn=self:getAnchorPosition()for aN,aO in pairs(cr)do if aO==self:getValue()then if cv=="left"then self.parent:writeText(aO.x+cm-1,aO.y+cn-1,aC,ey,ez)self.parent:writeText(aO.x+2+cm-1,aO.y+cn-1,aO.text,cs,ct)end else self.parent:drawBackgroundBox(aO.x+cm-1,aO.y+cn-1,1,1,self.bgColor)self.parent:writeText(aO.x+2+cm-1,aO.y+cn-1,aO.text,aO.bgCol,aO.fgCol)end end end end end}return setmetatable(bN,ci)end;local function eC(bE)local ci=bD(bE)local bF="Scrollbar"ci.width=1;ci.height=8;ci.bgColor=colors.lightGray;ci.fgColor=colors.gray;ci:setValue(1)ci:setZIndex(2)local eD="vertical"local aC=" "local eE=colors.black;local eF="\127"local eG=ci.height;local aJ=1;local eH=1;local bN={getType=function(self)return bF end,setSymbol=function(self,eI)aC=eI:sub(1,1)self:setVisualChanged()return self end,setSymbolSize=function(self,u)eH=tonumber(u)or 1;if eD=="vertical"then self:setValue(aJ-1*eG/(self.height-(eH-1))-eG/(self.height-(eH-1)))elseif eD=="horizontal"then self:setValue(aJ-1*eG/(self.width-(eH-1))-eG/(self.width-(eH-1)))end;self:setVisualChanged()return self end,setMaxValue=function(self,c_)eG=c_;return self end,setBackgroundSymbol=function(self,eJ)eF=string.sub(eJ,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,eK)eE=eK;self:setVisualChanged()return self end,setBarType=function(self,eL)eD=eL:lower()return self end,mouseClickHandler=function(self,aK,c1,ao,ap)if ci.mouseClickHandler(self,aK,c1,ao,ap)then local cm,cn=self:getAbsolutePosition(self:getAnchorPosition())if(aK=="mouse_click"or aK=="mouse_drag")and c1==1 then if eD=="horizontal"then for eM=0,self.width do if cm+eM==ao and cn<=ap and cn+self.height>ap then aJ=math.min(eM+1,self.width-(eH-1))self:setValue(eG/self.width*aJ)self:setVisualChanged()end end end;if eD=="vertical"then for eM=0,self.height do if cn+eM==ap and cm<=ao and cm+self.width>ao then aJ=math.min(eM+1,self.height-(eH-1))self:setValue(eG/self.height*aJ)self:setVisualChanged()end end end end;if aK=="mouse_scroll"then aJ=aJ+c1;if aJ<1 then aJ=1 end;aJ=math.min(aJ,(eD=="vertical"and self.height or self.width)-(eH-1))self:setValue(eG/(eD=="vertical"and self.height or self.width)*aJ)end;return true end end,draw=function(self)if ci.draw(self)then if self.parent~=nil then local cm,cn=self:getAnchorPosition()if eD=="horizontal"then self.parent:writeText(cm,cn,eF:rep(aJ-1),self.bgColor,self.fgColor)self.parent:writeText(cm+aJ-1,cn,aC:rep(eH),eE,eE)self.parent:writeText(cm+aJ+eH-1,cn,eF:rep(self.width-(aJ+eH-1)),self.bgColor,self.fgColor)end;if eD=="vertical"then for af=0,self.height-1 do if aJ==af+1 then for eN=0,math.min(eH-1,self.height)do self.parent:writeText(cm,cn+af+eN,aC,eE,eE)end else if af+1aJ-1+eH then self.parent:writeText(cm,cn+af,eF,self.bgColor,self.fgColor)end end end end end end end}return setmetatable(bN,ci)end;local function eO(bE)local ci=bD(bE)local bF="Slider"ci.width=8;ci.bgColor=colors.lightGray;ci.fgColor=colors.gray;ci:setValue(1)local eD="horizontal"local aC=" "local eE=colors.black;local eF="\140"local eG=ci.width;local aJ=1;local bN={getType=function(self)return bF end,setSymbol=function(self,eI)aC=eI:sub(1,1)self:setVisualChanged()return self end,setBackgroundSymbol=function(self,eJ)eF=string.sub(eJ,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,eK)eE=eK;self:setVisualChanged()return self end,setBarType=function(self,eL)eD=eL:lower()return self end,mouseClickHandler=function(self,aK,c1,ao,ap)if ci.mouseClickHandler(self,aK,c1,ao,ap)then local cm,cn=self:getAbsolutePosition(self:getAnchorPosition())if eD=="horizontal"then for eM=0,self.width-1 do if cm+eM==ao and cn<=ap and cn+self.height>ap then aJ=eM+1;self:setValue(eG/self.width*aJ)self:setVisualChanged()end end end;if eD=="vertical"then for eM=0,self.height-1 do if cn+eM==ap and cm<=ao and cm+self.width>ao then aJ=eM+1;self:setValue(eG/self.height*aJ)self:setVisualChanged()end end end end end,draw=function(self)if ci.draw(self)then if self.parent~=nil then local cm,cn=self:getAnchorPosition()if eD=="horizontal"then self.parent:writeText(cm,cn,eF:rep(aJ-1),self.bgColor,self.fgColor)self.parent:writeText(cm+aJ-1,cn,aC,eE,eE)self.parent:writeText(cm+aJ,cn,eF:rep(self.width-aJ),self.bgColor,self.fgColor)end;if eD=="vertical"then for af=0,self.height-1 do if af+1==aJ then self.parent:writeText(cm,cn+af,aC,eE,eE)else self.parent:writeText(cm,cn+af,eF,self.bgColor,self.fgColor)end end end end end end}return setmetatable(bN,ci)end;local function eP(bE)local ci=bD(bE)local bF="Switch"ci.width=3;ci.height=1;ci.bgColor=colors.lightGray;ci.fgColor=colors.gray;ci:setValue(false)ci:setZIndex(5)local bN={getType=function(self)return bF end,mouseClickHandler=function(self,aK,c1,ao,ap)if ci.mouseClickHandler(self,aK,c1,ao,ap)then local cm,cn=self:getAbsolutePosition(self:getAnchorPosition())if(aK=="mouse_click"or aK=="mouse_drag")and c1==1 then end;return true end end,draw=function(self)if ci.draw(self)then if self.parent~=nil then local cm,cn=self:getAnchorPosition()end end end}return setmetatable(bN,ci)end;local function eQ(bE)local ci=bD(bE)local bF="Textfield"local eR,cR,cQ,eS=1,1,1,1;local eT={""}local eU={[colors.purple]={"break"}}ci.width=20;ci.height=8;ci.bgColor=h.textfieldBG;ci.fgColor=h.textfieldFG;ci:setZIndex(5)local bN={getType=function(self)return bF end,getLines=function(self)return eT end,getLine=function(self,aJ)return eT[aJ]or""end,editLine=function(self,aJ,aq)eT[aJ]=aq or eT[aJ]return self end,addLine=function(self,aq,aJ)if aJ~=nil then table.insert(eT,aJ,aq)else table.insert(eT,aq)end;return self end,addKeyword=function(self,eV,bV)end,removeLine=function(self,aJ)table.remove(eT,aJ or#eT)if#eT<=0 then table.insert(eT,"")end;return self end,getTextCursor=function(self)return cQ,eS end,getFocusHandler=function(self)ci.getFocusHandler(self)if self.parent~=nil then local cm,cn=self:getAnchorPosition()if self.parent~=nil then self.parent:setCursor(true,cm+cQ-cR,cn+eS-eR,self.fgColor)end end end,loseFocusHandler=function(self)ci.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)end end,keyHandler=function(self,aK,bo)if ci.keyHandler(self,aK,bo)then local cm,cn=self:getAnchorPosition()if aK=="key"then if bo==keys.backspace then if eT[eS]==""then if eS>1 then table.remove(eT,eS)cQ=eT[eS-1]:len()+1;cR=cQ-self.width+1;if cR<1 then cR=1 end;eS=eS-1 end elseif cQ<=1 then if eS>1 then cQ=eT[eS-1]:len()+1;cR=cQ-self.width+1;if cR<1 then cR=1 end;eT[eS-1]=eT[eS-1]..eT[eS]table.remove(eT,eS)eS=eS-1 end else eT[eS]=eT[eS]:sub(1,cQ-2)..eT[eS]:sub(cQ,eT[eS]:len())if cQ>1 then cQ=cQ-1 end;if cR>1 then if cQeT[eS]:len()then if eT[eS+1]~=nil then eT[eS]=eT[eS]..eT[eS+1]table.remove(eT,eS+1)end else eT[eS]=eT[eS]:sub(1,cQ-1)..eT[eS]:sub(cQ+1,eT[eS]:len())end end;if bo==keys.enter then table.insert(eT,eS+1,eT[eS]:sub(cQ,eT[eS]:len()))eT[eS]=eT[eS]:sub(1,cQ-1)eS=eS+1;cQ=1;cR=1;if eS-eR>=self.height then eR=eR+1 end;self:setValue("")end;if bo==keys.up then if eS>1 then eS=eS-1;if cQ>eT[eS]:len()+1 then cQ=eT[eS]:len()+1 end;if cR>1 then if cQ1 then if eSeT[eS]:len()+1 then cQ=eT[eS]:len()+1 end;if eS>=eR+self.height then eR=eR+1 end end end;if bo==keys.right then cQ=cQ+1;if eS<#eT then if cQ>eT[eS]:len()+1 then cQ=1;eS=eS+1 end elseif cQ>eT[eS]:len()then cQ=eT[eS]:len()+1 end;if cQ<1 then cQ=1 end;if cQ=self.width+cR then cR=cQ-self.width+1 end;if cR<1 then cR=1 end end;if bo==keys.left then cQ=cQ-1;if cQ>=1 then if cQ=self.width+cR then cR=cQ end end;if eS>1 then if cQ<1 then eS=eS-1;cQ=eT[eS]:len()+1;cR=cQ-self.width+1 end end;if cQ<1 then cQ=1 end;if cR<1 then cR=1 end end end;if aK=="char"then eT[eS]=eT[eS]:sub(1,cQ-1)..bo..eT[eS]:sub(cQ,eT[eS]:len())cQ=cQ+1;if cQ>=self.width+cR then cR=cR+1 end;self:setValue("")end;local d3=(cQ<=eT[eS]:len()and cQ-1 or eT[eS]:len())-(cR-1)if d3>self.x+self.width-1 then d3=self.x+self.width-1 end;local eW=eS-eReT[eS]:len()then cQ=eT[eS]:len()+1 end;if cQeT[eS]:len()then cQ=eT[eS]:len()+1 end;if cQ#eT-(self.height-1)then eR=#eT-(self.height-1)end;if eR<1 then eR=1 end;if self.parent~=nil then if cm+cQ-cR>=cm and cm+cQ-cR<=cm+self.width and(cn+eS-eR>=cn and cn+eS-eR<=cn+self.height)then self.parent:setCursor(true,eX+cQ-cR,eY+eS-eR)else self.parent:setCursor(false)end end end;self:setVisualChanged()return true end end,draw=function(self)if ci.draw(self)then if self.parent~=nil then local cm,cn=self:getAnchorPosition()self.parent:drawBackgroundBox(cm,cn,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cm,cn,self.width,self.height,self.fgColor)for af=1,self.height do local aq=""if eT[af+eR-1]~=nil then aq=eT[af+eR-1]end;aq=aq:sub(cR,self.width+cR-1)local d4=self.width-aq:len()if d4<0 then d4=0 end;aq=aq..string.rep(" ",d4)self.parent:setText(cm,cn+af-1,aq)end end end end}return setmetatable(bN,ci)end;local function eZ(bE)local bN;local bF="Thread"local aM;local e_;local f0=false;bN={name=bE,getType=function(self)return bF end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,start=function(self,x)if x==nil then error("Function provided to thread is nil")end;aM=x;e_=coroutine.create(aM)f0=true;local aW,aX=coroutine.resume(e_)if not aW then if aX~="Terminated"then error("Thread Error Occurred - "..aX)end end;return self end,getStatus=function(self,x)if e_~=nil then return coroutine.status(e_)end;return nil end,stop=function(self,x)f0=false;return self end,eventHandler=function(self,aK,c4,c5,c6)if f0 then if coroutine.status(e_)~="dead"then local aW,aX=coroutine.resume(e_,aK,c4,c5,c6)if not aW then if aX~="Terminated"then error("Thread Error Occurred - "..aX)end end else f0=false end end end}bN.__index=bN;return bN end;local function f1(bE)local bF="Timer"local f2=0;local f3=0;local f4=0;local c9;local bM=aH()local bN={name=bE,getType=function(self)return bF end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,setTime=function(self,f5,f6)f2=f5 or 0;f3=f6 or 1;return self end,start=function(self)f4=f3;c9=os.startTimer(f2)return self end,cancel=function(self)if c9~=nil then os.cancelTimer(c9)end;return self end,onCall=function(self,aM)bM:registerEvent("timed_event",aM)return self end,eventHandler=function(self,aK,cg)if aK=="timer"and cg==c9 then bM:sendEvent("timed_event",self)if f4>=1 then f4=f4-1;if f4>=1 then c9=os.startTimer(f2)end elseif f4==-1 then c9=os.startTimer(f2)end end end}bN.__index=bN;return bN end;local function f7(bE,f8)local ci=bD(bE)local bF="Frame"local f9={}local fa={}local bN={}local fb;ci:setZIndex(10)local du=false;local dr=1;local ds=1;local fc=colors.white;local fd,cw=0,0;if f8~=nil then ci.parent=f8;ci.width,ci.height=f8.w,f8.h;ci.bgColor=h.FrameBG;ci.fgColor=h.FrameFG else local fe,ff=e.getSize()ci.width,ci.height=fe,ff;ci.bgColor=h.basaltBG;ci.fgColor=h.basaltFG end;local function fg(bE)for aN,aO in pairs(f9)do for aN,bq in pairs(aO)do if bq.name==bE then return aO end end end end;local function fh(fi)local bG=fi:getZIndex()if fg(fi.name)~=nil then return nil end;if f9[bG]==nil then for ao=1,#fa+1 do if fa[ao]~=nil then if bG==fa[ao]then break end;if bG>fa[ao]then table.insert(fa,ao,bG)break end else table.insert(fa,bG)end end;if#fa<=0 then table.insert(fa,bG)end;f9[bG]={}end;fi.parent=bN;table.insert(f9[bG],fi)return fi end;local function fj(fi)for bp,bq in pairs(f9)do for bo,aO in pairs(bq)do if aO==fi then table.remove(f9[bp],bo)return true end end end;return false end;bN={barActive=false,barBackground=colors.gray,barTextcolor=colors.black,barText="New Frame",barTextAlign="left",isMoveable=false,getType=function(self)return bF end,setFocusedObject=function(self,fi)for aN,aJ in pairs(fa)do for aN,aO in pairs(f9[aJ])do if aO==fi then if fb~=nil then fb:loseFocusHandler()end;fb=fi;fb:getFocusHandler()end end end;return self end,setOffset=function(self,bZ,b_)fd=bZ~=nil and math.floor(bZ<0 and math.abs(bZ)or-bZ)or fd;cw=b_~=nil and math.floor(b_<0 and math.abs(b_)or-b_)or cw;return self end,getFrameOffset=function(self)return fd,cw end,removeFocusedObject=function(self)if fb~=nil then fb:loseFocusHandler()end;fb=nil;return self end,getFocusedObject=function(self)return fb end,show=function(self)ci:show()if self.parent==nil then b=self end;return self end,setCursor=function(self,fk,fl,fm,bV)local cm,cn=self:getAbsolutePosition(self:getAnchorPosition())du=fk or false;if fl~=nil then dr=cm+fl-1 end;if fm~=nil then ds=cn+fm-1 end;fc=bV or fc;self:setVisualChanged()return self end,setMoveable=function(self,fn)self.isMoveable=fn or not self.isMoveable;self:setVisualChanged()return self end,showBar=function(self,fo)self.barActive=fo or not self.barActive;self:setVisualChanged()return self end,setBar=function(self,aq,aA,aB)self.barText=aq or""self.barBackground=aA or self.barBackground;self.barTextcolor=aB or self.barTextcolor;self:setVisualChanged()return self end,setBarTextAlign=function(self,cv)self.barTextAlign=cv or"left"self:setVisualChanged()return self end,getVisualChanged=function(self)local fp=ci.getVisualChanged(self)for aN,aJ in pairs(fa)do if f9[aJ]~=nil then for aN,aO in pairs(f9[aJ])do if aO.getVisualChanged~=nil and aO:getVisualChanged()then fp=true end end end end;return fp end,loseFocusHandler=function(self)ci.loseFocusHandler(self)end,getFocusHandler=function(self)ci.getFocusHandler(self)if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end end,keyHandler=function(self,aK,bo)if fb~=nil then if fb.keyHandler~=nil then if fb:keyHandler(aK,bo)then return true end end end;return false end,backgroundKeyHandler=function(self,aK,bo)ci.backgroundKeyHandler(self,aK,bo)for aN,aJ in pairs(fa)do if f9[aJ]~=nil then for aN,aO in pairs(f9[aJ])do if aO.backgroundKeyHandler~=nil then aO:backgroundKeyHandler(aK,bo)end end end end end,eventHandler=function(self,aK,c4,c5,c6,c7)ci.eventHandler(self,aK,c4,c5,c6,c7)for aN,aJ in pairs(fa)do if f9[aJ]~=nil then for aN,aO in pairs(f9[aJ])do if aO.eventHandler~=nil then aO:eventHandler(aK,c4,c5,c6,c7)end end end end;if aK=="terminate"then e.clear()e.setCursorPos(1,1)a.stop()end end,mouseClickHandler=function(self,aK,c1,ao,ap)local bZ,b_=self:getOffset()bZ=bZ<0 and math.abs(bZ)or-bZ;b_=b_<0 and math.abs(b_)or-b_;if self.drag then if aK=="mouse_drag"then local fq=1;local fr=1;if self.parent~=nil then fq,fr=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())end;self:setPosition(ao+self.xToRem-(fq-1)+bZ,ap-(fr-1)+b_)end;if aK=="mouse_up"then self.drag=false end;return true end;if ci.mouseClickHandler(self,aK,c1,ao,ap)then local bW,bX=self:getAbsolutePosition(self:getAnchorPosition())for aN,aJ in pairs(fa)do if f9[aJ]~=nil then for aN,aO in b3(f9[aJ])do if aO.mouseClickHandler~=nil then if aO:mouseClickHandler(aK,c1,ao+bZ,ap+b_)then return true end end end end end;if self.isMoveable then if ao>=bW and ao<=bW+self.width-1 and ap==bX and aK=="mouse_click"then self.drag=true;self.xToRem=bW-ao end end;if fb~=nil then fb:loseFocusHandler()fb=nil end;return true end;return false end,setText=function(self,ao,ap,aq)local cm,cn=self:getAbsolutePosition(self:getAnchorPosition())if ap>=1 and ap<=self.height then if self.parent~=nil then self.parent:setText(math.max(ao+cm-1,cm)-(self.parent.x-1),cn+ap-1-(self.parent.y-1),f(aq,math.max(1-ao+1,1),self.width-ao+1))else az.setText(math.max(ao+cm-1,cm),cn+ap-1,f(aq,math.max(1-ao+1,1),self.width-ao+1))end end end,setBG=function(self,ao,ap,aA)local cm,cn=self:getAbsolutePosition(self:getAnchorPosition())if ap>=1 and ap<=self.height then if self.parent~=nil then self.parent:setBG(math.max(ao+cm-1,cm)-(self.parent.x-1),cn+ap-1-(self.parent.y-1),f(aA,math.max(1-ao+1,1),self.width-ao+1))else az.setBG(math.max(ao+cm-1,cm),cn+ap-1,f(aA,math.max(1-ao+1,1),self.width-ao+1))end end end,setFG=function(self,ao,ap,aB)local cm,cn=self:getAbsolutePosition(self:getAnchorPosition())if ap>=1 and ap<=self.height then if self.parent~=nil then self.parent:setFG(math.max(ao+cm-1,cm)-(self.parent.x-1),cn+ap-1-(self.parent.y-1),f(aB,math.max(1-ao+1,1),self.width-ao+1))else az.setFG(math.max(ao+cm-1,cm),cn+ap-1,f(aB,math.max(1-ao+1,1),self.width-ao+1))end end end,writeText=function(self,ao,ap,aq,aA,aB)local cm,cn=self:getAbsolutePosition(self:getAnchorPosition())if ap>=1 and ap<=self.height then if self.parent~=nil then self.parent:writeText(math.max(ao+cm-1,cm)-(self.parent.x-1),cn+ap-1-(self.parent.y-1),f(aq,math.max(1-ao+1,1),self.width-ao+1),aA,aB)else az.writeText(math.max(ao+cm-1,cm),cn+ap-1,f(aq,math.max(1-ao+1,1),self.width-ao+1),aA,aB)end end end,drawBackgroundBox=function(self,ao,ap,a5,m,aA)local cm,cn=self:getAbsolutePosition(self:getAnchorPosition())m=ap<1 and(m+ap>self.height and self.height or m+ap-1)or(m+ap>self.height and self.height-ap+1 or m)a5=ao<1 and(a5+ao>self.width and self.width or a5+ao-1)or(a5+ao>self.width and self.width-ao+1 or a5)if self.parent~=nil then self.parent:drawBackgroundBox(math.max(ao+cm-1,cm)-(self.parent.x-1),math.max(ap+cn-1,cn)-(self.parent.y-1),a5,m,aA)else az.drawBackgroundBox(math.max(ao+cm-1,cm),math.max(ap+cn-1,cn),a5,m,aA)end end,drawTextBox=function(self,ao,ap,a5,m,aC)local cm,cn=self:getAbsolutePosition(self:getAnchorPosition())m=ap<1 and(m+ap>self.height and self.height or m+ap-1)or(m+ap>self.height and self.height-ap+1 or m)a5=ao<1 and(a5+ao>self.width and self.width or a5+ao-1)or(a5+ao>self.width and self.width-ao+1 or a5)if self.parent~=nil then self.parent:drawTextBox(math.max(ao+cm-1,cm)-(self.parent.x-1),math.max(ap+cn-1,cn)-(self.parent.y-1),a5,m,aC:sub(1,1))else az.drawTextBox(math.max(ao+cm-1,cm),math.max(ap+cn-1,cn),a5,m,aC:sub(1,1))end end,drawForegroundBox=function(self,ao,ap,a5,m,aB)local cm,cn=self:getAbsolutePosition(self:getAnchorPosition())m=ap<1 and(m+ap>self.height and self.height or m+ap-1)or(m+ap>self.height and self.height-ap+1 or m)a5=ao<1 and(a5+ao>self.width and self.width or a5+ao-1)or(a5+ao>self.width and self.width-ao+1 or a5)if self.parent~=nil then self.parent:drawForegroundBox(math.max(ao+cm-1,cm)-(self.parent.x-1),math.max(ap+cn-1,cn)-(self.parent.y-1),a5,m,aB)else az.drawForegroundBox(math.max(ao+cm-1,cm),math.max(ap+cn-1,cn),a5,m,aB)end end,draw=function(self)if self:getVisualChanged()then if ci.draw(self)then local cm,cn=self:getAbsolutePosition(self:getAnchorPosition())local eX,eY=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(eX,eY,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(eX,eY,self.width,self.height,self.fgColor)self.parent:drawTextBox(eX,eY,self.width,self.height," ")else az.drawBackgroundBox(cm,cn,self.width,self.height,self.bgColor)az.drawForegroundBox(cm,cn,self.width,self.height,self.fgColor)az.drawTextBox(cm,cn,self.width,self.height," ")end;e.setCursorBlink(false)if self.barActive then if self.parent~=nil then self.parent:writeText(eX,eY,aY(self.barText,self.width,self.barTextAlign),self.barBackground,self.barTextcolor)else az.writeText(cm,cn,aY(self.barText,self.width,self.barTextAlign),self.barBackground,self.barTextcolor)end end;for aN,aJ in b3(fa)do if f9[aJ]~=nil then for aN,aO in pairs(f9[aJ])do if aO.draw~=nil then aO:draw()end end end end;if du then e.setTextColor(fc)e.setCursorPos(dr,ds)if self.parent~=nil then e.setCursorBlink(self:isFocused())else e.setCursorBlink(du)end end;self:setVisualChanged(false)end end end,addObject=function(self,fi)return fh(fi)end,removeObject=function(self,fi)return fj(fi)end,getObject=function(self,fi)return fg(fi)end,addButton=function(self,bE)local fi=ch(bE)fi.name=bE;return fh(fi)end,addLabel=function(self,bE)local fi=d5(bE)fi.name=bE;fi.bgColor=self.bgColor;fi.fgColor=self.fgColor;return fh(fi)end,addCheckbox=function(self,bE)local fi=cp(bE)fi.name=bE;return fh(fi)end,addInput=function(self,bE)local fi=cN(bE)fi.name=bE;return fh(fi)end,addProgram=function(self,bE)local fi=dp(bE)fi.name=bE;return fh(fi)end,addTextfield=function(self,bE)local fi=eQ(bE)fi.name=bE;return fh(fi)end,addList=function(self,bE)local fi=df(bE)fi.name=bE;return fh(fi)end,addDropdown=function(self,bE)local fi=cq(bE)fi.name=bE;return fh(fi)end,addRadio=function(self,bE)local fi=ex(bE)fi.name=bE;return fh(fi)end,addTimer=function(self,bE)local fi=f1(bE)fi.name=bE;return fh(fi)end,addAnimation=function(self,bE)local fi=c8(bE)fi.name=bE;return fh(fi)end,addSlider=function(self,bE)local fi=eO(bE)fi.name=bE;return fh(fi)end,addScrollbar=function(self,bE)local fi=eC(bE)fi.name=bE;return fh(fi)end,addMenubar=function(self,bE)local fi=di(bE)fi.name=bE;return fh(fi)end,addThread=function(self,bE)local fi=eZ(bE)fi.name=bE;return fh(fi)end,addPane=function(self,bE)local fi=dn(bE)fi.name=bE;return fh(fi)end,addImage=function(self,bE)local fi=cF(bE)fi.name=bE;return fh(fi)end,addProgressbar=function(self,bE)local fi=eo(bE)fi.name=bE;return fh(fi)end,addFrame=function(self,bE)local fi=f7(bE,self)fi.name=bE;return fh(fi)end}setmetatable(bN,ci)if f8==nil then table.insert(c,bN)end;return bN end;local fs=false;local function ft(aK,c4,c5,c6,c7)if aK=="mouse_click"then b:mouseClickHandler(aK,c4,c5,c6,c7)end;if aK=="mouse_drag"then b:mouseClickHandler(aK,c4,c5,c6,c7)end;if aK=="mouse_up"then b:mouseClickHandler(aK,c4,c5,c6,c7)end;if aK=="mouse_scroll"then b:mouseClickHandler(aK,c4,c5,c6,c7)end;if aK=="key"or aK=="char"then b:keyHandler(aK,c4)b:backgroundKeyHandler(aK,c4)end;for aN,aO in pairs(c)do aO:eventHandler(aK,c4,c5,c6,c7)end;if fs then b:draw()az.update()end end;function a.autoUpdate(f0)e.clear()fs=f0 or true;b:draw()az.update()while fs do local aK,c4,c5,c6,c7=os.pullEventRaw()ft(aK,c4,c5,c6,c7)end end;function a.update(aK,c4,c5,c6,c7)if aK~="nil"then ft(aK,c4,c5,c6,c7)else b:draw()az.update()end end;function a.stop()fs=false end;function a.getFrame(bE)for aN,aO in pairs(c)do if aO.name==bE then return aO end end end;function a.getActiveFrame()return b end;function a.setActiveFrame(bO)if bO:getType()=="Frame"then b=bO;return true end;return false end;function a.createFrame(bE)local bO=f7(bE)return bO end;function a.removeFrame(bE)for bo,aO in pairs(c)do if aO.name==bE then c[bo]=nil;return true end end;return false end;if a.debugger then a.debugFrame=a.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray)a.debugList=a.debugFrame:addList("debugList"):setSize(a.debugFrame.width-2,a.debugFrame.height-3):setPosition(2,3):setScrollable(true):show()a.debugFrame:addButton("back"):setAnchor("right"):setSize(1,1):setText("\22"):onClick(function()a.oldFrame:show()end):setBackground(colors.red):show()a.debugLabel=a.debugFrame:addLabel("debugLabel"):onClick(function()a.oldFrame=b;a.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):setZIndex(20):show()end;if a.debugger then function a.debug(...)local aU={...}if b.name~="basaltDebuggingFrame"then if b~=a.debugLabel.frame then a.debugLabel:setParent(b)end end;local fu=""for bo,aO in pairs(aU)do fu=fu..tostring(aO)..(#aU~=bo and", "or"")end;a.debugLabel:setText("[Debug] "..fu)a.debugList:addItem(fu)if a.debugList:getItemCount()>50 then a.debugList:removeItem(1)end;a.debugList:setValue(a.debugList:getItem(a.debugList:getItemCount()))a.debugLabel:show()end end;return a