/*
 * 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-css-bp-zindex";const MSG="For best practices, CSS z-index property values should not be used.";const MSG_END="Use of JET standard secondary window components (popup, dialog or messages) is recommended for proper UI element stacking.";const MSG_REPLACE="JET secondary window components (popup, dialog or messages) for UI element stacking.";const DECLARATION="Declaration";const ZINDEX="z-index";class Rule{getName(){return RULENAME}getDescription(){return`${MSG} ${MSG_END}`}getShortDescription(){return MSG}register(regCtx){this._CssUtils=regCtx.utils.CssUtils;return{"css-rule":this._onRule,"style":this._onStyle}}_onRule(ruleCtx,rule){var block,decl,i;block=rule.block.children;for(i=0;i<block.length;i++){decl=block[i];if(decl.type===DECLARATION&&decl.property===ZINDEX&&!_isCssVar(decl)){let issue;issue=new ruleCtx.Issue(`CSS 'z-index' - best practice: replace with ${MSG_REPLACE}`);issue.setPosition(this._CssUtils.getPosition(ruleCtx,decl.loc));ruleCtx.reporter.addIssue(issue,ruleCtx)}}}_onStyle(ruleCtx,attr,value){var prop,issue,s,x,i;for(i=0;i<value.length;i++){s=value[i];x=s.indexOf(":");if(x>=0){prop=s.substring(0,x).trimEnd();if(prop===ZINDEX){issue=new ruleCtx.Issue(`'z-index' property in 'style' attribute. Best practice: replace " +
                                       "with ${MSG_REPLACE}`);issue.setMsgKey(RULENAME+"_1");ruleCtx.reporter.addIssue(issue,ruleCtx)}}}}}function _isCssVar(decl){var c;c=decl.value.children;if(c){let v=c[0];return v.name==="var"}return false};module.exports=Rule;