goog.provide('shadow.remote.runtime.shared');
shadow.remote.runtime.shared.init_state = (function shadow$remote$runtime$shared$init_state(client_info){
return new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,"extensions","extensions",-1103629196),cljs.core.PersistentArrayMap.EMPTY,new cljs.core.Keyword(null,"ops","ops",1237330063),cljs.core.PersistentArrayMap.EMPTY,new cljs.core.Keyword(null,"client-info","client-info",1958982504),client_info,new cljs.core.Keyword(null,"call-id-seq","call-id-seq",-1679248218),(0),new cljs.core.Keyword(null,"call-handlers","call-handlers",386605551),cljs.core.PersistentArrayMap.EMPTY], null);
});
shadow.remote.runtime.shared.now = (function shadow$remote$runtime$shared$now(){
return Date.now();
});
shadow.remote.runtime.shared.get_client_id = (function shadow$remote$runtime$shared$get_client_id(p__19820){
var map__19823 = p__19820;
var map__19823__$1 = cljs.core.__destructure_map(map__19823);
var runtime = map__19823__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__19823__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
var or__5002__auto__ = new cljs.core.Keyword(null,"client-id","client-id",-464622140).cljs$core$IFn$_invoke$arity$1(cljs.core.deref(state_ref));
if(cljs.core.truth_(or__5002__auto__)){
return or__5002__auto__;
} else {
throw cljs.core.ex_info.cljs$core$IFn$_invoke$arity$2("runtime has no assigned runtime-id",new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"runtime","runtime",-1331573996),runtime], null));
}
});
shadow.remote.runtime.shared.relay_msg = (function shadow$remote$runtime$shared$relay_msg(runtime,msg){
var self_id_20158 = shadow.remote.runtime.shared.get_client_id(runtime);
if(cljs.core.not_EQ_.cljs$core$IFn$_invoke$arity$2(new cljs.core.Keyword(null,"to","to",192099007).cljs$core$IFn$_invoke$arity$1(msg),self_id_20158)){
shadow.remote.runtime.api.relay_msg(runtime,msg);
} else {
Promise.resolve((1)).then((function (){
var G__19829 = runtime;
var G__19830 = cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(msg,new cljs.core.Keyword(null,"from","from",1815293044),self_id_20158);
return (shadow.remote.runtime.shared.process.cljs$core$IFn$_invoke$arity$2 ? shadow.remote.runtime.shared.process.cljs$core$IFn$_invoke$arity$2(G__19829,G__19830) : shadow.remote.runtime.shared.process.call(null, G__19829,G__19830));
}));
}

return msg;
});
shadow.remote.runtime.shared.reply = (function shadow$remote$runtime$shared$reply(runtime,p__19837,res){
var map__19838 = p__19837;
var map__19838__$1 = cljs.core.__destructure_map(map__19838);
var call_id = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__19838__$1,new cljs.core.Keyword(null,"call-id","call-id",1043012968));
var from = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__19838__$1,new cljs.core.Keyword(null,"from","from",1815293044));
var res__$1 = (function (){var G__19840 = res;
var G__19840__$1 = (cljs.core.truth_(call_id)?cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(G__19840,new cljs.core.Keyword(null,"call-id","call-id",1043012968),call_id):G__19840);
if(cljs.core.truth_(from)){
return cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(G__19840__$1,new cljs.core.Keyword(null,"to","to",192099007),from);
} else {
return G__19840__$1;
}
})();
return shadow.remote.runtime.api.relay_msg(runtime,res__$1);
});
shadow.remote.runtime.shared.call = (function shadow$remote$runtime$shared$call(var_args){
var G__19851 = arguments.length;
switch (G__19851) {
case 3:
return shadow.remote.runtime.shared.call.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));

break;
case 4:
return shadow.remote.runtime.shared.call.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));

break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));

}
});

(shadow.remote.runtime.shared.call.cljs$core$IFn$_invoke$arity$3 = (function (runtime,msg,handlers){
return shadow.remote.runtime.shared.call.cljs$core$IFn$_invoke$arity$4(runtime,msg,handlers,(0));
}));

