// Compiled by ClojureScript 1.9.562 {}
goog.provide('rum.core');
goog.require('cljs.core');
goog.require('sablono.core');
goog.require('rum.cursor');
goog.require('rum.util');
goog.require('rum.derived_atom');
/**
 * Given React component, returns Rum state associated with it
 */
rum.core.state = (function rum$core$state(comp){
return (comp.state[":rum/state"]);
});
rum.core.build_class = (function rum$core$build_class(render,mixins,display_name){
var init = rum.util.collect.call(null,new cljs.core.Keyword(null,"init","init",-1875481434),mixins);
var will_mount = rum.util.collect_STAR_.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"will-mount","will-mount",-434633071),new cljs.core.Keyword(null,"before-render","before-render",71256781)], null),mixins);
var render__$1 = render;
var wrap_render = rum.util.collect.call(null,new cljs.core.Keyword(null,"wrap-render","wrap-render",1782000986),mixins);
var wrapped_render = cljs.core.reduce.call(null,((function (init,will_mount,render__$1,wrap_render){
return (function (p1__37937_SHARP_,p2__37936_SHARP_){
return p2__37936_SHARP_.call(null,p1__37937_SHARP_);
});})(init,will_mount,render__$1,wrap_render))
,render__$1,wrap_render);
var did_mount = rum.util.collect_STAR_.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"did-mount","did-mount",918232960),new cljs.core.Keyword(null,"after-render","after-render",1997533433)], null),mixins);
var did_remount = rum.util.collect.call(null,new cljs.core.Keyword(null,"did-remount","did-remount",1362550500),mixins);
var should_update = rum.util.collect.call(null,new cljs.core.Keyword(null,"should-update","should-update",-1292781795),mixins);
var will_update = rum.util.collect_STAR_.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"will-update","will-update",328062998),new cljs.core.Keyword(null,"before-render","before-render",71256781)], null),mixins);
var did_update = rum.util.collect_STAR_.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"did-update","did-update",-2143702256),new cljs.core.Keyword(null,"after-render","after-render",1997533433)], null),mixins);
var will_unmount = rum.util.collect.call(null,new cljs.core.Keyword(null,"will-unmount","will-unmount",-808051550),mixins);
var child_context = rum.util.collect.call(null,new cljs.core.Keyword(null,"child-context","child-context",-1375270295),mixins);
var class_props = cljs.core.reduce.call(null,cljs.core.merge,rum.util.collect.call(null,new cljs.core.Keyword(null,"class-properties","class-properties",1351279702),mixins));
return React.createClass(cljs.core.clj__GT_js.call(null,rum.util.filter_vals.call(null,cljs.core.some_QMARK_,cljs.core.merge.call(null,cljs.core.PersistentHashMap.fromArrays([new cljs.core.Keyword(null,"componentDidUpdate","componentDidUpdate",-1983477981),new cljs.core.Keyword(null,"displayName","displayName",-809144601),new cljs.core.Keyword(null,"componentWillUnmount","componentWillUnmount",1573788814),new cljs.core.Keyword(null,"componentWillReceiveProps","componentWillReceiveProps",559988974),new cljs.core.Keyword(null,"shouldComponentUpdate","shouldComponentUpdate",1795750960),new cljs.core.Keyword(null,"render","render",-1408033454),new cljs.core.Keyword(null,"getChildContext","getChildContext",-1321948108),new cljs.core.Keyword(null,"componentWillUpdate","componentWillUpdate",657390932),new cljs.core.Keyword(null,"getInitialState","getInitialState",1541760916),new cljs.core.Keyword(null,"componentDidMount","componentDidMount",955710936),new cljs.core.Keyword(null,"componentWillMount","componentWillMount",-285327619)],[((cljs.core.empty_QMARK_.call(null,did_update))?null:((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (_,___$1){
var this$ = this;
return cljs.core._vreset_BANG_.call(null,rum.core.state.call(null,this$),rum.util.call_all.call(null,cljs.core._deref.call(null,rum.core.state.call(null,this$)),did_update));
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
),display_name,((cljs.core.empty_QMARK_.call(null,will_unmount))?null:((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (){
var this$ = this;
return cljs.core._vreset_BANG_.call(null,rum.core.state.call(null,this$),rum.util.call_all.call(null,cljs.core._deref.call(null,rum.core.state.call(null,this$)),will_unmount));
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
),((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (next_props){
var this$ = this;
var old_state = cljs.core.deref.call(null,rum.core.state.call(null,this$));
var state = cljs.core.merge.call(null,old_state,(next_props[":rum/initial-state"]));
var next_state = cljs.core.reduce.call(null,((function (old_state,state,this$,init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (p1__37939_SHARP_,p2__37938_SHARP_){
return p2__37938_SHARP_.call(null,old_state,p1__37939_SHARP_);
});})(old_state,state,this$,init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
,state,did_remount);
return this$.setState(({":rum/state": cljs.core.volatile_BANG_.call(null,next_state)}));
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
,((cljs.core.empty_QMARK_.call(null,should_update))?null:((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (next_props,next_state){
var this$ = this;
var old_state = cljs.core.deref.call(null,rum.core.state.call(null,this$));
var new_state = cljs.core.deref.call(null,(next_state[":rum/state"]));
var or__23338__auto__ = cljs.core.some.call(null,((function (old_state,new_state,this$,init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (p1__37940_SHARP_){
return p1__37940_SHARP_.call(null,old_state,new_state);
});})(old_state,new_state,this$,init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
,should_update);
if(cljs.core.truth_(or__23338__auto__)){
return or__23338__auto__;
} else {
return false;
}
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
),((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (){
var this$ = this;
var state = rum.core.state.call(null,this$);
var vec__37945 = wrapped_render.call(null,cljs.core.deref.call(null,state));
var dom = cljs.core.nth.call(null,vec__37945,(0),null);
var next_state = cljs.core.nth.call(null,vec__37945,(1),null);
cljs.core.vreset_BANG_.call(null,state,next_state);

return dom;
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
,((cljs.core.empty_QMARK_.call(null,child_context))?null:((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (){
var this$ = this;
var state = cljs.core.deref.call(null,rum.core.state.call(null,this$));
return cljs.core.clj__GT_js.call(null,cljs.core.transduce.call(null,cljs.core.map.call(null,((function (state,this$,init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (p1__37941_SHARP_){
return p1__37941_SHARP_.call(null,state);
});})(state,this$,init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
),cljs.core.merge,cljs.core.PersistentArrayMap.EMPTY,child_context));
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
),((cljs.core.empty_QMARK_.call(null,will_update))?null:((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (_,next_state){
var this$ = this;
var new_state = (next_state[":rum/state"]);
return cljs.core._vreset_BANG_.call(null,new_state,rum.util.call_all.call(null,cljs.core._deref.call(null,new_state),will_update));
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
),((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (){
var this$ = this;
var props = this$.props;
var state = rum.util.call_all.call(null,cljs.core.assoc.call(null,(props[":rum/initial-state"]),new cljs.core.Keyword("rum","react-component","rum/react-component",-1879897248),this$),init,props);
return ({":rum/state": cljs.core.volatile_BANG_.call(null,state)});
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
,((cljs.core.empty_QMARK_.call(null,did_mount))?null:((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (){
var this$ = this;
return cljs.core._vreset_BANG_.call(null,rum.core.state.call(null,this$),rum.util.call_all.call(null,cljs.core._deref.call(null,rum.core.state.call(null,this$)),did_mount));
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
),((cljs.core.empty_QMARK_.call(null,will_mount))?null:((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (){
var this$ = this;
return cljs.core._vreset_BANG_.call(null,rum.core.state.call(null,this$),rum.util.call_all.call(null,cljs.core._deref.call(null,rum.core.state.call(null,this$)),will_mount));
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
)]),class_props))));
});
rum.core.build_ctor = (function rum$core$build_ctor(render,mixins,display_name){
var class$ = rum.core.build_class.call(null,render,mixins,display_name);
var key_fn = cljs.core.first.call(null,rum.util.collect.call(null,new cljs.core.Keyword(null,"key-fn","key-fn",-636154479),mixins));
var ctor = ((!((key_fn == null)))?((function (class$,key_fn){
return (function() { 
var G__37948__delegate = function (args){
var props = ({":rum/initial-state": new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword("rum","args","rum/args",1315791754),args], null), "key": cljs.core.apply.call(null,key_fn,args)});
return React.createElement(class$,props);
};
var G__37948 = function (var_args){
var args = null;
if (arguments.length > 0) {
var G__37949__i = 0, G__37949__a = new Array(arguments.length -  0);
while (G__37949__i < G__37949__a.length) {G__37949__a[G__37949__i] = arguments[G__37949__i + 0]; ++G__37949__i;}
  args = new cljs.core.IndexedSeq(G__37949__a,0,null);
} 
return G__37948__delegate.call(this,args);};
G__37948.cljs$lang$maxFixedArity = 0;
G__37948.cljs$lang$applyTo = (function (arglist__37950){
var args = cljs.core.seq(arglist__37950);
return G__37948__delegate(args);
});
G__37948.cljs$core$IFn$_invoke$arity$variadic = G__37948__delegate;
return G__37948;
})()
;})(class$,key_fn))
:((function (class$,key_fn){
return (function() { 
var G__37951__delegate = function (args){
var props = ({":rum/initial-state": new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword("rum","args","rum/args",1315791754),args], null)});
return React.createElement(class$,props);
};
var G__37951 = function (var_args){
var args = null;
if (arguments.length > 0) {
var G__37952__i = 0, G__37952__a = new Array(arguments.length -  0);
while (G__37952__i < G__37952__a.length) {G__37952__a[G__37952__i] = arguments[G__37952__i + 0]; ++G__37952__i;}
  args = new cljs.core.IndexedSeq(G__37952__a,0,null);
} 
return G__37951__delegate.call(this,args);};
G__37951.cljs$lang$maxFixedArity = 0;
G__37951.cljs$lang$applyTo = (function (arglist__37953){
var args = cljs.core.seq(arglist__37953);
return G__37951__delegate(args);
});
G__37951.cljs$core$IFn$_invoke$arity$variadic = G__37951__delegate;
return G__37951;
})()
;})(class$,key_fn))
);
return cljs.core.with_meta.call(null,ctor,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword("rum","class","rum/class",-2030775258),class$], null));
});
rum.core.build_defc = (function rum$core$build_defc(render_body,mixins,display_name){
if(cljs.core.empty_QMARK_.call(null,mixins)){
var class$ = (function (props){
return cljs.core.apply.call(null,render_body,(props[":rum/args"]));
});
var _ = (class$["displayName"] = display_name);
var ctor = ((function (class$,_){
return (function() { 
var G__37954__delegate = function (args){
return React.createElement(class$,({":rum/args": args}));
};
var G__37954 = function (var_args){
var args = null;
if (arguments.length > 0) {
var G__37955__i = 0, G__37955__a = new Array(arguments.length -  0);
while (G__37955__i < G__37955__a.length) {G__37955__a[G__37955__i] = arguments[G__37955__i + 0]; ++G__37955__i;}
  args = new cljs.core.IndexedSeq(G__37955__a,0,null);
} 
return G__37954__delegate.call(this,args);};
G__37954.cljs$lang$maxFixedArity = 0;
G__37954.cljs$lang$applyTo = (function (arglist__37956){
var args = cljs.core.seq(arglist__37956);
return G__37954__delegate(args);
});
G__37954.cljs$core$IFn$_invoke$arity$variadic = G__37954__delegate;
return G__37954;
})()
;})(class$,_))
;
return cljs.core.with_meta.call(null,ctor,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword("rum","class","rum/class",-2030775258),class$], null));
} else {
var render = (function (state){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.apply.call(null,render_body,new cljs.core.Keyword("rum","args","rum/args",1315791754).cljs$core$IFn$_invoke$arity$1(state)),state], null);
});
return rum.core.build_ctor.call(null,render,mixins,display_name);
}
});
rum.core.build_defcs = (function rum$core$build_defcs(render_body,mixins,display_name){
var render = (function (state){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.apply.call(null,render_body,state,new cljs.core.Keyword("rum","args","rum/args",1315791754).cljs$core$IFn$_invoke$arity$1(state)),state], null);
});
return rum.core.build_ctor.call(null,render,mixins,display_name);
});
rum.core.build_defcc = (function rum$core$build_defcc(render_body,mixins,display_name){
var render = (function (state){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.apply.call(null,render_body,new cljs.core.Keyword("rum","react-component","rum/react-component",-1879897248).cljs$core$IFn$_invoke$arity$1(state),new cljs.core.Keyword("rum","args","rum/args",1315791754).cljs$core$IFn$_invoke$arity$1(state)),state], null);
});
return rum.core.build_ctor.call(null,render,mixins,display_name);
});
rum.core.schedule = (function (){var or__23338__auto__ = (function (){var and__23326__auto__ = typeof window !== 'undefined';
if(and__23326__auto__){
var or__23338__auto__ = window.requestAnimationFrame;
if(cljs.core.truth_(or__23338__auto__)){
return or__23338__auto__;
} else {
var or__23338__auto____$1 = window.webkitRequestAnimationFrame;
if(cljs.core.truth_(or__23338__auto____$1)){
return or__23338__auto____$1;
} else {
var or__23338__auto____$2 = window.mozRequestAnimationFrame;
if(cljs.core.truth_(or__23338__auto____$2)){
return or__23338__auto____$2;
} else {
return window.msRequestAnimationFrame;
}
}
}
} else {
return and__23326__auto__;
}
})();
if(cljs.core.truth_(or__23338__auto__)){
return or__23338__auto__;
} else {
return ((function (or__23338__auto__){
return (function (p1__37957_SHARP_){
return setTimeout(p1__37957_SHARP_,(16));
});
;})(or__23338__auto__))
}
})();
rum.core.batch = (function (){var or__23338__auto__ = ((typeof ReactNative !== 'undefined')?ReactNative.unstable_batchedUpdates:null);
if(cljs.core.truth_(or__23338__auto__)){
return or__23338__auto__;
} else {
var or__23338__auto____$1 = ((typeof ReactDOM !== 'undefined')?ReactDOM.unstable_batchedUpdates:null);
if(cljs.core.truth_(or__23338__auto____$1)){
return or__23338__auto____$1;
} else {
return ((function (or__23338__auto____$1,or__23338__auto__){
return (function (f,a){
return f.call(null,a);
});
;})(or__23338__auto____$1,or__23338__auto__))
}
}
})();
rum.core.empty_queue = cljs.core.PersistentVector.EMPTY;
rum.core.render_queue = cljs.core.volatile_BANG_.call(null,rum.core.empty_queue);
rum.core.render_all = (function rum$core$render_all(queue){
var seq__37964 = cljs.core.seq.call(null,queue);
var chunk__37966 = null;
var count__37967 = (0);
var i__37968 = (0);
while(true){
if((i__37968 < count__37967)){
var comp = cljs.core._nth.call(null,chunk__37966,i__37968);
if(cljs.core.truth_(comp.isMounted())){
comp.forceUpdate();

var G__37970 = seq__37964;
var G__37971 = chunk__37966;
var G__37972 = count__37967;
var G__37973 = (i__37968 + (1));
seq__37964 = G__37970;
chunk__37966 = G__37971;
count__37967 = G__37972;
i__37968 = G__37973;
continue;
} else {
var G__37974 = seq__37964;
var G__37975 = chunk__37966;
var G__37976 = count__37967;
var G__37977 = (i__37968 + (1));
seq__37964 = G__37974;
chunk__37966 = G__37975;
count__37967 = G__37976;
i__37968 = G__37977;
continue;
}
} else {
var temp__5278__auto__ = cljs.core.seq.call(null,seq__37964);
if(temp__5278__auto__){
var seq__37964__$1 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__37964__$1)){
var c__24249__auto__ = cljs.core.chunk_first.call(null,seq__37964__$1);
var G__37978 = cljs.core.chunk_rest.call(null,seq__37964__$1);
var G__37979 = c__24249__auto__;
var G__37980 = cljs.core.count.call(null,c__24249__auto__);
var G__37981 = (0);
seq__37964 = G__37978;
chunk__37966 = G__37979;
count__37967 = G__37980;
i__37968 = G__37981;
continue;
} else {
var comp = cljs.core.first.call(null,seq__37964__$1);
if(cljs.core.truth_(comp.isMounted())){
comp.forceUpdate();

var G__37982 = cljs.core.next.call(null,seq__37964__$1);
var G__37983 = null;
var G__37984 = (0);
var G__37985 = (0);
seq__37964 = G__37982;
chunk__37966 = G__37983;
count__37967 = G__37984;
i__37968 = G__37985;
continue;
} else {
var G__37986 = cljs.core.next.call(null,seq__37964__$1);
var G__37987 = null;
var G__37988 = (0);
var G__37989 = (0);
seq__37964 = G__37986;
chunk__37966 = G__37987;
count__37967 = G__37988;
i__37968 = G__37989;
continue;
}
}
} else {
return null;
}
}
break;
}
});
rum.core.render = (function rum$core$render(){
var queue = cljs.core.deref.call(null,rum.core.render_queue);
cljs.core.vreset_BANG_.call(null,rum.core.render_queue,rum.core.empty_queue);

return rum.core.batch.call(null,rum.core.render_all,queue);
});
/**
 * Schedules react component to be rendered on next animation frame
 */
rum.core.request_render = (function rum$core$request_render(component){
if(cljs.core.empty_QMARK_.call(null,cljs.core.deref.call(null,rum.core.render_queue))){
rum.core.schedule.call(null,rum.core.render);
} else {
}

return cljs.core._vreset_BANG_.call(null,rum.core.render_queue,cljs.core.conj.call(null,cljs.core._deref.call(null,rum.core.render_queue),component));
});
/**
 * Add component to the DOM tree. Idempotent. Subsequent mounts will just update component
 */
rum.core.mount = (function rum$core$mount(component,node){
ReactDOM.render(component,node);

return null;
});
/**
 * Removes component from the DOM tree
 */
rum.core.unmount = (function rum$core$unmount(node){
return ReactDOM.unmountComponentAtNode(node);
});
/**
 * Adds React key to component
 */
rum.core.with_key = (function rum$core$with_key(component,key){
return React.cloneElement(component,({"key": key}),null);
});
/**
 * Adds React ref (string or callback) to component
 */
rum.core.with_ref = (function rum$core$with_ref(component,ref){
return React.cloneElement(component,({"ref": ref}),null);
});
/**
 * Given state, returns top-level DOM node. Can’t be called during render
 */
rum.core.dom_node = (function rum$core$dom_node(state){
return ReactDOM.findDOMNode(new cljs.core.Keyword("rum","react-component","rum/react-component",-1879897248).cljs$core$IFn$_invoke$arity$1(state));
});
/**
 * Given state and ref handle, returns React component
 */
rum.core.ref = (function rum$core$ref(state,key){
return ((new cljs.core.Keyword("rum","react-component","rum/react-component",-1879897248).cljs$core$IFn$_invoke$arity$1(state)["refs"])[cljs.core.name.call(null,key)]);
});
/**
 * Given state and ref handle, returns DOM node associated with ref
 */
rum.core.ref_node = (function rum$core$ref_node(state,key){
return ReactDOM.findDOMNode(rum.core.ref.call(null,state,cljs.core.name.call(null,key)));
});
/**
 * Mixin. Will avoid re-render if none of component’s arguments have changed.
 * Does equality check (=) on all arguments
 */
rum.core.static$ = new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"should-update","should-update",-1292781795),(function (old_state,new_state){
return cljs.core.not_EQ_.call(null,new cljs.core.Keyword("rum","args","rum/args",1315791754).cljs$core$IFn$_invoke$arity$1(old_state),new cljs.core.Keyword("rum","args","rum/args",1315791754).cljs$core$IFn$_invoke$arity$1(new_state));
})], null);
/**
 * Mixin constructor. Adds an atom to component’s state that can be used to keep stuff
 * during component’s lifecycle. Component will be re-rendered if atom’s value changes.
 * Atom is stored under user-provided key or under `:rum/local` by default
 */
rum.core.local = (function rum$core$local(var_args){
var args37990 = [];
var len__24559__auto___37993 = arguments.length;
var i__24560__auto___37994 = (0);
while(true){
if((i__24560__auto___37994 < len__24559__auto___37993)){
args37990.push((arguments[i__24560__auto___37994]));

var G__37995 = (i__24560__auto___37994 + (1));
i__24560__auto___37994 = G__37995;
continue;
} else {
}
break;
}

var G__37992 = args37990.length;
switch (G__37992) {
case 1:
return rum.core.local.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));

break;
case 2:
return rum.core.local.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));

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

}
});

rum.core.local.cljs$core$IFn$_invoke$arity$1 = (function (initial){
return rum.core.local.call(null,initial,new cljs.core.Keyword("rum","local","rum/local",-1497916586));
});

rum.core.local.cljs$core$IFn$_invoke$arity$2 = (function (initial,key){
return new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"will-mount","will-mount",-434633071),(function (state){
var local_state = cljs.core.atom.call(null,initial);
var component = new cljs.core.Keyword("rum","react-component","rum/react-component",-1879897248).cljs$core$IFn$_invoke$arity$1(state);
cljs.core.add_watch.call(null,local_state,key,((function (local_state,component){
return (function (_,___$1,___$2,___$3){
return rum.core.request_render.call(null,component);
});})(local_state,component))
);

return cljs.core.assoc.call(null,state,key,local_state);
})], null);
});

rum.core.local.cljs$lang$maxFixedArity = 2;

/**
 * Mixin. Works in conjunction with `rum.core/react`
 */
rum.core.reactive = new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"init","init",-1875481434),(function (state,props){
return cljs.core.assoc.call(null,state,new cljs.core.Keyword("rum.reactive","key","rum.reactive/key",-803425142),cljs.core.random_uuid.call(null));
}),new cljs.core.Keyword(null,"wrap-render","wrap-render",1782000986),(function (render_fn){
return (function (state){
var _STAR_reactions_STAR_37997 = rum.core._STAR_reactions_STAR_;
rum.core._STAR_reactions_STAR_ = cljs.core.volatile_BANG_.call(null,cljs.core.PersistentHashSet.EMPTY);

try{var comp = new cljs.core.Keyword("rum","react-component","rum/react-component",-1879897248).cljs$core$IFn$_invoke$arity$1(state);
var old_reactions = new cljs.core.Keyword("rum.reactive","refs","rum.reactive/refs",-814076325).cljs$core$IFn$_invoke$arity$2(state,cljs.core.PersistentHashSet.EMPTY);
var vec__37998 = render_fn.call(null,state);
var dom = cljs.core.nth.call(null,vec__37998,(0),null);
var next_state = cljs.core.nth.call(null,vec__37998,(1),null);
var new_reactions = cljs.core.deref.call(null,rum.core._STAR_reactions_STAR_);
var key = new cljs.core.Keyword("rum.reactive","key","rum.reactive/key",-803425142).cljs$core$IFn$_invoke$arity$1(state);
var seq__38001_38013 = cljs.core.seq.call(null,old_reactions);
var chunk__38002_38014 = null;
var count__38003_38015 = (0);
var i__38004_38016 = (0);
while(true){
if((i__38004_38016 < count__38003_38015)){
var ref_38017 = cljs.core._nth.call(null,chunk__38002_38014,i__38004_38016);
if(cljs.core.contains_QMARK_.call(null,new_reactions,ref_38017)){
} else {
cljs.core.remove_watch.call(null,ref_38017,key);
}

var G__38018 = seq__38001_38013;
var G__38019 = chunk__38002_38014;
var G__38020 = count__38003_38015;
var G__38021 = (i__38004_38016 + (1));
seq__38001_38013 = G__38018;
chunk__38002_38014 = G__38019;
count__38003_38015 = G__38020;
i__38004_38016 = G__38021;
continue;
} else {
var temp__5278__auto___38022 = cljs.core.seq.call(null,seq__38001_38013);
if(temp__5278__auto___38022){
var seq__38001_38023__$1 = temp__5278__auto___38022;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__38001_38023__$1)){
var c__24249__auto___38024 = cljs.core.chunk_first.call(null,seq__38001_38023__$1);
var G__38025 = cljs.core.chunk_rest.call(null,seq__38001_38023__$1);
var G__38026 = c__24249__auto___38024;
var G__38027 = cljs.core.count.call(null,c__24249__auto___38024);
var G__38028 = (0);
seq__38001_38013 = G__38025;
chunk__38002_38014 = G__38026;
count__38003_38015 = G__38027;
i__38004_38016 = G__38028;
continue;
} else {
var ref_38029 = cljs.core.first.call(null,seq__38001_38023__$1);
if(cljs.core.contains_QMARK_.call(null,new_reactions,ref_38029)){
} else {
cljs.core.remove_watch.call(null,ref_38029,key);
}

var G__38030 = cljs.core.next.call(null,seq__38001_38023__$1);
var G__38031 = null;
var G__38032 = (0);
var G__38033 = (0);
seq__38001_38013 = G__38030;
chunk__38002_38014 = G__38031;
count__38003_38015 = G__38032;
i__38004_38016 = G__38033;
continue;
}
} else {
}
}
break;
}

var seq__38005_38034 = cljs.core.seq.call(null,new_reactions);
var chunk__38006_38035 = null;
var count__38007_38036 = (0);
var i__38008_38037 = (0);
while(true){
if((i__38008_38037 < count__38007_38036)){
var ref_38038 = cljs.core._nth.call(null,chunk__38006_38035,i__38008_38037);
if(cljs.core.contains_QMARK_.call(null,old_reactions,ref_38038)){
} else {
cljs.core.add_watch.call(null,ref_38038,key,((function (seq__38005_38034,chunk__38006_38035,count__38007_38036,i__38008_38037,ref_38038,comp,old_reactions,vec__37998,dom,next_state,new_reactions,key,_STAR_reactions_STAR_37997){
return (function (_,___$1,___$2,___$3){
return rum.core.request_render.call(null,comp);
});})(seq__38005_38034,chunk__38006_38035,count__38007_38036,i__38008_38037,ref_38038,comp,old_reactions,vec__37998,dom,next_state,new_reactions,key,_STAR_reactions_STAR_37997))
);
}

var G__38039 = seq__38005_38034;
var G__38040 = chunk__38006_38035;
var G__38041 = count__38007_38036;
var G__38042 = (i__38008_38037 + (1));
seq__38005_38034 = G__38039;
chunk__38006_38035 = G__38040;
count__38007_38036 = G__38041;
i__38008_38037 = G__38042;
continue;
} else {
var temp__5278__auto___38043 = cljs.core.seq.call(null,seq__38005_38034);
if(temp__5278__auto___38043){
var seq__38005_38044__$1 = temp__5278__auto___38043;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__38005_38044__$1)){
var c__24249__auto___38045 = cljs.core.chunk_first.call(null,seq__38005_38044__$1);
var G__38046 = cljs.core.chunk_rest.call(null,seq__38005_38044__$1);
var G__38047 = c__24249__auto___38045;
var G__38048 = cljs.core.count.call(null,c__24249__auto___38045);
var G__38049 = (0);
seq__38005_38034 = G__38046;
chunk__38006_38035 = G__38047;
count__38007_38036 = G__38048;
i__38008_38037 = G__38049;
continue;
} else {
var ref_38050 = cljs.core.first.call(null,seq__38005_38044__$1);
if(cljs.core.contains_QMARK_.call(null,old_reactions,ref_38050)){
} else {
cljs.core.add_watch.call(null,ref_38050,key,((function (seq__38005_38034,chunk__38006_38035,count__38007_38036,i__38008_38037,ref_38050,seq__38005_38044__$1,temp__5278__auto___38043,comp,old_reactions,vec__37998,dom,next_state,new_reactions,key,_STAR_reactions_STAR_37997){
return (function (_,___$1,___$2,___$3){
return rum.core.request_render.call(null,comp);
});})(seq__38005_38034,chunk__38006_38035,count__38007_38036,i__38008_38037,ref_38050,seq__38005_38044__$1,temp__5278__auto___38043,comp,old_reactions,vec__37998,dom,next_state,new_reactions,key,_STAR_reactions_STAR_37997))
);
}

var G__38051 = cljs.core.next.call(null,seq__38005_38044__$1);
var G__38052 = null;
var G__38053 = (0);
var G__38054 = (0);
seq__38005_38034 = G__38051;
chunk__38006_38035 = G__38052;
count__38007_38036 = G__38053;
i__38008_38037 = G__38054;
continue;
}
} else {
}
}
break;
}

return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [dom,cljs.core.assoc.call(null,next_state,new cljs.core.Keyword("rum.reactive","refs","rum.reactive/refs",-814076325),new_reactions)], null);
}finally {rum.core._STAR_reactions_STAR_ = _STAR_reactions_STAR_37997;
}});
}),new cljs.core.Keyword(null,"will-unmount","will-unmount",-808051550),(function (state){
var key_38055 = new cljs.core.Keyword("rum.reactive","key","rum.reactive/key",-803425142).cljs$core$IFn$_invoke$arity$1(state);
var seq__38009_38056 = cljs.core.seq.call(null,new cljs.core.Keyword("rum.reactive","refs","rum.reactive/refs",-814076325).cljs$core$IFn$_invoke$arity$1(state));
var chunk__38010_38057 = null;
var count__38011_38058 = (0);
var i__38012_38059 = (0);
while(true){
if((i__38012_38059 < count__38011_38058)){
var ref_38060 = cljs.core._nth.call(null,chunk__38010_38057,i__38012_38059);
cljs.core.remove_watch.call(null,ref_38060,key_38055);

var G__38061 = seq__38009_38056;
var G__38062 = chunk__38010_38057;
var G__38063 = count__38011_38058;
var G__38064 = (i__38012_38059 + (1));
seq__38009_38056 = G__38061;
chunk__38010_38057 = G__38062;
count__38011_38058 = G__38063;
i__38012_38059 = G__38064;
continue;
} else {
var temp__5278__auto___38065 = cljs.core.seq.call(null,seq__38009_38056);
if(temp__5278__auto___38065){
var seq__38009_38066__$1 = temp__5278__auto___38065;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__38009_38066__$1)){
var c__24249__auto___38067 = cljs.core.chunk_first.call(null,seq__38009_38066__$1);
var G__38068 = cljs.core.chunk_rest.call(null,seq__38009_38066__$1);
var G__38069 = c__24249__auto___38067;
var G__38070 = cljs.core.count.call(null,c__24249__auto___38067);
var G__38071 = (0);
seq__38009_38056 = G__38068;
chunk__38010_38057 = G__38069;
count__38011_38058 = G__38070;
i__38012_38059 = G__38071;
continue;
} else {
var ref_38072 = cljs.core.first.call(null,seq__38009_38066__$1);
cljs.core.remove_watch.call(null,ref_38072,key_38055);

var G__38073 = cljs.core.next.call(null,seq__38009_38066__$1);
var G__38074 = null;
var G__38075 = (0);
var G__38076 = (0);
seq__38009_38056 = G__38073;
chunk__38010_38057 = G__38074;
count__38011_38058 = G__38075;
i__38012_38059 = G__38076;
continue;
}
} else {
}
}
break;
}

