/*
 * 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-tsx-redwood-bp-btn-avatar";const DESCRIPTION="Buttons should not contain avatars, they may not correctly align within the button";const SHORT_DESCRIPTION=DESCRIPTION;class Rule{getName(){return RULENAME}getDescription(){return DESCRIPTION}getShortDescription(){return SHORT_DESCRIPTION}register(regCtx){this._tsxUtils=regCtx.utils.tsxUtils;return{"Tsx<oj-button>":this._onBtn,"Tsx<oj-c-button>":this._onBtn,"Tsx<oj-menu-button>":this._onBtn,"Tsx<oj-c-menu-button>":this._onBtn,"Tsx<oj-c-progress-button>":this._onBtn,"Tsx<oj-c-toggle-button>":this._onBtn}}_onBtn(ruleCtx,tsxComp){var childs;this._tsxComp=tsxComp;if(childs=tsxComp.children){for(let i=0;i<childs.length;i++){if(this._check(ruleCtx,childs[i],tsxComp.name)){return}};}}_check(ruleCtx,child,btnName){var childs;if(!child||!child.name||child.type!=="TsxComponent"){return false}if(_isAvatar(child.name)){this._emitIssue(ruleCtx,child,btnName);return true}else if(child.name==="span"||child.name.startsWith("oj-bind")){if(childs=child.children){for(let i=0;i<childs.length;i++){if(this._check(ruleCtx,childs[i],btnName)){return true};}}}return false}_emitIssue(ruleCtx,avatar,btnName){let issue=new ruleCtx.Issue(`An avatar should not be used inside <${btnName}> in Redwood theme`);this._tsxUtils.setIssuePosition(issue,avatar);ruleCtx.reporter.addIssue(issue,ruleCtx)}}function _isAvatar(tagName){return tagName==="oj-avatar"||tagName==="oj-c-avatar"};module.exports=Rule;