(shadow.remote.runtime.shared.call.cljs$core$IFn$_invoke$arity$4 = (function (p__19857,msg,handlers,timeout_after_ms){
var map__19858 = p__19857;
var map__19858__$1 = cljs.core.__destructure_map(map__19858);
var runtime = map__19858__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__19858__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
if(cljs.core.map_QMARK_(msg)){
} else {
throw (new Error("Assert failed: (map? msg)"));
}

if(cljs.core.map_QMARK_(handlers)){
} else {
throw (new Error("Assert failed: (map? handlers)"));
}

if(cljs.core.nat_int_QMARK_(timeout_after_ms)){
} else {
throw (new Error("Assert failed: (nat-int? timeout-after-ms)"));
}

var call_id = new cljs.core.Keyword(null,"call-id-seq","call-id-seq",-1679248218).cljs$core$IFn$_invoke$arity$1(cljs.core.deref(state_ref));
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$4(state_ref,cljs.core.update,new cljs.core.Keyword(null,"call-id-seq","call-id-seq",-1679248218),cljs.core.inc);

cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$4(state_ref,cljs.core.assoc_in,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"call-handlers","call-handlers",386605551),call_id], null),new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"handlers","handlers",79528781),handlers,new cljs.core.Keyword(null,"called-at","called-at",607081160),shadow.remote.runtime.shared.now(),new cljs.core.Keyword(null,"msg","msg",-1386103444),msg,new cljs.core.Keyword(null,"timeout","timeout",-318625318),timeout_after_ms], null));

return shadow.remote.runtime.api.relay_msg(runtime,cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(msg,new cljs.core.Keyword(null,"call-id","call-id",1043012968),call_id));
}));

(shadow.remote.runtime.shared.call.cljs$lang$maxFixedArity = 4);

shadow.remote.runtime.shared.trigger_BANG_ = (function shadow$remote$runtime$shared$trigger_BANG_(var_args){
var args__5732__auto__ = [];
var len__5726__auto___20202 = arguments.length;
var i__5727__auto___20203 = (0);
while(true){
if((i__5727__auto___20203 < len__5726__auto___20202)){
args__5732__auto__.push((arguments[i__5727__auto___20203]));

var G__20204 = (i__5727__auto___20203 + (1));
i__5727__auto___20203 = G__20204;
continue;
} else {
}
break;
}

var argseq__5733__auto__ = ((((2) < args__5732__auto__.length))?(new cljs.core.IndexedSeq(args__5732__auto__.slice((2)),(0),null)):null);
return shadow.remote.runtime.shared.trigger_BANG_.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__5733__auto__);
});

(shadow.remote.runtime.shared.trigger_BANG_.cljs$core$IFn$_invoke$arity$variadic = (function (p__19874,ev,args){
var map__19879 = p__19874;
var map__19879__$1 = cljs.core.__destructure_map(map__19879);
var runtime = map__19879__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__19879__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
var seq__19882 = cljs.core.seq(cljs.core.vals(new cljs.core.Keyword(null,"extensions","extensions",-1103629196).cljs$core$IFn$_invoke$arity$1(cljs.core.deref(state_ref))));
var chunk__19885 = null;
var count__19886 = (0);
var i__19887 = (0);
while(true){
if((i__19887 < count__19886)){
var ext = chunk__19885.cljs$core$IIndexed$_nth$arity$2(null, i__19887);
var ev_fn = cljs.core.get.cljs$core$IFn$_invoke$arity$2(ext,ev);
if(cljs.core.truth_(ev_fn)){
cljs.core.apply.cljs$core$IFn$_invoke$arity$2(ev_fn,args);


var G__20215 = seq__19882;
var G__20216 = chunk__19885;
var G__20217 = count__19886;
var G__20218 = (i__19887 + (1));
seq__19882 = G__20215;
chunk__19885 = G__20216;
count__19886 = G__20217;
i__19887 = G__20218;
continue;
} else {
var G__20222 = seq__19882;
var G__20223 = chunk__19885;
var G__20224 = count__19886;
var G__20225 = (i__19887 + (1));
seq__19882 = G__20222;
chunk__19885 = G__20223;
count__19886 = G__20224;
i__19887 = G__20225;
continue;
}
} else {
var temp__5804__auto__ = cljs.core.seq(seq__19882);
if(temp__5804__auto__){
var seq__19882__$1 = temp__5804__auto__;
if(cljs.core.chunked_seq_QMARK_(seq__19882__$1)){
var c__5525__auto__ = cljs.core.chunk_first(seq__19882__$1);
var G__20231 = cljs.core.chunk_rest(seq__19882__$1);
var G__20232 = c__5525__auto__;
var G__20233 = cljs.core.count(c__5525__auto__);
var G__20234 = (0);
seq__19882 = G__20231;
chunk__19885 = G__20232;
count__19886 = G__20233;
i__19887 = G__20234;
continue;
} else {
var ext = cljs.core.first(seq__19882__$1);
var ev_fn = cljs.core.get.cljs$core$IFn$_invoke$arity$2(ext,ev);
if(cljs.core.truth_(ev_fn)){
cljs.core.apply.cljs$core$IFn$_invoke$arity$2(ev_fn,args);


var G__20242 = cljs.core.next(seq__19882__$1);
var G__20243 = null;
var G__20244 = (0);
var G__20245 = (0);
seq__19882 = G__20242;
chunk__19885 = G__20243;
count__19886 = G__20244;
i__19887 = G__20245;
continue;
} else {
var G__20247 = cljs.core.next(seq__19882__$1);
var G__20248 = null;
var G__20249 = (0);
var G__20250 = (0);
seq__19882 = G__20247;
chunk__19885 = G__20248;
count__19886 = G__20249;
i__19887 = G__20250;
continue;
}
}
} else {
return null;
}
}
break;
}
}));

