/*
 * 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 MAINTENANCE="maintenance";const T_COMP="-- Component --";const T_COMP_L=T_COMP.length;const T_SINCE="-- Since --";const T_SINCE_L=T_SINCE.length;const T_SUPERSEDES="-- Superseded By --";const PAD=4;function show(metaLib,appCtx){var data;data=_jetLegacyComponents(metaLib);data=_UserAndCoreComponents(metaLib,data);_display(data,appCtx.colors);return true};function _jetLegacyComponents(metaLib){var comps,clazz,obj,deps,dep,hdr,since;var ret,list,maxTag=0;maxSince=0;comps=metaLib._json;for(clazz in comps){if(!metaLib._nonClasses.includes(clazz)){if(!clazz.startsWith("oj.")){continue}obj=comps[clazz];hdr=obj.header;if(deps=hdr?.ojdeprecated){for(i=0;i<deps.length;i++){dep=deps[i];if(dep.type===MAINTENANCE){if(!ret){list=[];ret={list:list}}tag=metaLib.getTagFromClass(clazz);since=dep.since?dep.since:"";rep=dep.value?"<"+dep.value.join(", <")+">":"";if(tag.length>maxTag){maxTag=tag.length}if(since.length>maxSince){maxSince=since.length}list.push({tag:tag,since:since,rep:rep})}}}}}if(ret){ret.maxTag=maxTag;ret.maxSince=maxSince}return ret};function _UserAndCoreComponents(metaLib,data){var list,tags,maxTag,maxSince,since,rep;if(!(tags=metaLib.getNonLegacyMaintenanceTags())){return data}if(data){list=data.list;maxTag=data.maxTag;maxSince=data.maxSince}else{list=[];data={list:list};maxTag=0;maxSince=0}tags.forEach(tag=>{let obj={};o=metaLib.getTagMaintenanceStatus(tag);since=o.since?o.since:"";rep=o.value?"<"+o.value.join(", <")+">":"";list.push({tag:tag,since:since,rep:rep});if(tag.length>maxTag){maxTag=tag.length}if(since.length>maxSince){maxSince=since.length}});data.maxTag=maxTag;data.maxSince=maxSince;return data};function _display(data,clr){if(!data){console.log("No components in 'maintenance' mode.");return}const{list,maxTag,maxSince}=data;const colTag=Math.max(T_COMP_L,maxTag)+PAD;const colSince=Math.max(T_SINCE_L,maxSince)+PAD;console.log(clr.BOLDGREEN(_left(T_COMP,colTag)+_left(T_SINCE,colSince)+T_SUPERSEDES));for(o of list){console.log(clr.BOLDRED(_left(o.tag,colTag))+_left("  "+o.since,colSince)+clr.BOLDYELLOW(o.rep))}};function _left(s,n){var len=n-s.length>=0?n-s.length:0;return s+" ".repeat(len)};function _center(s,n){if(s.length>=n){return s}var lenL=n-s.length;lenL=lenL>0?Math.floor(lenL/=2):0;return" ".repeat(lenL)+s+" ".repeat(n-lenL-s.length)}module.exports.showMaintenance=show;