-- Compiled with @isentinel/roblox-ts v4.0.11 local TS = _G[script] local is = TS.import(script, TS.getModule(script, "@lisachandra", "core").utils.type).is local _centurion = TS.import(script, TS.getModule(script, "@rbxts", "centurion").out) local ListTypeBuilder = _centurion.ListTypeBuilder local TransformResult = _centurion.TransformResult local TypeBuilder = _centurion.TypeBuilder --[[ * * Creates a {@link ListArgumentType} from a single-value argument type, enabling comma-separated * lists of that type in Centurion commands. * * @example * ```ts * const PlayersList = makeListableType("players", CenturionType.Player); * ```; * * @param name - The name for the generated list type. * @param userType - The base single-argument type to wrap as a list. * @returns A registered list argument type that transforms and suggests * multiple values at once. ]] local function makeListableType(name, userType) return ListTypeBuilder:create(name):transform(function(input, executor) local transformed = {} for _, text in input do local result = userType.transform(text, executor) if not result.ok then return result end local _value = result.value table.insert(transformed, _value) end return TransformResult.ok(transformed) end):suggestions(function(input, executor) if not userType.suggestions then return {} end local suggestions = {} for _, text in input do for _1, suggestion in userType.suggestions(text, executor) do table.insert(suggestions, suggestion) end end -- ▼ ReadonlyArray.filter ▼ local _newValue = {} local _callback = function(value, index) local _suggestions = suggestions local _value = value return (table.find(_suggestions, _value) or 0) - 1 ~= index end local _length = 0 for _k, _v in suggestions do if _callback(_v, _k - 1, suggestions) == true then _length += 1 _newValue[_length] = _v end end -- ▲ ReadonlyArray.filter ▲ suggestions = _newValue return suggestions end):markForRegistration():build() end --[[ * * Creates a Centurion {@link SingleArgumentType} that accepts only the provided string enum values. * * @example * ```ts * const TeamType = makeEnumType("team", ["Red", "Blue", "Green"]); * ```; * * @param name - The name for the generated type. * @param enums - The allowed string values. * @returns A registered single-argument type with enum validation. ]] local function makeEnumType(name, enums) local _set = {} for _, _v in enums do _set[_v] = true end local enumSet = _set return TypeBuilder:create(name):transform(function(text) local _condition = is(text) if _condition then local _text = text _condition = enumSet[_text] ~= nil end return if _condition then TransformResult.ok(text) else TransformResult.err(`Invalid {name}: {text}`) end):suggestions(function() return enums end):markForRegistration():build() end return { makeListableType = makeListableType, makeEnumType = makeEnumType, }