(shadow.remote.runtime.shared.trigger_BANG_.cljs$lang$maxFixedArity = (2));

/** @this {Function} */
(shadow.remote.runtime.shared.trigger_BANG_.cljs$lang$applyTo = (function (seq19866){
var G__19867 = cljs.core.first(seq19866);
var seq19866__$1 = cljs.core.next(seq19866);
var G__19868 = cljs.core.first(seq19866__$1);
var seq19866__$2 = cljs.core.next(seq19866__$1);
var self__5711__auto__ = this;
return self__5711__auto__.cljs$core$IFn$_invoke$arity$variadic(G__19867,G__19868,seq19866__$2);
}));

shadow.remote.runtime.shared.welcome = (function shadow$remote$runtime$shared$welcome(p__19920,p__19921){
var map__19922 = p__19920;
var map__19922__$1 = cljs.core.__destructure_map(map__19922);
var runtime = map__19922__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__19922__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
var map__19923 = p__19921;
var map__19923__$1 = cljs.core.__destructure_map(map__19923);
var msg = map__19923__$1;
var client_id = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__19923__$1,new cljs.core.Keyword(null,"client-id","client-id",-464622140));
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$variadic(state_ref,cljs.core.assoc,new cljs.core.Keyword(null,"client-id","client-id",-464622140),client_id,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.Keyword(null,"welcome","welcome",-578152123),true], 0));

var map__19930 = cljs.core.deref(state_ref);
var map__19930__$1 = cljs.core.__destructure_map(map__19930);
var client_info = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__19930__$1,new cljs.core.Keyword(null,"client-info","client-info",1958982504));
var extensions = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__19930__$1,new cljs.core.Keyword(null,"extensions","extensions",-1103629196));
shadow.remote.runtime.shared.relay_msg(runtime,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"op","op",-1882987955),new cljs.core.Keyword(null,"hello","hello",-245025397),new cljs.core.Keyword(null,"client-info","client-info",1958982504),client_info], null));

