/*
 * 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 CLI_MODE="cli";const API_MODE="api";const AMD_MODE="amd";function JafLib(nd,jfs,mctx,runMode,jafver,jv,cfg,ageLib){this._rdy=-1;this.setup(nd,jfs,mctx,runMode,jafver,jv,cfg,ageLib)};JafLib.prototype.getFileset=function(ruleCtx){if(this._nd&&ruleCtx.phase&&ruleCtx.phase==="startaudit"){return this._jfs.getFiles()}};JafLib.prototype.setFileset=function(ruleCtx,files,exclude){var rc=false;if(this._nd&&ruleCtx.phase&&ruleCtx.phase==="startaudit"){if(files&&!Array.isArray(files)||exclude&&!Array.isArray(exclude)){this._mCtx.error("Rule '"+ruleCtx.ruleName+"' attempt to call JafLib.setfiles() with non-array");this._jfs.setFiles(null,null);return false}this._jfs.setFiles(files,exclude);rc=true}return rc};JafLib.prototype.getRunMode=function(){return this._runMode};JafLib.prototype.getConfig=function(){return this._cfg};JafLib.prototype.getTsConfigObj=function(){return this._cfg.getTsConfigObj()};JafLib.prototype.isCLI=function(){return this._runMode===CLI_MODE};JafLib.prototype.isAPI=function(){return this._runMode===API_MODE};JafLib.prototype.isAMD=function(){return this._runMode===AMD_MODE};JafLib.prototype.getJetVer=function(){return this._jetver};JafLib.prototype.getJafVer=function(){return this._jafver};JafLib.prototype.getJetReleaseCount=function(){return this.getJafReleaseCount()};JafLib.prototype.getJafReleaseCount=function(){return this._ageLib.getJafReleaseCount()};JafLib.prototype.getMajorReleaseCount=function(major){return this._ageLib.getMajorReleaseCount(major)};JafLib.prototype.setup=function(nd,jfs,mctx,runMode,jafver,jv,cfg,ageLib){if(this._rdy===-1){this._nd=nd;this._jfs=jfs;this._mCtx=mctx;this._runMode=runMode;this._jafver=jafver;this._jetver=jv;this._cfg=cfg;this._ageLib=ageLib}};JafLib.prototype.disable=function(){this._rdy=-2};JafLib.prototype.getJafLib=function(){return{getConfig:this.getConfig.bind(this),getTsConfigObj:this.getTsConfigObj.bind(this),getRunMode:this.getRunMode.bind(this),isCLI:this.isCLI.bind(this),isAPI:this.isAPI.bind(this),isAMD:this.isAMD.bind(this),getJetVer:this.getJetVer.bind(this),getJafVer:this.getJafVer.bind(this),getJetReleaseCount:this.getJetReleaseCount.bind(this),getJafReleaseCount:this.getJafReleaseCount.bind(this),getMajorReleaseCount:this.getMajorReleaseCount.bind(this)}};JafLib.prototype.getPublic=function(){return{setFileset:this.setFileset.bind(this),getFileset:this.getFileset.bind(this)}};module.exports=JafLib;