import "./cljs_env.js";
goog.provide('shadow.remote.runtime.tap_support');
shadow.remote.runtime.tap_support.tap_subscribe = (function shadow$remote$runtime$tap_support$tap_subscribe(p__79780,p__79781){
var map__79782 = p__79780;
var map__79782__$1 = cljs.core.__destructure_map(map__79782);
var svc = map__79782__$1;
var subs_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__79782__$1,new cljs.core.Keyword(null,"subs-ref","subs-ref",-1355989911));
var obj_support = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__79782__$1,new cljs.core.Keyword(null,"obj-support","obj-support",1522559229));
var runtime = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__79782__$1,new cljs.core.Keyword(null,"runtime","runtime",-1331573996));
var map__79783 = p__79781;
var map__79783__$1 = cljs.core.__destructure_map(map__79783);
var msg = map__79783__$1;
var from = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__79783__$1,new cljs.core.Keyword(null,"from","from",1815293044));
var summary = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__79783__$1,new cljs.core.Keyword(null,"summary","summary",380847952));
var history = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__79783__$1,new cljs.core.Keyword(null,"history","history",-247395220));
var num = cljs.core.get.cljs$core$IFn$_invoke$arity$3(map__79783__$1,new cljs.core.Keyword(null,"num","num",1985240673),(10));
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$4(subs_ref,cljs.core.assoc,from,msg);

if(cljs.core.truth_(history)){
return shadow.remote.runtime.shared.reply(runtime,msg,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"op","op",-1882987955),new cljs.core.Keyword(null,"tap-subscribed","tap-subscribed",-1882247432),new cljs.core.Keyword(null,"history","history",-247395220),cljs.core.into.cljs$core$IFn$_invoke$arity$2(cljs.core.PersistentVector.EMPTY,cljs.core.map.cljs$core$IFn$_invoke$arity$2((function (oid){
return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"oid","oid",-768692334),oid,new cljs.core.Keyword(null,"summary","summary",380847952),shadow.remote.runtime.obj_support.obj_describe_STAR_(obj_support,oid)], null);
}),shadow.remote.runtime.obj_support.get_tap_history(obj_support,num)))], null));
} else {
return null;
}
});
shadow.remote.runtime.tap_support.tap_unsubscribe = (function shadow$remote$runtime$tap_support$tap_unsubscribe(p__79788,p__79789){
var map__79790 = p__79788;
var map__79790__$1 = cljs.core.__destructure_map(map__79790);
var subs_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__79790__$1,new cljs.core.Keyword(null,"subs-ref","subs-ref",-1355989911));
var map__79791 = p__79789;
var map__79791__$1 = cljs.core.__destructure_map(map__79791);
var from = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__79791__$1,new cljs.core.Keyword(null,"from","from",1815293044));
return cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$3(subs_ref,cljs.core.dissoc,from);
});
shadow.remote.runtime.tap_support.request_tap_history = (function shadow$remote$runtime$tap_support$request_tap_history(p__79796,p__79797){
var map__79798 = p__79796;
var map__79798__$1 = cljs.core.__destructure_map(map__79798);
var obj_support = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__79798__$1,new cljs.core.Keyword(null,"obj-support","obj-support",1522559229));
var runtime = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__79798__$1,new cljs.core.Keyword(null,"runtime","runtime",-1331573996));
var map__79799 = p__79797;
var map__79799__$1 = cljs.core.__destructure_map(map__79799);
var msg = map__79799__$1;
var num = cljs.core.get.cljs$core$IFn$_invoke$arity$3(map__79799__$1,new cljs.core.Keyword(null,"num","num",1985240673),(10));
var tap_ids = shadow.remote.runtime.obj_support.get_tap_history(obj_support,num);
return shadow.remote.runtime.shared.reply(runtime,msg,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"op","op",-1882987955),new cljs.core.Keyword(null,"tap-history","tap-history",-282803347),new cljs.core.Keyword(null,"oids","oids",-1580877688),tap_ids], null));
});
shadow.remote.runtime.tap_support.tool_disconnect = (function shadow$remote$runtime$tap_support$tool_disconnect(p__79803,tid){
var map__79804 = p__79803;
var map__79804__$1 = cljs.core.__destructure_map(map__79804);
var svc = map__79804__$1;
var subs_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__79804__$1,new cljs.core.Keyword(null,"subs-ref","subs-ref",-1355989911));
return cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$3(subs_ref,cljs.core.dissoc,tid);
});
shadow.remote.runtime.tap_support.start = (function shadow$remote$runtime$tap_support$start(runtime,obj_support){
var subs_ref = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(cljs.core.PersistentArrayMap.EMPTY);
var tap_fn = (function shadow$remote$runtime$tap_support$start_$_runtime_tap(obj){
if((!((obj == null)))){
var oid = shadow.remote.runtime.obj_support.register(obj_support,obj,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"from","from",1815293044),new cljs.core.Keyword(null,"tap","tap",-1086702463)], null));
var seq__79813 = cljs.core.seq(cljs.core.deref(subs_ref));
var chunk__79814 = null;
var count__79815 = (0);
var i__79816 = (0);
while(true){
if((i__79816 < count__79815)){
var vec__79826 = chunk__79814.cljs$core$IIndexed$_nth$arity$2(null,i__79816);
var tid = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__79826,(0),null);
var tap_config = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__79826,(1),null);
shadow.remote.runtime.api.relay_msg(runtime,new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"op","op",-1882987955),new cljs.core.Keyword(null,"tap","tap",-1086702463),new cljs.core.Keyword(null,"to","to",192099007),tid,new cljs.core.Keyword(null,"oid","oid",-768692334),oid], null));


