import "./cljs_env.js";
goog.provide('sci.impl.protocols');
sci.impl.protocols.defprotocol = (function sci$impl$protocols$defprotocol(var_args){
var args__4835__auto__ = [];
var len__4829__auto___62053 = arguments.length;
var i__4830__auto___62054 = (0);
while(true){
if((i__4830__auto___62054 < len__4829__auto___62053)){
args__4835__auto__.push((arguments[i__4830__auto___62054]));

var G__62055 = (i__4830__auto___62054 + (1));
i__4830__auto___62054 = G__62055;
continue;
} else {
}
break;
}

var argseq__4836__auto__ = ((((4) < args__4835__auto__.length))?(new cljs.core.IndexedSeq(args__4835__auto__.slice((4)),(0),null)):null);
return sci.impl.protocols.defprotocol.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),argseq__4836__auto__);
});

(sci.impl.protocols.defprotocol.cljs$core$IFn$_invoke$arity$variadic = (function (_,___$1,_ctx,protocol_name,signatures){
var vec__61863 = (function (){var sig = cljs.core.first(signatures);
if(typeof sig === 'string'){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [sig,cljs.core.rest(signatures)], null);
} else {
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,signatures], null);
}
})();
var docstring = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__61863,(0),null);
var signatures__$1 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__61863,(1),null);
var vec__61866 = (function (){var opt = cljs.core.first(signatures__$1);
if((opt instanceof cljs.core.Keyword)){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.PersistentArrayMap.createAsIfByAssoc([opt,cljs.core.second(signatures__$1)]),cljs.core.nnext(signatures__$1)], null);
} else {
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,signatures__$1], null);
}
})();
var opts = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__61866,(0),null);
var signatures__$2 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__61866,(1),null);
var current_ns = cljs.core.str.cljs$core$IFn$_invoke$arity$1(sci.impl.vars.current_ns_name());
var fq_name = cljs.core.symbol.cljs$core$IFn$_invoke$arity$2(current_ns,cljs.core.str.cljs$core$IFn$_invoke$arity$1(protocol_name));
var expansion = cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol(null,"do","do",1686842252,null),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol(null,"def","def",597100991,null),null,(1),null)),(new cljs.core.List(null,cljs.core.with_meta(protocol_name,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"doc","doc",1913296891),docstring], null)),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.array_map,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Keyword(null,"methods","methods",453930866),null,(1),null)),(new cljs.core.List(null,cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_set,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$0()))),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Keyword(null,"name","name",1843675177),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"quote","quote",1377916282,null),null,(1),null)),(new cljs.core.List(null,fq_name,null,(1),null))))),null,(1),null)),(new cljs.core.List(null,new cljs.core.Keyword(null,"ns","ns",441598760),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol("cljs.core","*ns*","cljs.core/*ns*",1155497085,null),null,(1),null))], 0))))),null,(1),null))], 0)))),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.map.cljs$core$IFn$_invoke$arity$2((function (p__61873){
var vec__61874 = p__61873;
var seq__61875 = cljs.core.seq(vec__61874);
var first__61876 = cljs.core.first(seq__61875);
var seq__61875__$1 = cljs.core.next(seq__61875);
var method_name = first__61876;
var ___$2 = seq__61875__$1;
var fq_name__$1 = cljs.core.symbol.cljs$core$IFn$_invoke$arity$2(current_ns,cljs.core.str.cljs$core$IFn$_invoke$arity$1(method_name));
var impls = new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","defmulti","cljs.core/defmulti",723984225,null),null,(1),null)),(new cljs.core.List(null,method_name,null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Symbol("cljs.core","protocol-type-impl","cljs.core/protocol-type-impl",155177701,null),null,(1),null))], 0)))),cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","defmethod","cljs.core/defmethod",-180785162,null),null,(1),null)),(new cljs.core.List(null,method_name,null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Keyword("sci.impl.protocols","reified","sci.impl.protocols/reified",-2019939396),null,(1),null)),(new cljs.core.List(null,cljs.core.vec(cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol(null,"x__61844__auto__","x__61844__auto__",-1096900476,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"&","&",-2144855648,null),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Symbol(null,"args__61845__auto__","args__61845__auto__",-270651401,null),null,(1),null))], 0))))),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","let","cljs.core/let",-308701135,null),null,(1),null)),(new cljs.core.List(null,cljs.core.vec(cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"methods__61846__auto__","methods__61846__auto__",-847249041,null),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","-reified-methods","cljs.core/-reified-methods",-1833109469,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"x__61844__auto__","x__61844__auto__",-1096900476,null),null,(1),null))))),null,(1),null)))))),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","apply","cljs.core/apply",1757277831,null),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","get","cljs.core/get",-296075407,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"methods__61846__auto__","methods__61846__auto__",-847249041,null),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"quote","quote",1377916282,null),null,(1),null)),(new cljs.core.List(null,method_name,null,(1),null))))),null,(1),null))], 0)))),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Symbol(null,"x__61844__auto__","x__61844__auto__",-1096900476,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"args__61845__auto__","args__61845__auto__",-270651401,null),null,(1),null))], 0)))),null,(1),null))], 0)))),null,(1),null))], 0))))], null);
var impls__$1 = (cljs.core.truth_(new cljs.core.Keyword(null,"extend-via-metadata","extend-via-metadata",-427346794).cljs$core$IFn$_invoke$arity$1(opts))?cljs.core.conj.cljs$core$IFn$_invoke$arity$2(impls,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","defmethod","cljs.core/defmethod",-180785162,null),null,(1),null)),(new cljs.core.List(null,method_name,null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Keyword(null,"default","default",-1987822328),null,(1),null)),(new cljs.core.List(null,cljs.core.vec(cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol(null,"x__61847__auto__","x__61847__auto__",-1261962203,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"&","&",-2144855648,null),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Symbol(null,"args__61848__auto__","args__61848__auto__",791410708,null),null,(1),null))], 0))))),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","let","cljs.core/let",-308701135,null),null,(1),null)),(new cljs.core.List(null,cljs.core.vec(cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol(null,"meta__61849__auto__","meta__61849__auto__",-1621484802,null),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","meta","cljs.core/meta",-748218346,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"x__61847__auto__","x__61847__auto__",-1261962203,null),null,(1),null))))),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Symbol(null,"method__61850__auto__","method__61850__auto__",1172935852,null),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","get","cljs.core/get",-296075407,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"meta__61849__auto__","meta__61849__auto__",-1621484802,null),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"quote","quote",1377916282,null),null,(1),null)),(new cljs.core.List(null,fq_name__$1,null,(1),null))))),null,(1),null))], 0)))),null,(1),null))], 0))))),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol(null,"if","if",1181717262,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"method__61850__auto__","method__61850__auto__",1172935852,null),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","apply","cljs.core/apply",1757277831,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"method__61850__auto__","method__61850__auto__",1172935852,null),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Symbol(null,"x__61847__auto__","x__61847__auto__",-1261962203,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"args__61848__auto__","args__61848__auto__",791410708,null),null,(1),null))], 0)))),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"throw","throw",595905694,null),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol(null,"new","new",-444906321,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol("js","Error","js/Error",-1692659266,null),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","str","cljs.core/str",-1971828991,null),null,(1),null)),(new cljs.core.List(null,"No implementation of method: ",null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.keyword.cljs$core$IFn$_invoke$arity$1(method_name),null,(1),null)),(new cljs.core.List(null," of protocol: ",null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"var","var",870848730,null),null,(1),null)),(new cljs.core.List(null,protocol_name,null,(1),null))))),null,(1),null)),(new cljs.core.List(null," found for: ",null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","protocol-type-impl","cljs.core/protocol-type-impl",155177701,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"x__61847__auto__","x__61847__auto__",-1261962203,null),null,(1),null))))),null,(1),null))], 0)))),null,(1),null))], 0)))),null,(1),null))))),null,(1),null))], 0)))),null,(1),null))], 0)))),null,(1),null))], 0))))):impls);
return cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol(null,"do","do",1686842252,null),null,(1),null)),impls__$1,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol(null,"def","def",597100991,null),null,(1),null)),(new cljs.core.List(null,protocol_name,null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","update","cljs.core/update",-908565906,null),null,(1),null)),(new cljs.core.List(null,protocol_name,null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Keyword(null,"methods","methods",453930866),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol("cljs.core","conj","cljs.core/conj",-460750931,null),null,(1),null)),(new cljs.core.List(null,method_name,null,(1),null))], 0)))),null,(1),null))], 0)))),null,(1),null))], 0))));
}),signatures__$2)], 0))));
return expansion;
}));

