/*
 * 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 RULE_NAME="oj-tsx-ojtag-deprecated";const SHORT="Deprecated custom components should not be used";const LONG="Deprecated custom components should not be used. Refer to the diagnostic issued for a suggested replacement.";const JET_RELS=2;const SEV_BLOCKER="blocker";const MSG_ID_AGED="_aged";const MSG_ID_USER="_user";const DOT=".";const OJ_DYNAMIC="oj-dynamic";const OJ_DYN="oj-dyn";class Rule{getName(){return RULE_NAME}getDescription(){return LONG}getShortDescription(){return SHORT}register(regCtx){this._metaLib=regCtx.utils.metaLib;return{"TsxRenderComponent":this._onTsxRC}}_onTsxRC(ruleCtx,tsxRC){tsxRC.components.forEach(tsxComp=>{this._checkDeprecatedTags(ruleCtx,tsxComp)})}_checkDeprecatedTags(ruleCtx,tsxComp){var tagName,status;if(tsxComp.isWCTag){tagName=tsxComp.name;if(tagName!=="oj-slot"){if(status=this._metaLib.isTagDeprecated(tagName)){this._emitIssue(ruleCtx,tsxComp,status)}}}if(tsxComp.children){tsxComp.children.forEach(child=>{if(child.name!=="oj-slot"){if(status=this._checkDeprecatedTags(ruleCtx,child)){this._emitIssue(ruleCtx,child,status)}}})}}_emitIssue(ruleCtx,tsxTag,status){var descript=status.description?` ${status.description}`:"";var since=status.since?" (since "+status.since+")":null;var value="";var tagName=tsxTag.name;if(descript&&!descript.endsWith(DOT)){descript+=DOT}if(status.value&&status.value.length){value=` Available alternative${status.value.length===1?" is":"s are"}`;value+=`: <${status.value.join(">, ")}>.`}let issue=new ruleCtx.Issue(`<${tagName}> is deprecated${since}.${descript}${value}`);if(this._metaLib.isJetTag(tagName)||tagName===OJ_DYNAMIC||tagName===OJ_DYN){if(status.since&&ruleCtx.utils.jafLib.getMajorReleaseCount(status.since)>JET_RELS){issue.setSeverity(SEV_BLOCKER);issue.setMsgKey(RULE_NAME+MSG_ID_AGED)}}else if(this._metaLib.isComponentTag(tagName)){issue.setMsgKey(RULE_NAME+MSG_ID_USER)}issue.setPosition(tsxTag.loc.start.line,tsxTag.loc.start.column,tsxTag.range[0],tsxTag.range[1]);ruleCtx.reporter.addIssue(issue,ruleCtx)}};module.exports=Rule;