/*
 * 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-html-bindif-test";const SHORT_DESCRIPT="'test' attribute of an <oj-bind-if> or <oj-if> must be a '[[...]]' expression";const LONG_DESCRIPT="The 'test' attribute of an <oj-bind-if> or <oj-if> component must be a '[[...]]' (read-only) expression and not a literal.";const TEST="test";const COLON_TEST=":test";const PREFERRED="preferred";const EXPECTED="expected";function getName(){return RULE_NAME};function getShortDescription(){return SHORT_DESCRIPT};function getDescription(){return LONG_DESCRIPT};function register(){return{"<oj-bind-if>":_onTag,"<oj-if>":_onTag}};function _onTag(ruleCtx,tagName){var attribs,val,valType,attrName,attrPos,issue,what;if(ruleCtx.tagNode.attribs){attribs=ruleCtx.tagNode.attribs;attrName=TEST;val=attribs[TEST];if((valType=typeof val)==="undefined"){attrName=COLON_TEST;val=attribs[attrName];valType=typeof val}if(valType==="undefined"){issue=new ruleCtx.Issue(`<${tagName} 'test' attribute missing`);ruleCtx.reporter.addIssue(issue,ruleCtx);return}if(valType==="string"){val=val.trimLeft();if(val.startsWith("[[")||val==="true"||val==="false"){return}what=val.startsWith("{{")?PREFERRED:EXPECTED;issue=new ruleCtx.Issue(`<${tagName}> 'test' attribute : read-only '[[...]]' expression ${what}.`);attrPos=ruleCtx.utils.DomUtils.getAttribPosition(ruleCtx.data,ruleCtx.tagNode,attrName);issue.setPosition(attrPos.row,attrPos.col,attrPos.start,attrPos.end);if(what===PREFERRED){issue.setSeverity("minor")}ruleCtx.reporter.addIssue(issue,ruleCtx)}}};module.exports={getName,getDescription,getShortDescription,register};