// Compiled by ClojureScript 0.0-2138
goog.provide('crate.compiler');
goog.require('cljs.core');
goog.require('crate.binding');
goog.require('crate.binding');
goog.require('clojure.string');
goog.require('clojure.string');
goog.require('goog.style');
goog.require('goog.style');
goog.require('goog.dom');
goog.require('goog.dom');
crate.compiler.xmlns = new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"xhtml","xhtml",1127939989),"http://www.w3.org/1999/xhtml",new cljs.core.Keyword(null,"svg","svg",1014018518),"http://www.w3.org/2000/svg"], null);
crate.compiler.group_id = cljs.core.atom.call(null,0);
crate.compiler.bindings = cljs.core.atom.call(null,cljs.core.PersistentVector.EMPTY);
crate.compiler.capture_binding = (function capture_binding(tag,b){return cljs.core.swap_BANG_.call(null,crate.compiler.bindings,cljs.core.conj,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [tag,b], null));
});
crate.compiler.Element = (function (){var obj16094 = {};return obj16094;
})();
crate.compiler._elem = (function _elem(this$){if((function (){var and__3508__auto__ = this$;if(and__3508__auto__)
{return this$.crate$compiler$Element$_elem$arity$1;
} else
{return and__3508__auto__;
}
})())
{return this$.crate$compiler$Element$_elem$arity$1(this$);
} else
{var x__4141__auto__ = (((this$ == null))?null:this$);return (function (){var or__3520__auto__ = (crate.compiler._elem[goog.typeOf(x__4141__auto__)]);if(or__3520__auto__)
{return or__3520__auto__;
} else
{var or__3520__auto____$1 = (crate.compiler._elem["_"]);if(or__3520__auto____$1)
{return or__3520__auto____$1;
} else
{throw cljs.core.missing_protocol.call(null,"Element.-elem",this$);
}
}
})().call(null,this$);
}
});
crate.compiler.as_content = (function as_content(parent,content){var seq__16101 = cljs.core.seq.call(null,content);var chunk__16102 = null;var count__16103 = 0;var i__16104 = 0;while(true){
if((i__16104 < count__16103))
{var c = cljs.core._nth.call(null,chunk__16102,i__16104);var child_16107 = (((function (){var G__16105 = c;if(G__16105)
{var bit__4164__auto__ = null;if(cljs.core.truth_((function (){var or__3520__auto__ = bit__4164__auto__;if(cljs.core.truth_(or__3520__auto__))
{return or__3520__auto__;
} else
{return G__16105.crate$compiler$Element$;
}
})()))
{return true;
} else
{if((!G__16105.cljs$lang$protocol_mask$partition$))
{return cljs.core.native_satisfies_QMARK_.call(null,crate.compiler.Element,G__16105);
} else
{return false;
}
}
} else
{return cljs.core.native_satisfies_QMARK_.call(null,crate.compiler.Element,G__16105);
}
})())?crate.compiler._elem.call(null,c):(((c == null))?null:((cljs.core.map_QMARK_.call(null,c))?(function(){throw "Maps cannot be used as content"})():((typeof c === 'string')?goog.dom.createTextNode(c):((cljs.core.vector_QMARK_.call(null,c))?crate.compiler.elem_factory.call(null,c):((cljs.core.seq_QMARK_.call(null,c))?as_content.call(null,parent,c):((crate.binding.binding_coll_QMARK_.call(null,c))?(function (){crate.compiler.capture_binding.call(null,new cljs.core.Keyword(null,"coll","coll",1016963678),c);
return as_content.call(null,parent,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [crate.binding.value.call(null,c)], null));
})():((crate.binding.binding_QMARK_.call(null,c))?(function (){crate.compiler.capture_binding.call(null,new cljs.core.Keyword(null,"text","text",1017460895),c);
return as_content.call(null,parent,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [crate.binding.value.call(null,c)], null));
})():(cljs.core.truth_(c.nodeName)?c:(cljs.core.truth_(c.get)?c.get(0):((new cljs.core.Keyword(null,"else","else",1017020587))?goog.dom.createTextNode([cljs.core.str(c)].join('')):null)))))))))));if(cljs.core.truth_(child_16107))
{goog.dom.appendChild(parent,child_16107);
} else
{}
{
var G__16108 = seq__16101;
var G__16109 = chunk__16102;
var G__16110 = count__16103;
var G__16111 = (i__16104 + 1);
seq__16101 = G__16108;
chunk__16102 = G__16109;
count__16103 = G__16110;
i__16104 = G__16111;
continue;
}
} else
{var temp__4092__auto__ = cljs.core.seq.call(null,seq__16101);if(temp__4092__auto__)
{var seq__16101__$1 = temp__4092__auto__;if(cljs.core.chunked_seq_QMARK_.call(null,seq__16101__$1))
{var c__4262__auto__ = cljs.core.chunk_first.call(null,seq__16101__$1);{
var G__16112 = cljs.core.chunk_rest.call(null,seq__16101__$1);
var G__16113 = c__4262__auto__;
var G__16114 = cljs.core.count.call(null,c__4262__auto__);
var G__16115 = 0;
seq__16101 = G__16112;
chunk__16102 = G__16113;
count__16103 = G__16114;
i__16104 = G__16115;
continue;
}
} else
{var c = cljs.core.first.call(null,seq__16101__$1);var child_16116 = (((function (){var G__16106 = c;if(G__16106)
{var bit__4164__auto__ = null;if(cljs.core.truth_((function (){var or__3520__auto__ = bit__4164__auto__;if(cljs.core.truth_(or__3520__auto__))
{return or__3520__auto__;
} else
{return G__16106.crate$compiler$Element$;
}
})()))
{return true;
} else
{if((!G__16106.cljs$lang$protocol_mask$partition$))
{return cljs.core.native_satisfies_QMARK_.call(null,crate.compiler.Element,G__16106);
} else
{return false;
}
}
} else
{return cljs.core.native_satisfies_QMARK_.call(null,crate.compiler.Element,G__16106);
}
})())?crate.compiler._elem.call(null,c):(((c == null))?null:((cljs.core.map_QMARK_.call(null,c))?(function(){throw "Maps cannot be used as content"})():((typeof c === 'string')?goog.dom.createTextNode(c):((cljs.core.vector_QMARK_.call(null,c))?crate.compiler.elem_factory.call(null,c):((cljs.core.seq_QMARK_.call(null,c))?as_content.call(null,parent,c):((crate.binding.binding_coll_QMARK_.call(null,c))?(function (){crate.compiler.capture_binding.call(null,new cljs.core.Keyword(null,"coll","coll",1016963678),c);
return as_content.call(null,parent,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [crate.binding.value.call(null,c)], null));
})():((crate.binding.binding_QMARK_.call(null,c))?(function (){crate.compiler.capture_binding.call(null,new cljs.core.Keyword(null,"text","text",1017460895),c);
return as_content.call(null,parent,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [crate.binding.value.call(null,c)], null));
})():(cljs.core.truth_(c.nodeName)?c:(cljs.core.truth_(c.get)?c.get(0):((new cljs.core.Keyword(null,"else","else",1017020587))?goog.dom.createTextNode([cljs.core.str(c)].join('')):null)))))))))));if(cljs.core.truth_(child_16116))
{goog.dom.appendChild(parent,child_16116);
} else
{}
{
var G__16117 = cljs.core.next.call(null,seq__16101__$1);
var G__16118 = null;
var G__16119 = 0;
var G__16120 = 0;
seq__16101 = G__16117;
chunk__16102 = G__16118;
count__16103 = G__16119;
i__16104 = G__16120;
continue;
}
}
} else
{return null;
}
}
break;
}
});
crate.compiler.dom_binding = (function (){var method_table__4372__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);var prefer_table__4373__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);var method_cache__4374__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);var cached_hierarchy__4375__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);var hierarchy__4376__auto__ = cljs.core.get.call(null,cljs.core.PersistentArrayMap.EMPTY,new cljs.core.Keyword(null,"hierarchy","hierarchy",3129050535),cljs.core.get_global_hierarchy.call(null));return (new cljs.core.MultiFn("dom-binding",(function (type,_,___$1){return type;
}),new cljs.core.Keyword(null,"default","default",2558708147),hierarchy__4376__auto__,method_table__4372__auto__,prefer_table__4373__auto__,method_cache__4374__auto__,cached_hierarchy__4375__auto__));
})();
cljs.core._add_method.call(null,crate.compiler.dom_binding,new cljs.core.Keyword(null,"text","text",1017460895),(function (_,b,elem){return crate.binding.on_change.call(null,b,(function (v){goog.dom.removeChildren(elem);
return crate.compiler.as_content.call(null,elem,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [v], null));
}));
}));
cljs.core._add_method.call(null,crate.compiler.dom_binding,new cljs.core.Keyword(null,"attr","attr",1016909155),(function (_,p__16121,elem){var vec__16122 = p__16121;var k = cljs.core.nth.call(null,vec__16122,0,null);var b = cljs.core.nth.call(null,vec__16122,1,null);return crate.binding.on_change.call(null,b,(function (v){return crate.compiler.dom_attr.call(null,elem,k,v);
}));
}));
cljs.core._add_method.call(null,crate.compiler.dom_binding,new cljs.core.Keyword(null,"style","style",1123684643),(function (_,p__16123,elem){var vec__16124 = p__16123;var k = cljs.core.nth.call(null,vec__16124,0,null);var b = cljs.core.nth.call(null,vec__16124,1,null);return crate.binding.on_change.call(null,b,(function (v){if(cljs.core.truth_(k))
{return crate.compiler.dom_style.call(null,elem,k,v);
} else
{return crate.compiler.dom_style.call(null,elem,v);
}
}));
}));
crate.compiler.dom_add = (function dom_add(bc,parent,elem,v){var temp__4090__auto__ = crate.binding.opt.call(null,bc,new cljs.core.Keyword(null,"add","add",1014000659));if(cljs.core.truth_(temp__4090__auto__))
{var adder = temp__4090__auto__;return adder.call(null,parent,elem,v);
} else
{return goog.dom.appendChild(parent,elem);
}
});
crate.compiler.dom_remove = (function dom_remove(bc,elem){var temp__4090__auto__ = crate.binding.opt.call(null,bc,new cljs.core.Keyword(null,"remove","remove",4374260726));if(cljs.core.truth_(temp__4090__auto__))
{var remover = temp__4090__auto__;return remover.call(null,elem);
} else
{return goog.dom.removeNode(elem);
}
});
cljs.core._add_method.call(null,crate.compiler.dom_binding,new cljs.core.Keyword(null,"coll","coll",1016963678),(function (_,bc,parent){return crate.binding.on_change.call(null,bc,(function (type,elem,v){var pred__16125 = cljs.core._EQ_;var expr__16126 = type;if(cljs.core.truth_(pred__16125.call(null,new cljs.core.Keyword(null,"add","add",1014000659),expr__16126)))
{return crate.compiler.dom_add.call(null,bc,parent,elem,v);
} else
{if(cljs.core.truth_(pred__16125.call(null,new cljs.core.Keyword(null,"remove","remove",4374260726),expr__16126)))
{return crate.compiler.dom_remove.call(null,bc,elem);
} else
{throw (new Error([cljs.core.str("No matching clause: "),cljs.core.str(expr__16126)].join('')));
}
}
}));
}));
crate.compiler.handle_bindings = (function handle_bindings(bs,elem){var seq__16134 = cljs.core.seq.call(null,bs);var chunk__16135 = null;var count__16136 = 0;var i__16137 = 0;while(true){
if((i__16137 < count__16136))
{var vec__16138 = cljs.core._nth.call(null,chunk__16135,i__16137);var type = cljs.core.nth.call(null,vec__16138,0,null);var b = cljs.core.nth.call(null,vec__16138,1,null);crate.compiler.dom_binding.call(null,type,b,elem);
{
var G__16140 = seq__16134;
var G__16141 = chunk__16135;
var G__16142 = count__16136;
var G__16143 = (i__16137 + 1);
seq__16134 = G__16140;
chunk__16135 = G__16141;
count__16136 = G__16142;
i__16137 = G__16143;
continue;
}
} else
{var temp__4092__auto__ = cljs.core.seq.call(null,seq__16134);if(temp__4092__auto__)
{var seq__16134__$1 = temp__4092__auto__;if(cljs.core.chunked_seq_QMARK_.call(null,seq__16134__$1))
{var c__4262__auto__ = cljs.core.chunk_first.call(null,seq__16134__$1);{
var G__16144 = cljs.core.chunk_rest.call(null,seq__16134__$1);
var G__16145 = c__4262__auto__;
var G__16146 = cljs.core.count.call(null,c__4262__auto__);
var G__16147 = 0;
seq__16134 = G__16144;
chunk__16135 = G__16145;
count__16136 = G__16146;
i__16137 = G__16147;
continue;
}
} else
{var vec__16139 = cljs.core.first.call(null,seq__16134__$1);var type = cljs.core.nth.call(null,vec__16139,0,null);var b = cljs.core.nth.call(null,vec__16139,1,null);crate.compiler.dom_binding.call(null,type,b,elem);
{
var G__16148 = cljs.core.next.call(null,seq__16134__$1);
var G__16149 = null;
var G__16150 = 0;
var G__16151 = 0;
seq__16134 = G__16148;
chunk__16135 = G__16149;
count__16136 = G__16150;
i__16137 = G__16151;
continue;
}
}
} else
{return null;
}
}
break;
}
});
crate.compiler.dom_style = (function() {
var dom_style = null;
var dom_style__2 = (function (elem,v){if(typeof v === 'string')
{elem.setAttribute("style",v);
} else
{if(cljs.core.map_QMARK_.call(null,v))
{var seq__16158_16164 = cljs.core.seq.call(null,v);var chunk__16159_16165 = null;var count__16160_16166 = 0;var i__16161_16167 = 0;while(true){
if((i__16161_16167 < count__16160_16166))
{var vec__16162_16168 = cljs.core._nth.call(null,chunk__16159_16165,i__16161_16167);var k_16169 = cljs.core.nth.call(null,vec__16162_16168,0,null);var v_16170__$1 = cljs.core.nth.call(null,vec__16162_16168,1,null);dom_style.call(null,elem,k_16169,v_16170__$1);
{
var G__16171 = seq__16158_16164;
var G__16172 = chunk__16159_16165;
var G__16173 = count__16160_16166;
var G__16174 = (i__16161_16167 + 1);
seq__16158_16164 = G__16171;
chunk__16159_16165 = G__16172;
count__16160_16166 = G__16173;
i__16161_16167 = G__16174;
continue;
}
} else
{var temp__4092__auto___16175 = cljs.core.seq.call(null,seq__16158_16164);if(temp__4092__auto___16175)
{var seq__16158_16176__$1 = temp__4092__auto___16175;if(cljs.core.chunked_seq_QMARK_.call(null,seq__16158_16176__$1))
{var c__4262__auto___16177 = cljs.core.chunk_first.call(null,seq__16158_16176__$1);{
var G__16178 = cljs.core.chunk_rest.call(null,seq__16158_16176__$1);
var G__16179 = c__4262__auto___16177;
var G__16180 = cljs.core.count.call(null,c__4262__auto___16177);
var G__16181 = 0;
seq__16158_16164 = G__16178;
chunk__16159_16165 = G__16179;
count__16160_16166 = G__16180;
i__16161_16167 = G__16181;
continue;
}
} else
{var vec__16163_16182 = cljs.core.first.call(null,seq__16158_16176__$1);var k_16183 = cljs.core.nth.call(null,vec__16163_16182,0,null);var v_16184__$1 = cljs.core.nth.call(null,vec__16163_16182,1,null);dom_style.call(null,elem,k_16183,v_16184__$1);
{
var G__16185 = cljs.core.next.call(null,seq__16158_16176__$1);
var G__16186 = null;
var G__16187 = 0;
var G__16188 = 0;
seq__16158_16164 = G__16185;
chunk__16159_16165 = G__16186;
count__16160_16166 = G__16187;
i__16161_16167 = G__16188;
continue;
}
}
} else
{}
}
break;
}
} else
{if(crate.binding.binding_QMARK_.call(null,v))
{crate.compiler.capture_binding.call(null,new cljs.core.Keyword(null,"style","style",1123684643),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,v], null));
dom_style.call(null,elem,crate.binding.value.call(null,v));
} else
{}
}
}
return elem;
});
var dom_style__3 = (function (elem,k,v){var v__$1 = ((crate.binding.binding_QMARK_.call(null,v))?(function (){crate.compiler.capture_binding.call(null,new cljs.core.Keyword(null,"style","style",1123684643),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [k,v], null));
return crate.binding.value.call(null,v);
})():v);return goog.style.setStyle(elem,cljs.core.name.call(null,k),v__$1);
});
dom_style = function(elem,k,v){
switch(arguments.length){
case 2:
return dom_style__2.call(this,elem,k);
case 3:
return dom_style__3.call(this,elem,k,v);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
dom_style.cljs$core$IFn$_invoke$arity$2 = dom_style__2;
dom_style.cljs$core$IFn$_invoke$arity$3 = dom_style__3;
return dom_style;
})()
;
crate.compiler.dom_attr = (function() {
var dom_attr = null;
var dom_attr__2 = (function (elem,attrs){if(cljs.core.truth_(elem))
{if(!(cljs.core.map_QMARK_.call(null,attrs)))
{return elem.getAttribute(cljs.core.name.call(null,attrs));
} else
{var seq__16195_16201 = cljs.core.seq.call(null,attrs);var chunk__16196_16202 = null;var count__16197_16203 = 0;var i__16198_16204 = 0;while(true){
if((i__16198_16204 < count__16197_16203))
{var vec__16199_16205 = cljs.core._nth.call(null,chunk__16196_16202,i__16198_16204);var k_16206 = cljs.core.nth.call(null,vec__16199_16205,0,null);var v_16207 = cljs.core.nth.call(null,vec__16199_16205,1,null);dom_attr.call(null,elem,k_16206,v_16207);
{
var G__16208 = seq__16195_16201;
var G__16209 = chunk__16196_16202;
var G__16210 = count__16197_16203;
var G__16211 = (i__16198_16204 + 1);
seq__16195_16201 = G__16208;
chunk__16196_16202 = G__16209;
count__16197_16203 = G__16210;
i__16198_16204 = G__16211;
continue;
}
} else
{var temp__4092__auto___16212 = cljs.core.seq.call(null,seq__16195_16201);if(temp__4092__auto___16212)
{var seq__16195_16213__$1 = temp__4092__auto___16212;if(cljs.core.chunked_seq_QMARK_.call(null,seq__16195_16213__$1))
{var c__4262__auto___16214 = cljs.core.chunk_first.call(null,seq__16195_16213__$1);{
var G__16215 = cljs.core.chunk_rest.call(null,seq__16195_16213__$1);
var G__16216 = c__4262__auto___16214;
var G__16217 = cljs.core.count.call(null,c__4262__auto___16214);
var G__16218 = 0;
seq__16195_16201 = G__16215;
chunk__16196_16202 = G__16216;
count__16197_16203 = G__16217;
i__16198_16204 = G__16218;
continue;
}
} else
{var vec__16200_16219 = cljs.core.first.call(null,seq__16195_16213__$1);var k_16220 = cljs.core.nth.call(null,vec__16200_16219,0,null);var v_16221 = cljs.core.nth.call(null,vec__16200_16219,1,null);dom_attr.call(null,elem,k_16220,v_16221);
{
var G__16222 = cljs.core.next.call(null,seq__16195_16213__$1);
var G__16223 = null;
var G__16224 = 0;
var G__16225 = 0;
seq__16195_16201 = G__16222;
chunk__16196_16202 = G__16223;
count__16197_16203 = G__16224;
i__16198_16204 = G__16225;
continue;
}
}
} else
{}
}
break;
}
return elem;
}
} else
{return null;
}
});
var dom_attr__3 = (function (elem,k,v){if(cljs.core._EQ_.call(null,k,new cljs.core.Keyword(null,"style","style",1123684643)))
{crate.compiler.dom_style.call(null,elem,v);
} else
{var v_16226__$1 = ((crate.binding.binding_QMARK_.call(null,v))?(function (){crate.compiler.capture_binding.call(null,new cljs.core.Keyword(null,"attr","attr",1016909155),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [k,v], null));
return crate.binding.value.call(null,v);
})():v);elem.setAttribute(cljs.core.name.call(null,k),v_16226__$1);
}
return elem;
});
dom_attr = function(elem,k,v){
switch(arguments.length){
case 2:
return dom_attr__2.call(this,elem,k);
case 3:
return dom_attr__3.call(this,elem,k,v);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
dom_attr.cljs$core$IFn$_invoke$arity$2 = dom_attr__2;
dom_attr.cljs$core$IFn$_invoke$arity$3 = dom_attr__3;
return dom_attr;
})()
;
/**
* Regular expression that parses a CSS-style id and class from a tag name.
*/
crate.compiler.re_tag = /([^\s\.#]+)(?:#([^\s\.#]+))?(?:\.([^\s#]+))?/;
crate.compiler.normalize_map_attrs = (function normalize_map_attrs(map_attrs){return cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.map.call(null,(function (p__16229){var vec__16230 = p__16229;var n = cljs.core.nth.call(null,vec__16230,0,null);var v = cljs.core.nth.call(null,vec__16230,1,null);if(v === true)
{return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [n,cljs.core.name.call(null,n)], null);
} else
{return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [n,v], null);
}
}),cljs.core.filter.call(null,cljs.core.comp.call(null,cljs.core.boolean$,cljs.core.second),map_attrs)));
});
/**
* Ensure a tag vector is of the form [tag-name attrs content].
*/
crate.compiler.normalize_element = (function normalize_element(p__16232){var vec__16237 = p__16232;var tag = cljs.core.nth.call(null,vec__16237,0,null);var content = cljs.core.nthnext.call(null,vec__16237,1);if(!(((tag instanceof cljs.core.Keyword)) || ((tag instanceof cljs.core.Symbol)) || (typeof tag === 'string')))
{throw [cljs.core.str(tag),cljs.core.str(" is not a valid tag name.")].join('');
} else
{}
var vec__16238 = cljs.core.re_matches.call(null,crate.compiler.re_tag,cljs.core.name.call(null,tag));var _ = cljs.core.nth.call(null,vec__16238,0,null);var tag__$1 = cljs.core.nth.call(null,vec__16238,1,null);var id = cljs.core.nth.call(null,vec__16238,2,null);var class$ = cljs.core.nth.call(null,vec__16238,3,null);var vec__16239 = (function (){var vec__16240 = clojure.string.split.call(null,tag__$1,/:/);var nsp = cljs.core.nth.call(null,vec__16240,0,null);var t = cljs.core.nth.call(null,vec__16240,1,null);var ns_xmlns = crate.compiler.xmlns.call(null,cljs.core.keyword.call(null,nsp));if(cljs.core.truth_(t))
{return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(function (){var or__3520__auto__ = ns_xmlns;if(cljs.core.truth_(or__3520__auto__))
{return or__3520__auto__;
} else
{return nsp;
}
})(),t], null);
} else
{return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"xhtml","xhtml",1127939989).cljs$core$IFn$_invoke$arity$1(crate.compiler.xmlns),nsp], null);
}
})();var nsp = cljs.core.nth.call(null,vec__16239,0,null);var tag__$2 = cljs.core.nth.call(null,vec__16239,1,null);var tag_attrs = cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.filter.call(null,((function (vec__16238,_,tag__$1,id,class$,vec__16239,nsp,tag__$2){
return (function (p1__16231_SHARP_){return !((cljs.core.second.call(null,p1__16231_SHARP_) == null));
});})(vec__16238,_,tag__$1,id,class$,vec__16239,nsp,tag__$2))
,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"id","id",1013907597),(function (){var or__3520__auto__ = id;if(cljs.core.truth_(or__3520__auto__))
{return or__3520__auto__;
} else
{return null;
}
})(),new cljs.core.Keyword(null,"class","class",1108647146),(cljs.core.truth_(class$)?clojure.string.replace.call(null,class$,/\./," "):null)], null)));var map_attrs = cljs.core.first.call(null,content);if(cljs.core.map_QMARK_.call(null,map_attrs))
{return new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [nsp,tag__$2,cljs.core.merge.call(null,tag_attrs,crate.compiler.normalize_map_attrs.call(null,map_attrs)),cljs.core.next.call(null,content)], null);
} else
{return new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [nsp,tag__$2,tag_attrs,content], null);
}
});
crate.compiler.parse_content = (function parse_content(elem,content){var attrs = cljs.core.first.call(null,content);if(cljs.core.map_QMARK_.call(null,attrs))
{crate.compiler.dom_attr.call(null,elem,attrs);
return cljs.core.rest.call(null,content);
} else
{return content;
}
});
crate.compiler.create_elem = (cljs.core.truth_(document.createElementNS)?(function (nsp,tag){return document.createElementNS(nsp,tag);
}):(function (_,tag){return document.createElement(tag);
}));
crate.compiler.elem_factory = (function elem_factory(tag_def){var bindings16243 = crate.compiler.bindings;try{crate.compiler.bindings = cljs.core.atom.call(null,cljs.core.PersistentVector.EMPTY);
var vec__16244 = crate.compiler.normalize_element.call(null,tag_def);var nsp = cljs.core.nth.call(null,vec__16244,0,null);var tag = cljs.core.nth.call(null,vec__16244,1,null);var attrs = cljs.core.nth.call(null,vec__16244,2,null);var content = cljs.core.nth.call(null,vec__16244,3,null);var elem = crate.compiler.create_elem.call(null,nsp,tag);crate.compiler.dom_attr.call(null,elem,attrs);
crate.compiler.as_content.call(null,elem,content);
crate.compiler.handle_bindings.call(null,cljs.core.deref.call(null,crate.compiler.bindings),elem);
return elem;
}finally {crate.compiler.bindings = bindings16243;
}});
/**
* Add an optional attribute argument to a function that returns a vector tag.
*/
crate.compiler.add_optional_attrs = (function add_optional_attrs(func){return (function() { 
var G__16247__delegate = function (args){if(cljs.core.map_QMARK_.call(null,cljs.core.first.call(null,args)))
{var vec__16246 = cljs.core.apply.call(null,func,cljs.core.rest.call(null,args));var tag = cljs.core.nth.call(null,vec__16246,0,null);var body = cljs.core.nthnext.call(null,vec__16246,1);if(cljs.core.map_QMARK_.call(null,cljs.core.first.call(null,body)))
{return cljs.core.apply.call(null,cljs.core.vector,tag,cljs.core.merge.call(null,cljs.core.first.call(null,body),cljs.core.first.call(null,args)),cljs.core.rest.call(null,body));
} else
{return cljs.core.apply.call(null,cljs.core.vector,tag,cljs.core.first.call(null,args),body);
}
} else
{return cljs.core.apply.call(null,func,args);
}
};
var G__16247 = function (var_args){
var args = null;if (arguments.length > 0) {
  args = cljs.core.array_seq(Array.prototype.slice.call(arguments, 0),0);} 
return G__16247__delegate.call(this,args);};
G__16247.cljs$lang$maxFixedArity = 0;
G__16247.cljs$lang$applyTo = (function (arglist__16248){
var args = cljs.core.seq(arglist__16248);
return G__16247__delegate(args);
});
G__16247.cljs$core$IFn$_invoke$arity$variadic = G__16247__delegate;
return G__16247;
})()
;
});