(sci.impl.protocols.defprotocol.cljs$lang$maxFixedArity = (4));

/** @this {Function} */
(sci.impl.protocols.defprotocol.cljs$lang$applyTo = (function (seq61851){
var G__61852 = cljs.core.first(seq61851);
var seq61851__$1 = cljs.core.next(seq61851);
var G__61853 = cljs.core.first(seq61851__$1);
var seq61851__$2 = cljs.core.next(seq61851__$1);
var G__61854 = cljs.core.first(seq61851__$2);
var seq61851__$3 = cljs.core.next(seq61851__$2);
var G__61855 = cljs.core.first(seq61851__$3);
var seq61851__$4 = cljs.core.next(seq61851__$3);
var self__4816__auto__ = this;
return self__4816__auto__.cljs$core$IFn$_invoke$arity$variadic(G__61852,G__61853,G__61854,G__61855,seq61851__$4);
}));

sci.impl.protocols.extend_protocol = (function sci$impl$protocols$extend_protocol(var_args){
var args__4835__auto__ = [];
var len__4829__auto___62068 = arguments.length;
var i__4830__auto___62069 = (0);
while(true){
if((i__4830__auto___62069 < len__4829__auto___62068)){
args__4835__auto__.push((arguments[i__4830__auto___62069]));

var G__62070 = (i__4830__auto___62069 + (1));
i__4830__auto___62069 = G__62070;
continue;
} else {
}
break;
}

var argseq__4836__auto__ = ((((4) < args__4835__auto__.length))?(new cljs.core.IndexedSeq(args__4835__auto__.slice((4)),(0),null)):null);
return sci.impl.protocols.extend_protocol.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),argseq__4836__auto__);
});

