var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.printBoxEnd=exports.printBoxStart=exports.printArrIntoBox=exports.printIntoBox=exports.logAppInfo=exports.logInitialize=exports.logEnd=exports.logError=exports.logSuccess=exports.logComplete=exports.isInfoEnabled=exports.logDebug=exports.logInfo=exports.logWarning=exports.logHook=exports.logExitTask=exports.logInitTask=exports.logTask=exports.setCurrentJob=exports.logSummary=exports.logRaw=exports.logToSummary=exports.getCurrentCommand=exports.logAndSave=exports.configureLogger=exports.logWelcome=exports.chalk=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _chalk2=_interopRequireDefault(require("chalk"));function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly)symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;});keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};if(i%2){ownKeys(Object(source),true).forEach(function(key){(0,_defineProperty2.default)(target,key,source[key]);});}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source));}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}}return target;}

var _chalkCols={
white:function white(v){return v;},
green:function green(v){return v;},
red:function red(v){return v;},
yellow:function yellow(v){return v;},
default:function _default(v){return v;},
gray:function gray(v){return v;},
grey:function grey(v){return v;},
blue:function blue(v){return v;},
cyan:function cyan(v){return v;},
magenta:function magenta(v){return v;}};

_chalkCols.rgb=function(){return function(v){return v;};};
_chalkCols.bold=_chalkCols;
var _chalkMono=_objectSpread({},
_chalkCols);


var currentChalk=_chalk2.default;

var RNV='ReNative';

var chalk=function chalk(){return currentChalk||_chalk2.default;};exports.chalk=chalk;

var logWelcome=function logWelcome(){var _c2,_c2$files,_c2$files$rnv,_c2$files$rnv$package,_c3;

var str=_defaultColor("\n\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502                                                                              \u2502\n\u2502        "+


currentChalk.red('██████╗')+" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557"+currentChalk.red('███╗   ██╗')+" \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557"+currentChalk.red('██╗   ██╗')+"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557       \u2502\n\u2502        "+
currentChalk.red('██╔══██╗')+"\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D"+currentChalk.red('████╗  ██║')+"\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2551"+currentChalk.red('██║   ██║')+"\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D       \u2502\n\u2502        "+
currentChalk.red('██████╔╝')+"\u2588\u2588\u2588\u2588\u2588\u2557  "+currentChalk.red('██╔██╗ ██║')+"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551   \u2588\u2588\u2551   \u2588\u2588\u2551"+currentChalk.red('██║   ██║')+"\u2588\u2588\u2588\u2588\u2588\u2557         \u2502\n\u2502        "+
currentChalk.red('██╔══██╗')+"\u2588\u2588\u2554\u2550\u2550\u255D  "+currentChalk.red('██║╚██╗██║')+"\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551   \u2588\u2588\u2551   \u2588\u2588\u2551"+currentChalk.red('╚██╗ ██╔╝')+"\u2588\u2588\u2554\u2550\u2550\u255D         \u2502\n\u2502        "+
currentChalk.red('██║  ██║')+"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557"+currentChalk.red('██║ ╚████║')+"\u2588\u2588\u2551  \u2588\u2588\u2551   \u2588\u2588\u2551   \u2588\u2588\u2551"+currentChalk.red(' ╚████╔╝ ')+"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557       \u2502\n\u2502        "+
currentChalk.red('╚═╝  ╚═╝')+"\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D"+currentChalk.red('╚═╝  ╚═══╝')+"\u255A\u2550\u255D  \u255A\u2550\u255D   \u255A\u2550\u255D   \u255A\u2550\u255D"+currentChalk.red('  ╚═══╝  ')+"\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D       \u2502\n\u2502                                                                              \u2502\n");



if((_c2=_c)==null?void 0:(_c2$files=_c2.files)==null?void 0:(_c2$files$rnv=_c2$files.rnv)==null?void 0:(_c2$files$rnv$package=_c2$files$rnv.package)==null?void 0:_c2$files$rnv$package.version){
_c.rnvVersion=_c.files.rnv.package.version;
str+=printIntoBox("      Version: "+currentChalk.green(_c.rnvVersion),1);
if(_c.rnvVersion.includes('alpha')){
str+=printIntoBox("      "+
currentChalk.yellow(
'WARNING: this is a prerelease version.'),

1);

}
}
str+=printIntoBox("      "+currentChalk.grey('https://renative.org'),1);
str+=printIntoBox("      \uD83D\uDE80 "+currentChalk.yellow('Firing up!...'),1);
str+=printIntoBox("      $ "+currentChalk.cyan(getCurrentCommand(true)),1);
if((_c3=_c)==null?void 0:_c3.timeStart){
str+=printIntoBox("      Start Time: "+
_c.timeStart.toLocaleString());

}
str+=printIntoBox('');
str+=printBoxEnd();
str+='\n';

console.log(str);
};exports.logWelcome=logWelcome;

