/*
 * 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-notag-style";const DESCRIPTION="If a 'notag' version  of a JET theme such as 'oj-redwood-notag-min-css' is applied, then it is recommended "+"that global HTML elements such as &lt;h1&gt;, &lt;p&gt;, or &lt;ul&gt; have the appropriate JET notag style class assigned "+"(such as 'oj-header', 'oj-p', or 'oj-ul'), to ensure that those tags remain consistent with the styling of "+"the underlying theme.";const SHORT_DESCRIPTION="If a 'notag' version  of a JET theme such as 'oj-redwood-notag-min-css' is applied, it is "+"recommended that global elements have the appropriate style class assigned.";const TAGS={"body":"oj-body","h1":"oj-header","h2":"oj-header","h3":"oj-header","h4":"oj-header","h5":"oj-header","h6":"oj-header","hr":"oj-hr","a":"oj-link","ol":"oj-ol","ul":"oj-ul","p":"oj-p"};class Rule{getName(){return RULENAME}getDescription(){return DESCRIPTION}getShortDescription(){return SHORT_DESCRIPTION}register(){return{globtag:this._onElem,file:this._onFile}}_onElem(ruleCtx,tag){var attrs,clazzes,style;if(!(style=TAGS[tag])){return}if(!this._hasNotagStyleSheet){return}if(attrs=ruleCtx.tagNode.attribs){if(clazzes=attrs.class){if(!_isStyle(clazzes,style)){_emitIssue(ruleCtx,tag,style,0);return}}}if(!attrs||!clazzes){_emitIssue(ruleCtx,tag,style,1)}}_onFile(ruleCtx){this._hasNotagStyleSheet=_isNoTagStyleSheet(ruleCtx)}};function _emitIssue(ruleCtx,tag,style,id){var issue,msg;tag=`<${tag}>`;msg=id===0?`${tag} - 'class' attribute does not include style '${style}'`:`${tag} - 'class' attribute with style '${style}' required`;issue=new ruleCtx.Issue(msg);if(id>0)issue.setMsgKey(RULENAME+"_"+id);ruleCtx.reporter.addIssue(issue,ruleCtx)};function _isStyle(clazzes,style){var styles,entry,ret=false;styles=clazzes.split(" ");for(entry of styles){if(entry&&entry.trim()===style){ret=true;break}}return ret};function _isNoTagStyleSheet(ruleCtx){var links,link,attribs,url,ret=false;if(links=ruleCtx.utils.DomUtils.getLinks()){for(link of links){if(attribs=link.attribs){if(attribs.rel==="stylesheet"){if(url=attribs.src||attribs.href){if(url.toLowerCase().indexOf("-notag")>=0){ret=true;break}}}}}}return ret};module.exports=Rule;