(sci.impl.protocols.extend_protocol.cljs$core$IFn$_invoke$arity$variadic = (function (_,___$1,ctx,protocol_name,impls){
var impls__$1 = sci.impl.utils.split_when((function (p1__61888_SHARP_){
return (!(cljs.core.seq_QMARK_(p1__61888_SHARP_)));
}),impls);
var protocol_var = (function (){var G__61897 = ctx;
var G__61898 = new cljs.core.Keyword(null,"bindingx","bindingx",679516896).cljs$core$IFn$_invoke$arity$1(ctx);
var G__61899 = protocol_name;
var fexpr__61896 = cljs.core.deref(sci.impl.utils.eval_resolve_state);
return (fexpr__61896.cljs$core$IFn$_invoke$arity$3 ? fexpr__61896.cljs$core$IFn$_invoke$arity$3(G__61897,G__61898,G__61899) : fexpr__61896.call(null,G__61897,G__61898,G__61899));
})();
var protocol_ns = new cljs.core.Keyword(null,"ns","ns",441598760).cljs$core$IFn$_invoke$arity$1(cljs.core.deref(protocol_var));
var pns = cljs.core.str.cljs$core$IFn$_invoke$arity$1(sci.impl.vars.getName(protocol_ns));
var fq_meth_name = (function (p1__61889_SHARP_){
return cljs.core.symbol.cljs$core$IFn$_invoke$arity$2(pns,p1__61889_SHARP_);
});
var expansion = cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"do","do",1686842252,null),null,(1),null)),cljs.core.map.cljs$core$IFn$_invoke$arity$2((function (p__61900){
var vec__61901 = p__61900;
var seq__61902 = cljs.core.seq(vec__61901);
var first__61903 = cljs.core.first(seq__61902);
var seq__61902__$1 = cljs.core.next(seq__61902);
var type = first__61903;
var meths = seq__61902__$1;
return cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"do","do",1686842252,null),null,(1),null)),cljs.core.map.cljs$core$IFn$_invoke$arity$2((function (meth){
return cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","defmethod","cljs.core/defmethod",-180785162,null),null,(1),null)),(new cljs.core.List(null,fq_meth_name(cljs.core.name(cljs.core.first(meth))),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,type,null,(1),null)),(new cljs.core.List(null,cljs.core.second(meth),null,(1),null)),cljs.core.nnext(meth)], 0))));
}),meths))));
}),impls__$1))));
return expansion;
}));