return cljs.core.dissoc.call(null,state,new cljs.core.Keyword("rum.reactive","refs","rum.reactive/refs",-814076325),new cljs.core.Keyword("rum.reactive","key","rum.reactive/key",-803425142));
})], null);
/**
 * Works in conjunction with `rum.core/reactive` mixin. Use this function instead of
 * `deref` inside render, and your component will subscribe to changes happening
 * to the derefed atom.
 */
rum.core.react = (function rum$core$react(ref){
if(cljs.core.truth_(rum.core._STAR_reactions_STAR_)){
} else {
throw (new Error([cljs.core.str.cljs$core$IFn$_invoke$arity$1("Assert failed: "),cljs.core.str.cljs$core$IFn$_invoke$arity$1("rum.core/react is only supported in conjunction with rum.core/reactive"),cljs.core.str.cljs$core$IFn$_invoke$arity$1("\n"),cljs.core.str.cljs$core$IFn$_invoke$arity$1("*reactions*")].join('')));
}

cljs.core._vreset_BANG_.call(null,rum.core._STAR_reactions_STAR_,cljs.core.conj.call(null,cljs.core._deref.call(null,rum.core._STAR_reactions_STAR_),ref));

return cljs.core.deref.call(null,ref);
});
/**
 * Use this to create “chains” and acyclic graphs of dependent atoms.
 * `derived-atom` will:
 *  - Take N “source” refs
 *  - Set up a watch on each of them
 *  - Create “sink” atom
 *  - When any of source refs changes:
 *     - re-run function `f`, passing N dereferenced values of source refs
 *     - `reset!` result of `f` to the sink atom
 *  - return sink atom
 * 
 *  (def *a (atom 0))
 *  (def *b (atom 1))
 *  (def *x (derived-atom [*a *b] ::key
 *            (fn [a b]
 *              (str a ":" b))))
 *  (type *x) ;; => clojure.lang.Atom
 *  \@*x     ;; => 0:1
 *  (swap! *a inc)
 *  \@*x     ;; => 1:1
 *  (reset! *b 7)
 *  \@*x     ;; => 1:7
 * 
 * Arguments:
 *   refs - sequence of source refs
 *   key  - unique key to register watcher, see `clojure.core/add-watch`
 *   f    - function that must accept N arguments (same as number of source refs)
 *          and return a value to be written to the sink ref.
 *          Note: `f` will be called with already dereferenced values
 *   opts - optional. Map of:
 *     :ref           - Use this as sink ref. By default creates new atom
 *     :check-equals? - Do an equality check on each update: `(= @sink (f new-vals))`.
 *                      If result of `f` is equal to the old one, do not call `reset!`.
 *                      Defaults to `true`. Set to false if calling `=` would be expensive
 */