var G__79845 = seq__79813;
var G__79846 = chunk__79814;
var G__79847 = count__79815;
var G__79848 = (i__79816 + (1));
seq__79813 = G__79845;
chunk__79814 = G__79846;
count__79815 = G__79847;
i__79816 = G__79848;
continue;
} else {
var temp__5753__auto__ = cljs.core.seq(seq__79813);
if(temp__5753__auto__){
var seq__79813__$1 = temp__5753__auto__;
if(cljs.core.chunked_seq_QMARK_(seq__79813__$1)){
var c__4649__auto__ = cljs.core.chunk_first(seq__79813__$1);
var G__79849 = cljs.core.chunk_rest(seq__79813__$1);
var G__79850 = c__4649__auto__;
var G__79851 = cljs.core.count(c__4649__auto__);
var G__79852 = (0);
seq__79813 = G__79849;
chunk__79814 = G__79850;
count__79815 = G__79851;
i__79816 = G__79852;
continue;
} else {
var vec__79830 = cljs.core.first(seq__79813__$1);
var tid = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__79830,(0),null);
var tap_config = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__79830,(1),null);
shadow.remote.runtime.api.relay_msg(runtime,new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"op","op",-1882987955),new cljs.core.Keyword(null,"tap","tap",-1086702463),new cljs.core.Keyword(null,"to","to",192099007),tid,new cljs.core.Keyword(null,"oid","oid",-768692334),oid], null));


var G__79853 = cljs.core.next(seq__79813__$1);
var G__79854 = null;
var G__79855 = (0);
var G__79856 = (0);
seq__79813 = G__79853;
chunk__79814 = G__79854;
count__79815 = G__79855;
i__79816 = G__79856;
continue;
}
} else {
return null;
}
}
break;
}
} else {
return null;
}
});
var svc = new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"runtime","runtime",-1331573996),runtime,new cljs.core.Keyword(null,"obj-support","obj-support",1522559229),obj_support,new cljs.core.Keyword(null,"tap-fn","tap-fn",1573556461),tap_fn,new cljs.core.Keyword(null,"subs-ref","subs-ref",-1355989911),subs_ref], null);
shadow.remote.runtime.api.add_extension(runtime,new cljs.core.Keyword("shadow.remote.runtime.tap-support","ext","shadow.remote.runtime.tap-support/ext",1019069674),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"ops","ops",1237330063),new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"tap-subscribe","tap-subscribe",411179050),(function (p1__79805_SHARP_){
return shadow.remote.runtime.tap_support.tap_subscribe(svc,p1__79805_SHARP_);
}),new cljs.core.Keyword(null,"tap-unsubscribe","tap-unsubscribe",1183890755),(function (p1__79806_SHARP_){
return shadow.remote.runtime.tap_support.tap_unsubscribe(svc,p1__79806_SHARP_);
}),new cljs.core.Keyword(null,"request-tap-history","request-tap-history",-670837812),(function (p1__79807_SHARP_){
return shadow.remote.runtime.tap_support.request_tap_history(svc,p1__79807_SHARP_);
})], null),new cljs.core.Keyword(null,"on-tool-disconnect","on-tool-disconnect",693464366),(function (p1__79808_SHARP_){
return shadow.remote.runtime.tap_support.tool_disconnect(svc,p1__79808_SHARP_);
})], null));

cljs.core.add_tap(tap_fn);

return svc;
});
shadow.remote.runtime.tap_support.stop = (function shadow$remote$runtime$tap_support$stop(p__79838){
var map__79843 = p__79838;
var map__79843__$1 = cljs.core.__destructure_map(map__79843);
var svc = map__79843__$1;
var tap_fn = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__79843__$1,new cljs.core.Keyword(null,"tap-fn","tap-fn",1573556461));
var runtime = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__79843__$1,new cljs.core.Keyword(null,"runtime","runtime",-1331573996));
cljs.core.remove_tap(tap_fn);

return shadow.remote.runtime.api.del_extension(runtime,new cljs.core.Keyword("shadow.remote.runtime.tap-support","ext","shadow.remote.runtime.tap-support/ext",1019069674));
});

//# sourceMappingURL=shadow.remote.runtime.tap_support.js.map
