goog.provide('reagent.dom');
var module$react_dom=shadow.js.require("module$react_dom", {});
if((typeof reagent !== 'undefined') && (typeof reagent.dom !== 'undefined') && (typeof reagent.dom.roots !== 'undefined')){
} else {
reagent.dom.roots = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(cljs.core.PersistentArrayMap.EMPTY);
}
reagent.dom.unmount_comp = (function reagent$dom$unmount_comp(container){
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$3(reagent.dom.roots,cljs.core.dissoc,container);

return module$react_dom.unmountComponentAtNode(container);
});
reagent.dom.render_comp = (function reagent$dom$render_comp(comp,container,callback){
var _STAR_always_update_STAR__orig_val__52044 = reagent.impl.util._STAR_always_update_STAR_;
var _STAR_always_update_STAR__temp_val__52045 = true;
(reagent.impl.util._STAR_always_update_STAR_ = _STAR_always_update_STAR__temp_val__52045);

try{return module$react_dom.render((comp.cljs$core$IFn$_invoke$arity$0 ? comp.cljs$core$IFn$_invoke$arity$0() : comp.call(null)),container,(function (){
var _STAR_always_update_STAR__orig_val__52049 = reagent.impl.util._STAR_always_update_STAR_;
var _STAR_always_update_STAR__temp_val__52050 = false;
(reagent.impl.util._STAR_always_update_STAR_ = _STAR_always_update_STAR__temp_val__52050);

try{cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$4(reagent.dom.roots,cljs.core.assoc,container,comp);

reagent.impl.batching.flush_after_render();

if((!((callback == null)))){
return (callback.cljs$core$IFn$_invoke$arity$0 ? callback.cljs$core$IFn$_invoke$arity$0() : callback.call(null));
} else {
return null;
}
}finally {(reagent.impl.util._STAR_always_update_STAR_ = _STAR_always_update_STAR__orig_val__52049);
}}));
}finally {(reagent.impl.util._STAR_always_update_STAR_ = _STAR_always_update_STAR__orig_val__52044);
}});
reagent.dom.re_render_component = (function reagent$dom$re_render_component(comp,container){
return reagent.dom.render_comp(comp,container,null);
});
/**
 * Render a Reagent component into the DOM. The first argument may be
 *   either a vector (using Reagent's Hiccup syntax), or a React element.
 *   The second argument should be a DOM node.
 * 
 *   Optionally takes a callback that is called when the component is in place.
 * 
 *   Returns the mounted component instance.
 */
reagent.dom.render = (function reagent$dom$render(var_args){
var G__52055 = arguments.length;
switch (G__52055) {
case 2:
return reagent.dom.render.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));

break;
case 3:
return reagent.dom.render.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));

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

}
});

(reagent.dom.render.cljs$core$IFn$_invoke$arity$2 = (function (comp,container){
return reagent.dom.render.cljs$core$IFn$_invoke$arity$3(comp,container,reagent.impl.template.default_compiler);
}));

(reagent.dom.render.cljs$core$IFn$_invoke$arity$3 = (function (comp,container,callback_or_compiler){
reagent.ratom.flush_BANG_();

var vec__52059 = ((cljs.core.fn_QMARK_(callback_or_compiler))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [reagent.impl.template.default_compiler,callback_or_compiler], null):new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [callback_or_compiler,new cljs.core.Keyword(null,"callback","callback",-705136228).cljs$core$IFn$_invoke$arity$1(callback_or_compiler)], null));
var compiler = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__52059,(0),null);
var callback = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__52059,(1),null);
var f = (function (){
return reagent.impl.protocols.as_element(compiler,((cljs.core.fn_QMARK_(comp))?(comp.cljs$core$IFn$_invoke$arity$0 ? comp.cljs$core$IFn$_invoke$arity$0() : comp.call(null)):comp));
});
return reagent.dom.render_comp(f,container,callback);
}));

(reagent.dom.render.cljs$lang$maxFixedArity = 3);

/**
 * Remove a component from the given DOM node.
 */
reagent.dom.unmount_component_at_node = (function reagent$dom$unmount_component_at_node(container){
return reagent.dom.unmount_comp(container);
});
/**
 * Returns the root DOM node of a mounted component.
 */
reagent.dom.dom_node = (function reagent$dom$dom_node(this$){
return module$react_dom.findDOMNode(this$);
});
/**
 * Force re-rendering of all mounted Reagent components. This is
 *   probably only useful in a development environment, when you want to
 *   update components in response to some dynamic changes to code.
 * 
 *   Note that force-update-all may not update root components. This
 *   happens if a component 'foo' is mounted with `(render [foo])` (since
 *   functions are passed by value, and not by reference, in
 *   ClojureScript). To get around this you'll have to introduce a layer
 *   of indirection, for example by using `(render [#'foo])` instead.
 */
reagent.dom.force_update_all = (function reagent$dom$force_update_all(){
reagent.ratom.flush_BANG_();

var seq__52068_52095 = cljs.core.seq(cljs.core.deref(reagent.dom.roots));
var chunk__52069_52096 = null;
var count__52070_52097 = (0);
var i__52071_52098 = (0);
while(true){
if((i__52071_52098 < count__52070_52097)){
var vec__52083_52100 = chunk__52069_52096.cljs$core$IIndexed$_nth$arity$2(null,i__52071_52098);
var container_52101 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__52083_52100,(0),null);
var comp_52102 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__52083_52100,(1),null);
reagent.dom.re_render_component(comp_52102,container_52101);


var G__52104 = seq__52068_52095;
var G__52105 = chunk__52069_52096;
var G__52106 = count__52070_52097;
var G__52107 = (i__52071_52098 + (1));
seq__52068_52095 = G__52104;
chunk__52069_52096 = G__52105;
count__52070_52097 = G__52106;
i__52071_52098 = G__52107;
continue;
} else {
var temp__5804__auto___52108 = cljs.core.seq(seq__52068_52095);
if(temp__5804__auto___52108){
var seq__52068_52110__$1 = temp__5804__auto___52108;
if(cljs.core.chunked_seq_QMARK_(seq__52068_52110__$1)){
var c__5548__auto___52112 = cljs.core.chunk_first(seq__52068_52110__$1);
var G__52113 = cljs.core.chunk_rest(seq__52068_52110__$1);
var G__52114 = c__5548__auto___52112;
var G__52115 = cljs.core.count(c__5548__auto___52112);
var G__52116 = (0);
seq__52068_52095 = G__52113;
chunk__52069_52096 = G__52114;
count__52070_52097 = G__52115;
i__52071_52098 = G__52116;
continue;
} else {
var vec__52086_52117 = cljs.core.first(seq__52068_52110__$1);
var container_52118 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__52086_52117,(0),null);
var comp_52119 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__52086_52117,(1),null);
reagent.dom.re_render_component(comp_52119,container_52118);


var G__52120 = cljs.core.next(seq__52068_52110__$1);
var G__52121 = null;
var G__52122 = (0);
var G__52123 = (0);
seq__52068_52095 = G__52120;
chunk__52069_52096 = G__52121;
count__52070_52097 = G__52122;
i__52071_52098 = G__52123;
continue;
}
} else {
}
}
break;
}

return reagent.impl.batching.flush_after_render();
});

//# sourceMappingURL=reagent.dom.js.map