return shadow.remote.runtime.shared.trigger_BANG_(runtime,new cljs.core.Keyword(null,"on-welcome","on-welcome",1895317125));
});
shadow.remote.runtime.shared.ping = (function shadow$remote$runtime$shared$ping(runtime,msg){
return shadow.remote.runtime.shared.reply(runtime,msg,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"op","op",-1882987955),new cljs.core.Keyword(null,"pong","pong",-172484958)], null));
});
shadow.remote.runtime.shared.request_supported_ops = (function shadow$remote$runtime$shared$request_supported_ops(p__19937,msg){
var map__19939 = p__19937;
var map__19939__$1 = cljs.core.__destructure_map(map__19939);
var runtime = map__19939__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__19939__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
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,"supported-ops","supported-ops",337914702),new cljs.core.Keyword(null,"ops","ops",1237330063),cljs.core.disj.cljs$core$IFn$_invoke$arity$variadic(cljs.core.set(cljs.core.keys(new cljs.core.Keyword(null,"ops","ops",1237330063).cljs$core$IFn$_invoke$arity$1(cljs.core.deref(state_ref)))),new cljs.core.Keyword(null,"welcome","welcome",-578152123),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.Keyword(null,"unknown-relay-op","unknown-relay-op",170832753),new cljs.core.Keyword(null,"unknown-op","unknown-op",1900385996),new cljs.core.Keyword(null,"request-supported-ops","request-supported-ops",-1034994502),new cljs.core.Keyword(null,"tool-disconnect","tool-disconnect",189103996)], 0))], null));
});
shadow.remote.runtime.shared.unknown_relay_op = (function shadow$remote$runtime$shared$unknown_relay_op(msg){
return console.warn("unknown-relay-op",msg);
});
shadow.remote.runtime.shared.unknown_op = (function shadow$remote$runtime$shared$unknown_op(msg){
return console.warn("unknown-op",msg);
});
shadow.remote.runtime.shared.add_extension_STAR_ = (function shadow$remote$runtime$shared$add_extension_STAR_(p__19953,key,p__19954){
var map__19956 = p__19953;
var map__19956__$1 = cljs.core.__destructure_map(map__19956);
var state = map__19956__$1;
var extensions = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__19956__$1,new cljs.core.Keyword(null,"extensions","extensions",-1103629196));
var map__19958 = p__19954;
var map__19958__$1 = cljs.core.__destructure_map(map__19958);
var spec = map__19958__$1;
var ops = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__19958__$1,new cljs.core.Keyword(null,"ops","ops",1237330063));
var transit_write_handlers = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__19958__$1,new cljs.core.Keyword(null,"transit-write-handlers","transit-write-handlers",1886308716));
if(cljs.core.contains_QMARK_(extensions,key)){
throw cljs.core.ex_info.cljs$core$IFn$_invoke$arity$2("extension already registered",new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"key","key",-1516042587),key,new cljs.core.Keyword(null,"spec","spec",347520401),spec], null));
} else {
}

return cljs.core.reduce_kv((function (state__$1,op_kw,op_handler){
if(cljs.core.truth_(cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(state__$1,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"ops","ops",1237330063),op_kw], null)))){
throw cljs.core.ex_info.cljs$core$IFn$_invoke$arity$2("op already registered",new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"key","key",-1516042587),key,new cljs.core.Keyword(null,"op","op",-1882987955),op_kw], null));
} else {
}

