/*
 * 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-html-ojtag-ns";const LONG="Web component namespaces prefixed by 'oj-' or 'ns-' must be registered via the Namespace Manager - "+"un-registered namespaces should not be used.\n"+"If a user/external component is flagged, the component is not known to JAF.  Review the confguration properties 'components' and 'nameSpaces'.";const SHORT="Web component namespaces starting with prefixes 'oj-' or 'ns-' must be registered.";class Rule{getName(){return RULENAME}getDescription(){return LONG}getShortDescription(){return SHORT}register(regCtx){if(this._nameSpaces=regCtx.config.nameSpaces){if(!this._nameSpaces.length){this._nameSpaces=null}}return{notglob:this._onNotGlob}}_onNotGlob(ruleCtx,tagName){if(!tagName.includes("-")||tagName.startsWith("demo-")||tagName.startsWith("my-")||tagName==="oj-slot"||ruleCtx.ojNS){return}ruleCtx.utils.metaLib.isNamespaceTag(tagName);if(tagName.startsWith("oj-")||tagName.startsWith("ns-")){if(!ruleCtx.utils.metaLib.isNamespaceTag(tagName)){if(!ruleCtx.utils.metaLib.isJetTag(tagName)){this._emitIssue(ruleCtx,`<${tagName}> : unregistered use of '${tagName.substring(0,2)}' web component namespace`)}}return}if(this._nameSpaces){let i;for(i=0;i<this._nameSpaces.length;i++){if(tagName.startsWith(this._nameSpaces[i])){return}}}if(!ruleCtx.utils.metaLib.isComponentTag(tagName)){this._emitIssue(ruleCtx,`'${tagName}' : unknown web component namespace`,1)}}_emitIssue(ruleCtx,msg,id){var issue=new ruleCtx.Issue(msg);if(id){issue.setMsgKey(RULENAME+"_"+id)}ruleCtx.reporter.addIssue(issue,ruleCtx)}}module.exports=Rule;