var _messages=[];

var _currentProcess;
var _isInfoEnabled=false;
var _infoFilter=[];
var _c;
var _isMono=false;
var _defaultColor;
var _highlightColor;
var _analytics;

var configureLogger=function configureLogger(c,analytics){var _c$program$info;
_messages=[];
_c=c;
_c.timeStart=new Date();
_currentProcess=c.process;
_isInfoEnabled=!!c.program.info;
_infoFilter=(_c$program$info=c.program.info)==null?void 0:_c$program$info.split==null?void 0:_c$program$info.split(',');
_isMono=c.program.mono;
_analytics=analytics;
if(_isMono){
currentChalk=_chalkMono;
}
_updateDefaultColors();
RNV=getCurrentCommand();
};exports.configureLogger=configureLogger;

var _updateDefaultColors=function _updateDefaultColors(){
_defaultColor=currentChalk.gray;
_highlightColor=currentChalk.green;
};
_updateDefaultColors();

var logAndSave=function logAndSave(msg,skipLog){
if(_messages&&!_messages.includes(msg))_messages.push(msg);
if(!skipLog)console.log(""+msg);
};exports.logAndSave=logAndSave;

var PRIVATE_PARAMS=['-k','--key'];

var getCurrentCommand=function getCurrentCommand(){var excludeDollar=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;
if(!_c)return'_c is undefined';
var argArr=_c.process.argv.slice(2);
var hideNext=false;
var output=argArr.
map(function(v){
if(hideNext){
hideNext=false;
return'********';
}
if(PRIVATE_PARAMS.includes(v)){
hideNext=true;
}

return v;
}).
join(' ');
var dollar=excludeDollar?'':'$ ';
return dollar+"rnv "+output;
};exports.getCurrentCommand=getCurrentCommand;

var logToSummary=function logToSummary(v){
_messages.push("\n"+v);
};exports.logToSummary=logToSummary;

var logRaw=function logRaw(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}
console.log.apply(null,args);
};exports.logRaw=logRaw;

