import "./cljs_env.js";
goog.provide('clojure_eval.extensions.match_brackets');
var module$node_modules$$codemirror$state$dist$index_cjs=shadow.js.require("module$node_modules$$codemirror$state$dist$index_cjs", {});
var module$node_modules$$codemirror$view$dist$index_cjs=shadow.js.require("module$node_modules$$codemirror$view$dist$index_cjs", {});
clojure_eval.extensions.match_brackets.base_theme = module$node_modules$$codemirror$view$dist$index_cjs.EditorView.baseTheme(({"$matchingBracket":({"color":"#0b0"}),"$nonmatchingBracket":({"color":"#a22"})}));
clojure_eval.extensions.match_brackets.matching_mark = module$node_modules$$codemirror$view$dist$index_cjs.Decoration.mark(({"class":"cm-matchingBracket"}));
clojure_eval.extensions.match_brackets.nonmatching_mark = module$node_modules$$codemirror$view$dist$index_cjs.Decoration.mark(({"class":"cm-nonmatchingBracket"}));
clojure_eval.extensions.match_brackets.mark_node = (function clojure_eval$extensions$match_brackets$mark_node(node,mark){
return mark.range(clojure_eval.node.start(node),clojure_eval.node.end(node));
});
clojure_eval.extensions.match_brackets.state = module$node_modules$$codemirror$state$dist$index_cjs.StateField.define(({"create":cljs.core.constantly(module$node_modules$$codemirror$view$dist$index_cjs.Decoration.none),"update":(function (deco,p__55453){
var map__55454 = p__55453;
var map__55454__$1 = (((((!((map__55454 == null))))?(((((map__55454.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__55454.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__55454):map__55454);
var tr = map__55454__$1;
var state = (function (){var obj55456 = map__55454__$1;
var k55457 = "state";
if((function (){var obj55458 = obj55456;
return (((!((obj55458 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55457,obj55458)));
})()){
return (obj55456[k55457]);
} else {
return undefined;
}
})();
var docChanged = (function (){var obj55459 = map__55454__$1;
var k55460 = "docChanged";
if((function (){var obj55461 = obj55459;
return (((!((obj55461 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55460,obj55461)));
})()){
return (obj55459[k55460]);
} else {
return undefined;
}
})();
var selection = (function (){var obj55462 = map__55454__$1;
var k55463 = "selection";
if((function (){var obj55464 = obj55462;
return (((!((obj55464 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55463,obj55464)));
})()){
return (obj55462[k55463]);
} else {
return undefined;
}
})();
if(cljs.core.truth_((function (){var or__4223__auto__ = docChanged;
if(cljs.core.truth_(or__4223__auto__)){
return or__4223__auto__;
} else {
return selection;
}
})())){
var decos = cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (out,p__55465){
var map__55466 = p__55465;
var map__55466__$1 = (((((!((map__55466 == null))))?(((((map__55466.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__55466.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__55466):map__55466);
var head = (function (){var obj55468 = map__55466__$1;
var k55469 = "head";
if((function (){var obj55470 = obj55468;
return (((!((obj55470 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55469,obj55470)));
})()){
return (obj55468[k55469]);
} else {
return undefined;
}
})();
var empty = (function (){var obj55471 = map__55466__$1;
var k55472 = "empty";
if((function (){var obj55473 = obj55471;
return (((!((obj55473 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55472,obj55473)));
})()){
return (obj55471[k55472]);
} else {
return undefined;
}
})();
var or__4223__auto__ = (function (){var temp__5753__auto__ = (function (){var and__4221__auto__ = empty;
if(cljs.core.truth_(and__4221__auto__)){
return cljs.core.first(cljs.core.filter.cljs$core$IFn$_invoke$arity$2(cljs.core.some_fn.cljs$core$IFn$_invoke$arity$2(clojure_eval.node.start_edge_QMARK_,clojure_eval.node.end_edge_QMARK_),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [clojure_eval.node.tree.cljs$core$IFn$_invoke$arity$3(state,head,(-1)),clojure_eval.node.tree.cljs$core$IFn$_invoke$arity$3(state,head,(1))], null)));
} else {
return and__4221__auto__;
}
})();
if(cljs.core.truth_(temp__5753__auto__)){
var bracket = temp__5753__auto__;
var temp__5751__auto__ = ((((clojure_eval.node.start_edge_QMARK_(bracket)) && (cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(clojure_eval.node.start(bracket),clojure_eval.node.start(clojure_eval.node.up(bracket))))))?clojure_eval.util.guard(clojure_eval.node.down_last(clojure_eval.node.up(bracket)),(function (p1__55447_SHARP_){
return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(clojure_eval.node.name(p1__55447_SHARP_),clojure_eval.node.closed_by(bracket));
})):((((clojure_eval.node.end_edge_QMARK_(bracket)) && (cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(clojure_eval.node.end(bracket),clojure_eval.node.end(clojure_eval.node.up(bracket))))))?clojure_eval.util.guard(clojure_eval.node.down(clojure_eval.node.up(bracket)),(function (p1__55448_SHARP_){
return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(clojure_eval.node.name(p1__55448_SHARP_),clojure_eval.node.opened_by(bracket));
})):null));
if(cljs.core.truth_(temp__5751__auto__)){
var other_bracket = temp__5751__auto__;
return cljs.core.conj.cljs$core$IFn$_invoke$arity$variadic(out,clojure_eval.extensions.match_brackets.mark_node(bracket,clojure_eval.extensions.match_brackets.matching_mark),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([clojure_eval.extensions.match_brackets.mark_node(other_bracket,clojure_eval.extensions.match_brackets.matching_mark)], 0));
} else {
return cljs.core.conj.cljs$core$IFn$_invoke$arity$2(out,clojure_eval.extensions.match_brackets.mark_node(bracket,clojure_eval.extensions.match_brackets.nonmatching_mark));
}
} else {
return null;
}
})();
if(cljs.core.truth_(or__4223__auto__)){
return or__4223__auto__;
} else {
var or__4223__auto____$1 = (function (){var temp__5753__auto__ = (function (){var and__4221__auto__ = cljs.core.not(clojure_eval.node.closest(clojure_eval.node.tree.cljs$core$IFn$_invoke$arity$2(state,head),clojure_eval.node.string_QMARK_));
if(and__4221__auto__){
var G__55475 = tr.state.doc.slice(head,(head + (1))).toString();
var fexpr__55474 = new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 3, [")",null,"]",null,"}",null], null), null);
return (fexpr__55474.cljs$core$IFn$_invoke$arity$1 ? fexpr__55474.cljs$core$IFn$_invoke$arity$1(G__55475) : fexpr__55474.call(null,G__55475));
} else {
return and__4221__auto__;
}
})();
if(cljs.core.truth_(temp__5753__auto__)){
var unparsed_bracket = temp__5753__auto__;
return cljs.core.conj.cljs$core$IFn$_invoke$arity$2(out,clojure_eval.extensions.match_brackets.mark_node(clojure_eval.node.from_to.cljs$core$IFn$_invoke$arity$2(head,(head + (1))),clojure_eval.extensions.match_brackets.nonmatching_mark));
} else {
return null;
}
})();
if(cljs.core.truth_(or__4223__auto____$1)){
return or__4223__auto____$1;
} else {
return out;
}
}
}),cljs.core.PersistentVector.EMPTY,tr.state.selection.ranges);
return module$node_modules$$codemirror$view$dist$index_cjs.Decoration.set(cljs.core.into_array.cljs$core$IFn$_invoke$arity$1(decos),true);
} else {
return deco;
}
})}));
clojure_eval.extensions.match_brackets.extension = (function clojure_eval$extensions$match_brackets$extension(){
return [clojure_eval.extensions.match_brackets.base_theme,clojure_eval.extensions.match_brackets.state,module$node_modules$$codemirror$view$dist$index_cjs.EditorView.decorations.from(clojure_eval.extensions.match_brackets.state)];
});

//# sourceMappingURL=clojure_eval.extensions.match_brackets.js.map
