/*
 * 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-css-style-bp-font";const DESCRIPT="For best practices, CSS properties 'font-size' and 'font-weight' should not be used. Use of JET typography classes is recommended.";const SHORT_DESCRIPT=DESCRIPT;const DECLARATION="Declaration";const FONT_CLASSES=["font-size","font-weight"];function Rule(){this._checkList=null;this._isAccept=false};Rule.prototype.getName=function(){return RULE_NAME};Rule.prototype.getShortDescription=function(){return SHORT_DESCRIPT};Rule.prototype.getDescription=function(){return DESCRIPT};Rule.prototype.register=function(regCtx){if(!this._checkAcceptReject(regCtx)){return false}return{"css-rule":this._onRule}};Rule.prototype._onRule=function(ruleCtx,rule){var block,decl,i;if(!(rule.prelude&&rule.prelude.children&&rule.prelude.children.length)){return}block=rule.block.children;for(i=0;i<block.length;i++){decl=block[i];if(decl.type===DECLARATION){if(FONT_CLASSES.includes(decl.property)){if(!_isCssVar(decl)){if(this._okProp(decl.property)){_emitIssue(ruleCtx,decl)}}}}}};function _emitIssue(ruleCtx,o){var issue;issue=new ruleCtx.Issue("CSS property '"+o.property+"' - for best practices, JET typography classes preferred");issue.setPosition(ruleCtx.utils.CssUtils.getPosition(ruleCtx,o.loc));ruleCtx.reporter.addIssue(issue,ruleCtx)};Rule.prototype._okProp=function(prop){var i;if(this._checkList){for(i=0;i<this._checkList.length;i++){if(this._checkList[i]===prop){return this._isAccept}}return!this._isAccept}return true};Rule.prototype._checkAcceptReject=function(regCtx){var customOpts,accept,reject;if(!(customOpts=regCtx.ruleOpts.customOpts)){return true}accept=customOpts.accept;reject=customOpts.reject;if(accept||reject){if(accept&&reject){regCtx.utils.msgLib.error("Rule "+RULE_NAME+":  options 'accept' and 'reject' are mutually exclusive");return false}if(accept){this._checkList=accept;this._isAccept=true}else{this._checkList=reject}if(!Array.isArray(this._checkList)){regCtx.utils.msgLib.error("Rule "+RULE_NAME+":  option '"+(accept?"accept":"reject")+"' is not an array");return false}for(let i=0;i<this._checkList.length;i++){if(typeof this._checkList[i]==="string"){this._checkList[i]=this._checkList[i].trim()}}}return true};function _isCssVar(decl){var c,v;c=decl.value.children;v=c[0];return v.name==="var"};module.exports=Rule;