(sci.impl.protocols.extend_protocol.cljs$lang$maxFixedArity = (4));

/** @this {Function} */
(sci.impl.protocols.extend_protocol.cljs$lang$applyTo = (function (seq61890){
var G__61891 = cljs.core.first(seq61890);
var seq61890__$1 = cljs.core.next(seq61890);
var G__61892 = cljs.core.first(seq61890__$1);
var seq61890__$2 = cljs.core.next(seq61890__$1);
var G__61893 = cljs.core.first(seq61890__$2);
var seq61890__$3 = cljs.core.next(seq61890__$2);
var G__61894 = cljs.core.first(seq61890__$3);
var seq61890__$4 = cljs.core.next(seq61890__$3);
var self__4816__auto__ = this;
return self__4816__auto__.cljs$core$IFn$_invoke$arity$variadic(G__61891,G__61892,G__61893,G__61894,seq61890__$4);
}));

sci.impl.protocols.extend = (function sci$impl$protocols$extend(var_args){
var args__4835__auto__ = [];
var len__4829__auto___62072 = arguments.length;
var i__4830__auto___62073 = (0);
while(true){
if((i__4830__auto___62073 < len__4829__auto___62072)){
args__4835__auto__.push((arguments[i__4830__auto___62073]));

var G__62074 = (i__4830__auto___62073 + (1));
i__4830__auto___62073 = G__62074;
continue;
} else {
}
break;
}

var argseq__4836__auto__ = ((((2) < args__4835__auto__.length))?(new cljs.core.IndexedSeq(args__4835__auto__.slice((2)),(0),null)):null);
return sci.impl.protocols.extend.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__4836__auto__);
});

(sci.impl.protocols.extend.cljs$core$IFn$_invoke$arity$variadic = (function (ctx,atype,proto_PLUS_mmaps){
var seq__61910 = cljs.core.seq(cljs.core.partition.cljs$core$IFn$_invoke$arity$2((2),proto_PLUS_mmaps));
var chunk__61912 = null;
var count__61913 = (0);
var i__61914 = (0);
while(true){
if((i__61914 < count__61913)){
var vec__61957 = chunk__61912.cljs$core$IIndexed$_nth$arity$2(null,i__61914);
var proto = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__61957,(0),null);
var mmap = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__61957,(1),null);
var proto_ns_62075 = new cljs.core.Keyword(null,"ns","ns",441598760).cljs$core$IFn$_invoke$arity$1(proto);
var pns_62076 = sci.impl.vars.getName(proto_ns_62075);
var seq__61960_62077 = cljs.core.seq(mmap);
var chunk__61961_62078 = null;
var count__61962_62079 = (0);
var i__61963_62080 = (0);
while(true){
if((i__61963_62080 < count__61962_62079)){
var vec__61970_62081 = chunk__61961_62078.cljs$core$IIndexed$_nth$arity$2(null,i__61963_62080);
var fn_name_62082 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__61970_62081,(0),null);
var f_62083 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__61970_62081,(1),null);
var fn_sym_62084 = cljs.core.symbol.cljs$core$IFn$_invoke$arity$1(cljs.core.name(fn_name_62082));
var env_62085 = cljs.core.deref(new cljs.core.Keyword(null,"env","env",-1815813235).cljs$core$IFn$_invoke$arity$1(ctx));
var multi_method_var_62086 = cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(env_62085,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"namespaces","namespaces",-1444157469),pns_62076,fn_sym_62084], null));
var multi_method_62087 = cljs.core.deref(multi_method_var_62086);
sci.impl.multimethods.multi_fn_add_method_impl(multi_method_62087,atype,f_62083);


