/*
 * Copyright (c) 2018, 2025, 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-wctag-arialabelledby";const SHORT_DESCRIPT="Custom components should not used a hard-coded 'aria-labelledby' attribute and it should be set to an expression";const LONG_DESCRIPT="Hard-coded 'aria-labelledby' attributes should not be used within custom components. 'aria-labelledby' values must be unique for each instance of the component. See context.uniqueId in the custom element documentation for information on how to derive unique values for elements."+"<p>If a web component implements a hard-coded 'aria-labelledby' elements in the web component view, e.g.<p>"+"<oj-xxx aria-labelledby=\"foo\"><p>"+"then this is guaranteed to cause issues as soon as more than one instance of "+"the component is used on the page (plus there is a significant risk of "+"collision with other values in the page as a whole.";const ATTR="aria-labelledby";const COLON_ATTR=":aria-labelledby";function getName(){return RULE_NAME};function getShortDescription(){return SHORT_DESCRIPT};function getDescription(){return LONG_DESCRIPT};function register(){return{"webcomp":_handle}}function _handle(context,tagName){var attribs,attr,isAttr,isColonAttr,isExpr,msg,issue,attrPos;if(!context.ojTag||!context.filepath.includes("jet-composites")||!context.tagNode.attribs){return}if(context.utils.metaLib.isBindingTag(tagName)){return}attribs=context.tagNode.attribs;isAttr=attribs.hasOwnProperty(ATTR);isColonAttr=attribs.hasOwnProperty(COLON_ATTR);if(!isAttr&&!isColonAttr){return}attr=isAttr?ATTR:COLON_ATTR;isExpr=_isAttrExpr(attribs[attr]);if(isAttr){msg="<"+context.tag+"> 'aria-labelledby be prefixed as ':aria-labelledby'"+(!isExpr?" and set to an expression":"")}else if(!isExpr){msg="<"+context.tag+"> ':aria-labelledby' should be set to an expression"}if(msg){issue=new context.Issue(msg);attrPos=context.utils.DomUtils.getAttribPosition(context.data,context.node,attr);issue.setPosition(attrPos.row,attrPos.col,attrPos.start,attrPos.end);context.reporter.addIssue(issue,context)}};function _isAttrExpr(attrValue){var rc=false;if(typeof attrValue==="string"){attrValue=attrValue.trim();rc=attrValue.startsWith("[[")||attrValue.startsWith("{{")}return rc};module.exports={getName,getDescription,getShortDescription,register};