/*
 * Copyright (c) 2018, 2026, Oracle and/or its affiliates.
 * Licensed under The Universal Permissive License (UPL), Version 1.0
 * as shown at https://oss.oracle.com/licenses/upl/
 */
const REQUIRED="$required";function show(nd,arg,appCtx){var packs;if(packs=nd.builtinpacks.getPackMetadata(nd,appCtx)){let prefixes=nd.builtinpacks.getPrefixes();arg=arg?arg.toLowerCase():arg;for(let pack of prefixes){if(!arg||arg===pack)_display(packs[pack],appCtx.colors)}}};function _display(pack,clr){var rules,rule,opts,insrvc,enabled,i;var list=[],noload=[];console.log(`\n\n${clr.CYAN("---")}  ${clr.CYAN("Pack")} ${clr.BRIGHTRED(`${pack.prefix}`)} ${clr.CYAN(" - Rules by Load Order ---")}`);rules=pack.rules;for(rule in rules){opts=rules[rule];insrvc=opts.hasOwnProperty("inservice")?opts.inservice:true;enabled=opts.hasOwnProperty("enabled")?opts.enabled:true;if(opts[REQUIRED]){if(insrvc&&enabled){list.push(rule)}else{noload.push(rule);noload.push(insrvc);noload.push(enabled)}}}for(rule in rules){if(!list.includes(rule)){opts=rules[rule];insrvc=opts.hasOwnProperty("inservice")?opts.inservice:true;enabled=opts.hasOwnProperty("enabled")?opts.enabled:true;if(insrvc&&enabled){list.push(rule)}else{noload.push(rule);noload.push(insrvc);noload.push(enabled)}}}if(!list.length){console.log(clr.BRIGHTYELLOW(`●  No rules found.`));return}for(i=0;i<list.length;i++){let row;rule=list[i];row="["+(i+1)+"]";console.log(" "+clr.BRIGHTYELLOW(row)+_spacer(row,4)+" "+clr.BRIGHTGREEN(rule))}if(noload.length){let n,max=0;for(i=0;i<noload.length;i+=3){n=noload[i].length;max=n>max?n:max}console.log("\n"+"--- Not loaded : Out of service or disabled ---");for(i=0;i<noload.length;i++){let state;rule=noload[i++];insrvc=noload[i++];enabled=noload[i];state="("+(insrvc?"":clr.BRIGHTRED("out-of-service"))+(!insrvc&&!enabled?", ":"")+(enabled?"":"disabled")+")";console.log(" "+clr.BRIGHTRED(rule)+"  "+_spacer(rule,max)+state)}}};function _spacer(s,len){return" ".repeat(len-s.length)};module.exports.show=show;