var G__62088 = seq__61960_62077;
var G__62089 = chunk__61961_62078;
var G__62090 = count__61962_62079;
var G__62091 = (i__61963_62080 + (1));
seq__61960_62077 = G__62088;
chunk__61961_62078 = G__62089;
count__61962_62079 = G__62090;
i__61963_62080 = G__62091;
continue;
} else {
var temp__5753__auto___62092 = cljs.core.seq(seq__61960_62077);
if(temp__5753__auto___62092){
var seq__61960_62094__$1 = temp__5753__auto___62092;
if(cljs.core.chunked_seq_QMARK_(seq__61960_62094__$1)){
var c__4649__auto___62095 = cljs.core.chunk_first(seq__61960_62094__$1);
var G__62096 = cljs.core.chunk_rest(seq__61960_62094__$1);
var G__62097 = c__4649__auto___62095;
var G__62098 = cljs.core.count(c__4649__auto___62095);
var G__62099 = (0);
seq__61960_62077 = G__62096;
chunk__61961_62078 = G__62097;
count__61962_62079 = G__62098;
i__61963_62080 = G__62099;
continue;
} else {
var vec__61973_62100 = cljs.core.first(seq__61960_62094__$1);
var fn_name_62101 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__61973_62100,(0),null);
var f_62102 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__61973_62100,(1),null);
var fn_sym_62103 = cljs.core.symbol.cljs$core$IFn$_invoke$arity$1(cljs.core.name(fn_name_62101));
var env_62104 = cljs.core.deref(new cljs.core.Keyword(null,"env","env",-1815813235).cljs$core$IFn$_invoke$arity$1(ctx));
var multi_method_var_62105 = cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(env_62104,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"namespaces","namespaces",-1444157469),pns_62076,fn_sym_62103], null));
var multi_method_62106 = cljs.core.deref(multi_method_var_62105);
sci.impl.multimethods.multi_fn_add_method_impl(multi_method_62106,atype,f_62102);


var G__62107 = cljs.core.next(seq__61960_62094__$1);
var G__62108 = null;
var G__62109 = (0);
var G__62110 = (0);
seq__61960_62077 = G__62107;
chunk__61961_62078 = G__62108;
count__61962_62079 = G__62109;
i__61963_62080 = G__62110;
continue;
}
} else {
}
}
break;
}


var G__62111 = seq__61910;
var G__62112 = chunk__61912;
var G__62113 = count__61913;
var G__62114 = (i__61914 + (1));
seq__61910 = G__62111;
chunk__61912 = G__62112;
count__61913 = G__62113;
i__61914 = G__62114;
continue;
} else {
var temp__5753__auto__ = cljs.core.seq(seq__61910);
if(temp__5753__auto__){
var seq__61910__$1 = temp__5753__auto__;
if(cljs.core.chunked_seq_QMARK_(seq__61910__$1)){
var c__4649__auto__ = cljs.core.chunk_first(seq__61910__$1);
var G__62115 = cljs.core.chunk_rest(seq__61910__$1);
var G__62116 = c__4649__auto__;
var G__62117 = cljs.core.count(c__4649__auto__);
var G__62118 = (0);
seq__61910 = G__62115;
chunk__61912 = G__62116;
count__61913 = G__62117;
i__61914 = G__62118;
continue;
} else {
var vec__61976 = cljs.core.first(seq__61910__$1);
var proto = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__61976,(0),null);
var mmap = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__61976,(1),null);
var proto_ns_62119 = new cljs.core.Keyword(null,"ns","ns",441598760).cljs$core$IFn$_invoke$arity$1(proto);
var pns_62120 = sci.impl.vars.getName(proto_ns_62119);
var seq__61979_62121 = cljs.core.seq(mmap);
var chunk__61980_62122 = null;
var count__61981_62123 = (0);
var i__61982_62124 = (0);
while(true){
if((i__61982_62124 < count__61981_62123)){
var vec__61991_62125 = chunk__61980_62122.cljs$core$IIndexed$_nth$arity$2(null,i__61982_62124);
var fn_name_62126 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__61991_62125,(0),null);
var f_62127 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__61991_62125,(1),null);
var fn_sym_62128 = cljs.core.symbol.cljs$core$IFn$_invoke$arity$1(cljs.core.name(fn_name_62126));
var env_62129 = cljs.core.deref(new cljs.core.Keyword(null,"env","env",-1815813235).cljs$core$IFn$_invoke$arity$1(ctx));
var multi_method_var_62130 = cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(env_62129,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"namespaces","namespaces",-1444157469),pns_62120,fn_sym_62128], null));
var multi_method_62131 = cljs.core.deref(multi_method_var_62130);
sci.impl.multimethods.multi_fn_add_method_impl(multi_method_62131,atype,f_62127);


