// Compiled by ClojureScript 1.9.293 {:target :nodejs}
goog.provide('eginez.calvin.core');
goog.require('cljs.core');
goog.require('eginez.huckleberry.core');
goog.require('cljs.pprint');
goog.require('cljs.core.async');
goog.require('cljs.tools.cli');
goog.require('cljs.analyzer');
goog.require('cljs.nodejs');
goog.require('clojure.string');
goog.require('cljs.reader');
eginez.calvin.core.fs = cljs.nodejs.require.call(null,"fs");
eginez.calvin.core.npath = cljs.nodejs.require.call(null,"path");
eginez.calvin.core.nchild = cljs.nodejs.require.call(null,"child_process");
eginez.calvin.core.nproc = cljs.nodejs.require.call(null,"process");
eginez.calvin.core.build_preface = cljs.core.list(new cljs.core.Symbol(null,"require","require",1172530194,null),cljs.core.list(new cljs.core.Symbol(null,"quote","quote",1377916282,null),new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"lumo.build.api","lumo.build.api",1252131409,null),new cljs.core.Keyword(null,"as","as",1148689641),new cljs.core.Symbol(null,"b","b",-1172211299,null)], null)));
eginez.calvin.core.find_file = (function eginez$calvin$core$find_file(fpath){
try{var files = eginez.calvin.core.fs.readdirSync(fpath);
var fname = cljs.core.first.call(null,cljs.core.filter.call(null,((function (files){
return (function (p1__20269_SHARP_){
return clojure.string.includes_QMARK_.call(null,p1__20269_SHARP_,"project.clj");
});})(files))
,files));
var or__6543__auto__ = eginez.calvin.core.npath.join(fpath,fname);
if(cljs.core.truth_(or__6543__auto__)){
return or__6543__auto__;
} else {
return null;
}
}catch (e20271){if((e20271 instanceof Error)){
var e = e20271;
return null;
} else {
throw e20271;

}
}});
eginez.calvin.core.samedep_QMARK_ = (function eginez$calvin$core$samedep_QMARK_(dep1,dep2){
return (cljs.core._EQ_.call(null,new cljs.core.Keyword(null,"artifact","artifact",610074681).cljs$core$IFn$_invoke$arity$1(dep1),new cljs.core.Keyword(null,"artifact","artifact",610074681).cljs$core$IFn$_invoke$arity$1(dep2))) && (cljs.core._EQ_.call(null,new cljs.core.Keyword(null,"version","version",425292698).cljs$core$IFn$_invoke$arity$1(dep1),new cljs.core.Keyword(null,"version","version",425292698).cljs$core$IFn$_invoke$arity$1(dep2))) && (cljs.core._EQ_.call(null,new cljs.core.Keyword(null,"group","group",582596132).cljs$core$IFn$_invoke$arity$1(dep1),new cljs.core.Keyword(null,"group","group",582596132).cljs$core$IFn$_invoke$arity$1(dep2)));
});
eginez.calvin.core.load_content = (function eginez$calvin$core$load_content(file){
try{return eginez.calvin.core.fs.readFileSync(file).toString();
}catch (e20273){if((e20273 instanceof Error)){
var e = e20273;
return null;
} else {
throw e20273;

}
}});
eginez.calvin.core.find_lein_project_configuration = (function eginez$calvin$core$find_lein_project_configuration(lein_project_file){
if(cljs.core.truth_(lein_project_file)){
var content = eginez.calvin.core.load_content.call(null,lein_project_file);
var rcontent = cljs.reader.read_string.call(null,content);
var vec__20278 = rcontent;
var seq__20279 = cljs.core.seq.call(null,vec__20278);
var first__20280 = cljs.core.first.call(null,seq__20279);
var seq__20279__$1 = cljs.core.next.call(null,seq__20279);
var _ = first__20280;
var first__20280__$1 = cljs.core.first.call(null,seq__20279__$1);
var seq__20279__$2 = cljs.core.next.call(null,seq__20279__$1);
var name = first__20280__$1;
var first__20280__$2 = cljs.core.first.call(null,seq__20279__$2);
var seq__20279__$3 = cljs.core.next.call(null,seq__20279__$2);
var version = first__20280__$2;
var opts = seq__20279__$3;
var lopts = cljs.core.partition.call(null,(2),opts);
var mapopts = cljs.core.map.call(null,((function (content,rcontent,vec__20278,seq__20279,first__20280,seq__20279__$1,_,first__20280__$1,seq__20279__$2,name,first__20280__$2,seq__20279__$3,version,opts,lopts){
return (function (p1__20274_SHARP_){
return cljs.core.assoc.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.first.call(null,p1__20274_SHARP_),cljs.core.second.call(null,p1__20274_SHARP_));
});})(content,rcontent,vec__20278,seq__20279,first__20280,seq__20279__$1,_,first__20280__$1,seq__20279__$2,name,first__20280__$2,seq__20279__$3,version,opts,lopts))
,lopts);
var ret = cljs.core.reduce.call(null,cljs.core.merge,mapopts);
return ret;
} else {
return null;
}
});
eginez.calvin.core.resolve_dependencies = (function eginez$calvin$core$resolve_dependencies(coordinates,retrieve){
var dp = eginez.huckleberry.core.resolve_dependencies.call(null,new cljs.core.Keyword(null,"coordinates","coordinates",-1225332668),coordinates,new cljs.core.Keyword(null,"local-repo","local-repo",764410280),new cljs.core.Keyword(null,"local","local",-1497766724).cljs$core$IFn$_invoke$arity$1(eginez.huckleberry.core.default_repos),new cljs.core.Keyword(null,"retrieve","retrieve",-657129560),retrieve);
return dp;
});
eginez.calvin.core.with_lein_project = (function eginez$calvin$core$with_lein_project(var_args){
var args__7658__auto__ = [];
var len__7651__auto___20283 = arguments.length;
var i__7652__auto___20284 = (0);
while(true){
if((i__7652__auto___20284 < len__7651__auto___20283)){
args__7658__auto__.push((arguments[i__7652__auto___20284]));

var G__20285 = (i__7652__auto___20284 + (1));
i__7652__auto___20284 = G__20285;
continue;
} else {
}
break;
}

var argseq__7659__auto__ = ((((1) < args__7658__auto__.length))?(new cljs.core.IndexedSeq(args__7658__auto__.slice((1)),(0),null)):null);
return eginez.calvin.core.with_lein_project.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__7659__auto__);
});