rum.core.derived_atom = rum.derived_atom.derived_atom;
/**
 * Given atom with deep nested value and path inside it, creates an atom-like structure
 * that can be used separately from main atom, but will sync changes both ways:
 *   
 *   (def db (atom { :users { "Ivan" { :age 30 }}}))
 *   (def ivan (rum/cursor db [:users "Ivan"]))
 *   \@ivan ;; => { :age 30 }
 *   (swap! ivan update :age inc) ;; => { :age 31 }
 *   \@db ;; => { :users { "Ivan" { :age 31 }}}
 *   (swap! db update-in [:users "Ivan" :age] inc) ;; => { :users { "Ivan" { :age 32 }}}
 *   \@ivan ;; => { :age 32 }
 *   
 *   Returned value supports deref, swap!, reset!, watches and metadata.
 *   The only supported option is `:meta`
 */
rum.core.cursor_in = (function rum$core$cursor_in(var_args){
var args__24566__auto__ = [];
var len__24559__auto___38083 = arguments.length;
var i__24560__auto___38084 = (0);
while(true){
if((i__24560__auto___38084 < len__24559__auto___38083)){
args__24566__auto__.push((arguments[i__24560__auto___38084]));

var G__38085 = (i__24560__auto___38084 + (1));
i__24560__auto___38084 = G__38085;
continue;
} else {
}
break;
}

var argseq__24567__auto__ = ((((2) < args__24566__auto__.length))?(new cljs.core.IndexedSeq(args__24566__auto__.slice((2)),(0),null)):null);
return rum.core.cursor_in.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__24567__auto__);
});