return cljs.core.assoc_in(state__$1,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"ops","ops",1237330063),op_kw], null),op_handler);
}),cljs.core.assoc_in(state,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"extensions","extensions",-1103629196),key], null),spec),ops);
});
shadow.remote.runtime.shared.add_extension = (function shadow$remote$runtime$shared$add_extension(p__19969,key,spec){
var map__19970 = p__19969;
var map__19970__$1 = cljs.core.__destructure_map(map__19970);
var runtime = map__19970__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__19970__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$4(state_ref,shadow.remote.runtime.shared.add_extension_STAR_,key,spec);

var temp__5808__auto___20281 = new cljs.core.Keyword(null,"on-welcome","on-welcome",1895317125).cljs$core$IFn$_invoke$arity$1(spec);
if((temp__5808__auto___20281 == null)){
} else {
var on_welcome_20283 = temp__5808__auto___20281;
if(cljs.core.truth_(new cljs.core.Keyword(null,"welcome","welcome",-578152123).cljs$core$IFn$_invoke$arity$1(cljs.core.deref(state_ref)))){
(on_welcome_20283.cljs$core$IFn$_invoke$arity$0 ? on_welcome_20283.cljs$core$IFn$_invoke$arity$0() : on_welcome_20283.call(null, ));
} else {
}
}

return runtime;
});
shadow.remote.runtime.shared.add_defaults = (function shadow$remote$runtime$shared$add_defaults(runtime){
return shadow.remote.runtime.shared.add_extension(runtime,new cljs.core.Keyword("shadow.remote.runtime.shared","defaults","shadow.remote.runtime.shared/defaults",-1821257543),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"ops","ops",1237330063),new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,"welcome","welcome",-578152123),(function (p1__19982_SHARP_){
return shadow.remote.runtime.shared.welcome(runtime,p1__19982_SHARP_);
}),new cljs.core.Keyword(null,"unknown-relay-op","unknown-relay-op",170832753),(function (p1__19983_SHARP_){
return shadow.remote.runtime.shared.unknown_relay_op(p1__19983_SHARP_);
}),new cljs.core.Keyword(null,"unknown-op","unknown-op",1900385996),(function (p1__19985_SHARP_){
return shadow.remote.runtime.shared.unknown_op(p1__19985_SHARP_);
}),new cljs.core.Keyword(null,"ping","ping",-1670114784),(function (p1__19986_SHARP_){
return shadow.remote.runtime.shared.ping(runtime,p1__19986_SHARP_);
}),new cljs.core.Keyword(null,"request-supported-ops","request-supported-ops",-1034994502),(function (p1__19988_SHARP_){
return shadow.remote.runtime.shared.request_supported_ops(runtime,p1__19988_SHARP_);
})], null)], null));
});
shadow.remote.runtime.shared.del_extension_STAR_ = (function shadow$remote$runtime$shared$del_extension_STAR_(state,key){
var ext = cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(state,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"extensions","extensions",-1103629196),key], null));
if(cljs.core.not(ext)){
return state;
} else {
return cljs.core.reduce_kv((function (state__$1,op_kw,op_handler){
return cljs.core.update_in.cljs$core$IFn$_invoke$arity$4(state__$1,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"ops","ops",1237330063)], null),cljs.core.dissoc,op_kw);
}),cljs.core.update.cljs$core$IFn$_invoke$arity$4(state,new cljs.core.Keyword(null,"extensions","extensions",-1103629196),cljs.core.dissoc,key),new cljs.core.Keyword(null,"ops","ops",1237330063).cljs$core$IFn$_invoke$arity$1(ext));
}
});
shadow.remote.runtime.shared.del_extension = (function shadow$remote$runtime$shared$del_extension(p__20012,key){
var map__20013 = p__20012;
var map__20013__$1 = cljs.core.__destructure_map(map__20013);
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__20013__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
return cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$3(state_ref,shadow.remote.runtime.shared.del_extension_STAR_,key);
});
shadow.remote.runtime.shared.unhandled_call_result = (function shadow$remote$runtime$shared$unhandled_call_result(call_config,msg){
return console.warn("unhandled call result",msg,call_config);
});
shadow.remote.runtime.shared.unhandled_client_not_found = (function shadow$remote$runtime$shared$unhandled_client_not_found(p__20021,msg){
var map__20024 = p__20021;
var map__20024__$1 = cljs.core.__destructure_map(map__20024);
var runtime = map__20024__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__20024__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
return shadow.remote.runtime.shared.trigger_BANG_.cljs$core$IFn$_invoke$arity$variadic(runtime,new cljs.core.Keyword(null,"on-client-not-found","on-client-not-found",-642452849),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([msg], 0));
});
shadow.remote.runtime.shared.reply_unknown_op = (function shadow$remote$runtime$shared$reply_unknown_op(runtime,msg){
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,"unknown-op","unknown-op",1900385996),new cljs.core.Keyword(null,"msg","msg",-1386103444),msg], null));
});
shadow.remote.runtime.shared.process = (function shadow$remote$runtime$shared$process(p__20051,p__20052){
var map__20053 = p__20051;
var map__20053__$1 = cljs.core.__destructure_map(map__20053);
var runtime = map__20053__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__20053__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
var map__20054 = p__20052;
var map__20054__$1 = cljs.core.__destructure_map(map__20054);
var msg = map__20054__$1;
var op = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__20054__$1,new cljs.core.Keyword(null,"op","op",-1882987955));
var call_id = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__20054__$1,new cljs.core.Keyword(null,"call-id","call-id",1043012968));
var state = cljs.core.deref(state_ref);
var op_handler = cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(state,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"ops","ops",1237330063),op], null));
if(cljs.core.truth_(call_id)){
var cfg = cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(state,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"call-handlers","call-handlers",386605551),call_id], null));
var call_handler = cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(cfg,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"handlers","handlers",79528781),op], null));
if(cljs.core.truth_(call_handler)){
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$variadic(state_ref,cljs.core.update,new cljs.core.Keyword(null,"call-handlers","call-handlers",386605551),cljs.core.dissoc,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([call_id], 0));

return (call_handler.cljs$core$IFn$_invoke$arity$1 ? call_handler.cljs$core$IFn$_invoke$arity$1(msg) : call_handler.call(null, msg));
} else {
if(cljs.core.truth_(op_handler)){
return (op_handler.cljs$core$IFn$_invoke$arity$1 ? op_handler.cljs$core$IFn$_invoke$arity$1(msg) : op_handler.call(null, msg));
} else {
return shadow.remote.runtime.shared.unhandled_call_result(cfg,msg);

}
}
} else {
if(cljs.core.truth_(op_handler)){
return (op_handler.cljs$core$IFn$_invoke$arity$1 ? op_handler.cljs$core$IFn$_invoke$arity$1(msg) : op_handler.call(null, msg));
} else {
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(new cljs.core.Keyword(null,"client-not-found","client-not-found",-1754042614),op)){
return shadow.remote.runtime.shared.unhandled_client_not_found(runtime,msg);
} else {
return shadow.remote.runtime.shared.reply_unknown_op(runtime,msg);

}
}
}
});
shadow.remote.runtime.shared.run_on_idle = (function shadow$remote$runtime$shared$run_on_idle(state_ref){
var seq__20074 = cljs.core.seq(cljs.core.vals(new cljs.core.Keyword(null,"extensions","extensions",-1103629196).cljs$core$IFn$_invoke$arity$1(cljs.core.deref(state_ref))));
var chunk__20076 = null;
var count__20077 = (0);
var i__20078 = (0);
while(true){
if((i__20078 < count__20077)){
var map__20102 = chunk__20076.cljs$core$IIndexed$_nth$arity$2(null, i__20078);
var map__20102__$1 = cljs.core.__destructure_map(map__20102);
var on_idle = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__20102__$1,new cljs.core.Keyword(null,"on-idle","on-idle",2044706602));
if(cljs.core.truth_(on_idle)){
(on_idle.cljs$core$IFn$_invoke$arity$0 ? on_idle.cljs$core$IFn$_invoke$arity$0() : on_idle.call(null, ));


var G__20306 = seq__20074;
var G__20307 = chunk__20076;
var G__20308 = count__20077;
var G__20309 = (i__20078 + (1));
seq__20074 = G__20306;
chunk__20076 = G__20307;
count__20077 = G__20308;
i__20078 = G__20309;
continue;
} else {
var G__20310 = seq__20074;
var G__20311 = chunk__20076;
var G__20312 = count__20077;
var G__20313 = (i__20078 + (1));
seq__20074 = G__20310;
chunk__20076 = G__20311;
count__20077 = G__20312;
i__20078 = G__20313;
continue;
}
} else {
var temp__5804__auto__ = cljs.core.seq(seq__20074);
if(temp__5804__auto__){
var seq__20074__$1 = temp__5804__auto__;
if(cljs.core.chunked_seq_QMARK_(seq__20074__$1)){
var c__5525__auto__ = cljs.core.chunk_first(seq__20074__$1);
var G__20316 = cljs.core.chunk_rest(seq__20074__$1);
var G__20317 = c__5525__auto__;
var G__20318 = cljs.core.count(c__5525__auto__);
var G__20319 = (0);
seq__20074 = G__20316;
chunk__20076 = G__20317;
count__20077 = G__20318;
i__20078 = G__20319;
continue;
} else {
var map__20116 = cljs.core.first(seq__20074__$1);
var map__20116__$1 = cljs.core.__destructure_map(map__20116);
var on_idle = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__20116__$1,new cljs.core.Keyword(null,"on-idle","on-idle",2044706602));
if(cljs.core.truth_(on_idle)){
(on_idle.cljs$core$IFn$_invoke$arity$0 ? on_idle.cljs$core$IFn$_invoke$arity$0() : on_idle.call(null, ));


var G__20321 = cljs.core.next(seq__20074__$1);
var G__20322 = null;
var G__20323 = (0);
var G__20324 = (0);
seq__20074 = G__20321;
chunk__20076 = G__20322;
count__20077 = G__20323;
i__20078 = G__20324;
continue;
} else {
var G__20325 = cljs.core.next(seq__20074__$1);
var G__20326 = null;
var G__20327 = (0);
var G__20328 = (0);
seq__20074 = G__20325;
chunk__20076 = G__20326;
count__20077 = G__20327;
i__20078 = G__20328;
continue;
}
}
} else {
return null;
}
}
break;
}
});

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