/*
 * 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 Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-slot-displayname"};ruleDef.prototype.getShortDescription=function(){return"Check component has display name defined for slots"};ruleDef.prototype.getDescription=function(){return"This rule checks that slots have a display name supplied to make the user experience in Visual Builder as useful as possible"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const componentType=Utils.getComponentType(meta);if(componentType==="composite"){this._checkSlots(context,meta.slots)}}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkSlots(context,componentInfo.slots)}};ruleDef.prototype._checkSlots=function(context,slots){let issue;if(slots){Object.keys(slots).forEach(slotName=>{if(!slots[slotName].displayName){issue=new context.Issue(`displayName for ${slotName===""?"default slot":"slot '"+slotName+"'"} should be defined`);context.reporter.addIssue(issue,context)}})}};module.exports=ruleDef;