goog.provide('shadow.remote.runtime.tap_support');
shadow.remote.runtime.tap_support.tap_subscribe = (function shadow$remote$runtime$tap_support$tap_subscribe(p__28415,p__28416){
var map__28418 = p__28415;
var map__28418__$1 = cljs.core.__destructure_map(map__28418);
var svc = map__28418__$1;
var subs_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__28418__$1,new cljs.core.Keyword(null,"subs-ref","subs-ref",-1355989911));
var obj_support = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__28418__$1,new cljs.core.Keyword(null,"obj-support","obj-support",1522559229));
var runtime = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__28418__$1,new cljs.core.Keyword(null,"runtime","runtime",-1331573996));
var map__28419 = p__28416;
var map__28419__$1 = cljs.core.__destructure_map(map__28419);
var msg = map__28419__$1;
var from = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__28419__$1,new cljs.core.Keyword(null,"from","from",1815293044));
var summary = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__28419__$1,new cljs.core.Keyword(null,"summary","summary",380847952));
var history__$1 = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__28419__$1,new cljs.core.Keyword(null,"history","history",-247395220));
var num = cljs.core.get.cljs$core$IFn$_invoke$arity$3(map__28419__$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__$1)){
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__28430,p__28431){
var map__28433 = p__28430;
var map__28433__$1 = cljs.core.__destructure_map(map__28433);
var subs_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__28433__$1,new cljs.core.Keyword(null,"subs-ref","subs-ref",-1355989911));
var map__28434 = p__28431;
var map__28434__$1 = cljs.core.__destructure_map(map__28434);
var from = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__28434__$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__28445,p__28446){
var map__28447 = p__28445;
var map__28447__$1 = cljs.core.__destructure_map(map__28447);
var obj_support = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__28447__$1,new cljs.core.Keyword(null,"obj-support","obj-support",1522559229));
var runtime = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__28447__$1,new cljs.core.Keyword(null,"runtime","runtime",-1331573996));
var map__28448 = p__28446;
var map__28448__$1 = cljs.core.__destructure_map(map__28448);
var msg = map__28448__$1;
var num = cljs.core.get.cljs$core$IFn$_invoke$arity$3(map__28448__$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__28452,tid){
var map__28453 = p__28452;
var map__28453__$1 = cljs.core.__destructure_map(map__28453);
var svc = map__28453__$1;
var subs_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__28453__$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__28469 = cljs.core.seq(cljs.core.deref(subs_ref));
var chunk__28470 = null;
var count__28471 = (0);
var i__28472 = (0);
while(true){
if((i__28472 < count__28471)){
var vec__28485 = chunk__28470.cljs$core$IIndexed$_nth$arity$2(null, i__28472);
var tid = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__28485,(0),null);
var tap_config = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__28485,(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__28503 = seq__28469;
var G__28504 = chunk__28470;
var G__28505 = count__28471;
var G__28506 = (i__28472 + (1));
seq__28469 = G__28503;
chunk__28470 = G__28504;
count__28471 = G__28505;
i__28472 = G__28506;
continue;
} else {
var temp__5804__auto__ = cljs.core.seq(seq__28469);
if(temp__5804__auto__){
var seq__28469__$1 = temp__5804__auto__;
if(cljs.core.chunked_seq_QMARK_(seq__28469__$1)){
var c__5525__auto__ = cljs.core.chunk_first(seq__28469__$1);
var G__28507 = cljs.core.chunk_rest(seq__28469__$1);
var G__28508 = c__5525__auto__;
var G__28509 = cljs.core.count(c__5525__auto__);
var G__28510 = (0);
seq__28469 = G__28507;
chunk__28470 = G__28508;
count__28471 = G__28509;
i__28472 = G__28510;
continue;
} else {
var vec__28489 = cljs.core.first(seq__28469__$1);
var tid = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__28489,(0),null);
var tap_config = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__28489,(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__28511 = cljs.core.next(seq__28469__$1);
var G__28512 = null;
var G__28513 = (0);
var G__28514 = (0);
seq__28469 = G__28511;
chunk__28470 = G__28512;
count__28471 = G__28513;
i__28472 = G__28514;
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__28457_SHARP_){
return shadow.remote.runtime.tap_support.tap_subscribe(svc,p1__28457_SHARP_);
}),new cljs.core.Keyword(null,"tap-unsubscribe","tap-unsubscribe",1183890755),(function (p1__28458_SHARP_){
return shadow.remote.runtime.tap_support.tap_unsubscribe(svc,p1__28458_SHARP_);
}),new cljs.core.Keyword(null,"request-tap-history","request-tap-history",-670837812),(function (p1__28459_SHARP_){
return shadow.remote.runtime.tap_support.request_tap_history(svc,p1__28459_SHARP_);
})], null),new cljs.core.Keyword(null,"on-tool-disconnect","on-tool-disconnect",693464366),(function (p1__28460_SHARP_){
return shadow.remote.runtime.tap_support.tool_disconnect(svc,p1__28460_SHARP_);
})], null));

cljs.core.add_tap(tap_fn);

return svc;
});
shadow.remote.runtime.tap_support.stop = (function shadow$remote$runtime$tap_support$stop(p__28496){
var map__28497 = p__28496;
var map__28497__$1 = cljs.core.__destructure_map(map__28497);
var svc = map__28497__$1;
var tap_fn = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__28497__$1,new cljs.core.Keyword(null,"tap-fn","tap-fn",1573556461));
var runtime = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__28497__$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