var logSummary=function logSummary(){var _c11,_c11$runtime;var header=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'SUMMARY';
var logContent=printIntoBox('All good as 🦄 ');
if(_messages&&_messages.length){
logContent='';
_messages.forEach(function(m){
logContent+="\u2502 "+m+"\n";
});
}

var timeString='';
if(_c){
_c.timeEnd=new Date();
timeString="| "+_c.timeEnd.toLocaleString();
}

var str=printBoxStart("\uD83D\uDE80  "+header+" "+timeString,getCurrentCommand());
if(_c){var _c$buildConfig,_c4,_c5,_c5$runtime,_c$buildConfig2,_c$buildConfig2$_meta,_c$runtime,_c7,_c7$runtime,_c$runtime4,_c$program,_c$program3,_c9,_c9$runtime,_c9$runtime$supported,_c10,_c10$files,_c10$files$project,_c10$files$project$co;
str+=printIntoBox("ReNative Version: "+
_highlightColor(_c.rnvVersion),
1);

if(_c.files.project.package){
str+=printIntoBox("Project Name ($package.name): "+
_highlightColor(
_c.files.project.package.name),

1);

str+=printIntoBox("Project Version ($package.version): "+
_highlightColor(
_c.files.project.package.version),

1);

}

if((_c$buildConfig=_c.buildConfig)==null?void 0:_c$buildConfig.workspaceID){
str+=printIntoBox("Workspace ($.workspaceID): "+
_highlightColor(_c.buildConfig.workspaceID),
1);

}
if((_c4=_c)==null?void 0:_c4.platform){
str+=printIntoBox("Platform (-p): "+_highlightColor(_c.platform),1);
}
if((_c5=_c)==null?void 0:(_c5$runtime=_c5.runtime)==null?void 0:_c5$runtime.engine){var _c6,_c$runtime$engine;
str+=printIntoBox("Engine ($.platforms."+((_c6=_c)==null?void 0:_c6.platform)+".engine): "+
_highlightColor((_c$runtime$engine=_c.runtime.engine)==null?void 0:_c$runtime$engine.getId==null?void 0:_c$runtime$engine.getId()),
1);
}
if((_c$buildConfig2=_c.buildConfig)==null?void 0:(_c$buildConfig2$_meta=_c$buildConfig2._meta)==null?void 0:_c$buildConfig2$_meta.currentAppConfigId){var _c$buildConfig$_meta;
str+=printIntoBox("App Config (-c): "+
_highlightColor((_c$buildConfig$_meta=
_c.buildConfig._meta)==null?void 0:_c$buildConfig$_meta.currentAppConfigId),

1);

}
if((_c$runtime=_c.runtime)==null?void 0:_c$runtime.scheme){var _c$runtime2;
str+=printIntoBox("Build Scheme (-s): "+
_highlightColor((_c$runtime2=_c.runtime)==null?void 0:_c$runtime2.scheme),
1);

}
if((_c7=_c)==null?void 0:(_c7$runtime=_c7.runtime)==null?void 0:_c7$runtime.bundleAssets){var _c8,_c$runtime3;
str+=printIntoBox("Bundle assets ($.platforms."+((_c8=
_c)==null?void 0:_c8.platform)+".bundleAssets): "+
_highlightColor(!!((_c$runtime3=_c.runtime)==null?void 0:_c$runtime3.bundleAssets)),
1);

}
if((_c$runtime4=_c.runtime)==null?void 0:_c$runtime4.target){var _c$runtime5;
str+=printIntoBox("Target (-t): "+
_highlightColor((_c$runtime5=_c.runtime)==null?void 0:_c$runtime5.target),
1);

}
if((_c$program=_c.program)==null?void 0:_c$program.reset){var _c$program2;
str+=printIntoBox("Reset Project (-r): "+
_highlightColor(!!((_c$program2=_c.program)==null?void 0:_c$program2.reset)),
1);

}
if((_c$program3=_c.program)==null?void 0:_c$program3.resetHard){var _c$program4;
str+=printIntoBox("Reset Project and Assets (-R): "+
_highlightColor(!!((_c$program4=_c.program)==null?void 0:_c$program4.resetHard)),
1);

}
if((_c9=_c)==null?void 0:(_c9$runtime=_c9.runtime)==null?void 0:(_c9$runtime$supported=_c9$runtime.supportedPlatforms)==null?void 0:_c9$runtime$supported.length){
var plats=_c.runtime.supportedPlatforms.map(function(v){return""+v.platform+(v.isConnected?'':'(ejected)');});
str+=printArrIntoBox(plats,'Supported Platforms: ');
}

if((_c10=_c)==null?void 0:(_c10$files=_c10.files)==null?void 0:(_c10$files$project=_c10$files.project)==null?void 0:(_c10$files$project$co=_c10$files$project.config)==null?void 0:_c10$files$project$co.defaults){
var defaultProjectConfigs=_c.files.project.config.defaults;
if(defaultProjectConfigs==null?void 0:defaultProjectConfigs.template){
str+=printIntoBox("Master Template: "+
_highlightColor(
defaultProjectConfigs.template),

1);

}
}

if(_c.process){var _c$process$versions;
var envString=_c.process.platform+" | "+_c.process.arch+" | node v"+((_c$process$versions=_c.process.versions)==null?void 0:_c$process$versions.node);
str+=printIntoBox("Env Info: "+currentChalk.gray(envString),1);
}

if(_c.timeEnd){
str+=printIntoBox("Executed Time: "+
currentChalk.yellow(
_msToTime(_c.timeEnd-_c.timeStart)),

1);

}
}

str+=printIntoBox('');
str+=logContent.replace(/\n\s*\n\s*\n/g,'\n\n');
str+=printIntoBox('');
if((_c11=_c)==null?void 0:(_c11$runtime=_c11.runtime)==null?void 0:_c11$runtime.platformBuildsProjectPath){
str+=printIntoBox('Project location:');
str+=printIntoBox(""+currentChalk.cyan(_sanitizePaths(_c.runtime.platformBuildsProjectPath)),1);
}
str+=printBoxEnd();

console.log(str);
};exports.logSummary=logSummary;