eginez.calvin.core.with_lein_project.cljs$core$IFn$_invoke$arity$variadic = (function (path,opts){
var file = eginez.calvin.core.find_file.call(null,path);
var options = eginez.calvin.core.find_lein_project_configuration.call(null,file);
return cljs.core.get_in.call(null,options,cljs.core.vec.call(null,opts));
});

eginez.calvin.core.with_lein_project.cljs$lang$maxFixedArity = (1);

eginez.calvin.core.with_lein_project.cljs$lang$applyTo = (function (seq20281){
var G__20282 = cljs.core.first.call(null,seq20281);
var seq20281__$1 = cljs.core.next.call(null,seq20281);
return eginez.calvin.core.with_lein_project.cljs$core$IFn$_invoke$arity$variadic(G__20282,seq20281__$1);
});

eginez.calvin.core.find_coordinates_in_project = (function eginez$calvin$core$find_coordinates_in_project(path){
var project_file = eginez.calvin.core.find_file.call(null,path);
var options = eginez.calvin.core.find_lein_project_configuration.call(null,project_file);
var coordiantes = new cljs.core.Keyword(null,"dependencies","dependencies",1108064605).cljs$core$IFn$_invoke$arity$1(options);
return coordiantes;
});
eginez.calvin.core.find_srcs_in_project = (function eginez$calvin$core$find_srcs_in_project(path,id){
var builds = eginez.calvin.core.with_lein_project.call(null,path,new cljs.core.Keyword(null,"cljsbuild","cljsbuild",-518195792),new cljs.core.Keyword(null,"builds","builds",-1946283802));
var srcs = cljs.core.first.call(null,cljs.core.filter.call(null,((function (builds){
return (function (p1__20286_SHARP_){
return cljs.core._EQ_.call(null,new cljs.core.Keyword(null,"id","id",-1388402092).cljs$core$IFn$_invoke$arity$1(p1__20286_SHARP_),id);
});})(builds))
,builds));
var dropped = cljs.core.rest.call(null,new cljs.core.Keyword(null,"source-paths","source-paths",-71903349).cljs$core$IFn$_invoke$arity$1(srcs));
if(!(cljs.core.empty_QMARK_.call(null,dropped))){
cljs.core.println.call(null,"Current lumo api does not support multiple sources, dropping ",dropped);
} else {
}

return cljs.core.first.call(null,new cljs.core.Keyword(null,"source-paths","source-paths",-71903349).cljs$core$IFn$_invoke$arity$1(srcs));
});
eginez.calvin.core.find_compiler_opts_in_project = (function eginez$calvin$core$find_compiler_opts_in_project(path,id){
var builds = eginez.calvin.core.with_lein_project.call(null,path,new cljs.core.Keyword(null,"cljsbuild","cljsbuild",-518195792),new cljs.core.Keyword(null,"builds","builds",-1946283802));
var srcs = cljs.core.first.call(null,cljs.core.filter.call(null,((function (builds){
return (function (p1__20287_SHARP_){
return cljs.core._EQ_.call(null,new cljs.core.Keyword(null,"id","id",-1388402092).cljs$core$IFn$_invoke$arity$1(p1__20287_SHARP_),id);
});})(builds))
,builds));
var opts = new cljs.core.Keyword(null,"compiler","compiler",-267926731).cljs$core$IFn$_invoke$arity$1(srcs);
var main = new cljs.core.Keyword(null,"main","main",-2117802661).cljs$core$IFn$_invoke$arity$1(opts);
return cljs.core.assoc.call(null,opts,new cljs.core.Keyword(null,"main","main",-2117802661),cljs.core.sequence.call(null,cljs.core.seq.call(null,cljs.core.concat.call(null,cljs.core._conj.call(null,cljs.core.List.EMPTY,new cljs.core.Symbol(null,"quote","quote",1377916282,null)),(function (){var x__7380__auto__ = main;
return cljs.core._conj.call(null,cljs.core.List.EMPTY,x__7380__auto__);
})()))));
});
eginez.calvin.core.build_build_command = (function eginez$calvin$core$build_build_command(src_projects,compiler_options){
var b = cljs.core.sequence.call(null,cljs.core.seq.call(null,cljs.core.concat.call(null,cljs.core._conj.call(null,cljs.core.List.EMPTY,new cljs.core.Symbol("b","build","b/build",-1690039705,null)),(function (){var x__7380__auto__ = src_projects;
return cljs.core._conj.call(null,cljs.core.List.EMPTY,x__7380__auto__);
})(),(function (){var x__7380__auto__ = compiler_options;
return cljs.core._conj.call(null,cljs.core.List.EMPTY,x__7380__auto__);
})())));
return clojure.string.join.call(null," ",cljs.core.map.call(null,cljs.core.str,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [eginez.calvin.core.build_preface,b], null)));
});
eginez.calvin.core.resolve_classpath = (function eginez$calvin$core$resolve_classpath(path_to_project){
var c__13855__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,((function (c__13855__auto__){
return (function (){
var f__13856__auto__ = (function (){var switch__13839__auto__ = ((function (c__13855__auto__){
return (function (state_20324){
var state_val_20325 = (state_20324[(1)]);
if((state_val_20325 === (1))){
var inst_20313 = (state_20324[(7)]);
var inst_20313__$1 = eginez.calvin.core.find_coordinates_in_project.call(null,path_to_project);
var state_20324__$1 = (function (){var statearr_20326 = state_20324;
(statearr_20326[(7)] = inst_20313__$1);

return statearr_20326;
})();
if(cljs.core.truth_(inst_20313__$1)){
var statearr_20327_20338 = state_20324__$1;
(statearr_20327_20338[(1)] = (2));

} else {
var statearr_20328_20339 = state_20324__$1;
(statearr_20328_20339[(1)] = (3));

}

return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_20325 === (2))){
var inst_20313 = (state_20324[(7)]);
var inst_20315 = eginez.calvin.core.resolve_dependencies.call(null,inst_20313,true);
var state_20324__$1 = state_20324;
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_20324__$1,(5),inst_20315);
} else {
if((state_val_20325 === (3))){
var state_20324__$1 = state_20324;
var statearr_20329_20340 = state_20324__$1;
(statearr_20329_20340[(2)] = null);

(statearr_20329_20340[(1)] = (4));


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_20325 === (4))){
var inst_20322 = (state_20324[(2)]);
var state_20324__$1 = state_20324;
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_20324__$1,inst_20322);
} else {
if((state_val_20325 === (5))){
var inst_20317 = (state_20324[(2)]);
var inst_20318 = cljs.core.map.call(null,eginez.huckleberry.core.dep__GT_path,inst_20317);
var inst_20319 = clojure.string.join.call(null,":",inst_20318);
var state_20324__$1 = state_20324;
var statearr_20330_20341 = state_20324__$1;
(statearr_20330_20341[(2)] = inst_20319);

(statearr_20330_20341[(1)] = (4));


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
return null;
}
}
}
}
}
});})(c__13855__auto__))
;
return ((function (switch__13839__auto__,c__13855__auto__){
return (function() {
var eginez$calvin$core$resolve_classpath_$_state_machine__13840__auto__ = null;
var eginez$calvin$core$resolve_classpath_$_state_machine__13840__auto____0 = (function (){
var statearr_20334 = [null,null,null,null,null,null,null,null];
(statearr_20334[(0)] = eginez$calvin$core$resolve_classpath_$_state_machine__13840__auto__);

(statearr_20334[(1)] = (1));

return statearr_20334;
});
var eginez$calvin$core$resolve_classpath_$_state_machine__13840__auto____1 = (function (state_20324){
while(true){
var ret_value__13841__auto__ = (function (){try{while(true){
var result__13842__auto__ = switch__13839__auto__.call(null,state_20324);
if(cljs.core.keyword_identical_QMARK_.call(null,result__13842__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__13842__auto__;
}
break;
}
}catch (e20335){if((e20335 instanceof Object)){
var ex__13843__auto__ = e20335;
var statearr_20336_20342 = state_20324;
(statearr_20336_20342[(5)] = ex__13843__auto__);


cljs.core.async.impl.ioc_helpers.process_exception.call(null,state_20324);

return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
throw e20335;

}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__13841__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__20343 = state_20324;
state_20324 = G__20343;
continue;
} else {
return ret_value__13841__auto__;
}
break;
}
});
eginez$calvin$core$resolve_classpath_$_state_machine__13840__auto__ = function(state_20324){
switch(arguments.length){
case 0:
return eginez$calvin$core$resolve_classpath_$_state_machine__13840__auto____0.call(this);
case 1:
return eginez$calvin$core$resolve_classpath_$_state_machine__13840__auto____1.call(this,state_20324);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
eginez$calvin$core$resolve_classpath_$_state_machine__13840__auto__.cljs$core$IFn$_invoke$arity$0 = eginez$calvin$core$resolve_classpath_$_state_machine__13840__auto____0;
eginez$calvin$core$resolve_classpath_$_state_machine__13840__auto__.cljs$core$IFn$_invoke$arity$1 = eginez$calvin$core$resolve_classpath_$_state_machine__13840__auto____1;
return eginez$calvin$core$resolve_classpath_$_state_machine__13840__auto__;
})()
;})(switch__13839__auto__,c__13855__auto__))
})();
var state__13857__auto__ = (function (){var statearr_20337 = f__13856__auto__.call(null);
(statearr_20337[cljs.core.async.impl.ioc_helpers.USER_START_IDX] = c__13855__auto__);

return statearr_20337;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__13857__auto__);
});})(c__13855__auto__))
);

return c__13855__auto__;
});
eginez.calvin.core.print_dep_tree = (function eginez$calvin$core$print_dep_tree(root,graph,depth){
var art = cljs.core.first.call(null,cljs.core.filter.call(null,(function (p1__20344_SHARP_){
return eginez.calvin.core.samedep_QMARK_.call(null,root,p1__20344_SHARP_);
}),cljs.core.keys.call(null,graph)));
var deps = cljs.core.get.call(null,graph,art);
cljs.core.println.call(null,clojure.string.join.call(null,cljs.core.concat.call(null,cljs.core.repeat.call(null,depth,"*"),">")),eginez.huckleberry.core.dep__GT_coordinate.call(null,art));

if(cljs.core.truth_(cljs.core.not_empty.call(null,deps))){
var seq__20349 = cljs.core.seq.call(null,deps);
var chunk__20350 = null;
var count__20351 = (0);
var i__20352 = (0);
while(true){
if((i__20352 < count__20351)){
var n = cljs.core._nth.call(null,chunk__20350,i__20352);
eginez.calvin.core.print_dep_tree.call(null,n,graph,(depth + (1)));

var G__20353 = seq__20349;
var G__20354 = chunk__20350;
var G__20355 = count__20351;
var G__20356 = (i__20352 + (1));
seq__20349 = G__20353;
chunk__20350 = G__20354;
count__20351 = G__20355;
i__20352 = G__20356;
continue;
} else {
var temp__4657__auto__ = cljs.core.seq.call(null,seq__20349);
if(temp__4657__auto__){
var seq__20349__$1 = temp__4657__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__20349__$1)){
var c__7357__auto__ = cljs.core.chunk_first.call(null,seq__20349__$1);
var G__20357 = cljs.core.chunk_rest.call(null,seq__20349__$1);
var G__20358 = c__7357__auto__;
var G__20359 = cljs.core.count.call(null,c__7357__auto__);
var G__20360 = (0);
seq__20349 = G__20357;
chunk__20350 = G__20358;
count__20351 = G__20359;
i__20352 = G__20360;
continue;
} else {
var n = cljs.core.first.call(null,seq__20349__$1);
eginez.calvin.core.print_dep_tree.call(null,n,graph,(depth + (1)));

var G__20361 = cljs.core.next.call(null,seq__20349__$1);
var G__20362 = null;
var G__20363 = (0);
var G__20364 = (0);
seq__20349 = G__20361;
chunk__20350 = G__20362;
count__20351 = G__20363;
i__20352 = G__20364;
continue;
}
} else {
return null;
}
}
break;
}
} else {
return null;
}
});
eginez.calvin.core.lumo_build_cmd = (function eginez$calvin$core$lumo_build_cmd(path,id,classpath){
var src_path = eginez.calvin.core.find_srcs_in_project.call(null,path,id);
var compiler_options = eginez.calvin.core.find_compiler_opts_in_project.call(null,path,id);
var build_cmd = eginez.calvin.core.build_build_command.call(null,src_path,compiler_options);
var final_cmd = [cljs.core.str("\""),cljs.core.str(clojure.string.replace_all.call(null,build_cmd,/\"/,"\\\"")),cljs.core.str("\"")].join('');
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, ["lumo",new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, ["-c",[cljs.core.str(src_path),cljs.core.str(":"),cljs.core.str(classpath)].join(''),"-e",final_cmd], null)], null);
});
eginez.calvin.core.show_all_deps = (function eginez$calvin$core$show_all_deps(graph){
while(true){
if(cljs.core.truth_(cljs.core.not_empty.call(null,graph))){
var root = cljs.core.dissoc.call(null,cljs.core.first.call(null,graph),new cljs.core.Keyword(null,"exclusions","exclusions",1098729003));
var dg = cljs.core.second.call(null,graph);
var vec__20369 = cljs.core.filter.call(null,((function (graph,root,dg){
return (function (p1__20365_SHARP_){
return eginez.calvin.core.samedep_QMARK_.call(null,root,p1__20365_SHARP_);
});})(graph,root,dg))
,cljs.core.keys.call(null,dg));
var seq__20370 = cljs.core.seq.call(null,vec__20369);
var first__20371 = cljs.core.first.call(null,seq__20370);
var seq__20370__$1 = cljs.core.next.call(null,seq__20370);
var head_dep = first__20371;
var _ = seq__20370__$1;
cljs.core.println.call(null);

eginez.calvin.core.print_dep_tree.call(null,head_dep,dg,(0));

var G__20372 = cljs.core.drop.call(null,(2),graph);
graph = G__20372;
continue;
} else {
return null;
}
break;
}
});
eginez.calvin.core.build_cmd_for_platform = (function eginez$calvin$core$build_cmd_for_platform(platform,classpath){
var classpath_cmd = (cljs.core.truth_(classpath)?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, ["-c",classpath], null):cljs.core.PersistentVector.EMPTY);
var G__20374 = platform;
switch (G__20374) {
case "lumo":
return cljs.core.conj.call(null,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, ["lumo"], null),classpath_cmd);

break;
case "planck":
return cljs.core.conj.call(null,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, ["planck"], null),classpath_cmd);

