/*
 * 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 RULENAME="oj-html-prop-anti-pattern";const DESCRIPTION="Some components, or component features, may be present but are not applicable for "+"use in all design systems and as such may be flagged as anti-patterns in the content "+"of a particular theme. In these cases, the feature should not be used if targeting the "+"design system in question.";const SHORT_DESCRIPTION="The specified component property is an anti pattern for code written for the designated theme.";const ANTIPATTERN="antiPattern";class Rule{getName(){return RULENAME}getDescription(){return DESCRIPTION}getShortDescription(){return SHORT_DESCRIPTION}register(regCtx){this._metaLib=regCtx.utils.metaLib;this._theme=regCtx.config.theme;return{webcomp:this._onWebComp}}_onWebComp(ruleCtx,tagName){var attrs,attr;if(ruleCtx.tagNode.attribs){attrs=ruleCtx.tagNode.attribs;for(attr in attrs){this._checkAttr(ruleCtx,tagName,attr,attrs[attr])}}}_checkAttr(ruleCtx,tagName,attrName,attrValue){var aStat,attrName;if(aStat=this._metaLib.getPropStatus(tagName,attrName,ANTIPATTERN)){let stat,themes,i;for(i=0;i<aStat.length;i++){stat=aStat[i];if(!(themes=stat.themes)){continue}if(!stat.hasOwnProperty("target")){if(themes.includes(this._theme)){this._emitIssue(1,ruleCtx,tagName,attrName,stat)}}else if(stat.target==="propertyValue"&&attrValue){if(!_isExpr(attrValue)&&!attrValue.startsWith("{")){if(stat.value&&stat.value.includes(attrValue)){this._emitIssue(2,ruleCtx,tagName,attrName,stat,attrValue)}}}}}}_emitIssue(issueType,ruleCtx,tagName,attrName,stat,attrValue){var issue,since,descript,themes,multi,attrPos;since=stat.since?` (since ${stat.since})`:"";descript=stat.description;descript=descript?` ${descript}`:"";descript=descript&&!descript.endsWith(".")?descript+".":descript;themes="'"+stat.themes.join("', '")+"'";if(multi=stat.themes.length>1){let x;if((x=themes.lastIndexOf(","))>=0){themes=themes.substring(0,x)+" and"+themes.substring(x+1)}}themes=`${multi?"s":""} ${themes}`;if(issueType===1){issue=new ruleCtx.Issue(`<${tagName}> attribute '${attrName}' is an antipattern in theme${themes}${since}.${descript} `)}else{issue=new ruleCtx.Issue(`<${tagName}> attribute '${attrName}' value '${attrValue}' is an antipattern in theme${themes}${since}.${descript} `);issue.setMsgKey(RULENAME+"_1")}attrPos=ruleCtx.utils.DomUtils.getAttribPosition(ruleCtx.data,ruleCtx.node,attrName);issue.setPosition(attrPos.row,attrPos.col,attrPos.start,attrPos.end);ruleCtx.reporter.addIssue(issue,ruleCtx)}}function _isExpr(s){return /[(}{}+*\/]/.test(s)};module.exports=Rule;