var _msToTime=function _msToTime(seconds){
var s=seconds;
var ms=s%1000;
s=(s-ms)/1000;
var secs=s%60;
s=(s-secs)/60;
var mins=s%60;
var hrs=(s-mins)/60;

return hrs+"h:"+mins+"m:"+secs+"s:"+ms+"ms";
};

var setCurrentJob=function setCurrentJob(){

};exports.setCurrentJob=setCurrentJob;

var _getCurrentTask=function _getCurrentTask(){var _c12;return((_c12=_c)==null?void 0:_c12._currentTask)?currentChalk.grey(" ["+_c._currentTask+"]"):'';};

var _sanitizePaths=function _sanitizePaths(msg){var _c13,_c13$paths,_c13$paths$project;
if((msg==null?void 0:msg.replace)&&((_c13=_c)==null?void 0:(_c13$paths=_c13.paths)==null?void 0:(_c13$paths$project=_c13$paths.project)==null?void 0:_c13$paths$project.dir)){
return msg.replace(new RegExp(_c.paths.project.dir,'g'),'.');
}
return msg;
};

var TASK_COUNTER={};

var logTask=function logTask(task,customChalk){
if(!TASK_COUNTER[task])TASK_COUNTER[task]=0;
TASK_COUNTER[task]+=1;
var taskCount=currentChalk.grey("["+TASK_COUNTER[task]+"]");
var msg='';
if(typeof customChalk==='string'){
msg=""+currentChalk.green("[ task ]"+
_getCurrentTask()+" "+task)+taskCount+" "+currentChalk.grey(customChalk);
}else if(customChalk){
msg=customChalk("[ task ]"+_getCurrentTask()+" "+task+taskCount);
}else{
msg=currentChalk.green("[ task ]"+_getCurrentTask()+" "+task+taskCount);
}

console.log(_sanitizePaths(msg));
};exports.logTask=logTask;


var logInitTask=function logInitTask(task,customChalk){
var msg='';
if(typeof customChalk==='string'){
msg=currentChalk.rgb(183,84,117)("[ task ] "+task)+" "+currentChalk.grey(customChalk);
}else if(customChalk){
msg=customChalk("[ task ] "+task);
}else{
msg=currentChalk.rgb(183,84,117)("[ task ] "+task);
}

console.log(msg);
};exports.logInitTask=logInitTask;

var logExitTask=function logExitTask(task,customChalk){
var msg='';
if(typeof customChalk==='string'){
msg=currentChalk.rgb(183,84,117)("[ task ] "+task)+" "+currentChalk.grey(customChalk);
}else if(customChalk){
msg=customChalk("[ task ] "+task);
}else{
msg=currentChalk.rgb(183,84,117)("[ task ] "+task);
}

console.log(msg);
};exports.logExitTask=logExitTask;

var logHook=function logHook(){var hook=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';var msg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';
console.log(currentChalk.rgb(127,255,212)("[ hook ]"+_getCurrentTask()+" "+
hook)+" "+currentChalk.grey(_sanitizePaths(msg)));
};exports.logHook=logHook;

var logWarning=function logWarning(msg){
logAndSave(currentChalk.yellow("[ warn ]"+_getCurrentTask()+" "+_sanitizePaths(msg)));
};exports.logWarning=logWarning;

var logInfo=function logInfo(msg){
console.log(currentChalk.cyan("[ info ]"+_getCurrentTask()+" "+_sanitizePaths(msg)));
};exports.logInfo=logInfo;

var logDebug=function logDebug(){
if(_isInfoEnabled){for(var _len2=arguments.length,args=new Array(_len2),_key2=0;_key2<_len2;_key2++){args[_key2]=arguments[_key2];}
if(_infoFilter){
var firstArg=args[0];

if(_infoFilter.filter(function(v){return firstArg==null?void 0:firstArg.includes==null?void 0:firstArg.includes(v);}).length){
console.log.apply(null,args);
}
}else{
console.log.apply(null,args);
}
}
};exports.logDebug=logDebug;

