---@class Utils Utils = {} --- Trim whitespace from both ends of a string. ---@param s string ---@return string function Utils.Trim(s) return s:match("^%s*(.-)%s*$") end --- Clamp a value between min and max. ---@param val number ---@param min number ---@param max number ---@return number function Utils.Clamp(val, min, max) if val < min then return min end if val > max then return max end return val end --- Sanitize a string for safe DB storage (basic, not a replacement for prepared statements). ---@param s string ---@return string function Utils.Sanitize(s) return tostring(s):gsub("[<>\"'%;]", "") end --- Check if a value exists in a plain table. ---@param tbl table ---@param val any ---@return boolean function Utils.TableContains(tbl, val) for _, v in ipairs(tbl) do if v == val then return true end end return false end --- Generate a simple UUID-like string (server-side only, uses os.time). ---@return string function Utils.UUID() local t = os.time() return string.format("%x-%x", t, math.random(0xFFFF)) end -- Logging helpers function Utils.Log(msg) print(("[pc-live] %s"):format(msg)) end function Utils.Warn(msg) print(("[pc-live] [WARN] %s"):format(msg)) end function Utils.Error(msg) print(("[pc-live] [ERROR] %s"):format(msg)) end