/*
 * 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-ojattr-value";const DATABIND="data-bind";function getName(){return RULE_NAME};function getShortDescription(){return"Custom component attribute value must be a defined value"};function getDescription(){return"Custom component attribute value must be a defined value for the component"};function register(){return{"webcomp":_onWComp}};function _onWComp(ruleCtx,tag){var attrs,attr,val;if(ruleCtx.tagNode.attribs){attrs=ruleCtx.tagNode.attribs;for(attr in attrs){val=attrs[attr];if(val.startsWith("{{")||val.startsWith("[[")){continue}_checkAttr(ruleCtx,tag,attr,val)}}};function _checkAttr(ruleCtx,tag,attr,val){var issue,metaLib,DomUtils,aVals,aVal,jsonChar,i;metaLib=ruleCtx.utils.metaLib;DomUtils=ruleCtx.utils.DomUtils;if(DomUtils.isCommonAttr(attr)||DomUtils.isCommonEventAttr(attr)||attr===DATABIND){return}if(!metaLib.isTagAttr(tag,attr)){return}jsonChar=val.charAt(0);try{if(jsonChar==="{"){return}else if(val.charAt(0)==="["){aVals=JSON.parse(val)}else{aVals=[val]}}catch(e){}if(!aVals){return true}if(!metaLib.hasTagAttrValues(tag,attr)){return}for(i=0;i<aVals.length;i++){aVal=aVals[i];if(!metaLib.isTagAttrValue(tag,attr,aVal)){if(!_checkSpecialCases(ruleCtx,tag,attr,aVal)){let attrPos;issue=new ruleCtx.Issue(`<${tag}> attribute '${attr}' refers to undefined value '${aVal}'`);attrPos=DomUtils.getAttribPosition(ruleCtx.data,ruleCtx.tagNode,attr);issue.setPosition(attrPos.row,attrPos.col,attrPos.start,attrPos.end);ruleCtx.reporter.addIssue(issue,ruleCtx)}}}};function _checkSpecialCases(ruleCtx,tag,attr,attrValue){if(tag==="oj-led-gauge"&&attr==="type"){return ruleCtx.utils.DomUtils.isSvgPath(attrValue)}return false};module.exports={getName,getDescription,getShortDescription,register};