var isInfoEnabled=function isInfoEnabled(){return _isInfoEnabled;};exports.isInfoEnabled=isInfoEnabled;

var logComplete=function logComplete(){var isEnd=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;
console.log(currentChalk.bold.white("\n "+RNV+" - Done! \uD83D\uDE80"));
if(isEnd)logEnd(0);
};exports.logComplete=logComplete;

var logSuccess=function logSuccess(msg){
logAndSave(currentChalk.magenta("[ success ]"+_getCurrentTask()+" "+_sanitizePaths(msg)));
};exports.logSuccess=logSuccess;

var logError=function logError(e){var isEnd=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var skipAnalytics=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;
if(!skipAnalytics&&!!_analytics){
_analytics.captureException(e);
}

if(e&&e.message){
logAndSave(
currentChalk.red("[ error ]"+_getCurrentTask()+" "+e.message+"\n"+e.stack),
isEnd);

}else{
logAndSave(currentChalk.red("[ error ]"+_getCurrentTask()+" "+e),isEnd);
}

if(isEnd)logEnd(1);
};exports.logError=logError;

var logEnd=function logEnd(code){
logSummary();
if(_currentProcess&&!!_analytics){
_analytics.teardown().then(function(){
_currentProcess.exit(code);
});
}
};exports.logEnd=logEnd;

var logInitialize=function logInitialize(){
logWelcome();
};exports.logInitialize=logInitialize;

var logAppInfo=function logAppInfo(c){
logInfo("Current App Config: "+currentChalk.bold.white(
c.runtime.appId));

};exports.logAppInfo=logAppInfo;

var printIntoBox=function printIntoBox(str2){var intent=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;
var output=_defaultColor('│  ');
var chalkIntend=intent;
var endLine='';
var intend;
if(_isMono){
intend=0;
chalkIntend=0;
}else{
intend=str2===''?1:2;
}
for(var i=0;i<chalkIntend+intend;i++){
endLine+='          ';
}
endLine+=
'                                                                               │\n';
output+=_defaultColor(str2);
var l=output.length-endLine.length;
output+=_defaultColor(endLine.slice(l));
return output;
};exports.printIntoBox=printIntoBox;

var printArrIntoBox=function printArrIntoBox(arr){var prefix=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';
var output='';
var stringArr='';
var i=0;
arr.forEach(function(v){
var l=i===0?60-_defaultColor(prefix).length:60;
if(stringArr.length>l){
if(i===0&&prefix.length){
output+=printIntoBox(""+
_defaultColor(prefix)+_defaultColor(stringArr),
2);

}else{
output+=printIntoBox(_defaultColor(stringArr),1);
}

stringArr='';
i++;
}
stringArr+=v+", ";

});
if(i===0&&prefix.length){
output+=printIntoBox(""+
_defaultColor(prefix)+_defaultColor(stringArr.slice(0,-2)),
2);

}else{
output+=printIntoBox(_defaultColor(stringArr.slice(0,-2)),1);
}

return output;
};exports.printArrIntoBox=printArrIntoBox;

var printBoxStart=function printBoxStart(str,str2){
var output=_defaultColor(
'┌──────────────────────────────────────────────────────────────────────────────┐\n');

output+=printIntoBox(str);
output+=printIntoBox(str2||'');
output+=_defaultColor(
'├──────────────────────────────────────────────────────────────────────────────┤\n');

return output;
};exports.printBoxStart=printBoxStart;

var printBoxEnd=function printBoxEnd(){return _defaultColor(
'└──────────────────────────────────────────────────────────────────────────────┘');};exports.printBoxEnd=printBoxEnd;var _default2=


{
chalk:chalk,
logHook:logHook,
logEnd:logEnd,
logInfo:logInfo,
logTask:logTask,
logError:logError,
logDebug:logDebug,
logAppInfo:logAppInfo,
logWarning:logWarning,
logSuccess:logSuccess,
logWelcome:logWelcome,
logComplete:logComplete,
logInitialize:logInitialize};exports.default=_default2;
//# sourceMappingURL=logger.js.map