break;
default:
throw (new Error([cljs.core.str("No matching clause: "),cljs.core.str(platform)].join('')));

}
});
eginez.calvin.core.show_deps = (function eginez$calvin$core$show_deps(cwd){
var c__13855__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,((function (c__13855__auto__){
return (function (){
var f__13856__auto__ = (function (){var switch__13839__auto__ = ((function (c__13855__auto__){
return (function (state_20452){
var state_val_20453 = (state_20452[(1)]);
if((state_val_20453 === (1))){
var inst_20423 = (state_20452[(7)]);
var inst_20422 = cljs.core.println.call(null,"Calculating dependencies");
var inst_20423__$1 = eginez.calvin.core.find_coordinates_in_project.call(null,cwd);
var state_20452__$1 = (function (){var statearr_20454 = state_20452;
(statearr_20454[(7)] = inst_20423__$1);

(statearr_20454[(8)] = inst_20422);

return statearr_20454;
})();
if(cljs.core.truth_(inst_20423__$1)){
var statearr_20455_20467 = state_20452__$1;
(statearr_20455_20467[(1)] = (2));

} else {
var statearr_20456_20468 = state_20452__$1;
(statearr_20456_20468[(1)] = (3));

}

return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_20453 === (2))){
var inst_20423 = (state_20452[(7)]);
var inst_20431 = eginez.calvin.core.resolve_dependencies.call(null,inst_20423,false);
var state_20452__$1 = state_20452;
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_20452__$1,(5),inst_20431);
} else {
if((state_val_20453 === (3))){
var inst_20448 = cljs.core.println.call(null,"No dependencies file found are you missing a project.clj or boot.clj?");
var state_20452__$1 = state_20452;
var statearr_20457_20469 = state_20452__$1;
(statearr_20457_20469[(2)] = inst_20448);

(statearr_20457_20469[(1)] = (4));


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_20453 === (4))){
var inst_20450 = (state_20452[(2)]);
var state_20452__$1 = state_20452;
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_20452__$1,inst_20450);
} else {
if((state_val_20453 === (5))){
var inst_20423 = (state_20452[(7)]);
var inst_20433 = (state_20452[(2)]);
var inst_20434 = cljs.core.nth.call(null,inst_20433,(0),null);
var inst_20435 = cljs.core.nth.call(null,inst_20433,(1),null);
var inst_20436 = cljs.core.nth.call(null,inst_20433,(2),null);
var inst_20437 = cljs.core.first.call(null,inst_20435);
var inst_20438 = cljs.core.dissoc.call(null,inst_20437,new cljs.core.Keyword(null,"exclusions","exclusions",1098729003));
var inst_20439 = cljs.core.second.call(null,inst_20435);
var inst_20440 = (function (){var temp__4655__auto__ = inst_20423;
var coordinates = inst_20423;
var vec__20425 = inst_20433;
var status = inst_20434;
var dep_graph = inst_20435;
var dep_list = inst_20436;
var root = inst_20438;
var dg = inst_20439;
return ((function (temp__4655__auto__,coordinates,vec__20425,status,dep_graph,dep_list,root,dg,inst_20423,inst_20433,inst_20434,inst_20435,inst_20436,inst_20437,inst_20438,inst_20439,state_val_20453,c__13855__auto__){
return (function (p1__20376_SHARP_){
return eginez.calvin.core.samedep_QMARK_.call(null,root,p1__20376_SHARP_);
});
;})(temp__4655__auto__,coordinates,vec__20425,status,dep_graph,dep_list,root,dg,inst_20423,inst_20433,inst_20434,inst_20435,inst_20436,inst_20437,inst_20438,inst_20439,state_val_20453,c__13855__auto__))
})();
var inst_20441 = cljs.core.keys.call(null,inst_20439);
var inst_20442 = cljs.core.filter.call(null,inst_20440,inst_20441);
var inst_20443 = cljs.core.seq.call(null,inst_20442);
var inst_20444 = cljs.core.first.call(null,inst_20443);
var inst_20445 = cljs.core.next.call(null,inst_20443);
var inst_20446 = eginez.calvin.core.show_all_deps.call(null,inst_20435);
var state_20452__$1 = (function (){var statearr_20458 = state_20452;
(statearr_20458[(9)] = inst_20444);

(statearr_20458[(10)] = inst_20445);

return statearr_20458;
})();
var statearr_20459_20470 = state_20452__$1;
(statearr_20459_20470[(2)] = inst_20446);

(statearr_20459_20470[(1)] = (4));


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
return null;
}
}
}
}
}
});})(c__13855__auto__))
;
return ((function (switch__13839__auto__,c__13855__auto__){
return (function() {
var eginez$calvin$core$show_deps_$_state_machine__13840__auto__ = null;
var eginez$calvin$core$show_deps_$_state_machine__13840__auto____0 = (function (){
var statearr_20463 = [null,null,null,null,null,null,null,null,null,null,null];
(statearr_20463[(0)] = eginez$calvin$core$show_deps_$_state_machine__13840__auto__);

(statearr_20463[(1)] = (1));

return statearr_20463;
});
var eginez$calvin$core$show_deps_$_state_machine__13840__auto____1 = (function (state_20452){
while(true){
var ret_value__13841__auto__ = (function (){try{while(true){
var result__13842__auto__ = switch__13839__auto__.call(null,state_20452);
if(cljs.core.keyword_identical_QMARK_.call(null,result__13842__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__13842__auto__;
}
break;
}
}catch (e20464){if((e20464 instanceof Object)){
var ex__13843__auto__ = e20464;
var statearr_20465_20471 = state_20452;
(statearr_20465_20471[(5)] = ex__13843__auto__);


cljs.core.async.impl.ioc_helpers.process_exception.call(null,state_20452);

return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
throw e20464;

}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__13841__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__20472 = state_20452;
state_20452 = G__20472;
continue;
} else {
return ret_value__13841__auto__;
}
break;
}
});
eginez$calvin$core$show_deps_$_state_machine__13840__auto__ = function(state_20452){
switch(arguments.length){
case 0:
return eginez$calvin$core$show_deps_$_state_machine__13840__auto____0.call(this);
case 1:
return eginez$calvin$core$show_deps_$_state_machine__13840__auto____1.call(this,state_20452);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
eginez$calvin$core$show_deps_$_state_machine__13840__auto__.cljs$core$IFn$_invoke$arity$0 = eginez$calvin$core$show_deps_$_state_machine__13840__auto____0;
eginez$calvin$core$show_deps_$_state_machine__13840__auto__.cljs$core$IFn$_invoke$arity$1 = eginez$calvin$core$show_deps_$_state_machine__13840__auto____1;
return eginez$calvin$core$show_deps_$_state_machine__13840__auto__;
})()
;})(switch__13839__auto__,c__13855__auto__))
})();
var state__13857__auto__ = (function (){var statearr_20466 = f__13856__auto__.call(null);
(statearr_20466[cljs.core.async.impl.ioc_helpers.USER_START_IDX] = c__13855__auto__);

return statearr_20466;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__13857__auto__);
});})(c__13855__auto__))
);

return c__13855__auto__;
});
eginez.calvin.core.run_build = (function eginez$calvin$core$run_build(cwd,id){
var c__13855__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,((function (c__13855__auto__){
return (function (){
var f__13856__auto__ = (function (){var switch__13839__auto__ = ((function (c__13855__auto__){
return (function (state_20520){
var state_val_20521 = (state_20520[(1)]);
if((state_val_20521 === (1))){
var inst_20504 = eginez.calvin.core.resolve_classpath.call(null,cwd);
var state_20520__$1 = state_20520;
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_20520__$1,(2),inst_20504);
} else {
if((state_val_20521 === (2))){
var inst_20506 = (state_20520[(2)]);
var inst_20507 = eginez.calvin.core.lumo_build_cmd.call(null,cwd,id,inst_20506);
var inst_20508 = cljs.core.nth.call(null,inst_20507,(0),null);
var inst_20509 = cljs.core.nth.call(null,inst_20507,(1),null);
var inst_20510 = cljs.core.clj__GT_js.call(null,inst_20509);
var inst_20511 = [new cljs.core.Keyword(null,"stdio","stdio",-1570777132),new cljs.core.Keyword(null,"shell","shell",1402941019)];
var inst_20512 = cljs.core.PersistentVector.EMPTY_NODE;
var inst_20513 = [(0),(1),(2)];
var inst_20514 = (new cljs.core.PersistentVector(null,3,(5),inst_20512,inst_20513,null));
var inst_20515 = [inst_20514,true];
var inst_20516 = cljs.core.PersistentHashMap.fromArrays(inst_20511,inst_20515);
var inst_20517 = cljs.core.clj__GT_js.call(null,inst_20516);
var inst_20518 = eginez.calvin.core.nchild.spawn(inst_20508,inst_20510,inst_20517);
var state_20520__$1 = state_20520;
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_20520__$1,inst_20518);
} else {
return null;
}
}
});})(c__13855__auto__))
;
return ((function (switch__13839__auto__,c__13855__auto__){
return (function() {
var eginez$calvin$core$run_build_$_state_machine__13840__auto__ = null;
var eginez$calvin$core$run_build_$_state_machine__13840__auto____0 = (function (){
var statearr_20525 = [null,null,null,null,null,null,null];
(statearr_20525[(0)] = eginez$calvin$core$run_build_$_state_machine__13840__auto__);

(statearr_20525[(1)] = (1));

return statearr_20525;
});
var eginez$calvin$core$run_build_$_state_machine__13840__auto____1 = (function (state_20520){
while(true){
var ret_value__13841__auto__ = (function (){try{while(true){
var result__13842__auto__ = switch__13839__auto__.call(null,state_20520);
if(cljs.core.keyword_identical_QMARK_.call(null,result__13842__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__13842__auto__;
}
break;
}
}catch (e20526){if((e20526 instanceof Object)){
var ex__13843__auto__ = e20526;
var statearr_20527_20529 = state_20520;
(statearr_20527_20529[(5)] = ex__13843__auto__);


cljs.core.async.impl.ioc_helpers.process_exception.call(null,state_20520);

return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
throw e20526;

}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__13841__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__20530 = state_20520;
state_20520 = G__20530;
continue;
} else {
return ret_value__13841__auto__;
}
break;
}
});
eginez$calvin$core$run_build_$_state_machine__13840__auto__ = function(state_20520){
switch(arguments.length){
case 0:
return eginez$calvin$core$run_build_$_state_machine__13840__auto____0.call(this);
case 1:
return eginez$calvin$core$run_build_$_state_machine__13840__auto____1.call(this,state_20520);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
eginez$calvin$core$run_build_$_state_machine__13840__auto__.cljs$core$IFn$_invoke$arity$0 = eginez$calvin$core$run_build_$_state_machine__13840__auto____0;
eginez$calvin$core$run_build_$_state_machine__13840__auto__.cljs$core$IFn$_invoke$arity$1 = eginez$calvin$core$run_build_$_state_machine__13840__auto____1;
return eginez$calvin$core$run_build_$_state_machine__13840__auto__;
})()
;})(switch__13839__auto__,c__13855__auto__))
})();
var state__13857__auto__ = (function (){var statearr_20528 = f__13856__auto__.call(null);
(statearr_20528[cljs.core.async.impl.ioc_helpers.USER_START_IDX] = c__13855__auto__);

return statearr_20528;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__13857__auto__);
});})(c__13855__auto__))
);

return c__13855__auto__;
});
eginez.calvin.core.run_repl = (function eginez$calvin$core$run_repl(platform,cwd){
var c__13855__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,((function (c__13855__auto__){
return (function (){
var f__13856__auto__ = (function (){var switch__13839__auto__ = ((function (c__13855__auto__){
return (function (state_20578){
var state_val_20579 = (state_20578[(1)]);
if((state_val_20579 === (1))){
var inst_20562 = eginez.calvin.core.resolve_classpath.call(null,cwd);
var state_20578__$1 = state_20578;
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_20578__$1,(2),inst_20562);
} else {
if((state_val_20579 === (2))){
var inst_20564 = (state_20578[(2)]);
var inst_20565 = eginez.calvin.core.build_cmd_for_platform.call(null,platform,inst_20564);
var inst_20566 = cljs.core.nth.call(null,inst_20565,(0),null);
var inst_20567 = cljs.core.nth.call(null,inst_20565,(1),null);
var inst_20568 = cljs.core.clj__GT_js.call(null,inst_20567);
var inst_20569 = [new cljs.core.Keyword(null,"stdio","stdio",-1570777132)];
var inst_20570 = cljs.core.PersistentVector.EMPTY_NODE;
var inst_20571 = [(0),(1),(2)];
var inst_20572 = (new cljs.core.PersistentVector(null,3,(5),inst_20570,inst_20571,null));
var inst_20573 = [inst_20572];
var inst_20574 = cljs.core.PersistentHashMap.fromArrays(inst_20569,inst_20573);
var inst_20575 = cljs.core.clj__GT_js.call(null,inst_20574);
var inst_20576 = eginez.calvin.core.nchild.spawn(inst_20566,inst_20568,inst_20575);
var state_20578__$1 = state_20578;
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_20578__$1,inst_20576);
} else {
return null;
}
}
});})(c__13855__auto__))
;
return ((function (switch__13839__auto__,c__13855__auto__){
return (function() {
var eginez$calvin$core$run_repl_$_state_machine__13840__auto__ = null;
var eginez$calvin$core$run_repl_$_state_machine__13840__auto____0 = (function (){
var statearr_20583 = [null,null,null,null,null,null,null];
(statearr_20583[(0)] = eginez$calvin$core$run_repl_$_state_machine__13840__auto__);

(statearr_20583[(1)] = (1));

return statearr_20583;
});
var eginez$calvin$core$run_repl_$_state_machine__13840__auto____1 = (function (state_20578){
while(true){
var ret_value__13841__auto__ = (function (){try{while(true){
var result__13842__auto__ = switch__13839__auto__.call(null,state_20578);
if(cljs.core.keyword_identical_QMARK_.call(null,result__13842__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__13842__auto__;
}
break;
}
}catch (e20584){if((e20584 instanceof Object)){
var ex__13843__auto__ = e20584;
var statearr_20585_20587 = state_20578;
(statearr_20585_20587[(5)] = ex__13843__auto__);


cljs.core.async.impl.ioc_helpers.process_exception.call(null,state_20578);

return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
throw e20584;

}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__13841__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__20588 = state_20578;
state_20578 = G__20588;
continue;
} else {
return ret_value__13841__auto__;
}
break;
}
});
eginez$calvin$core$run_repl_$_state_machine__13840__auto__ = function(state_20578){
switch(arguments.length){
case 0:
return eginez$calvin$core$run_repl_$_state_machine__13840__auto____0.call(this);
case 1:
return eginez$calvin$core$run_repl_$_state_machine__13840__auto____1.call(this,state_20578);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
eginez$calvin$core$run_repl_$_state_machine__13840__auto__.cljs$core$IFn$_invoke$arity$0 = eginez$calvin$core$run_repl_$_state_machine__13840__auto____0;
eginez$calvin$core$run_repl_$_state_machine__13840__auto__.cljs$core$IFn$_invoke$arity$1 = eginez$calvin$core$run_repl_$_state_machine__13840__auto____1;
return eginez$calvin$core$run_repl_$_state_machine__13840__auto__;
})()
;})(switch__13839__auto__,c__13855__auto__))
})();
var state__13857__auto__ = (function (){var statearr_20586 = f__13856__auto__.call(null);
(statearr_20586[cljs.core.async.impl.ioc_helpers.USER_START_IDX] = c__13855__auto__);

return statearr_20586;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__13857__auto__);
});})(c__13855__auto__))
);

return c__13855__auto__;
});
eginez.calvin.core.cli_options = new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, ["-h","--help"], null),new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, ["-p","--platform PLATFORM","Either planck or lumo",new cljs.core.Keyword(null,"default","default",-1987822328),"lumo"], null)], null);
eginez.calvin.core.help = clojure.string.join.call(null,"\n",cljs.core.flatten.call(null,new cljs.core.PersistentVector(null, 8, 5, cljs.core.PersistentVector.EMPTY_NODE, ["Calvin a minimalistic build tool for clojurescript","Usage: calvin [options] args","Options:",cljs.core.map.call(null,(function (p1__20589_SHARP_){
return [cljs.core.str("\t"),cljs.core.str(clojure.string.join.call(null," ",cljs.core.take.call(null,(2),p1__20589_SHARP_)))].join('');
}),eginez.calvin.core.cli_options),"Arguments:","\tdeps Shows dependencies","\tbuild [id] Builds the project using the 'id' configuration","\trepl Starts a repl using either lumo or planck"], null)));
eginez.calvin.core._main = (function eginez$calvin$core$_main(var_args){
var args__7658__auto__ = [];
var len__7651__auto___20594 = arguments.length;
var i__7652__auto___20595 = (0);
while(true){
if((i__7652__auto___20595 < len__7651__auto___20594)){
args__7658__auto__.push((arguments[i__7652__auto___20595]));

var G__20596 = (i__7652__auto___20595 + (1));
i__7652__auto___20595 = G__20596;
continue;
} else {
}
break;
}

var argseq__7659__auto__ = ((((0) < args__7658__auto__.length))?(new cljs.core.IndexedSeq(args__7658__auto__.slice((0)),(0),null)):null);
return eginez.calvin.core._main.cljs$core$IFn$_invoke$arity$variadic(argseq__7659__auto__);
});

eginez.calvin.core._main.cljs$core$IFn$_invoke$arity$variadic = (function (args){
var map__20591 = cljs.tools.cli.parse_opts.call(null,args,eginez.calvin.core.cli_options,new cljs.core.Keyword(null,"in-order","in-order",-1605651796),true);
var map__20591__$1 = ((((!((map__20591 == null)))?((((map__20591.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__20591.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__20591):map__20591);
var options = cljs.core.get.call(null,map__20591__$1,new cljs.core.Keyword(null,"options","options",99638489));
var arguments$ = cljs.core.get.call(null,map__20591__$1,new cljs.core.Keyword(null,"arguments","arguments",-1182834456));
var errors = cljs.core.get.call(null,map__20591__$1,new cljs.core.Keyword(null,"errors","errors",-908790718));
var summ = cljs.core.get.call(null,map__20591__$1,new cljs.core.Keyword(null,"summ","summ",-1220398077));
var platform = new cljs.core.Keyword(null,"platform","platform",-1086422114).cljs$core$IFn$_invoke$arity$1(options);
var G__20593 = cljs.core.first.call(null,arguments$);
if(cljs.core._EQ_.call(null,"deps",G__20593)){
return eginez.calvin.core.show_deps.call(null,eginez.calvin.core.nproc.cwd());
} else {
if(cljs.core._EQ_.call(null,"repl",G__20593)){
return eginez.calvin.core.run_repl.call(null,platform,eginez.calvin.core.nproc.cwd());
} else {
if(cljs.core._EQ_.call(null,"build",G__20593)){
return eginez.calvin.core.run_build.call(null,eginez.calvin.core.nproc.cwd(),(function (){var or__6543__auto__ = cljs.core.second.call(null,arguments$);
if(cljs.core.truth_(or__6543__auto__)){
return or__6543__auto__;
} else {
return "dev";
}
})());
} else {
if(cljs.core._EQ_.call(null,null,G__20593)){
return cljs.core.println.call(null,eginez.calvin.core.help);
} else {
throw (new Error([cljs.core.str("No matching clause: "),cljs.core.str(cljs.core.first.call(null,arguments$))].join('')));

}
}
}
}
});

eginez.calvin.core._main.cljs$lang$maxFixedArity = (0);

eginez.calvin.core._main.cljs$lang$applyTo = (function (seq20590){
return eginez.calvin.core._main.cljs$core$IFn$_invoke$arity$variadic(cljs.core.seq.call(null,seq20590));
});

cljs.nodejs.enable_util_print_BANG_.call(null);
cljs.core._STAR_main_cli_fn_STAR_ = eginez.calvin.core._main;