var G__62132 = seq__61979_62121;
var G__62133 = chunk__61980_62122;
var G__62134 = count__61981_62123;
var G__62135 = (i__61982_62124 + (1));
seq__61979_62121 = G__62132;
chunk__61980_62122 = G__62133;
count__61981_62123 = G__62134;
i__61982_62124 = G__62135;
continue;
} else {
var temp__5753__auto___62136__$1 = cljs.core.seq(seq__61979_62121);
if(temp__5753__auto___62136__$1){
var seq__61979_62137__$1 = temp__5753__auto___62136__$1;
if(cljs.core.chunked_seq_QMARK_(seq__61979_62137__$1)){
var c__4649__auto___62138 = cljs.core.chunk_first(seq__61979_62137__$1);
var G__62139 = cljs.core.chunk_rest(seq__61979_62137__$1);
var G__62140 = c__4649__auto___62138;
var G__62141 = cljs.core.count(c__4649__auto___62138);
var G__62142 = (0);
seq__61979_62121 = G__62139;
chunk__61980_62122 = G__62140;
count__61981_62123 = G__62141;
i__61982_62124 = G__62142;
continue;
} else {
var vec__61994_62143 = cljs.core.first(seq__61979_62137__$1);
var fn_name_62144 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__61994_62143,(0),null);
var f_62145 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__61994_62143,(1),null);
var fn_sym_62146 = cljs.core.symbol.cljs$core$IFn$_invoke$arity$1(cljs.core.name(fn_name_62144));
var env_62147 = cljs.core.deref(new cljs.core.Keyword(null,"env","env",-1815813235).cljs$core$IFn$_invoke$arity$1(ctx));
var multi_method_var_62148 = cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(env_62147,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"namespaces","namespaces",-1444157469),pns_62120,fn_sym_62146], null));
var multi_method_62149 = cljs.core.deref(multi_method_var_62148);
sci.impl.multimethods.multi_fn_add_method_impl(multi_method_62149,atype,f_62145);


var G__62150 = cljs.core.next(seq__61979_62137__$1);
var G__62151 = null;
var G__62152 = (0);
var G__62153 = (0);
seq__61979_62121 = G__62150;
chunk__61980_62122 = G__62151;
count__61981_62123 = G__62152;
i__61982_62124 = G__62153;
continue;
}
} else {
}
}
break;
}


var G__62154 = cljs.core.next(seq__61910__$1);
var G__62155 = null;
var G__62156 = (0);
var G__62157 = (0);
seq__61910 = G__62154;
chunk__61912 = G__62155;
count__61913 = G__62156;
i__61914 = G__62157;
continue;
}
} else {
return null;
}
}
break;
}
}));

(sci.impl.protocols.extend.cljs$lang$maxFixedArity = (2));

/** @this {Function} */
(sci.impl.protocols.extend.cljs$lang$applyTo = (function (seq61904){
var G__61905 = cljs.core.first(seq61904);
var seq61904__$1 = cljs.core.next(seq61904);
var G__61906 = cljs.core.first(seq61904__$1);
var seq61904__$2 = cljs.core.next(seq61904__$1);
var self__4816__auto__ = this;
return self__4816__auto__.cljs$core$IFn$_invoke$arity$variadic(G__61905,G__61906,seq61904__$2);
}));

sci.impl.protocols.extend_type = (function sci$impl$protocols$extend_type(var_args){
var args__4835__auto__ = [];
var len__4829__auto___62158 = arguments.length;
var i__4830__auto___62159 = (0);
while(true){
if((i__4830__auto___62159 < len__4829__auto___62158)){
args__4835__auto__.push((arguments[i__4830__auto___62159]));

var G__62160 = (i__4830__auto___62159 + (1));
i__4830__auto___62159 = G__62160;
continue;
} else {
}
break;
}

var argseq__4836__auto__ = ((((4) < args__4835__auto__.length))?(new cljs.core.IndexedSeq(args__4835__auto__.slice((4)),(0),null)):null);
return sci.impl.protocols.extend_type.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),argseq__4836__auto__);
});

