local c,y="\076\105\098\083\116\117\098",2 local K=_G[c]if not K or K.minor<y then K=K or{libs={};minors={}}_G[c]=K K.minor=y function K.NewLibrary(K,c,y)assert(type(c)=="\115\116\114\105\110\103","\066\097\100 \097\114\103\117\109\101\110\116 \035\050 \116\111 \096\078\101\119\076\105\098\114\097\114\121\' \040\115\116\114\105\110\103 \101\120\112\101\099\116\101\100\041")y=assert(tonumber(strmatch(y,"\037\100\043")),"\077\105\110\111\114 \118\101\114\115\105\111\110 \109\117\115\116 \101\105\116\104\101\114 \098\101 \097 \110\117\109\098\101\114 \111\114 \099\111\110\116\097\105\110 \097 \110\117\109\098\101\114\046")local T=K.minors[c]if T and T>=y then return nil end K.minors[c],K.libs[c]=y,K.libs[c]or{}return K.libs[c],T end function K.GetLibrary(K,c,y)if not K.libs[c]and not y then error(("\067\097\110\110\111\116 \102\105\110\100 \097 \108\105\098\114\097\114\121 \105\110\115\116\097\110\099\101 \111\102 \037\113\046"):format(tostring(c)),2)end return K.libs[c],K.minors[c]end function K.IterateLibraries(c)return pairs(c.libs)end setmetatable(K,{__call=K.GetLibrary})end
-- $Id: LibStub.lua 76 2007-09-03 01:50:17Z mikk $
-- LibStub is a simple versioning stub meant for use in Libraries.  http://www.wowace.com/wiki/LibStub for more info
-- LibStub is hereby placed in the Public Domain
-- Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2  -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
local LibStub = _G[LIBSTUB_MAJOR]

-- Check to see is this version of the stub is obsolete
if not LibStub or LibStub.minor < LIBSTUB_MINOR then
	LibStub = LibStub or {libs = {}, minors = {} }
	_G[LIBSTUB_MAJOR] = LibStub
	LibStub.minor = LIBSTUB_MINOR
	
	-- LibStub:NewLibrary(major, minor)
	-- major (string) - the major version of the library
	-- minor (string or number ) - the minor version of the library
	-- 
	-- returns nil if a newer or same version of the lib is already present
	-- returns empty library object or old library object if upgrade is needed
	function LibStub:NewLibrary(major, minor)
		assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
		minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
		
		local oldminor = self.minors[major]
		if oldminor and oldminor >= minor then return nil end
		self.minors[major], self.libs[major] = minor, self.libs[major] or {}
		return self.libs[major], oldminor
	end
	
	-- LibStub:GetLibrary(major, [silent])
	-- major (string) - the major version of the library
	-- silent (boolean) - if true, library is optional, silently return nil if its not found
	--
	-- throws an error if the library can not be found (except silent is set)
	-- returns the library object if found
	function LibStub:GetLibrary(major, silent)
		if not self.libs[major] and not silent then
			error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
		end
		return self.libs[major], self.minors[major]
	end
	
	-- LibStub:IterateLibraries()
	-- 
	-- Returns an iterator for the currently registered libraries
	function LibStub:IterateLibraries() 
		return pairs(self.libs) 
	end
	
	setmetatable(LibStub, { __call = LibStub.GetLibrary })
end