rum.core.cursor_in.cljs$core$IFn$_invoke$arity$variadic = (function (ref,path,p__38080){
var map__38081 = p__38080;
var map__38081__$1 = ((((!((map__38081 == null)))?((((map__38081.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__38081.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__38081):map__38081);
var options = map__38081__$1;
if((ref instanceof rum.cursor.Cursor)){
return (new rum.cursor.Cursor(ref.ref,cljs.core.into.call(null,ref.path,path),new cljs.core.Keyword(null,"meta","meta",1499536964).cljs$core$IFn$_invoke$arity$1(options)));
} else {
return (new rum.cursor.Cursor(ref,path,new cljs.core.Keyword(null,"meta","meta",1499536964).cljs$core$IFn$_invoke$arity$1(options)));
}
});

rum.core.cursor_in.cljs$lang$maxFixedArity = (2);

rum.core.cursor_in.cljs$lang$applyTo = (function (seq38077){
var G__38078 = cljs.core.first.call(null,seq38077);
var seq38077__$1 = cljs.core.next.call(null,seq38077);
var G__38079 = cljs.core.first.call(null,seq38077__$1);
var seq38077__$2 = cljs.core.next.call(null,seq38077__$1);
return rum.core.cursor_in.cljs$core$IFn$_invoke$arity$variadic(G__38078,G__38079,seq38077__$2);
});

/**
 * Same as `rum.core/cursor-in` but accepts single key instead of path vector
 */
rum.core.cursor = (function rum$core$cursor(var_args){
var args__24566__auto__ = [];
var len__24559__auto___38089 = arguments.length;
var i__24560__auto___38090 = (0);
while(true){
if((i__24560__auto___38090 < len__24559__auto___38089)){
args__24566__auto__.push((arguments[i__24560__auto___38090]));

var G__38091 = (i__24560__auto___38090 + (1));
i__24560__auto___38090 = G__38091;
continue;
} else {
}
break;
}

var argseq__24567__auto__ = ((((2) < args__24566__auto__.length))?(new cljs.core.IndexedSeq(args__24566__auto__.slice((2)),(0),null)):null);
return rum.core.cursor.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__24567__auto__);
});

rum.core.cursor.cljs$core$IFn$_invoke$arity$variadic = (function (ref,key,options){
return cljs.core.apply.call(null,rum.core.cursor_in,ref,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [key], null),options);
});

rum.core.cursor.cljs$lang$maxFixedArity = (2);

rum.core.cursor.cljs$lang$applyTo = (function (seq38086){
var G__38087 = cljs.core.first.call(null,seq38086);
var seq38086__$1 = cljs.core.next.call(null,seq38086);
var G__38088 = cljs.core.first.call(null,seq38086__$1);
var seq38086__$2 = cljs.core.next.call(null,seq38086__$1);
return rum.core.cursor.cljs$core$IFn$_invoke$arity$variadic(G__38087,G__38088,seq38086__$2);
});