(sci.impl.protocols.extend_type.cljs$core$IFn$_invoke$arity$variadic = (function (_,___$1,ctx,atype,proto_PLUS_meths){
var proto_PLUS_meths__$1 = sci.impl.utils.split_when((function (p1__62009_SHARP_){
return (!(cljs.core.seq_QMARK_(p1__62009_SHARP_)));
}),proto_PLUS_meths);
return cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"do","do",1686842252,null),null,(1),null)),cljs.core.map.cljs$core$IFn$_invoke$arity$2((function (p__62016){
var vec__62017 = p__62016;
var seq__62018 = cljs.core.seq(vec__62017);
var first__62019 = cljs.core.first(seq__62018);
var seq__62018__$1 = cljs.core.next(seq__62018);
var proto = first__62019;
var meths = seq__62018__$1;
var protocol_var = (function (){var G__62021 = ctx;
var G__62022 = new cljs.core.Keyword(null,"bindings","bindings",1271397192).cljs$core$IFn$_invoke$arity$1(ctx);
var G__62023 = proto;
var fexpr__62020 = cljs.core.deref(sci.impl.utils.eval_resolve_state);
return (fexpr__62020.cljs$core$IFn$_invoke$arity$3 ? fexpr__62020.cljs$core$IFn$_invoke$arity$3(G__62021,G__62022,G__62023) : fexpr__62020.call(null,G__62021,G__62022,G__62023));
})();
var protocol_ns = new cljs.core.Keyword(null,"ns","ns",441598760).cljs$core$IFn$_invoke$arity$1(cljs.core.deref(protocol_var));
var pns = cljs.core.str.cljs$core$IFn$_invoke$arity$1(sci.impl.vars.getName(protocol_ns));
var fq_meth_name = (function (p1__62010_SHARP_){
return cljs.core.symbol.cljs$core$IFn$_invoke$arity$2(pns,p1__62010_SHARP_);
});
return cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"do","do",1686842252,null),null,(1),null)),cljs.core.map.cljs$core$IFn$_invoke$arity$2((function (meth){
return cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","defmethod","cljs.core/defmethod",-180785162,null),null,(1),null)),(new cljs.core.List(null,fq_meth_name(cljs.core.name(cljs.core.first(meth))),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,atype,null,(1),null)),(new cljs.core.List(null,cljs.core.second(meth),null,(1),null)),cljs.core.nnext(meth)], 0))));
}),meths))));
}),proto_PLUS_meths__$1))));
}));

(sci.impl.protocols.extend_type.cljs$lang$maxFixedArity = (4));

/** @this {Function} */
(sci.impl.protocols.extend_type.cljs$lang$applyTo = (function (seq62011){
var G__62012 = cljs.core.first(seq62011);
var seq62011__$1 = cljs.core.next(seq62011);
var G__62013 = cljs.core.first(seq62011__$1);
var seq62011__$2 = cljs.core.next(seq62011__$1);
var G__62014 = cljs.core.first(seq62011__$2);
var seq62011__$3 = cljs.core.next(seq62011__$2);
var G__62015 = cljs.core.first(seq62011__$3);
var seq62011__$4 = cljs.core.next(seq62011__$3);
var self__4816__auto__ = this;
return self__4816__auto__.cljs$core$IFn$_invoke$arity$variadic(G__62012,G__62013,G__62014,G__62015,seq62011__$4);
}));

