diff --git a/aiserver.py b/aiserver.py index 2e0fd952..d6bcc09f 100644 --- a/aiserver.py +++ b/aiserver.py @@ -87,8 +87,10 @@ class vars: andepth = 3 # How far back in history to append author's note actions = structures.KoboldStoryRegister() # Actions submitted by user and AI worldinfo = [] # List of World Info key/value objects + worldinfo_u = {} # Dictionary of World Info UID - key/value pairs wifolders_d = {} # Dictionary of World Info folder UID-info pairs wifolders_l = [] # List of World Info folder UIDs + wifolders_u = {} # Dictionary of pairs of folder UID - list of WI UID # badwords = [] # Array of str/chr values that should be removed from output badwordsids = [[13460], [6880], [50256], [42496], [4613], [17414], [22039], [16410], [27], [29], [38430], [37922], [15913], [24618], [28725], [58], [47175], [36937], [26700], [12878], [16471], [37981], [5218], [29795], [13412], [45160], [3693], [49778], [4211], [20598], [36475], [33409], [44167], [32406], [29847], [29342], [42669], [685], [25787], [7359], [3784], [5320], [33994], [33490], [34516], [43734], [17635], [24293], [9959], [23785], [21737], [28401], [18161], [26358], [32509], [1279], [38155], [18189], [26894], [6927], [14610], [23834], [11037], [14631], [26933], [46904], [22330], [25915], [47934], [38214], [1875], [14692], [41832], [13163], [25970], [29565], [44926], [19841], [37250], [49029], [9609], [44438], [16791], [17816], [30109], [41888], [47527], [42924], [23984], [49074], [33717], [31161], [49082], [30138], [31175], [12240], [14804], [7131], [26076], [33250], [3556], [38381], [36338], [32756], [46581], [17912], [49146]] # Tokenized array of badwords used to prevent AI artifacting deletewi = -1 # Temporary storage for index to delete @@ -2157,6 +2159,12 @@ def addwiitem(folder_uid=None): assert folder_uid is None or folder_uid in vars.wifolders_d ob = {"key": "", "keysecondary": "", "content": "", "comment": "", "folder": folder_uid, "num": len(vars.worldinfo), "init": False, "selective": False, "constant": False} vars.worldinfo.append(ob) + while(True): + uid = int.from_bytes(os.urandom(4), "little", signed=True) + if(uid not in vars.worldinfo_u): + break + vars.worldinfo_u[uid] = vars.worldinfo[-1] + vars.worldinfo[-1]["uid"] = uid emit('from_server', {'cmd': 'addwiitem', 'data': ob}, broadcast=True) #==================================================================# @@ -2170,6 +2178,7 @@ def addwifolder(): ob = {"name": "", "collapsed": False} vars.wifolders_d[uid] = ob vars.wifolders_l.append(uid) + vars.wifolders_u[uid] = [] emit('from_server', {'cmd': 'addwifolder', 'uid': uid, 'data': ob}, broadcast=True) addwiitem(folder_uid=uid) @@ -2178,6 +2187,13 @@ def addwifolder(): # the WI entry with number dst #==================================================================# def movewiitem(dst, src): + if(vars.worldinfo[src]["folder"] is not None): + for i, e in enumerate(vars.wifolders_u[vars.worldinfo[src]["folder"]]): + if(e is vars.worldinfo[src]): + vars.wifolders_u[vars.worldinfo[src]["folder"]].pop(i) + if(vars.worldinfo[dst]["folder"] is not None): + vars.wifolders_u[vars.worldinfo[dst]["folder"]].append(vars.worldinfo[src]) + vars.wifolders_u[vars.worldinfo[src]["folder"]] vars.worldinfo[src]["folder"] = vars.worldinfo[dst]["folder"] vars.worldinfo.insert(dst - (dst >= src), vars.worldinfo.pop(src)) sendwi() @@ -2213,7 +2229,6 @@ def sendwi(): addwiitem() else: # Send contents of WI array - organizewi() last_folder = ... for wi in vars.worldinfo: if(wi["folder"] != last_folder): @@ -2242,7 +2257,8 @@ def stablesortwi(): vars.worldinfo.sort(key=lambda x: mapping[x["folder"]] if x["folder"] is not None else float("inf")) last_folder = ... last_wi = None - for wi in vars.worldinfo: + for i, wi in enumerate(vars.worldinfo): + wi["num"] = i wi["init"] = True if(wi["folder"] != last_folder): if(last_wi is not None and last_folder is not ...): @@ -2251,17 +2267,8 @@ def stablesortwi(): last_wi = wi if(last_wi is not None): last_wi["init"] = False - -#==================================================================# -# Renumber WI items consecutively -#==================================================================# -def organizewi(): - if(len(vars.worldinfo) > 0): - count = 0 - for wi in vars.worldinfo: - wi["num"] = count - count += 1 - + for folder in vars.wifolders_u: + folder.sort(key=lambda x: x["num"]) #==================================================================# # Extract object from server and send it to WI objects @@ -2277,6 +2284,11 @@ def commitwi(ar): vars.worldinfo[ob["num"]]["constant"] = ob.get("constant", False) # Was this a deletion request? If so, remove the requested index if(vars.deletewi >= 0): + if(vars.worldinfo[vars.deletewi]["folder"] is not None): + for i, e in enumerate(vars.wifolders_u[vars.worldinfo[vars.deletewi]["folder"]]): + if(e is vars.worldinfo[vars.deletewi]): + vars.wifolders_u[vars.worldinfo[vars.deletewi]["folder"]].pop(i) + del vars.worldinfo_d[vars.worldinfo[vars.deletewi]] del vars.worldinfo[vars.deletewi] # Send the new WI array structure sendwi() @@ -2298,6 +2310,7 @@ def deletewi(num): #==================================================================# def deletewifolder(uid): uid = int(uid) + del vars.wifolders_u[uid] del vars.wifolders_d[uid] del vars.wifolders_l[vars.wifolders_l.index(uid)] # Delete uninitialized entries in the folder we're going to delete @@ -2717,8 +2730,10 @@ def loadRequest(loadpath, filename=None): vars.prompt = js["prompt"] vars.memory = js["memory"] vars.worldinfo = [] + vars.worldinfo_u = {} vars.wifolders_d = {int(k): v for k, v in js.get("wifolders_d", {}).items()} vars.wifolders_l = js.get("wifolders_l", []) + vars.wifolders_u = {uid: [] for uid in vars.wifolders_d} vars.lastact = "" vars.lastctx = "" @@ -2756,14 +2771,20 @@ def loadRequest(loadpath, filename=None): "num": num, "init": True, "selective": wi.get("selective", False), - "constant": wi.get("constant", False) + "constant": wi.get("constant", False), + "uid": None, }) + while(True): + uid = int.from_bytes(os.urandom(4), "little", signed=True) + if(uid not in vars.worldinfo_u): + break + vars.worldinfo_u[uid] = vars.worldinfo[-1] + vars.worldinfo[-1]["uid"] = uid num += 1 for uid in vars.wifolders_l + [None]: - vars.worldinfo.append({"key": "", "keysecondary": "", "content": "", "comment": "", "folder": uid, "num": None, "init": False, "selective": False, "constant": False}) + vars.worldinfo.append({"key": "", "keysecondary": "", "content": "", "comment": "", "folder": uid, "num": None, "init": False, "selective": False, "constant": False, "uid": None}) stablesortwi() - organizewi() # Save path for save button vars.savedir = loadpath @@ -2905,8 +2926,10 @@ def importgame(): vars.authornote = ref["authorsNote"] if type(ref["authorsNote"]) is str else "" vars.actions = structures.KoboldStoryRegister() vars.worldinfo = [] + vars.worldinfo_u = {} vars.wifolders_d = {} vars.wifolders_l = [] + vars.wifolders_u = {uid: [] for uid in vars.wifolders_d} vars.lastact = "" vars.lastctx = "" @@ -2934,8 +2957,15 @@ def importgame(): "num": num, "init": True, "selective": wi.get("selective", False), - "constant": wi.get("constant", False) + "constant": wi.get("constant", False), + "uid": None, }) + while(True): + uid = int.from_bytes(os.urandom(4), "little", signed=True) + if(uid not in vars.worldinfo_u): + break + vars.worldinfo_u[uid] = vars.worldinfo[-1] + vars.worldinfo[-1]["uid"] = uid num += 1 # Clear import data @@ -2973,8 +3003,10 @@ def importAidgRequest(id): vars.authornote = js["authorsNote"] vars.actions = structures.KoboldStoryRegister() vars.worldinfo = [] + vars.worldinfo_u = {} vars.wifolders_d = {} vars.wifolders_l = [] + vars.wifolders_u = {uid: [] for uid in vars.wifolders_d} vars.lastact = "" vars.lastctx = "" @@ -2989,8 +3021,15 @@ def importAidgRequest(id): "num": num, "init": True, "selective": wi.get("selective", False), - "constant": wi.get("constant", False) + "constant": wi.get("constant", False), + "uid": None, }) + while(True): + uid = int.from_bytes(os.urandom(4), "little", signed=True) + if(uid not in vars.worldinfo_u): + break + vars.worldinfo_u[uid] = vars.worldinfo[-1] + vars.worldinfo[-1]["uid"] = uid num += 1 # Reset current save @@ -3029,8 +3068,15 @@ def wiimportrequest(): "num": num, "init": True, "selective": wi.get("selective", False), - "constant": wi.get("constant", False) + "constant": wi.get("constant", False), + "uid": None, }) + while(True): + uid = int.from_bytes(os.urandom(4), "little", signed=True) + if(uid not in vars.worldinfo_u): + break + vars.worldinfo_u[uid] = vars.worldinfo[-1] + vars.worldinfo[-1]["uid"] = uid num += 1 print("{0}".format(vars.worldinfo[0])) @@ -3053,6 +3099,7 @@ def newGameRequest(): vars.authornote = "" vars.worldinfo = [] + vars.worldinfo_u = {} vars.wifolders_d = {} vars.wifolders_l = [] vars.lastact = "" diff --git a/bridge.lua b/bridge.lua new file mode 100644 index 00000000..3e3299f0 --- /dev/null +++ b/bridge.lua @@ -0,0 +1,1112 @@ +-- KoboldAI Lua 5.4 Bridge + + +---@param _python? table +---@param _bridged? table +---@return KoboldLib, KoboldCoreLib|nil +return function(_python, _bridged) + + --========================================================================== + -- Globally allows using a _kobold_next metamethod for "Kobold" classes only + --========================================================================== + + local old_next = next + ---@generic K, V + ---@param t table + ---@param k? K + ---@return K|nil, V|nil + function next(t, k) + local meta = getmetatable(t) + return ((meta ~= nil and string.match(rawget(t, "_name"), "^Kobold") and type(meta._kobold_next) == "function") and meta._kobold_next or old_next)(t,k) + end + + + --========================================================================== + -- General utility functions + --========================================================================== + + ---@generic T + ---@param original T + ---@return T + local function deepcopy(original) + if type(original) == "table" then + local copy = {} + for k, v in old_next, original, nil do + copy[k] = deepcopy(v) + end + setmetatable(copy, deepcopy(getmetatable(original))) + return copy + end + return original + end + + ---@param path string + ---@return nil + function set_require_path(path) + local config = {} + local i = 1 + for substring in string.gmatch(package.config, "[^\n]+") do + config[i] = substring + i = i + 1 + end + package.path = path .. config[1] .. config[3] .. ".lua" .. config[2] .. path .. config[1] .. config[3] .. config[1] .. "init.lua" + package.cpath = "" + end + + + --========================================================================== + -- _bridged preprocessing + --========================================================================== + + local bridged = {} + for k, v in pairs(_bridged) do + bridged[k] = type(v) == "userdata" and _python.as_attrgetter(v) or v + end + set_require_path(bridged.lib_path) + + + --========================================================================== + -- Wraps most functions in this file so that they restore original + -- metatables prior to executing the function body + --========================================================================== + + ---@class Metatables + local metatables = {} + local type_map = { + _nil = nil, + _boolean = false, + _number = 0, + _string = "", + _function = type, + _thread = coroutine.create(function() end), + } + + function metatables:overwrite() + for k, v in pairs(type_map) do + self[k] = debug.getmetatable(v) + end + end + + function metatables:restore() + for k, v in pairs(type_map) do + debug.setmetatable(v, self[k]) + end + end + + local metatables_original = deepcopy(metatables) + metatables_original:overwrite() + + local metawrapper = {} + ---@generic T : table + ---@param t T + ---@return T + function metawrapper.__newindex(t, k, v) + if type(v) == "function" then + return rawset(t, k, function(...) + metatables:overwrite() + metatables_original:restore() + local r = {v(...)} + metatables:restore() + return table.unpack(r) + end) + else + return rawset(t, k, v) + end + end + + + --========================================================================== + -- Modules + --========================================================================== + + ---@class KoboldLib + ---@field memory string + local kobold = setmetatable({}, metawrapper) + local KoboldLib_mt = setmetatable({}, metawrapper) + local KoboldLib_getters = setmetatable({}, metawrapper) + local KoboldLib_setters = setmetatable({}, metawrapper) + + ---@param t KoboldLib + function KoboldLib_mt.__index(t, k) + local getter = KoboldLib_getters[k] + if getter ~= nil then + return getter(t) + end + return rawget(t, k) + end + + ---@param t KoboldLib + function KoboldLib_mt.__newindex(t, k, v) + local setter = KoboldLib_setters[k] + if setter ~= nil then + return setter(t, v) + end + return rawset(t, k, v) + end + + ---@class KoboldCoreLib + ---@field userscripts KoboldUserScriptList + local koboldcore = setmetatable({}, metawrapper) + local KoboldCoreLib_mt = setmetatable({}, metawrapper) + local KoboldCoreLib_getters = setmetatable({}, metawrapper) + local KoboldCoreLib_setters = setmetatable({}, metawrapper) + + ---@param t KoboldCoreLib + function KoboldCoreLib_mt.__index(t, k) + local getter = KoboldCoreLib_getters[k] + if getter ~= nil then + return getter(t, k) + end + return rawget(t, k) + end + + ---@param t KoboldCoreLib + function KoboldCoreLib_mt.__newindex(t, k, v) + local setter = KoboldCoreLib_setters[k] + if setter ~= nil then + return setter(t, k, v) + end + return rawset(t, k, v) + end + + ---@class KoboldBridgeLib + local koboldbridge = setmetatable({}, metawrapper) + + + --========================================================================== + -- Userscript API: World Info + --========================================================================== + + local inmods = setmetatable({}, metawrapper) + local genmods = setmetatable({}, metawrapper) + local outmods = setmetatable({}, metawrapper) + + local genmod_comparison_context = nil + local generating = true + local userstate = "inmod" + + local fields = setmetatable({}, metawrapper) + + ---@param t KoboldWorldInfoEntry|KoboldWorldInfoFolder|KoboldWorldInfo|KoboldWorldInfoFolderSelector + ---@return boolean + local function check_validity(t) + if not t:is_valid() then + error("Attempted to use a nonexistent/deleted `"..rawget(t, "_name").."`") + return false + end + return true + end + + ---@return nil + local function maybe_save_genmod_comparison_context() + if userstate == "genmod" and genmod_comparison_context == nil then + genmod_comparison_context = kobold.worldinfo:compute_context() + end + end + + + ---------------------------------------------------------------------------- + + ---@class KoboldWorldInfoEntry_base + ---@type table + local _ = {} + + ---@class KoboldWorldInfoEntry : KoboldWorldInfoEntry_base + ---@field key string + ---@field keysecondary string + ---@field content string + ---@field comment string + ---@field folder integer + ---@field num integer + ---@field selective boolean + ---@field constant boolean + ---@field uid integer + local KoboldWorldInfoEntry = setmetatable({ + _name = "KoboldWorldInfoEntry", + }, metawrapper) + fields.KoboldWorldInfoEntry = { + "key", + "keysecondary", + "content", + "comment", + "folder", + "num", + "selective", + "constant", + "uid", + } + local KoboldWorldInfoEntry_mt = setmetatable({}, metawrapper) + + local KoboldWorldInfoEntry_fieldtypes = { + key = "string", + keysecondary = "string", + content = "string", + comment = "string", + selective = "boolean", + constant = "boolean", + } + + ---@return boolean + function KoboldWorldInfoEntry:is_valid() + return bridged.worldinfo_u.get(self.uid) ~= nil + end + + ---@return string + function KoboldWorldInfoEntry:compute_context() + if not check_validity(self) then + return "" + end + return bridged.compute_context({self.uid}) + end + + ---@generic K + ---@param t KoboldWorldInfoEntry|KoboldWorldInfoFolder|KoboldWorldInfo|KoboldWorldInfoFolderSelector + ---@param k K + ---@return K, any + function KoboldWorldInfoEntry_mt._kobold_next(t, k) + return next(fields[rawget(t, "_name")], k) + end + + ---@param t KoboldWorldInfoEntry|KoboldWorldInfoFolder|KoboldWorldInfo|KoboldWorldInfoFolderSelector + ---@return function, KoboldWorldInfoEntry|KoboldWorldInfoFolder|KoboldWorldInfo|KoboldWorldInfoFolderSelector, nil + function KoboldWorldInfoEntry_mt.__pairs(t) + return next, t, nil + end + + ---@param t KoboldWorldInfoEntry + function KoboldWorldInfoEntry_mt.__index(t, k) + if not check_validity(t) then + return + elseif k == "uid" then + return rawget(t, "_uid") + elseif type(k) == "string" then + return bridged.get_attr(t.uid, k) + end + end + + ---@param t KoboldWorldInfoEntry + ---@return KoboldWorldInfoEntry + function KoboldWorldInfoEntry_mt.__newindex(t, k, v) + if not check_validity(t) then + return + elseif fields[rawget(t, "_name")] then + if type(k) == "string" and KoboldWorldInfoEntry_fieldtypes[k] == nil then + error("`"..rawget(t, "_name").."."..k.."` is a read-only attribute") + return + elseif type(k) == "string" and type(v) ~= KoboldWorldInfoEntry_fieldtypes[k] then + error("`"..rawget(t, "_name").."."..k.."` must be a "..KoboldWorldInfoEntry_fieldtypes[k].."; you attempted to set it to a "..type(v)) + return + else + if k ~= "comment" then + maybe_save_genmod_comparison_context() + end + bridged.set_attr(t.uid, k, v) + return t + end + end + return rawset(t, k, v) + end + + + ---------------------------------------------------------------------------- + + ---@class KoboldWorldInfoFolder_base + ---@type table + local _ = {} + + ---@class KoboldWorldInfoFolder : KoboldWorldInfoFolder_base + ---@field uid integer + ---@field comment string + local KoboldWorldInfoFolder = setmetatable({ + _name = "KoboldWorldInfoFolder", + }, metawrapper) + + fields.KoboldWorldInfoFolder = { + "uid", + } + local KoboldWorldInfoFolder_mt = setmetatable({}, metawrapper) + + ---@param u integer + ---@return KoboldWorldInfoEntry|nil + function KoboldWorldInfoFolder:finduid(u) + if not check_validity(self) or type(u) ~= "number" then + return + end + local query = bridged.worldinfo_u.get(u) + if query == nil or (rawget(self, "_name") == "KoboldWorldInfoFolder" and self.uid ~= query.get("folder")) then + return + end + local entry = deepcopy(KoboldWorldInfoEntry) + rawset(entry, "_uid", u) + return entry + end + + ---@param entries? KoboldWorldInfoEntry|table + ---@return string + function KoboldWorldInfoFolder:compute_context(entries) + if not check_validity(self) then + return + end + if entries ~= nil and type(entries) ~= "table" or (entries.name ~= nil and entries.name ~= "KoboldWorldInfoEntry") then + error("`compute_context` takes a KoboldWorldInfoEntry, table of KoboldWorldInfoEntries or nil as argument, but got a " .. type(entries)) + return "" + end + if entries.name == "KoboldWorldInfoEntry" then + entries = {entries} + end + local _entries + for k, v in pairs(entries) do + if type(v) == "table" and v.name == "KoboldWorldInfoEntry" and (rawget(self, "_name") ~= "KoboldWorldInfoFolder" or self.uid == v.uid) and v:is_valid() then + _entries[k] = v.uid + end + end + return bridged.compute_context(_entries) + end + + ---@return boolean + function KoboldWorldInfoFolder:is_valid() + return bridged.wifolders_d.get(self.uid) ~= nil + end + + ---@param t KoboldWorldInfoFolder + ---@return integer + function KoboldWorldInfoFolder_mt.__len(t) + if not check_validity(t) then + return 0 + end + return _python.builtins.len(bridged.worldinfo_u.get(t.uid)) + end + + KoboldWorldInfoFolder_mt._kobold_next = KoboldWorldInfoEntry_mt._kobold_next + + KoboldWorldInfoFolder_mt.__pairs = KoboldWorldInfoEntry_mt.__pairs + + ---@param t KoboldWorldInfoFolder|KoboldWorldInfo + ---@return KoboldWorldInfoEntry|nil + function KoboldWorldInfoFolder_mt.__index(t, k) + if not check_validity(t) then + return + elseif rawget(t, "_name") == "KoboldWorldInfoFolder" and k == "uid" then + return rawget(t, "_uid") + elseif rawget(t, "_name") == "KoboldWorldInfoFolder" and k == "comment" then + return bridged.wifolders_d.get(t.uid).__getitem__("comment") + elseif type(k) == "number" then + local query = rawget(t, "_name") == "KoboldWorldInfoFolder" and bridged.wifolders_u.get(t.uid) or bridged.worldinfo + k = math.tointeger(k) + if k == nil or k < 1 or k > _python.builtins.len(query) then + return + end + local entry = deepcopy(KoboldWorldInfoEntry) + rawset(entry, "_uid", query.__getitem__(k)) + return entry + end + end + + ---@param t KoboldWorldInfoFolder|KoboldWorldInfo + ---@return KoboldWorldInfoFolder|KoboldWorldInfo + function KoboldWorldInfoFolder_mt.__newindex(t, k, v) + if not check_validity(t) then + return + elseif type(t) == "number" and math.tointeger(t) ~= nil then + error("Cannot write to integer indices of `"..rawget(t, "_name").."`") + elseif rawget(t, "_name") == "KoboldWorldInfoFolder" and k == "uid" then + error("`"..rawget(t, "_name").."."..k.."` is a read-only attribute") + elseif t == "comment" then + if type(v) ~= "string" then + error("`"..rawget(t, "_name").."."..k.."` must be a string; you attempted to set it to a "..type(v)) + return + end + bridged.safe_setitem(bridged.wifolders_d.get(t.uid), "comment", v) + return t + else + return rawset(t, k, v) + end + end + + + ---------------------------------------------------------------------------- + + ---@class KoboldWorldInfoFolderSelector_base + ---@type table + local _ = {} + + ---@class KoboldWorldInfoFolderSelector : KoboldWorldInfoFolderSelector_base + local KoboldWorldInfoFolderSelector = setmetatable({ + _name = "KoboldWorldInfoFolderSelector", + }, metawrapper) + local KoboldWorldInfoFolderSelector_mt = setmetatable({}, metawrapper) + + ---@param u integer + ---@return KoboldWorldInfoFolder|nil + function KoboldWorldInfoFolderSelector:finduid(u) + if not check_validity(self) or type(u) ~= "number" then + return + end + local query = bridged.wifolders_d.get(u) + if query == nil then + return + end + local folder = deepcopy(KoboldWorldInfoFolder) + rawset(folder, "_uid", u) + return folder + end + + ---@return boolean + function KoboldWorldInfoFolderSelector:is_valid() + return true + end + + ---@param t KoboldWorldInfoFolderSelector + ---@return integer + function KoboldWorldInfoFolderSelector_mt.__len(t) + if not check_validity(t) then + return 0 + end + return #kobold.worldinfo + end + + KoboldWorldInfoFolderSelector_mt._kobold_next = KoboldWorldInfoEntry_mt._kobold_next + + KoboldWorldInfoFolderSelector_mt.__pairs = KoboldWorldInfoEntry_mt.__pairs + + ---@param t KoboldWorldInfoFolderSelector + ---@return KoboldWorldInfoFolder|nil + function KoboldWorldInfoFolderSelector_mt.__index(t, k) + if not check_validity(t) or type(t) ~= "number" or math.tointeger(t) == nil or t < 1 or t > _python.builtins.len(bridged.wifolders_l) then + return + end + local folder = deepcopy(KoboldWorldInfoFolder) + rawset(folder, "_uid", bridged.wifolders_l.__getitem__(k)) + return folder + end + + ---@param t KoboldWorldInfoFolderSelector + ---@return KoboldWorldInfoFolderSelector + function KoboldWorldInfoFolderSelector_mt.__newindex(t, k, v) + if check_validity(t) or (type(t) == "number" and math.tointeger(t) ~= nil) then + error("Cannot write to integer indices of `"..rawget(t, "_name").."`") + end + return rawset(t, k, v) + end + + + ---------------------------------------------------------------------------- + + ---@class KoboldWorldInfo : KoboldWorldInfoFolder_base + local KoboldWorldInfo = setmetatable({ + _name = "KoboldWorldInfo", + }, metawrapper) + local KoboldWorldInfo_mt = setmetatable({}, metawrapper) + + KoboldWorldInfo.folders = KoboldWorldInfoFolderSelector + + KoboldWorldInfo.finduid = KoboldWorldInfoFolder.finduid + + KoboldWorldInfo.compute_context = KoboldWorldInfoFolder.compute_context + + ---@return boolean + function KoboldWorldInfo:is_valid() + return true + end + + ---@param t KoboldWorldInfo + ---@return integer + function KoboldWorldInfo_mt.__len(t) + if not check_validity(t) then + return 0 + end + return _python.builtins.len(bridged.worldinfo) + end + + KoboldWorldInfo_mt._kobold_next = KoboldWorldInfoEntry_mt._kobold_next + + KoboldWorldInfo_mt.__pairs = KoboldWorldInfoEntry_mt.__pairs + + KoboldWorldInfo_mt.__index = KoboldWorldInfoFolder_mt.__index + + KoboldWorldInfo_mt.__newindex = KoboldWorldInfoFolder_mt.__newindex + + kobold.worldinfo = KoboldWorldInfo + + + --========================================================================== + -- Userscript API: Settings + --========================================================================== + + ---@class KoboldSettings_base + ---@type table + local _ = {} + + ---@class KoboldSettings : KoboldSettings_base + local KoboldSettings = setmetatable({ + _name = "KoboldSettings", + }, metawrapper) + local KoboldSettings_mt = setmetatable({}, metawrapper) + + ---@generic K + ---@param t KoboldSettings + ---@param k K + ---@return K, any + function KoboldSettings_mt._kobold_next(t, k) + local v + repeat + k, v = next() + until type(k) ~= "string" or k ~= "_name" + return k, v + end + + ---@param t KoboldSettings + ---@return function, KoboldSettings, nil + function KoboldSettings_mt.__pairs(t) + return next, t, nil + end + + ---@param t KoboldSettings + ---@return any, boolean + function KoboldSettings_mt.__index(t, k) + if type(k) ~= "string" then + return + end + if k == "gen_len" then + return bridged.get_gen_len() + elseif bridged.has_setting(k) then + return bridged.get_setting(k), true + else + return nil, false + end + end + + ---@param t KoboldSettings_base + function KoboldSettings_mt.__newindex(t, k, v) + if k == "gen_len" and type(v) == "number" and math.tointeger(v) ~= nil and v >= 0 then + bridged.set_gen_len(v) + elseif type(k) == "string" and bridged.has_setting(k) and type(v) == type(bridged.get_setting(k)) then + return bridged.set_setting(k, v) + end + return t + end + + kobold.settings = KoboldSettings + + + --========================================================================== + -- Userscript API: Memory + --========================================================================== + + ---@param t KoboldLib + ---@return string + function KoboldLib_getters.memory(t) + return bridged.get_memory() + end + + ---@param t KoboldLib + ---@param v string + ---@return KoboldLib + function KoboldLib_setters.memory(t, v) + if type(t) ~= "string" then + error("`KoboldLib.memory` must be a string; you attempted to set it to a "..type(v)) + return + end + maybe_save_genmod_comparison_context() + bridged.set_memory(v) + end + + + --========================================================================== + -- Userscript API: Utilities + --========================================================================== + + ---@param str string + ---@return table + function kobold.encode(str) + if type(str) ~= "string" then + error("`encode` takes a string as argument, but got a " .. type(str)) + return + end + local encoded = {} + local i = 1 + for token in _python.iter(bridged.encode(str)) do + encoded[i] = token + i = i + 1 + end + return encoded + end + + ---@param tok integer|table + ---@return string + function kobold.decode(tok) + if type(tok) ~= "number" and type(tok) ~= "table" then + error("`decode` takes a number or table of numbers as argument, but got a " .. type(tok)) + return + end + if type(tok) ~= "number" then + tok = {tok} + end + for k, v in ipairs(tok) do + tok[k] = math.tointeger(v) + if tok[k] == nil then + error "`decode` got a table with one or more non-integer values" + return + end + end + return bridged.decode(_python.builtins.list(tok)) + end + + ---@return nil + function kobold.halt_generation() + generating = false + end + + + --========================================================================== + -- Core script API + --========================================================================== + + koboldbridge.userscripts = {} ---@type table + koboldbridge.num_userscripts = 0 + koboldbridge.inmod = nil ---@type function|nil + koboldbridge.genmod = nil ---@type function|nil + koboldbridge.outmod = nil ---@type function|nil + + ---@class KoboldUserScript + ---@field inmod function|nil + ---@field genmod function|nil + ---@field outmod function|nil + + ---@class KoboldCoreScript + ---@field inmod function|nil + ---@field genmod function|nil + ---@field outmod function|nil + + + ---------------------------------------------------------------------------- + + ---@class KoboldUserScriptModule + ---@field filename string + ---@field modulename string + ---@field description string + ---@field inmod function|nil + ---@field genmod function|nil + ---@field outmod function|nil + local KoboldUserScriptModule = setmetatable({ + _name = "KoboldUserScriptModule", + }, metawrapper) + local KoboldUserScriptModule_mt = setmetatable({}, metawrapper) + + local KoboldUserScriptModule_fields = { + filename = false, + modulename = false, + description = false, + inmod = false, + genmod = false, + outmod = false, + } + + ---@generic K + ---@param t KoboldUserScriptModule + ---@param k K + ---@return K, any + function KoboldUserScriptModule_mt._kobold_next(t, k) + k = (next(KoboldUserScriptModule_fields, k)) + return k, t[k] + end + + ---@param t KoboldUserScriptModule + ---@return function, KoboldUserScriptModule, nil + function KoboldUserScriptModule_mt.__pairs(t) + return next, t, nil + end + + ---@param t KoboldUserScriptModule + function KoboldUserScriptModule_mt.__index(t, k) + if type(k) == "string" and KoboldUserScriptModule_fields[k] ~= nil then + return rawget(t, "_" .. k) + end + return rawget(t, k) + end + + ---@param t KoboldUserScriptModule + function KoboldUserScriptModule_mt.__newindex(t, k, v) + error("`"..rawget(t, "_name").."` is a read-only class") + end + + + ---------------------------------------------------------------------------- + + ---@class KoboldUserScriptList_base + ---@type table + local _ = {} + + ---@class KoboldUserScriptList : KoboldUserScriptList_base + local KoboldUserScriptList = setmetatable({ + _name = "KoboldUserScriptList", + }, metawrapper) + local KoboldUserScriptList_mt = setmetatable({}, metawrapper) + + ---@param t KoboldUserScriptList + ---@return integer + function KoboldUserScriptList_mt.__len(t) + return koboldbridge.num_userscripts + end + + ---@param t KoboldUserScriptList + ---@param k integer + ---@return KoboldUserScriptModule|nil + function KoboldUserScriptList_mt.__index(t, k) + if type(k) == "number" and math.tointeger(k) ~= nil then + return koboldbridge.userscripts[k] + end + end + + ---@generic K + ---@param t KoboldUserScriptList + ---@param k K + ---@return K, any + function KoboldUserScriptList_mt._kobold_next(t, k) + if k == nil then + k = 0 + elseif type(k) ~= "number" then + return nil + end + k = k + 1 + local v = t[k] + if v == nil then + return nil + end + return v.filename, v + end + + ---@param t KoboldUserScriptList + ---@return function, KoboldUserScriptList, nil + function KoboldUserScriptList_mt.__pairs(t) + return next, t, nil + end + + ---@param t KoboldUserScriptList + function KoboldUserScriptList_mt.__newindex(t, k, v) + error("`"..rawget(t, "_name").."` is a read-only class") + end + + + ---------------------------------------------------------------------------- + + ---@param t KoboldCoreLib + ---@return string + function KoboldCoreLib_getters.userscripts(t) + return koboldbridge.userscripts + end + + ---@param t KoboldCoreLib + ---@param v string + ---@return KoboldCoreLib + function KoboldCoreLib_setters.userscripts(t, v) + error("`KoboldCoreLib.userscripts` is a read-only attribute") + end + + + --========================================================================== + -- Sandboxing code + --========================================================================== + + local envs = {} + + local old_load = load + local function safe_load(chunk, chunkname, mode, env) + if mode == nil then + mode = "t" + elseif mode ~= "t" then + error("Calling `load` with a `mode` other than 't' is disabled for security reasons") + return + end + if env == nil then + env = _G + end + return old_load(chunk, chunkname, mode, env) + end + + local old_loadfile = loadfile + local old_package_loaded = package.loaded + local old_package_searchers = package.searchers + ---@param modname string + ---@param env table + ---@return any, string|nil + local function safe_require_with_env(modname, env) + if modname == "bridge" then + return function() return _G.kobold, _G.koboldcore end + end + if type(modname) == "number" then + modname = tostring(modname) + elseif type(modname) ~= "string" then + error("bad argument #1 to 'require' (string expected, got "..type(modname)..")") + return + end + local allowsearch = type(modname) == "string" and string.match(modname, "[^%w._]") == nil and string.match(modname, "%.%.") == nil + if allowsearch and old_package_loaded[modname] then + return old_package_loaded[modname] + end + local loader, path + local errors = {} + local n_errors = 0 + for k, v in ipairs(old_package_searchers) do + loader, path = v(modname) + if allowsearch and type(loader) == "function" then + break + elseif type(loader) == "string" then + n_errors = n_errors + 1 + errors[n_errors] = "\n\t" .. loader + end + end + if not allowsearch or type(loader) ~= "function" then + error("module '" .. modname .. "' not found:" .. table.concat(errors)) + return + end + local retval = old_loadfile(path, "t", env)() + old_package_loaded[modname] = retval == nil or retval + return old_package_loaded[modname], path + end + ---@param modname string + ---@return any, string|nil + local function safe_require(modname) + return safe_require_with_env(modname, _G) + end + + local sandbox_template_env = { + assert = assert, + connectgarbage = collectgarbage, + error = error, + getmetatable = getmetatable, + ipairs = ipairs, + load = safe_load, + next = next, + pairs = pairs, + pcall = pcall, + print = print, + rawequal = rawequal, + rawget = rawget, + rawlen = rawlen, + rawset = rawset, + select = select, + setmetatable = setmetatable, + tonumber = tonumber, + tostring = tostring, + type = type, + _VERSION = _VERSION, + warn = warn, + xpcall = xpcall, + coroutine = { + close = coroutine.close, + create = coroutine.create, + isyieldable = coroutine.isyieldable, + resume = coroutine.resume, + running = coroutine.running, + status = coroutine.status, + wrap = coroutine.wrap, + yield = coroutine.yield, + }, + require = safe_require, + package = { + config = package.config, + }, + string = { + byte = string.byte, + char = string.char, + dump = string.dump, + find = string.find, + format = string.format, + gmatch = string.gmatch, + gsub = string.gsub, + len = string.len, + lower = string.lower, + match = string.match, + pack = string.pack, + packsize = string.packsize, + rep = string.rep, + reverse = string.reverse, + sub = string.sub, + unpack = string.unpack, + upper = string.upper, + }, + utf8 = { + char = utf8.char, + charpattern = utf8.charpattern, + codes = utf8.codes, + codepoint = utf8.codepoint, + len = utf8.len, + offset = utf8.offset, + }, + table = { + concat = table.concat, + insert = table.insert, + move = table.move, + pack = table.pack, + remove = table.remove, + sort = table.sort, + unpack = table.unpack, + }, + math = { + abs = math.abs, + acos = math.acos, + asin = math.asin, + atan = math.atan, + atan2 = math.atan2, + ceil = math.ceil, + cos = math.cos, + cosh = math.cosh, + deg = math.deg, + exp = math.exp, + floor = math.floor, + fmod = math.fmod, + frexp = math.frexp, + huge = math.huge, + ldexp = math.ldexp, + log = math.log, + log10 = math.log10, + max = math.max, + maxinteger = math.maxinteger, + min = math.min, + mininteger = math.mininteger, + modf = math.modf, + pi = math.pi, + pow = math.pow, + rad = math.rad, + random = math.random, + randomseed = function() warn("WARNING: math.randomseed() is not permitted; please use the mt19937ar library instead") end, + sin = math.sin, + sinh = math.sinh, + sqrt = math.sqrt, + tan = math.tan, + tanh = math.tanh, + tointeger = math.tointeger, + type = math.type, + ult = math.ult, + }, + io = { + read = io.read, + write = io.write, + flush = io.flush, + type = io.type, + }, + os = { + clock = os.clock, + date = os.date, + difftime = os.difftime, + exit = function() end, + getenv = os.getenv, + time = os.time, + tmpname = os.tmpname, + }, + debug = { + getinfo = debug.getinfo, + gethook = debug.gethook, + getmetatable = debug.getmetatable, + getuservalue = debug.getuservalue, + sethook = debug.sethook, + setmetatable = debug.setmetatable, + setuservalue = debug.setuservalue, + traceback = debug.traceback, + upvalueid = debug.upvalueid, + }, + } + + function koboldbridge.get_universe(universe) + local env = envs[universe] + if env == nil then + envs[universe] = deepcopy(sandbox_template_env) + env = envs[universe] + envs[universe].kobold = deepcopy(kobold) + if universe == 0 then + envs[universe].koboldcore = deepcopy(koboldcore) + end + env._G = env + end + return env + end + + function koboldbridge.obliterate_multiverse() + envs = {} + end + + + --========================================================================== + -- Connection to aiserver.py + --========================================================================== + + ---@return nil + function koboldbridge.load_userscripts(filenames, modulenames, descriptions) + local old_path = set_require_path(bridged.userscript_path) + koboldbridge.userscripts = {} + koboldbridge.num_userscripts = 0 + for i, filename in _python.enumerate(filenames) do + bridged.load_callback(filename) + local _userscript = safe_require_with_env(filename, koboldbridge.get_universe(filename)) + local userscript = deepcopy(KoboldUserScriptModule) + rawset(userscript, "_inmod", _userscript.inmod) + rawset(userscript, "_genmod", _userscript.genmod) + rawset(userscript, "_outmod", _userscript.outmod) + rawset(userscript, "_filename", filename) + rawset(userscript, "_modulename", modulenames[i]) + rawset(userscript, "_description", descriptions[i]) + koboldbridge.userscripts[i+1] = userscript + koboldbridge.num_userscripts = i + 1 + end + set_require_path(old_path) + end + + ---@return nil + function koboldbridge.load_corescript(filename) + set_require_path(bridged.corescript_path) + local corescript = safe_require_with_env(filename, koboldbridge.get_universe(0)) + koboldbridge.inmod = corescript.inmod + koboldbridge.genmod = corescript.genmod + koboldbridge.outmod = corescript.outmod + set_require_path(bridged.lib_path) + end + + ---@return any, any, any + function koboldbridge.execute() + local i, g, o + local num_generated = 0 + g = {} + generating = true + userstate = "inmod" + if koboldbridge.inmod ~= nil then + i = koboldbridge.inmod() + end + userstate = "genmod" + bridged.start_generation() + while generating and num_generated < bridged.get_gen_len() do + bridged.generation_step() + if koboldbridge.genmod ~= nil then + table.insert(g, koboldbridge.genmod()) + if genmod_comparison_context ~= kobold.worldinfo:compute_context() then + bridged.register_context_change() + genmod_comparison_context = nil + end + end + num_generated = num_generated + 1 + end + userstate = "outmod" + bridged.stop_generation() + if koboldbridge.outmod ~= nil then + o = koboldbridge.outmod() + end + generating = true + userstate = "inmod" + return i, g, o + end + + + ---------------------------------------------------------------------------- + + metawrapper.__newindex = nil + setmetatable(KoboldWorldInfoEntry, KoboldWorldInfoEntry_mt) + setmetatable(KoboldWorldInfoFolder, KoboldWorldInfoFolder_mt) + setmetatable(KoboldWorldInfoFolderSelector, KoboldWorldInfoFolderSelector_mt) + setmetatable(KoboldWorldInfo, KoboldWorldInfo_mt) + setmetatable(KoboldUserScriptModule, KoboldUserScriptModule_mt) + setmetatable(KoboldUserScriptList, KoboldUserScriptList_mt) + setmetatable(kobold, KoboldLib_mt) + setmetatable(koboldcore, KoboldCoreLib_mt) + + return kobold, koboldcore, koboldbridge +end diff --git a/extern/lualibs/base64.lua b/extern/lualibs/base64.lua new file mode 100644 index 00000000..7fda45f2 --- /dev/null +++ b/extern/lualibs/base64.lua @@ -0,0 +1,4 @@ +-- base64 1.5.3 | /base64.lua | https://github.com/iskolbin/lbase64 | License: Unlicense | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +local a={}local b=_G.bit32 and _G.bit32.extract;if not b then if _G.bit then local c,d,e=_G.bit.lshift,_G.bit.rshift,_G.bit.band;b=function(f,g,h)return e(d(f,g),c(1,h)-1)end elseif _G._VERSION=="Lua 5.1"then b=function(f,g,h)local i=0;local j=2^g;for k=0,h-1 do local l=j+j;if f%l>=j then i=i+2^k end;j=l end;return i end else b=load[[return function( v, from, width ) + return ( v >> from ) & ((1 << width) - 1) + end]]()end end;function a.makeencoder(m,n,o)local p={}for q,r in pairs{[0]='A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9',m or'+',n or'/',o or'='}do p[q]=r:byte()end;return p end;function a.makedecoder(m,n,o)local s={}for q,t in pairs(a.makeencoder(m,n,o))do s[t]=q end;return s end;local u=a.makeencoder()local v=a.makedecoder()local r,w=string.char,table.concat;function a.encode(x,p,y)p=p or u;local z,A,B={},1,#x;local C=B%3;local D={}for k=1,B-C,3 do local E,F,G=x:byte(k,k+2)local f=E*0x10000+F*0x100+G;local H;if y then H=D[f]if not H then H=r(p[b(f,18,6)],p[b(f,12,6)],p[b(f,6,6)],p[b(f,0,6)])D[f]=H end else H=r(p[b(f,18,6)],p[b(f,12,6)],p[b(f,6,6)],p[b(f,0,6)])end;z[A]=H;A=A+1 end;if C==2 then local E,F=x:byte(B-1,B)local f=E*0x10000+F*0x100;z[A]=r(p[b(f,18,6)],p[b(f,12,6)],p[b(f,6,6)],p[64])elseif C==1 then local f=x:byte(B)*0x10000;z[A]=r(p[b(f,18,6)],p[b(f,12,6)],p[64],p[64])end;return w(z)end;function a.decode(I,s,y)s=s or v;local J='[^%w%+%/%=]'if s then local m,n;for t,q in pairs(s)do if q==62 then m=t elseif q==63 then n=t end end;J=('[^%%w%%%s%%%s%%=]'):format(r(m),r(n))end;I=I:gsub(J,'')local D=y and{}local z,A={},1;local B=#I;local K=I:sub(-2)=='=='and 2 or I:sub(-1)=='='and 1 or 0;for k=1,K>0 and B-4 or B,4 do local E,F,G,L=I:byte(k,k+3)local H;if y then local M=E*0x1000000+F*0x10000+G*0x100+L;H=D[M]if not H then local f=s[E]*0x40000+s[F]*0x1000+s[G]*0x40+s[L]H=r(b(f,16,8),b(f,8,8),b(f,0,8))D[M]=H end else local f=s[E]*0x40000+s[F]*0x1000+s[G]*0x40+s[L]H=r(b(f,16,8),b(f,8,8),b(f,0,8))end;z[A]=H;A=A+1 end;if K==1 then local E,F,G=I:byte(B-3,B-1)local f=s[E]*0x40000+s[F]*0x1000+s[G]*0x40;z[A]=r(b(f,16,8),b(f,8,8))elseif K==2 then local E,F=I:byte(B-3,B-2)local f=s[E]*0x40000+s[F]*0x1000;z[A]=r(b(f,16,8))end;return w(z)end;return a diff --git a/extern/lualibs/hashings/adler32.lua b/extern/lualibs/hashings/adler32.lua new file mode 100644 index 00000000..27e1ebbd --- /dev/null +++ b/extern/lualibs/hashings/adler32.lua @@ -0,0 +1,6 @@ +-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/adler32.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2016 John Schember +-- 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 a=require("string")local b=require("nums.uintn").u32;local c={}local d={__metatable={},__index=c}local e=65521;c.digest_size=8;c.block_size=8;function c:new(f)if self~=c then return nil,"First argument must be self"end;local g=setmetatable({},d)g._b1=b(1)g._b2=b(0)if f~=nil then g:update(f)end;return g end;setmetatable(c,{__call=c.new})function c:copy()local g=c:new()g._b1=self._b1:copy()g._b2=self._b2:copy()return g end;function c:update(f)local h;if f==nil then f=""end;f=tostring(f)for i=1,#f do h=a.byte(f,i)self._b1=(self._b1+h)%e;self._b2=(self._b2+self._b1)%e end end;function c:digest()return(self._b2<<16|self._b1):asbytestring()end;function c:hexdigest()local j;local k={}j=self:digest()for i=1,#j do k[i]=a.format("%02X",a.byte(j,i))end;return table.concat(k)end;return c diff --git a/extern/lualibs/hashings/blake2b.lua b/extern/lualibs/hashings/blake2b.lua new file mode 100644 index 00000000..dbcabee0 --- /dev/null +++ b/extern/lualibs/hashings/blake2b.lua @@ -0,0 +1,6 @@ +-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/blake2b.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2016 John Schember +-- 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 a=require("string")local b=require("nums.uintb").u64;local c=require("nums.uintn").u8;local d={}local e={__metatable={},__index=d}d.digest_size=64;d.block_size=128;local f={b("0x6A09E667F3BCC908"),b("0xBB67AE8584CAA73B"),b("0x3C6EF372FE94F82B"),b("0xA54FF53A5F1D36F1"),b("0x510E527FADE682D1"),b("0x9B05688C2B3E6C1F"),b("0x1F83D9ABFB41BD6B"),b("0x5BE0CD19137E2179")}local g={{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16},{15,11,5,9,10,16,14,7,2,13,1,3,12,8,6,4},{12,9,13,1,6,3,16,14,11,15,4,7,8,2,10,5},{8,10,4,2,14,13,12,15,3,7,6,11,5,1,16,9},{10,1,6,8,3,5,11,16,15,2,12,13,7,9,4,14},{3,13,7,11,1,12,9,4,5,14,8,6,16,15,2,10},{13,6,2,16,15,14,5,11,1,8,7,4,10,3,9,12},{14,12,8,15,13,2,4,10,6,1,16,5,9,7,3,11},{7,16,15,10,12,4,1,9,13,3,14,8,2,5,11,6},{11,3,9,5,8,7,2,6,16,12,10,15,4,13,14,1},{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16},{15,11,5,9,10,16,14,7,2,13,1,3,12,8,6,4}}local function h(i,j)return i>>j|(i<<64-j)end;local function k(l,m)l._t0=l._t0+m;if l._t0128 do k(self,128)x(self)end end;function d:digest()local B;local C={}local y;B=self:copy()k(B,#B._data)B._last=true;B._data=B._data..a.rep(a.char(0),128-#B._data)x(B)for p=1,#B._h do C[p]=B._h[p]:swape():asbytestring()end;return table.concat(C)end;function d:hexdigest()local D;local C={}D=self:digest()for p=1,#D do C[p]=a.format("%02X",a.byte(D,p))end;return table.concat(C)end;return d diff --git a/extern/lualibs/hashings/blake2s.lua b/extern/lualibs/hashings/blake2s.lua new file mode 100644 index 00000000..ed46923c --- /dev/null +++ b/extern/lualibs/hashings/blake2s.lua @@ -0,0 +1,6 @@ +-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/blake2s.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2016 John Schember +-- 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 a=require("string")local b=require("nums.uintn").u32;local c=require("nums.uintn").u8;local d={}local e={__metatable={},__index=d}d.digest_size=32;d.block_size=64;local f={b(0x6A09E667),b(0xBB67AE85),b(0x3C6EF372),b(0xA54FF53A),b(0x510E527F),b(0x9B05688C),b(0x1F83D9AB),b(0x5BE0CD19)}local g={{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16},{15,11,5,9,10,16,14,7,2,13,1,3,12,8,6,4},{12,9,13,1,6,3,16,14,11,15,4,7,8,2,10,5},{8,10,4,2,14,13,12,15,3,7,6,11,5,1,16,9},{10,1,6,8,3,5,11,16,15,2,12,13,7,9,4,14},{3,13,7,11,1,12,9,4,5,14,8,6,16,15,2,10},{13,6,2,16,15,14,5,11,1,8,7,4,10,3,9,12},{14,12,8,15,13,2,4,10,6,1,16,5,9,7,3,11},{7,16,15,10,12,4,1,9,13,3,14,8,2,5,11,6},{11,3,9,5,8,7,2,6,16,12,10,15,4,13,14,1}}local function h(i,j)return i>>j|(i<<32-j)end;local function k(l,m)l._t0=l._t0+m;if l._t064 do k(self,64)x(self)end end;function d:digest()local B;local C={}B=self:copy()k(B,#B._data)B._last=true;B._data=B._data..a.rep(a.char(0),64-#B._data)x(B)for p=1,#B._h do C[p]=B._h[p]:swape():asbytestring()end;return table.concat(C)end;function d:hexdigest()local D;local C={}D=self:digest()for p=1,#D do C[p]=a.format("%02X",a.byte(D,p))end;return table.concat(C)end;return d diff --git a/extern/lualibs/hashings/crc32.lua b/extern/lualibs/hashings/crc32.lua new file mode 100644 index 00000000..6a1d40cc --- /dev/null +++ b/extern/lualibs/hashings/crc32.lua @@ -0,0 +1,6 @@ +-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/crc32.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2016 John Schember +-- 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 a=require("string")local b=require("nums.uintn").u32;local c={}local d={__metatable={},__index=c}c.digest_size=8;c.block_size=8;local function e(f)end;function c:new(g)if self~=c then return nil,"First argument must be self"end;local h=setmetatable({},d)h._crc=b(0xFFFFFFFF)if g~=nil then h:update(g)end;return h end;setmetatable(c,{__call=c.new})function c:copy()local h=c:new()h._crc=self._crc:copy()return h end;function c:update(g)local i;local j;if g==nil then g=""end;g=tostring(g)for k=1,#g do i=a.byte(g,k)self._crc=self._crc~i;for l=1,8 do j=self._crc&1*-1;self._crc=self._crc>>1~(0xEDB88320&j)end end end;function c:digest()return~self._crc:asbytestring()end;function c:hexdigest()local m;local n={}m=self:digest()for k=1,#m do n[k]=a.format("%02X",a.byte(m,k))end;return table.concat(n)end;return c diff --git a/extern/lualibs/hashings/hmac.lua b/extern/lualibs/hashings/hmac.lua new file mode 100644 index 00000000..9efad303 --- /dev/null +++ b/extern/lualibs/hashings/hmac.lua @@ -0,0 +1,6 @@ +-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/hmac.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2016 John Schember +-- 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 a=require("string")local b={}local c={__metatable={},__index=b}function b:new(d,e,f)local g;local h={}local i={}if self~=b then return nil,"First argument must be self"end;local j=setmetatable({},c)j._hm=d;if#e>d.block_size then g=d(e)e=g:digest()end;for k=1,#e do h[#h+1]=a.byte(e,k)end;for k=#e+1,d.block_size do h[#h+1]=0 end;j._opad={}for k=1,#h do i[k]=a.char(h[k]~0x36)j._opad[k]=a.char(h[k]~0x5C)end;i=table.concat(i)j._opad=table.concat(j._opad)j._hash=j._hm(i)if f~=nil then j._hash:update(f)end;return j end;setmetatable(b,{__call=b.new})function b:copy()local j=setmetatable({},c)j._hm=self._hm;j._hash=self._hash:copy()j._opad=self._opad;return j end;function b:update(f)self._hash:update(f)end;function b:digest()local l;local m;local g;l=self:copy()m=l._hash:digest()g=l._hm(l._opad)g:update(m)return g:digest()end;function b:hexdigest()local n;local o={}n=self:digest()for k=1,#n do o[k]=a.format("%02X",a.byte(n,k))end;return table.concat(o)end;return b diff --git a/extern/lualibs/hashings/init.lua b/extern/lualibs/hashings/init.lua new file mode 100644 index 00000000..0e107966 --- /dev/null +++ b/extern/lualibs/hashings/init.lua @@ -0,0 +1,6 @@ +-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/init.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2016 John Schember +-- 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 a={}a.adler32=require("hashings.adler32")a.blake2b=require("hashings.blake2b")a.blake2s=require("hashings.blake2s")a.crc32=require("hashings.crc32")a.md5=require("hashings.md5")a.ripemd160=require("hashings.ripemd160")a.sha1=require("hashings.sha1")a.sha256=require("hashings.sha256")a.sha3_256=require("hashings.sha3_256")a.sha3_512=require("hashings.sha3_512")a.sha512=require("hashings.sha512")a.whirlpool=require("hashings.whirlpool")a.hmac=require("hashings.hmac")a.pbkdf2=require("hashings.pbkdf2")a.algorithms={"adler32","blake2b","blake2s","crc32","md5","ripemd160","sha1","sha256","sha3_256","sha3_512","sha512","whirlpool"}local b={adler32=a.adler32,blake2b=a.blake2b,blake2s=a.blake2s,crc32=a.crc32,md5=a.md5,ripemd160=a.ripemd160,sha1=a.sha1,sha256=a.sha256,sha3_256=a.sha3_256,sha3_512=a.sha3_512,sha512=a.sha512,whirlpool=a.whirlpool}function a:new(c,d)local e;e=b[c]if e==nil then return nil end;return e:new(d)end;setmetatable(a,{__call=a.new})return a diff --git a/extern/lualibs/hashings/keccak.lua b/extern/lualibs/hashings/keccak.lua new file mode 100644 index 00000000..1f7bec4b --- /dev/null +++ b/extern/lualibs/hashings/keccak.lua @@ -0,0 +1,6 @@ +-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/keccak.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2016 John Schember +-- 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 a=require("string")local b=require("nums.uintb").u64;local c={}local d={__metatable={},__index=c}local e={{5,2},{1,3},{2,4},{3,5},{4,1}}local f={11,8,12,18,19,4,6,17,9,22,25,5,16,24,20,14,13,3,21,15,23,10,7,2}local g={1,3,6,10,15,21,28,36,45,55,2,14,27,41,56,8,25,43,62,18,39,61,20,44}local h={{2,3},{3,4},{4,5},{5,1},{1,2},{7,8},{8,9},{9,10},{10,6},{6,7},{12,13},{13,14},{14,15},{15,11},{11,12},{17,18},{18,19},{19,20},{20,16},{16,17},{22,23},{23,24},{24,25},{25,21},{21,22}}local i={b("0x1"),b("0x8082"),b("0x800000000000808A"),b("0x8000000080008000"),b("0x808B"),b("0x80000001"),b("0x8000000080008081"),b("0x8000000000008009"),b("0x8A"),b("0x88"),b("0x80008009"),b("0x8000000A"),b("0x8000808B"),b("0x800000000000008B"),b("0x8000000000008089"),b("0x8000000000008003"),b("0x8000000000008002"),b("0x8000000000000080"),b("0x800A"),b("0x800000008000000A"),b("0x8000000080008081"),b("0x8000000000008080"),b("0x80000001"),b("0x8000000080008008")}local function j(k,l)return k<>64-l)end;local function m(n)local o;local p;for q=1,n._block_size,8 do o=q//8+1;p=q//8*8+1;n._s[o]=n._s[o]~(b(a.byte(n._data,p))|(b(a.byte(n._data,p+1))<<8)|(b(a.byte(n._data,p+2))<<16)|(b(a.byte(n._data,p+3))<<24)|(b(a.byte(n._data,p+4))<<32)|(b(a.byte(n._data,p+5))<<40)|(b(a.byte(n._data,p+6))<<48)|(b(a.byte(n._data,p+7))<<56))end;n._data=n._data:sub(n._block_size+1)end;local function r(s)local t={}local u;for q=1,5 do t[q]=s[q]~s[q+5]~s[q+10]~s[q+15]~s[q+20]end;for q=1,5 do u=t[e[q][1]]~j(t[e[q][2]],1)for o=q,25,5 do s[o]=s[o]~u end end end;local function v(s)local w;local u;u=s[2]:copy()for q=1,24 do w=s[f[q]]s[f[q]]=j(u,g[q])u=w end end;local function x(s)local t={}for q=1,25 do t[q]=s[q]:copy()end;for q=1,25 do s[q]=s[q]~(~t[h[q][1]]&t[h[q][2]])end end;local function y(s,l)s[1]=s[1]~i[l]end;function c:new(z,A,B)if self~=c then return nil,"First argument must be self"end;if z>200 then return nil,"Invalid block size"end;local C=setmetatable({},d)C._block_size=z;C._digest_size=A;C._data=""C._s={}for q=1,25 do C._s[q]=b(0)end;if B~=nil then C:update(B)end;return C end;setmetatable(c,{__call=c.new})function c:copy()local C=setmetatable({},d)C._block_size=self._block_size;C._digest_size=self._digest_size;C._data=self._data;C._s={}for q=1,25 do C._s[q]=self._s[q]:copy()end;return C end;function c:update(B)if B==nil then B=""end;B=tostring(B)self._data=self._data..B;while#self._data>=self._block_size do m(self)for q=1,24 do r(self._s)v(self._s)x(self._s)y(self._s,q)end end end;function c:digest()local D;local B;local E={}D=self:copy()if#D._data==D._block_size-1 then B=a.char(0x06|0x80)else B=a.char(0x06)..a.rep(a.char(0),D._block_size-#D._data-2)..a.char(0x80)end;D:update(B)for q=1,D._digest_size//8 do E[q]=D._s[q]:swape():asbytestring()end;return table.concat(E)end;function c:hexdigest()local F;local E={}F=self:digest()for q=1,#F do E[q]=a.format("%02X",a.byte(F,q))end;return table.concat(E)end;return c diff --git a/extern/lualibs/hashings/md5.lua b/extern/lualibs/hashings/md5.lua new file mode 100644 index 00000000..d24bed22 --- /dev/null +++ b/extern/lualibs/hashings/md5.lua @@ -0,0 +1,6 @@ +-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/md5.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2016 John Schember +-- 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 a=require("string")local b=require("nums.uintn").u32;local c={}local d={__metatable={},__index=c}c.digest_size=16;c.block_size=64;local function e(f,g,h)return f&g|(~f&h)end;local function i(f,g,h)return f&h|(g&~h)end;local function j(f,g,h)return f~g~h end;local function k(f,g,h)return g~(f|~h)end;local function l(m,n)return m<>32-n)end;local function o(p,q,r,s,t,m,u,v)return l(q+p(r,s,t)+m+v,u)+r end;local function w(x,y,z,A,f)local q=x;local r=y;local s=z;local t=A;q=o(e,q,r,s,t,f[1],7,0xD76AA478)t=o(e,t,q,r,s,f[2],12,0xE8C7B756)s=o(e,s,t,q,r,f[3],17,0x242070DB)r=o(e,r,s,t,q,f[4],22,0xC1BDCEEE)q=o(e,q,r,s,t,f[5],7,0xF57C0FAF)t=o(e,t,q,r,s,f[6],12,0x4787C62A)s=o(e,s,t,q,r,f[7],17,0xA8304613)r=o(e,r,s,t,q,f[8],22,0xFD469501)q=o(e,q,r,s,t,f[9],7,0x698098D8)t=o(e,t,q,r,s,f[10],12,0x8B44F7AF)s=o(e,s,t,q,r,f[11],17,0xFFFF5BB1)r=o(e,r,s,t,q,f[12],22,0x895CD7BE)q=o(e,q,r,s,t,f[13],7,0x6B901122)t=o(e,t,q,r,s,f[14],12,0xFD987193)s=o(e,s,t,q,r,f[15],17,0xA679438E)r=o(e,r,s,t,q,f[16],22,0x49B40821)q=o(i,q,r,s,t,f[2],5,0xF61E2562)t=o(i,t,q,r,s,f[7],9,0xC040B340)s=o(i,s,t,q,r,f[12],14,0x265E5A51)r=o(i,r,s,t,q,f[1],20,0xE9B6C7AA)q=o(i,q,r,s,t,f[6],5,0xD62F105D)t=o(i,t,q,r,s,f[11],9,0x2441453)s=o(i,s,t,q,r,f[16],14,0xD8A1E681)r=o(i,r,s,t,q,f[5],20,0xE7D3FBC8)q=o(i,q,r,s,t,f[10],5,0x21E1CDE6)t=o(i,t,q,r,s,f[15],9,0xC33707D6)s=o(i,s,t,q,r,f[4],14,0xF4D50D87)r=o(i,r,s,t,q,f[9],20,0x455A14ED)q=o(i,q,r,s,t,f[14],5,0xA9E3E905)t=o(i,t,q,r,s,f[3],9,0xFCEFA3F8)s=o(i,s,t,q,r,f[8],14,0x676F02D9)r=o(i,r,s,t,q,f[13],20,0x8D2A4C8A)q=o(j,q,r,s,t,f[6],4,0xFFFA3942)t=o(j,t,q,r,s,f[9],11,0x8771F681)s=o(j,s,t,q,r,f[12],16,0x6D9D6122)r=o(j,r,s,t,q,f[15],23,0xFDE5380C)q=o(j,q,r,s,t,f[2],4,0xA4BEEA44)t=o(j,t,q,r,s,f[5],11,0x4BDECFA9)s=o(j,s,t,q,r,f[8],16,0xF6BB4B60)r=o(j,r,s,t,q,f[11],23,0xBEBFBC70)q=o(j,q,r,s,t,f[14],4,0x289B7EC6)t=o(j,t,q,r,s,f[1],11,0xEAA127FA)s=o(j,s,t,q,r,f[4],16,0xD4EF3085)r=o(j,r,s,t,q,f[7],23,0x4881D05)q=o(j,q,r,s,t,f[10],4,0xD9D4D039)t=o(j,t,q,r,s,f[13],11,0xE6DB99E5)s=o(j,s,t,q,r,f[16],16,0x1FA27CF8)r=o(j,r,s,t,q,f[3],23,0xC4AC5665)q=o(k,q,r,s,t,f[1],6,0xF4292244)t=o(k,t,q,r,s,f[8],10,0x432AFF97)s=o(k,s,t,q,r,f[15],15,0xAB9423A7)r=o(k,r,s,t,q,f[6],21,0xFC93A039)q=o(k,q,r,s,t,f[13],6,0x655B59C3)t=o(k,t,q,r,s,f[4],10,0x8F0CCC92)s=o(k,s,t,q,r,f[11],15,0xFFEFF47D)r=o(k,r,s,t,q,f[2],21,0x85845DD1)q=o(k,q,r,s,t,f[9],6,0x6FA87E4F)t=o(k,t,q,r,s,f[16],10,0xFE2CE6E0)s=o(k,s,t,q,r,f[7],15,0xA3014314)r=o(k,r,s,t,q,f[14],21,0x4E0811A1)q=o(k,q,r,s,t,f[5],6,0xF7537E82)t=o(k,t,q,r,s,f[12],10,0xBD3AF235)s=o(k,s,t,q,r,f[3],15,0x2AD7D2BB)r=o(k,r,s,t,q,f[10],21,0xEB86D391)return q+x,r+y,s+z,t+A end;function c:new(B)if self~=c then return nil,"First argument must be self"end;local C=setmetatable({},d)C._A=b(0x67452301)C._B=b(0xEFCDAB89)C._C=b(0x98BADCFE)C._D=b(0x10325476)C._len=0;C._data=""if B~=nil then C:update(B)end;return C end;setmetatable(c,{__call=c.new})function c:copy()local C=c()C._A=self._A:copy()C._B=self._B:copy()C._C=self._C:copy()C._D=self._D:copy()C._data=self._data;C._len=self._len;return C end;function c:update(B)local f;if B==nil then B=""end;B=tostring(B)self._len=self._len+#B;self._data=self._data..B;while#self._data>=64 do f={}for D=1,64,4 do f[#f+1]=a.byte(self._data,D+3)<<24|(a.byte(self._data,D+2)<<16)|(a.byte(self._data,D+1)<<8)|a.byte(self._data,D)end;self._data=self._data:sub(65,#self._data)self._A,self._B,self._C,self._D=w(self._A,self._B,self._C,self._D,f)end end;function c:digest()local E;local B;local F=0;local G=0;E=self:copy()G=E._len%64;if G<56 then G=56-G else G=120-G end;F=E._len*8;B=a.char(1<<7)..a.rep(a.char(0),G-1)..a.char(F&0xFF)..a.char(F>>8&0xFF)..a.char(F>>16&0xFF)..a.char(F>>24&0xFF)..a.char(F>>32&0xFF)..a.char(F>>40&0xFF)..a.char(F>>48&0xFF)..a.char(F>>56&0xFF)E:update(B)return E._A:swape():asbytestring()..E._B:swape():asbytestring()..E._C:swape():asbytestring()..E._D:swape():asbytestring()end;function c:hexdigest()local H;local I={}H=self:digest()for J=1,#H do I[J]=a.format("%02X",a.byte(H,J))end;return table.concat(I)end;return c diff --git a/extern/lualibs/hashings/pbkdf2.lua b/extern/lualibs/hashings/pbkdf2.lua new file mode 100644 index 00000000..0bdbed8c --- /dev/null +++ b/extern/lualibs/hashings/pbkdf2.lua @@ -0,0 +1,6 @@ +-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/pbkdf2.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2016 John Schember +-- 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 a=require("string")local b=require("nums.uintn").u32;local c=require("hashings.hmac")local d={}local function e(f,g)local h={}local i={}local j={}for k=1,#f do h[#h+1]=a.byte(f,k)end;for k=1,#g do i[#i+1]=a.byte(g,k)end;for k=1,#h do j[#j+1]=a.char(h[k]~i[k])end;return table.concat(j)end;local function l(m)local n={}for k=1,#m do n[k]=a.format("%02X",a.byte(m,k))end;return table.concat(n)end;function d:pbkdf2(o,p,q,r)local s;local t;s=c(o,p,q..b(1):asbytestring()):digest()t=s;for k=2,r do s=c(o,p,s):digest()t=e(t,s)end;return l(t)end;setmetatable(d,{__call=d.pbkdf2})return d diff --git a/extern/lualibs/hashings/ripemd160.lua b/extern/lualibs/hashings/ripemd160.lua new file mode 100644 index 00000000..1c306a8a --- /dev/null +++ b/extern/lualibs/hashings/ripemd160.lua @@ -0,0 +1,6 @@ +-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/ripemd160.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2016 John Schember +-- 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 a=require("string")local b=require("nums.uintn").u32;local c={}local d={__metatable={},__index=c}c.digest_size=20;c.block_size=64;local function e(f,g,h)return f~g~h end;local function i(f,g,h)return f&g|(~f&h)end;local function j(f,g,h)return f|~g~h end;local function k(f,g,h)return f&h|(g&~h)end;local function l(f,g,h)return f~(g|~h)end;local function m(n,o)return n<>32-o)end;local function p(q,r,s,t,u,v,n,w,x)r=r+q(s,t,u)+n+x;r=m(r,w)+v;return r,m(t,10)end;local function y(z,A,B,C,D,f)local r=z;local s=A;local t=B;local u=C;local v=D;local E=z;local F=A;local G=B;local H=C;local I=D;r,t=p(e,r,s,t,u,v,f[1],11,0)v,s=p(e,v,r,s,t,u,f[2],14,0)u,r=p(e,u,v,r,s,t,f[3],15,0)t,v=p(e,t,u,v,r,s,f[4],12,0)s,u=p(e,s,t,u,v,r,f[5],5,0)r,t=p(e,r,s,t,u,v,f[6],8,0)v,s=p(e,v,r,s,t,u,f[7],7,0)u,r=p(e,u,v,r,s,t,f[8],9,0)t,v=p(e,t,u,v,r,s,f[9],11,0)s,u=p(e,s,t,u,v,r,f[10],13,0)r,t=p(e,r,s,t,u,v,f[11],14,0)v,s=p(e,v,r,s,t,u,f[12],15,0)u,r=p(e,u,v,r,s,t,f[13],6,0)t,v=p(e,t,u,v,r,s,f[14],7,0)s,u=p(e,s,t,u,v,r,f[15],9,0)r,t=p(e,r,s,t,u,v,f[16],8,0)v,s=p(i,v,r,s,t,u,f[8],7,0x5A827999)u,r=p(i,u,v,r,s,t,f[5],6,0x5A827999)t,v=p(i,t,u,v,r,s,f[14],8,0x5A827999)s,u=p(i,s,t,u,v,r,f[2],13,0x5A827999)r,t=p(i,r,s,t,u,v,f[11],11,0x5A827999)v,s=p(i,v,r,s,t,u,f[7],9,0x5A827999)u,r=p(i,u,v,r,s,t,f[16],7,0x5A827999)t,v=p(i,t,u,v,r,s,f[4],15,0x5A827999)s,u=p(i,s,t,u,v,r,f[13],7,0x5A827999)r,t=p(i,r,s,t,u,v,f[1],12,0x5A827999)v,s=p(i,v,r,s,t,u,f[10],15,0x5A827999)u,r=p(i,u,v,r,s,t,f[6],9,0x5A827999)t,v=p(i,t,u,v,r,s,f[3],11,0x5A827999)s,u=p(i,s,t,u,v,r,f[15],7,0x5A827999)r,t=p(i,r,s,t,u,v,f[12],13,0x5A827999)v,s=p(i,v,r,s,t,u,f[9],12,0x5A827999)u,r=p(j,u,v,r,s,t,f[4],11,0x6ED9EBA1)t,v=p(j,t,u,v,r,s,f[11],13,0x6ED9EBA1)s,u=p(j,s,t,u,v,r,f[15],6,0x6ED9EBA1)r,t=p(j,r,s,t,u,v,f[5],7,0x6ED9EBA1)v,s=p(j,v,r,s,t,u,f[10],14,0x6ED9EBA1)u,r=p(j,u,v,r,s,t,f[16],9,0x6ED9EBA1)t,v=p(j,t,u,v,r,s,f[9],13,0x6ED9EBA1)s,u=p(j,s,t,u,v,r,f[2],15,0x6ED9EBA1)r,t=p(j,r,s,t,u,v,f[3],14,0x6ED9EBA1)v,s=p(j,v,r,s,t,u,f[8],8,0x6ED9EBA1)u,r=p(j,u,v,r,s,t,f[1],13,0x6ED9EBA1)t,v=p(j,t,u,v,r,s,f[7],6,0x6ED9EBA1)s,u=p(j,s,t,u,v,r,f[14],5,0x6ED9EBA1)r,t=p(j,r,s,t,u,v,f[12],12,0x6ED9EBA1)v,s=p(j,v,r,s,t,u,f[6],7,0x6ED9EBA1)u,r=p(j,u,v,r,s,t,f[13],5,0x6ED9EBA1)t,v=p(k,t,u,v,r,s,f[2],11,0x8F1BBCDC)s,u=p(k,s,t,u,v,r,f[10],12,0x8F1BBCDC)r,t=p(k,r,s,t,u,v,f[12],14,0x8F1BBCDC)v,s=p(k,v,r,s,t,u,f[11],15,0x8F1BBCDC)u,r=p(k,u,v,r,s,t,f[1],14,0x8F1BBCDC)t,v=p(k,t,u,v,r,s,f[9],15,0x8F1BBCDC)s,u=p(k,s,t,u,v,r,f[13],9,0x8F1BBCDC)r,t=p(k,r,s,t,u,v,f[5],8,0x8F1BBCDC)v,s=p(k,v,r,s,t,u,f[14],9,0x8F1BBCDC)u,r=p(k,u,v,r,s,t,f[4],14,0x8F1BBCDC)t,v=p(k,t,u,v,r,s,f[8],5,0x8F1BBCDC)s,u=p(k,s,t,u,v,r,f[16],6,0x8F1BBCDC)r,t=p(k,r,s,t,u,v,f[15],8,0x8F1BBCDC)v,s=p(k,v,r,s,t,u,f[6],6,0x8F1BBCDC)u,r=p(k,u,v,r,s,t,f[7],5,0x8F1BBCDC)t,v=p(k,t,u,v,r,s,f[3],12,0x8F1BBCDC)s,u=p(l,s,t,u,v,r,f[5],9,0xA953FD4E)r,t=p(l,r,s,t,u,v,f[1],15,0xA953FD4E)v,s=p(l,v,r,s,t,u,f[6],5,0xA953FD4E)u,r=p(l,u,v,r,s,t,f[10],11,0xA953FD4E)t,v=p(l,t,u,v,r,s,f[8],6,0xA953FD4E)s,u=p(l,s,t,u,v,r,f[13],8,0xA953FD4E)r,t=p(l,r,s,t,u,v,f[3],13,0xA953FD4E)v,s=p(l,v,r,s,t,u,f[11],12,0xA953FD4E)u,r=p(l,u,v,r,s,t,f[15],5,0xA953FD4E)t,v=p(l,t,u,v,r,s,f[2],12,0xA953FD4E)s,u=p(l,s,t,u,v,r,f[4],13,0xA953FD4E)r,t=p(l,r,s,t,u,v,f[9],14,0xA953FD4E)v,s=p(l,v,r,s,t,u,f[12],11,0xA953FD4E)u,r=p(l,u,v,r,s,t,f[7],8,0xA953FD4E)t,v=p(l,t,u,v,r,s,f[16],5,0xA953FD4E)s,u=p(l,s,t,u,v,r,f[14],6,0xA953FD4E)E,G=p(l,E,F,G,H,I,f[6],8,0x50A28BE6)I,F=p(l,I,E,F,G,H,f[15],9,0x50A28BE6)H,E=p(l,H,I,E,F,G,f[8],9,0x50A28BE6)G,I=p(l,G,H,I,E,F,f[1],11,0x50A28BE6)F,H=p(l,F,G,H,I,E,f[10],13,0x50A28BE6)E,G=p(l,E,F,G,H,I,f[3],15,0x50A28BE6)I,F=p(l,I,E,F,G,H,f[12],15,0x50A28BE6)H,E=p(l,H,I,E,F,G,f[5],5,0x50A28BE6)G,I=p(l,G,H,I,E,F,f[14],7,0x50A28BE6)F,H=p(l,F,G,H,I,E,f[7],7,0x50A28BE6)E,G=p(l,E,F,G,H,I,f[16],8,0x50A28BE6)I,F=p(l,I,E,F,G,H,f[9],11,0x50A28BE6)H,E=p(l,H,I,E,F,G,f[2],14,0x50A28BE6)G,I=p(l,G,H,I,E,F,f[11],14,0x50A28BE6)F,H=p(l,F,G,H,I,E,f[4],12,0x50A28BE6)E,G=p(l,E,F,G,H,I,f[13],6,0x50A28BE6)I,F=p(k,I,E,F,G,H,f[7],9,0x5C4DD124)H,E=p(k,H,I,E,F,G,f[12],13,0x5C4DD124)G,I=p(k,G,H,I,E,F,f[4],15,0x5C4DD124)F,H=p(k,F,G,H,I,E,f[8],7,0x5C4DD124)E,G=p(k,E,F,G,H,I,f[1],12,0x5C4DD124)I,F=p(k,I,E,F,G,H,f[14],8,0x5C4DD124)H,E=p(k,H,I,E,F,G,f[6],9,0x5C4DD124)G,I=p(k,G,H,I,E,F,f[11],11,0x5C4DD124)F,H=p(k,F,G,H,I,E,f[15],7,0x5C4DD124)E,G=p(k,E,F,G,H,I,f[16],7,0x5C4DD124)I,F=p(k,I,E,F,G,H,f[9],12,0x5C4DD124)H,E=p(k,H,I,E,F,G,f[13],7,0x5C4DD124)G,I=p(k,G,H,I,E,F,f[5],6,0x5C4DD124)F,H=p(k,F,G,H,I,E,f[10],15,0x5C4DD124)E,G=p(k,E,F,G,H,I,f[2],13,0x5C4DD124)I,F=p(k,I,E,F,G,H,f[3],11,0x5C4DD124)H,E=p(j,H,I,E,F,G,f[16],9,0x6D703EF3)G,I=p(j,G,H,I,E,F,f[6],7,0x6D703EF3)F,H=p(j,F,G,H,I,E,f[2],15,0x6D703EF3)E,G=p(j,E,F,G,H,I,f[4],11,0x6D703EF3)I,F=p(j,I,E,F,G,H,f[8],8,0x6D703EF3)H,E=p(j,H,I,E,F,G,f[15],6,0x6D703EF3)G,I=p(j,G,H,I,E,F,f[7],6,0x6D703EF3)F,H=p(j,F,G,H,I,E,f[10],14,0x6D703EF3)E,G=p(j,E,F,G,H,I,f[12],12,0x6D703EF3)I,F=p(j,I,E,F,G,H,f[9],13,0x6D703EF3)H,E=p(j,H,I,E,F,G,f[13],5,0x6D703EF3)G,I=p(j,G,H,I,E,F,f[3],14,0x6D703EF3)F,H=p(j,F,G,H,I,E,f[11],13,0x6D703EF3)E,G=p(j,E,F,G,H,I,f[1],13,0x6D703EF3)I,F=p(j,I,E,F,G,H,f[5],7,0x6D703EF3)H,E=p(j,H,I,E,F,G,f[14],5,0x6D703EF3)G,I=p(i,G,H,I,E,F,f[9],15,0x7A6D76E9)F,H=p(i,F,G,H,I,E,f[7],5,0x7A6D76E9)E,G=p(i,E,F,G,H,I,f[5],8,0x7A6D76E9)I,F=p(i,I,E,F,G,H,f[2],11,0x7A6D76E9)H,E=p(i,H,I,E,F,G,f[4],14,0x7A6D76E9)G,I=p(i,G,H,I,E,F,f[12],14,0x7A6D76E9)F,H=p(i,F,G,H,I,E,f[16],6,0x7A6D76E9)E,G=p(i,E,F,G,H,I,f[1],14,0x7A6D76E9)I,F=p(i,I,E,F,G,H,f[6],6,0x7A6D76E9)H,E=p(i,H,I,E,F,G,f[13],9,0x7A6D76E9)G,I=p(i,G,H,I,E,F,f[3],12,0x7A6D76E9)F,H=p(i,F,G,H,I,E,f[14],9,0x7A6D76E9)E,G=p(i,E,F,G,H,I,f[10],12,0x7A6D76E9)I,F=p(i,I,E,F,G,H,f[8],5,0x7A6D76E9)H,E=p(i,H,I,E,F,G,f[11],15,0x7A6D76E9)G,I=p(i,G,H,I,E,F,f[15],8,0x7A6D76E9)F,H=p(e,F,G,H,I,E,f[13],8,0)E,G=p(e,E,F,G,H,I,f[16],5,0)I,F=p(e,I,E,F,G,H,f[11],12,0)H,E=p(e,H,I,E,F,G,f[5],9,0)G,I=p(e,G,H,I,E,F,f[2],12,0)F,H=p(e,F,G,H,I,E,f[6],5,0)E,G=p(e,E,F,G,H,I,f[9],14,0)I,F=p(e,I,E,F,G,H,f[8],6,0)H,E=p(e,H,I,E,F,G,f[7],8,0)G,I=p(e,G,H,I,E,F,f[3],13,0)F,H=p(e,F,G,H,I,E,f[14],6,0)E,G=p(e,E,F,G,H,I,f[15],5,0)I,F=p(e,I,E,F,G,H,f[1],15,0)H,E=p(e,H,I,E,F,G,f[4],13,0)G,I=p(e,G,H,I,E,F,f[10],11,0)F,H=p(e,F,G,H,I,E,f[12],11,0)H=H+t+A;return H,B+u+I,C+v+E,D+r+F,z+s+G end;function c:new(J)if self~=c then return nil,"First argument must be self"end;local K=setmetatable({},d)K._A=b(0x67452301)K._B=b(0xEFCDAB89)K._C=b(0x98BADCFE)K._D=b(0x10325476)K._E=b(0xC3D2E1F0)K._len=0;K._data=""if J~=nil then K:update(J)end;return K end;setmetatable(c,{__call=c.new})function c:copy()local K=c()K._A=self._A:copy()K._B=self._B:copy()K._C=self._C:copy()K._D=self._D:copy()K._E=self._E:copy()K._data=self._data;K._len=self._len;return K end;function c:update(J)local f;if J==nil then J=""end;J=tostring(J)self._len=self._len+#J;self._data=self._data..J;while#self._data>=64 do f={}for L=1,64,4 do f[#f+1]=a.byte(self._data,L+3)<<24|(a.byte(self._data,L+2)<<16)|(a.byte(self._data,L+1)<<8)|a.byte(self._data,L)end;self._A,self._B,self._C,self._D,self._E=y(self._A,self._B,self._C,self._D,self._E,f)self._data=self._data:sub(65,#self._data)end end;local function M(N)end;function c:digest()local O;local J;local P=0;local Q=0;O=self:copy()Q=O._len%64;if Q<56 then Q=56-Q else Q=120-Q end;P=O._len*8;J=a.char(1<<7)..a.rep(a.char(0),Q-1)..a.char(P&0xFF)..a.char(P>>8&0xFF)..a.char(P>>16&0xFF)..a.char(P>>24&0xFF)..a.char(P>>32&0xFF)..a.char(P>>40&0xFF)..a.char(P>>48&0xFF)..a.char(P>>56&0xFF)O:update(J)return O._A:swape():asbytestring()..O._B:swape():asbytestring()..O._C:swape():asbytestring()..O._D:swape():asbytestring()..O._E:swape():asbytestring()end;function c:hexdigest()local R;local S={}R=self:digest()for T=1,#R do S[T]=a.format("%02X",a.byte(R,T))end;return table.concat(S)end;return c diff --git a/extern/lualibs/hashings/sha1.lua b/extern/lualibs/hashings/sha1.lua new file mode 100644 index 00000000..dd84bee7 --- /dev/null +++ b/extern/lualibs/hashings/sha1.lua @@ -0,0 +1,6 @@ +-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/sha1.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2016 John Schember +-- 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 a=require("string")local b=require("nums.uintn").u32;local c={}local d={__metatable={},__index=c}c.digest_size=20;c.block_size=64;local function e(f,g)return f<>32-g)end;function c:new(h)if self~=c then return nil,"First argument must be self"end;local i=setmetatable({},d)i._H0=b(0x67452301)i._H1=b(0xEFCDAB89)i._H2=b(0x98BADCFE)i._H3=b(0x10325476)i._H4=b(0xC3D2E1F0)i._len=0;i._data=""if h~=nil then i:update(h)end;return i end;setmetatable(c,{__call=c.new})function c:copy()local i=c:new()i._H0=self._H0:copy()i._H1=self._H1:copy()i._H2=self._H2:copy()i._H3=self._H3:copy()i._H4=self._H4:copy()i._data=self._data;i._len=self._len;return i end;function c:update(h)local j=b(0x5A827999)local k=b(0x6ED9EBA1)local l=b(0x8F1BBCDC)local m=b(0xCA62C1D6)local n;local o;local p;local q;local r;local s;local t;if h==nil then h=""end;h=tostring(h)self._len=self._len+#h;self._data=self._data..h;while#self._data>=64 do n={}for u=1,64,4 do local v=#n+1;n[v]=b(a.byte(self._data,u))<<24;n[v]=n[v]|(b(a.byte(self._data,u+1))<<16)n[v]=n[v]|(b(a.byte(self._data,u+2))<<8)n[v]=n[v]|b(a.byte(self._data,u+3))end;for u=17,80 do n[u]=e(n[u-3]~n[u-8]~n[u-14]~n[u-16],1)end;p=self._H0;q=self._H1;r=self._H2;s=self._H3;t=self._H4;for u=1,20 do o=e(p,5)+q&r|(~q&s)+t+n[u]+j;t=s;s=r;r=e(q,30)q=p;p=o end;for u=21,40 do o=e(p,5)+q~r~s+t+n[u]+k;t=s;s=r;r=e(q,30)q=p;p=o end;for u=41,60 do o=e(p,5)+q&r|(q&s)|(r&s)+t+n[u]+l;t=s;s=r;r=e(q,30)q=p;p=o end;for u=61,80 do o=e(p,5)+q~r~s+t+n[u]+m;t=s;s=r;r=e(q,30)q=p;p=o end;self._H0=self._H0+p;self._H1=self._H1+q;self._H2=self._H2+r;self._H3=self._H3+s;self._H4=self._H4+t;self._data=self._data:sub(65,#self._data)end end;function c:digest()local w;local h;local x=0;local y=0;w=self:copy()y=w._len%64;if y<56 then y=56-y else y=120-y end;x=w._len*8;h=a.char(1<<7)..a.rep(a.char(0),y-1)..a.char(x>>56&0xFF)..a.char(x>>48&0xFF)..a.char(x>>40&0xFF)..a.char(x>>32&0xFF)..a.char(x>>24&0xFF)..a.char(x>>16&0xFF)..a.char(x>>8&0xFF)..a.char(x&0xFF)w:update(h)return w._H0:asbytestring()..w._H1:asbytestring()..w._H2:asbytestring()..w._H3:asbytestring()..w._H4:asbytestring()end;function c:hexdigest()local z;local A={}z=self:digest()for u=1,#z do A[u]=a.format("%02X",a.byte(z,u))end;return table.concat(A)end;return c diff --git a/extern/lualibs/hashings/sha256.lua b/extern/lualibs/hashings/sha256.lua new file mode 100644 index 00000000..117c0874 --- /dev/null +++ b/extern/lualibs/hashings/sha256.lua @@ -0,0 +1,6 @@ +-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/sha256.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2016 John Schember +-- 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 a=require("string")local b=require("nums.uintn").u32;local c={}local d={__metatable={},__index=c}c.digest_size=32;c.block_size=64;local e={b(0x428A2F98),b(0x71374491),b(0xB5C0FBCF),b(0xE9B5DBA5),b(0x3956C25B),b(0x59F111F1),b(0x923F82A4),b(0xAB1C5ED5),b(0xD807AA98),b(0x12835B01),b(0x243185BE),b(0x550C7DC3),b(0x72BE5D74),b(0x80DEB1FE),b(0x9BDC06A7),b(0xC19BF174),b(0xE49B69C1),b(0xEFBE4786),b(0x0FC19DC6),b(0x240CA1CC),b(0x2DE92C6F),b(0x4A7484AA),b(0x5CB0A9DC),b(0x76F988DA),b(0x983E5152),b(0xA831C66D),b(0xB00327C8),b(0xBF597FC7),b(0xC6E00BF3),b(0xD5A79147),b(0x06CA6351),b(0x14292967),b(0x27B70A85),b(0x2E1B2138),b(0x4D2C6DFC),b(0x53380D13),b(0x650A7354),b(0x766A0ABB),b(0x81C2C92E),b(0x92722C85),b(0xA2BFE8A1),b(0xA81A664B),b(0xC24B8B70),b(0xC76C51A3),b(0xD192E819),b(0xD6990624),b(0xF40E3585),b(0x106AA070),b(0x19A4C116),b(0x1E376C08),b(0x2748774C),b(0x34B0BCB5),b(0x391C0CB3),b(0x4ED8AA4A),b(0x5B9CCA4F),b(0x682E6FF3),b(0x748F82EE),b(0x78A5636F),b(0x84C87814),b(0x8CC70208),b(0x90BEFFFA),b(0xA4506CEB),b(0xBEF9A3F7),b(0xC67178F2)}local function f(g,h)return g>>h|(g<<32-h)end;local function i(g,j,k)return g&j~(~g&k)end;local function l(g,j,k)return g&j~(g&k)~(j&k)end;local function m(g)return f(g,2)~f(g,13)~f(g,22)end;local function n(g)return f(g,6)~f(g,11)~f(g,25)end;local function o(g)return f(g,7)~f(g,18)~(g>>3)end;local function p(g)return f(g,17)~f(g,19)~(g>>10)end;function c:new(q)if self~=c then return nil,"First argument must be self"end;local r=setmetatable({},d)r._H0=b(0x6A09E667)r._H1=b(0xBB67AE85)r._H2=b(0x3C6EF372)r._H3=b(0xA54FF53A)r._H4=b(0x510E527F)r._H5=b(0x9B05688C)r._H6=b(0x1F83D9AB)r._H7=b(0x5BE0CD19)r._len=0;r._data=""if q~=nil then r:update(q)end;return r end;setmetatable(c,{__call=c.new})function c:copy()local r=c:new()r._H0=self._H0:copy()r._H1=self._H1:copy()r._H2=self._H2:copy()r._H3=self._H3:copy()r._H4=self._H4:copy()r._H5=self._H5:copy()r._H6=self._H6:copy()r._H7=self._H7:copy()r._data=self._data;r._len=self._len;return r end;function c:update(q)local s;local t;local u;local v;local w;local x;local y;local z;local A;local B;local C;if q==nil then q=""end;q=tostring(q)self._len=self._len+#q;self._data=self._data..q;while#self._data>=64 do s={}for D=1,64,4 do local E=#s+1;s[E]=b(a.byte(self._data,D))<<24;s[E]=s[E]|(b(a.byte(self._data,D+1))<<16)s[E]=s[E]|(b(a.byte(self._data,D+2))<<8)s[E]=s[E]|b(a.byte(self._data,D+3))end;self._data=self._data:sub(65,#self._data)for D=17,64 do s[D]=p(s[D-2])+s[D-7]+o(s[D-15])+s[D-16]end;v=self._H0;w=self._H1;x=self._H2;y=self._H3;z=self._H4;A=self._H5;B=self._H6;C=self._H7;for D=1,64 do t=C+n(z)+i(z,A,B)+e[D]+s[D]u=m(v)+l(v,w,x)C=B;B=A;A=z;z=y+t;y=x;x=w;w=v;v=t+u end;self._H0=self._H0+v;self._H1=self._H1+w;self._H2=self._H2+x;self._H3=self._H3+y;self._H4=self._H4+z;self._H5=self._H5+A;self._H6=self._H6+B;self._H7=self._H7+C end end;function c:digest()local F;local q;local G=0;local H=0;F=self:copy()H=F._len%64;if H<56 then H=56-H else H=120-H end;G=F._len*8;q=a.char(1<<7)..a.rep(a.char(0),H-1)..a.char(G>>56&0xFF)..a.char(G>>48&0xFF)..a.char(G>>40&0xFF)..a.char(G>>32&0xFF)..a.char(G>>24&0xFF)..a.char(G>>16&0xFF)..a.char(G>>8&0xFF)..a.char(G&0xFF)F:update(q)return F._H0:asbytestring()..F._H1:asbytestring()..F._H2:asbytestring()..F._H3:asbytestring()..F._H4:asbytestring()..F._H5:asbytestring()..F._H6:asbytestring()..F._H7:asbytestring()end;function c:hexdigest()local C;local I={}C=self:digest()for D=1,#C do I[D]=a.format("%02X",a.byte(C,D))end;return table.concat(I)end;return c diff --git a/extern/lualibs/hashings/sha3_256.lua b/extern/lualibs/hashings/sha3_256.lua new file mode 100644 index 00000000..98f32bd9 --- /dev/null +++ b/extern/lualibs/hashings/sha3_256.lua @@ -0,0 +1,6 @@ +-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/sha3_256.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2016 John Schember +-- 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 a=require("hashings.keccak")local b={}local c={__metatable={},__index=b}b.digest_size=32;b.block_size=136;function b:new(d)return a:new(b.block_size,b.digest_size,d)end;setmetatable(b,{__call=b.new})return b diff --git a/extern/lualibs/hashings/sha3_512.lua b/extern/lualibs/hashings/sha3_512.lua new file mode 100644 index 00000000..baf9b908 --- /dev/null +++ b/extern/lualibs/hashings/sha3_512.lua @@ -0,0 +1,6 @@ +-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/sha3_512.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2016 John Schember +-- 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 a=require("hashings.keccak")local b={}local c={__metatable={},__index=b}b.digest_size=64;b.block_size=72;function b:new(d)return a:new(b.block_size,b.digest_size,d)end;setmetatable(b,{__call=b.new})return b diff --git a/extern/lualibs/hashings/sha512.lua b/extern/lualibs/hashings/sha512.lua new file mode 100644 index 00000000..c7149656 --- /dev/null +++ b/extern/lualibs/hashings/sha512.lua @@ -0,0 +1,6 @@ +-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/sha512.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2016 John Schember +-- 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 a=require("string")local b=require("nums.uintb").u64;local c={}local d={__metatable={},__index=c}c.digest_size=64;c.block_size=128;local e={b("0x428A2F98D728AE22"),b("0x7137449123EF65CD"),b("0xB5C0FBCFEC4D3B2F"),b("0xE9B5DBA58189DBBC"),b("0x3956C25BF348B538"),b("0x59F111F1B605D019"),b("0x923F82A4AF194F9B"),b("0xAB1C5ED5DA6D8118"),b("0xD807AA98A3030242"),b("0x12835B0145706FBE"),b("0x243185BE4EE4B28C"),b("0x550C7DC3D5FFB4E2"),b("0x72BE5D74F27B896F"),b("0x80DEB1FE3B1696B1"),b("0x9BDC06A725C71235"),b("0xC19BF174CF692694"),b("0xE49B69C19EF14AD2"),b("0xEFBE4786384F25E3"),b("0x0FC19DC68B8CD5B5"),b("0x240CA1CC77AC9C65"),b("0x2DE92C6F592B0275"),b("0x4A7484AA6EA6E483"),b("0x5CB0A9DCBD41FBD4"),b("0x76F988DA831153B5"),b("0x983E5152EE66DFAB"),b("0xA831C66D2DB43210"),b("0xB00327C898FB213F"),b("0xBF597FC7BEEF0EE4"),b("0xC6E00BF33DA88FC2"),b("0xD5A79147930AA725"),b("0x06CA6351E003826F"),b("0x142929670A0E6E70"),b("0x27B70A8546D22FFC"),b("0x2E1B21385C26C926"),b("0x4D2C6DFC5AC42AED"),b("0x53380D139D95B3DF"),b("0x650A73548BAF63DE"),b("0x766A0ABB3C77B2A8"),b("0x81C2C92E47EDAEE6"),b("0x92722C851482353B"),b("0xA2BFE8A14CF10364"),b("0xA81A664BBC423001"),b("0xC24B8B70D0F89791"),b("0xC76C51A30654BE30"),b("0xD192E819D6EF5218"),b("0xD69906245565A910"),b("0xF40E35855771202A"),b("0x106AA07032BBD1B8"),b("0x19A4C116B8D2D0C8"),b("0x1E376C085141AB53"),b("0x2748774CDF8EEB99"),b("0x34B0BCB5E19B48A8"),b("0x391C0CB3C5C95A63"),b("0x4ED8AA4AE3418ACB"),b("0x5B9CCA4F7763E373"),b("0x682E6FF3D6B2B8A3"),b("0x748F82EE5DEFB2FC"),b("0x78A5636F43172F60"),b("0x84C87814A1F0AB72"),b("0x8CC702081A6439EC"),b("0x90BEFFFA23631E28"),b("0xA4506CEBDE82BDE9"),b("0xBEF9A3F7B2C67915"),b("0xC67178F2E372532B"),b("0xCA273ECEEA26619C"),b("0xD186B8C721C0C207"),b("0xEADA7DD6CDE0EB1E"),b("0xF57D4F7FEE6ED178"),b("0x06F067AA72176FBA"),b("0x0A637DC5A2C898A6"),b("0x113F9804BEF90DAE"),b("0x1B710B35131C471B"),b("0x28DB77F523047D84"),b("0x32CAAB7B40C72493"),b("0x3C9EBE0A15C9BEBC"),b("0x431D67C49C100D4C"),b("0x4CC5D4BECB3E42B6"),b("0x597F299CFC657E2A"),b("0x5FCB6FAB3AD6FAEC"),b("0x6C44198C4A475817")}local function f(g,h)return g>>h|(g<<64-h)end;local function i(g,j,k)return g&j~(~g&k)end;local function l(g,j,k)return g&j~(g&k)~(j&k)end;local function m(g)return f(g,28)~f(g,34)~f(g,39)end;local function n(g)return f(g,14)~f(g,18)~f(g,41)end;local function o(g)return f(g,1)~f(g,8)~(g>>7)end;local function p(g)return f(g,19)~f(g,61)~(g>>6)end;function c:new(q)if self~=c then return nil,"First argument must be self"end;local r=setmetatable({},d)r._H0=b(0x6A09E667F3BCC908)r._H1=b(0xBB67AE8584CAA73B)r._H2=b(0x3C6EF372FE94F82B)r._H3=b(0xA54FF53A5F1D36F1)r._H4=b(0x510E527FADE682D1)r._H5=b(0x9B05688C2B3E6C1F)r._H6=b(0x1F83D9ABFB41BD6B)r._H7=b(0x5BE0CD19137E2179)r._len=0;r._data=""if q~=nil then r:update(q)end;return r end;setmetatable(c,{__call=c.new})function c:copy()local r=c:new()r._H0=self._H0:copy()r._H1=self._H1:copy()r._H2=self._H2:copy()r._H3=self._H3:copy()r._H4=self._H4:copy()r._H5=self._H5:copy()r._H6=self._H6:copy()r._H7=self._H7:copy()r._data=self._data;r._len=self._len;return r end;function c:update(q)local s;local t;local u;local v;local w;local x;local y;local z;local A;local B;local C;if q==nil then q=""end;q=tostring(q)self._len=self._len+#q;self._data=self._data..q;while#self._data>=128 do s={}for D=1,128,8 do local E=#s+1;s[E]=b(a.byte(self._data,D))<<56;s[E]=s[E]|(b(a.byte(self._data,D+1))<<48)s[E]=s[E]|(b(a.byte(self._data,D+2))<<40)s[E]=s[E]|(b(a.byte(self._data,D+3))<<32)s[E]=s[E]|(b(a.byte(self._data,D+4))<<24)s[E]=s[E]|(b(a.byte(self._data,D+5))<<16)s[E]=s[E]|(b(a.byte(self._data,D+6))<<8)s[E]=s[E]|b(a.byte(self._data,D+7))end;self._data=self._data:sub(129,#self._data)for D=17,80 do s[D]=p(s[D-2])+s[D-7]+o(s[D-15])+s[D-16]end;v=self._H0;w=self._H1;x=self._H2;y=self._H3;z=self._H4;A=self._H5;B=self._H6;C=self._H7;for D=1,80 do t=C+n(z)+i(z,A,B)+e[D]+s[D]u=m(v)+l(v,w,x)C=B;B=A;A=z;z=y+t;y=x;x=w;w=v;v=t+u end;self._H0=self._H0+v;self._H1=self._H1+w;self._H2=self._H2+x;self._H3=self._H3+y;self._H4=self._H4+z;self._H5=self._H5+A;self._H6=self._H6+B;self._H7=self._H7+C end end;function c:digest()local F;local q;local G=0;local H=0;F=self:copy()H=F._len%128;if H<112 then H=112-H else H=240-H end;G=F._len*8;q=a.char(1<<7)..a.rep(a.char(0),H-1)..a.char(G>>120&0xFF)..a.char(G>>112&0xFF)..a.char(G>>104&0xFF)..a.char(G>>96&0xFF)..a.char(G>>88&0xFF)..a.char(G>>80&0xFF)..a.char(G>>72&0xFF)..a.char(G>>64&0xFF)..a.char(G>>56&0xFF)..a.char(G>>48&0xFF)..a.char(G>>40&0xFF)..a.char(G>>32&0xFF)..a.char(G>>24&0xFF)..a.char(G>>16&0xFF)..a.char(G>>8&0xFF)..a.char(G&0xFF)F:update(q)return F._H0:asbytestring()..F._H1:asbytestring()..F._H2:asbytestring()..F._H3:asbytestring()..F._H4:asbytestring()..F._H5:asbytestring()..F._H6:asbytestring()..F._H7:asbytestring()end;function c:hexdigest()local C;local I={}C=self:digest()for D=1,#C do I[D]=a.format("%02X",a.byte(C,D))end;return table.concat(I)end;return c diff --git a/extern/lualibs/hashings/whirlpool.lua b/extern/lualibs/hashings/whirlpool.lua new file mode 100644 index 00000000..99a2f585 --- /dev/null +++ b/extern/lualibs/hashings/whirlpool.lua @@ -0,0 +1,6 @@ +-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/whirlpool.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2016 John Schember +-- 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 a=require("string")local b=require("nums.uintb").u64;local c=require("nums.uintb").u256;local d=require("nums.uintn").u8;local e={}local f={__metatable={},__index=e}e.digest_size=64;e.block_size=64;local g={b("0x18186018C07830D8"),b("0x23238C2305AF4626"),b("0xC6C63FC67EF991B8"),b("0xE8E887E8136FCDFB"),b("0x878726874CA113CB"),b("0xB8B8DAB8A9626D11"),b("0x0101040108050209"),b("0x4F4F214F426E9E0D"),b("0x3636D836ADEE6C9B"),b("0xA6A6A2A6590451FF"),b("0xD2D26FD2DEBDB90C"),b("0xF5F5F3F5FB06F70E"),b("0x7979F979EF80F296"),b("0x6F6FA16F5FCEDE30"),b("0x91917E91FCEF3F6D"),b("0x52525552AA07A4F8"),b("0x60609D6027FDC047"),b("0xBCBCCABC89766535"),b("0x9B9B569BACCD2B37"),b("0x8E8E028E048C018A"),b("0xA3A3B6A371155BD2"),b("0x0C0C300C603C186C"),b("0x7B7BF17BFF8AF684"),b("0x3535D435B5E16A80"),b("0x1D1D741DE8693AF5"),b("0xE0E0A7E05347DDB3"),b("0xD7D77BD7F6ACB321"),b("0xC2C22FC25EED999C"),b("0x2E2EB82E6D965C43"),b("0x4B4B314B627A9629"),b("0xFEFEDFFEA321E15D"),b("0x575741578216AED5"),b("0x15155415A8412ABD"),b("0x7777C1779FB6EEE8"),b("0x3737DC37A5EB6E92"),b("0xE5E5B3E57B56D79E"),b("0x9F9F469F8CD92313"),b("0xF0F0E7F0D317FD23"),b("0x4A4A354A6A7F9420"),b("0xDADA4FDA9E95A944"),b("0x58587D58FA25B0A2"),b("0xC9C903C906CA8FCF"),b("0x2929A429558D527C"),b("0x0A0A280A5022145A"),b("0xB1B1FEB1E14F7F50"),b("0xA0A0BAA0691A5DC9"),b("0x6B6BB16B7FDAD614"),b("0x85852E855CAB17D9"),b("0xBDBDCEBD8173673C"),b("0x5D5D695DD234BA8F"),b("0x1010401080502090"),b("0xF4F4F7F4F303F507"),b("0xCBCB0BCB16C08BDD"),b("0x3E3EF83EEDC67CD3"),b("0x0505140528110A2D"),b("0x676781671FE6CE78"),b("0xE4E4B7E47353D597"),b("0x27279C2725BB4E02"),b("0x4141194132588273"),b("0x8B8B168B2C9D0BA7"),b("0xA7A7A6A7510153F6"),b("0x7D7DE97DCF94FAB2"),b("0x95956E95DCFB3749"),b("0xD8D847D88E9FAD56"),b("0xFBFBCBFB8B30EB70"),b("0xEEEE9FEE2371C1CD"),b("0x7C7CED7CC791F8BB"),b("0x6666856617E3CC71"),b("0xDDDD53DDA68EA77B"),b("0x17175C17B84B2EAF"),b("0x4747014702468E45"),b("0x9E9E429E84DC211A"),b("0xCACA0FCA1EC589D4"),b("0x2D2DB42D75995A58"),b("0xBFBFC6BF9179632E"),b("0x07071C07381B0E3F"),b("0xADAD8EAD012347AC"),b("0x5A5A755AEA2FB4B0"),b("0x838336836CB51BEF"),b("0x3333CC3385FF66B6"),b("0x636391633FF2C65C"),b("0x02020802100A0412"),b("0xAAAA92AA39384993"),b("0x7171D971AFA8E2DE"),b("0xC8C807C80ECF8DC6"),b("0x19196419C87D32D1"),b("0x494939497270923B"),b("0xD9D943D9869AAF5F"),b("0xF2F2EFF2C31DF931"),b("0xE3E3ABE34B48DBA8"),b("0x5B5B715BE22AB6B9"),b("0x88881A8834920DBC"),b("0x9A9A529AA4C8293E"),b("0x262698262DBE4C0B"),b("0x3232C8328DFA64BF"),b("0xB0B0FAB0E94A7D59"),b("0xE9E983E91B6ACFF2"),b("0x0F0F3C0F78331E77"),b("0xD5D573D5E6A6B733"),b("0x80803A8074BA1DF4"),b("0xBEBEC2BE997C6127"),b("0xCDCD13CD26DE87EB"),b("0x3434D034BDE46889"),b("0x48483D487A759032"),b("0xFFFFDBFFAB24E354"),b("0x7A7AF57AF78FF48D"),b("0x90907A90F4EA3D64"),b("0x5F5F615FC23EBE9D"),b("0x202080201DA0403D"),b("0x6868BD6867D5D00F"),b("0x1A1A681AD07234CA"),b("0xAEAE82AE192C41B7"),b("0xB4B4EAB4C95E757D"),b("0x54544D549A19A8CE"),b("0x93937693ECE53B7F"),b("0x222288220DAA442F"),b("0x64648D6407E9C863"),b("0xF1F1E3F1DB12FF2A"),b("0x7373D173BFA2E6CC"),b("0x12124812905A2482"),b("0x40401D403A5D807A"),b("0x0808200840281048"),b("0xC3C32BC356E89B95"),b("0xECEC97EC337BC5DF"),b("0xDBDB4BDB9690AB4D"),b("0xA1A1BEA1611F5FC0"),b("0x8D8D0E8D1C830791"),b("0x3D3DF43DF5C97AC8"),b("0x97976697CCF1335B"),b("0x0000000000000000"),b("0xCFCF1BCF36D483F9"),b("0x2B2BAC2B4587566E"),b("0x7676C57697B3ECE1"),b("0x8282328264B019E6"),b("0xD6D67FD6FEA9B128"),b("0x1B1B6C1BD87736C3"),b("0xB5B5EEB5C15B7774"),b("0xAFAF86AF112943BE"),b("0x6A6AB56A77DFD41D"),b("0x50505D50BA0DA0EA"),b("0x45450945124C8A57"),b("0xF3F3EBF3CB18FB38"),b("0x3030C0309DF060AD"),b("0xEFEF9BEF2B74C3C4"),b("0x3F3FFC3FE5C37EDA"),b("0x55554955921CAAC7"),b("0xA2A2B2A2791059DB"),b("0xEAEA8FEA0365C9E9"),b("0x656589650FECCA6A"),b("0xBABAD2BAB9686903"),b("0x2F2FBC2F65935E4A"),b("0xC0C027C04EE79D8E"),b("0xDEDE5FDEBE81A160"),b("0x1C1C701CE06C38FC"),b("0xFDFDD3FDBB2EE746"),b("0x4D4D294D52649A1F"),b("0x92927292E4E03976"),b("0x7575C9758FBCEAFA"),b("0x06061806301E0C36"),b("0x8A8A128A249809AE"),b("0xB2B2F2B2F940794B"),b("0xE6E6BFE66359D185"),b("0x0E0E380E70361C7E"),b("0x1F1F7C1FF8633EE7"),b("0x6262956237F7C455"),b("0xD4D477D4EEA3B53A"),b("0xA8A89AA829324D81"),b("0x96966296C4F43152"),b("0xF9F9C3F99B3AEF62"),b("0xC5C533C566F697A3"),b("0x2525942535B14A10"),b("0x59597959F220B2AB"),b("0x84842A8454AE15D0"),b("0x7272D572B7A7E4C5"),b("0x3939E439D5DD72EC"),b("0x4C4C2D4C5A619816"),b("0x5E5E655ECA3BBC94"),b("0x7878FD78E785F09F"),b("0x3838E038DDD870E5"),b("0x8C8C0A8C14860598"),b("0xD1D163D1C6B2BF17"),b("0xA5A5AEA5410B57E4"),b("0xE2E2AFE2434DD9A1"),b("0x616199612FF8C24E"),b("0xB3B3F6B3F1457B42"),b("0x2121842115A54234"),b("0x9C9C4A9C94D62508"),b("0x1E1E781EF0663CEE"),b("0x4343114322528661"),b("0xC7C73BC776FC93B1"),b("0xFCFCD7FCB32BE54F"),b("0x0404100420140824"),b("0x51515951B208A2E3"),b("0x99995E99BCC72F25"),b("0x6D6DA96D4FC4DA22"),b("0x0D0D340D68391A65"),b("0xFAFACFFA8335E979"),b("0xDFDF5BDFB684A369"),b("0x7E7EE57ED79BFCA9"),b("0x242490243DB44819"),b("0x3B3BEC3BC5D776FE"),b("0xABAB96AB313D4B9A"),b("0xCECE1FCE3ED181F0"),b("0x1111441188552299"),b("0x8F8F068F0C890383"),b("0x4E4E254E4A6B9C04"),b("0xB7B7E6B7D1517366"),b("0xEBEB8BEB0B60CBE0"),b("0x3C3CF03CFDCC78C1"),b("0x81813E817CBF1FFD"),b("0x94946A94D4FE3540"),b("0xF7F7FBF7EB0CF31C"),b("0xB9B9DEB9A1676F18"),b("0x13134C13985F268B"),b("0x2C2CB02C7D9C5851"),b("0xD3D36BD3D6B8BB05"),b("0xE7E7BBE76B5CD38C"),b("0x6E6EA56E57CBDC39"),b("0xC4C437C46EF395AA"),b("0x03030C03180F061B"),b("0x565645568A13ACDC"),b("0x44440D441A49885E"),b("0x7F7FE17FDF9EFEA0"),b("0xA9A99EA921374F88"),b("0x2A2AA82A4D825467"),b("0xBBBBD6BBB16D6B0A"),b("0xC1C123C146E29F87"),b("0x53535153A202A6F1"),b("0xDCDC57DCAE8BA572"),b("0x0B0B2C0B58271653"),b("0x9D9D4E9D9CD32701"),b("0x6C6CAD6C47C1D82B"),b("0x3131C43195F562A4"),b("0x7474CD7487B9E8F3"),b("0xF6F6FFF6E309F115"),b("0x464605460A438C4C"),b("0xACAC8AAC092645A5"),b("0x89891E893C970FB5"),b("0x14145014A04428B4"),b("0xE1E1A3E15B42DFBA"),b("0x16165816B04E2CA6"),b("0x3A3AE83ACDD274F7"),b("0x6969B9696FD0D206"),b("0x09092409482D1241"),b("0x7070DD70A7ADE0D7"),b("0xB6B6E2B6D954716F"),b("0xD0D067D0CEB7BD1E"),b("0xEDED93ED3B7EC7D6"),b("0xCCCC17CC2EDB85E2"),b("0x424215422A578468"),b("0x98985A98B4C22D2C"),b("0xA4A4AAA4490E55ED"),b("0x2828A0285D885075"),b("0x5C5C6D5CDA31B886"),b("0xF8F8C7F8933FED6B"),b("0x8686228644A411C2")}local h={b("0xD818186018C07830"),b("0x2623238C2305AF46"),b("0xB8C6C63FC67EF991"),b("0xFBE8E887E8136FCD"),b("0xCB878726874CA113"),b("0x11B8B8DAB8A9626D"),b("0x0901010401080502"),b("0x0D4F4F214F426E9E"),b("0x9B3636D836ADEE6C"),b("0xFFA6A6A2A6590451"),b("0x0CD2D26FD2DEBDB9"),b("0x0EF5F5F3F5FB06F7"),b("0x967979F979EF80F2"),b("0x306F6FA16F5FCEDE"),b("0x6D91917E91FCEF3F"),b("0xF852525552AA07A4"),b("0x4760609D6027FDC0"),b("0x35BCBCCABC897665"),b("0x379B9B569BACCD2B"),b("0x8A8E8E028E048C01"),b("0xD2A3A3B6A371155B"),b("0x6C0C0C300C603C18"),b("0x847B7BF17BFF8AF6"),b("0x803535D435B5E16A"),b("0xF51D1D741DE8693A"),b("0xB3E0E0A7E05347DD"),b("0x21D7D77BD7F6ACB3"),b("0x9CC2C22FC25EED99"),b("0x432E2EB82E6D965C"),b("0x294B4B314B627A96"),b("0x5DFEFEDFFEA321E1"),b("0xD5575741578216AE"),b("0xBD15155415A8412A"),b("0xE87777C1779FB6EE"),b("0x923737DC37A5EB6E"),b("0x9EE5E5B3E57B56D7"),b("0x139F9F469F8CD923"),b("0x23F0F0E7F0D317FD"),b("0x204A4A354A6A7F94"),b("0x44DADA4FDA9E95A9"),b("0xA258587D58FA25B0"),b("0xCFC9C903C906CA8F"),b("0x7C2929A429558D52"),b("0x5A0A0A280A502214"),b("0x50B1B1FEB1E14F7F"),b("0xC9A0A0BAA0691A5D"),b("0x146B6BB16B7FDAD6"),b("0xD985852E855CAB17"),b("0x3CBDBDCEBD817367"),b("0x8F5D5D695DD234BA"),b("0x9010104010805020"),b("0x07F4F4F7F4F303F5"),b("0xDDCBCB0BCB16C08B"),b("0xD33E3EF83EEDC67C"),b("0x2D0505140528110A"),b("0x78676781671FE6CE"),b("0x97E4E4B7E47353D5"),b("0x0227279C2725BB4E"),b("0x7341411941325882"),b("0xA78B8B168B2C9D0B"),b("0xF6A7A7A6A7510153"),b("0xB27D7DE97DCF94FA"),b("0x4995956E95DCFB37"),b("0x56D8D847D88E9FAD"),b("0x70FBFBCBFB8B30EB"),b("0xCDEEEE9FEE2371C1"),b("0xBB7C7CED7CC791F8"),b("0x716666856617E3CC"),b("0x7BDDDD53DDA68EA7"),b("0xAF17175C17B84B2E"),b("0x454747014702468E"),b("0x1A9E9E429E84DC21"),b("0xD4CACA0FCA1EC589"),b("0x582D2DB42D75995A"),b("0x2EBFBFC6BF917963"),b("0x3F07071C07381B0E"),b("0xACADAD8EAD012347"),b("0xB05A5A755AEA2FB4"),b("0xEF838336836CB51B"),b("0xB63333CC3385FF66"),b("0x5C636391633FF2C6"),b("0x1202020802100A04"),b("0x93AAAA92AA393849"),b("0xDE7171D971AFA8E2"),b("0xC6C8C807C80ECF8D"),b("0xD119196419C87D32"),b("0x3B49493949727092"),b("0x5FD9D943D9869AAF"),b("0x31F2F2EFF2C31DF9"),b("0xA8E3E3ABE34B48DB"),b("0xB95B5B715BE22AB6"),b("0xBC88881A8834920D"),b("0x3E9A9A529AA4C829"),b("0x0B262698262DBE4C"),b("0xBF3232C8328DFA64"),b("0x59B0B0FAB0E94A7D"),b("0xF2E9E983E91B6ACF"),b("0x770F0F3C0F78331E"),b("0x33D5D573D5E6A6B7"),b("0xF480803A8074BA1D"),b("0x27BEBEC2BE997C61"),b("0xEBCDCD13CD26DE87"),b("0x893434D034BDE468"),b("0x3248483D487A7590"),b("0x54FFFFDBFFAB24E3"),b("0x8D7A7AF57AF78FF4"),b("0x6490907A90F4EA3D"),b("0x9D5F5F615FC23EBE"),b("0x3D202080201DA040"),b("0x0F6868BD6867D5D0"),b("0xCA1A1A681AD07234"),b("0xB7AEAE82AE192C41"),b("0x7DB4B4EAB4C95E75"),b("0xCE54544D549A19A8"),b("0x7F93937693ECE53B"),b("0x2F222288220DAA44"),b("0x6364648D6407E9C8"),b("0x2AF1F1E3F1DB12FF"),b("0xCC7373D173BFA2E6"),b("0x8212124812905A24"),b("0x7A40401D403A5D80"),b("0x4808082008402810"),b("0x95C3C32BC356E89B"),b("0xDFECEC97EC337BC5"),b("0x4DDBDB4BDB9690AB"),b("0xC0A1A1BEA1611F5F"),b("0x918D8D0E8D1C8307"),b("0xC83D3DF43DF5C97A"),b("0x5B97976697CCF133"),b("0x0000000000000000"),b("0xF9CFCF1BCF36D483"),b("0x6E2B2BAC2B458756"),b("0xE17676C57697B3EC"),b("0xE68282328264B019"),b("0x28D6D67FD6FEA9B1"),b("0xC31B1B6C1BD87736"),b("0x74B5B5EEB5C15B77"),b("0xBEAFAF86AF112943"),b("0x1D6A6AB56A77DFD4"),b("0xEA50505D50BA0DA0"),b("0x5745450945124C8A"),b("0x38F3F3EBF3CB18FB"),b("0xAD3030C0309DF060"),b("0xC4EFEF9BEF2B74C3"),b("0xDA3F3FFC3FE5C37E"),b("0xC755554955921CAA"),b("0xDBA2A2B2A2791059"),b("0xE9EAEA8FEA0365C9"),b("0x6A656589650FECCA"),b("0x03BABAD2BAB96869"),b("0x4A2F2FBC2F65935E"),b("0x8EC0C027C04EE79D"),b("0x60DEDE5FDEBE81A1"),b("0xFC1C1C701CE06C38"),b("0x46FDFDD3FDBB2EE7"),b("0x1F4D4D294D52649A"),b("0x7692927292E4E039"),b("0xFA7575C9758FBCEA"),b("0x3606061806301E0C"),b("0xAE8A8A128A249809"),b("0x4BB2B2F2B2F94079"),b("0x85E6E6BFE66359D1"),b("0x7E0E0E380E70361C"),b("0xE71F1F7C1FF8633E"),b("0x556262956237F7C4"),b("0x3AD4D477D4EEA3B5"),b("0x81A8A89AA829324D"),b("0x5296966296C4F431"),b("0x62F9F9C3F99B3AEF"),b("0xA3C5C533C566F697"),b("0x102525942535B14A"),b("0xAB59597959F220B2"),b("0xD084842A8454AE15"),b("0xC57272D572B7A7E4"),b("0xEC3939E439D5DD72"),b("0x164C4C2D4C5A6198"),b("0x945E5E655ECA3BBC"),b("0x9F7878FD78E785F0"),b("0xE53838E038DDD870"),b("0x988C8C0A8C148605"),b("0x17D1D163D1C6B2BF"),b("0xE4A5A5AEA5410B57"),b("0xA1E2E2AFE2434DD9"),b("0x4E616199612FF8C2"),b("0x42B3B3F6B3F1457B"),b("0x342121842115A542"),b("0x089C9C4A9C94D625"),b("0xEE1E1E781EF0663C"),b("0x6143431143225286"),b("0xB1C7C73BC776FC93"),b("0x4FFCFCD7FCB32BE5"),b("0x2404041004201408"),b("0xE351515951B208A2"),b("0x2599995E99BCC72F"),b("0x226D6DA96D4FC4DA"),b("0x650D0D340D68391A"),b("0x79FAFACFFA8335E9"),b("0x69DFDF5BDFB684A3"),b("0xA97E7EE57ED79BFC"),b("0x19242490243DB448"),b("0xFE3B3BEC3BC5D776"),b("0x9AABAB96AB313D4B"),b("0xF0CECE1FCE3ED181"),b("0x9911114411885522"),b("0x838F8F068F0C8903"),b("0x044E4E254E4A6B9C"),b("0x66B7B7E6B7D15173"),b("0xE0EBEB8BEB0B60CB"),b("0xC13C3CF03CFDCC78"),b("0xFD81813E817CBF1F"),b("0x4094946A94D4FE35"),b("0x1CF7F7FBF7EB0CF3"),b("0x18B9B9DEB9A1676F"),b("0x8B13134C13985F26"),b("0x512C2CB02C7D9C58"),b("0x05D3D36BD3D6B8BB"),b("0x8CE7E7BBE76B5CD3"),b("0x396E6EA56E57CBDC"),b("0xAAC4C437C46EF395"),b("0x1B03030C03180F06"),b("0xDC565645568A13AC"),b("0x5E44440D441A4988"),b("0xA07F7FE17FDF9EFE"),b("0x88A9A99EA921374F"),b("0x672A2AA82A4D8254"),b("0x0ABBBBD6BBB16D6B"),b("0x87C1C123C146E29F"),b("0xF153535153A202A6"),b("0x72DCDC57DCAE8BA5"),b("0x530B0B2C0B582716"),b("0x019D9D4E9D9CD327"),b("0x2B6C6CAD6C47C1D8"),b("0xA43131C43195F562"),b("0xF37474CD7487B9E8"),b("0x15F6F6FFF6E309F1"),b("0x4C464605460A438C"),b("0xA5ACAC8AAC092645"),b("0xB589891E893C970F"),b("0xB414145014A04428"),b("0xBAE1E1A3E15B42DF"),b("0xA616165816B04E2C"),b("0xF73A3AE83ACDD274"),b("0x066969B9696FD0D2"),b("0x4109092409482D12"),b("0xD77070DD70A7ADE0"),b("0x6FB6B6E2B6D95471"),b("0x1ED0D067D0CEB7BD"),b("0xD6EDED93ED3B7EC7"),b("0xE2CCCC17CC2EDB85"),b("0x68424215422A5784"),b("0x2C98985A98B4C22D"),b("0xEDA4A4AAA4490E55"),b("0x752828A0285D8850"),b("0x865C5C6D5CDA31B8"),b("0x6BF8F8C7F8933FED"),b("0xC28686228644A411")}local i={b("0x30D818186018C078"),b("0x462623238C2305AF"),b("0x91B8C6C63FC67EF9"),b("0xCDFBE8E887E8136F"),b("0x13CB878726874CA1"),b("0x6D11B8B8DAB8A962"),b("0x0209010104010805"),b("0x9E0D4F4F214F426E"),b("0x6C9B3636D836ADEE"),b("0x51FFA6A6A2A65904"),b("0xB90CD2D26FD2DEBD"),b("0xF70EF5F5F3F5FB06"),b("0xF2967979F979EF80"),b("0xDE306F6FA16F5FCE"),b("0x3F6D91917E91FCEF"),b("0xA4F852525552AA07"),b("0xC04760609D6027FD"),b("0x6535BCBCCABC8976"),b("0x2B379B9B569BACCD"),b("0x018A8E8E028E048C"),b("0x5BD2A3A3B6A37115"),b("0x186C0C0C300C603C"),b("0xF6847B7BF17BFF8A"),b("0x6A803535D435B5E1"),b("0x3AF51D1D741DE869"),b("0xDDB3E0E0A7E05347"),b("0xB321D7D77BD7F6AC"),b("0x999CC2C22FC25EED"),b("0x5C432E2EB82E6D96"),b("0x96294B4B314B627A"),b("0xE15DFEFEDFFEA321"),b("0xAED5575741578216"),b("0x2ABD15155415A841"),b("0xEEE87777C1779FB6"),b("0x6E923737DC37A5EB"),b("0xD79EE5E5B3E57B56"),b("0x23139F9F469F8CD9"),b("0xFD23F0F0E7F0D317"),b("0x94204A4A354A6A7F"),b("0xA944DADA4FDA9E95"),b("0xB0A258587D58FA25"),b("0x8FCFC9C903C906CA"),b("0x527C2929A429558D"),b("0x145A0A0A280A5022"),b("0x7F50B1B1FEB1E14F"),b("0x5DC9A0A0BAA0691A"),b("0xD6146B6BB16B7FDA"),b("0x17D985852E855CAB"),b("0x673CBDBDCEBD8173"),b("0xBA8F5D5D695DD234"),b("0x2090101040108050"),b("0xF507F4F4F7F4F303"),b("0x8BDDCBCB0BCB16C0"),b("0x7CD33E3EF83EEDC6"),b("0x0A2D050514052811"),b("0xCE78676781671FE6"),b("0xD597E4E4B7E47353"),b("0x4E0227279C2725BB"),b("0x8273414119413258"),b("0x0BA78B8B168B2C9D"),b("0x53F6A7A7A6A75101"),b("0xFAB27D7DE97DCF94"),b("0x374995956E95DCFB"),b("0xAD56D8D847D88E9F"),b("0xEB70FBFBCBFB8B30"),b("0xC1CDEEEE9FEE2371"),b("0xF8BB7C7CED7CC791"),b("0xCC716666856617E3"),b("0xA77BDDDD53DDA68E"),b("0x2EAF17175C17B84B"),b("0x8E45474701470246"),b("0x211A9E9E429E84DC"),b("0x89D4CACA0FCA1EC5"),b("0x5A582D2DB42D7599"),b("0x632EBFBFC6BF9179"),b("0x0E3F07071C07381B"),b("0x47ACADAD8EAD0123"),b("0xB4B05A5A755AEA2F"),b("0x1BEF838336836CB5"),b("0x66B63333CC3385FF"),b("0xC65C636391633FF2"),b("0x041202020802100A"),b("0x4993AAAA92AA3938"),b("0xE2DE7171D971AFA8"),b("0x8DC6C8C807C80ECF"),b("0x32D119196419C87D"),b("0x923B494939497270"),b("0xAF5FD9D943D9869A"),b("0xF931F2F2EFF2C31D"),b("0xDBA8E3E3ABE34B48"),b("0xB6B95B5B715BE22A"),b("0x0DBC88881A883492"),b("0x293E9A9A529AA4C8"),b("0x4C0B262698262DBE"),b("0x64BF3232C8328DFA"),b("0x7D59B0B0FAB0E94A"),b("0xCFF2E9E983E91B6A"),b("0x1E770F0F3C0F7833"),b("0xB733D5D573D5E6A6"),b("0x1DF480803A8074BA"),b("0x6127BEBEC2BE997C"),b("0x87EBCDCD13CD26DE"),b("0x68893434D034BDE4"),b("0x903248483D487A75"),b("0xE354FFFFDBFFAB24"),b("0xF48D7A7AF57AF78F"),b("0x3D6490907A90F4EA"),b("0xBE9D5F5F615FC23E"),b("0x403D202080201DA0"),b("0xD00F6868BD6867D5"),b("0x34CA1A1A681AD072"),b("0x41B7AEAE82AE192C"),b("0x757DB4B4EAB4C95E"),b("0xA8CE54544D549A19"),b("0x3B7F93937693ECE5"),b("0x442F222288220DAA"),b("0xC86364648D6407E9"),b("0xFF2AF1F1E3F1DB12"),b("0xE6CC7373D173BFA2"),b("0x248212124812905A"),b("0x807A40401D403A5D"),b("0x1048080820084028"),b("0x9B95C3C32BC356E8"),b("0xC5DFECEC97EC337B"),b("0xAB4DDBDB4BDB9690"),b("0x5FC0A1A1BEA1611F"),b("0x07918D8D0E8D1C83"),b("0x7AC83D3DF43DF5C9"),b("0x335B97976697CCF1"),b("0x0000000000000000"),b("0x83F9CFCF1BCF36D4"),b("0x566E2B2BAC2B4587"),b("0xECE17676C57697B3"),b("0x19E68282328264B0"),b("0xB128D6D67FD6FEA9"),b("0x36C31B1B6C1BD877"),b("0x7774B5B5EEB5C15B"),b("0x43BEAFAF86AF1129"),b("0xD41D6A6AB56A77DF"),b("0xA0EA50505D50BA0D"),b("0x8A5745450945124C"),b("0xFB38F3F3EBF3CB18"),b("0x60AD3030C0309DF0"),b("0xC3C4EFEF9BEF2B74"),b("0x7EDA3F3FFC3FE5C3"),b("0xAAC755554955921C"),b("0x59DBA2A2B2A27910"),b("0xC9E9EAEA8FEA0365"),b("0xCA6A656589650FEC"),b("0x6903BABAD2BAB968"),b("0x5E4A2F2FBC2F6593"),b("0x9D8EC0C027C04EE7"),b("0xA160DEDE5FDEBE81"),b("0x38FC1C1C701CE06C"),b("0xE746FDFDD3FDBB2E"),b("0x9A1F4D4D294D5264"),b("0x397692927292E4E0"),b("0xEAFA7575C9758FBC"),b("0x0C3606061806301E"),b("0x09AE8A8A128A2498"),b("0x794BB2B2F2B2F940"),b("0xD185E6E6BFE66359"),b("0x1C7E0E0E380E7036"),b("0x3EE71F1F7C1FF863"),b("0xC4556262956237F7"),b("0xB53AD4D477D4EEA3"),b("0x4D81A8A89AA82932"),b("0x315296966296C4F4"),b("0xEF62F9F9C3F99B3A"),b("0x97A3C5C533C566F6"),b("0x4A102525942535B1"),b("0xB2AB59597959F220"),b("0x15D084842A8454AE"),b("0xE4C57272D572B7A7"),b("0x72EC3939E439D5DD"),b("0x98164C4C2D4C5A61"),b("0xBC945E5E655ECA3B"),b("0xF09F7878FD78E785"),b("0x70E53838E038DDD8"),b("0x05988C8C0A8C1486"),b("0xBF17D1D163D1C6B2"),b("0x57E4A5A5AEA5410B"),b("0xD9A1E2E2AFE2434D"),b("0xC24E616199612FF8"),b("0x7B42B3B3F6B3F145"),b("0x42342121842115A5"),b("0x25089C9C4A9C94D6"),b("0x3CEE1E1E781EF066"),b("0x8661434311432252"),b("0x93B1C7C73BC776FC"),b("0xE54FFCFCD7FCB32B"),b("0x0824040410042014"),b("0xA2E351515951B208"),b("0x2F2599995E99BCC7"),b("0xDA226D6DA96D4FC4"),b("0x1A650D0D340D6839"),b("0xE979FAFACFFA8335"),b("0xA369DFDF5BDFB684"),b("0xFCA97E7EE57ED79B"),b("0x4819242490243DB4"),b("0x76FE3B3BEC3BC5D7"),b("0x4B9AABAB96AB313D"),b("0x81F0CECE1FCE3ED1"),b("0x2299111144118855"),b("0x03838F8F068F0C89"),b("0x9C044E4E254E4A6B"),b("0x7366B7B7E6B7D151"),b("0xCBE0EBEB8BEB0B60"),b("0x78C13C3CF03CFDCC"),b("0x1FFD81813E817CBF"),b("0x354094946A94D4FE"),b("0xF31CF7F7FBF7EB0C"),b("0x6F18B9B9DEB9A167"),b("0x268B13134C13985F"),b("0x58512C2CB02C7D9C"),b("0xBB05D3D36BD3D6B8"),b("0xD38CE7E7BBE76B5C"),b("0xDC396E6EA56E57CB"),b("0x95AAC4C437C46EF3"),b("0x061B03030C03180F"),b("0xACDC565645568A13"),b("0x885E44440D441A49"),b("0xFEA07F7FE17FDF9E"),b("0x4F88A9A99EA92137"),b("0x54672A2AA82A4D82"),b("0x6B0ABBBBD6BBB16D"),b("0x9F87C1C123C146E2"),b("0xA6F153535153A202"),b("0xA572DCDC57DCAE8B"),b("0x16530B0B2C0B5827"),b("0x27019D9D4E9D9CD3"),b("0xD82B6C6CAD6C47C1"),b("0x62A43131C43195F5"),b("0xE8F37474CD7487B9"),b("0xF115F6F6FFF6E309"),b("0x8C4C464605460A43"),b("0x45A5ACAC8AAC0926"),b("0x0FB589891E893C97"),b("0x28B414145014A044"),b("0xDFBAE1E1A3E15B42"),b("0x2CA616165816B04E"),b("0x74F73A3AE83ACDD2"),b("0xD2066969B9696FD0"),b("0x124109092409482D"),b("0xE0D77070DD70A7AD"),b("0x716FB6B6E2B6D954"),b("0xBD1ED0D067D0CEB7"),b("0xC7D6EDED93ED3B7E"),b("0x85E2CCCC17CC2EDB"),b("0x8468424215422A57"),b("0x2D2C98985A98B4C2"),b("0x55EDA4A4AAA4490E"),b("0x50752828A0285D88"),b("0xB8865C5C6D5CDA31"),b("0xED6BF8F8C7F8933F"),b("0x11C28686228644A4")}local j={b("0x7830D818186018C0"),b("0xAF462623238C2305"),b("0xF991B8C6C63FC67E"),b("0x6FCDFBE8E887E813"),b("0xA113CB878726874C"),b("0x626D11B8B8DAB8A9"),b("0x0502090101040108"),b("0x6E9E0D4F4F214F42"),b("0xEE6C9B3636D836AD"),b("0x0451FFA6A6A2A659"),b("0xBDB90CD2D26FD2DE"),b("0x06F70EF5F5F3F5FB"),b("0x80F2967979F979EF"),b("0xCEDE306F6FA16F5F"),b("0xEF3F6D91917E91FC"),b("0x07A4F852525552AA"),b("0xFDC04760609D6027"),b("0x766535BCBCCABC89"),b("0xCD2B379B9B569BAC"),b("0x8C018A8E8E028E04"),b("0x155BD2A3A3B6A371"),b("0x3C186C0C0C300C60"),b("0x8AF6847B7BF17BFF"),b("0xE16A803535D435B5"),b("0x693AF51D1D741DE8"),b("0x47DDB3E0E0A7E053"),b("0xACB321D7D77BD7F6"),b("0xED999CC2C22FC25E"),b("0x965C432E2EB82E6D"),b("0x7A96294B4B314B62"),b("0x21E15DFEFEDFFEA3"),b("0x16AED55757415782"),b("0x412ABD15155415A8"),b("0xB6EEE87777C1779F"),b("0xEB6E923737DC37A5"),b("0x56D79EE5E5B3E57B"),b("0xD923139F9F469F8C"),b("0x17FD23F0F0E7F0D3"),b("0x7F94204A4A354A6A"),b("0x95A944DADA4FDA9E"),b("0x25B0A258587D58FA"),b("0xCA8FCFC9C903C906"),b("0x8D527C2929A42955"),b("0x22145A0A0A280A50"),b("0x4F7F50B1B1FEB1E1"),b("0x1A5DC9A0A0BAA069"),b("0xDAD6146B6BB16B7F"),b("0xAB17D985852E855C"),b("0x73673CBDBDCEBD81"),b("0x34BA8F5D5D695DD2"),b("0x5020901010401080"),b("0x03F507F4F4F7F4F3"),b("0xC08BDDCBCB0BCB16"),b("0xC67CD33E3EF83EED"),b("0x110A2D0505140528"),b("0xE6CE78676781671F"),b("0x53D597E4E4B7E473"),b("0xBB4E0227279C2725"),b("0x5882734141194132"),b("0x9D0BA78B8B168B2C"),b("0x0153F6A7A7A6A751"),b("0x94FAB27D7DE97DCF"),b("0xFB374995956E95DC"),b("0x9FAD56D8D847D88E"),b("0x30EB70FBFBCBFB8B"),b("0x71C1CDEEEE9FEE23"),b("0x91F8BB7C7CED7CC7"),b("0xE3CC716666856617"),b("0x8EA77BDDDD53DDA6"),b("0x4B2EAF17175C17B8"),b("0x468E454747014702"),b("0xDC211A9E9E429E84"),b("0xC589D4CACA0FCA1E"),b("0x995A582D2DB42D75"),b("0x79632EBFBFC6BF91"),b("0x1B0E3F07071C0738"),b("0x2347ACADAD8EAD01"),b("0x2FB4B05A5A755AEA"),b("0xB51BEF838336836C"),b("0xFF66B63333CC3385"),b("0xF2C65C636391633F"),b("0x0A04120202080210"),b("0x384993AAAA92AA39"),b("0xA8E2DE7171D971AF"),b("0xCF8DC6C8C807C80E"),b("0x7D32D119196419C8"),b("0x70923B4949394972"),b("0x9AAF5FD9D943D986"),b("0x1DF931F2F2EFF2C3"),b("0x48DBA8E3E3ABE34B"),b("0x2AB6B95B5B715BE2"),b("0x920DBC88881A8834"),b("0xC8293E9A9A529AA4"),b("0xBE4C0B262698262D"),b("0xFA64BF3232C8328D"),b("0x4A7D59B0B0FAB0E9"),b("0x6ACFF2E9E983E91B"),b("0x331E770F0F3C0F78"),b("0xA6B733D5D573D5E6"),b("0xBA1DF480803A8074"),b("0x7C6127BEBEC2BE99"),b("0xDE87EBCDCD13CD26"),b("0xE468893434D034BD"),b("0x75903248483D487A"),b("0x24E354FFFFDBFFAB"),b("0x8FF48D7A7AF57AF7"),b("0xEA3D6490907A90F4"),b("0x3EBE9D5F5F615FC2"),b("0xA0403D202080201D"),b("0xD5D00F6868BD6867"),b("0x7234CA1A1A681AD0"),b("0x2C41B7AEAE82AE19"),b("0x5E757DB4B4EAB4C9"),b("0x19A8CE54544D549A"),b("0xE53B7F93937693EC"),b("0xAA442F222288220D"),b("0xE9C86364648D6407"),b("0x12FF2AF1F1E3F1DB"),b("0xA2E6CC7373D173BF"),b("0x5A24821212481290"),b("0x5D807A40401D403A"),b("0x2810480808200840"),b("0xE89B95C3C32BC356"),b("0x7BC5DFECEC97EC33"),b("0x90AB4DDBDB4BDB96"),b("0x1F5FC0A1A1BEA161"),b("0x8307918D8D0E8D1C"),b("0xC97AC83D3DF43DF5"),b("0xF1335B97976697CC"),b("0x0000000000000000"),b("0xD483F9CFCF1BCF36"),b("0x87566E2B2BAC2B45"),b("0xB3ECE17676C57697"),b("0xB019E68282328264"),b("0xA9B128D6D67FD6FE"),b("0x7736C31B1B6C1BD8"),b("0x5B7774B5B5EEB5C1"),b("0x2943BEAFAF86AF11"),b("0xDFD41D6A6AB56A77"),b("0x0DA0EA50505D50BA"),b("0x4C8A574545094512"),b("0x18FB38F3F3EBF3CB"),b("0xF060AD3030C0309D"),b("0x74C3C4EFEF9BEF2B"),b("0xC37EDA3F3FFC3FE5"),b("0x1CAAC75555495592"),b("0x1059DBA2A2B2A279"),b("0x65C9E9EAEA8FEA03"),b("0xECCA6A656589650F"),b("0x686903BABAD2BAB9"),b("0x935E4A2F2FBC2F65"),b("0xE79D8EC0C027C04E"),b("0x81A160DEDE5FDEBE"),b("0x6C38FC1C1C701CE0"),b("0x2EE746FDFDD3FDBB"),b("0x649A1F4D4D294D52"),b("0xE0397692927292E4"),b("0xBCEAFA7575C9758F"),b("0x1E0C360606180630"),b("0x9809AE8A8A128A24"),b("0x40794BB2B2F2B2F9"),b("0x59D185E6E6BFE663"),b("0x361C7E0E0E380E70"),b("0x633EE71F1F7C1FF8"),b("0xF7C4556262956237"),b("0xA3B53AD4D477D4EE"),b("0x324D81A8A89AA829"),b("0xF4315296966296C4"),b("0x3AEF62F9F9C3F99B"),b("0xF697A3C5C533C566"),b("0xB14A102525942535"),b("0x20B2AB59597959F2"),b("0xAE15D084842A8454"),b("0xA7E4C57272D572B7"),b("0xDD72EC3939E439D5"),b("0x6198164C4C2D4C5A"),b("0x3BBC945E5E655ECA"),b("0x85F09F7878FD78E7"),b("0xD870E53838E038DD"),b("0x8605988C8C0A8C14"),b("0xB2BF17D1D163D1C6"),b("0x0B57E4A5A5AEA541"),b("0x4DD9A1E2E2AFE243"),b("0xF8C24E616199612F"),b("0x457B42B3B3F6B3F1"),b("0xA542342121842115"),b("0xD625089C9C4A9C94"),b("0x663CEE1E1E781EF0"),b("0x5286614343114322"),b("0xFC93B1C7C73BC776"),b("0x2BE54FFCFCD7FCB3"),b("0x1408240404100420"),b("0x08A2E351515951B2"),b("0xC72F2599995E99BC"),b("0xC4DA226D6DA96D4F"),b("0x391A650D0D340D68"),b("0x35E979FAFACFFA83"),b("0x84A369DFDF5BDFB6"),b("0x9BFCA97E7EE57ED7"),b("0xB44819242490243D"),b("0xD776FE3B3BEC3BC5"),b("0x3D4B9AABAB96AB31"),b("0xD181F0CECE1FCE3E"),b("0x5522991111441188"),b("0x8903838F8F068F0C"),b("0x6B9C044E4E254E4A"),b("0x517366B7B7E6B7D1"),b("0x60CBE0EBEB8BEB0B"),b("0xCC78C13C3CF03CFD"),b("0xBF1FFD81813E817C"),b("0xFE354094946A94D4"),b("0x0CF31CF7F7FBF7EB"),b("0x676F18B9B9DEB9A1"),b("0x5F268B13134C1398"),b("0x9C58512C2CB02C7D"),b("0xB8BB05D3D36BD3D6"),b("0x5CD38CE7E7BBE76B"),b("0xCBDC396E6EA56E57"),b("0xF395AAC4C437C46E"),b("0x0F061B03030C0318"),b("0x13ACDC565645568A"),b("0x49885E44440D441A"),b("0x9EFEA07F7FE17FDF"),b("0x374F88A9A99EA921"),b("0x8254672A2AA82A4D"),b("0x6D6B0ABBBBD6BBB1"),b("0xE29F87C1C123C146"),b("0x02A6F153535153A2"),b("0x8BA572DCDC57DCAE"),b("0x2716530B0B2C0B58"),b("0xD327019D9D4E9D9C"),b("0xC1D82B6C6CAD6C47"),b("0xF562A43131C43195"),b("0xB9E8F37474CD7487"),b("0x09F115F6F6FFF6E3"),b("0x438C4C464605460A"),b("0x2645A5ACAC8AAC09"),b("0x970FB589891E893C"),b("0x4428B414145014A0"),b("0x42DFBAE1E1A3E15B"),b("0x4E2CA616165816B0"),b("0xD274F73A3AE83ACD"),b("0xD0D2066969B9696F"),b("0x2D12410909240948"),b("0xADE0D77070DD70A7"),b("0x54716FB6B6E2B6D9"),b("0xB7BD1ED0D067D0CE"),b("0x7EC7D6EDED93ED3B"),b("0xDB85E2CCCC17CC2E"),b("0x578468424215422A"),b("0xC22D2C98985A98B4"),b("0x0E55EDA4A4AAA449"),b("0x8850752828A0285D"),b("0x31B8865C5C6D5CDA"),b("0x3FED6BF8F8C7F893"),b("0xA411C28686228644")}local k={b("0xC07830D818186018"),b("0x05AF462623238C23"),b("0x7EF991B8C6C63FC6"),b("0x136FCDFBE8E887E8"),b("0x4CA113CB87872687"),b("0xA9626D11B8B8DAB8"),b("0x0805020901010401"),b("0x426E9E0D4F4F214F"),b("0xADEE6C9B3636D836"),b("0x590451FFA6A6A2A6"),b("0xDEBDB90CD2D26FD2"),b("0xFB06F70EF5F5F3F5"),b("0xEF80F2967979F979"),b("0x5FCEDE306F6FA16F"),b("0xFCEF3F6D91917E91"),b("0xAA07A4F852525552"),b("0x27FDC04760609D60"),b("0x89766535BCBCCABC"),b("0xACCD2B379B9B569B"),b("0x048C018A8E8E028E"),b("0x71155BD2A3A3B6A3"),b("0x603C186C0C0C300C"),b("0xFF8AF6847B7BF17B"),b("0xB5E16A803535D435"),b("0xE8693AF51D1D741D"),b("0x5347DDB3E0E0A7E0"),b("0xF6ACB321D7D77BD7"),b("0x5EED999CC2C22FC2"),b("0x6D965C432E2EB82E"),b("0x627A96294B4B314B"),b("0xA321E15DFEFEDFFE"),b("0x8216AED557574157"),b("0xA8412ABD15155415"),b("0x9FB6EEE87777C177"),b("0xA5EB6E923737DC37"),b("0x7B56D79EE5E5B3E5"),b("0x8CD923139F9F469F"),b("0xD317FD23F0F0E7F0"),b("0x6A7F94204A4A354A"),b("0x9E95A944DADA4FDA"),b("0xFA25B0A258587D58"),b("0x06CA8FCFC9C903C9"),b("0x558D527C2929A429"),b("0x5022145A0A0A280A"),b("0xE14F7F50B1B1FEB1"),b("0x691A5DC9A0A0BAA0"),b("0x7FDAD6146B6BB16B"),b("0x5CAB17D985852E85"),b("0x8173673CBDBDCEBD"),b("0xD234BA8F5D5D695D"),b("0x8050209010104010"),b("0xF303F507F4F4F7F4"),b("0x16C08BDDCBCB0BCB"),b("0xEDC67CD33E3EF83E"),b("0x28110A2D05051405"),b("0x1FE6CE7867678167"),b("0x7353D597E4E4B7E4"),b("0x25BB4E0227279C27"),b("0x3258827341411941"),b("0x2C9D0BA78B8B168B"),b("0x510153F6A7A7A6A7"),b("0xCF94FAB27D7DE97D"),b("0xDCFB374995956E95"),b("0x8E9FAD56D8D847D8"),b("0x8B30EB70FBFBCBFB"),b("0x2371C1CDEEEE9FEE"),b("0xC791F8BB7C7CED7C"),b("0x17E3CC7166668566"),b("0xA68EA77BDDDD53DD"),b("0xB84B2EAF17175C17"),b("0x02468E4547470147"),b("0x84DC211A9E9E429E"),b("0x1EC589D4CACA0FCA"),b("0x75995A582D2DB42D"),b("0x9179632EBFBFC6BF"),b("0x381B0E3F07071C07"),b("0x012347ACADAD8EAD"),b("0xEA2FB4B05A5A755A"),b("0x6CB51BEF83833683"),b("0x85FF66B63333CC33"),b("0x3FF2C65C63639163"),b("0x100A041202020802"),b("0x39384993AAAA92AA"),b("0xAFA8E2DE7171D971"),b("0x0ECF8DC6C8C807C8"),b("0xC87D32D119196419"),b("0x7270923B49493949"),b("0x869AAF5FD9D943D9"),b("0xC31DF931F2F2EFF2"),b("0x4B48DBA8E3E3ABE3"),b("0xE22AB6B95B5B715B"),b("0x34920DBC88881A88"),b("0xA4C8293E9A9A529A"),b("0x2DBE4C0B26269826"),b("0x8DFA64BF3232C832"),b("0xE94A7D59B0B0FAB0"),b("0x1B6ACFF2E9E983E9"),b("0x78331E770F0F3C0F"),b("0xE6A6B733D5D573D5"),b("0x74BA1DF480803A80"),b("0x997C6127BEBEC2BE"),b("0x26DE87EBCDCD13CD"),b("0xBDE468893434D034"),b("0x7A75903248483D48"),b("0xAB24E354FFFFDBFF"),b("0xF78FF48D7A7AF57A"),b("0xF4EA3D6490907A90"),b("0xC23EBE9D5F5F615F"),b("0x1DA0403D20208020"),b("0x67D5D00F6868BD68"),b("0xD07234CA1A1A681A"),b("0x192C41B7AEAE82AE"),b("0xC95E757DB4B4EAB4"),b("0x9A19A8CE54544D54"),b("0xECE53B7F93937693"),b("0x0DAA442F22228822"),b("0x07E9C86364648D64"),b("0xDB12FF2AF1F1E3F1"),b("0xBFA2E6CC7373D173"),b("0x905A248212124812"),b("0x3A5D807A40401D40"),b("0x4028104808082008"),b("0x56E89B95C3C32BC3"),b("0x337BC5DFECEC97EC"),b("0x9690AB4DDBDB4BDB"),b("0x611F5FC0A1A1BEA1"),b("0x1C8307918D8D0E8D"),b("0xF5C97AC83D3DF43D"),b("0xCCF1335B97976697"),b("0x0000000000000000"),b("0x36D483F9CFCF1BCF"),b("0x4587566E2B2BAC2B"),b("0x97B3ECE17676C576"),b("0x64B019E682823282"),b("0xFEA9B128D6D67FD6"),b("0xD87736C31B1B6C1B"),b("0xC15B7774B5B5EEB5"),b("0x112943BEAFAF86AF"),b("0x77DFD41D6A6AB56A"),b("0xBA0DA0EA50505D50"),b("0x124C8A5745450945"),b("0xCB18FB38F3F3EBF3"),b("0x9DF060AD3030C030"),b("0x2B74C3C4EFEF9BEF"),b("0xE5C37EDA3F3FFC3F"),b("0x921CAAC755554955"),b("0x791059DBA2A2B2A2"),b("0x0365C9E9EAEA8FEA"),b("0x0FECCA6A65658965"),b("0xB9686903BABAD2BA"),b("0x65935E4A2F2FBC2F"),b("0x4EE79D8EC0C027C0"),b("0xBE81A160DEDE5FDE"),b("0xE06C38FC1C1C701C"),b("0xBB2EE746FDFDD3FD"),b("0x52649A1F4D4D294D"),b("0xE4E0397692927292"),b("0x8FBCEAFA7575C975"),b("0x301E0C3606061806"),b("0x249809AE8A8A128A"),b("0xF940794BB2B2F2B2"),b("0x6359D185E6E6BFE6"),b("0x70361C7E0E0E380E"),b("0xF8633EE71F1F7C1F"),b("0x37F7C45562629562"),b("0xEEA3B53AD4D477D4"),b("0x29324D81A8A89AA8"),b("0xC4F4315296966296"),b("0x9B3AEF62F9F9C3F9"),b("0x66F697A3C5C533C5"),b("0x35B14A1025259425"),b("0xF220B2AB59597959"),b("0x54AE15D084842A84"),b("0xB7A7E4C57272D572"),b("0xD5DD72EC3939E439"),b("0x5A6198164C4C2D4C"),b("0xCA3BBC945E5E655E"),b("0xE785F09F7878FD78"),b("0xDDD870E53838E038"),b("0x148605988C8C0A8C"),b("0xC6B2BF17D1D163D1"),b("0x410B57E4A5A5AEA5"),b("0x434DD9A1E2E2AFE2"),b("0x2FF8C24E61619961"),b("0xF1457B42B3B3F6B3"),b("0x15A5423421218421"),b("0x94D625089C9C4A9C"),b("0xF0663CEE1E1E781E"),b("0x2252866143431143"),b("0x76FC93B1C7C73BC7"),b("0xB32BE54FFCFCD7FC"),b("0x2014082404041004"),b("0xB208A2E351515951"),b("0xBCC72F2599995E99"),b("0x4FC4DA226D6DA96D"),b("0x68391A650D0D340D"),b("0x8335E979FAFACFFA"),b("0xB684A369DFDF5BDF"),b("0xD79BFCA97E7EE57E"),b("0x3DB4481924249024"),b("0xC5D776FE3B3BEC3B"),b("0x313D4B9AABAB96AB"),b("0x3ED181F0CECE1FCE"),b("0x8855229911114411"),b("0x0C8903838F8F068F"),b("0x4A6B9C044E4E254E"),b("0xD1517366B7B7E6B7"),b("0x0B60CBE0EBEB8BEB"),b("0xFDCC78C13C3CF03C"),b("0x7CBF1FFD81813E81"),b("0xD4FE354094946A94"),b("0xEB0CF31CF7F7FBF7"),b("0xA1676F18B9B9DEB9"),b("0x985F268B13134C13"),b("0x7D9C58512C2CB02C"),b("0xD6B8BB05D3D36BD3"),b("0x6B5CD38CE7E7BBE7"),b("0x57CBDC396E6EA56E"),b("0x6EF395AAC4C437C4"),b("0x180F061B03030C03"),b("0x8A13ACDC56564556"),b("0x1A49885E44440D44"),b("0xDF9EFEA07F7FE17F"),b("0x21374F88A9A99EA9"),b("0x4D8254672A2AA82A"),b("0xB16D6B0ABBBBD6BB"),b("0x46E29F87C1C123C1"),b("0xA202A6F153535153"),b("0xAE8BA572DCDC57DC"),b("0x582716530B0B2C0B"),b("0x9CD327019D9D4E9D"),b("0x47C1D82B6C6CAD6C"),b("0x95F562A43131C431"),b("0x87B9E8F37474CD74"),b("0xE309F115F6F6FFF6"),b("0x0A438C4C46460546"),b("0x092645A5ACAC8AAC"),b("0x3C970FB589891E89"),b("0xA04428B414145014"),b("0x5B42DFBAE1E1A3E1"),b("0xB04E2CA616165816"),b("0xCDD274F73A3AE83A"),b("0x6FD0D2066969B969"),b("0x482D124109092409"),b("0xA7ADE0D77070DD70"),b("0xD954716FB6B6E2B6"),b("0xCEB7BD1ED0D067D0"),b("0x3B7EC7D6EDED93ED"),b("0x2EDB85E2CCCC17CC"),b("0x2A57846842421542"),b("0xB4C22D2C98985A98"),b("0x490E55EDA4A4AAA4"),b("0x5D8850752828A028"),b("0xDA31B8865C5C6D5C"),b("0x933FED6BF8F8C7F8"),b("0x44A411C286862286")}local l={b("0x18C07830D8181860"),b("0x2305AF462623238C"),b("0xC67EF991B8C6C63F"),b("0xE8136FCDFBE8E887"),b("0x874CA113CB878726"),b("0xB8A9626D11B8B8DA"),b("0x0108050209010104"),b("0x4F426E9E0D4F4F21"),b("0x36ADEE6C9B3636D8"),b("0xA6590451FFA6A6A2"),b("0xD2DEBDB90CD2D26F"),b("0xF5FB06F70EF5F5F3"),b("0x79EF80F2967979F9"),b("0x6F5FCEDE306F6FA1"),b("0x91FCEF3F6D91917E"),b("0x52AA07A4F8525255"),b("0x6027FDC04760609D"),b("0xBC89766535BCBCCA"),b("0x9BACCD2B379B9B56"),b("0x8E048C018A8E8E02"),b("0xA371155BD2A3A3B6"),b("0x0C603C186C0C0C30"),b("0x7BFF8AF6847B7BF1"),b("0x35B5E16A803535D4"),b("0x1DE8693AF51D1D74"),b("0xE05347DDB3E0E0A7"),b("0xD7F6ACB321D7D77B"),b("0xC25EED999CC2C22F"),b("0x2E6D965C432E2EB8"),b("0x4B627A96294B4B31"),b("0xFEA321E15DFEFEDF"),b("0x578216AED5575741"),b("0x15A8412ABD151554"),b("0x779FB6EEE87777C1"),b("0x37A5EB6E923737DC"),b("0xE57B56D79EE5E5B3"),b("0x9F8CD923139F9F46"),b("0xF0D317FD23F0F0E7"),b("0x4A6A7F94204A4A35"),b("0xDA9E95A944DADA4F"),b("0x58FA25B0A258587D"),b("0xC906CA8FCFC9C903"),b("0x29558D527C2929A4"),b("0x0A5022145A0A0A28"),b("0xB1E14F7F50B1B1FE"),b("0xA0691A5DC9A0A0BA"),b("0x6B7FDAD6146B6BB1"),b("0x855CAB17D985852E"),b("0xBD8173673CBDBDCE"),b("0x5DD234BA8F5D5D69"),b("0x1080502090101040"),b("0xF4F303F507F4F4F7"),b("0xCB16C08BDDCBCB0B"),b("0x3EEDC67CD33E3EF8"),b("0x0528110A2D050514"),b("0x671FE6CE78676781"),b("0xE47353D597E4E4B7"),b("0x2725BB4E0227279C"),b("0x4132588273414119"),b("0x8B2C9D0BA78B8B16"),b("0xA7510153F6A7A7A6"),b("0x7DCF94FAB27D7DE9"),b("0x95DCFB374995956E"),b("0xD88E9FAD56D8D847"),b("0xFB8B30EB70FBFBCB"),b("0xEE2371C1CDEEEE9F"),b("0x7CC791F8BB7C7CED"),b("0x6617E3CC71666685"),b("0xDDA68EA77BDDDD53"),b("0x17B84B2EAF17175C"),b("0x4702468E45474701"),b("0x9E84DC211A9E9E42"),b("0xCA1EC589D4CACA0F"),b("0x2D75995A582D2DB4"),b("0xBF9179632EBFBFC6"),b("0x07381B0E3F07071C"),b("0xAD012347ACADAD8E"),b("0x5AEA2FB4B05A5A75"),b("0x836CB51BEF838336"),b("0x3385FF66B63333CC"),b("0x633FF2C65C636391"),b("0x02100A0412020208"),b("0xAA39384993AAAA92"),b("0x71AFA8E2DE7171D9"),b("0xC80ECF8DC6C8C807"),b("0x19C87D32D1191964"),b("0x497270923B494939"),b("0xD9869AAF5FD9D943"),b("0xF2C31DF931F2F2EF"),b("0xE34B48DBA8E3E3AB"),b("0x5BE22AB6B95B5B71"),b("0x8834920DBC88881A"),b("0x9AA4C8293E9A9A52"),b("0x262DBE4C0B262698"),b("0x328DFA64BF3232C8"),b("0xB0E94A7D59B0B0FA"),b("0xE91B6ACFF2E9E983"),b("0x0F78331E770F0F3C"),b("0xD5E6A6B733D5D573"),b("0x8074BA1DF480803A"),b("0xBE997C6127BEBEC2"),b("0xCD26DE87EBCDCD13"),b("0x34BDE468893434D0"),b("0x487A75903248483D"),b("0xFFAB24E354FFFFDB"),b("0x7AF78FF48D7A7AF5"),b("0x90F4EA3D6490907A"),b("0x5FC23EBE9D5F5F61"),b("0x201DA0403D202080"),b("0x6867D5D00F6868BD"),b("0x1AD07234CA1A1A68"),b("0xAE192C41B7AEAE82"),b("0xB4C95E757DB4B4EA"),b("0x549A19A8CE54544D"),b("0x93ECE53B7F939376"),b("0x220DAA442F222288"),b("0x6407E9C86364648D"),b("0xF1DB12FF2AF1F1E3"),b("0x73BFA2E6CC7373D1"),b("0x12905A2482121248"),b("0x403A5D807A40401D"),b("0x0840281048080820"),b("0xC356E89B95C3C32B"),b("0xEC337BC5DFECEC97"),b("0xDB9690AB4DDBDB4B"),b("0xA1611F5FC0A1A1BE"),b("0x8D1C8307918D8D0E"),b("0x3DF5C97AC83D3DF4"),b("0x97CCF1335B979766"),b("0x0000000000000000"),b("0xCF36D483F9CFCF1B"),b("0x2B4587566E2B2BAC"),b("0x7697B3ECE17676C5"),b("0x8264B019E6828232"),b("0xD6FEA9B128D6D67F"),b("0x1BD87736C31B1B6C"),b("0xB5C15B7774B5B5EE"),b("0xAF112943BEAFAF86"),b("0x6A77DFD41D6A6AB5"),b("0x50BA0DA0EA50505D"),b("0x45124C8A57454509"),b("0xF3CB18FB38F3F3EB"),b("0x309DF060AD3030C0"),b("0xEF2B74C3C4EFEF9B"),b("0x3FE5C37EDA3F3FFC"),b("0x55921CAAC7555549"),b("0xA2791059DBA2A2B2"),b("0xEA0365C9E9EAEA8F"),b("0x650FECCA6A656589"),b("0xBAB9686903BABAD2"),b("0x2F65935E4A2F2FBC"),b("0xC04EE79D8EC0C027"),b("0xDEBE81A160DEDE5F"),b("0x1CE06C38FC1C1C70"),b("0xFDBB2EE746FDFDD3"),b("0x4D52649A1F4D4D29"),b("0x92E4E03976929272"),b("0x758FBCEAFA7575C9"),b("0x06301E0C36060618"),b("0x8A249809AE8A8A12"),b("0xB2F940794BB2B2F2"),b("0xE66359D185E6E6BF"),b("0x0E70361C7E0E0E38"),b("0x1FF8633EE71F1F7C"),b("0x6237F7C455626295"),b("0xD4EEA3B53AD4D477"),b("0xA829324D81A8A89A"),b("0x96C4F43152969662"),b("0xF99B3AEF62F9F9C3"),b("0xC566F697A3C5C533"),b("0x2535B14A10252594"),b("0x59F220B2AB595979"),b("0x8454AE15D084842A"),b("0x72B7A7E4C57272D5"),b("0x39D5DD72EC3939E4"),b("0x4C5A6198164C4C2D"),b("0x5ECA3BBC945E5E65"),b("0x78E785F09F7878FD"),b("0x38DDD870E53838E0"),b("0x8C148605988C8C0A"),b("0xD1C6B2BF17D1D163"),b("0xA5410B57E4A5A5AE"),b("0xE2434DD9A1E2E2AF"),b("0x612FF8C24E616199"),b("0xB3F1457B42B3B3F6"),b("0x2115A54234212184"),b("0x9C94D625089C9C4A"),b("0x1EF0663CEE1E1E78"),b("0x4322528661434311"),b("0xC776FC93B1C7C73B"),b("0xFCB32BE54FFCFCD7"),b("0x0420140824040410"),b("0x51B208A2E3515159"),b("0x99BCC72F2599995E"),b("0x6D4FC4DA226D6DA9"),b("0x0D68391A650D0D34"),b("0xFA8335E979FAFACF"),b("0xDFB684A369DFDF5B"),b("0x7ED79BFCA97E7EE5"),b("0x243DB44819242490"),b("0x3BC5D776FE3B3BEC"),b("0xAB313D4B9AABAB96"),b("0xCE3ED181F0CECE1F"),b("0x1188552299111144"),b("0x8F0C8903838F8F06"),b("0x4E4A6B9C044E4E25"),b("0xB7D1517366B7B7E6"),b("0xEB0B60CBE0EBEB8B"),b("0x3CFDCC78C13C3CF0"),b("0x817CBF1FFD81813E"),b("0x94D4FE354094946A"),b("0xF7EB0CF31CF7F7FB"),b("0xB9A1676F18B9B9DE"),b("0x13985F268B13134C"),b("0x2C7D9C58512C2CB0"),b("0xD3D6B8BB05D3D36B"),b("0xE76B5CD38CE7E7BB"),b("0x6E57CBDC396E6EA5"),b("0xC46EF395AAC4C437"),b("0x03180F061B03030C"),b("0x568A13ACDC565645"),b("0x441A49885E44440D"),b("0x7FDF9EFEA07F7FE1"),b("0xA921374F88A9A99E"),b("0x2A4D8254672A2AA8"),b("0xBBB16D6B0ABBBBD6"),b("0xC146E29F87C1C123"),b("0x53A202A6F1535351"),b("0xDCAE8BA572DCDC57"),b("0x0B582716530B0B2C"),b("0x9D9CD327019D9D4E"),b("0x6C47C1D82B6C6CAD"),b("0x3195F562A43131C4"),b("0x7487B9E8F37474CD"),b("0xF6E309F115F6F6FF"),b("0x460A438C4C464605"),b("0xAC092645A5ACAC8A"),b("0x893C970FB589891E"),b("0x14A04428B4141450"),b("0xE15B42DFBAE1E1A3"),b("0x16B04E2CA6161658"),b("0x3ACDD274F73A3AE8"),b("0x696FD0D2066969B9"),b("0x09482D1241090924"),b("0x70A7ADE0D77070DD"),b("0xB6D954716FB6B6E2"),b("0xD0CEB7BD1ED0D067"),b("0xED3B7EC7D6EDED93"),b("0xCC2EDB85E2CCCC17"),b("0x422A578468424215"),b("0x98B4C22D2C98985A"),b("0xA4490E55EDA4A4AA"),b("0x285D8850752828A0"),b("0x5CDA31B8865C5C6D"),b("0xF8933FED6BF8F8C7"),b("0x8644A411C2868622")}local m={b("0x6018C07830D81818"),b("0x8C2305AF46262323"),b("0x3FC67EF991B8C6C6"),b("0x87E8136FCDFBE8E8"),b("0x26874CA113CB8787"),b("0xDAB8A9626D11B8B8"),b("0x0401080502090101"),b("0x214F426E9E0D4F4F"),b("0xD836ADEE6C9B3636"),b("0xA2A6590451FFA6A6"),b("0x6FD2DEBDB90CD2D2"),b("0xF3F5FB06F70EF5F5"),b("0xF979EF80F2967979"),b("0xA16F5FCEDE306F6F"),b("0x7E91FCEF3F6D9191"),b("0x5552AA07A4F85252"),b("0x9D6027FDC0476060"),b("0xCABC89766535BCBC"),b("0x569BACCD2B379B9B"),b("0x028E048C018A8E8E"),b("0xB6A371155BD2A3A3"),b("0x300C603C186C0C0C"),b("0xF17BFF8AF6847B7B"),b("0xD435B5E16A803535"),b("0x741DE8693AF51D1D"),b("0xA7E05347DDB3E0E0"),b("0x7BD7F6ACB321D7D7"),b("0x2FC25EED999CC2C2"),b("0xB82E6D965C432E2E"),b("0x314B627A96294B4B"),b("0xDFFEA321E15DFEFE"),b("0x41578216AED55757"),b("0x5415A8412ABD1515"),b("0xC1779FB6EEE87777"),b("0xDC37A5EB6E923737"),b("0xB3E57B56D79EE5E5"),b("0x469F8CD923139F9F"),b("0xE7F0D317FD23F0F0"),b("0x354A6A7F94204A4A"),b("0x4FDA9E95A944DADA"),b("0x7D58FA25B0A25858"),b("0x03C906CA8FCFC9C9"),b("0xA429558D527C2929"),b("0x280A5022145A0A0A"),b("0xFEB1E14F7F50B1B1"),b("0xBAA0691A5DC9A0A0"),b("0xB16B7FDAD6146B6B"),b("0x2E855CAB17D98585"),b("0xCEBD8173673CBDBD"),b("0x695DD234BA8F5D5D"),b("0x4010805020901010"),b("0xF7F4F303F507F4F4"),b("0x0BCB16C08BDDCBCB"),b("0xF83EEDC67CD33E3E"),b("0x140528110A2D0505"),b("0x81671FE6CE786767"),b("0xB7E47353D597E4E4"),b("0x9C2725BB4E022727"),b("0x1941325882734141"),b("0x168B2C9D0BA78B8B"),b("0xA6A7510153F6A7A7"),b("0xE97DCF94FAB27D7D"),b("0x6E95DCFB37499595"),b("0x47D88E9FAD56D8D8"),b("0xCBFB8B30EB70FBFB"),b("0x9FEE2371C1CDEEEE"),b("0xED7CC791F8BB7C7C"),b("0x856617E3CC716666"),b("0x53DDA68EA77BDDDD"),b("0x5C17B84B2EAF1717"),b("0x014702468E454747"),b("0x429E84DC211A9E9E"),b("0x0FCA1EC589D4CACA"),b("0xB42D75995A582D2D"),b("0xC6BF9179632EBFBF"),b("0x1C07381B0E3F0707"),b("0x8EAD012347ACADAD"),b("0x755AEA2FB4B05A5A"),b("0x36836CB51BEF8383"),b("0xCC3385FF66B63333"),b("0x91633FF2C65C6363"),b("0x0802100A04120202"),b("0x92AA39384993AAAA"),b("0xD971AFA8E2DE7171"),b("0x07C80ECF8DC6C8C8"),b("0x6419C87D32D11919"),b("0x39497270923B4949"),b("0x43D9869AAF5FD9D9"),b("0xEFF2C31DF931F2F2"),b("0xABE34B48DBA8E3E3"),b("0x715BE22AB6B95B5B"),b("0x1A8834920DBC8888"),b("0x529AA4C8293E9A9A"),b("0x98262DBE4C0B2626"),b("0xC8328DFA64BF3232"),b("0xFAB0E94A7D59B0B0"),b("0x83E91B6ACFF2E9E9"),b("0x3C0F78331E770F0F"),b("0x73D5E6A6B733D5D5"),b("0x3A8074BA1DF48080"),b("0xC2BE997C6127BEBE"),b("0x13CD26DE87EBCDCD"),b("0xD034BDE468893434"),b("0x3D487A7590324848"),b("0xDBFFAB24E354FFFF"),b("0xF57AF78FF48D7A7A"),b("0x7A90F4EA3D649090"),b("0x615FC23EBE9D5F5F"),b("0x80201DA0403D2020"),b("0xBD6867D5D00F6868"),b("0x681AD07234CA1A1A"),b("0x82AE192C41B7AEAE"),b("0xEAB4C95E757DB4B4"),b("0x4D549A19A8CE5454"),b("0x7693ECE53B7F9393"),b("0x88220DAA442F2222"),b("0x8D6407E9C8636464"),b("0xE3F1DB12FF2AF1F1"),b("0xD173BFA2E6CC7373"),b("0x4812905A24821212"),b("0x1D403A5D807A4040"),b("0x2008402810480808"),b("0x2BC356E89B95C3C3"),b("0x97EC337BC5DFECEC"),b("0x4BDB9690AB4DDBDB"),b("0xBEA1611F5FC0A1A1"),b("0x0E8D1C8307918D8D"),b("0xF43DF5C97AC83D3D"),b("0x6697CCF1335B9797"),b("0x0000000000000000"),b("0x1BCF36D483F9CFCF"),b("0xAC2B4587566E2B2B"),b("0xC57697B3ECE17676"),b("0x328264B019E68282"),b("0x7FD6FEA9B128D6D6"),b("0x6C1BD87736C31B1B"),b("0xEEB5C15B7774B5B5"),b("0x86AF112943BEAFAF"),b("0xB56A77DFD41D6A6A"),b("0x5D50BA0DA0EA5050"),b("0x0945124C8A574545"),b("0xEBF3CB18FB38F3F3"),b("0xC0309DF060AD3030"),b("0x9BEF2B74C3C4EFEF"),b("0xFC3FE5C37EDA3F3F"),b("0x4955921CAAC75555"),b("0xB2A2791059DBA2A2"),b("0x8FEA0365C9E9EAEA"),b("0x89650FECCA6A6565"),b("0xD2BAB9686903BABA"),b("0xBC2F65935E4A2F2F"),b("0x27C04EE79D8EC0C0"),b("0x5FDEBE81A160DEDE"),b("0x701CE06C38FC1C1C"),b("0xD3FDBB2EE746FDFD"),b("0x294D52649A1F4D4D"),b("0x7292E4E039769292"),b("0xC9758FBCEAFA7575"),b("0x1806301E0C360606"),b("0x128A249809AE8A8A"),b("0xF2B2F940794BB2B2"),b("0xBFE66359D185E6E6"),b("0x380E70361C7E0E0E"),b("0x7C1FF8633EE71F1F"),b("0x956237F7C4556262"),b("0x77D4EEA3B53AD4D4"),b("0x9AA829324D81A8A8"),b("0x6296C4F431529696"),b("0xC3F99B3AEF62F9F9"),b("0x33C566F697A3C5C5"),b("0x942535B14A102525"),b("0x7959F220B2AB5959"),b("0x2A8454AE15D08484"),b("0xD572B7A7E4C57272"),b("0xE439D5DD72EC3939"),b("0x2D4C5A6198164C4C"),b("0x655ECA3BBC945E5E"),b("0xFD78E785F09F7878"),b("0xE038DDD870E53838"),b("0x0A8C148605988C8C"),b("0x63D1C6B2BF17D1D1"),b("0xAEA5410B57E4A5A5"),b("0xAFE2434DD9A1E2E2"),b("0x99612FF8C24E6161"),b("0xF6B3F1457B42B3B3"),b("0x842115A542342121"),b("0x4A9C94D625089C9C"),b("0x781EF0663CEE1E1E"),b("0x1143225286614343"),b("0x3BC776FC93B1C7C7"),b("0xD7FCB32BE54FFCFC"),b("0x1004201408240404"),b("0x5951B208A2E35151"),b("0x5E99BCC72F259999"),b("0xA96D4FC4DA226D6D"),b("0x340D68391A650D0D"),b("0xCFFA8335E979FAFA"),b("0x5BDFB684A369DFDF"),b("0xE57ED79BFCA97E7E"),b("0x90243DB448192424"),b("0xEC3BC5D776FE3B3B"),b("0x96AB313D4B9AABAB"),b("0x1FCE3ED181F0CECE"),b("0x4411885522991111"),b("0x068F0C8903838F8F"),b("0x254E4A6B9C044E4E"),b("0xE6B7D1517366B7B7"),b("0x8BEB0B60CBE0EBEB"),b("0xF03CFDCC78C13C3C"),b("0x3E817CBF1FFD8181"),b("0x6A94D4FE35409494"),b("0xFBF7EB0CF31CF7F7"),b("0xDEB9A1676F18B9B9"),b("0x4C13985F268B1313"),b("0xB02C7D9C58512C2C"),b("0x6BD3D6B8BB05D3D3"),b("0xBBE76B5CD38CE7E7"),b("0xA56E57CBDC396E6E"),b("0x37C46EF395AAC4C4"),b("0x0C03180F061B0303"),b("0x45568A13ACDC5656"),b("0x0D441A49885E4444"),b("0xE17FDF9EFEA07F7F"),b("0x9EA921374F88A9A9"),b("0xA82A4D8254672A2A"),b("0xD6BBB16D6B0ABBBB"),b("0x23C146E29F87C1C1"),b("0x5153A202A6F15353"),b("0x57DCAE8BA572DCDC"),b("0x2C0B582716530B0B"),b("0x4E9D9CD327019D9D"),b("0xAD6C47C1D82B6C6C"),b("0xC43195F562A43131"),b("0xCD7487B9E8F37474"),b("0xFFF6E309F115F6F6"),b("0x05460A438C4C4646"),b("0x8AAC092645A5ACAC"),b("0x1E893C970FB58989"),b("0x5014A04428B41414"),b("0xA3E15B42DFBAE1E1"),b("0x5816B04E2CA61616"),b("0xE83ACDD274F73A3A"),b("0xB9696FD0D2066969"),b("0x2409482D12410909"),b("0xDD70A7ADE0D77070"),b("0xE2B6D954716FB6B6"),b("0x67D0CEB7BD1ED0D0"),b("0x93ED3B7EC7D6EDED"),b("0x17CC2EDB85E2CCCC"),b("0x15422A5784684242"),b("0x5A98B4C22D2C9898"),b("0xAAA4490E55EDA4A4"),b("0xA0285D8850752828"),b("0x6D5CDA31B8865C5C"),b("0xC7F8933FED6BF8F8"),b("0x228644A411C28686")}local n={b("0x186018C07830D818"),b("0x238C2305AF462623"),b("0xC63FC67EF991B8C6"),b("0xE887E8136FCDFBE8"),b("0x8726874CA113CB87"),b("0xB8DAB8A9626D11B8"),b("0x0104010805020901"),b("0x4F214F426E9E0D4F"),b("0x36D836ADEE6C9B36"),b("0xA6A2A6590451FFA6"),b("0xD26FD2DEBDB90CD2"),b("0xF5F3F5FB06F70EF5"),b("0x79F979EF80F29679"),b("0x6FA16F5FCEDE306F"),b("0x917E91FCEF3F6D91"),b("0x525552AA07A4F852"),b("0x609D6027FDC04760"),b("0xBCCABC89766535BC"),b("0x9B569BACCD2B379B"),b("0x8E028E048C018A8E"),b("0xA3B6A371155BD2A3"),b("0x0C300C603C186C0C"),b("0x7BF17BFF8AF6847B"),b("0x35D435B5E16A8035"),b("0x1D741DE8693AF51D"),b("0xE0A7E05347DDB3E0"),b("0xD77BD7F6ACB321D7"),b("0xC22FC25EED999CC2"),b("0x2EB82E6D965C432E"),b("0x4B314B627A96294B"),b("0xFEDFFEA321E15DFE"),b("0x5741578216AED557"),b("0x155415A8412ABD15"),b("0x77C1779FB6EEE877"),b("0x37DC37A5EB6E9237"),b("0xE5B3E57B56D79EE5"),b("0x9F469F8CD923139F"),b("0xF0E7F0D317FD23F0"),b("0x4A354A6A7F94204A"),b("0xDA4FDA9E95A944DA"),b("0x587D58FA25B0A258"),b("0xC903C906CA8FCFC9"),b("0x29A429558D527C29"),b("0x0A280A5022145A0A"),b("0xB1FEB1E14F7F50B1"),b("0xA0BAA0691A5DC9A0"),b("0x6BB16B7FDAD6146B"),b("0x852E855CAB17D985"),b("0xBDCEBD8173673CBD"),b("0x5D695DD234BA8F5D"),b("0x1040108050209010"),b("0xF4F7F4F303F507F4"),b("0xCB0BCB16C08BDDCB"),b("0x3EF83EEDC67CD33E"),b("0x05140528110A2D05"),b("0x6781671FE6CE7867"),b("0xE4B7E47353D597E4"),b("0x279C2725BB4E0227"),b("0x4119413258827341"),b("0x8B168B2C9D0BA78B"),b("0xA7A6A7510153F6A7"),b("0x7DE97DCF94FAB27D"),b("0x956E95DCFB374995"),b("0xD847D88E9FAD56D8"),b("0xFBCBFB8B30EB70FB"),b("0xEE9FEE2371C1CDEE"),b("0x7CED7CC791F8BB7C"),b("0x66856617E3CC7166"),b("0xDD53DDA68EA77BDD"),b("0x175C17B84B2EAF17"),b("0x47014702468E4547"),b("0x9E429E84DC211A9E"),b("0xCA0FCA1EC589D4CA"),b("0x2DB42D75995A582D"),b("0xBFC6BF9179632EBF"),b("0x071C07381B0E3F07"),b("0xAD8EAD012347ACAD"),b("0x5A755AEA2FB4B05A"),b("0x8336836CB51BEF83"),b("0x33CC3385FF66B633"),b("0x6391633FF2C65C63"),b("0x020802100A041202"),b("0xAA92AA39384993AA"),b("0x71D971AFA8E2DE71"),b("0xC807C80ECF8DC6C8"),b("0x196419C87D32D119"),b("0x4939497270923B49"),b("0xD943D9869AAF5FD9"),b("0xF2EFF2C31DF931F2"),b("0xE3ABE34B48DBA8E3"),b("0x5B715BE22AB6B95B"),b("0x881A8834920DBC88"),b("0x9A529AA4C8293E9A"),b("0x2698262DBE4C0B26"),b("0x32C8328DFA64BF32"),b("0xB0FAB0E94A7D59B0"),b("0xE983E91B6ACFF2E9"),b("0x0F3C0F78331E770F"),b("0xD573D5E6A6B733D5"),b("0x803A8074BA1DF480"),b("0xBEC2BE997C6127BE"),b("0xCD13CD26DE87EBCD"),b("0x34D034BDE4688934"),b("0x483D487A75903248"),b("0xFFDBFFAB24E354FF"),b("0x7AF57AF78FF48D7A"),b("0x907A90F4EA3D6490"),b("0x5F615FC23EBE9D5F"),b("0x2080201DA0403D20"),b("0x68BD6867D5D00F68"),b("0x1A681AD07234CA1A"),b("0xAE82AE192C41B7AE"),b("0xB4EAB4C95E757DB4"),b("0x544D549A19A8CE54"),b("0x937693ECE53B7F93"),b("0x2288220DAA442F22"),b("0x648D6407E9C86364"),b("0xF1E3F1DB12FF2AF1"),b("0x73D173BFA2E6CC73"),b("0x124812905A248212"),b("0x401D403A5D807A40"),b("0x0820084028104808"),b("0xC32BC356E89B95C3"),b("0xEC97EC337BC5DFEC"),b("0xDB4BDB9690AB4DDB"),b("0xA1BEA1611F5FC0A1"),b("0x8D0E8D1C8307918D"),b("0x3DF43DF5C97AC83D"),b("0x976697CCF1335B97"),b("0x0000000000000000"),b("0xCF1BCF36D483F9CF"),b("0x2BAC2B4587566E2B"),b("0x76C57697B3ECE176"),b("0x82328264B019E682"),b("0xD67FD6FEA9B128D6"),b("0x1B6C1BD87736C31B"),b("0xB5EEB5C15B7774B5"),b("0xAF86AF112943BEAF"),b("0x6AB56A77DFD41D6A"),b("0x505D50BA0DA0EA50"),b("0x450945124C8A5745"),b("0xF3EBF3CB18FB38F3"),b("0x30C0309DF060AD30"),b("0xEF9BEF2B74C3C4EF"),b("0x3FFC3FE5C37EDA3F"),b("0x554955921CAAC755"),b("0xA2B2A2791059DBA2"),b("0xEA8FEA0365C9E9EA"),b("0x6589650FECCA6A65"),b("0xBAD2BAB9686903BA"),b("0x2FBC2F65935E4A2F"),b("0xC027C04EE79D8EC0"),b("0xDE5FDEBE81A160DE"),b("0x1C701CE06C38FC1C"),b("0xFDD3FDBB2EE746FD"),b("0x4D294D52649A1F4D"),b("0x927292E4E0397692"),b("0x75C9758FBCEAFA75"),b("0x061806301E0C3606"),b("0x8A128A249809AE8A"),b("0xB2F2B2F940794BB2"),b("0xE6BFE66359D185E6"),b("0x0E380E70361C7E0E"),b("0x1F7C1FF8633EE71F"),b("0x62956237F7C45562"),b("0xD477D4EEA3B53AD4"),b("0xA89AA829324D81A8"),b("0x966296C4F4315296"),b("0xF9C3F99B3AEF62F9"),b("0xC533C566F697A3C5"),b("0x25942535B14A1025"),b("0x597959F220B2AB59"),b("0x842A8454AE15D084"),b("0x72D572B7A7E4C572"),b("0x39E439D5DD72EC39"),b("0x4C2D4C5A6198164C"),b("0x5E655ECA3BBC945E"),b("0x78FD78E785F09F78"),b("0x38E038DDD870E538"),b("0x8C0A8C148605988C"),b("0xD163D1C6B2BF17D1"),b("0xA5AEA5410B57E4A5"),b("0xE2AFE2434DD9A1E2"),b("0x6199612FF8C24E61"),b("0xB3F6B3F1457B42B3"),b("0x21842115A5423421"),b("0x9C4A9C94D625089C"),b("0x1E781EF0663CEE1E"),b("0x4311432252866143"),b("0xC73BC776FC93B1C7"),b("0xFCD7FCB32BE54FFC"),b("0x0410042014082404"),b("0x515951B208A2E351"),b("0x995E99BCC72F2599"),b("0x6DA96D4FC4DA226D"),b("0x0D340D68391A650D"),b("0xFACFFA8335E979FA"),b("0xDF5BDFB684A369DF"),b("0x7EE57ED79BFCA97E"),b("0x2490243DB4481924"),b("0x3BEC3BC5D776FE3B"),b("0xAB96AB313D4B9AAB"),b("0xCE1FCE3ED181F0CE"),b("0x1144118855229911"),b("0x8F068F0C8903838F"),b("0x4E254E4A6B9C044E"),b("0xB7E6B7D1517366B7"),b("0xEB8BEB0B60CBE0EB"),b("0x3CF03CFDCC78C13C"),b("0x813E817CBF1FFD81"),b("0x946A94D4FE354094"),b("0xF7FBF7EB0CF31CF7"),b("0xB9DEB9A1676F18B9"),b("0x134C13985F268B13"),b("0x2CB02C7D9C58512C"),b("0xD36BD3D6B8BB05D3"),b("0xE7BBE76B5CD38CE7"),b("0x6EA56E57CBDC396E"),b("0xC437C46EF395AAC4"),b("0x030C03180F061B03"),b("0x5645568A13ACDC56"),b("0x440D441A49885E44"),b("0x7FE17FDF9EFEA07F"),b("0xA99EA921374F88A9"),b("0x2AA82A4D8254672A"),b("0xBBD6BBB16D6B0ABB"),b("0xC123C146E29F87C1"),b("0x535153A202A6F153"),b("0xDC57DCAE8BA572DC"),b("0x0B2C0B582716530B"),b("0x9D4E9D9CD327019D"),b("0x6CAD6C47C1D82B6C"),b("0x31C43195F562A431"),b("0x74CD7487B9E8F374"),b("0xF6FFF6E309F115F6"),b("0x4605460A438C4C46"),b("0xAC8AAC092645A5AC"),b("0x891E893C970FB589"),b("0x145014A04428B414"),b("0xE1A3E15B42DFBAE1"),b("0x165816B04E2CA616"),b("0x3AE83ACDD274F73A"),b("0x69B9696FD0D20669"),b("0x092409482D124109"),b("0x70DD70A7ADE0D770"),b("0xB6E2B6D954716FB6"),b("0xD067D0CEB7BD1ED0"),b("0xED93ED3B7EC7D6ED"),b("0xCC17CC2EDB85E2CC"),b("0x4215422A57846842"),b("0x985A98B4C22D2C98"),b("0xA4AAA4490E55EDA4"),b("0x28A0285D88507528"),b("0x5C6D5CDA31B8865C"),b("0xF8C7F8933FED6BF8"),b("0x86228644A411C286")}local o={b("0x0000000000000000"),b("0x1823C6E887B8014F"),b("0x36A6D2F5796F9152"),b("0x60BC9B8EA30C7B35"),b("0x1DE0D7C22E4BFE57"),b("0x157737E59FF04ADA"),b("0x58C9290AB1A06B85"),b("0xBD5D10F4CB3E0567"),b("0xE427418BA77D95D8"),b("0xFBEE7C66DD17479E"),b("0xCA2DBF07AD5A8333")}local function p(q)local r={}local s;local t;for u=1,e.block_size,8 do s=u//8+1;t=u//8*8+1;r[s]=b(a.byte(q._data,t))<<56~(b(a.byte(q._data,t+1))<<48)~(b(a.byte(q._data,t+2))<<40)~(b(a.byte(q._data,t+3))<<32)~(b(a.byte(q._data,t+4))<<24)~(b(a.byte(q._data,t+5))<<16)~(b(a.byte(q._data,t+6))<<8)~b(a.byte(q._data,t+7))end;q._data=q._data:sub(e.block_size+1)return r end;function e:new(v)if self~=e then return nil,"First argument must be self"end;local w=setmetatable({},f)w._hash={}for u=1,8 do w._hash[u]=b(0)end;w._len=c(0)w._data=""if v~=nil then w:update(v)end;return w end;setmetatable(e,{__call=e.new})function e:copy()local w=e:new()for u=1,8 do w._hash[u]=self._hash[u]:copy()end;w._data=self._data;w._len=self._len:copy()return w end;function e:update(v)local x={}local y={}local r={}local z={}if v==nil then v=""end;v=tostring(v)self._len=self._len+#v*8;self._data=self._data..v;while#self._data>=e.block_size do r=p(self)x[1]=self._hash[1]:copy()x[2]=self._hash[2]:copy()x[3]=self._hash[3]:copy()x[4]=self._hash[4]:copy()x[5]=self._hash[5]:copy()x[6]=self._hash[6]:copy()x[7]=self._hash[7]:copy()x[8]=self._hash[8]:copy()y[1]=r[1]~x[1]y[2]=r[2]~x[2]y[3]=r[3]~x[3]y[4]=r[4]~x[4]y[5]=r[5]~x[5]y[6]=r[6]~x[6]y[7]=r[7]~x[7]y[8]=r[8]~x[8]for A=2,11 do z[1]=g[(x[1]>>56+1):asnumber()]~h[(x[8]>>48&0xFF+1):asnumber()]~i[(x[7]>>40&0xFF+1):asnumber()]~j[(x[6]>>32&0xFF+1):asnumber()]~k[(x[5]>>24&0xFF+1):asnumber()]~l[(x[4]>>16&0xFF+1):asnumber()]~m[(x[3]>>8&0xFF+1):asnumber()]~n[(x[2]&0xFF+1):asnumber()]~o[A]z[2]=g[(x[2]>>56+1):asnumber()]~h[(x[1]>>48&0xFF+1):asnumber()]~i[(x[8]>>40&0xFF+1):asnumber()]~j[(x[7]>>32&0xFF+1):asnumber()]~k[(x[6]>>24&0xFF+1):asnumber()]~l[(x[5]>>16&0xFF+1):asnumber()]~m[(x[4]>>8&0xFF+1):asnumber()]~n[(x[3]&0xFF+1):asnumber()]z[3]=g[(x[3]>>56+1):asnumber()]~h[(x[2]>>48&0xFF+1):asnumber()]~i[(x[1]>>40&0xFF+1):asnumber()]~j[(x[8]>>32&0xFF+1):asnumber()]~k[(x[7]>>24&0xFF+1):asnumber()]~l[(x[6]>>16&0xFF+1):asnumber()]~m[(x[5]>>8&0xFF+1):asnumber()]~n[(x[4]&0xFF+1):asnumber()]z[4]=g[(x[4]>>56+1):asnumber()]~h[(x[3]>>48&0xFF+1):asnumber()]~i[(x[2]>>40&0xFF+1):asnumber()]~j[(x[1]>>32&0xFF+1):asnumber()]~k[(x[8]>>24&0xFF+1):asnumber()]~l[(x[7]>>16&0xFF+1):asnumber()]~m[(x[6]>>8&0xFF+1):asnumber()]~n[(x[5]&0xFF+1):asnumber()]z[5]=g[(x[5]>>56+1):asnumber()]~h[(x[4]>>48&0xFF+1):asnumber()]~i[(x[3]>>40&0xFF+1):asnumber()]~j[(x[2]>>32&0xFF+1):asnumber()]~k[(x[1]>>24&0xFF+1):asnumber()]~l[(x[8]>>16&0xFF+1):asnumber()]~m[(x[7]>>8&0xFF+1):asnumber()]~n[(x[6]&0xFF+1):asnumber()]z[6]=g[(x[6]>>56+1):asnumber()]~h[(x[5]>>48&0xFF+1):asnumber()]~i[(x[4]>>40&0xFF+1):asnumber()]~j[(x[3]>>32&0xFF+1):asnumber()]~k[(x[2]>>24&0xFF+1):asnumber()]~l[(x[1]>>16&0xFF+1):asnumber()]~m[(x[8]>>8&0xFF+1):asnumber()]~n[(x[7]&0xFF+1):asnumber()]z[7]=g[(x[7]>>56+1):asnumber()]~h[(x[6]>>48&0xFF+1):asnumber()]~i[(x[5]>>40&0xFF+1):asnumber()]~j[(x[4]>>32&0xFF+1):asnumber()]~k[(x[3]>>24&0xFF+1):asnumber()]~l[(x[2]>>16&0xFF+1):asnumber()]~m[(x[1]>>8&0xFF+1):asnumber()]~n[(x[8]&0xFF+1):asnumber()]z[8]=g[(x[8]>>56+1):asnumber()]~h[(x[7]>>48&0xFF+1):asnumber()]~i[(x[6]>>40&0xFF+1):asnumber()]~j[(x[5]>>32&0xFF+1):asnumber()]~k[(x[4]>>24&0xFF+1):asnumber()]~l[(x[3]>>16&0xFF+1):asnumber()]~m[(x[2]>>8&0xFF+1):asnumber()]~n[(x[1]&0xFF+1):asnumber()]x[1]=z[1]:copy()x[2]=z[2]:copy()x[3]=z[3]:copy()x[4]=z[4]:copy()x[5]=z[5]:copy()x[6]=z[6]:copy()x[7]=z[7]:copy()x[8]=z[8]:copy()z[1]=g[(y[1]>>56+1):asnumber()]~h[(y[8]>>48&0xFF+1):asnumber()]~i[(y[7]>>40&0xFF+1):asnumber()]~j[(y[6]>>32&0xFF+1):asnumber()]~k[(y[5]>>24&0xFF+1):asnumber()]~l[(y[4]>>16&0xFF+1):asnumber()]~m[(y[3]>>8&0xFF+1):asnumber()]~n[(y[2]&0xFF+1):asnumber()]~x[1]z[2]=g[(y[2]>>56+1):asnumber()]~h[(y[1]>>48&0xFF+1):asnumber()]~i[(y[8]>>40&0xFF+1):asnumber()]~j[(y[7]>>32&0xFF+1):asnumber()]~k[(y[6]>>24&0xFF+1):asnumber()]~l[(y[5]>>16&0xFF+1):asnumber()]~m[(y[4]>>8&0xFF+1):asnumber()]~n[(y[3]&0xFF+1):asnumber()]~x[2]z[3]=g[(y[3]>>56+1):asnumber()]~h[(y[2]>>48&0xFF+1):asnumber()]~i[(y[1]>>40&0xFF+1):asnumber()]~j[(y[8]>>32&0xFF+1):asnumber()]~k[(y[7]>>24&0xFF+1):asnumber()]~l[(y[6]>>16&0xFF+1):asnumber()]~m[(y[5]>>8&0xFF+1):asnumber()]~n[(y[4]&0xFF+1):asnumber()]~x[3]z[4]=g[(y[4]>>56+1):asnumber()]~h[(y[3]>>48&0xFF+1):asnumber()]~i[(y[2]>>40&0xFF+1):asnumber()]~j[(y[1]>>32&0xFF+1):asnumber()]~k[(y[8]>>24&0xFF+1):asnumber()]~l[(y[7]>>16&0xFF+1):asnumber()]~m[(y[6]>>8&0xFF+1):asnumber()]~n[(y[5]&0xFF+1):asnumber()]~x[4]z[5]=g[(y[5]>>56+1):asnumber()]~h[(y[4]>>48&0xFF+1):asnumber()]~i[(y[3]>>40&0xFF+1):asnumber()]~j[(y[2]>>32&0xFF+1):asnumber()]~k[(y[1]>>24&0xFF+1):asnumber()]~l[(y[8]>>16&0xFF+1):asnumber()]~m[(y[7]>>8&0xFF+1):asnumber()]~n[(y[6]&0xFF+1):asnumber()]~x[5]z[6]=g[(y[6]>>56+1):asnumber()]~h[(y[5]>>48&0xFF+1):asnumber()]~i[(y[4]>>40&0xFF+1):asnumber()]~j[(y[3]>>32&0xFF+1):asnumber()]~k[(y[2]>>24&0xFF+1):asnumber()]~l[(y[1]>>16&0xFF+1):asnumber()]~m[(y[8]>>8&0xFF+1):asnumber()]~n[(y[7]&0xFF+1):asnumber()]~x[6]z[7]=g[(y[7]>>56+1):asnumber()]~h[(y[6]>>48&0xFF+1):asnumber()]~i[(y[5]>>40&0xFF+1):asnumber()]~j[(y[4]>>32&0xFF+1):asnumber()]~k[(y[3]>>24&0xFF+1):asnumber()]~l[(y[2]>>16&0xFF+1):asnumber()]~m[(y[1]>>8&0xFF+1):asnumber()]~n[(y[8]&0xff+1):asnumber()]~x[7]z[8]=g[(y[8]>>56+1):asnumber()]~h[(y[7]>>48&0xFF+1):asnumber()]~i[(y[6]>>40&0xFF+1):asnumber()]~j[(y[5]>>32&0xFF+1):asnumber()]~k[(y[4]>>24&0xFF+1):asnumber()]~l[(y[3]>>16&0xFF+1):asnumber()]~m[(y[2]>>8&0xFF+1):asnumber()]~n[(y[1]&0xFF+1):asnumber()]~x[8]y[1]=z[1]:copy()y[2]=z[2]:copy()y[3]=z[3]:copy()y[4]=z[4]:copy()y[5]=z[5]:copy()y[6]=z[6]:copy()y[7]=z[7]:copy()y[8]=z[8]:copy()end;self._hash[1]=self._hash[1]~y[1]~r[1]self._hash[2]=self._hash[2]~y[2]~r[2]self._hash[3]=self._hash[3]~y[3]~r[3]self._hash[4]=self._hash[4]~y[4]~r[4]self._hash[5]=self._hash[5]~y[5]~r[5]self._hash[6]=self._hash[6]~y[6]~r[6]self._hash[7]=self._hash[7]~y[7]~r[7]self._hash[8]=self._hash[8]~y[8]~r[8]end end;function e:digest()local B;local C={}local D=0;local s;B=self:copy()B._data=B._data..a.char(1<<7)if#B._data>32 then B._data=B._data..a.rep(a.char(0),64-#B._data)D=64-#B._data+32 else D=32-#B._data end;B._data=B._data..a.rep(a.char(0),D)..B._len:asbytestring()B:update()for u=1,#B._hash do C[u]=B._hash[u]:asbytestring()end;return table.concat(C)end;function e:hexdigest()local E;local C={}E=self:digest()for u=1,#E do C[u]=a.format("%02X",a.byte(E,u))end;return table.concat(C)end;return e diff --git a/extern/lualibs/inspect.lua b/extern/lualibs/inspect.lua new file mode 100644 index 00000000..f5f9c5db --- /dev/null +++ b/extern/lualibs/inspect.lua @@ -0,0 +1,25 @@ +-- inspect 3.1.2 | /inspect.lua | https://github.com/kikito/inspect.lua | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +local a={_VERSION='inspect.lua 3.1.0',_URL='http://github.com/kikito/inspect.lua',_DESCRIPTION='human-readable representations of tables',_LICENSE=[[ + MIT LICENSE + + Copyright (c) 2013 Enrique García Cota + + 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 tostring=tostring;a.KEY=setmetatable({},{__tostring=function()return'inspect.KEY'end})a.METATABLE=setmetatable({},{__tostring=function()return'inspect.METATABLE'end})local function b(c)return next,c,nil end;local function d(e)if e:match('"')and not e:match("'")then return"'"..e.."'"end;return'"'..e:gsub('"','\\"')..'"'end;local f={["\a"]="\\a",["\b"]="\\b",["\f"]="\\f",["\n"]="\\n",["\r"]="\\r",["\t"]="\\t",["\v"]="\\v",["\127"]="\\127"}local g={["\127"]="\127"}for h=0,31 do local i=string.char(h)if not f[i]then f[i]="\\"..h;g[i]=string.format("\\%03d",h)end end;local function j(e)return e:gsub("\\","\\\\"):gsub("(%c)%f[0-9]",g):gsub("%c",f)end;local function k(e)return type(e)=='string'and e:match("^[_%a][_%a%d]*$")end;local function l(m,n)return type(m)=='number'and 1<=m and m<=n and math.floor(m)==m end;local o={['number']=1,['boolean']=2,['string']=3,['table']=4,['function']=5,['userdata']=6,['thread']=7}local function p(q,r)local s,t=type(q),type(r)if s==t and(s=='string'or s=='number')then return q')elseif self.level>=self.depth then self:puts('{...}')else if self.tableAppearances[c]>1 then self:puts('<',self:getId(c),'>')end;local _,a0,n=z(c)local S=getmetatable(c)self:puts('{')self:down(function()local a1=0;for h=1,n do if a1>0 then self:puts(',')end;self:puts(' ')self:putValue(c[h])a1=a1+1 end;for h=1,a0 do local m=_[h]if a1>0 then self:puts(',')end;self:tabify()self:putKey(m)self:puts(' = ')self:putValue(c[m])a1=a1+1 end;if type(S)=='table'then if a1>0 then self:puts(',')end;self:tabify()self:puts(' = ')self:putValue(S)end end)if a0>0 or type(S)=='table'then self:tabify()elseif n>0 then self:puts(' ')end;self:puts('}')end end;function T:putValue(y)local Z=type(y)if Z=='string'then self:puts(d(j(y)))elseif Z=='number'or Z=='boolean'or Z=='nil'or Z=='cdata'or Z=='ctype'then self:puts(tostring(y))elseif Z=='table'then self:putTable(y)else self:puts('<',Z,' ',self:getId(y),'>')end end;function a.inspect(a2,a3)a3=a3 or{}local a4=a3.depth or math.huge;local a5=a3.newline or'\n'local a6=a3.indent or' 'local M=a3.process;if M then a2=L(M,a2,{},{})end;local a7=setmetatable({depth=a4,level=0,buffer={},ids={},maxIds={},newline=a5,indent=a6,tableAppearances=D(a2)},U)a7:putValue(a2)return table.concat(a7.buffer)end;setmetatable(a,{__call=function(C,...)return a.inspect(...)end})return a diff --git a/extern/lualibs/json.lua b/extern/lualibs/json.lua new file mode 100644 index 00000000..610e8e91 --- /dev/null +++ b/extern/lualibs/json.lua @@ -0,0 +1,6 @@ +-- json.lua @dbf4b2dd2eb7c23be2773c89eb059dadd6436f94 | /json.lua | https://github.com/rxi/json.lua | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2020 rxi +-- 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 a={_version="0.1.2"}local b;local c={["\\"]="\\",["\""]="\"",["\b"]="b",["\f"]="f",["\n"]="n",["\r"]="r",["\t"]="t"}local d={["/"]="/"}for e,f in pairs(c)do d[f]=e end;local function g(h)return"\\"..(c[h]or string.format("u%04x",h:byte()))end;local function i(j)return"null"end;local function k(j,l)local m={}l=l or{}if l[j]then error("circular reference")end;l[j]=true;if rawget(j,1)~=nil or next(j)==nil then local n=0;for e in pairs(j)do if type(e)~="number"then error("invalid table: mixed or invalid key types")end;n=n+1 end;if n~=#j then error("invalid table: sparse array")end;for o,f in ipairs(j)do table.insert(m,b(f,l))end;l[j]=nil;return"["..table.concat(m,",").."]"else for e,f in pairs(j)do if type(e)~="string"then error("invalid table: mixed or invalid key types")end;table.insert(m,b(e,l)..":"..b(f,l))end;l[j]=nil;return"{"..table.concat(m,",").."}"end end;local function p(j)return'"'..j:gsub('[%z\1-\31\\"]',g)..'"'end;local function q(j)if j~=j or j<=-math.huge or j>=math.huge then error("unexpected number value '"..tostring(j).."'")end;return string.format("%.14g",j)end;local r={["nil"]=i,["table"]=k,["string"]=p,["number"]=q,["boolean"]=tostring}b=function(j,l)local s=type(j)local t=r[s]if t then return t(j,l)end;error("unexpected type '"..s.."'")end;function a.encode(j)return b(j)end;local u;local function v(...)local m={}for o=1,select("#",...)do m[select(o,...)]=true end;return m end;local w=v(" ","\t","\r","\n")local x=v(" ","\t","\r","\n","]","}",",")local y=v("\\","/",'"',"b","f","n","r","t","u")local z=v("true","false","null")local A={["true"]=true,["false"]=false,["null"]=nil}local function B(C,D,E,F)for o=D,#C do if E[C:sub(o,o)]~=F then return o end end;return#C+1 end;local function G(C,D,H)local I=1;local J=1;for o=1,D-1 do J=J+1;if C:sub(o,o)=="\n"then I=I+1;J=1 end end;error(string.format("%s at line %d col %d",H,I,J))end;local function K(n)local t=math.floor;if n<=0x7f then return string.char(n)elseif n<=0x7ff then return string.char(t(n/64)+192,n%64+128)elseif n<=0xffff then return string.char(t(n/4096)+224,t(n%4096/64)+128,n%64+128)elseif n<=0x10ffff then return string.char(t(n/262144)+240,t(n%262144/4096)+128,t(n%4096/64)+128,n%64+128)end;error(string.format("invalid unicode codepoint '%x'",n))end;local function L(M)local N=tonumber(M:sub(1,4),16)local O=tonumber(M:sub(7,10),16)if O then return K((N-0xd800)*0x400+O-0xdc00+0x10000)else return K(N)end end;local function P(C,o)local m=""local Q=o+1;local e=Q;while Q<=#C do local R=C:byte(Q)if R<32 then G(C,Q,"control character in string")elseif R==92 then m=m..C:sub(e,Q-1)Q=Q+1;local h=C:sub(Q,Q)if h=="u"then local S=C:match("^[dD][89aAbB]%x%x\\u%x%x%x%x",Q+1)or C:match("^%x%x%x%x",Q+1)or G(C,Q-1,"invalid unicode escape in string")m=m..L(S)Q=Q+#S else if not y[h]then G(C,Q-1,"invalid escape char '"..h.."' in string")end;m=m..d[h]end;e=Q+1 elseif R==34 then m=m..C:sub(e,Q-1)return m,Q+1 end;Q=Q+1 end;G(C,o,"expected closing quote for string")end;local function T(C,o)local R=B(C,o,x)local M=C:sub(o,R-1)local n=tonumber(M)if not n then G(C,o,"invalid number '"..M.."'")end;return n,R end;local function U(C,o)local R=B(C,o,x)local V=C:sub(o,R-1)if not z[V]then G(C,o,"invalid literal '"..V.."'")end;return A[V],R end;local function W(C,o)local m={}local n=1;o=o+1;while 1 do local R;o=B(C,o,w,true)if C:sub(o,o)=="]"then o=o+1;break end;R,o=u(C,o)m[n]=R;n=n+1;o=B(C,o,w,true)local X=C:sub(o,o)o=o+1;if X=="]"then break end;if X~=","then G(C,o,"expected ']' or ','")end end;return m,o end;local function Y(C,o)local m={}o=o+1;while 1 do local Z,j;o=B(C,o,w,true)if C:sub(o,o)=="}"then o=o+1;break end;if C:sub(o,o)~='"'then G(C,o,"expected string for key")end;Z,o=u(C,o)o=B(C,o,w,true)if C:sub(o,o)~=":"then G(C,o,"expected ':' after key")end;o=B(C,o+1,w,true)j,o=u(C,o)m[Z]=j;o=B(C,o,w,true)local X=C:sub(o,o)o=o+1;if X=="}"then break end;if X~=","then G(C,o,"expected '}' or ','")end end;return m,o end;local _={['"']=P,["0"]=T,["1"]=T,["2"]=T,["3"]=T,["4"]=T,["5"]=T,["6"]=T,["7"]=T,["8"]=T,["9"]=T,["-"]=T,["t"]=U,["f"]=U,["n"]=U,["["]=W,["{"]=Y}u=function(C,D)local X=C:sub(D,D)local t=_[X]if t then return t(C,D)end;G(C,D,"unexpected character '"..X.."'")end;function a.decode(C)if type(C)~="string"then error("expected argument of type string, got "..type(C))end;local m,D=u(C,B(C,1,w,true))D=B(C,D,w,true)if D<=#C then G(C,D,"trailing garbage")end;return m end;return a diff --git a/extern/lualibs/moses.lua b/extern/lualibs/moses.lua new file mode 100644 index 00000000..d242e437 --- /dev/null +++ b/extern/lualibs/moses.lua @@ -0,0 +1,6 @@ +-- Moses @6fe8d76d50a22d85fe064aaa80390b72381befed | /moses.lua | https://github.com/Yonaba/Moses | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2012-2018 Roland Yonaba +-- 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 a='2.1.0'local next,type,pcall=next,type,pcall;local setmetatable,getmetatable=setmetatable,getmetatable;local b,c=table.insert,table.sort;local d,e=table.remove,table.concat;local f,g,h=math.randomseed,math.random,math.huge;local i,j,k,l=math.floor,math.max,math.min,math.ceil;local m=coroutine.wrap;local n=coroutine.yield;local rawget=rawget;local unpack=table.unpack or unpack;local pairs,ipairs=pairs,ipairs;local error=error;local o=os and os.clock or nil;local p={}local function q(r,s)return r>s end;local function t(r,s)return r0 then while#J0 and w+1<#v then while#J0 and w+G<=#v then while#J=0 and 1 or-1 end;local O=-1;p.operator={}p.operator.add=function(r,s)return r+s end;p.operator.sub=function(r,s)return r-s end;p.operator.mul=function(r,s)return r*s end;p.operator.div=function(r,s)return r/s end;p.operator.mod=function(r,s)return r%s end;p.operator.exp=function(r,s)return r^s end;p.operator.pow=p.operator.exp;p.operator.unm=function(r)return-r end;p.operator.neg=p.operator.unm;p.operator.floordiv=function(r,s)return i(r/s)end;p.operator.intdiv=function(r,s)return r>=0 and i(r/s)or l(r/s)end;p.operator.eq=function(r,s)return r==s end;p.operator.neq=function(r,s)return r~=s end;p.operator.lt=function(r,s)return rs end;p.operator.le=function(r,s)return r<=s end;p.operator.ge=function(r,s)return r>=s end;p.operator.land=function(r,s)return r and s end;p.operator.lor=function(r,s)return r or s end;p.operator.lnot=function(r)return not r end;p.operator.concat=function(r,s)return r..s end;p.operator.length=function(r)return#r end;p.operator.len=p.operator.length;function p.clear(v)for x in pairs(v)do v[x]=nil end;return v end;function p.each(v,H)for P,Q in pairs(v)do H(Q,P)end end;function p.eachi(v,H)local R=p.sort(p.select(p.keys(v),p.isInteger))for x,S in ipairs(R)do H(v[S],S)end end;function p.at(v,...)local T={}for w,S in ipairs({...})do T[#T+1]=v[S]end;return T end;function p.adjust(v,S,H)if v[S]==nil then error("key not existing in table")end;local U=p.clone(v)U[S]=type(H)=='function'and H(U[S])or H;return U end;function p.count(v,E)if E==nil then return p.size(v)end;local u=0;for x,y in pairs(v)do if p.isEqual(y,E)then u=u+1 end end;return u end;function p.countf(v,H)local u=0;for x,y in pairs(v)do if H(y,x)then u=u+1 end end;return u end;function p.allEqual(v,B)local x,V=next(v)for x,y in pairs(v)do if B then if not B(V,y)then return false end else if not p.isEqual(V,y)then return false end end end;return true end;function p.cycle(v,G)G=G or 1;if G<=0 then return p.noop end;local x,W;local w=0;while true do return function()x=x and next(v,x)or next(v)W=not W and x or W;if G then w=x==W and w+1 or w;if w>G then return end end;return v[x],x end end end;function p.map(v,H)local U={}for P,Q in pairs(v)do local x,X,y=P,H(Q,P)U[y and X or x]=y or X end;return U end;function p.mapi(v,H)local U={}for P,Q in ipairs(v)do local x,X,y=P,H(Q,P)U[y and X or x]=y or X end;return U end;function p.reduce(v,H,Y)for x,Q in pairs(v)do if Y==nil then Y=Q else Y=H(Y,Q)end end;return Y end;function p.best(v,H)local Z,Y=next(v)for x,Q in pairs(v)do if Y==nil then Y=Q else Y=H(Y,Q)and Y or Q end end;return Y end;function p.reduceBy(v,H,_,Y)return p.reduce(p.select(v,_),H,Y)end;function p.reduceRight(v,H,Y)return p.reduce(p.reverse(v),H,Y)end;function p.mapReduce(v,H,Y)local U={}for w,Q in pairs(v)do U[w]=not Y and Q or H(Y,Q)Y=U[w]end;return U end;function p.mapReduceRight(v,H,Y)return p.mapReduce(p.reverse(v),H,Y)end;function p.include(v,Q)local a0=type(Q)=='function'and Q or p.isEqual;for x,y in pairs(v)do if a0(y,Q)then return true end end;return false end;function p.detect(v,Q)local a0=type(Q)=='function'and Q or p.isEqual;for S,a1 in pairs(v)do if a0(a1,Q)then return S end end end;function p.where(v,a2)local a3=p.select(v,function(y)for S in pairs(a2)do if y[S]~=a2[S]then return false end end;return true end)return#a3>0 and a3 or nil end;function p.findWhere(v,a2)local P=p.detect(v,function(y)for S in pairs(a2)do if a2[S]~=y[S]then return false end end;return true end)return P and v[P]end;function p.select(v,H)local U={}for P,Q in pairs(v)do if H(Q,P)then U[#U+1]=Q end end;return U end;function p.reject(v,H)local U={}for P,Q in pairs(v)do if not H(Q,P)then U[#U+1]=Q end end;return U end;function p.all(v,H)for P,Q in pairs(v)do if not H(Q,P)then return false end end;return true end;function p.invoke(v,a4)return p.map(v,function(y,x)if type(y)=='table'then if y[a4]then if p.isCallable(y[a4])then return y[a4](y,x)else return y[a4]end else if p.isCallable(a4)then return a4(y,x)end end elseif p.isCallable(a4)then return a4(y,x)end end)end;function p.pluck(v,S)local U={}for x,y in pairs(v)do if y[S]then U[#U+1]=y[S]end end;return U end;function p.max(v,C)return z(v,q,C)end;function p.min(v,C)return z(v,t,C)end;function p.same(r,s)return p.all(r,function(y)return p.include(s,y)end)and p.all(s,function(y)return p.include(r,y)end)end;function p.sort(v,B)c(v,B)return v end;function p.sortedk(v,B)local a5=p.keys(v)c(a5,B)local w=0;return function()w=w+1;return a5[w],v[a5[w]]end end;function p.sortedv(v,B)local a5=p.keys(v)B=B or t;c(a5,function(r,s)return B(v[r],v[s])end)local w=0;return function()w=w+1;return a5[w],v[a5[w]]end end;function p.sortBy(v,C,B)local H=C or p.identity;if type(C)=='string'then H=function(v)return v[C]end end;B=B or t;c(v,function(r,s)return B(H(r),H(s))end)return v end;function p.groupBy(v,a6)local U={}for x,y in pairs(v)do local a7=a6(y,x)if U[a7]then U[a7][#U[a7]+1]=y else U[a7]={y}end end;return U end;function p.countBy(v,a6)local a8={}for w,y in pairs(v)do local S=a6(y,w)a8[S]=(a8[S]or 0)+1 end;return a8 end;function p.size(...)local a9={...}local aa=a9[1]return type(aa)=='table'and u(a9[1])or u(a9)end;function p.containsKeys(v,ab)for S in pairs(ab)do if not v[S]then return false end end;return true end;function p.sameKeys(ac,ad)for S in pairs(ac)do if not ad[S]then return false end end;for S in pairs(ad)do if not ac[S]then return false end end;return true end;function p.sample(ae,G,af)G=G or 1;if G==0 then return{}end;if G==1 then if af then f(af)end;return{ae[g(1,#ae)]}end;return p.slice(p.shuffle(ae,af),1,G)end;function p.sampleProb(ae,ag,af)if af then f(af)end;local v={}for x,y in ipairs(ae)do if g()au then error("start cannot be greater than finish.")end;for w=au,at,-1 do d(ae,w)end;return ae end;function p.chunk(ae,H)local av,aw,ax,E={},0;H=H or p.identity;for x,y in ipairs(ae)do E=H(y,x)aw=E~=ax and aw+1 or aw;ax=ax==nil and E or ax;if not av[aw]then av[aw]={ae[x]}else av[aw][#av[aw]+1]=ae[x]end;ax=E end;return av end;function p.slice(ae,at,au)local v={}for x=at or 1,au or#ae do v[#v+1]=ae[x]end;return v end;function p.first(ae,G)G=G or 1;local v={}for x=1,G do v[x]=ae[x]end;return v end;function p.initial(ae,G)local ay=#ae;G=G and ay-k(G,ay)or ay-1;local v={}for x=1,G do v[x]=ae[x]end;return v end;function p.last(ae,G)local ay=#ae;G=G and ay-k(G-1,ay-1)or 2;local v={}for x=G,ay do v[#v+1]=ae[x]end;return v end;function p.rest(ae,P)local v={}for x=P or 1,#ae do v[#v+1]=ae[x]end;return v end;function p.nth(ae,P)return ae[P]end;function p.compact(ae)local v={}for x,y in pairs(ae)do if y then v[#v+1]=y end end;return v end;function p.flatten(ae,az)az=az or false;local aA;local aB={}for S,Q in ipairs(ae)do if type(Q)=='table'then aA=az and Q or p.flatten(Q)for x,aC in ipairs(aA)do aB[#aB+1]=aC end else aB[#aB+1]=Q end end;return aB end;function p.difference(ae,aD)if not aD then return p.clone(ae)end;return p.select(ae,function(Q)return not p.include(aD,Q)end)end;function p.union(...)return p.unique(p.flatten({...}))end;function p.intersection(...)local a1={...}local ae=a1[1]d(a1,1)local aE={}for w,Q in ipairs(ae)do if p.all(a1,function(y)return p.include(y,Q)end)then aE[#aE+1]=Q end end;return aE end;function p.disjoint(...)return#p.intersection(...)==0 end;function p.symmetricDifference(ae,aD)return p.difference(p.union(ae,aD),p.intersection(ae,aD))end;function p.unique(ae)local ap={}for w=1,#ae do if not p.find(ap,ae[w])then ap[#ap+1]=ae[w]end end;return ap end;function p.isunique(ae)return#ae==#p.unique(ae)end;function p.duplicates(ae)local aF=p.invert(ae)local aG={}for x,y in ipairs(ae)do if aF[y]~=x and not p.find(aG,y)then aG[#aG+1]=y end end;return aG end;function p.zip(...)local a9={...}local G=p.max(a9,function(ae)return#ae end)local D={}for w=1,G do if not D[w]then D[w]={}end;for x,ae in ipairs(a9)do if ae[w]~=nil then D[w][#D[w]+1]=ae[w]end end end;return D end;function p.zipWith(H,...)local a9={...}local G=p.max(a9,function(ae)return#ae end)local D={}for w=1,G do D[w]=H(unpack(p.pluck(a9,w)))end;return D end;function p.append(ae,ab)local v={}for w,y in ipairs(ae)do v[w]=y end;for w,y in ipairs(ab)do v[#v+1]=y end;return v end;function p.interleave(...)local a9={...}local G=p.max(a9,p.size)local v={}for w=1,G do for x,ae in ipairs(a9)do if ae[w]then v[#v+1]=ae[w]end end end;return v end;function p.interpose(ae,Q)for x=#ae,2,-1 do b(ae,x,Q)end;return ae end;function p.range(aj,aH,aI)if aj==nil and aH==nil and aI==nil then return{}elseif aj~=nil and aH==nil and aI==nil then aj,aH,aI=N(aj),aj,N(aj)elseif aj~=nil and aH~=nil and aI==nil then aI=N(aH-aj)end;local aJ={aj}local aK=j(i((aH-aj)/aI),0)for w=1,aK do aJ[#aJ+1]=aj+aI*w end;return aJ end;function p.rep(Q,G)local ap={}for w=1,G do ap[w]=Q end;return ap end;function p.powerset(ae)local G=#ae;local aL={}for w,y in ipairs(ae)do for al=1,#aL do local aM=aL[al]b(aL,p.push(p.slice(aM),y))end;b(aL,{y})end;b(aL,{})return aL end;function p.partition(ae,G,I)if G<=0 then return end;return m(function()F(ae,G or 1,n,I)end)end;function p.overlapping(ae,G,I)if G<=1 then return end;return m(function()K(ae,G or 2,n,I)end)end;function p.aperture(ae,G)if G<=1 then return end;return m(function()L(ae,G or 2,n)end)end;function p.pairwise(ae)return p.aperture(ae,2)end;function p.permutation(ae)return m(function()M(ae,#ae,n)end)end;function p.concat(ae,aN,w,al)return e(p.map(ae,tostring),aN,w,al)end;function p.xprod(ae,aD)local aO={}for w,aP in ipairs(ae)do for al,aQ in ipairs(aD)do aO[#aO+1]={aP,aQ}end end;return aO end;function p.xpairs(Q,ae)local aR={}for x,y in ipairs(ae)do aR[x]={Q,y}end;return aR end;function p.xpairsRight(Q,ae)local aR={}for x,y in ipairs(ae)do aR[x]={y,Q}end;return aR end;function p.sum(ae)local J=0;for x,y in ipairs(ae)do J=J+y end;return J end;function p.product(ae)local aO=1;for x,y in ipairs(ae)do aO=aO*y end;return aO end;function p.mean(ae)return p.sum(ae)/#ae end;function p.median(ae)local v=p.sort(p.clone(ae))local G=#v;if G==0 then return elseif G==1 then return v[1]end;local aS=l(G/2)return G%2==0 and(v[aS]+v[aS+1])/2 or v[aS]end;function p.noop()return end;function p.identity(Q)return Q end;function p.call(H,...)return H(...)end;function p.constant(Q)return function()return Q end end;function p.applySpec(aT)return function(...)local aU={}for w,H in pairs(aT)do aU[w]=H(...)end;return aU end end;function p.thread(Q,...)local Y=Q;local a1={...}for x,v in ipairs(a1)do if type(v)=='function'then Y=v(Y)elseif type(v)=='table'then local H=v[1]d(v,1)Y=p.reduce(v,H,Y)end end;return Y end;function p.threadRight(Q,...)local Y=Q;local a1={...}for x,v in ipairs(a1)do if type(v)=='function'then Y=v(Y)elseif type(v)=='table'then local H=v[1]d(v,1)b(v,Y)Y=p.reduce(v,H)end end;return Y end;function p.dispatch(...)local aV={...}return function(...)for x,H in ipairs(aV)do local a3={H(...)}if#a3>0 then return unpack(a3)end end end end;function p.memoize(H)local aW=setmetatable({},{__mode='kv'})return function(S)if aW[S]==nil then aW[S]=H(S)end;return aW[S]end end;function p.unfold(H,af)local v,aX={}while true do aX,af=H(af)if aX~=nil then v[#v+1]=aX else break end end;return v end;function p.once(H)local aY=0;local aZ={}return function(...)aY=aY+1;if aY<=1 then aZ={...}end;return H(unpack(aZ))end end;function p.before(H,u)local aY=0;local aZ={}return function(...)aY=aY+1;if aY<=u then aZ={...}end;return H(unpack(aZ))end end;function p.after(H,u)local a_,aY=u,0;return function(...)aY=aY+1;if aY>=a_ then return H(...)end end end;function p.compose(...)local H=p.reverse{...}return function(...)local b0,b1=true;for w,b2 in ipairs(H)do if b0 then b0=false;b1=b2(...)else b1=b2(b1)end end;return b1 end end;function p.pipe(Q,...)return p.compose(...)(Q)end;function p.complement(H)return function(...)return not H(...)end end;function p.juxtapose(Q,...)local b3={}for w,b2 in ipairs({...})do b3[w]=b2(Q)end;return unpack(b3)end;function p.wrap(H,b4)return function(...)return b4(H,...)end end;function p.times(a6,G)local b5={}for w=1,G or 1 do b5[w]=a6(w)end;return b5 end;function p.bind(H,y)return function(...)return H(y,...)end end;function p.bind2(H,y)return function(v,...)return H(v,y,...)end end;function p.bindn(H,...)local a9={...}return function(...)return H(unpack(p.append(a9,{...})))end end;function p.bindall(b6,...)local b7={...}for w,b8 in ipairs(b7)do local a4=b6[b8]if a4 then b6[b8]=p.bind(a4,b6)end end;return b6 end;function p.cond(b9)return function(...)for x,ba in ipairs(b9)do if ba[1](...)then return ba[2](...)end end end end;function p.both(...)local aV={...}return function(...)for x,H in ipairs(aV)do if not H(...)then return false end end;return true end end;function p.either(...)local aV={...}return function(...)for x,H in ipairs(aV)do if H(...)then return true end end;return false end end;function p.neither(...)local aV={...}return function(...)for x,H in ipairs(aV)do if H(...)then return false end end;return true end end;function p.uniqueId(bb)O=O+1;if bb then if type(bb)=='string'then return bb:format(O)elseif type(bb)=='function'then return bb(O)end end;return O end;function p.iterator(H,Q,G)local bc=0;return function()bc=bc+1;if G and bc>G then return end;Q=H(Q)return Q end end;function p.skip(a6,G)for w=1,G or 1 do if a6()==nil then return end end;return a6 end;function p.tabulate(...)local a3={}for y in...do a3[#a3+1]=y end;return a3 end;function p.iterlen(...)local ay=0;for y in...do ay=ay+1 end;return ay end;function p.castArray(Q)return type(Q)~='table'and{Q}or Q end;function p.flip(H)return function(...)return H(unpack(p.reverse({...})))end end;function p.nthArg(G)return function(...)local a9={...}return a9[G<0 and#a9+G+1 or G]end end;function p.unary(H)return function(...)local a9={...}return H(a9[1])end end;function p.ary(H,G)G=G or 1;return function(...)local a9={...}local bd={}for w=1,G do bd[w]=a9[w]end;return H(unpack(bd))end end;function p.noarg(H)return function()return H()end end;function p.rearg(H,be)return function(...)local a9={...}local bf={}for w,a1 in ipairs(be)do bf[w]=a9[a1]end;return H(unpack(bf))end end;function p.over(...)local bg={...}return function(...)local a3={}for w,C in ipairs(bg)do a3[#a3+1]=C(...)end;return a3 end end;function p.overEvery(...)local H=p.over(...)return function(...)return p.reduce(H(...),function(Y,y)return Y and y end)end end;function p.overSome(...)local H=p.over(...)return function(...)return p.reduce(H(...),function(Y,y)return Y or y end)end end;function p.overArgs(H,...)local bh={...}return function(...)local aZ={...}for w=1,#bh do local b2=bh[w]if aZ[w]then aZ[w]=b2(aZ[w])end end;return H(unpack(aZ))end end;function p.converge(H,bi,bj)return function(...)return H(bi(...),bj(...))end end;function p.partial(H,...)local bk={...}return function(...)local bl={...}local bm={}for x,y in ipairs(bk)do bm[x]=y=='_'and p.shift(bl)or y end;return H(unpack(p.append(bm,bl)))end end;function p.partialRight(H,...)local bk={...}return function(...)local bl={...}local bm={}for x=1,#bk do bm[x]=bk[x]=='_'and p.shift(bl)or bk[x]end;return H(unpack(p.append(bl,bm)))end end;function p.curry(H,bl)bl=bl or 2;local aZ={}local function bn(y)if bl==1 then return H(y)end;if y~=nil then aZ[#aZ+1]=y end;if#aZ-h and b60 and r>0 then n=n+o end;if q>0 then c=c-1 end;if r>0 then d=d-1 end;c=c/2;d=d/2;o=o*2 end;return n end;local function s(c,d)local n,o=0,1;for p=0,31 do local q=c%2;local r=d%2;if q>0 or r>0 then n=n+o end;if q>0 then c=c-1 end;if r>0 then d=d-1 end;c=c/2;d=d/2;o=o*2 end;return n end;local function t(c,d)local n,o=0,1;for p=0,31 do local q=c%2;local r=d%2;if q~=r then n=n+o end;if q>0 then c=c-1 end;if r>0 then d=d-1 end;c=c/2;d=d/2;o=o*2 end;return n end;local u=function(v)return a(v/2)end;local w=function(v)return a(v/1073741824)end;local x=function(v)return a(v/2048)end;local y=function(v)return v*128 end;local z=function(v)return v*32768 end;local A=function(v)return a(v/262144)end;local B=function(v)return v%2 end;local C=624;local D=397;local E=0x9908B0DF;local F=0x80000000;local G=0x7FFFFFFF;local H={}function H.new()local I={}local J={}local K=C+1;function I:init_genrand(L)J[0]=m(L,0xFFFFFFFF)for p=1,C-1 do J[p]=b(1812433253,t(J[p-1],w(J[p-1])))+p;J[p]=m(J[p],0xFFFFFFFF)end;K=C end;function I:init_by_array(M,N)self:init_genrand(19650218)if not N then N=#M end;local p,O,P=1,0,C>N and C or N;while P>0 do J[p]=t(J[p],b(t(J[p-1],w(J[p-1])),1664525))+M[O+1]+O;J[p]=m(J[p],0xFFFFFFFF)p,O=p+1,O+1;if p>=C then J[0]=J[C-1]p=1 end;if O>=N then O=0 end;P=P-1 end;for P=C-1,1,-1 do J[p]=t(J[p],b(t(J[p-1],w(J[p-1])),1566083941))-p;J[p]=m(J[p],0xFFFFFFFF)p=p+1;if p>=C then J[0]=J[C-1]p=1 end end;J[0]=0x80000000 end;function I:genrand_int32()local v;if K>=C then if K==C+1 then self:init_genrand(5489)end;for Q=0,C-D-1 do v=s(m(J[Q],F),m(J[Q+1],G))J[Q]=t(J[Q+D],t(u(v),B(v)*E))Q=Q+1 end;for Q=C-D,C-2 do v=s(m(J[Q],F),m(J[Q+1],G))J[Q]=t(J[Q+D-C],t(u(v),B(v)*E))Q=Q+1 end;v=s(m(J[C-1],F),m(J[0],G))J[C-1]=t(J[D-1],t(u(v),B(v)*E))K=0 end;v=J[K]K=K+1;v=t(v,x(v))v=t(v,m(y(v),0x9D2C5680))v=t(v,m(z(v),0xEFC60000))v=t(v,A(v))return v end;function I:genrand_int31()return a(self:genrand_int32()/2)end;function I:genrand_real1()return self:genrand_int32()*1.0/4294967295.0 end;function I:genrand_real2()return self:genrand_int32()*1.0/4294967296.0 end;function I:genrand_real3()return(self:genrand_int32()+0.5)*1.0/4294967296.0 end;function I:genrand_res53()local c=a(self:genrand_int32()/32)local d=a(self:genrand_int32()/64)return(c*67108864.0+d)*1.0/9007199254740992.0 end;I.randomseed=I.init_genrand;function I:random(R,S)if not R then return self:genrand_real2()else if not S then return self:genrand_int32()%R+1 else return R+self:genrand_int32()%(S-R+1)end end end;function I:getState()local n={}n.mti=K;n.mt={}for p=0,C-1 do n.mt[p]=J[p]end;return n end;function I:setState(L)if L==nil then return end;if type(L.mti)=="number"then K=a(L.mti)end;if type(L.mt)=="table"then for p=0,C-1 do if type(L.mt[p])=="number"then J[p]=a(L.mt[p])end end end end;function I:createValidationOutput()local T="mt19937ar.lua.out"local U=io.open(T,"wb")self:init_by_array({291,564,837,1110})U:write("1000 outputs of genrand_int32()\n")for p=0,999 do U:write(string.format("%10.0f ",self:genrand_int32()))if p%5==4 then U:write("\n")end end;U:write("\n1000 outputs of genrand_real2()\n")for p=0,999 do U:write(string.format("%10.8f ",self:genrand_real2()))if p%5==4 then U:write("\n")end end;U:close()end;return I end;return H diff --git a/extern/lualibs/nums/bn.lua b/extern/lualibs/nums/bn.lua new file mode 100644 index 00000000..6d6fc856 --- /dev/null +++ b/extern/lualibs/nums/bn.lua @@ -0,0 +1,6 @@ +-- Lua-nums @fef161a940aaafdbb8d9c75fe073b8bb43152474 | /nums/bn.lua | https://github.com/user-none/lua-nums | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2016 John Schember +-- 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 math=math;local a={}local b={}local c;local d=1;local e=0;local f=0;while d>f do f=d;d=d<<1;e=e+1 end;c=e-1//2-1;local g=1<=#n._digits then o(n,#m._digits)else o(m,#n._digits)end end;local function q(m)if#m._digits==0 then m._pos=true;m._digits={0}return end;for r=#m._digits,2,-1 do if m._digits[r]~=0 then break end;table.remove(m._digits,r)end;if#m._digits==1 and m._digits[1]==0 then m._pos=true end end;local function s(m)m._digits={0}m._pos=true end;local function t(m)if a.isbn(m)then m=m:copy()else m=a:new(m)end;return m end;local function u(m,n)m=t(m)n=t(n)return m,n end;local function v(m,n)if m._pos==n._pos then return true end;return false end;local function w(m,n)m=t(m)if n==0 then return m end;for r=1,n do table.insert(m._digits,1,0)end;q(m)return m end;local function x(m,n)m=t(m)if n==0 then return m elseif n>=#m._digits then return a:new()end;for r=1,n do table.remove(m._digits,1)end;q(m)return m end;local function y(m,n)local z=a:new()local A=0;m,n=u(m,n)l(m,n)for r=1,#m._digits do z._digits[r]=m._digits[r]+n._digits[r]+A;A=z._digits[r]>>c;z._digits[r]=z._digits[r]&g end;if A~=0 then z._digits[#z._digits+1]=A end;q(z)return z end;local function B(m,n)local z=a()local A=0;m,n=u(m,n)l(m,n)for r=1,#m._digits do z._digits[r]=m._digits[r]-n._digits[r]-A&i;A=z._digits[r]>>c;z._digits[r]=z._digits[r]&g end;q(z)return z end;local function C(m,n,D)local z;m,n=u(m,n)l(m,n)z=a:new()l(z,m)for r=1,#m._digits do z._digits[r]=D(m._digits[r],n._digits[r])end;q(z)return z end;local function E(m,n)local F;local G;local H;local I;local J;m,n=u(m,n)if m==a.ZERO then return a:new(),a:new()elseif n==a.ZERO then return nil,"divide by 0"elseif n==a:new(1)then return m,a:new()end;I=v(m,n)J=m._pos;m._pos=true;n._pos=true;F=m:len_bits()-1;H=a:new()G=a:new()while F>=0 do H=H<<1;if m&(a:new(1)<0 then H=H|1 end;if H>=n then H=H-n;G=G|(a:new(1)<>c;L._digits[r]=L._digits[r]&g end;if A~=0 then L._digits[#L._digits+1]=A end;L._digits[1]=L._digits[1]+n;A=L._digits[1]>>c;L._digits[1]=L._digits[1]&g;for r=2,#L._digits do if A==0 then break end;L._digits[r]=L._digits[r]+A;A=L._digits[r]>>c;L._digits[r]=L._digits[r]&g end;if A~=0 then L._digits[#L._digits+1]=A end end;q(L)return true end;local function O(L,M)M=math.floor(M)if M>=-h and M<=h then if M<0 then M=-M;L._pos=false end;L._digits[1]=M;return true end;K(L,M)return true end;local function P(m,n)n._pos=m._pos;n._digits={}for r=1,#m._digits do n._digits[r]=m._digits[r]end end;local function Q(m,N)local n;local R={}local S={}local T;local A;local U;if#m._digits==1 and m._digits[1]==0 then return"0"end;if N~=10 and N~=16 then return nil,"base not supported"end;U=m._pos;m=m:copy()while#m._digits>1 or m._digits[1]~=0 do n=a:new()l(n,m)T=0;for r=#m._digits,1,-1 do T=T<=N then A=T//N;T=T-A*N else A=0 end;n._digits[r]=A end;R[#R+1]=k[T+1]m=n;q(m)end;if not U then R[#R+1]="-"end;for r=#R,1,-1 do S[#S+1]=R[r]end;return table.concat(S)end;b.__index=a;b.__add=function(m,n)local z;local V;local W;m,n=u(m,n)V=m._pos;W=n._pos;m._pos=true;n._pos=true;if V==W then z=y(m,n)z._pos=V elseif m=n then z=B(m,n)z._pos=V else z=B(n,m)z._pos=not V end;return z end;b.__mul=function(m,n)local z;local H;local A;m,n=u(m,n)z=a:new()z._pos=v(m,n)l(z,#m._digits+#n._digits+1)for r=1,#m._digits do A=0;for e=1,#n._digits do H=z._digits[r+e-1]+m._digits[r]*n._digits[e]+A;A=H>>c;z._digits[r+e-1]=H&g end;z._digits[r+#n._digits]=A end;q(z)return z end;b.__div=function(m,n)return m//n end;b.__mod=function(m,n)local z;local X;m,n=u(m,n)X,z=E(m,n)if z~=a.ZERO and z._pos~=n._pos then z=n+z end;return z end;b.__pow=function(m,n)local z;local Y;m,n=u(m,n)if n0 do if n&1==Y then z=z*m end;n=n>>1;m=m*m end;return z end;b.__unm=function(m)m=t(m)m._pos=not m._pos;return m end;b.__idiv=function(m,n)local z;local X;m,n=u(m,n)z,X=E(m,n)return z end;b.__band=function(m,n)local function D(m,n)return m&n end;return C(m,n,D)end;b.__bor=function(m,n)local function D(m,n)return m|n end;return C(m,n,D)end;b.__bxor=function(m,n)local function D(m,n)return m~n end;return C(m,n,D)end;b.__bnot=function(m)m=t(m)return-(m+1)end;b.__shl=function(m,n)local z;local A;local R;local Z;local _;local a0;m,n=u(m,n)if not n._pos then return nil,"Cannot shift by negative"end;R=n;n=n:asnumber()if a:new(n)~=R then return nil,"Overflow"end;z=n//c;m=w(m,z)z=n%c;if z==0 then return m end;_=1<>a0&_;m._digits[r]=m._digits[r]<>z|(A<#n._digits then if m._pos then return false else return true end end;if not m._pos then d=m;m=n;n=d end;for r=#m._digits,1,-1 do if m._digits[r]n._digits[r]then return false end end;return false end;b.__le=function(m,n)m,n=u(m,n)if m=a4 then return(self._pos and""or"-")..L end;return(self._pos and""or"-")..string.rep("0",a4-#L)..L end;function a:asnumber()local G=1;local d=0;while G>0 do d=d+1;G=1<>r*8&0xFF):asnumber()end;return R end;function a:asbytestring()local n;n=self:asbytearray()for r=1,#n do n[r]=string.char(n[r])end;return table.concat(n)end;a.ZERO=a:new()function a.isbn(R)if type(R)=="table"and getmetatable(R)==b then return true end;return false end;return a diff --git a/extern/lualibs/nums/init.lua b/extern/lualibs/nums/init.lua new file mode 100644 index 00000000..0bfed8a3 --- /dev/null +++ b/extern/lualibs/nums/init.lua @@ -0,0 +1,6 @@ +-- Lua-nums @fef161a940aaafdbb8d9c75fe073b8bb43152474 | /nums/init.lua | https://github.com/user-none/lua-nums | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2016 John Schember +-- 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 a={}a.bn=require("nums.bn")a.uintb=require("nums.uintb")a.uintn=require("nums.uintn")return a diff --git a/extern/lualibs/nums/uintb.lua b/extern/lualibs/nums/uintb.lua new file mode 100644 index 00000000..7e8c6dc8 --- /dev/null +++ b/extern/lualibs/nums/uintb.lua @@ -0,0 +1,6 @@ +-- Lua-nums @fef161a940aaafdbb8d9c75fe073b8bb43152474 | /nums/uintb.lua | https://github.com/user-none/lua-nums | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2016 John Schember +-- 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 a=require("nums.bn")local b={}local c={}local function d(e,f)local g=false;if not b.isuint(e)then e,f=f,e;g=true end;return e:copy(),a(f),g end;local function h(i)if i._bn==i._max then i._bn:set(0)elseif i._bn<0 or i._bn>i._max then i._bn=i._bn%i._max end end;c.__index=b;c.__add=function(e,f)local j;e,f,j=d(e,f)if j then e._bn=f+e._bn else e._bn=e._bn+f end;h(e)return e end;c.__sub=function(e,f)local j;e,f,j=d(e,f)if j then e._bn=f-e._bn else e._bn=e._bn-f end;h(e)return e end;c.__mul=function(e,f)e,f=d(e,f)e._bn=e._bn*f;h(e)return e end;c.__div=function(e,f)return e//f end;c.__mod=function(e,f)local j;e,f,j=d(e,f)if j then e._bn=f%e._bn else e._bn=e._bn%f end;h(e)return e end;c.__pow=function(e,f)local j;e,f,j=d(e,f)if j then e._bn=f^e._bn else e._bn=e._bn^f end;h(e)return e end;c.__unm=function(e)e=e:copy()e._bn=-e._bn;h(e)return e end;c.__idiv=function(e,f)local j;e,f,j=d(e,f)if j and f==0 then e._val=0;return e end;if j then e._bn=f//e._bn else e._bn=e._bn//f end;h(e)return e end;c.__band=function(e,f)e,f=d(e,f)e._bn=e._bn&f;h(e)return e end;c.__bor=function(e,f)e,f=d(e,f)e._bn=e._bn|f;h(e)return e end;c.__bxor=function(e,f)e,f=d(e,f)e._bn=e._bn~f;h(e)return e end;c.__bnot=function(e)e=e:copy()e._bn=~e._bn;h(e)return e end;c.__shl=function(e,f)local j;e,f,j=d(e,f)if j then e._bn=f<>e._bn else e._bn=e._bn>>f end;h(e)return e end;c.__concat=function(e,f)if b.isuint(e)and b.isuint(f)then return e._bn..f._bn elseif b.isuint(e)and not b.isuint(f)then return e._bn..f end;return e..f._bn end;c.__len=function(e)return e._bits end;c.__eq=function(e,f)e,f=d(e,f)return e._bn==f end;c.__lt=function(e,f)local j;e,f,j=d(e,f)if j then return e._bn>f end;return e._bnh._max then h._val=h._val%h._max end end;b.__index=a;b.__add=function(d,e)local i;d,e,i=c(d,e)if i then d._val=e+d._val else d._val=d._val+e end;g(d)return d end;b.__sub=function(d,e)local i;d,e,i=c(d,e)if i then d._val=e-d._val else d._val=d._val-e end;g(d)return d end;b.__mul=function(d,e)d,e=c(d,e)d._val=d._val*e;g(d)return d end;b.__div=function(d,e)return d//e end;b.__mod=function(d,e)local i;d,e,i=c(d,e)if i then d._val=e%d._val else d._val=d._val%e end;g(d)return d end;b.__pow=function(d,e)local i;d,e,i=c(d,e)if i then d._val=e^d._val else d._val=d._val^e end;g(d)return d end;b.__unm=function(d)d=d:copy()d._val=-d._val;g(d)return d end;b.__idiv=function(d,e)local i;d,e,i=c(d,e)if i and e==0 then d._val=0;return d end;if i then d._val=e//d._val else d._val=d._val//e end;g(d)return d end;b.__band=function(d,e)d,e=c(d,e)d._val=d._val&e;g(d)return d end;b.__bor=function(d,e)d,e=c(d,e)d._val=d._val|e;g(d)return d end;b.__bxor=function(d,e)d,e=c(d,e)d._val=d._val~e;g(d)return d end;b.__bnot=function(d)d=d:copy()d._val=~d._val;g(d)return d end;b.__shl=function(d,e)local i;d,e,i=c(d,e)if i then d._val=e<>d._val else d._val=d._val>>e end;g(d)return d end;b.__concat=function(d,e)if a.isuint(d)and a.isuint(e)then return d._val..e._val elseif a.isuint(d)and not a.isuint(e)then return d._val..e end;return d..e._val end;b.__len=function(d)return d._bits end;b.__eq=function(d,e)d,e=c(d,e)return d._val==e end;b.__lt=function(d,e)local i;d,e,i=c(d,e)if i then return d._val>e end;return d._val>o&0xFF end;return m end;function a:asbytestring()local e;e=self:asbytearray()for o=1,#e do e[o]=string.char(e[o])end;return table.concat(e)end;return a diff --git a/extern/lualibs/pl/Date.lua b/extern/lualibs/pl/Date.lua new file mode 100644 index 00000000..3b1b12a7 --- /dev/null +++ b/extern/lualibs/pl/Date.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/Date.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a=require'pl.class'local b,c=os.time,os.date;local d=require'pl.stringx'local e=require'pl.utils'local f,g=e.assert_arg,e.assert_string;e.raise_deprecation{source="Penlight "..e._VERSION,message="the 'Date' module is deprecated, see https://github.com/lunarmodules/Penlight/issues/285",version_removed="2.0.0",version_deprecated="1.9.2"}local h=a()h.Format=a()function h:_init(i,...)local j;local k=select('#',...)if k>2 then local l={...}local m=i;i={year=m,month=l[1],day=l[2],hour=l[3],min=l[4],sec=l[5]}end;if k==1 then self.utc=select(1,...)==true end;if i==nil or i=='utc'then j=b()self.utc=i=='utc'elseif type(i)=='number'then j=i;if self.utc==nil then self.utc=true end elseif type(i)=='table'then if getmetatable(i)==h then j=i.time;self.utc=i.utc else if not(i.year and i.month)then local n=c('*t')if not i.year and not i.month and not i.day then i.year=n.year;i.month=n.month;i.day=n.day else i.year=i.year or n.year;i.month=i.month or(i.day and n.month or 1)i.day=i.day or 1 end end;i.day=i.day or 1;j=b(i)end else error("bad type for Date constructor: "..type(i),2)end;self:set(j)end;function h:set(i)self.time=i;if self.utc then self.tab=c('!*t',i)else self.tab=c('*t',i)end end;function h.tzone(o)if o==nil then o=b()elseif type(o)=="table"then if getmetatable(o)==h then o=o.time else o=h(o).time end end;local p=c('!*t',o)local q=c('*t',o)q.isdst=false;return os.difftime(b(q),b(p))end;function h:toUTC()local r=h(self)if not self.utc then r.utc=true;r:set(r.time)end;return r end;function h:toLocal()local r=h(self)if self.utc then r.utc=false;r:set(r.time)end;return r end;for s,t in ipairs{'year','month','day','hour','min','sec','yday'}do h[t]=function(self,u)if u then f(1,u,"number")self.tab[t]=u;self:set(b(self.tab))return self else return self.tab[t]end end end;function h:weekday_name(v)return c(v and'%A'or'%a',self.time)end;function h:month_name(v)return c(v and'%B'or'%b',self.time)end;function h:is_weekend()return self.tab.wday==1 or self.tab.wday==7 end;function h:add(i)local w=self.tab.isdst;local x,u=next(i)self.tab[x]=self.tab[x]+u;self:set(b(self.tab))if w~=self.tab.isdst then self.tab.hour=self.tab.hour-(w and 1 or-1)self:set(b(self.tab))end;return self end;function h:last_day()local y=28;local z=self.tab.month;while self.tab.month==z do y=y+1;self:add{day=1}end;self:add{day=-1}return self end;function h:diff(A)local B=self.time-A.time;if B<0 then error("date difference is negative!",2)end;return h.Interval(B)end;function h:__tostring()local C='%Y-%m-%dT%H:%M:%S'if self.utc then C="!"..C end;local i=c(C,self.time)if self.utc then return i..'Z'else local D=self:tzone()if D==0 then return i..'Z'end;local E=D>0 and'+'or'-'local F=math.ceil(D/3600)local z=D%3600/60;if z==0 then return i..('%s%02d'):format(E,F)else return i..('%s%02d:%02d'):format(E,F,z)end end end;function h:__eq(A)return self.time==A.time end;function h:__lt(A)return self.time1 then return's 'else return' 'end end;function h.Interval:__tostring()local i,J=self.tab,''local K,z,y=i.year-1970,i.month-1,i.day-1;if K>0 then J=J..K..' year'..H(K)end;if z>0 then J=J..z..' month'..H(z)end;if y>0 then J=J..y..' day'..H(y)end;if K==0 and z==0 then local F=i.hour;if F>0 then J=J..F..' hour'..H(F)end;if i.min>0 then J=J..i.min..' min 'end;if i.sec>0 then J=J..i.sec..' sec 'end end;if J==''then J='zero'end;return J end;local L={d={'day',{true,true}},y={'year',{false,true,false,true}},m={'month',{true,true}},H={'hour',{true,true}},M={'min',{true,true}},S={'sec',{true,true}}}function h.Format:_init(C)if not C then self.fmt='%Y-%m-%d %H:%M:%S'self.outf=self.fmt;self.plain=true;return end;local M=table.insert;local N,O,P,Q='\001','\002','\003','\004'local R,S={},{}local T,U={},{}local V=1;while V<#C do local W=C:sub(V,V)local X=L[W]if X then if S[W]then error("field appeared twice: "..W,4)end;S[W]=true;local s,Y=C:find(W..'+',V+1)local Z=not s and 1 or Y-V+1;if not X[2][Z]then error("wrong number of fields: "..W,4)end;local _=Z==1 and N..O or N:rep(Z)M(T,P.._..Q)M(R,W)if W=='y'then M(U,Z==2 and'%y'or'%Y')else M(U,'%'..W)end;V=V+Z else M(T,W)M(U,W)V=V+1 end end;C=e.escape(table.concat(T))C=C:gsub(N,'%%d'):gsub(O,'+'):gsub(P,'('):gsub(Q,')')self.fmt=C;self.outf=table.concat(U)self.vars=R end;local a0;function h.Format:parse(a1)g(1,a1)if self.plain then return a0(a1,self.us)end;local J={a1:match(self.fmt)}if#J==0 then return nil,'cannot parse '..a1 end;local a2={}for V,a3 in ipairs(self.vars)do local a4=L[a3][1]a2[a4]=tonumber(J[V])end;if not(a2.year and a2.month and a2.day)then local a5=h()a2.year=a2.year or a5:year()a2.month=a2.month or a5:month()a2.day=a2.day or a5:day()end;local a6=a2.year;if a6<100 then a2.year=a6+(a6<35 and 2000 or 1999)elseif not a6 then a2.year=1970 end;return h(a2)end;function h.Format:tostring(y)local a7;local C=self.outf;if type(y)=='number'then a7=y else a7=y.time;if y.utc then C='!'..C end end;return c(C,a7)end;function h.Format:US_order(a8)self.us=a8 end;local a9;local aa;local function ab()local ac,ad=aa'2000-12-31',{day=1}a9={}for V=1,12 do ac=ac:last_day()ac:add(ad)local ae=ac:month_name():lower()a9[ae]=V end end;local function af(ag)return ag:match'^%a+,*$'~=nil end;local ah=d.isdigit;local function ai(aj,ak,al,am)am=am or''local I=tonumber(aj)if not I then error(("%snot a number: '%s'"):format(am,aj))end;if Ial then error(("%s out of range: %s is not between %d and %d"):format(am,aj,ak,al))end;return I end;local function an(_,ao,ap)local s,aq,ar=_:find('^%.%d+',ao+1)if ar then ap=ap..ar;_=_:sub(aq+1)else _=_:sub(ao+1)end;if _:match'z$'then return ap,{h=0,m=0}end;_=_:gsub(':','')local s,s,E,D=_:find('^([%+%-])(%d+)')if not E then return ap,nil end;if#D==2 then D=D..'00'end;local as={h=tonumber(D:sub(1,2)),m=tonumber(D:sub(3,4))}if E=='-'then as.h=-as.h;as.m=-as.m end;return ap,as end;function aa(aj,at)aj=aj:gsub('T',' ')local au=d.split(aj:lower())local V,_=1,au[1]local function av()V=V+1;_=au[V]end;local m,aw,ax,ap,ay;local as;local s,az,aA,aB=_:find'^(%d+)/(%d+)'if aA then if at then aA,aB=aB,aA end;s,s,m=_:find('^/(%d+)',az+1)av()else m,aB,aA=_:match('^(%d+)%-(%d+)%-(%d+)')if m then av()end end;if _ and not m and ah(_)then if#_<4 then aA=_;av()else m=true end end;if _ and af(_)then _=_:sub(1,3)if not a9 then ab()end;local ae=a9[_]if ae then aB=ae else error("not a month: ".._)end;av()end;if _ and not m and ah(_)then m=_;av()end;if _ then s,az,ax,aw=_:find'^(%d+):(%d+)'local ao;if az then s,ao,ap=_:find('^:(%d+)',az+1)ap,as=an(_,ao or az,ap)else s,ao,ax,aw=_:find'^(%d+)%.(%d+)'if ao then ay=_:match'[ap]m$'else local aC;s,az,aC=_:find('^(%d+)')if az then ax=aC:sub(1,2)aw=aC:sub(3,4)ap=aC:sub(5,6)if#ap==0 then ap=nil end;ap,as=an(_,az,ap)end end end end;local a5;if m==true then m=nil end;if not(m and aB and aA)then a5=h()end;aA=aA and ai(aA,1,31,'day')or(aB and 1 or a5:day())aB=aB and ai(aB,1,12,'month')or a5:month()m=m and tonumber(m)or a5:year()if m<100 then m=m+(m<35 and 2000 or 1900)end;ax=ax and ai(ax,0,ay and 12 or 24,'hour')or 12;if ay=='pm'then ax=ax+12 end;aw=aw and ai(aw,0,59)or 0;ap=ap and ai(ap,0,60)or 0;local J=h{year=m,month=aB,day=aA,hour=ax,min=aw,sec=ap}if as then local aD=false;if as.h~=0 then J:add{hour=-as.h}aD=true end;if as.m~=0 then J:add{min=-as.m}aD=true end;J.utc=true;if aD then J=J:toLocal()end end;return J end;function a0(aj)local aE,y=pcall(aa,aj)if not aE then y=y:gsub('.-:%d+: ','')return nil,y else return y end end;return h diff --git a/extern/lualibs/pl/List.lua b/extern/lualibs/pl/List.lua new file mode 100644 index 00000000..706f733b --- /dev/null +++ b/extern/lualibs/pl/List.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/List.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a,b,c,d=table.insert,table.remove,table.concat,table.sort;local setmetatable,getmetatable,type,tostring,string=setmetatable,getmetatable,type,tostring,string;local e=require'pl.tablex'local f,g,h,i,j,k=e.filter,e.imap,e.imap2,e.reduce,e.transform,e.removevalues;local l=e.sub;local m=require'pl.utils'local n=require'pl.class'local o,p,q,r=m.array_tostring,m.split,m.assert_arg,m.function_arg;local s=e._normalize_slice;local t=m.stdmt.MultiMap;local u=m.stdmt.List;local v;n(nil,nil,u)local function w(x,y)local z=u;if y then z=getmetatable(y)end;return setmetatable(x,z)end;local function A(x)return type(x)=='table'and not getmetatable(x)and#x>0 end;function u._create(B)if A(B)then return B end end;function u:_init(B)if self==B then return end;if B then for C in v(B)do a(self,C)end end end;u.new=u;function u:clone()local D=w({},self)D:extend(self)return D end;function u:append(E)a(self,E)return self end;u.push=a;function u:extend(F)q(1,F,'table')for E=1,#F do a(self,F[E])end;return self end;function u:insert(E,G)q(1,E,'number')a(self,E,G)return self end;function u:put(G)return self:insert(1,G)end;function u:remove(E)q(1,E,'number')b(self,E)return self end;function u:remove_value(G)for E=1,#self do if self[E]==G then b(self,E)return self end end;return self end;function u:pop(E)if not E then E=#self end;q(1,E,'number')return b(self,E)end;u.get=u.pop;local H=e.find;u.index=H;function u:contains(G)return H(self,G)and true or false end;function u:count(G)local I=0;for E=1,#self do if self[E]==G then I=I+1 end end;return I end;function u:sort(J)if J then J=r(1,J)end;d(self,J)return self end;function u:sorted(J)return u(self):sort(J)end;function u:reverse()local x=self;local K=#x;for E=1,K/2 do x[E],x[K]=x[K],x[E]K=K-1 end;return self end;function u:minmax()local L,M=1e70,-1e70;for E=1,#self do local C=self[E]if CM then M=C end end;return L,M end;function u:slice(N,O)return l(self,N,O)end;function u:clear()for E=1,#self do b(self)end;return self end;local P=1.0e-10;function u.range(Q,R,S)if not R then R=Q;Q=1 end;if S then q(3,S,'number')if math.ceil(S)~=S then R=R+P end else S=1 end;q(1,Q,'number')q(2,R,'number')local x=u()for E=Q,R,S do a(x,E)end;return x end;function u:len()return#self end;function u:chop(T,U)return k(self,T,U)end;function u:splice(V,W)q(1,V,'number')V=V-1;local E=1;for C in v(W)do a(self,E+V,C)E=E+1 end;return self end;function u:slice_assign(T,U,X)q(1,T,'number')q(1,U,'number')T,U=s(self,T,U)if U>=T then self:chop(T,U)end;self:splice(T,X)return self end;function u:__concat(F)q(1,F,'table')local D=self:clone()D:extend(F)return D end;function u:__eq(F)if#self~=#F then return false end;for E=1,#self do if self[E]~=F[E]then return false end end;return true end;function u:join(Y)Y=Y or''q(1,Y,'string')return c(o(self),Y)end;u.concat=c;local function Z(_)local a0=tostring(_)if type(_)=='string'then a0='"'..a0 ..'"'end;return a0 end;function u:__tostring()return'{'..self:join(',',Z)..'}'end;function u:foreach(a1,...)a1=r(1,a1)for E=1,#self do a1(self[E],...)end end;local function a2(y,a3)local a4=y[a3]if not a4 then error(type(y).." does not have method "..a3,3)end;return a4 end;function u:foreachm(a3,...)for E=1,#self do local y=self[E]local a4=a2(y,a3)a4(y,...)end end;function u:filter(a1,a5)return w(f(self,a1,a5),self)end;function u.split(a0,Y)q(1,a0,'string')return w(p(a0,Y))end;function u:map(a1,...)return w(g(a1,self,...),self)end;function u:transform(a1,...)j(a1,self,...)return self end;function u:map2(a1,D,...)return w(h(a1,self,D,...),self)end;function u:mapm(a3,...)local a6={}for E=1,#self do local _=self[E]local a7=a2(_,a3)a6[E]=a7(_,...)end;return w(a6,self)end;local function a8(a9,a4)return function(self,...)return self[a9](self,a4,...)end end;function u.default_map_with(aa)return function(self,a3)local ab;if aa then local a4=a2(aa,a3)ab=a8('map',a4)else ab=a8('mapn',a3)end;getmetatable(self)[a3]=ab;return ab end end;u.default_map=u.default_map_with;function u:reduce(a1)return i(a1,self)end;function u:partition(a1,...)a1=r(1,a1)local a6={}for E=1,#self do local _=self[E]local z=a1(_,...)if z==nil then z=''end;if not a6[z]then a6[z]=u()end;a6[z]:append(_)end;return setmetatable(a6,t)end;function u:iter()return v(self)end;function u.iterate(X)if type(X)=='string'then local V=0;local K=#X;local ac=string.sub;return function()V=V+1;if V>K then return nil else return ac(X,V,V)end end elseif type(X)=='table'then local V=0;local K=#X;return function()V=V+1;if V>K then return nil else return X[V]end end elseif type(X)=='function'then return X elseif type(X)=='userdata'and io.type(X)=='file'then return X:lines()end end;v=u.iterate;return u diff --git a/extern/lualibs/pl/Map.lua b/extern/lualibs/pl/Map.lua new file mode 100644 index 00000000..e1dbc5a5 --- /dev/null +++ b/extern/lualibs/pl/Map.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/Map.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a=require'pl.tablex'local b=require'pl.utils'local c=b.stdmt;local d=a.deepcompare;local e=require'pl.pretty'.write;local f=c.Map;local g=c.Set;local h=require'pl.class'h(nil,nil,f)function f:_init(i)local j=getmetatable(i)if j==g or j==f then self:update(i)else return i end end;local function k(i)return setmetatable(i,require('pl.List'))end;f.keys=a.keys;f.values=a.values;function f:iter()return pairs(self)end;function f:items()local l=k(a.pairmap(function(m,n)return k{m,n}end,self))l:sort(function(o,p)return o[1]0 then if type(j[1])=='table'then for q,r in ipairs(j)do local s,t=next(r)if not s then return n'empty pair initialization table'end;self:set(s,t)end else return n'cannot use an array to initialize an OrderedMap'end else for o,p in pairs(j)do self:set(o,p)end end;return self end;function i:set(s,u)if rawget(self,s)==nil and u~=nil then self._keys:append(s)rawset(self,s,u)else if u==nil then self._keys:remove_value(s)rawset(self,s,nil)else self[s]=u end end;return self end;i.__newindex=i.set;function i:insert(v,s,u)local w=self[s]u=u or w;if w then self._keys:remove_value(s)end;if u then self._keys:insert(v,s)rawset(self,s,u)end;return self end;function i:keys()return self._keys end;function i:values()return c(d(self,self._keys))end;function i:sort(x)e(self._keys,x)return self end;function i:iter()local y=0;local z=self._keys;local A;return function()y=y+1;if y>#z then return nil end;A=z[y]return A,self[A]end end;i.__pairs=i.iter;function i:__tostring()local B={}for y,p in ipairs(self._keys)do local u=self[p]local C=tostring(u)if type(u)~='number'then C='"'..C..'"'end;B[y]=tostring(p)..'='..C end;return'{'..f(B,',')..'}'end;return i diff --git a/extern/lualibs/pl/Set.lua b/extern/lualibs/pl/Set.lua new file mode 100644 index 00000000..b69bd969 --- /dev/null +++ b/extern/lualibs/pl/Set.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/Set.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a=require'pl.tablex'local b=require'pl.utils'local c,d=b.array_tostring,table.concat;local e,f=a.merge,a.difference;local g=require'pl.Map'local h=require'pl.class'local i=b.stdmt;local j=i.Set;h(g,nil,j)j.__index=nil;local function k(l)return setmetatable(l,j)end;function j:_init(l)l=l or{}local m=getmetatable(l)if m==j or m==g then for n in pairs(l)do self[n]=true end else for o,p in ipairs(l)do self[p]=true end end end;function j:__tostring()return'['..d(c(j.values(self)),',')..']'end;j.values=g.keys;function j.map(self,q,...)q=b.function_arg(1,q)local r={}for n in pairs(self)do r[q(n,...)]=true end;return k(r)end;function j.union(self,s)return e(self,s,true)end;local function t(self,u)local m=getmetatable(u)if m==j or m==g then return j.union(self,u)else local v=j(self)v[u]=true;return v end end;j.__add=t;function j.intersection(self,s)return e(self,s,false)end;j.__mul=j.intersection;function j.difference(self,s)return f(self,s,false)end;local function w(self,u)local m=getmetatable(u)if m==j or m==g then return j.difference(self,u)else local v=j(self)v[u]=nil;return v end end;j.__sub=w;function j.symmetric_difference(self,s)return f(self,s,true)end;j.__pow=j.symmetric_difference;function j.issubset(self,s)for n in pairs(self)do if not s[n]then return false end end;return true end;j.__lt=j.issubset;function j.isempty(self)return next(self)==nil end;function j.isdisjoint(x,y)return j.isempty(j.intersection(x,y))end;j.len=a.size;j.__len=j.len;function j.__eq(x,y)return j.issubset(x,y)and j.issubset(y,x)end;return j diff --git a/extern/lualibs/pl/array2d.lua b/extern/lualibs/pl/array2d.lua new file mode 100644 index 00000000..b872e007 --- /dev/null +++ b/extern/lualibs/pl/array2d.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/array2d.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a,b,c,d,e,f=_G.tonumber,_G.tostring,_G.io,_G.ipairs,_G.string,_G.table;local setmetatable,getmetatable=setmetatable,getmetatable;local g=require'pl.tablex'local h=require'pl.utils'local i=require'pl.types'local j,k,l,m,n,o,p=g.imap,g.map,g.reduce,g.keys,g.map2,g.set,g.index_by;local q=f.remove;local r,s,t=h.splitv,h.fprintf,h.assert_arg;local u=e.byte;local v=c.stdout;local w=math.min;local x={}local function y(z,A)local B=getmetatable(z)if B then setmetatable(A,B)end;return A end;local function C(D)return setmetatable(D,require('pl.List'))end;function x.size(E)t(1,E,'table')return#E,#E[1]end;do local function F(G,H)return G[H]end;function x.column(E,I)t(1,E,'table')return C(j(F,E,I))end end;local J=x.column;function x.row(E,K)t(1,E,'table')local L=E[K]local M={}for N,O in d(L)do M[N]=O end;return C(M)end;function x.map(P,E,Q)t(2,E,'table')P=h.function_arg(1,P)return y(E,j(function(L)return j(P,L,Q)end,E))end;function x.reduce_rows(P,E)t(1,E,'table')return k(function(L)return l(P,L)end,E)end;function x.reduce_cols(P,E)t(1,E,'table')return k(function(R)return l(P,J(E,R))end,m(E[1]))end;function x.reduce2(S,T,E)t(3,E,'table')local U=x.reduce_rows(T,E)return l(S,U)end;function x.map2(P,V,W,E,X,Q)t(1,E,'table')t(2,X,'table')P=h.function_arg(1,P)if V==1 and W==2 then return j(function(L)return n(P,E,L,Q)end,X)elseif V==2 and W==1 then return j(function(L)return n(P,L,X,Q)end,E)elseif V==1 and W==1 then return n(P,E,X)elseif V==2 and W==2 then return n(function(Y,Z)return n(P,Y,Z,Q)end,E,X)end end;function x.product(P,_,a0)P=h.function_arg(1,P)t(2,_,'table')t(3,a0,'table')local D={}for K,O in d(a0)do D[K]=k(P,_,O)end;return D end;function x.flatten(G)local D={}local H=1;local a1,a2=x.size(G)for M=1,a1 do local L=G[M]for R=1,a2 do D[H]=L[R]H=H+1 end end;return C(D)end;function x.reshape(G,a3,a4)local a5,a6=x.size(G)local a7=a5*a6/a3;local D={}local a8,a9=1,1;for K=1,a3 do local L={}for I=1,a7 do L[I]=G[a8][a9]if not a4 then a9=a9+1;if a9>a6 then a8=a8+1;a9=1 end else a8=a8+1;if a8>a5 then a9=a9+1;a8=1 end end end;D[K]=L end;return y(G,D)end;function x.transpose(G)t(1,G,'table')local aa,R=x.size(G)return x.reshape(G,R,true)end;function x.swap_rows(G,ab,ac)t(1,G,'table')G[ab],G[ac]=G[ac],G[ab]return G end;function x.swap_cols(G,ad,ae)t(1,G,'table')for aa,L in d(G)do L[ad],L[ae]=L[ae],L[ad]end;return G end;function x.extract_rows(G,af)return y(G,p(G,af))end;function x.extract_cols(G,ag)t(1,G,'table')local D={}for K=1,#G do D[K]=p(G[K],ag)end;return y(G,D)end;x.remove_row=q;function x.remove_col(G,I)t(1,G,'table')for K=1,#G do q(G[K],I)end end;do local function ah(ai)local M,R=ai:match'R(%d+)C(%d+)'if M then M,R=a(M),a(R)return M,R end;R,M=ai:match'(%a+)(%d+)'if R then local aj=0;for K=1,#R do aj=aj*26+u(R:sub(K,K))-u'A'+1 end;return a(M),aj end;error('bad cell specifier: '..ai)end;function x.parse_range(ai)t(1,ai,'string')ai=ai:upper()if ai:find':'then local ak,al=r(ai,':')local ab,ad=ah(ak)local ac,ae=ah(al)return ab,ad,ac,ae else local K,I=ah(ai)return K,I end end end;function x.range(G,am)t(1,G,'table')return x.slice(G,x.parse_range(am))end;local an;do local function ao(O,ap)if not O then return O end;if O<0 then O=ap+O+1 end;if O<1 then O=1 end;if O>ap then O=ap end;return O end;function x.default_range(G,ab,ad,ac,ae)local a5,a6=x.size(G)ab=ao(ab or 1,a5)ad=ao(ad or 1,a6)ac=ao(ac or a5,a5)ae=ao(ae or a6,a6)return ab,ad,ac,ae end;an=x.default_range end;function x.slice(G,ab,ad,ac,ae)t(1,G,'table')ab,ad,ac,ae=an(G,ab,ad,ac,ae)local D={}for K=ab,ac do local aq;local L=G[K]if ad==ae then aq=L[ad]else aq={}for I=ad,ae do aq[#aq+1]=L[I]end end;D[#D+1]=aq end;if ab==ac then D=D[1]end;return y(G,D)end;function x.set(G,ar,ab,ad,ac,ae)ab,ad,ac,ae=an(G,ab,ad,ac,ae)local K=ab;if i.is_callable(ar)then local as=ar;ar=function(I)return as(K,I)end end;while K<=ac do o(G[K],ar,ad,ae)K=K+1 end end;function x.write(G,P,at,ab,ad,ac,ae)t(1,G,'table')P=P or v;local au;if at then au=function(L,I)s(P,at,L[I])end else au=function(L,I)P:write(b(L[I]),' ')end end;local function av()P:write'\n'end;x.forall(G,au,av,ab,ad,ac,ae)end;function x.forall(G,aw,ax,ab,ad,ac,ae)t(1,G,'table')ab,ad,ac,ae=an(G,ab,ad,ac,ae)for K=ab,ac do local L=G[K]for I=ad,ae do aw(L,I)end;if ax then ax(K)end end end;function x.move(ay,az,aA,aB,ab,ad,ac,ae)t(1,ay,'table')t(4,aB,'table')ab,ad,ac,ae=an(aB,ab,ad,ac,ae)local a5,a6=x.size(ay)ac,ae=w(a5,ac),w(a6,ae)aA=aA-1;for K=ab,ac do local aC,aD=ay[K+az-1],aB[K]for I=ad,ae do aC[I+aA]=aD[I]end end end;function x.iter(E,aE,ab,ad,ac,ae)t(1,E,'table')ab,ad,ac,ae=an(E,ab,ad,ac,ae)local K,I=ab,ad-1;local L=E[K]return function()I=I+1;if I>ae then I=ad;K=K+1;L=E[K]if K>ac then return nil end end;if aE then return K,I,L[I]else return L[I]end end end;function x.columns(E)t(1,E,'table')local N=#E[1]local K=0;return function()K=K+1;if K>N then return nil end;return J(E,K),K end end;function x.rows(E)t(1,E,'table')local N=#E;local K=0;return function()K=K+1;if K>N then return nil end;return x.row(E,K),K end end;function x.new(a1,a2,aq)local D={}local aF=i.is_callable(aq)for K=1,a1 do local L={}if aF then for I=1,a2 do L[I]=aq(K,I)end else for I=1,a2 do L[I]=aq end end;D[K]=L end;return D end;return x diff --git a/extern/lualibs/pl/class.lua b/extern/lualibs/pl/class.lua new file mode 100644 index 00000000..16bcbcd2 --- /dev/null +++ b/extern/lualibs/pl/class.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/class.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a,b,c,d,e,f,g,h,i=_G.error,_G.getmetatable,_G.io,_G.pairs,_G.rawget,_G.rawset,_G.setmetatable,_G.tostring,_G.type;local j;local function k(l,m,...)local n=e(l,'_init')local o=e(l,'_parent_with_init')if o then if not n then n=e(o,'_init')o=e(o,'_parent_with_init')end;if o then f(m,'super',function(m,...)k(o,m,...)end)end else f(m,'super',nil)end;local p=n(m,...)if o then f(m,'super',nil)end;return p end;local function q(self,r)if r==nil then return b(self)end;local s=b(self)if not s then return false end;while s do if s==r then return true end;s=e(s,'_base')end;return false end;local function t(r,m)if i(r)~='table'or not e(r,'is_a')then return false end;return r.is_a(m,r)end;local function u(r,m)return g(m,r)end;local function v(m)local w=m._class;local x=e(w,'_name')g(m,nil)local y=h(m)g(m,w)if x then y=x..y:gsub('table','')end;return y end;local function z(A,B,C)for D,E in d(B)do if not C or A[D]==nil then A[D]=E end end end;local function F(G,H,l)local w={}local I=i(G)=='table'and not b(G)if I then l=G;G=l._base else l=l or{}end;if i(G)=='table'then z(l,G,I)l._base=G;if e(l,'_handler')then w.__index=l._handler end elseif G~=nil then a("must derive from a table type",3)end;l.__index=l;g(l,w)if not I then if G and e(G,'_init')then l._parent_with_init=G end;l._init=nil end;if G and e(G,'_class_init')then G._class_init(l,H)end;w.__call=function(J,...)local m;if e(l,'_create')then m=l._create(...)end;if not m then m={}end;g(m,l)if e(l,'_init')or e(l,'_parent_with_init')then local p=k(l,m,...)if p then m=p;g(m,l)end end;if G and e(G,'_post_init')then G._post_init(m)end;return m end;l.catch=function(self,K)if i(self)=="function"then K=self end;l._handler=K;w.__index=K end;l.is_a=q;l.class_of=t;l.cast=u;l._class=l;if not e(l,'__tostring')then l.__tostring=v end;return l end;local L;L=g({},{__call=function(M,...)return F(...)end,__index=function(N,O)if O=='class'then c.stderr:write('require("pl.class").class is deprecated. Use require("pl.class")\n')return L end;j=j or require'pl.compat'local P=j.getfenv(2)return function(...)local l=F(...)l._name=O;f(P,O,l)return l end end})L.properties=L()function L.properties._class_init(r)r.__index=function(Q,O)local E=r[O]if E then return E end;E=e(r,'get_'..O)if E then return E(Q)end;return e(Q,'_'..O)end;r.__newindex=function(Q,O,R)local S='set_'..O;local T=r[S]if T then T(Q,R)else f(Q,O,R)end end end;return L diff --git a/extern/lualibs/pl/compat.lua b/extern/lualibs/pl/compat.lua new file mode 100644 index 00000000..10202b8e --- /dev/null +++ b/extern/lualibs/pl/compat.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/compat.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a={}a.lua51=_VERSION=='Lua 5.1'a.jit=tostring(assert):match('builtin')~=nil;if a.jit then a.jit52=not loadstring("local goto = 1")end;a.dir_separator=_G.package.config:sub(1,1)a.is_windows=a.dir_separator=='\\'function a.execute(b)local c,d,e=os.execute(b)if d=="No error"and e==0 and a.is_windows then e=-1 end;if a.lua51 and not a.jit52 then if a.is_windows then return c==0,c else c=c>255 and c/256 or c;return c==0,c end else if a.is_windows then return e==0,e else return not not c,e end end end;if a.lua51 then if not a.jit then local f=load;function a.load(g,h,i,j)local k,l;if type(g)=='string'then if g:byte(1)==27 and not(i or'bt'):find'b'then return nil,"attempt to load a binary chunk"end;k,l=loadstring(g,h)else k,l=f(g,h)end;if k and j then setfenv(k,j)end;return k,l end else a.load=load end;a.setfenv,a.getfenv=setfenv,getfenv else a.load=load;function a.setfenv(m,n)m=type(m)=='function'and m or debug.getinfo(m+1,'f').func;local o;local p=0;repeat p=p+1;o=debug.getupvalue(m,p)until o=='_ENV'or o==nil;if o then debug.upvaluejoin(m,p,function()return o end,1)debug.setupvalue(m,p,n)end;if m~=0 then return m end end;function a.getfenv(m)local m=m or 0;m=type(m)=='function'and m or debug.getinfo(m+1,'f').func;local o,q;local p=0;repeat p=p+1;o,q=debug.getupvalue(m,p)until o=='_ENV'or o==nil;return q end end;if not table.pack then function table.pack(...)return{n=select('#',...),...}end end;if not table.unpack then table.unpack=unpack end;if not package.searchpath then function package.searchpath(o,r,s,t)if type(o)~="string"then error(("bad argument #1 to 'searchpath' (string expected, got %s)"):format(type(r)),2)end;if type(r)~="string"then error(("bad argument #2 to 'searchpath' (string expected, got %s)"):format(type(r)),2)end;if s~=nil and type(s)~="string"then error(("bad argument #3 to 'searchpath' (string expected, got %s)"):format(type(r)),2)end;if t~=nil and type(t)~="string"then error(("bad argument #4 to 'searchpath' (string expected, got %s)"):format(type(r)),2)end;s=s or"."t=t or a.dir_separator;do local u,v=o:find(s,nil,true)while u do o=o:sub(1,u-1)..t..o:sub(v+1,-1)u,v=o:find(s,u+#t+1,true)end end;local w={}for x in r:gmatch('[^;]+')do local y=x:gsub('?',o)w[#w+1]=y;local m=io.open(y,'r')if m then m:close()return y end end;return nil,"\tno file '"..table.concat(w,"'\n\tno file '").."'"end end;if not warn then local z=false;function warn(A,...)if type(A)=="string"and A:sub(1,1)=="@"then if A=="@on"then z=true;return end;if A=="@off"then z=false;return end;return end;if z then io.stderr:write("Lua warning: ",A,...)io.stderr:write("\n")end end end;return a diff --git a/extern/lualibs/pl/comprehension.lua b/extern/lualibs/pl/comprehension.lua new file mode 100644 index 00000000..a6cab896 --- /dev/null +++ b/extern/lualibs/pl/comprehension.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/comprehension.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a=require'pl.utils'local b,c=pcall(require,"pl.luabalanced")if not b then c=require'luabalanced'end;local d=math.max;local e=table.concat;local f={list={init=' {} ',accum=' __result[#__result+1] = (%s) '},table={init=' {} ',accum=' local __k, __v = %s __result[__k] = __v '},sum={init=' 0 ',accum=' __result = __result + (%s) '},min={init=' nil ',accum=' local __tmp = %s '..' if __result then if __tmp < __result then '..'__result = __tmp end else __result = __tmp end '},max={init=' nil ',accum=' local __tmp = %s '..' if __result then if __tmp > __result then '..'__result = __tmp end else __result = __tmp end '}}local function g(h)local i=1;local j;local k,l=h:match('^%s*([%a_][%w_]*)%s*%(()',i)local m=#h+1;if k then local n,o=c.match_bracketed(h,l-1)assert(n,'syntax error')if h:match('^%s*$',o)then j=k;m=o-1;i=l end end;j=j or"list"local p;p,i=c.match_explist(h,i)assert(p,"syntax error: missing expression list")p=e(p,', ')local q={}local r={}local s={}while 1 do local l=h:match('^%s*for%s+()',i)if not l then break end;i=l;local t;t,i=c.match_namelist(h,i)assert(#t>0,'syntax error: zero variables')for u,v in ipairs(t)do assert(not v:match'^__',"identifier "..v.." may not contain __ prefix")end;r[#r+1]=t;local w,l=h:match('^(=)%s*()',i)if not w then w,l=h:match('^(in)%s+()',i)end;if w then i=l;local x;x,i=c.match_explist(h,i)assert(#x>0,'syntax error: zero expressions')assert(w~='='or#x==2 or#x==3,'syntax error: numeric for requires 2 or three expressions')q[#r]=w;s[#r]=x else q[#r]=false;s[#r]=false end end;assert(#r>0,'syntax error: missing "for" clause')local y={}while 1 do local l=h:match('^%s*if%s+()',i)if not l then break end;i=l;local z;z,i=c.match_expression(h,i)assert(z,'syntax error: predicated expression not found')y[#y+1]=z end;local A=''c.gsub(h,function(B,C)if B=='e'then A=A..' '..C..' 'end end)local D=0;A:gsub('[%a_][%w_]*',function(E)local E=E:match('^_(%d+)$')if E then D=d(D,tonumber(E))end end)if i~=m then assert(false,"syntax error: unrecognized "..h:sub(i))end;return p,q,r,s,y,j,D end;local function F(p,q,r,s,y,j,D)local G=assert(f[j])local H=G.accum:gsub('%%s',p)for I=#y,1,-1 do local z=y[I]H=' if '..z..' then '..H..' end 'end;for I=#r,1,-1 do if not q[I]then local J='__in'..I;local K='__idx'..I;H=' for '..K..' = 1, #'..J..' do '..' local '..r[I][1]..' = '..J..'['..K..'] '..H..' end 'else H=' for '..e(r[I],', ')..' '..q[I]..' '..e(s[I],', ')..' do '..H..' end 'end end;H=' local __result = ( '..G.init..' ) '..H;return H end;local function L(H,M,D,s,N)assert(M>0)local O={}for I=1,D do O[#O+1]='_'..I end;for I=1,M do if not s[I]then local P='__in'..I;O[#O+1]=P end end;if#O>0 then H=' local '..e(O,', ')..' = ... '..H end;H=H..' return __result 'local Q,R=a.load(H,'tmp','t',N)if not Q then assert(false,R..' with generated code '..H)end;return Q end;local function S(h,N)local p,q,r,s,y,j,D=g(h)local H=F(p,q,r,s,y,j,D)local Q=L(H,#r,D,s,N)return Q end;local function T(N)if not N then N=a.getfenv(2)end;local U={}local V=setmetatable({},U)function U:__index(h)local Q=S(h,N)self[h]=Q;return Q end;U.__call=U.__index;V.new=T;return V end;local W={}W.new=T;return W diff --git a/extern/lualibs/pl/config.lua b/extern/lualibs/pl/config.lua new file mode 100644 index 00000000..48db31d2 --- /dev/null +++ b/extern/lualibs/pl/config.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/config.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a,b,c,d,e=_G.type,_G.tonumber,_G.ipairs,_G.io,_G.table;local function f(g,h)local i={}local j=e.insert;h='[^'..h..']+'for k in g:gmatch(h)do j(i,k)end;return i end;local function l(g)return g:gsub('^%s+',''):gsub('%s+$','')end;local function m(g)return g:gsub("['\"](.*)['\"]",'%1')end;local n={}function n.lines(o)local p,q,r;local s=''if a(o)=='string'then p,r=d.open(o,'r')if not p then return nil,r end;q=true else p=o or d.stdin;if not o.read then return nil,'not a file-like object'end end;if not p then return nil,'file is nil'end;return function()local t=p:read()while t do if t:match'%S'and not t:match'^%s*[;#]'then local u=t:find'\\%s*$'if u then s=s..t:sub(1,u-1)elseif s==''then return t else t=s..t;s=''return t end end;t=p:read()end;if q then p:close()end end end;function n.read(o,v)local w;local x,r=n.lines(o)if not x then return nil,r end;local s=x()v=v or{}if v.smart then w=true;if s:match'^[^=]+='then v.keysep='='elseif s:match'^[^:]+:'then v.keysep=':'v.list_delim=':'elseif s:match'^%S+%s+'then v.keysep=' 'if s:match'^%S+%s+%S+%s+%S+'then v.list_delim=' 'end;v.variabilize=false end end;local function y(z,A)local B=v[z]if B==nil then return A else return B end end;local C='^[%d%+%-]'local D={}local E=D;local F=y('variabilize',true)local G=y('list_delim',',')local H=y('convert_numbers',true)local I=y('convert_boolean',false)local J=y('trim_space',true)local K=y('trim_quotes',false)local L=y('ignore_assign',false)local M=y('keysep','=')local N=M==' 'and'%s+'or'%s*'..M..'%s*'if G==' 'then G='%s+'end;local function O(P)if F then P=P:gsub('[^%w]','_')end;return P end;local function Q(R)if G and R:find(G)then R=f(R,G)for u,S in c(R)do R[u]=Q(S)end elseif H and R:find(C)then local B=b(R)if not B and R:match' kB$'then R=R:gsub(' kB','')B=b(R)end;if B then R=B end elseif I and R=='true'then return true elseif I and R=='false'then return false end;if a(R)=='string'then if J then R=l(R)end;if not K and w and R:match'^"'then K=true end;if K then R=m(R)end end;return R end;while s do if s:find('^%[')then local T=O(s:match('%[([^%]]+)%]'))D=E;D[T]={}D=D[T]else s=s:gsub('^%s*','')local U,V=s:find(N)if U and not L then local P=O(s:sub(1,U-1))local R=Q(s:sub(V+1))D[P]=R else D[#D+1]=Q(s)end end;s=x()end;return E end;return n diff --git a/extern/lualibs/pl/data.lua b/extern/lualibs/pl/data.lua new file mode 100644 index 00000000..027d5069 --- /dev/null +++ b/extern/lualibs/pl/data.lua @@ -0,0 +1,41 @@ +-- Penlight 1.11.0-1 | /lua/pl/data.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a=require'pl.utils'local b=rawget(_G,'_DEBUG')local c,d,e,f=a.patterns,a.function_arg,a.split,a.array_tostring;local g,h=table.insert,table.concat;local i=string.gsub;local io=io;local _G,print,type,tonumber,ipairs,setmetatable=_G,print,type,tonumber,ipairs,setmetatable;local j={}local k;local function l(m)return m:gsub('%s+$','')end;local function n(m)return l(m):gsub('^%s*','')end;local function o(p)return setmetatable(p,require('pl.List'))end;local function q(r,s)local t={}for u=1,#s do t[u]=r(s[u])end;return t end;local function v(w,x,y,z)local A;if y and w:match'"'then w=w:gsub('"([^"]+)"',function(B)local m,C=B:gsub(',','\001')if C>0 then A=true end;return m end)if A then A=function(m)return m:gsub('\001',',')end end end;local t=e(w,x,false,z)if y then if A then t=q(A,t)end;if w:match',$'then g(t,'')end end;return o(t)end;local function D(s,E)for u=1,#s do if E==s[u]then return u end end end;local F={column_by_name=function(self,G)if type(G)=='number'then G='$'..G end;local H={}for t in j.query(self,G)do g(H,t)end;return o(H)end,copy_select=function(self,I)I=k(I,self)local J=j.query(self,I)local t={}local K=o{J()}while#K>0 do g(t,K)K=o{J()}end;t.delim=self.delim;return j.new(t,v(I.fields,','))end,column_names=function(self)return self.fieldnames end}local L;F.__index=function(self,G)local M=F[G]if M then return M end;if not L then L=require'pl.array2d'end;return L[G]end;local N={',','\t',' ',';'}local function O(w)if w==''then return' 'end;for P,x in ipairs(N)do if w:find(x)then return x==' 'and'%s+'or x end end;return' 'end;local function Q(M,R)local S,T;local U=R=='r'if type(M)=='string'then if M=='stdin'then M=io.stdin elseif M=='stdout'then M=io.stdout else M,T=io.open(M,R)if not M then return nil,T end;S=true end end;if M and(U and not M.read or not U and not M.write)then return nil,"not a file-like object"end;return M,nil,S end;function j.read(V,W)local X,w;local Y={}if not W then W={}end;local M,T,S=Q(V,'r')if not M then return nil,T end;local Z=W.thousands_dot;local y=W.csv;if y then W.delim=','end;local tonumber=tonumber;local function _(a0)if Z then a0=a0:gsub('%.(...)','%1')end;if y and a0==''then a0='0'end;local E=tonumber(a0)if E==nil then return nil,"not a number"end;return E end;X=1;w=M:read()if not w then return nil,"empty file"end;Y.delim=W.delim and W.delim or O(w)local x=Y.delim;local a1;local a2={}local function a3(a4,a5)a1=a1 or{}g(a2,a4)g(a1,a5)end;if W.numfields then for P,z in ipairs(W.numfields)do a3(z,_)end end;local a6;if x=='%s+'and w:find(x)==1 then a6=function(m)return m:gsub('^%s+','')end;w=a6(w)end;if not W.fieldnames then local a7,a8;a7=v(w,x,y)if not W.convert then a8=q(tonumber,a7)if#a8==#a7 then g(Y,a8)for u=1,#a8 do a3(u,_)end else a8=nil end else for a4,a5 in pairs(W.convert)do a3(a4,a5)end end;if a8==nil then W.fieldnames=a7 end;w=M:read()X=X+1;if a6 then w=a6(w)end elseif type(W.fieldnames)=='string'then W.fieldnames=v(W.fieldnames,x,y)end;local a9;if W.fieldnames then Y.fieldnames=W.fieldnames;if W.last_field_collect then a9=#Y.fieldnames end;if not W.no_convert then local a7=v(w,Y.delim,y,a9)for u=1,#a7 do if not D(a2,u)and _(a7[u])then a3(u,_)end end end end;while w do if not w:find('^%s*$')then if a6 then w=a6(w)end;local a7=v(w,x,y,a9)if a1 then for aa=1,#a2 do local u,a5=a2[aa],a1[aa]local ab,T=a5(a7[u])if ab==nil then return nil,T..": "..a7[u].." at line "..X else a7[u]=ab end end end;g(Y,a7)end;w=M:read()X=X+1 end;if S then M:close()end;if x=='%s+'then Y.delim=' 'end;if not Y.fieldnames then Y.fieldnames={}end;return j.new(Y)end;local function ac(j,M,K,x)j.temp=f(K,j.temp)M:write(h(j.temp,x),'\n')end;function F:write_row(M,K)ac(self,M,K,self.delim)end;function j.write(j,V,ad,x)local M,T,S=Q(V,'w')if not M then return nil,T end;if not ad then ad=j.fieldnames end;x=x or'\t'if ad and#ad>0 then M:write(h(ad,x),'\n')end;for u=1,#j do ac(j,M,j[u],x)end;if S then M:close()end;return true end;function F:write(V)j.write(self,V,self.fieldnames,self.delim)end;local function ae(a7,af)for u=1,#a7 do local M=n(a7[u])af[u]=M;a7[u]=M:gsub('%W','_')end end;function j.new(ag,ad)ag.fieldnames=ag.fieldnames or ad or''if not ag.delim and type(ag.fieldnames)=='string'then ag.delim=O(ag.fieldnames)ag.fieldnames=v(ag.fieldnames,ag.delim)end;ag.fieldnames=o(ag.fieldnames)ag.original_fieldnames={}ae(ag.fieldnames,ag.original_fieldnames)setmetatable(ag,F)return ag end;local ah=[[ +return function (t) + local i = 0 + local v + local ls = {} + for i,v in ipairs(t) do + if CONDITION then + ls[#ls+1] = v + end + end + table.sort(ls,function(v1,v2) + return SORT_EXPR + end) + local n = #ls + return function() + i = i + 1 + v = ls[i] + if i > n then return end + return FIELDLIST + end +end +]]local ai=[[ +return function (t) + local n = #t + local i = 0 + local v + return function() + repeat + i = i + 1 + v = t[i] + until i > n or CONDITION + if i > n then return end + return FIELDLIST + end +end +]]local function aj(m)return type(m)=='string'end;local ak;local function al(j)return h(j.fieldnames,',')end;local function am(j,M)local a4;if M:find'^%d+$'then a4=tonumber(M)else a4=D(j.fieldnames,M)end;if a4 then return'v['..a4 ..']'else ak=M..' not found in '..al(j)return M end end;local function an(j,ao)ak=nil;local a7=ao.fields;local a2=a7:find'%$'or#j.fieldnames==0;if a7:find'^%s*%*%s*'then if not a2 then a7=al(j)else local ap=#j[1]a7={}for u=1,ap do g(a7,'$'..u)end;a7=h(a7,',')end end;local aq=c.IDEN;if a2 then aq='%$(%d+)'else a7=l(a7):gsub('[^,%w]','_')end;local am=a.bind1(am,j)local ar=i(a7,aq,am)if ak then return nil,ak end;ao.fields=a7;ao.proc_fields=ar;ao.where=ao.where or'true'if aj(ao.where)then ao.where=i(ao.where,aq,am)ak=nil end;return true end;k=function(m,j)local as;local ao={}local at,au=m:find('where ')local av,aw=m:find('sort by ')if at then as=(av or 0)-1;ao.where=m:sub(au+1,as)end;if av then ao.sort_by=m:sub(aw+1)end;as=(at or av or 0)-1;ao.fields=m:sub(1,as)local ax,T=an(j,ao)if not ax then return nil,T else return ao end end;function j.query(j,I,ay,az)local T;if aj(I)then I,T=k(I,j)if not I then return nil,T end elseif type(I)=='table'then if type(I.fields)=='table'then I.fields=h(I.fields,',')end;if not I.proc_fields then local ax,T=an(j,I)if not ax then return nil,T end end else return nil,"condition must be a string or a table"end;local aA;if I.sort_by then aA=ah else aA=ai end;local a7=I.proc_fields or I.fields;if az then a7='{'..a7 ..'}'end;aA=aA:gsub('FIELDLIST',a7)if aj(I.where)then aA=aA:gsub('CONDITION',I.where)I.where=nil else aA=aA:gsub('CONDITION','_condn(v)')I.where=d(0,I.where,'condition.where must be callable')end;if I.sort_by then local aB,aC,aD;local aE=I.sort_by;local aF,aG=aE:find('%s+')if aF then aC,aD=aE:sub(1,aF-1),aE:sub(aG+1)else aC=aE;aD='asc'end;if aC:match'^%$'then aC=aC:sub(2)end;aC=am(j,aC)if ak then return nil,ak end;if aD=='asc'then aD='<'else aD='>'end;aB=('%s %s %s'):format(aC:gsub('v','v1'),aD,aC:gsub('v','v2'))aA=aA:gsub('SORT_EXPR',aB)end;if I.where then aA='return function(_condn) '..aA..' end'end;if b then print(aA)end;local aH,T=a.load(aA,'tmp')if not aH then return nil,T end;aH=aH()if I.where then aH=aH(I.where)end;local aI=aH(j)if ay then g(ay,_G)local aJ={}a.setfenv(aI,aJ)setmetatable(aJ,{__index=function(aK,aL)for aa,s in ipairs(ay)do if s[aL]then return s[aL]end end end})end;return aI end;F.select=j.query;F.select_row=function(ag,I,ay)return j.query(ag,I,ay,true)end;function j.filter(aM,aN,aO,aP)local ag=j.read(aN or'stdin')local aQ=Q(aO or'stdout')local J,T=ag:select(aM)local x=ag.delim;if not J then T='error: '..T;if aP then return nil,T else a.quit(1,T)end end;while true do local t={J()}if#t==0 then break end;aQ:write(h(t,x),'\n')end end;return j diff --git a/extern/lualibs/pl/func.lua b/extern/lualibs/pl/func.lua new file mode 100644 index 00000000..14723ee7 --- /dev/null +++ b/extern/lualibs/pl/func.lua @@ -0,0 +1,10 @@ +-- Penlight 1.11.0-1 | /lua/pl/func.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 type,setmetatable,getmetatable,rawset=type,setmetatable,getmetatable,rawset;local a,b=table.concat,table.insert;local tostring=tostring;local c=require'pl.utils'local pairs,rawget,d,e=pairs,rawget,c.unpack,c.pack;local f=require'pl.tablex'local g=f.map;local h=rawget(_G,'_DEBUG')local i=c.assert_arg;local j={}local k={}local function l(m)setmetatable(m,k)return m end;j.PE=l;local function n(o)return getmetatable(o)==k end;j.isPE=n;local function p(q)return l{op='X',repr='_'..q,index=q}end;local function r(q)return l{op='X',repr='_C'..q,index=q}end;j._1,j._2,j._3,j._4,j._5=p(1),p(2),p(3),p(4),p(5)j._0=l{op='X',repr='...',index=0}function j.Var(s)local t=c.split(s,'[%s,]+')local u={}for v=1,#t do b(u,l{op='X',repr=t[v],index=0})end;return d(u)end;function j._(w)return l{op='X',repr=w,index='wrap'}end;local x;j.Nil=j.Var'nil'function k.__index(o,y)return l{op='[]',o,y}end;function k.__call(z,...)return l{op='()',z,...}end;function k.__tostring(A)return x(A)end;function k.__unm(B)return l{op='unm',B}end;function j.Not(B)return l{op='not',B}end;function j.Len(B)return l{op='#',B}end;local function C(D,m)for s,E in pairs(m)do rawset(D,s,function(F,G)return l{op=E,F,G}end)end end;local function H(s,z,D)rawset(D,s,function(...)return l{op='()',z,...}end)end;local I={}local function J(K)return type(_G[K])=='table'end;function j.import(L,D)i(1,L,'string',J,'arg# 1: not a name of a global table')local m=_G[L]D=D or _G;for s,z in pairs(m)do H(s,z,D)I[z]=s end end;function j.register(z,s)i(1,z,'function')if s then i(2,s,'string')I[z]=s end;return function(...)return l{op='()',z,...}end end;function j.lookup_imported_name(z)return I[z]end;local function M(...)return...end;function j.Args(...)return l{op='()',M,...}end;local N={['or']=0,['and']=2,['==']=4,['~=']=4,['<']=4,['>']=4,['<=']=4,['>=']=4,['..']=6,['+']=8,['-']=8,['*']=10,['/']=10,['%']=10,['^']=14}local O={['not']=12,['#']=12,['unm']=12}C(j,{And='and',Or='or',Eq='==',Lt='<',Gt='>',Le='<=',Ge='>='})C(k,{__add='+',__sub='-',__mul='*',__div='/',__mod='%',__pow='^',__concat='..'})C(k,{__eq='=='})function j.tail(t)i(1,t,'table')local u={}for v=2,#t do b(u,t[v])end;return u end;function x(A,P)local Q=j.tail;if n(A)then local R=N[A.op]or O[A.op]if R then local S;if N[A.op]then local T=R;local U=R;if A.op=='..'or A.op=='^'then T=T+1 else U=U+1 end;local V=x(A[1],T)local W=x(A[2],U)S=V..' '..A.op..' '..W else local E=A.op=='unm'and'-'or A.op;S=E..' '..x(A[1],R)end;if P and P>R then S='('..S..')'end;return S else local t=g(x,A)if A.op=='[]'then return t[1]..'['..t[2]..']'elseif A.op=='()'then local X;if t[1]~=nil then X=t[1]else X=''end;return X..'('..a(Q(t),',')..')'else return A.repr end end elseif type(A)=='string'then return'"'..A..'"'elseif type(A)=='function'then local s=j.lookup_imported_name(A)if s then return s else return tostring(A)end else return tostring(A)end end;j.repr=x;local Y;function Y(A,Z)if n(A)then if A.op~='X'then local _=0;for v=1,#A do local a0=A[v]local a1=n(a0)if a1 then if a0.op=='X'and a0.index=='wrap'then a0=a0.repr;a1=false else _=math.max(_,Y(a0,Z))end end;if not a1 then b(Z,a0)A[v]=r(#Z)end end;return _ else return A.index end else return 0 end end;j.collect_values=Y;function j.instantiate(A)local a2,a3,a4={},{},{}local a5,a6,z;local K=j.collect_values(A,a3)for v=1,#a3 do b(a2,'_C'..v)if h then print(v,a3[v])end end;for v=1,K do b(a4,'_'..v)end;a2=a(a2,',')a4=a(a4,',')a5=x(A)local a7=('return function(%s) return function(%s) return %s end end'):format(a2,a4,a5)if h then print(a7)end;z,a6=c.load(a7,'fun')if not z then return nil,a6 end;z=z()z=z(d(a3))A.__PE_function=z;return z end;function j.I(A)if rawget(A,'__PE_function')then return A.__PE_function else return j.instantiate(A)end end;c.add_function_factory(k,j.I)j.bind1=c.bind1;j.curry=j.bind1;function j.compose(a8,a9)return function(...)return a8(a9(...))end end;function j.bind(X,...)local aa=e(...)local ab,a4,ac,a3={},{},{'fn'},{}local ad,ae,af=1,0,false;for v=1,aa.n do local ag=aa[v]if n(ag)and ag.op=='X'then b(ab,ag.repr)ae=math.max(ae,ag.index)if ag.index==0 then af=true end else local ah='_v'..ad;b(ac,ah)b(ab,ah)b(a3,ag)ad=ad+1 end end;for ai=1,ae do b(a4,'_'..ai)end;if af then b(a4,'...')end;ac=a(ac,',')a4=a(a4,',')ab=a(ab,',')local a7=([[ +return function (%s) + return function(%s) return fn(%s) end +end +]]):format(ac,a4,ab)if h then print(a7)end;local u=c.load(a7)u=u()return u(X,d(a3))end;return j diff --git a/extern/lualibs/pl/import_into.lua b/extern/lualibs/pl/import_into.lua new file mode 100644 index 00000000..7b166e77 --- /dev/null +++ b/extern/lualibs/pl/import_into.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/import_into.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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. +return function(a)local b;if a==true then b={}a={}end;local a=a or{}local c={utils=true,path=true,dir=true,tablex=true,stringio=true,sip=true,input=true,seq=true,lexer=true,stringx=true,config=true,pretty=true,data=true,func=true,text=true,operator=true,lapp=true,array2d=true,comprehension=true,xml=true,types=true,test=true,app=true,file=true,class=true,luabalanced=true,permute=true,template=true,url=true,compat=true,List=true,Map=true,Set=true,OrderedMap=true,MultiMap=true,Date=true}rawset(a,'utils',require'pl.utils')for d,e in pairs(a.utils.stdmt)do e.__index=function(f,g)return require('pl.'..d)[g]end end;local h,i;local j={}local k=getmetatable(a)if k then i=k.__index;if k.__newindex then j.__index=k.__newindex end end;function j.hook(l)h=l end;function j.__index(f,d)local m=c[d]if m then rawset(a,d,require('pl.'..d))return a[d]else local n;if h then n=h(f,d)if n then return n end end;if i then return i(f,d)end end end;if b then function j.__newindex(f,d,o)b[d]=o;rawset(f,d,o)end end;setmetatable(a,j)return a,b or a end diff --git a/extern/lualibs/pl/init.lua b/extern/lualibs/pl/init.lua new file mode 100644 index 00000000..af7a1a52 --- /dev/null +++ b/extern/lualibs/pl/init.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/init.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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. +require'pl.import_into'(_G)if rawget(_G,'PENLIGHT_STRICT')then require'pl.strict'end diff --git a/extern/lualibs/pl/input.lua b/extern/lualibs/pl/input.lua new file mode 100644 index 00000000..c5af97e3 --- /dev/null +++ b/extern/lualibs/pl/input.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/input.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a=string.find;local b=string.sub;local c=string.match;local d=require'pl.utils'local e=d.unpack;local pairs,type,tonumber=pairs,type,tonumber;local f=d.patterns;local io=io;local g={}function g.alltokens(h,i,j)local k=h()local l=1;return function()while k do local m,n=a(k,i,l)if m then l=n+1;local o=b(k,m,n)if j then o=j(o)end;return o else k=h()l=1 end end;return nil end end;local p=g.alltokens;function g.create_getter(q)if q then if type(q)=='string'then local r=d.split(q,'\n')local s,t=0,#r;return function()s=s+1;if s>t then return nil end;return r[s]end else if not q.read then error('not a file-like object')end;return function()return q:read()end end else return io.read end end;function g.numbers(q)return p(g.create_getter(q),'('..f.FLOAT..')',tonumber)end;function g.words(q)return p(g.create_getter(q),"%w+")end;local function u(v,...)local w={...}for s=1,#w do local t=tonumber(w[s])if t==nil then if not v then return nil,w[s]end else w[s]=t end end;return w end;function g.fields(x,y,q,z)local A;local m;local h=g.create_getter(q)local v=z and z.no_fail;local B=z and z.no_convert;if not y or y==' 'then y='%s'A='%s+'m='%s*'else A=y;m=''end;local C=0;if type(x)=='table'then for s,D in pairs(x)do if D>C then C=D end end else C=x;x={}for s=1,C do x[#x+1]=s end end;local E='[^'..y..']*'local F=1;for s=1,C do if x[F]==s then F=F+1;m=m..'('..E..')'else m=m..E end;if s0;return e(H)end end;return g diff --git a/extern/lualibs/pl/lapp.lua b/extern/lualibs/pl/lapp.lua new file mode 100644 index 00000000..d50c676d --- /dev/null +++ b/extern/lualibs/pl/lapp.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/lapp.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a,b=pcall(require,'pl.sip')if not a then b=require'sip'end;local c=b.match_at_start;local d,e=table.insert,table.insert;b.custom_pattern('X','(%a[%w_%-]*)')local function f(g)return g:gmatch('([^\n]*)\n')end;local function h(i)return i:gsub('^%s+','')end;local function j(i)return h(i):gsub('%s+$','')end;local function k(g,l)return g:sub(l,l)end;local m={}local n,o,p,q,r,s;m.callback=false;local t={stdin={io.stdin,'file-in'},stdout={io.stdout,'file-out'},stderr={io.stderr,'file-out'}}m.show_usage_error=true;function m.quit(u,v)if v=='throw'then error(u)end;if u then io.stderr:write(u..'\n\n')end;if not v then io.stderr:write(r)end;os.exit(1)end;function m.error(u,v)if not m.show_usage_error then v=true elseif m.show_usage_error=='throw'then v='throw'end;m.quit(s..': '..u,v)end;function m.open(w,x)local y,z=io.open(w,x)if not y then m.error(z,true)end;d(n,y)return y end;function m.assert(A,u)if not A then m.error(u)end end;local function B(C,D,E,F)m.assert(D<=C and E>=C,F..' out of range')end;local function G(g)local y=tonumber(g)if not y then m.error("unable to convert to number: "..g)end;return y end;local H={}local I={string=true,number=true,['file-in']='file',['file-out']='file',boolean=true}local function J(K,y)if K.converter then y=K.converter(y)end;if K.type=='number'then y=G(y)elseif I[K.type]=='file'then y=m.open(y,K.type=='file-in'and'r'or'w')elseif K.type=='boolean'then return y end;if K.constraint then K.constraint(y)end;return y end;function m.add_type(L,M,N)H[L]={converter=M,constraint=N}end;local function O(P)m.assert(#P==1,P..": short parameters should be one character")end;local function Q(R,S)local y,T;if not S or S=='number'then y=tonumber(R)end;if y then return y,'number'elseif t[R]then local U=t[R]return U[1],U[2]else if R=='true'and not S then return true,'boolean'end;if R:match'^["\']'then R=R:sub(2,-2)end;local K=H[S]or{}K.type=S;local V=m.show_usage_error;m.show_usage_error="throw"T,y=pcall(J,K,R)m.show_usage_error=V;if T then return y,S or'string'end;return R,S or'string'end end;function m.process_options_string(i,W)local X={}local Y;local arg=W or _G.arg;n={}o={}p={}q={}local function Z(g)local _,a0=g:gsub('^%.%.%.%s*','')return _,a0>0 end;local function a1(K,F,y)F=type(F)=="string"and F:gsub("%W","_")or F;if not K.varargs then X[F]=y else if not X[F]then X[F]={y}else d(X[F],y)end end end;r=i;for a2,a3 in ipairs(arg)do if a3=="-h"or a3=="--help"then return m.quit()end end;for a4 in f(i)do local _={}local a5,a6,S,N,a7;a4=h(a4)local function a8(i)return c(i,a4,_)end;if a8'-$v{short}, --$o{long} $'or a8'-$v{short} $'or a8'--$o{long} $'then if _.long then a5=_.long:gsub('[^%w%-]','_')if#_.rest==1 then a5=a5 .._.rest end;if _.short then p[_.short]=a5 end else a5=_.short end;if _.short and not m.slack then O(_.short)end;_.rest,Y=Z(_.rest)elseif a8'$<{name} $'then a5,a7=_.name:match'([^%.]+)(.*)'a5=a5:gsub('%A','_')Y=a7=='...'d(q,a5)end;if _.rest then a4=_.rest;_={}local a9;if c('$({def} $',a4,_)or c('$({def}',a4,_)then local aa=j(_.def)local ab,a7=aa:match('^(%S+)(.*)$')a7=j(a7)if ab=='optional'then ab,a7=a7:match('^(%S+)(.*)$')a7=j(a7)a9=true end;local ac;if ab=='default'then ac=true;if a7==''then m.error("value must follow default")end else if c('$f{min}..$f{max}',ab,_)then local D,E=_.min,_.max;S='number'N=function(C)B(C,D,E,a5)end elseif not ab:match'|'then S=ab else local ad=ab;local ae='|'..ad..'|'S='string'N=function(g)m.assert(ae:match('|'..g..'|'),"value '"..g.."' not in "..ad)end end end;_.rest=a7;aa=_.rest;if ac or c('default $r{rest}',aa,_)then a6,S=Q(_.rest,S)end else a6=false;S='boolean'end;local K={type=S,defval=a6,required=a6==nil and not a9,comment=_.rest or a5,constraint=N,varargs=Y}Y=nil;if H[S]then local M=H[S].converter;if type(M)=='string'then K.type=M else K.converter=M end;K.constraint=H[S].constraint elseif not I[S]and S then m.error(S.." is unknown type")end;o[a5]=K end end;local af=1;local ag=1;local ah=1;local F,K,y;local ai=false;local function aj(F)local ak=F:find'[=:]'if ak then e(arg,ah+1,F:sub(ak+1))F=F:sub(1,ak-1)end;return F,ak end;local function al(F)return o[p[F]or F]end;while ah<=#arg do local am=arg[ah]local _={}if am=='--'then ai=true;af=#q+1;ah=ah+1;am=arg[ah]if not am then break end end;if not ai and(c('--$S{long}',am,_)or c('-$S{short}',am,_))then if _.long then F=aj(_.long)elseif#_.short==1 or al(_.short)then F=_.short else local an,ao=aj(_.short)if not ao then F=k(an,1)local ap=al(F)if ap and ap.type~='boolean'then e(arg,ah+1,an:sub(2))else for l=2,#an do e(arg,ah+l-1,'-'..k(an,l))end end else F=an end end;if p[F]then F=p[F]end;if not o[F]and(F=='h'or F=='help')then m.quit()end else F=q[af]if not F then F=ag;K={type='string'}o[F]=K;ag=ag+1 else K=o[F]end;if not K.varargs then af=af+1 end;y=am end;K=o[F]if not K then m.error("unrecognized parameter: "..F)end;if K.type~='boolean'then if not y then ah=ah+1;y=arg[ah]am=y end;m.assert(y,F.." was expecting a value")else y=not K.defval end;K.used=true;y=J(K,y)a1(K,F,y)if I[K.type]=='file'then a1(K,F..'_name',am)end;if m.callback then m.callback(F,am,_)end;ah=ah+1;y=nil end;for F,K in pairs(o)do if not K.used then if K.required then m.error("missing required parameter: "..F)end;a1(K,F,K.defval)end end;return X end;if arg then s=arg[0]s=s or rawget(_G,"LAPP_SCRIPT")or"unknown"s=s:gsub('.+[\\/]',''):gsub('%.%a+$','')else s="inter"end;setmetatable(m,{__call=function(aq,i,W)return m.process_options_string(i,W)end})return m diff --git a/extern/lualibs/pl/lexer.lua b/extern/lualibs/pl/lexer.lua new file mode 100644 index 00000000..c1c28a15 --- /dev/null +++ b/extern/lualibs/pl/lexer.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/lexer.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a=string.find;local b=string.sub;local c=table.insert;local function d(e,f,g)if type(f)~=g then error("argument "..e.." must be "..g,2)end end;local h={}local i='^[%+%-]?%d+%.?%d*[eE][%+%-]?%d+'local j='^[%+%-]?%d*%.%d+[eE][%+%-]?%d+'local k='^[%+%-]?%d+%.?%d*'local l='^[%+%-]?%d*%.%d+'local m='^0x[%da-fA-F]+'local n='^%d+%.?%d*[eE][%+%-]?%d+'local o='^%d*%.%d+[eE][%+%-]?%d+'local p='^%d+%.?%d*'local q='^%d*%.%d+'local r='^[%a_][%w_]*'local s='^%s+'local t="^(['\"])%1"local u=[[^(['"])(\*)%2%1]]local v=[[^(['"]).-[^\](\*)%2%1]]local w="^''"local x=[[^'(\*)%1']]local y=[[^'.-[^\](\*)%1']]local z='^#.-[^\\]\n'local A,B,C,D,E;local function F(G)return G,G end;local function H(G,I)if I and I.number then G=tonumber(G)end;return"number",G end;local function J(G,I)if I and I.string then G=G:sub(2,-2)end;return"string",G end;local function K(G,I,L)if I and I.string then local M=3;if L[3]then M=M+L[3]:len()end;G=G:sub(M,-M)if G:sub(1,1)=="\n"then G=G:sub(2)end end;return"string",G end;local function N(G,I)if I and I.string then G=G:sub(2,-2)end;return"char",G end;local function O(G)return"comment",G end;local function P(G)return"space",G end;local function Q(G)return"prepro",G end;local function R(G)return"iden",G end;local function S(G)if D[G]then return"keyword",G else return"iden",G end end;local function T(G)if E[G]then return"keyword",G else return"iden",G end end;function h.scan(U,V,W,I)local X=type(U)~='string'and U;W=W or{space=true}I=I or{number=true,string=true}if W then if W.space then W[P]=true end;if W.comments then W[O]=true end end;if not V then if not A then A={{s,P},{m,H},{r,R},{i,H},{j,H},{k,H},{l,H},{t,J},{u,J},{v,J},{'^.',F}}end;V=A end;local Y=0;local Z=X and X:read()local _=X and 0 or#U;local e=1;local a0;local a1;local a2=true;local function a3(a4)local g=type(a4)if a1 then local a5=a1[a0]if a5 then a0=a0+1;return a5[1],a5[2]else a1=nil end end;if g=='string'then local a6,a7=a(U,a4,e)if a6 then local G=b(U,a6,a7)e=a7+1;return'',G else e=_+1;return'',''end elseif g=='table'then a0=1;a1=a4;return'',''elseif g~='nil'then return Y,e else if a2 then if not X then Y=1 end;a2=false end;if e>_ then if X then if not Z then return end;U=Z;Y=Y+1;Z=X:read()if Z then U=U..'\n'end;e,_=1,#U else return end end;for a8,a9 in ipairs(V)do local aa=a9[1]local ab=a9[2]local L={a(U,aa,e)}local a6,a7=L[1],L[2]if a6 then local G=b(U,a6,a7)e=a7+1;local ac,ad;if not(W and W[ab])then h.finished=e>_;ac,ad=ab(G,I,L)end;if not X and G:find("\n")then local a8,ae=G:gsub("\n",{})Y=Y+ae end;if ac then return ac,ad else return a3()end end end end end;return a3 end;local function af(U)return type(U)=='string'end;function h.insert(G,ag,ah)if not ag then return end;local ai;if af(ag)and af(ah)then ai={{ag,ah}}elseif type(ag)=='function'then ai={}for aj,ak in ag()do c(ai,{aj,ak})end else ai=ag end;G(ai)end;function h.getline(G)local a8,ak=G('.-\n')return ak end;function h.lineno(G)return G(0)end;function h.getrest(G)local a8,ak=G('.+')return ak end;function h.get_keywords()if not D then D={["and"]=true,["break"]=true,["do"]=true,["else"]=true,["elseif"]=true,["end"]=true,["false"]=true,["for"]=true,["function"]=true,["if"]=true,["in"]=true,["local"]=true,["nil"]=true,["not"]=true,["or"]=true,["repeat"]=true,["return"]=true,["then"]=true,["true"]=true,["until"]=true,["while"]=true}end;return D end;function h.lua(U,W,I)W=W or{space=true,comments=true}h.get_keywords()if not B then B={{s,P},{m,H},{r,S},{n,H},{o,H},{p,H},{q,H},{t,J},{u,J},{v,J},{'^%-%-%[(=*)%[.-%]%1%]',O},{'^%-%-.-\n',O},{'^%[(=*)%[.-%]%1%]',K},{'^==',F},{'^~=',F},{'^<=',F},{'^>=',F},{'^%.%.%.',F},{'^%.%.',F},{'^.',F}}end;return h.scan(U,B,W,I)end;function h.cpp(U,W,I)W=W or{space=true,comments=true}if not E then E={["class"]=true,["break"]=true,["do"]=true,["sizeof"]=true,["else"]=true,["continue"]=true,["struct"]=true,["false"]=true,["for"]=true,["public"]=true,["void"]=true,["private"]=true,["protected"]=true,["goto"]=true,["if"]=true,["static"]=true,["const"]=true,["typedef"]=true,["enum"]=true,["char"]=true,["int"]=true,["bool"]=true,["long"]=true,["float"]=true,["true"]=true,["delete"]=true,["double"]=true,["while"]=true,["new"]=true,["namespace"]=true,["try"]=true,["catch"]=true,["switch"]=true,["case"]=true,["extern"]=true,["return"]=true,["default"]=true,['unsigned']=true,['signed']=true,["union"]=true,["volatile"]=true,["register"]=true,["short"]=true}end;if not C then C={{s,P},{z,Q},{m,H},{r,T},{n,H},{o,H},{p,H},{q,H},{w,N},{x,N},{y,N},{t,J},{u,J},{v,J},{'^//.-\n',O},{'^/%*.-%*/',O},{'^==',F},{'^!=',F},{'^<=',F},{'^>=',F},{'^->',F},{'^&&',F},{'^||',F},{'^%+%+',F},{'^%-%-',F},{'^%+=',F},{'^%-=',F},{'^%*=',F},{'^/=',F},{'^|=',F},{'^%^=',F},{'^::',F},{'^.',F}}end;return h.scan(U,C,W,I)end;function h.get_separated_list(G,al,am)al=al or')'am=am or','local an={}local ao=1;local ap={}local function aq(ap,aj,f)f=f or aj;c(ap,{aj,f})end;local ar;if al=='\n'then ar=function(aj,f)return aj=='space'and f:find'\n'end else ar=function(aj)return aj==al end end;local as,at;while true do as,at=G()if not as then return nil,'EOS'end;if ar(as,at)and ao==1 then c(an,ap)break elseif as=='('then ao=ao+1;aq(ap,'(')elseif as==')'then ao=ao-1;if ao==0 then c(an,ap)break else aq(ap,')')end elseif as==am and ao==1 then c(an,ap)ap={}else aq(ap,as,at)end end;return an,{as,at}end;function h.skipws(G)local aj,ak=G()while aj=='space'do aj,ak=G()end;return aj,ak end;local au=h.skipws;function h.expecting(G,av,aw)d(1,G,'function')d(2,av,'string')local aj,ak;if aw then aj,ak=G()else aj,ak=au(G)end;if aj~=av then error("expecting "..av,2)end;return ak end;return h diff --git a/extern/lualibs/pl/luabalanced.lua b/extern/lualibs/pl/luabalanced.lua new file mode 100644 index 00000000..ba795fdf --- /dev/null +++ b/extern/lualibs/pl/luabalanced.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/luabalanced.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a={}local assert=assert;local b={['(']=')',['{']='}',['[']=']'}local c={}for d,e in pairs(b)do c[e]=d end;local function f(g,h)h=h or 1;local i=h;local j=g:sub(h,h)if j=='"'or j=="'"then h=h+1;while 1 do h=assert(g:find("["..j.."\\]",h),'syntax error')if g:sub(h,h)==j then local k=g:sub(i,h)return k,h+1 else h=h+2 end end else local l=g:match("^%[(=*)%[",h)if l then local m;m,h=g:find("%]"..l.."%]",h)assert(h)local k=g:sub(i,h)return k,h+1 else return nil,h end end end;a.match_string=f;local function n(g,h)h=h or 1;local i=h;local o=g:sub(h,h)if not b[o]then return nil,h end;local p={}while 1 do h=g:find('[%(%{%[%)%}%]\"\']',h)assert(h,'syntax error: unbalanced')local j=g:sub(h,h)if j=='"'or j=="'"then local k;k,h=f(g,h)assert(k)elseif b[j]then local q,r;if j=='['then q,r=g:match('^%[(=*)%[()',h)end;if q then h=g:match('%]'..q..'%]()',r)assert(h,'syntax error: long string not terminated')if#p==0 then local k=g:sub(i,h-1)return k,h end else p[#p+1]=j;h=h+1 end else assert(p[#p]==assert(c[j]),'syntax error: unbalanced')p[#p]=nil;if#p==0 then local k=g:sub(i,h)return k,h+1 end;h=h+1 end end end;a.match_bracketed=n;local function s(g,h)h=h or 1;if g:sub(h,h+1)~='--'then return nil,h end;h=h+2;local t,u=f(g,h)if t then return'--'..t,u end;local k;k,h=g:match('^([^\n]*\n?)()',h)return'--'..k,h end;local v={['and']=true,['or']=true,['not']=true}local w={['>']=true,['<']=true,['~']=true}local function x(g,h)h=h or 1;local m;local i=h;local y;local z,A;while h do local j=g:sub(h,h)if j=='"'or j=="'"or j=='['and g:find('^[=%[]',h+1)then local k;k,h=f(g,h)assert(k,'syntax error')elseif j=='-'and g:sub(h+1,h+1)=='-'then z=h;while g:sub(h,h+1)=='--'do local k;k,h=s(g,h)assert(k)h=g:match('^%s*()',h)A=h end elseif j=='('or j=='{'or j=='['then m,h=n(g,h)elseif j=='='and g:sub(h+1,h+1)=='='then h=h+2 elseif j=='='and w[g:sub(h-1,h-1)]then h=h+1 elseif j:match'^[%)%}%];,=]'then local k=g:sub(i,h-1)return k,h elseif j:match'^[%w_]'then local B,C=g:match('^([%w_]+)()',h)if h~=i and not v[B]then local D=(A==h and z or h)-1;while g:match('^%s',D)do D=D-1 end;local E=g:sub(D,D)if E:match'[%)%}\'\"%]]'or E:match'[%w_]'and not v[y]then local k=g:sub(i,h-1)return k,h end end;y,h=B,C else h=h+1 end;h=g:find('[%(%{%[%)%}%]\"\';,=%w_%-]',h)end;local k=g:sub(i,#g)return k,#g+1 end;a.match_expression=x;local function F(g,h)h=h or 1;local G={}while 1 do local j=#G==0 and'^'or'^%s*,%s*'local H,u=g:match(j..'([%a_][%w_]*)%s*()',h)if H then h=u else break end;G[#G+1]=H end;return G,h end;a.match_namelist=F;local function I(g,h)h=h or 1;local G={}while 1 do if#G~=0 then local u=g:match('^%s*,%s*()',h)if u then h=u else break end end;local H;H,h=x(g,h)assert(H,'syntax error')G[#G+1]=H end;return G,h end;a.match_explist=I;local function J(g,K)local h=1;local i=1;local L=''while 1 do h=g:find('[%-\'\"%[]',h)if not h then break end;if g:match('^%-%-',h)then local M=g:sub(i,h-1)if#M>0 then L=L..(K('e',M)or M)end;local N;N,h=s(g,h)L=L..(K('c',assert(N))or N)i=h else local r=g:find('^[\'\"%[]',h)local O;if r then O,h=f(g,r)end;if O then local M=g:sub(i,r-1)if#M>0 then L=L..(K('e',M)or M)end;L=L..(K('s',O)or O)i=h else h=h+1 end end end;local M=g:sub(i)if#M>0 then L=L..(K('e',M)or M)end;return L end;a.gsub=J;return a diff --git a/extern/lualibs/pl/operator.lua b/extern/lualibs/pl/operator.lua new file mode 100644 index 00000000..c774e0fd --- /dev/null +++ b/extern/lualibs/pl/operator.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/operator.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a=string.find;local b={}function b.call(c,...)return c(...)end;function b.index(d,e)return d[e]end;function b.eq(f,g)return f==g end;function b.neq(f,g)return f~=g end;function b.lt(f,g)return fg end;function b.ge(f,g)return f>=g end;function b.len(f)return#f end;function b.add(f,g)return f+g end;function b.sub(f,g)return f-g end;function b.mul(f,g)return f*g end;function b.div(f,g)return f/g end;function b.pow(f,g)return f^g end;function b.mod(f,g)return f%g end;function b.concat(f,g)return f..g end;function b.unm(f)return-f end;function b.lnot(f)return not f end;function b.land(f,g)return f and g end;function b.lor(f,g)return f or g end;function b.table(...)return{...}end;function b.match(f,g)return a(f,g)~=nil end;function b.nop(...)return...end;b.optable={['+']=b.add,['-']=b.sub,['*']=b.mul,['/']=b.div,['%']=b.mod,['^']=b.pow,['..']=b.concat,['()']=b.call,['[]']=b.index,['<']=b.lt,['<=']=b.le,['>']=b.gt,['>=']=b.ge,['==']=b.eq,['~=']=b.neq,['#']=b.len,['and']=b.land,['or']=b.lor,['{}']=b.table,['~']=b.match,['']=b.nop}return b diff --git a/extern/lualibs/pl/permute.lua b/extern/lualibs/pl/permute.lua new file mode 100644 index 00000000..46808dd6 --- /dev/null +++ b/extern/lualibs/pl/permute.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/permute.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a=require'pl.tablex'local b=require'pl.utils'local c=a.deepcopy;local d=table.insert;local e=b.assert_arg;local f={}function f.order_iter(g)e(1,g,'table')local h=#g;local i={1}local function j()local k=#i;local l=h-k+1;local m=i[k]if m>h then return end;if l==0 then table.remove(i)k=k-1;i[k]=i[k]+1;return g elseif m<=l then g[l],g[m]=g[m],g[l]table.insert(i,1)else table.remove(i)k=k-1;l=l+1;m=i[k]g[l],g[m]=g[m],g[l]i[k]=i[k]+1 end;return j()end;return j end;function f.order_table(g)e(1,g,'table')local n={}for h in f.iter(g)do d(n,c(h))end;return n end;function f.list_iter(...)local o={...}local p={}local q={}local r=#o;for m,s in ipairs(o)do e(m,s,'table')p[m]=1;q[m]=s.n or#s end;local t=0;return function()if p[r]>q[r]then return end;t=t+1;local u={n=#o}local v=true;for m=1,r do u[m]=o[m][p[m]]if v then p[m]=p[m]+1;if p[m]<=q[m]then v=false else if m~=r then p[m]=1 end end end end;return t,b.unpack(u)end end;function f.list_table(...)local j=f.list_iter(...)local w={}local m=1;while true do local x=b.pack(j())if x[1]==nil then return w end;for m=1,x.n do x[m]=x[m+1]end;x.n=x.n-1;w[m]=x;m=m+1 end end;function f.iter(...)b.raise_deprecation{source="Penlight "..b._VERSION,message="function 'iter' was renamed to 'order_iter'",version_removed="2.0.0",deprecated_after="1.9.2"}return f.order_iter(...)end;function f.table(...)b.raise_deprecation{source="Penlight "..b._VERSION,message="function 'table' was renamed to 'order_table'",version_removed="2.0.0",deprecated_after="1.9.2"}return f.order_table(...)end;return f diff --git a/extern/lualibs/pl/pretty.lua b/extern/lualibs/pl/pretty.lua new file mode 100644 index 00000000..3eb87f76 --- /dev/null +++ b/extern/lualibs/pl/pretty.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/pretty.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a=table.insert;local b=table.concat;local c,d=math.floor,math.huge;local e=math.type;local f=require'pl.utils'local g=require'pl.lexer'local h=require'debug'local i=require'pl.stringx'.quote_string;local j=f.assert_arg;local k=tostring;local function tostring(l)if type(l)~="number"then return k(l)elseif l~=l then return"NaN"elseif l==d then return"Inf"elseif l==-d then return"-Inf"elseif(_VERSION~="Lua 5.3"or e(l)=="integer")and c(l)==l then return("%d"):format(l)else local m=("%.14g"):format(l)if _VERSION=="Lua 5.3"and e(l)=="float"and not m:find("%.")then m=m:gsub("%d+","%0.0",1)end;return m end end;local n={}local function o()local p={}p.hook,p.mask,p.count=h.gethook()if p.hook~="external hook"then h.sethook()end;p.string_mt=getmetatable("")h.setmetatable("",nil)return p end;local function q(p)if p then h.setmetatable("",p.string_mt)if p.hook~="external hook"then h.sethook(p.hook,p.mask,p.count)end end end;function n.read(r)j(1,r,'string')if r:find'^%s*%-%-'then r=r:gsub('%-%-.-\n','')end;if not r:find'^%s*{'then return nil,"not a Lua table"end;if r:find'[^\'"%w_]function[^\'"%w_]'then local s=g.lua(r)for t,u in s do if t=='keyword'and u=='function'then return nil,"cannot have functions in table definition"end end end;r='return '..r;local v,w=f.load(r,'tbl','t',{})if not v then return nil,w end;local x=o()local y,z=pcall(v)q(x)if y then return z else return nil,z end end;function n.load(r,p,A)p=p or{}if A then local s=g.lua(r)for t,u in s do if t=='keyword'and(u=='for'or u=='repeat'or u=='function'or u=='goto')then return nil,"looping not allowed"end end end;local v,w=f.load(r,'tbl','t',p)if not v then return nil,w end;local x=A and o()local y,w=pcall(v)q(x)if not y then return nil,w end;return p end;local function B(u)if not u then return''else if u:find' 'then u=i(u)end end;return u end;local C;local function D(r)return type(r)=='string'and r:find('^[%a_][%w_]*$')and not C[r]end;local function E(r)if type(r)=='table'then return n.write(r,'')else return i(r)end end;local function F(G,H)if not G then H=E(H)H=H:find("^%[")and" "..H.." "or H end;return'['..H..']'end;function n.write(I,J,K)if type(I)~='table'then local m=tostring(I)if type(I)=='string'then return E(I)end;return m,'not a table'end;if not C then C=g.get_keywords()end;local L=' = 'if J==''then L='='end;J=J or' 'local M={}local N=''local O={}local function P(r)if#r>0 then N=N..r end end;local function Q(r)if#N>0 then N=N..r;a(M,N)N=''else a(M,r)end end;local function R()local S=#M;local T=M[S]:sub(-1,-1)if T==','then M[S]=M[S]:sub(1,-2)end end;local U=function(t)local V=0;local y,u;local W=function()return t[V]end;return function()V=V+1;y,u=pcall(W)if u==nil or not y then return end;return V,t[V]end end;local X=function(t)local Y,u,y;local W=function()return next(t,Y)end;return function()y,Y,u=pcall(W)if not y then return end;return Y,u end end;local Z;Z=function(t,_,a0)local a1=type(t)if a1~='string'and a1~='table'then Q(B(tostring(t))..',')elseif a1=='string'then Q(i(t)..",")elseif a1=='table'then if O[t]then Q(',')return end;O[t]=true;local a2=a0 ..J;Q('{')local a3={}if not K then for V,a4 in U(t)do P(a0)Z(a4,a0,a2)a3[V]=true end end;local a5={}for Y,u in X(t)do if type(Y)~='number'then a5[#a5+1]=Y end end;table.sort(a5,function(a6,a7)if type(a6)==type(a7)and type(a6)=='string'then return a60 and'\n'or'')end;function n.dump(t,aa)if not aa then print(n.write(t))return true else return f.writefile(aa,n.write(t))end end;function n.debug(...)local S=select("#",...)local t={...}for V=1,S do local l=t[V]if l==nil then l=""end;t[V]=nil;t["arg "..V]=l end;print(n.write(t))return true end;local ab,ac={'B','KiB','MiB','GiB'},{'','K','M','B'}local function ad(a4)local ae=math.floor(a4/1000)if ae>0 then return ad(ae)..','..tostring(a4%1000)else return tostring(a4)end end;function n.number(af,ag,ah)local ai='%.'..(ah or 1)..'f%s'if ag=='T'then return ad(af)else local aj,ak;if ag=='M'then ak=1024;aj=ab else ak=1000;aj=ac end;local al=ak;local Y=1;while af>=al and Y<=#aj do al=al*ak;Y=Y+1 end;al=al/ak;if Y>#aj then Y=Y-1;al=al/ak end;if Y>1 then return ai:format(af/al,aj[Y]or'duh')else return af..aj[1]end end end;return setmetatable(n,{__call=function(self,...)return self.debug(...)end}) diff --git a/extern/lualibs/pl/seq.lua b/extern/lualibs/pl/seq.lua new file mode 100644 index 00000000..4befdbd8 --- /dev/null +++ b/extern/lualibs/pl/seq.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/seq.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 next,assert,pairs,tonumber,type,setmetatable=next,assert,pairs,tonumber,type,setmetatable;local a,b=string.find,string.format;local c=math.random;local d,e=table.sort,table.insert;local io=io;local f=require'pl.utils'local g=require'pl.types'.is_callable;local h=f.function_arg;local i=f.assert_arg;local j=require'debug'local k={}function k.greater_than(l)return function(m)return tonumber(m)>l end end;function k.less_than(l)return function(m)return tonumber(m)w then return nil else return x end end end;function k.count(u,y,z)local x=0;k.foreach(u,function(A)if y(A,z)then x=x+1 end end)return x end;function k.minmax(u)local B,C=1e70,-1e70;for m in t(u)do m=tonumber(m)if mC then C=m end end;return B,C end;function k.sum(u,D)local n=0;local x=0;for m in t(u)do if D then m=D(m)end;n=n+m;x=x+1 end;return n,x end;function k.copy(u)local E,F={},1;for m in t(u)do E[F]=m;F=F+1 end;setmetatable(E,require('pl.List'))return E end;function k.copy2(u,G,H)local E,F={},1;for I,J in u,G,H do E[F]={I,J}F=F+1 end;return E end;function k.copy_tuples(u)u=t(u)local E={}local K={u()}while#K>0 do e(E,K)K={u()}end;return E end;function k.random(L,M,N)local O;assert(type(L)=='number')if N then O=function()return c(M,N)end elseif M then O=function()return c(M)end else O=c end;return function()if L==0 then return nil else L=L-1;return O()end end end;function k.sort(u,P)local p=k.copy(u)d(p,P)return s(p)end;function k.zip(Q,R)Q=t(Q)R=t(R)return function()return Q(),R()end end;function k.count_map(u)local p={}local m;for n in t(u)do m=p[n]if m then p[n]=m+1 else p[n]=1 end end;return setmetatable(p,require('pl.Map'))end;function k.unique(u,S)local p=k.count_map(u)local E,F={},1;for q in pairs(p)do E[F]=q;F=F+1 end;table.sort(E)if S then return E else return s(E)end end;function k.printall(u,T,U,V)local W=io.write;if not T then T=' 'end;if not U then if T=='\n'then U=1e30 else U=7 end end;if V then local X=V;V=function(m)return b(X,m)end end;local F=1;for m in t(u)do if V then m=V(m)end;if F',['(']=')',['{']='}',['[']=']'}local l={a=1,c=0,d=1,l=1,p=0,u=1,w=1,x=1,s=0}local function m(n)return'('..n..')'end;local function o(p)return p:gsub('[%-%.%+%[%]%(%)%^%%%?%*]','%%%0'):gsub('%$%%(%S)','$%1')end;local function q(r)return r:gsub("()%s+()",function(s,t)local u=r:sub(s-2,s-1)if u:match('%$[vifadxlu]')or u:match('^[^%$]?[%w_]$')then local v=r:sub(t,t+1)if v:match('%$[vifadxlu]')or v:match('^[%w_]')then return'%s+'end end;return'%s*'end)end;local w={v=m(e.IDEN),i=m(e.INTEGER),f=m(e.FLOAT),o=m(e.OPTION),r='(%S.*)',p='([%a]?[:]?[\\/%.%w_]+)'}function j.custom_pattern(x,r)w[x]=r end;function j.create_pattern(p,y)f(1,p,'string')local z,A={},{}if type(p)=='string'then p=o(p)else local B={}for C,n in ipairs(p)do B[C]=o(n)end;p=d(B,'.-')end;local D=1;local function E(F,type)F=F or D;c(z,F)A[F]=type;D=D+1 end;local G=p:find('{%a+}')if y and y.at_start then p='^'..p end;if p:sub(-1,-1)=='$'then p=p:sub(1,-2)..'$r'if G then p=p..'{rest}'end end;local H;if G then H={}p=p:gsub('{(%a+)}',function(F)c(H,F)return''end)end;p=q(p)local I=1;local J;local K=p:gsub('%$%S',function(n)local type,F;type=n:sub(2,2)if H then F=H[I]I=I+1 end;if not H and type=='q'then E(nil,'Q')else E(F,type)end;local B;if w[type]then B=w[type]elseif type=='q'then E(F,type)B='(["\'])(.-)%'..D-2 else local L=k[type]if L then B='(%b'..type..L..')'elseif l[type]or l[type:lower()]then B='(%'..type..'+)'else J="unknown format type or character class"end end;return B end)if J then return nil,J else return K,z,A end end;local function M(n)return n=='d'or n=='i'or n=='f'end;function j.create_spec_fun(p,y)local A,z;local N={}p,z,A=j.create_pattern(p,y)if not p then return p,z end;local G=type(z[1])=='string'for C=1,#z do c(N,'mm'..C)end;N[1]=N[1]or"mm1"local O=('return (function(s,res)\n\tlocal %s = s:match(%q)\n'):format(d(N,','),p)O=O..'\tif not mm1 then return false end\n'local I=1;for C,P in ipairs(z)do if P~='_'then local Q='mm'..C;if M(A[P])then Q='tonumber('..Q..')'elseif k[A[P]]then Q=Q..':sub(2,-2)'end;if G then O=('%s\tres.%s = %s\n'):format(O,P,Q)else if A[P]~='Q'then O=('%s\tres[%d] = %s\n'):format(O,I,Q)I=I+1 end end end end;return O..'\treturn true\nend)\n',G end;function j.compile(p,y)f(1,p,'string')local O,H=j.create_spec_fun(p,y)if not O then return nil,H end;if rawget(_G,'_DEBUG')then print(O)end;local R,J=a(O,'tmp')if J then return nil,J end;return R(),H end;local S={}function j.match(p,T,B,y)f(1,p,'string')f(2,T,'string')f(3,B,'table')if not S[p]then S[p]=j.compile(p,y)end;return S[p](T,B)end;function j.match_at_start(p,T,B)return j.match(p,T,B,{at_start=true})end;function j.fields(p,P)f(1,p,'string')if not P then return nil,"no file object"end;local O,J=j.compile(p)if not O then return nil,J end;local B={}return function()while true do local T=P:read()if not T then return end;if O(T,B)then local U=B;B={}return b(U)end end end end;local V={}function j.pattern(p,O)f(1,p,'string')local W,X=j.compile(p)c(V,{pat=W,named=X,callback=O})end;function j.read(P,Y)local Z,J;if not P then return nil,"no file object"end;if type(P)=='string'then P,J=io.open(P)if not P then return nil,J end;Z=true end;if Y then for _,a0 in ipairs(Y)do j.pattern(a0[1],a0[2])end end;local B={}for T in P:lines()do for _,a1 in ipairs(V)do if a1.pat(T,B)then if a1.callback then if a1.named then a1.callback(B)else a1.callback(b(B))end end;B={}break end end end;if Z then P:close()end end;return j diff --git a/extern/lualibs/pl/strict.lua b/extern/lualibs/pl/strict.lua new file mode 100644 index 00000000..c5274262 --- /dev/null +++ b/extern/lualibs/pl/strict.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/strict.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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. +require'debug'local a,error,rawset,rawget=debug.getinfo,error,rawset,rawget;local b={}local function c()local d=a(3,"S")return d and d.what or"C"end;function b.module(e,f,g)local h,i,j,k,l;if g then l=g.__global end;if type(f)=='table'then h=getmetatable(f)if h and rawget(h,'__declared')then return end else f={}end;if h==nil then h={}setmetatable(f,h)else i=h.__newindex;j=h.__index;k=type(j)end;h.__declared=g or{}h.__newindex=function(m,n,o)if i then i(m,n,o)if rawget(m,n)~=nil then return end end;if not h.__declared[n]then if l then local p=c()if p~="main"and p~="C"then error("assign to undeclared global '"..n.."'",2)end end;h.__declared[n]=true end;rawset(m,n,o)end;h.__index=function(m,n)if not h.__declared[n]and c()~="C"then if j then if k=="table"then local q=j[n]if q~=nil then return q end else local r=j(m,n)if r~=nil then return r end end end;local s="variable '"..n.."' is not declared"if e then s=s.." in '"..tostring(e).."'"end;error(s,2)end;return rawget(m,n)end;return f end;function b.make_all_strict(t)for u,o in pairs(t)do if type(o)=='table'and o~=t then b.module(u,o)end end end;function b.closed_module(f,e)local v={}f=f or{}local h=getmetatable(f)if not h then h={}setmetatable(f,h)end;h.__newindex=function(m,u,o)v[u]=o end;return b.module(e,v)end;if not rawget(_G,'PENLIGHT_NO_GLOBAL_STRICT')then b.module(nil,_G,{_PROMPT=true,_PROMPT2=true,__global=true})end;return b diff --git a/extern/lualibs/pl/stringio.lua b/extern/lualibs/pl/stringio.lua new file mode 100644 index 00000000..d8bc595e --- /dev/null +++ b/extern/lualibs/pl/stringio.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/stringio.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a=rawget(_G,'unpack')or rawget(table,'unpack')local tonumber=tonumber;local b,c=table.concat,table.insert;local d={}local e={}e.__index=e;local function f(self,...)local g={...}for h=1,#g do c(self.tbl,g[h])end end;function e:write(i,j,...)if j then f(self,i,j,...)else c(self.tbl,i)end end;function e:writef(k,...)self:write(k:format(...))end;function e:value()return b(self.tbl)end;function e:__tostring()return self:value()end;function e:close()end;function e:seek()end;local l={}l.__index=l;function l:_read(k)local h,m=self.i,self.str;local n=#m;if h>n then return nil end;local o;if k=='*l'or k=='*L'then local p=m:find('\n',h)or n+1;o=m:sub(h,k=='*l'and p-1 or p)self.i=p+1 elseif k=='*a'then o=m:sub(h)self.i=n elseif k=='*n'then local q,r,p;q,p=m:find('%s*%d+',h)q,r=m:find('^%.%d+',p+1)if r then p=r end;q,r=m:find('^[eE][%+%-]*%d+',p+1)if r then p=r end;local s=m:sub(h,p)o=tonumber(s)self.i=p+1 elseif type(k)=='number'then o=m:sub(h,h+k-1)self.i=h+k else error("bad read format",2)end;return o end;function l:read(...)if select('#',...)==0 then return self:_read('*l')else local o,t={},{...}for h=1,#t do o[h]=self:_read(t[h])end;return a(o)end end;function l:seek(u,v)local w;u=u or'cur'v=v or 0;if u=='set'then w=1 elseif u=='cur'then w=self.i elseif u=='end'then w=#self.str end;self.i=w+v;return self.i end;function l:lines(...)local x,g=select('#',...)if x>0 then g={...}end;return function()if x==0 then return self:_read'*l'else return self:read(a(g))end end end;function l:close()end;function d.create()return setmetatable({tbl={}},e)end;function d.open(y)return setmetatable({str=y,i=1},l)end;function d.lines(y,...)return d.open(y):lines(...)end;return d diff --git a/extern/lualibs/pl/stringx.lua b/extern/lualibs/pl/stringx.lua new file mode 100644 index 00000000..f93003f7 --- /dev/null +++ b/extern/lualibs/pl/stringx.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/stringx.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a=require'pl.utils'local string=string;local b=string.find;local type,setmetatable,ipairs=type,setmetatable,ipairs;local error=error;local c=string.gsub;local d=string.rep;local e=string.sub;local f=string.reverse;local g=table.concat;local h=table.insert;local i=a.escape;local j,k=math.ceil,math.max;local l,m=a.assert_arg,a.split;local n;local function o(p,q)l(p,q,'string')end;local function r(q)return#q>0 end;local function s(p,q)l(p,q,'string',r,'must be a non-empty string')end;local function t(u)return setmetatable(u,require('pl.List'))end;local v={}function v.isalpha(q)o(1,q)return b(q,'^%a+$')==1 end;function v.isdigit(q)o(1,q)return b(q,'^%d+$')==1 end;function v.isalnum(q)o(1,q)return b(q,'^%w+$')==1 end;function v.isspace(q)o(1,q)return b(q,'^%s+$')==1 end;function v.islower(q)o(1,q)return b(q,'^[%l%s]+$')==1 end;function v.isupper(q)o(1,q)return b(q,'^[%u%s]+$')==1 end;local function w(q,x)return b(q,x,1,true)==1 end;local function y(q,z)return#q>=#z and b(q,z,#q-#z+1,true)and true or false end;local function A(q,B,C)if type(B)=='string'then return C(q,B)elseif type(B)=='table'then for D,E in ipairs(B)do if C(q,E)then return true end end;return false else error(("argument #2 expected a 'string' or a 'table', got a '%s'"):format(type(B)))end end;function v.startswith(q,x)o(1,q)return A(q,x,w)end;function v.endswith(q,z)o(1,q)return A(q,z,y)end;function v.join(q,F)o(1,q)return g(F,q)end;function v.splitlines(q,G)o(1,q)local H={}local I=1;while true do local J=b(q,'[\r\n]',I)if not J then break end;local K=e(q,J,J)if K=='\r'and e(q,J+1,J+1)=='\n'then K='\r\n'end;local L=e(q,I,J-1)if G then L=L..K end;h(H,L)I=J+#K end;if I<=#q then h(H,e(q,I))end;return t(H)end;function v.split(q,M,p)o(1,q)local N=true;if not M then q=n(q)N=false end;local H=m(q,M,N,p)if M and M~=''and b(q,M,-#M,true)and(p or math.huge)>#H then H[#H+1]=""end;return t(H)end;function v.expandtabs(q,O)o(1,q)O=O or 8;return q:gsub("([^\t\r\n]*)\t",function(P)return P..(" "):rep(O-#P%O)end)end;local function Q(q,e,R,S,T)R=R or 1;S=S or#q;if e==''then return S+1,S-R+1 end;local U,V=b(q,e,R,true)local H;local W=0;while U do if S and V>S then break end;H=U;W=W+1;if T then U,V=b(q,e,U+1,true)else U,V=b(q,e,V+1,true)end end;return H,W end;function v.lfind(q,e,R,S)o(1,q)o(2,e)local U,V=b(q,e,R,true)if U and(not S or V<=S)then return U else return nil end end;function v.rfind(q,e,R,S)o(1,q)o(2,e)return Q(q,e,R,S,true)end;function v.replace(q,X,Y,p)o(1,q)o(2,X)o(3,Y)return c(q,i(X),Y:gsub('%%','%%%%'),p)end;function v.count(q,e,T)o(1,q)local D,W=Q(q,e,1,false,T)return W end;local function Z(q,_,a0,a1,a2)local p=#q;if _>p then if not a0 then a0=' 'end;local a3,a4;if a1 and a2 then local a5=j((_-p)/2)local a6=_-p-a5;a3=d(a0,a6)a4=d(a0,a5)elseif a2 then a3=d(a0,_-p)a4=''else a4=d(a0,_-p)a3=''end;return a3 ..q..a4 else return q end end;function v.ljust(q,_,a0)o(1,q)l(2,_,'number')return Z(q,_,a0,true,false)end;function v.rjust(q,_,a0)o(1,q)l(2,_,'number')return Z(q,_,a0,false,true)end;function v.center(q,_,a0)o(1,q)l(2,_,'number')return Z(q,_,a0,true,true)end;local function a7(q,a1,a2,a8)if not a8 then a8='%s'else a8='['..i(a8)..']'end;local a9=1;local aa;if a1 then local U,V=b(q,'^'..a8 ..'*')if V>=U then a9=V+1 end end;if a2 then if#q<200 then local U,V=b(q,a8 ..'*$',a9)if V>=U then aa=U-1 end else local ab=f(q)local U,V=b(ab,'^'..a8 ..'*')if V>=U then aa=-V-1 end end end;return e(q,a9,aa)end;function v.lstrip(q,a8)o(1,q)return a7(q,true,false,a8)end;n=v.lstrip;function v.rstrip(q,a8)o(1,q)return a7(q,false,true,a8)end;function v.strip(q,a8)o(1,q)return a7(q,true,true,a8)end;function v.splitv(q,M)o(1,q)return a.splitv(q,M)end;local function ac(ad,ae,C)local U,V=C(ad,ae)if not U or U==-1 then return ad,'',''else if not V then V=U end;return e(ad,1,U-1),e(ad,U,V),e(ad,V+1)end end;function v.partition(q,a0)o(1,q)s(2,a0)return ac(q,a0,v.lfind)end;function v.rpartition(q,a0)o(1,q)s(2,a0)local af,ag,ah=ac(q,a0,v.rfind)if af==q then return ah,ag,af end;return af,ag,ah end;function v.at(q,ai)o(1,q)l(2,ai,'number')return e(q,ai,ai)end;function v.lines(q)o(1,q)if not q:find'\n$'then q=q..'\n'end;return q:gmatch('([^\n]*)\n')end;function v.title(q)o(1,q)return q:gsub('(%S)(%S*)',function(a9,aj)return a9:upper()..aj:lower()end)end;v.capitalize=v.title;local ak='...'local al=#ak;function v.shorten(q,_,am)o(1,q)if#q>_ then if _a1 and a2>0 or a1>a0 and a2<0 then l={}else local C=1;l={}for F=a0,a1,a2 do l[C]=F;C=C+1 end end;return p(l)end;function j.map2(Z,A,B,...)y(1,A)y(2,B)Z=h(1,Z)local l={}for C,D in pairs(A)do l[C]=Z(D,B[C],...)end;return k(l,A,'List')end;function j.imap2(Z,A,B,...)w(2,A)w(3,B)Z=h(1,Z)local l,a3={},math.min(#A,#B)for F=1,a3 do l[F]=Z(A[F],B[F],...)end;return l end;function j.reduce(Z,E,a4)w(2,E)Z=h(1,Z)local a3=#E;if a3==0 then return a4 end;local l=a4 and Z(a4,E[1])or E[1]for F=2,a3 do l=Z(l,E[F])end;return l end;function j.foreach(E,Z,...)y(1,E)Z=h(2,Z)for C,D in pairs(E)do Z(D,C,...)end end;function j.foreachi(E,Z,...)w(1,E)Z=h(2,Z)for F=1,#E do Z(E[F],F,...)end end;function j.mapn(Z,...)Z=h(1,Z)local l={}local a5={...}local a6=1e40;for F=1,#a5 do a6=f(a6,#a5[F])end;for F=1,a6 do local a7,C={},1;for V=1,#a5 do a7[C]=a5[V][F]C=C+1 end;l[#l+1]=Z(g(a7))end;return l end;function j.pairmap(Z,E,...)y(1,E)Z=h(1,Z)local l={}for C,D in pairs(E)do local a8,a9=Z(C,D,...)if a9 then if l[a9]then if type(l[a9])=='table'then table.insert(l[a9],a8)else l[a9]={l[a9],a8}end else l[a9]=a8 end else l[#l+1]=a8 end end;return l end;local function aa(F,D)return F end;function j.keys(E)y(1,E)return p(j.pairmap(aa,E))end;local function ab(F,D)return D end;function j.values(E)y(1,E)return p(j.pairmap(ab,E))end;local function ac(F,D)return F,D end;function j.index_map(E)w(1,E)return r(j.pairmap(ac,E))end;local function ad(F,D)return true,D end;function j.makeset(E)w(1,E)return setmetatable(j.pairmap(ad,E),require('pl.Set'))end;function j.merge(A,B,ae)y(1,A)y(2,B)local l={}for C,D in pairs(A)do if ae or B[C]then l[C]=D end end;if ae then for C,D in pairs(B)do l[C]=D end end;return k(l,A,'Map')end;function j.union(A,B)return j.merge(A,B,true)end;function j.intersection(A,B)return j.merge(A,B,false)end;function j.difference(af,ag,ah)y(1,af)y(2,ag)local l={}for C,D in pairs(af)do if ag[C]==nil then l[C]=D end end;if ah then for C,D in pairs(ag)do if af[C]==nil then l[C]=D end end end;return k(l,af,'Map')end;function j.count_map(E,S)w(1,E)local l,ai={},{}S=h(2,S or'==')local a3=#E;for F=1,#E do local D=E[F]if not ai[D]then ai[D]=true;l[D]=1;for V=F+1,a3 do local aj=E[V]local ak=S(D,aj)if ak then l[D]=l[D]+1;ai[aj]=true end end end end;return r(l)end;function j.filter(E,al,X)w(1,E)al=h(2,al)local l,C={},1;for F=1,#E do local D=E[F]if al(D,X)then l[C]=D;C=C+1 end end;return k(l,E,'List')end;function j.zip(...)return j.mapn(function(...)return{...}end,...)end;local am;function am(an,ao,ap,aq,ar,as)ap=ap or 1;aq=aq or 1;local at;if not ar then ar=#ao;at=#ao else at=aq+f(ar-1,#ao-aq)end;if an==ao then if ap>aq and at>=ap then ao=j.sub(ao,aq,ar)aq=1;at=#ao end end;for F=aq,at do an[ap]=ao[F]ap=ap+1 end;if as then j.clear(an,ap)end;return an end;function j.icopy(an,ao,ap,aq,ar)w(1,an)w(2,ao)return am(an,ao,ap,aq,ar,true)end;function j.move(an,ao,ap,aq,ar)w(1,an)w(2,ao)return am(an,ao,ap,aq,ar,false)end;function j._normalize_slice(self,au,av)local aw=#self;if not au then au=1 end;if au<0 then au=aw+au+1 end;if not av then av=aw end;if av<0 then av=aw+1+av end;return au,av end;function j.sub(E,au,av)w(1,E)au,av=j._normalize_slice(E,au,av)local l={}for F=au,av do d(l,E[F])end;return k(l,E,'List')end;function j.set(E,x,ax,ay)w(1,E)ax,ay=ax or 1,ay or#E;if b.is_callable(x)then for F=ax,ay do E[F]=x(F)end else for F=ax,ay do E[F]=x end end end;function j.new(a3,x)local l={}j.set(l,x,1,a3)return l end;function j.clear(E,az)az=az or 1;for F=az,#E do e(E)end end;function j.insertvalues(E,...)i(1,E,'table')local aA,aB;if select('#',...)==1 then aA,aB=#E+1,...else aA,aB=...end;if#aB>0 then for F=#E,aA,-1 do E[F+#aB]=E[F]end;local aC=1-aA;for F=aA,aA+#aB-1 do E[F]=aB[F+aC]end end;return E end;function j.removevalues(E,ax,ay)i(1,E,'table')ax,ay=j._normalize_slice(E,ax,ay)for F=ax,ay do e(E,ax)end;return E end;local aD;aD=function(E,aE,aF)for C,D in pairs(E)do if D==aE then return C end end;for C,D in pairs(E)do if not aF[D]and type(D)=='table'then aF[D]=true;local l=aD(D,aE,aF)if l then l=tostring(l)if type(C)~='string'then return'['..C..']'..l else return C..'.'..l end end end end end;function j.search(E,aE,aG)y(1,E)local aF={[E]=true}if aG then for aH,D in pairs(aG)do aF[D]=true end end;return aD(E,aE,aF)end;function j.sort(E,aI)local aJ={}for C in pairs(E)do aJ[#aJ+1]=C end;c(aJ,aI)local F=0;return function()F=F+1;return aJ[F],E[aJ[F]]end end;function j.sortv(E,aI)aI=h(2,aI or'<')local aJ={}for C in pairs(E)do aJ[#aJ+1]=C end;c(aJ,function(aK,aL)return aI(E[aK],E[aL])end)local F=0;return function()F=F+1;return aJ[F],E[aJ[F]]end end;function j.readonly(E)local o={__index=E,__newindex=function(E,C,D)error("Attempt to modify read-only table",2)end,__pairs=function()return pairs(E)end,__ipairs=function()return ipairs(E)end,__len=function()return#E end,__metatable=false}return setmetatable({},o)end;return j diff --git a/extern/lualibs/pl/template.lua b/extern/lualibs/pl/template.lua new file mode 100644 index 00000000..2bf86f4c --- /dev/null +++ b/extern/lualibs/pl/template.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/template.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a=require'pl.utils'local b,c,d,e,f=table.insert,string.format,string.sub,string.find,string.gsub;local g="\n__R_size = __R_size + 1; __R_table[__R_size] = "local function h(i,j,k,l)local m=1;for n,o,p in j:gmatch(k)do o='('..d(o,2,-2)..')'b(i,g..c("%q",d(j,m,n-1)))b(i,g..c("__tostring(%s or '')",o))m=p end;local q;if l then q=c("%q",f(d(j,m),"\n",""))else q=c("%q",d(j,m))end;if q~='""'then b(i,g..q)end end;local function r(j,s,t,u,l)local k="()"..s.."(%b"..t..")()"local v=u.."+([^\n]*\n?)"local w,x="^"..v,"\n"..v;local i,m={"return function()\nlocal __R_size, __R_table, __tostring = 0, {}, __tostring",n=1},1;while true do local y,p,z=e(j,w,m)if not p then local A;A,p,z=e(j,x,m)h(i,d(j,m,A),k,l)if not p then break end end;if d(z,-1,-1)=="\n"then z=d(z,1,-2)end;b(i,"\n"..z)m=p+1 end;b(i,"\nreturn __R_table\nend")local B=false;if#i==3 and i[2]:find(g,1,true)==1 then i={"return "..i[2]:sub(#g+1,-1)}B=true end;return table.concat(i),B end;local C={}function C.substitute(D,E)E=E or{}local F,G=C.compile(D,{chunk_name=rawget(E,"_chunk_name"),escape=rawget(E,"_escape"),inline_escape=rawget(E,"_inline_escape"),inline_brackets=rawget(E,"_brackets"),newline=nil,debug=rawget(E,"_debug")})if not F then return F,G end;return F:render(E,rawget(E,"_parent"),rawget(E,"_debug"))end;local H=function(self,E,I,J)E=E or{}if I then setmetatable(E,{__index=I})end;setmetatable(self.env,{__index=E})local K,L=xpcall(self.fn,debug.traceback)if not K then if self.code and J then print(self.code)end;return nil,L,self.code end;return table.concat(L),nil,self.code end;function C.compile(D,M)M=M or{}local N=M.chunk_name or'TMP'local O=M.escape or'#'local s=M.inline_escape or'$'local P=M.inline_brackets or'()'local Q,B=r(D,s,P,O,M.newline)local E={__tostring=tostring}local R,G=a.load(Q,N,'t',E)if not R then return nil,G,Q end;if B then local S=R()return{fn=R(),env=E,render=function(self)return S,nil,self.code end,code=M.debug and Q or nil}end;return{fn=R(),env=E,render=H,code=M.debug and Q or nil}end;return C diff --git a/extern/lualibs/pl/test.lua b/extern/lualibs/pl/test.lua new file mode 100644 index 00000000..5ce532d2 --- /dev/null +++ b/extern/lualibs/pl/test.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/test.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a=require'pl.tablex'local b=require'pl.utils'local c=require'pl.pretty'local d=require'pl.path'local type,e,f=type,b.unpack,b.pack;local g=os.clock;local h=require'debug'local io=io;local function i(j)if type(j)=='table'and not(getmetatable(j)and getmetatable(j).__tostring)then return c.write(j,' ',true)elseif type(j)=='string'then return'"'..j..'"'else return tostring(j)end end;local k={}function k.error_handler(l,m,n,o,p)local q=io.stderr;q:write(d.basename(l)..':'..m..': assertion failed\n')q:write("got:\t",n,'\n')q:write("needed:\t",o,'\n')b.quit(1,p or"these values were not equal")end;local function r(j,s,p,t)local u=h.getinfo(3+(t or 0))k.error_handler(u.short_src,u.currentline,i(j),i(s),p)end;k.complain=r;function k.asserteq(j,s,v,t)local w=j==s;if not w then w=a.deepcompare(j,s,true,v)end;if not w then r(j,s,nil,t)end end;function k.assertmatch(x,y,t)if not x:match(y)then r(x,y,"these strings did not match",t)end end;function k.assertraise(z,A,t)local B,q;if type(z)=='table'then B,q=pcall(e(z))else B,q=pcall(z)end;if B or q:match(A)==nil then r(q,A,"these errors did not match",t)end end;function k.asserteq2(C,D,E,F,t)if C~=E then r(C,E,nil,t)end;if D~=F then r(D,F,nil,t)end end;local G={unpack=e}G.__index=G;function G.__tostring(self)local H={}for u=1,self.n do local I=self[u]H[u]=type(I)=='string'and('%q'):format(I)or tostring(I)end;return'tuple('..table.concat(H,', ')..')'end;function G.__eq(J,K)if J.n~=K.n then return false end;for u=1,J.n do if J[u]~=K[u]then return false end end;return true end;function G.__len(self)return self.n end;function k.tuple(...)return setmetatable(f(...),G)end;function k.timer(p,L,M,...)local N=g()for u=1,L do M(...)end;b.printf("%s: took %7.2f sec\n",p,g()-N)end;return k diff --git a/extern/lualibs/pl/text.lua b/extern/lualibs/pl/text.lua new file mode 100644 index 00000000..7c9fdc9d --- /dev/null +++ b/extern/lualibs/pl/text.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/text.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a=string.gsub;local b,c=table.concat,table.insert;local d=require'pl.utils'local e,f,g=d.bind1,d.split,d.assert_arg;local h=require'pl.types'.is_callable;local i=d.unpack;local j={}local function k(l)return setmetatable(l,require('pl.List'))end;local function m(n)return n:gsub('^%s+','')end;local function o(n)return m(n):gsub('%s+$','')end;local function p(q,r)return k(f(q,r))end;local function s(t,u,...)local v={}for w=1,#u do v[w]=t(u[w],...)end;return v end;local function x(q,y)local z=p(q,'\n')return b(s(e('..',y),z),'\n')..'\n'end;function j.indent(q,A,B)g(1,q,'string')g(2,A,'number')return x(q,string.rep(B or' ',A))end;function j.dedent(q)g(1,q,'string')local z=p(q,'\n')local C,D=(#z>0 and z[1]or''):find('^%s*')z=s(string.sub,z,D+1)return b(z,'\n')..'\n'end;function j.wrap(q,E)g(1,q,'string')E=E or 70;q=q:gsub('\n',' ')local w,F=1;local G,H={}while w<#q do F=w+E;if q:find("[%w']",F)then F=q:find('%W',F+1)end;H=q:sub(w,F)w=w+#H;c(G,o(H))end;return k(G)end;function j.fill(q,E)return b(j.wrap(q,E),'\n')..'\n'end;local I={}j.Template=I;I.__index=I;setmetatable(I,{__call=function(J,K)return I.new(K)end})function I.new(K)g(1,K,'string')local v={}v.tmpl=K;setmetatable(v,I)return v end;local function L(q,M,N)local O;if h(M)then O=M else function O(t)local q=M[t]if not q then if N then return t else error("not present in table "..t)end else return q end end end;local v=a(q,'%${([%w_]+)}',O)return a(v,'%$([%w_]+)',O)end;function I:substitute(M)g(1,M,'table')return L(self.tmpl,M,false)end;function I:safe_substitute(M)g(1,M,'table')return L(self.tmpl,M,true)end;function I:indent_substitute(M)g(1,M,'table')if not self.strings then self.strings=p(self.tmpl,'\n')end;local function O(H)return H:gsub('(%s*)%$([%w_]+)',function(y,t)local P;local q=M[t]if not q then error("not present in table "..t)end;if getmetatable(q)==I then P=q;q=q.tmpl else q=tostring(q)end;if q:find'\n'then q=x(q,y)end;if P then return L(q,M)else return q end end)end;local G=s(O,self.strings)return b(G,'\n')..'\n'end;function j.format_operator()local Q=string.format;local function R(S,...)local T={...}local w=1;for U in S:gmatch('%%.')do if U=='%s'and type(T[w])~='string'then T[w]=tostring(T[w])end;w=w+1 end;return Q(S,i(T))end;local function V(q,u)return q:gsub('%$([%w_]+)',u)end;getmetatable("").__mod=function(W,X)if X==nil then return W elseif type(X)=="table"and getmetatable(X)==nil then if#X==0 then return L(W,X,true)else return R(W,i(X))end elseif type(X)=='function'then return V(W,X)else return R(W,X)end end end;return j diff --git a/extern/lualibs/pl/types.lua b/extern/lualibs/pl/types.lua new file mode 100644 index 00000000..8a73a8b6 --- /dev/null +++ b/extern/lualibs/pl/types.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/types.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a=require'pl.utils'local b=math.ceil;local c=a.assert_arg;local d={}function d.is_callable(e)return type(e)=='function'or getmetatable(e)and getmetatable(e).__call and true end;d.is_type=a.is_type;local f=getmetatable(io.stdout)function d.type(e)local g=type(e)if g=='table'or g=='userdata'then local h=getmetatable(e)if h==f then return'file'elseif h==nil then return g else return h._name or"unknown "..g end else return g end end;function d.is_integer(i)return b(i)==i end;function d.is_empty(j,k)if j==nil then return true elseif type(j)=="table"then return next(j)==nil elseif type(j)=="string"then return j==""or not not k and not not j:find("^%s+$")else return true end end;local function l(m)if type(m)=='table'then return true end;return getmetatable(m)end;function d.is_indexable(m)local h=l(m)if h==true then return true end;return h and h.__len and h.__index and true end;function d.is_iterable(m)local h=l(m)if h==true then return true end;return h and h.__pairs and true end;function d.is_writeable(m)local h=l(m)if h==true then return true end;return h and h.__newindex and true end;local n={yes=true,y=true,["true"]=true,t=true,["1"]=true}local o={boolean=function(j,p,q)return j end,string=function(j,p,q)j=j:lower()if n[j]then return true end;for r,s in ipairs(p or{})do if type(s)=="string"and j==s:lower()then return true end end;return false end,number=function(j,p,q)return j~=0 end,table=function(j,p,q)if q and next(j)~=nil then return true end;return false end}function d.to_bool(j,p,q)local t;if p then c(2,p,"table")end;t=o[type(j)]if t then return t(j,p,q)elseif q and j~=nil then return true end;return false end;return d diff --git a/extern/lualibs/pl/url.lua b/extern/lualibs/pl/url.lua new file mode 100644 index 00000000..06b8039f --- /dev/null +++ b/extern/lualibs/pl/url.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/url.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a={}local function b(c)return string.format("%%%02X",string.byte(c))end;function a.quote(d,e)if type(d)~="string"then return d end;d=d:gsub("\n","\r\n")d=d:gsub("([^A-Za-z0-9 %-_%./])",b)if e then d=d:gsub(" ","+")d=d:gsub("/",b)else d=d:gsub(" ","%%20")end;return d end;local function f(g)return string.char(tonumber(g,16))end;function a.unquote(d)if type(d)~="string"then return d end;d=d:gsub("+"," ")d=d:gsub("%%(%x%x)",f)d=d:gsub("\r\n","\n")return d end;return a diff --git a/extern/lualibs/pl/utils.lua b/extern/lualibs/pl/utils.lua new file mode 100644 index 00000000..0d8bec53 --- /dev/null +++ b/extern/lualibs/pl/utils.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/utils.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a=string.format;local b=require'pl.compat'local c=io.stdout;local d=table.insert;local e=table.unpack;local f=b.is_windows;local g='default'local h;local i;local j={}local k={_VERSION="1.11.0"}for l,m in pairs(b)do k[l]=m end;k.patterns={FLOAT='[%+%-%d]%d*%.?%d*[eE]?[%+%-]?%d*',INTEGER='[+%-%d]%d*',IDEN='[%a_][%w_]*',FILE='[%a%.\\][:%][%w%._%-\\]*'}k.stdmt={List={_name='List'},Map={_name='Map'},Set={_name='Set'},MultiMap={_name='MultiMap'}}k.pack=table.pack;function k.unpack(n,o,p)return e(n,o or 1,p or n.n or#n)end;function k.printf(q,...)k.assert_string(1,q)k.fprintf(c,q,...)end;function k.fprintf(r,q,...)k.assert_string(2,q)r:write(a(q,...))end;do local function s(t,l,m,u)local v=rawget(t,l)if v and l~='_M'and l~='_NAME'and l~='_PACKAGE'and l~='_VERSION'then k.fprintf(io.stderr,"warning: '%s.%s' will not override existing symbol\n",u,l)return end;rawset(t,l,m)end;local function w(t,n)for l,m in pairs(t)do if m==n then return l end end;return'?'end;local x={}function k.import(n,t)t=t or _G;n=n or k;if type(n)=='string'then n=require(n)end;local u=w(t,n)if x[n]then return end;x[n]=u;for l,m in pairs(n)do s(t,l,m,u)end end end;function k.choose(y,z,A)return y and z or A end;function k.array_tostring(n,B,C)B,C=B or{},C or tostring;for o=1,#n do B[o]=C(n[o],o)end;return B end;function k.is_type(D,E)if type(E)=='string'then return type(D)==E end;local F=getmetatable(D)return E==F end;function k.assert_arg(G,H,E,I,J,K)if type(H)~=E then error(("argument %d expected a '%s', got a '%s'"):format(G,E,type(H)),K or 2)end;if I and not I(H)then error(("argument %d: '%s' %s"):format(G,H,J),K or 2)end;return H end;function k.function_arg(L,r,J)k.assert_arg(1,L,'number')local E=type(r)if E=='function'then return r end;if E=='string'then if not i then i=require'pl.operator'.optable end;local M=i[r]if M then return M end;local M,N=k.string_lambda(r)if not M then error(N..': '..r)end;return M elseif E=='table'or E=='userdata'then local F=getmetatable(r)if not F then error('not a callable object',2)end;local O=j[F]if not O then if not F.__call then error('not a callable object',2)end;return r else return O(r)end end;if not J then J=" must be callable"end;if L>0 then error("argument "..L..": "..J,2)else error(J,2)end end;function k.assert_string(G,H)return k.assert_arg(G,H,'string',nil,nil,3)end;function k.on_error(P)P=tostring(P)if({['default']=1,['quit']=2,['error']=3})[P]then g=P else local N="Bad argument expected string; 'default', 'quit', or 'error'. Got '"..tostring(P).."'"if g=='default'then error(N,2)end;h(N)end end;function k.raise(N)if g=='default'then return nil,N elseif g=='quit'then return k.quit(N)else error(N,2)end end;h=k.raise;function k.readfile(Q,R)local P=R and'b'or''k.assert_string(1,Q)local r,S=io.open(Q,'r'..P)if not r then return h(S)end;local T,U=r:read('*a')r:close()if not T then return h(Q..": "..U)end;return T end;function k.writefile(Q,V,R)local P=R and'b'or''k.assert_string(1,Q)k.assert_string(2,V)local r,N=io.open(Q,'w'..P)if not r then return h(N)end;local W,X=r:write(V)r:close()if not W then return h(Q..": "..X)end;return true end;function k.readlines(Q)k.assert_string(1,Q)local r,N=io.open(Q,'r')if not r then return h(N)end;local T={}for Y in r:lines()do d(T,Y)end;r:close()return T end;function k.executeex(Z,_)local a0=os.tmpname()local a1=os.tmpname()if f and not a0:find(':')then a0=os.getenv('TEMP')..a0;a1=os.getenv('TEMP')..a1 end;Z=Z.." > "..k.quote_arg(a0).." 2> "..k.quote_arg(a1)local a2,a3=k.execute(Z)local a4=k.readfile(a0,_)local a5=k.readfile(a1,_)os.remove(a0)os.remove(a1)return a2,a3,a4 or"",a5 or""end;function k.quote_arg(a6)if type(a6)=="table"then local a7={}for o,a8 in ipairs(a6)do a7[o]=k.quote_arg(a8)end;return table.concat(a7," ")end;if f then if a6==""or a6:find('[ \f\t\v]')then a6='"'..a6:gsub([[(\*)"]],[[%1%1\"]]):gsub([[\+$]],"%0%0")..'"'end;return a6:gsub('["^<>!|&%%]',"^%0")else if a6==""or a6:find('[^a-zA-Z0-9_@%+=:,./-]')then a6="'"..a6:gsub("'",[['\'']]).."'"end;return a6 end end;function k.quit(a9,J,...)if type(a9)=='string'then k.fprintf(io.stderr,a9,J,...)io.stderr:write('\n')a9=-1 elseif J then k.fprintf(io.stderr,J,...)io.stderr:write('\n')end;os.exit(a9,true)end;function k.escape(aa)k.assert_string(1,aa)return aa:gsub('[%-%.%+%[%]%(%)%$%^%%%?%*]','%%%1')end;function k.split(aa,ab,ac,G)k.assert_string(1,aa)local ad,ae,d=string.find,string.sub,table.insert;local af,ag=1,{}if not ab then ab='%s+'end;if ab==''then return{aa}end;while true do local ah,ai=ad(aa,ab,af,ac)if not ah then local aj=ae(aa,af)if aj~=''then d(ag,aj)end;if#ag==1 and ag[1]==''then return{}else return ag end end;d(ag,ae(aa,af,ah-1))if G and#ag==G then ag[#ag]=ae(aa,af)return ag end;af=ai+1 end end;function k.splitv(aa,ab,ac,G)return e(k.split(aa,ab,ac,G))end;function k.memoize(ak)local al={}return function(l)local T=al[l]if T==nil then T=ak(l)al[l]=T end;return T end end;function k.add_function_factory(F,am)j[F]=am end;local function an(r)if r:find'^|'or r:find'_'then local ao,ap=r:match'|([^|]*)|(.+)'if r:find'_'then ao='_'ap=r else if not ao then return h'bad string lambda'end end;local aq='return function('..ao..') return '..ap..' end'local M,N=k.load(aq)if not M then return h(N)end;M=M()return M else return h'not a string lambda'end end;k.string_lambda=k.memoize(an)function k.bind1(M,ar)M=k.function_arg(1,M)return function(...)return M(ar,...)end end;function k.bind2(M,ar)M=k.function_arg(1,M)return function(as,...)return M(as,ar,...)end end;do local at=function(J,au)if au then warn(J,"\n",au)else warn(J)end end;function k.set_deprecation_func(ak)if ak==nil then at=function()end else k.assert_arg(1,ak,"function")at=ak end end;function k.raise_deprecation(av)k.assert_arg(1,av,"table")if type(av.message)~="string"then error("field 'message' of the options table must be a string",2)end;local au;if not av.no_trace then au=debug.traceback("",2):match("[\n%s]*(.-)$")end;local J;if av.deprecated_after and av.version_removed then J=(" (deprecated after %s, scheduled for removal in %s)"):format(tostring(av.deprecated_after),tostring(av.version_removed))elseif av.deprecated_after then J=(" (deprecated after %s)"):format(tostring(av.deprecated_after))elseif av.version_removed then J=(" (scheduled for removal in %s)"):format(tostring(av.version_removed))else J=""end;J=av.message..J;if av.source then J="["..av.source.."] "..J else if J:sub(1,1)=="@"then error("message cannot start with '@'",2)end end;at(J,au)end end;return k diff --git a/extern/lualibs/pl/xml.lua b/extern/lualibs/pl/xml.lua new file mode 100644 index 00000000..44a52ee5 --- /dev/null +++ b/extern/lualibs/pl/xml.lua @@ -0,0 +1,6 @@ +-- Penlight 1.11.0-1 | /lua/pl/xml.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (C) 2009-2016 Steve Donovan, David Manura. +-- 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 a=require'pl.utils'local b=a.split;local c=table.insert;local d=table.concat;local e=table.remove;local f=string.match;local tostring=tostring;local setmetatable=setmetatable;local getmetatable=getmetatable;local pairs=pairs;local ipairs=ipairs;local type=type;local next=next;local print=print;local g=a.unpack;local h=string.gsub;local i=string.find;local pcall,require,io=pcall,require,io;local j={}local k={__type="doc"}k.__index=k;function j.new(l,m)local n={tag=l,attr=m or{},last_add={}}return setmetatable(n,k)end;function j.parse(o,p,q)local r,s,t;if q then r=j.basic_parse else s,t=pcall(require,'lxp.lom')if not s then r=j.basic_parse else r=t.parse end end;if p then local u,v=io.open(o)if not u then return nil,v end;o=u:read'*a'u:close()end;local n,v=r(o)if not n then return nil,v end;if t then j.walk(n,false,function(w,x)setmetatable(x,k)end)end;return n end;function k:addtag(l,y)local z=j.new(l,y)(self.last_add[#self.last_add]or self):add_direct_child(z)c(self.last_add,z)return self end;function k:text(A)(self.last_add[#self.last_add]or self):add_direct_child(A)return self end;function k:up()e(self.last_add)return self end;function k:reset()local B=self.last_add;for C=1,#B do B[C]=nil end;return self end;function k:add_direct_child(D)c(self,D)end;function k:add_child(D)(self.last_add[#self.last_add]or self):add_direct_child(D)return self end;function k:set_attribs(E)for F,G in pairs(E)do self.attr[F]=G end end;function k:set_attrib(H,G)self.attr[H]=G end;function k:get_attribs()return self.attr end;local function I(z)return type(z)=='string'end;function j.elem(l,J)local z=j.new(l)if I(J)then J={J}end;if j.is_tag(J)then c(z,J)elseif type(J)=='table'then for F,G in pairs(J)do if I(F)then z.attr[F]=G;c(z.attr,F)else z[F]=G end end end;return z end;function j.tags(K)local L={}if I(K)then K=b(K,'%s*,%s*')end;for w,l in ipairs(K)do local M=function(J)return j.elem(l,J)end;c(L,M)end;return g(L)end;local N={}local function O(P)if I(P)then if N[P]then P=N[P]else local Q,v=P;P,v=j.parse(Q,false,true)if not P then return nil,v end;N[Q]=P end elseif not j.is_tag(P)then return nil,"template is not a document"end;return P end;local function R(S)return#S==0 or type(S[1])~='table'end;local function T(S)for C,G in ipairs(S)do S[tostring(C)]=G end end;function k.subst(P,S)local v;if type(S)~='table'or not next(S)then return nil,"data must be a non-empty table"end;if R(S)then T(S)end;P,v=O(P)if v then return nil,v end;local function U(V)return j.clone(P,function(z)return z:gsub('%$(%w+)',V)end)end;if R(S)then return U(S)end;local K={}for w,V in ipairs(S)do T(V)c(K,U(V))end;if S.tag then K=j.elem(S.tag,K)end;return K end;function k:child_with_name(l)for w,D in ipairs(self)do if D.tag==l then return D end end end;local W;function W(self,l,K,X)for w,D in ipairs(self)do if type(D)=='table'then if D.tag==l then c(K,D)end;if X then W(D,l,K,X)end end end end;function k:get_elements_with_name(l,Y)local Z={}W(self,l,Z,not Y)return Z end;function k:children()local C=0;return function(H)C=C+1;return H[C]end,self,C end;function k:first_childtag()if#self==0 then return end;for w,E in ipairs(self)do if type(E)=='table'then return E end end end;function k:matching_tags(l,_)_=_ or self.attr.xmlns;local a0=self;local a1,a2,G=1,#a0;return function()for C=a1,a2 do G=a0[C]if(not l or G.tag==l)and(not _ or _==G.attr.xmlns)then a1=C+1;return G end end end,a0,a1 end;function k:childtags()local C=0;return function(H)local G;repeat C=C+1;G=self[C]if G and type(G)=='table'then return G end until not G end,self[1],C end;function k:maptags(a3)local a4=j.is_tag;local C=1;while C<=#self do if a4(self[C])then local a5=a3(self[C])if a5==nil then e(self,C)else self[C]=a5;C=C+1 end end end;return self end;local a6;do local a7={["'"]="'",["\""]=""",["<"]="<",[">"]=">",["&"]="&"}function a6(Q)return h(Q,"['&<>\"]",a7)end;j.xml_escape=a6 end;local function a8(E,a9,self,a6,aa,ab,ac,ad)local ae=0;local l=E.tag;local af,ag=""," "if ac then af='\n'..ab end;if ad then ag='\n'..ab..ad end;c(a9,af.."<"..l)local function ah(F,G)if i(F,"\1",1,true)then local ai,aj=f(F,"^([^\1]*)\1?(.*)$")ae=ae+1;c(a9," xmlns:ns"..ae.."='"..a6(ai).."' ".."ns"..ae..":"..aj.."='"..a6(G).."'")elseif not(F=="xmlns"and G==aa)then c(a9,ag..F.."='"..a6(G).."'")end end;if#E.attr>0 then for w,F in ipairs(E.attr)do ah(F,E.attr[F])end else for F,G in pairs(E.attr)do ah(F,G)end end;local ak,al=#E;if ak==0 then local am="/>"if ad then am='\n'..ab..am end;c(a9,am)else c(a9,">")for an=1,ak do local D=E[an]if D.tag then self(D,a9,self,a6,E.attr.xmlns,ab and ab..ac,ac,ad)al=true else c(a9,a6(D))end end;c(a9,(al and af or'').."")end end;function j.tostring(E,ab,ac,ad,ao)local a9={}if ao then if type(ao)=="string"then a9[1]=ao else a9[1]=""end end;a8(E,a9,a8,a6,nil,ab,ac,ad)return d(a9)end;k.__tostring=j.tostring;function k:get_text()local Z={}for C,ap in ipairs(self)do if I(ap)then c(Z,ap)end end;return d(Z)end;function j.clone(n,aq)local ar={}local function as(at,au,av)if type(at)~="table"then if aq and I(at)then return aq(at,au,av)else return at end elseif ar[at]then return ar[at]end;local aw={}ar[at]=aw;local l=at.tag;aw.tag=as(l,'*TAG',av)if at.attr then local Z={}for m,ax in pairs(at.attr)do Z[m]=as(ax,m,at)end;aw.attr=Z end;for ay=1,#at do local G=as(at[ay],'*TEXT',at)c(aw,G)end;return setmetatable(aw,getmetatable(at))end;return as(n)end;k.filter=j.clone;function j.compare(az,aA)local aB=type(az)local aC=type(aA)if aB~=aC then return false,'type mismatch'end;if aB=='string'then return az==aA and true or'text '..az..' ~= text '..aA end;if aB~='table'or aC~='table'then return false,'not a document'end;if az.tag~=aA.tag then return false,'tag '..az.tag..' ~= tag '..aA.tag end;if#az~=#aA then return false,'size '..#az..' ~= size '..#aA..' for tag '..az.tag end;for F,G in pairs(az.attr)do if aA.attr[F]~=G then return false,'mismatch attrib'end end;for F,G in pairs(aA.attr)do if az.attr[F]~=G then return false,'mismatch attrib'end end;for C=1,#az do local aD,v=j.compare(az[C],aA[C])if not aD then return v end end;return true end;function j.is_tag(x)return type(x)=='table'and I(x.tag)end;function j.walk(n,aE,aF)if not aE then aF(n.tag,n)end;for w,x in ipairs(n)do if j.is_tag(x)then j.walk(x,aE,aF)end end;if aE then aF(n.tag,n)end end;local aG={br=true,img=true,meta=true,frame=true,area=true,hr=true,base=true,col=true,link=true,input=true,option=true,param=true,isindex=true,embed=true}local aH={quot="\"",apos="'",lt="<",gt=">",amp="&"}local function aI(Q)return Q:gsub("&(%a+);",aH)end;function j.parsehtml(z)return j.basic_parse(z,false,true)end;function j.basic_parse(z,aJ,aK)local c,e=table.insert,table.remove;local i,aL=string.find,string.sub;local aM={}local aN={}local function aO(z)local aP={}z:gsub("([%w:%-_]+)%s*=%s*([\"'])(.-)%2",function(aQ,w,H)if aK then aQ=aQ:lower()end;aP[aQ]=aI(H)end)if aK then z:gsub("([%w:%-_]+)%s*=%s*([^\"']+)%s*",function(aQ,H)aQ=aQ:lower()aP[aQ]=aI(H)end)end;return aP end;c(aM,aN)local aR,aS,aT,aU,aV,w,aW;local C=1;local aX;w,aW=i(z,'^%s*<%?[^%?]+%?>%s*')if not aW then w,aW=i(z,'^%s*%s*')end;if aW then C=aW+1 end;while true do aR,aX,aS,aT,aU,aV=i(z,"<([%/!]?)([%w:%-_]+)(.-)(%/?)>",C)if not aR then break end;if aS=="!"then if not(aT:match'%-%-$'and aU=='')then if aU:match'%-%-$'then aX=aX-2 end;w,aX=i(z,"-->",aX,true)end else local A=aL(z,C,aR-1)if aK then aT=aT:lower()if aG[aT]then aV="/"end end;if aJ or not i(A,"^%s*$")then c(aN,aI(A))end;if aV=="/"then c(aN,setmetatable({tag=aT,attr=aO(aU),empty=1},k))elseif aS==""then aN=setmetatable({tag=aT,attr=aO(aU)},k)c(aM,aN)else local aY=e(aM)aN=aM[#aM]if#aM<1 then error("nothing to close with "..aT..':'..A)end;if aY.tag~=aT then error("trying to close "..aY.tag.." with "..aT.." "..A)end;c(aN,aY)end end;C=aX+1 end;local A=aL(z,C)if aJ or not i(A,"^%s*$")then c(aM[#aM],aI(A))end;if#aM>1 then error("unclosed "..aM[#aM].tag)end;local Z=aM[1]return I(Z[1])and Z[2]or Z[1]end;local function aV(m)return not m or not next(m)end;local function aZ(x)return type(x)=='table'and x.tag~=nil end;local function a_(E)local b0,ax=next(E)if next(E,b0)~=nil then return false end;return b0,ax end;local function b1(Z,b2)if not aV(b2)then local b0;if b2._ then b0=b2._;b2._=nil;if aV(b2)then return end end;local b3,b4=a_(b2)if b3==0 then b2=b4 end;if b0 then Z[b0]=b2 else c(Z,b2)end end end;local function b5(b6)if b6:find'^%d+$'then b6=tonumber(b6)end;return b6 end;local function b7(Z,b6,ax)b6=b5(b6:sub(2))Z[b6]=ax;return true end;local b8;function b8(x,b6,Z,b9)local a5=true;if x==nil then x=''end;if I(x)then if not I(b6)then return false end;if j.debug then print(x,b6)end;if b6:find'^%$'then return b7(Z,b6,x)else return x==b6 end else if j.debug then print(x.tag,b6.tag)end;local ba=b6.tag:match'^(.-)%-$'if ba then ba=b5(ba)Z[ba]=x.tag end;if x.tag==b6.tag or ba then if not aV(b6.attr)then if aV(x.attr)then a5=false else for bb,bc in pairs(b6.attr)do local bd=x.attr[bb]if not b8(bd,bc,Z)then a5=false;break end end end end;if a5 and#b6>0 then local C,aX=1,1;local function be()aX=aX+1;if I(x[aX])then aX=aX+1 end;return aX<=#x end;repeat local bf=b6[C]if aZ(bf)and bf.repeated then local bg;repeat local b2={}a5=b8(x[aX],bf,b2,false)if a5 then bg=false;b1(Z,b2)end until not be()or bg and not a5;C=C+1 else a5=b8(x[aX],bf,Z,false)if a5 then C=C+1 end end until not be()or C>#b6;if C>#b6 then return true end end;if a5 then return true end else a5=false end;if b9 then for D in x:childtags()do a5=b8(D,b6,Z,b9)if a5 then break end end end end;return a5 end;function k:match(b6)local v;b6,v=O(b6)if not b6 then return nil,v end;j.walk(b6,false,function(w,x)if I(x[1])and aZ(x[2])and I(x[3])and x[1]:find'%s*{{'and x[3]:find'}}%s*'then e(x,1)e(x,2)x[1].repeated=true end end)local Z={}local a5=b8(self,b6,Z,true)return Z,a5 end;return j diff --git a/extern/lualibs/serpent.lua b/extern/lualibs/serpent.lua new file mode 100644 index 00000000..4e7e0b83 --- /dev/null +++ b/extern/lualibs/serpent.lua @@ -0,0 +1,6 @@ +-- Serpent @879580fb21933f63eb23ece7d60ba2349a8d2848 | /src/serpent.lua | https://github.com/pkulchenko/serpent | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4 +-- Copyright (c) 2012-2018 Paul Kulchenko (paul@kulchenko.com) +-- 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 a,b="serpent","0.302"local c,d="Paul Kulchenko","Lua serializer and pretty printer"local e={[tostring(1/0)]='1/0 --[[math.huge]]',[tostring(-1/0)]='-1/0 --[[-math.huge]]',[tostring(0/0)]='0/0'}local f={thread=true,userdata=true,cdata=true}local getmetatable=debug and debug.getmetatable or getmetatable;local g=function(h)return next,h end;local i,j,k={},{},_G or _ENV;for l,m in ipairs({'and','break','do','else','elseif','end','false','for','function','goto','if','in','local','nil','not','or','repeat','return','then','true','until','while'})do i[m]=true end;for m,b in g(k)do j[b]=m end;for l,n in ipairs({'coroutine','debug','io','math','string','table','os'})do for m,b in g(type(k[n])=='table'and k[n]or{})do j[b]=n..'.'..m end end;local function o(h,p)local q,r,s,t=p.name,p.indent,p.fatal,p.maxnum;local u,v,w=p.sparse,p.custom,not p.nohuge;local x,y=p.compact and''or' ',p.maxlevel or math.huge;local z,A=tonumber(p.maxlength),p.metatostring;local B,C='_'..(q or''),p.comment and(tonumber(p.comment)or math.huge)local D=p.numformat or"%.17g"local E,F,G,H={},{'local '..B..'={}'},{},0;local function I(J)return'_'..tostring(tostring(J)):gsub("[^%w]",""):gsub("(%d%w+)",function(o)if not G[o]then H=H+1;G[o]=H end;return tostring(G[o])end)end;local function K(o)return type(o)=="number"and tostring(w and e[tostring(o)]or D:format(o))or type(o)~="string"and tostring(o)or("%q"):format(o):gsub("\010","n"):gsub("\026","\\026")end;local function L(o,M)return C and(M or 0)=y then return a6 ..'{}'..L('maxlvl',a1)end;E[h]=_ or a4;if next(h)==nil then return a6 ..'{}'..L(h,a1)end;if z and z<0 then return a6 ..'{}'..L('maxlen',a1)end;local U,T,aa=math.min(#h,t or#h),{},{}for ab=1,U do T[ab]=ab end;if not t or#Tt then T[t+1]=nil end;if p.sortkeys and#T>U then S(T,h,p.sortkeys)end;local u=u and#T>U;for a,ab in ipairs(T)do local ac,ad,a0=h[ab],type(ab),a<=U and not u;if p.valignore and p.valignore[ac]or p.keyallow and not p.keyallow[ab]or p.keyignore and p.keyignore[ab]or p.valtypeignore and p.valtypeignore[type(ac)]or u and ac==nil then elseif ad=='table'or ad=='function'or f[ad]then if not E[ab]and not j[ab]then F[#F+1]='placeholder'local a5=O(B,I(ab))F[#F]=Z(ab,a5,r,a5,B,true)end;F[#F+1]='placeholder'local P=E[h]..'['..tostring(E[ab]or j[ab]or I(ab))..']'F[#F]=P..x..'='..x..tostring(E[ac]or Z(ac,nil,r,P))else aa[#aa+1]=Z(ac,ab,r,nil,E[h],a0,a1+1)if z then z=z-#aa[#aa]if z<0 then break end end end end;local ae=string.rep(r or'',a1)local af=r and'{\n'..ae..r or'{'local ag=table.concat(aa,','..(r and'\n'..ae..r or x))local ah=r and"\n"..ae..'}'or'}'return(v and v(a6,af,ag,ah,a1)or a6 ..af..ag..ah)..L(h,a1)elseif f[a2]then E[h]=_ or a4;return a6 ..N(h,a1)elseif a2=='function'then E[h]=_ or a4;if p.nocode then return a6 .."function() --[[..skipped..]] end"..L(h,a1)end;local ai,aj=pcall(string.dump,h)local ak=ai and"((loadstring or load)("..K(aj)..",'@serialized'))"..L(h,a1)return a6 ..(ak or N(h,a1))else return a6 ..K(h)end end;local al=r and"\n"or";"..x;local ag=Z(h,q,r)local ah=#F>1 and table.concat(F,al)..al or''local am=p.comment and#F>1 and x.."--[[incomplete output with shared/self-references skipped]]"or''return not q and ag..am or"do local "..ag..al..ah.."return "..q..al.."end"end;local function an(ao,p)local ap=p and p.safe==false and k or setmetatable({},{__index=function(h,m)return h end,__call=function(h,...)error("cannot call functions")end})local aq,aj=(loadstring or load)('return '..ao,nil,nil,ap)if not aq then aq,aj=(loadstring or load)(ao,nil,nil,ap)end;if not aq then return aq,aj end;if setfenv then setfenv(aq,ap)end;return pcall(aq)end;local function ar(X,Y)if Y then for m,b in g(Y)do X[m]=b end end;return X end;return{_NAME=a,_COPYRIGHT=c,_DESCRIPTION=d,_VERSION=b,serialize=o,load=an,dump=function(X,p)return o(X,ar({name='_',compact=true,sparse=true},p))end,line=function(X,p)return o(X,ar({sortkeys=true,comment=true},p))end,block=function(X,p)return o(X,ar({indent=' ',sortkeys=true,comment=true},p))end} diff --git a/scripts/corescripts/default.lua b/scripts/corescripts/default.lua new file mode 100644 index 00000000..7c6e1511 --- /dev/null +++ b/scripts/corescripts/default.lua @@ -0,0 +1,41 @@ +-- Default core script +-- Runs all input modifiers and generation modifiers in forward order, and +-- runs all output modifiers in reverse order + +kobold, koboldcore = require("bridge")() -- This line is optional and is only for EmmyLua type annotations + +---@class KoboldCoreScript +local corescript = {} + + +-- Run all the input modifiers from top to bottom +function corescript.inmod() + for i, userscript in ipairs(koboldcore.userscripts) do + if userscript.inmod ~= nil then + userscript.inmod() + end + end +end + +-- Run all the generation modifiers from top to bottom +function corescript.genmod() + for i, userscript in ipairs(koboldcore.userscripts) do + if userscript.genmod ~= nil then + userscript.genmod() + end + end +end + +-- Run all the generation modifiers from bottom to top +function corescript.outmod() + local userscript + for i = #koboldcore.userscripts, 1, -1 do + userscript = koboldcore.userscripts[i] + if userscript.outmod ~= nil then + userscript.outmod() + end + end +end + + +return corescript