/*
 * Copyright (c) 2018, 2025, Oracle and/or its affiliates.
 * Licensed under The Universal Permissive License (UPL), Version 1.0
 * as shown at https://oss.oracle.com/licenses/upl/
 */
function showBuiltinGroups(nd,arg,appCtx){var packs;if(packs=nd.builtinpacks.getPackMetadata(nd,appCtx)){let prefixes=nd.builtinpacks.getPrefixes();for(let pack of prefixes){if(!arg||arg===pack){_display(packs[pack],true,appCtx.colors)}}}};function showExternalGroups(packs,arg,nd,appCtx){var pack,isExternal;if(arg){arg=arg.toLowerCase()}for(pack of packs){if(!pack.builtin){if(!arg||arg===pack.prefix.toLowerCase()){_display(pack,appCtx.colors);isExternal=true}}}if(!isExternal){console.log(appCtx.colors.BRIGHTRED("  No external rule packs declared!"))}};function _display(pack,isBuiltin,clr){var rules,rule,opts,summary={},oos=[],dis=[],dep=[],groups,group,msg,status;if(isBuiltin){_title(pack,clr);rules=pack.rules;for(rule in rules){opts=rules[rule];if(!(groups=opts.group)){continue};if(typeof groups==="string"){groups=[groups]}for(group of groups){if(!summary[group]){summary[group]=[]}summary[group].push(rule)}if(opts.hasOwnProperty("inservice")&&!opts.inservice){oos.push(rule)}else{if(opts.hasOwnProperty("enabled")&&!opts.enabled){dis.push(rule)}}if(opts.hasOwnProperty("status")&&opts.status==="deprecated"){dep.push(rule)}}groups=Object.keys(summary);groups=groups.sort()}else{_title(pack,clr);if(pack.groupMap){summary=pack.groupMap;groups=Object.keys(pack.groupMap);groups=groups.sort()}}if(!groups){console.log(clr.BRIGHTYELLOW(`●  No groups`));return}for(group of groups){console.log(clr.BRIGHTYELLOW(`●  ${group}:`));rules=summary[group];for(rule of rules){msg=`      ${rule}`;if(oos.includes(rule)){status="out of service";msg+=clr.RED(" (out of service)")}else{status="";if(dis.includes(rule)){if(status){status+=", "}status+="disabled by default"}if(dep.includes(rule)){if(status){status+=", "}status+="deprecated"}if(status){msg+=clr.RED(` (${status})`)}}console.log(msg)}}};function _title(pack,clr){console.log(`\n\n${clr.BRIGHTRED("\u25CF")}  ${clr.CYAN("Pack")} ${clr.BRIGHTRED(`${pack.prefix}`)} ${clr.CYAN(" - Group Rule Membership")}`)};module.exports.showBuiltinGroups=showBuiltinGroups;module.exports.showExternalGroups=showExternalGroups;