/*
 * 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 isValidAttr=require("./helpers/valid-attr");const RULE_NAME="oj-html-attr-prefix-expr";const COLON=":";const STYLE="style";const STYLE_DOT="style.";const CLASS="class";const TYPE="type";const ON_OJ_EVENT="on-oj-";function getName(){return RULE_NAME};function getShortDescription(){return"Colon-prefixed attribute should specify a '[[...]]' or '{{...}}' expression."};function getDescription(){return"Attributes prefixed with the late-binding indicator <b>':'</b?, should refer to a read-only expression <b>'[[. . .]]'</b>, or a read-write expression '{{. . .}}'</b>."};function register(){return{"elem":_onElem}};function _onElem(ruleCtx,tag){var attrs,attr,val;if(ruleCtx.tagNode.attribs){attrs=ruleCtx.tagNode.attribs;for(attr in attrs){if(attr.charAt(0)===COLON&&typeof(val=attrs[attr])==="string"){attr=attr.substring(1);if(attr===CLASS||attr===TYPE||attr.startsWith(ON_OJ_EVENT)){continue}if(attr===STYLE||attr.startsWith(STYLE_DOT)){continue}if(!isValidAttr(attr)){continue}_checkAttr(ruleCtx,tag,":"+attr,val)}}}};function _checkAttr(ruleCtx,tag,attr,attrValue){let val=attrValue.trim();if(!val.startsWith("{{")&&!val.startsWith("[[")){let issue=new ruleCtx.Issue(`Colon-prefixed attribute '${attr}' is not a read-only '[[...]]', or read-write '{{...}} expression`);let attrPos=ruleCtx.utils.DomUtils.getAttribPosition(ruleCtx.data,ruleCtx.tagNode,attr);issue.setPosition(attrPos.row,attrPos.col,attrPos.start,attrPos.end);ruleCtx.reporter.addIssue(issue,ruleCtx)}};module.exports={getName,getDescription,getShortDescription,register};