sci.impl.protocols.find_matching_non_default_method = (function sci$impl$protocols$find_matching_non_default_method(protocol,obj){
return cljs.core.boolean$(cljs.core.some((function (p1__62028_SHARP_){
var temp__5753__auto__ = cljs.core.get_method(p1__62028_SHARP_,sci.impl.types.type_impl(obj));
if(cljs.core.truth_(temp__5753__auto__)){
var m = temp__5753__auto__;
var ms = cljs.core.methods$(p1__62028_SHARP_);
var default$ = cljs.core.get.cljs$core$IFn$_invoke$arity$2(ms,new cljs.core.Keyword(null,"default","default",-1987822328));
return (!((m === default$)));
} else {
return null;
}
}),new cljs.core.Keyword(null,"methods","methods",453930866).cljs$core$IFn$_invoke$arity$1(protocol)));
});
sci.impl.protocols.satisfies_QMARK_ = (function sci$impl$protocols$satisfies_QMARK_(protocol,obj){
if((obj instanceof sci.impl.types.Reified)){
return cljs.core.contains_QMARK_(obj.sci$impl$types$IReified$getProtocols$arity$1(null),protocol);
} else {
var p = new cljs.core.Keyword(null,"protocol","protocol",652470118).cljs$core$IFn$_invoke$arity$1(protocol);
var or__4223__auto__ = (function (){var and__4221__auto__ = p;
if(cljs.core.truth_(and__4221__auto__)){
var pred__62039 = cljs.core._EQ_;
var expr__62040 = p;
if(cljs.core.truth_((pred__62039.cljs$core$IFn$_invoke$arity$2 ? pred__62039.cljs$core$IFn$_invoke$arity$2(cljs.core.IDeref,expr__62040) : pred__62039.call(null,cljs.core.IDeref,expr__62040)))){
if((!((obj == null)))){
if((((obj.cljs$lang$protocol_mask$partition0$ & (32768))) || ((cljs.core.PROTOCOL_SENTINEL === obj.cljs$core$IDeref$)))){
return true;
} else {
if((!obj.cljs$lang$protocol_mask$partition0$)){
return cljs.core.native_satisfies_QMARK_(cljs.core.IDeref,obj);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_(cljs.core.IDeref,obj);
}
} else {
if(cljs.core.truth_((pred__62039.cljs$core$IFn$_invoke$arity$2 ? pred__62039.cljs$core$IFn$_invoke$arity$2(cljs.core.ISwap,expr__62040) : pred__62039.call(null,cljs.core.ISwap,expr__62040)))){
if((!((obj == null)))){
if((((obj.cljs$lang$protocol_mask$partition1$ & (65536))) || ((cljs.core.PROTOCOL_SENTINEL === obj.cljs$core$ISwap$)))){
return true;
} else {
if((!obj.cljs$lang$protocol_mask$partition1$)){
return cljs.core.native_satisfies_QMARK_(cljs.core.ISwap,obj);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_(cljs.core.ISwap,obj);
}
} else {
if(cljs.core.truth_((pred__62039.cljs$core$IFn$_invoke$arity$2 ? pred__62039.cljs$core$IFn$_invoke$arity$2(cljs.core.IReset,expr__62040) : pred__62039.call(null,cljs.core.IReset,expr__62040)))){
if((!((obj == null)))){
if((((obj.cljs$lang$protocol_mask$partition1$ & (32768))) || ((cljs.core.PROTOCOL_SENTINEL === obj.cljs$core$IReset$)))){
return true;
} else {
if((!obj.cljs$lang$protocol_mask$partition1$)){
return cljs.core.native_satisfies_QMARK_(cljs.core.IReset,obj);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_(cljs.core.IReset,obj);
}
} else {
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(expr__62040)].join('')));
}
}
}
} else {
return and__4221__auto__;
}
})();
if(cljs.core.truth_(or__4223__auto__)){
return or__4223__auto__;
} else {
return sci.impl.protocols.find_matching_non_default_method(protocol,obj);
}
}
});
sci.impl.protocols.instance_impl = (function sci$impl$protocols$instance_impl(clazz,x){
if(cljs.core.truth_((function (){var and__4221__auto__ = (clazz instanceof cljs.core.Symbol);
if(and__4221__auto__){
var G__62051 = clazz;
var G__62051__$1 = (((G__62051 == null))?null:cljs.core.meta(G__62051));
if((G__62051__$1 == null)){
return null;
} else {
return new cljs.core.Keyword("sci.impl","record","sci.impl/record",-1939193950).cljs$core$IFn$_invoke$arity$1(G__62051__$1);
}
} else {
return and__4221__auto__;
}
})())){
return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(clazz,new cljs.core.Keyword(null,"type","type",1174270348).cljs$core$IFn$_invoke$arity$1(cljs.core.meta(x)));
} else {
return (x instanceof clazz);

}
});
/**
 * Returns true if atype extends protocol
 */
sci.impl.protocols.extends_QMARK_ = (function sci$impl$protocols$extends_QMARK_(protocol,atype){
return cljs.core.boolean$(cljs.core.some((function (p1__62052_SHARP_){
return cljs.core.get_method(p1__62052_SHARP_,atype);
}),new cljs.core.Keyword(null,"methods","methods",453930866).cljs$core$IFn$_invoke$arity$1(protocol)));
});

//# sourceMappingURL=sci.impl.protocols.js.map
