import "./cljs_env.js";
goog.provide('clojure_eval.commands');
var module$node_modules$$codemirror$commands$dist$index_cjs=shadow.js.require("module$node_modules$$codemirror$commands$dist$index_cjs", {});
var module$node_modules$$codemirror$state$dist$index_cjs=shadow.js.require("module$node_modules$$codemirror$state$dist$index_cjs", {});
clojure_eval.commands.view_command = (function clojure_eval$commands$view_command(f){
return (function (p__55476){
var map__55477 = p__55476;
var map__55477__$1 = (((((!((map__55477 == null))))?(((((map__55477.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__55477.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__55477):map__55477);
var state = (function (){var obj55479 = map__55477__$1;
var k55480 = "state";
if((function (){var obj55481 = obj55479;
return (((!((obj55481 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55480,obj55481)));
})()){
return (obj55479[k55480]);
} else {
return undefined;
}
})();
var dispatch = (function (){var obj55482 = map__55477__$1;
var k55483 = "dispatch";
if((function (){var obj55484 = obj55482;
return (((!((obj55484 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55483,obj55484)));
})()){
return (obj55482[k55483]);
} else {
return undefined;
}
})();
var G__55485_55918 = (f.cljs$core$IFn$_invoke$arity$1 ? f.cljs$core$IFn$_invoke$arity$1(state) : f.call(null,state));
if((G__55485_55918 == null)){
} else {
(dispatch.cljs$core$IFn$_invoke$arity$1 ? dispatch.cljs$core$IFn$_invoke$arity$1(G__55485_55918) : dispatch.call(null,G__55485_55918));
}

return true;
});
});
clojure_eval.commands.unwrap_STAR_ = (function clojure_eval$commands$unwrap_STAR_(state){
return clojure_eval.util.update_ranges.cljs$core$IFn$_invoke$arity$2(state,(function (p__55486){
var map__55487 = p__55486;
var map__55487__$1 = (((((!((map__55487 == null))))?(((((map__55487.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__55487.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__55487):map__55487);
var range = map__55487__$1;
var from = (function (){var obj55489 = map__55487__$1;
var k55490 = "from";
if((function (){var obj55491 = obj55489;
return (((!((obj55491 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55490,obj55491)));
})()){
return (obj55489[k55490]);
} else {
return undefined;
}
})();
var to = (function (){var obj55493 = map__55487__$1;
var k55494 = "to";
if((function (){var obj55495 = obj55493;
return (((!((obj55495 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55494,obj55495)));
})()){
return (obj55493[k55494]);
} else {
return undefined;
}
})();
var empty = (function (){var obj55496 = map__55487__$1;
var k55497 = "empty";
if((function (){var obj55498 = obj55496;
return (((!((obj55498 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55497,obj55498)));
})()){
return (obj55496[k55497]);
} else {
return undefined;
}
})();
if(cljs.core.truth_(empty)){
var temp__5753__auto__ = (function (){var G__55499 = clojure_eval.node.tree.cljs$core$IFn$_invoke$arity$3(state,from,(-1));
var G__55499__$1 = (((G__55499 == null))?null:clojure_eval.node.closest(G__55499,clojure_eval.node.coll_QMARK_));
if((G__55499__$1 == null)){
return null;
} else {
return clojure_eval.util.guard(G__55499__$1,clojure_eval.node.balanced_QMARK_);
}
})();
if(cljs.core.truth_(temp__5753__auto__)){
var nearest_balanced_coll = temp__5753__auto__;
return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"cursor","cursor",1011937484),(from - (1)),new cljs.core.Keyword(null,"changes","changes",1492088),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [clojure_eval.node.from_to.cljs$core$IFn$_invoke$arity$1(clojure_eval.node.down(nearest_balanced_coll)),clojure_eval.node.from_to.cljs$core$IFn$_invoke$arity$1(clojure_eval.node.down_last(nearest_balanced_coll))], null)], null);
} else {
return null;
}
} else {
return null;
}
}));
});
clojure_eval.commands.copy_to_clipboard_BANG_ = (function clojure_eval$commands$copy_to_clipboard_BANG_(text){
var focus_el = (function (){var obj55505 = document;
var k55506 = "activeElement";
if((function (){var obj55508 = obj55505;
return (((!((obj55508 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55506,obj55508)));
})()){
return (obj55505[k55506]);
} else {
return undefined;
}
})();
var input_el = document.createElement("textarea");
input_el.setAttribute("class","clipboard-input");

var obj55525_55937 = input_el;
var obj55526_55938 = (((!((obj55525_55937 == null))))?obj55525_55937:({}));
(obj55526_55938["innerHTML"] = text);


document.body.appendChild(input_el);

input_el.focus();

input_el.select();

document.execCommand("copy");

focus_el.focus(({"preventScroll": true}));

return document.body.removeChild(input_el);
});
clojure_eval.commands.kill_STAR_ = (function clojure_eval$commands$kill_STAR_(state){
return clojure_eval.util.update_ranges.cljs$core$IFn$_invoke$arity$2(state,(function (p__55532){
var map__55533 = p__55532;
var map__55533__$1 = (((((!((map__55533 == null))))?(((((map__55533.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__55533.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__55533):map__55533);
var range = map__55533__$1;
var from = (function (){var obj55536 = map__55533__$1;
var k55537 = "from";
if((function (){var obj55538 = obj55536;
return (((!((obj55538 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55537,obj55538)));
})()){
return (obj55536[k55537]);
} else {
return undefined;
}
})();
var to = (function (){var obj55569 = map__55533__$1;
var k55570 = "to";
if((function (){var obj55574 = obj55569;
return (((!((obj55574 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55570,obj55574)));
})()){
return (obj55569[k55570]);
} else {
return undefined;
}
})();
var empty = (function (){var obj55575 = map__55533__$1;
var k55576 = "empty";
if((function (){var obj55577 = obj55575;
return (((!((obj55577 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55576,obj55577)));
})()){
return (obj55575[k55576]);
} else {
return undefined;
}
})();
if(cljs.core.truth_(empty)){
var node = clojure_eval.node.tree.cljs$core$IFn$_invoke$arity$2(state,from);
var parent = clojure_eval.node.closest(node,(function (p1__55530_SHARP_){
var or__4223__auto__ = clojure_eval.node.coll_QMARK_(p1__55530_SHARP_);
if(cljs.core.truth_(or__4223__auto__)){
return or__4223__auto__;
} else {
return ((clojure_eval.node.string_QMARK_(p1__55530_SHARP_)) || (clojure_eval.node.top_QMARK_(p1__55530_SHARP_)));
}
}));
var line_end = state.doc.lineAt(from).to;
var next_children = (cljs.core.truth_(parent)?clojure_eval.node.children.cljs$core$IFn$_invoke$arity$3(parent,from,(1)):null);
var last_child_on_line = (cljs.core.truth_(parent)?(function (){var G__55586 = next_children;
var G__55586__$1 = (((G__55586 == null))?null:cljs.core.take_while.cljs$core$IFn$_invoke$arity$2(cljs.core.every_pred.cljs$core$IFn$_invoke$arity$1((function (p1__55531_SHARP_){
return (clojure_eval.node.start(p1__55531_SHARP_) <= line_end);
})),G__55586));
if((G__55586__$1 == null)){
return null;
} else {
return cljs.core.last(G__55586__$1);
}
})():null);
var to__$1 = ((clojure_eval.node.string_QMARK_(parent))?(function (){var content = cljs.core.str.cljs$core$IFn$_invoke$arity$1(clojure_eval.node.string.cljs$core$IFn$_invoke$arity$2(state,parent));
var content_from = cljs.core.subs.cljs$core$IFn$_invoke$arity$2(content,(from - clojure_eval.node.start(parent)));
var next_newline = content_from.indexOf("\n");
if((next_newline < (0))){
return (clojure_eval.node.end(parent) - (1));
} else {
return ((from + next_newline) + (1));
}
})():(cljs.core.truth_(last_child_on_line)?((clojure_eval.node.end_edge_QMARK_(last_child_on_line))?clojure_eval.node.start(last_child_on_line):clojure_eval.node.end(last_child_on_line)):(cljs.core.truth_((function (){var G__55590 = cljs.core.first(next_children);
var G__55590__$1 = (((G__55590 == null))?null:clojure_eval.node.start(G__55590));
if((G__55590__$1 == null)){
return null;
} else {
return (G__55590__$1 > line_end);
}
})())?clojure_eval.node.start(cljs.core.first(next_children)):null)));
clojure_eval.commands.copy_to_clipboard_BANG_(clojure_eval.node.string.cljs$core$IFn$_invoke$arity$3(state,from,to__$1));

if(cljs.core.truth_(to__$1)){
return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"cursor","cursor",1011937484),from,new cljs.core.Keyword(null,"changes","changes",1492088),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"from","from",1815293044),from,new cljs.core.Keyword(null,"to","to",192099007),to__$1], null)], null);
} else {
return null;
}
} else {
clojure_eval.commands.copy_to_clipboard_BANG_(clojure_eval.node.string.cljs$core$IFn$_invoke$arity$3(state,from,to));

return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"cursor","cursor",1011937484),from,new cljs.core.Keyword(null,"changes","changes",1492088),clojure_eval.util.from_to(from,to)], null);
}
}));
});
clojure_eval.commands.enter_and_indent_STAR_ = (function clojure_eval$commands$enter_and_indent_STAR_(state){
var ctx = clojure_eval.extensions.formatting.make_indent_context(state);
return clojure_eval.util.update_ranges.cljs$core$IFn$_invoke$arity$2(state,(function (p__55596){
var map__55598 = p__55596;
var map__55598__$1 = (((((!((map__55598 == null))))?(((((map__55598.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__55598.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__55598):map__55598);
var range = map__55598__$1;
var from = (function (){var obj55607 = map__55598__$1;
var k55608 = "from";
if((function (){var obj55609 = obj55607;
return (((!((obj55609 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55608,obj55609)));
})()){
return (obj55607[k55608]);
} else {
return undefined;
}
})();
var to = (function (){var obj55611 = map__55598__$1;
var k55612 = "to";
if((function (){var obj55614 = obj55611;
return (((!((obj55614 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55612,obj55614)));
})()){
return (obj55611[k55612]);
} else {
return undefined;
}
})();
var empty = (function (){var obj55616 = map__55598__$1;
var k55617 = "empty";
if((function (){var obj55618 = obj55616;
return (((!((obj55618 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55617,obj55618)));
})()){
return (obj55616[k55617]);
} else {
return undefined;
}
})();
var indent_at = clojure_eval.node.start(clojure_eval.node.inner_span(clojure_eval.node.closest(clojure_eval.node.tree.cljs$core$IFn$_invoke$arity$2(state,from),cljs.core.some_fn.cljs$core$IFn$_invoke$arity$2(clojure_eval.node.coll_QMARK_,clojure_eval.node.top_QMARK_))));
var indent = clojure_eval.extensions.formatting.get_indentation(ctx,indent_at);
var insertion = ["\n",cljs.core.str.cljs$core$IFn$_invoke$arity$1(clojure_eval.extensions.formatting.spaces(state,indent))].join('');
return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"cursor","cursor",1011937484),(from + ((insertion).length)),new cljs.core.Keyword(null,"changes","changes",1492088),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"from","from",1815293044),from,new cljs.core.Keyword(null,"to","to",192099007),to,new cljs.core.Keyword(null,"insert","insert",1286475395),insertion], null)], null)], null);
}));
});
clojure_eval.commands.nav_position = (function clojure_eval$commands$nav_position(state,from,dir){
var or__4223__auto__ = (function (){var G__55627 = clojure_eval.node.closest(clojure_eval.node.tree.cljs$core$IFn$_invoke$arity$2(state,from),(function (p1__55625_SHARP_){
var or__4223__auto__ = clojure_eval.node.coll_QMARK_(p1__55625_SHARP_);
if(cljs.core.truth_(or__4223__auto__)){
return or__4223__auto__;
} else {
return ((clojure_eval.node.string_QMARK_(p1__55625_SHARP_)) || (clojure_eval.node.top_QMARK_(p1__55625_SHARP_)));
}
}));
var G__55627__$1 = (((G__55627 == null))?null:clojure_eval.node.children.cljs$core$IFn$_invoke$arity$3(G__55627,from,dir));
var G__55627__$2 = (((G__55627__$1 == null))?null:cljs.core.first(G__55627__$1));
if((G__55627__$2 == null)){
return null;
} else {
var obj55630 = G__55627__$2;
var k55631 = applied_science.js_interop.impl.wrap_key((function (){var G__55634 = dir;
switch (G__55634) {
case (-1):
return new cljs.core.Keyword(null,"from","from",1815293044);

break;
case (1):
return new cljs.core.Keyword(null,"to","to",192099007);

break;
default:
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__55634)].join('')));

}
})());
if((function (){var obj55638 = obj55630;
return (((!((obj55638 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55631,obj55638)));
})()){
return (obj55630[k55631]);
} else {
return undefined;
}
}
})();
if(cljs.core.truth_(or__4223__auto__)){
return or__4223__auto__;
} else {
return clojure_eval.selections.constrain(state,(from + dir));
}
});
clojure_eval.commands.nav = (function clojure_eval$commands$nav(dir){
return (function (state){
return clojure_eval.util.update_ranges.cljs$core$IFn$_invoke$arity$2(state,(function (p__55642){
var map__55643 = p__55642;
var map__55643__$1 = (((((!((map__55643 == null))))?(((((map__55643.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__55643.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__55643):map__55643);
var range = map__55643__$1;
var from = (function (){var obj55645 = map__55643__$1;
var k55646 = "from";
if((function (){var obj55647 = obj55645;
return (((!((obj55647 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55646,obj55647)));
})()){
return (obj55645[k55646]);
} else {
return undefined;
}
})();
var to = (function (){var obj55649 = map__55643__$1;
var k55650 = "to";
if((function (){var obj55654 = obj55649;
return (((!((obj55654 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55650,obj55654)));
})()){
return (obj55649[k55650]);
} else {
return undefined;
}
})();
var empty = (function (){var obj55659 = map__55643__$1;
var k55660 = "empty";
if((function (){var obj55661 = obj55659;
return (((!((obj55661 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55660,obj55661)));
})()){
return (obj55659[k55660]);
} else {
return undefined;
}
})();
if(cljs.core.truth_(empty)){
return new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"cursor","cursor",1011937484),clojure_eval.commands.nav_position(state,from,dir)], null);
} else {
return new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"cursor","cursor",1011937484),(function (){var obj55662 = clojure_eval.util.from_to(from,to);
var k55663 = applied_science.js_interop.impl.wrap_key((function (){var G__55668 = dir;
switch (G__55668) {
case (-1):
return new cljs.core.Keyword(null,"from","from",1815293044);

break;
case (1):
return new cljs.core.Keyword(null,"to","to",192099007);

break;
default:
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__55668)].join('')));

}
})());
if((function (){var obj55669 = obj55662;
return (((!((obj55669 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55663,obj55669)));
})()){
return (obj55662[k55663]);
} else {
return undefined;
}
})()], null);
}
}));
});
});
clojure_eval.commands.nav_select = (function clojure_eval$commands$nav_select(dir){
return (function (state){
return clojure_eval.util.update_ranges.cljs$core$IFn$_invoke$arity$2(state,(function (p__55670){
var map__55671 = p__55670;
var map__55671__$1 = (((((!((map__55671 == null))))?(((((map__55671.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__55671.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__55671):map__55671);
var range = map__55671__$1;
var from = (function (){var obj55675 = map__55671__$1;
var k55676 = "from";
if((function (){var obj55677 = obj55675;
return (((!((obj55677 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55676,obj55677)));
})()){
return (obj55675[k55676]);
} else {
return undefined;
}
})();
var to = (function (){var obj55678 = map__55671__$1;
var k55679 = "to";
if((function (){var obj55680 = obj55678;
return (((!((obj55680 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55679,obj55680)));
})()){
return (obj55678[k55679]);
} else {
return undefined;
}
})();
var empty = (function (){var obj55683 = map__55671__$1;
var k55684 = "empty";
if((function (){var obj55685 = obj55683;
return (((!((obj55685 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55684,obj55685)));
})()){
return (obj55683[k55684]);
} else {
return undefined;
}
})();
if(cljs.core.truth_(empty)){
return new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"range","range",1639692286),clojure_eval.node.balanced_range.cljs$core$IFn$_invoke$arity$3(state,from,clojure_eval.commands.nav_position(state,from,dir))], null);
} else {
return new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"range","range",1639692286),(function (){var map__55688 = clojure_eval.util.from_to(from,to);
var map__55688__$1 = (((((!((map__55688 == null))))?(((((map__55688.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__55688.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__55688):map__55688);
var from__$1 = (function (){var obj55694 = map__55688__$1;
var k55695 = "from";
if((function (){var obj55696 = obj55694;
return (((!((obj55696 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55695,obj55696)));
})()){
return (obj55694[k55695]);
} else {
return undefined;
}
})();
var to__$1 = (function (){var obj55700 = map__55688__$1;
var k55701 = "to";
if((function (){var obj55702 = obj55700;
return (((!((obj55702 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55701,obj55702)));
})()){
return (obj55700[k55701]);
} else {
return undefined;
}
})();
var G__55705 = dir;
switch (G__55705) {
case (1):
return clojure_eval.node.balanced_range.cljs$core$IFn$_invoke$arity$3(state,from__$1,clojure_eval.commands.nav_position(state,to__$1,dir));

break;
case (-1):
return clojure_eval.node.balanced_range.cljs$core$IFn$_invoke$arity$3(state,clojure_eval.commands.nav_position(state,from__$1,dir),to__$1);

break;
default:
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__55705)].join('')));

}
})()], null);
}
}));
});
});
clojure_eval.commands.balance_ranges = (function clojure_eval$commands$balance_ranges(state){
return clojure_eval.util.update_ranges.cljs$core$IFn$_invoke$arity$2(state,(function (p__55710){
var map__55712 = p__55710;
var map__55712__$1 = (((((!((map__55712 == null))))?(((((map__55712.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__55712.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__55712):map__55712);
var from = (function (){var obj55716 = map__55712__$1;
var k55717 = "from";
if((function (){var obj55718 = obj55716;
return (((!((obj55718 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55717,obj55718)));
})()){
return (obj55716[k55717]);
} else {
return undefined;
}
})();
var to = (function (){var obj55723 = map__55712__$1;
var k55724 = "to";
if((function (){var obj55725 = obj55723;
return (((!((obj55725 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55724,obj55725)));
})()){
return (obj55723[k55724]);
} else {
return undefined;
}
})();
var empty = (function (){var obj55726 = map__55712__$1;
var k55727 = "empty";
if((function (){var obj55728 = obj55726;
return (((!((obj55728 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55727,obj55728)));
})()){
return (obj55726[k55727]);
} else {
return undefined;
}
})();
if(cljs.core.truth_(empty)){
return null;
} else {
return new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"range","range",1639692286),clojure_eval.node.balanced_range.cljs$core$IFn$_invoke$arity$3(state,from,to)], null);
}
}));
});
clojure_eval.commands.log = console.log;
clojure_eval.commands.slurp = (function clojure_eval$commands$slurp(direction){
return (function (state){
return clojure_eval.util.update_ranges.cljs$core$IFn$_invoke$arity$2(state,(function (p__55730){
var map__55731 = p__55730;
var map__55731__$1 = (((((!((map__55731 == null))))?(((((map__55731.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__55731.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__55731):map__55731);
var range = map__55731__$1;
var from = (function (){var obj55733 = map__55731__$1;
var k55734 = "from";
if((function (){var obj55735 = obj55733;
return (((!((obj55735 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55734,obj55735)));
})()){
return (obj55733[k55734]);
} else {
return undefined;
}
})();
var to = (function (){var obj55736 = map__55731__$1;
var k55737 = "to";
if((function (){var obj55738 = obj55736;
return (((!((obj55738 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55737,obj55738)));
})()){
return (obj55736[k55737]);
} else {
return undefined;
}
})();
var empty = (function (){var obj55742 = map__55731__$1;
var k55743 = "empty";
if((function (){var obj55744 = obj55742;
return (((!((obj55744 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55743,obj55744)));
})()){
return (obj55742[k55743]);
} else {
return undefined;
}
})();
if(cljs.core.truth_(empty)){
var temp__5753__auto__ = clojure_eval.node.closest(clojure_eval.node.tree.cljs$core$IFn$_invoke$arity$2(state,from),cljs.core.every_pred.cljs$core$IFn$_invoke$arity$2(clojure_eval.node.coll_QMARK_,(function (p1__55729_SHARP_){
return cljs.core.not((function (){var G__55745 = direction;
switch (G__55745) {
case (1):
var G__55746 = p1__55729_SHARP_;
var G__55746__$1 = (((G__55746 == null))?null:clojure_eval.node.with_prefix(G__55746));
var G__55746__$2 = (((G__55746__$1 == null))?null:clojure_eval.node.right(G__55746__$1));
if((G__55746__$2 == null)){
return null;
} else {
return clojure_eval.node.end_edge_QMARK_(G__55746__$2);
}

break;
case (-1):
var G__55747 = p1__55729_SHARP_;
var G__55747__$1 = (((G__55747 == null))?null:clojure_eval.node.with_prefix(G__55747));
var G__55747__$2 = (((G__55747__$1 == null))?null:clojure_eval.node.left(G__55747__$1));
if((G__55747__$2 == null)){
return null;
} else {
return clojure_eval.node.start_edge_QMARK_(G__55747__$2);
}

break;
default:
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__55745)].join('')));

}
})());
})));
if(cljs.core.truth_(temp__5753__auto__)){
var parent = temp__5753__auto__;
var temp__5753__auto____$1 = (function (){var G__55748 = direction;
switch (G__55748) {
case (1):
return cljs.core.first(cljs.core.remove.cljs$core$IFn$_invoke$arity$2(clojure_eval.node.line_comment_QMARK_,clojure_eval.node.rights(clojure_eval.node.with_prefix(parent))));

break;
case (-1):
return cljs.core.first(cljs.core.remove.cljs$core$IFn$_invoke$arity$2(clojure_eval.node.line_comment_QMARK_,clojure_eval.node.lefts(clojure_eval.node.with_prefix(parent))));

break;
default:
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__55748)].join('')));

}
})();
if(cljs.core.truth_(temp__5753__auto____$1)){
var target = temp__5753__auto____$1;
return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword("cursor","mapped","cursor/mapped",1625530272),from,new cljs.core.Keyword(null,"changes","changes",1492088),(function (){var G__55749 = direction;
switch (G__55749) {
case (1):
var edge = clojure_eval.node.down_last(parent);
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"from","from",1815293044),clojure_eval.node.end(target),new cljs.core.Keyword(null,"insert","insert",1286475395),clojure_eval.node.name(edge)], null),(function (){var obj55750 = clojure_eval.node.from_to.cljs$core$IFn$_invoke$arity$1(edge);
var obj55751 = (((!((obj55750 == null))))?obj55750:({}));
(obj55751["insert"] = " ");

return obj55751;
})()], null);

break;
case (-1):
var edge = clojure_eval.node.left_edge_with_prefix(state,parent);
var start = clojure_eval.node.start(clojure_eval.node.with_prefix(parent));
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"from","from",1815293044),start,new cljs.core.Keyword(null,"to","to",192099007),(start + ((edge).length)),new cljs.core.Keyword(null,"insert","insert",1286475395)," "], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"from","from",1815293044),clojure_eval.node.start(target),new cljs.core.Keyword(null,"insert","insert",1286475395),edge], null)], null);

break;
default:
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__55749)].join('')));

}
})()], null);
} else {
return null;
}
} else {
return null;
}
} else {
return null;
}
}));
});
});
clojure_eval.commands.barf = (function clojure_eval$commands$barf(direction){
return (function (state){
return clojure_eval.util.update_ranges.cljs$core$IFn$_invoke$arity$2(state,(function (p__55765){
var map__55766 = p__55765;
var map__55766__$1 = (((((!((map__55766 == null))))?(((((map__55766.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__55766.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__55766):map__55766);
var range = map__55766__$1;
var from = (function (){var obj55792 = map__55766__$1;
var k55793 = "from";
if((function (){var obj55797 = obj55792;
return (((!((obj55797 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55793,obj55797)));
})()){
return (obj55792[k55793]);
} else {
return undefined;
}
})();
var to = (function (){var obj55803 = map__55766__$1;
var k55804 = "to";
if((function (){var obj55808 = obj55803;
return (((!((obj55808 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55804,obj55808)));
})()){
return (obj55803[k55804]);
} else {
return undefined;
}
})();
var empty = (function (){var obj55810 = map__55766__$1;
var k55811 = "empty";
if((function (){var obj55813 = obj55810;
return (((!((obj55813 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k55811,obj55813)));
})()){
return (obj55810[k55811]);
} else {
return undefined;
}
})();
if(cljs.core.truth_(empty)){
var temp__5753__auto__ = clojure_eval.node.closest(clojure_eval.node.tree.cljs$core$IFn$_invoke$arity$2(state,from),clojure_eval.node.coll_QMARK_);
if(cljs.core.truth_(temp__5753__auto__)){
var parent = temp__5753__auto__;
var G__55833 = direction;
switch (G__55833) {
case (1):
var temp__5753__auto____$1 = (function (){var G__55834 = clojure_eval.node.down_last(parent);
var G__55834__$1 = (((G__55834 == null))?null:clojure_eval.node.lefts(G__55834));
var G__55834__$2 = (((G__55834__$1 == null))?null:cljs.core.remove.cljs$core$IFn$_invoke$arity$2(clojure_eval.node.line_comment_QMARK_,G__55834__$1));
var G__55834__$3 = (((G__55834__$2 == null))?null:cljs.core.drop.cljs$core$IFn$_invoke$arity$2((1),G__55834__$2));
if((G__55834__$3 == null)){
return null;
} else {
return cljs.core.first(G__55834__$3);
}
})();
if(cljs.core.truth_(temp__5753__auto____$1)){
var target = temp__5753__auto____$1;
return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"cursor","cursor",1011937484),(function (){var x__4309__auto__ = clojure_eval.node.end(target);
var y__4310__auto__ = from;
return ((x__4309__auto__ < y__4310__auto__) ? x__4309__auto__ : y__4310__auto__);
})(),new cljs.core.Keyword(null,"changes","changes",1492088),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"from","from",1815293044),clojure_eval.node.end(target),new cljs.core.Keyword(null,"insert","insert",1286475395),clojure_eval.node.name(clojure_eval.node.down_last(parent))], null),(function (){var obj55845 = clojure_eval.node.from_to.cljs$core$IFn$_invoke$arity$1(clojure_eval.node.down_last(parent));
var obj55854 = (((!((obj55845 == null))))?obj55845:({}));
(obj55854["insert"] = " ");

return obj55854;
})()], null)], null);
} else {
return null;
}

break;
case (-1):
var temp__5753__auto____$1 = (function (){var G__55858 = clojure_eval.node.down(parent);
var G__55858__$1 = (((G__55858 == null))?null:clojure_eval.node.rights(G__55858));
var G__55858__$2 = (((G__55858__$1 == null))?null:cljs.core.remove.cljs$core$IFn$_invoke$arity$2(clojure_eval.node.line_comment_QMARK_,G__55858__$1));
var G__55858__$3 = (((G__55858__$2 == null))?null:cljs.core.drop.cljs$core$IFn$_invoke$arity$2((1),G__55858__$2));
if((G__55858__$3 == null)){
return null;
} else {
return cljs.core.first(G__55858__$3);
}
})();
if(cljs.core.truth_(temp__5753__auto____$1)){
var next_first_child = temp__5753__auto____$1;
var left_edge = clojure_eval.node.left_edge_with_prefix(state,parent);
var left_start = clojure_eval.node.start(clojure_eval.node.with_prefix(parent));
return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"cursor","cursor",1011937484),(function (){var x__4306__auto__ = from;
var y__4307__auto__ = (clojure_eval.node.start(next_first_child) + (((left_edge).length) + (1)));
return ((x__4306__auto__ > y__4307__auto__) ? x__4306__auto__ : y__4307__auto__);
})(),new cljs.core.Keyword(null,"changes","changes",1492088),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"from","from",1815293044),clojure_eval.node.start(next_first_child),new cljs.core.Keyword(null,"insert","insert",1286475395),[" ",left_edge].join('')], null),new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"from","from",1815293044),left_start,new cljs.core.Keyword(null,"to","to",192099007),(left_start + ((left_edge).length)),new cljs.core.Keyword(null,"insert","insert",1286475395),clojure_eval.extensions.formatting.spaces(state,((left_edge).length))], null)], null)], null);
} else {
return null;
}

break;
default:
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__55833)].join('')));

}
} else {
return null;
}
} else {
return null;
}
}));
});
});
/**
 * Subset of builtin commands that compliment paredit
 */
clojure_eval.commands.builtin_index = cljs.core.PersistentHashMap.fromArrays([new cljs.core.Keyword(null,"cursorLineStart","cursorLineStart",-1505072960),new cljs.core.Keyword(null,"cursorLineDown","cursorLineDown",180576864),new cljs.core.Keyword(null,"selectAll","selectAll",869127842),new cljs.core.Keyword(null,"selectLineUp","selectLineUp",-255594686),new cljs.core.Keyword(null,"cursorLineBoundaryForward","cursorLineBoundaryForward",-1283359997),new cljs.core.Keyword(null,"selectLineBoundaryBackward","selectLineBoundaryBackward",-1443564123),new cljs.core.Keyword(null,"deleteCharBackward","deleteCharBackward",-618312025),new cljs.core.Keyword(null,"insertNewlineAndIndent","insertNewlineAndIndent",-542382007),new cljs.core.Keyword(null,"cursorLineBoundaryBackward","cursorLineBoundaryBackward",1373049802),new cljs.core.Keyword(null,"selectCharRight","selectCharRight",1049825195),new cljs.core.Keyword(null,"selectPageUp","selectPageUp",152840428),new cljs.core.Keyword(null,"deleteCharForward","deleteCharForward",823474956),new cljs.core.Keyword(null,"cursorCharLeft","cursorCharLeft",-1572589780),new cljs.core.Keyword(null,"cursorGroupBackward","cursorGroupBackward",-1004717331),new cljs.core.Keyword(null,"selectDocStart","selectDocStart",-217268371),new cljs.core.Keyword(null,"selectGroupBackward","selectGroupBackward",1569543117),new cljs.core.Keyword(null,"cursorDocEnd","cursorDocEnd",-1298653903),new cljs.core.Keyword(null,"deleteGroupBackward","deleteGroupBackward",616768113),new cljs.core.Keyword(null,"selectLineStart","selectLineStart",1211557745),new cljs.core.Keyword(null,"deleteGroupForward","deleteGroupForward",596007091),new cljs.core.Keyword(null,"selectDocEnd","selectDocEnd",496449813),new cljs.core.Keyword(null,"selectPageDown","selectPageDown",226562613),new cljs.core.Keyword(null,"cursorPageDown","cursorPageDown",-1143253131),new cljs.core.Keyword(null,"cursorPageUp","cursorPageUp",-716828715),new cljs.core.Keyword(null,"selectLineBoundaryForward","selectLineBoundaryForward",904508598),new cljs.core.Keyword(null,"cursorLineEnd","cursorLineEnd",-234219178),new cljs.core.Keyword(null,"cursorGroupForward","cursorGroupForward",1231480632),new cljs.core.Keyword(null,"cursorCharRight","cursorCharRight",-739900583),new cljs.core.Keyword(null,"selectGroupForward","selectGroupForward",1344873433),new cljs.core.Keyword(null,"selectLineEnd","selectLineEnd",-1578526086),new cljs.core.Keyword(null,"selectCharLeft","selectCharLeft",1894248154),new cljs.core.Keyword(null,"splitLine","splitLine",-1338533189),new cljs.core.Keyword(null,"selectLineDown","selectLineDown",1741100604),new cljs.core.Keyword(null,"transposeChars","transposeChars",1566260285),new cljs.core.Keyword(null,"cursorLineUp","cursorLineUp",-1375841219),new cljs.core.Keyword(null,"cursorDocStart","cursorDocStart",2008312830)],[module$node_modules$$codemirror$commands$dist$index_cjs.cursorLineStart,module$node_modules$$codemirror$commands$dist$index_cjs.cursorLineDown,module$node_modules$$codemirror$commands$dist$index_cjs.selectAll,module$node_modules$$codemirror$commands$dist$index_cjs.selectLineUp,module$node_modules$$codemirror$commands$dist$index_cjs.cursorLineBoundaryForward,module$node_modules$$codemirror$commands$dist$index_cjs.selectLineBoundaryBackward,module$node_modules$$codemirror$commands$dist$index_cjs.deleteCharBackward,module$node_modules$$codemirror$commands$dist$index_cjs.insertNewlineAndIndent,module$node_modules$$codemirror$commands$dist$index_cjs.cursorLineBoundaryBackward,module$node_modules$$codemirror$commands$dist$index_cjs.selectCharRight,module$node_modules$$codemirror$commands$dist$index_cjs.selectPageUp,module$node_modules$$codemirror$commands$dist$index_cjs.deleteCharForward,module$node_modules$$codemirror$commands$dist$index_cjs.cursorCharLeft,module$node_modules$$codemirror$commands$dist$index_cjs.cursorGroupBackward,module$node_modules$$codemirror$commands$dist$index_cjs.selectDocStart,module$node_modules$$codemirror$commands$dist$index_cjs.selectGroupBackward,module$node_modules$$codemirror$commands$dist$index_cjs.cursorDocEnd,module$node_modules$$codemirror$commands$dist$index_cjs.deleteGroupBackward,module$node_modules$$codemirror$commands$dist$index_cjs.selectLineStart,module$node_modules$$codemirror$commands$dist$index_cjs.deleteGroupForward,module$node_modules$$codemirror$commands$dist$index_cjs.selectDocEnd,module$node_modules$$codemirror$commands$dist$index_cjs.selectPageDown,module$node_modules$$codemirror$commands$dist$index_cjs.cursorPageDown,module$node_modules$$codemirror$commands$dist$index_cjs.cursorPageUp,module$node_modules$$codemirror$commands$dist$index_cjs.selectLineBoundaryForward,module$node_modules$$codemirror$commands$dist$index_cjs.cursorLineEnd,module$node_modules$$codemirror$commands$dist$index_cjs.cursorGroupForward,module$node_modules$$codemirror$commands$dist$index_cjs.cursorCharRight,module$node_modules$$codemirror$commands$dist$index_cjs.selectGroupForward,module$node_modules$$codemirror$commands$dist$index_cjs.selectLineEnd,module$node_modules$$codemirror$commands$dist$index_cjs.selectCharLeft,module$node_modules$$codemirror$commands$dist$index_cjs.splitLine,module$node_modules$$codemirror$commands$dist$index_cjs.selectLineDown,module$node_modules$$codemirror$commands$dist$index_cjs.transposeChars,module$node_modules$$codemirror$commands$dist$index_cjs.cursorLineUp,module$node_modules$$codemirror$commands$dist$index_cjs.cursorDocStart]);
clojure_eval.commands.indent = clojure_eval.commands.view_command(clojure_eval.extensions.formatting.format);
clojure_eval.commands.unwrap = clojure_eval.commands.view_command(clojure_eval.commands.unwrap_STAR_);
clojure_eval.commands.kill = clojure_eval.commands.view_command(clojure_eval.commands.kill_STAR_);
clojure_eval.commands.nav_right = clojure_eval.commands.view_command(clojure_eval.commands.nav((1)));
clojure_eval.commands.nav_left = clojure_eval.commands.view_command(clojure_eval.commands.nav((-1)));
clojure_eval.commands.nav_select_right = clojure_eval.commands.view_command(clojure_eval.commands.nav_select((1)));
clojure_eval.commands.nav_select_left = clojure_eval.commands.view_command(clojure_eval.commands.nav_select((-1)));
clojure_eval.commands.slurp_forward = clojure_eval.commands.view_command(clojure_eval.commands.slurp((1)));
clojure_eval.commands.slurp_backward = clojure_eval.commands.view_command(clojure_eval.commands.slurp((-1)));
clojure_eval.commands.barf_forward = clojure_eval.commands.view_command(clojure_eval.commands.barf((1)));
clojure_eval.commands.barf_backward = clojure_eval.commands.view_command(clojure_eval.commands.barf((-1)));
clojure_eval.commands.selection_grow = clojure_eval.commands.view_command(clojure_eval.extensions.selection_history.selection_grow_STAR_);
clojure_eval.commands.selection_return = clojure_eval.commands.view_command(clojure_eval.extensions.selection_history.selection_return_STAR_);
clojure_eval.commands.enter_and_indent = clojure_eval.commands.view_command(clojure_eval.commands.enter_and_indent_STAR_);
clojure_eval.commands.paredit_index = cljs.core.PersistentHashMap.fromArrays([new cljs.core.Keyword(null,"indent","indent",-148200125),new cljs.core.Keyword(null,"nav-left","nav-left",845947876),new cljs.core.Keyword(null,"enter-and-indent","enter-and-indent",-1825406873),new cljs.core.Keyword(null,"selection-grow","selection-grow",1627169352),new cljs.core.Keyword(null,"kill","kill",-12335575),new cljs.core.Keyword(null,"slurp-forward","slurp-forward",-866284566),new cljs.core.Keyword(null,"nav-select-right","nav-select-right",-455278613),new cljs.core.Keyword(null,"nav-select-left","nav-select-left",-1033285138),new cljs.core.Keyword(null,"barf-forward","barf-forward",1278612337),new cljs.core.Keyword(null,"barf-backward","barf-backward",434854195),new cljs.core.Keyword(null,"nav-right","nav-right",591041267),new cljs.core.Keyword(null,"slurp-backward","slurp-backward",-1615745159),new cljs.core.Keyword(null,"unwrap","unwrap",-1399175462),new cljs.core.Keyword(null,"selection-return","selection-return",267226206)],[clojure_eval.commands.indent,clojure_eval.commands.nav_left,clojure_eval.commands.enter_and_indent,clojure_eval.commands.selection_grow,clojure_eval.commands.kill,clojure_eval.commands.slurp_forward,clojure_eval.commands.nav_select_right,clojure_eval.commands.nav_select_left,clojure_eval.commands.barf_forward,clojure_eval.commands.barf_backward,clojure_eval.commands.nav_right,clojure_eval.commands.slurp_backward,clojure_eval.commands.unwrap,clojure_eval.commands.selection_return]);
/**
 * Mapping of keyword-id to command functions
 */
clojure_eval.commands.index = cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([clojure_eval.commands.builtin_index,clojure_eval.commands.paredit_index], 0));
/**
 * Lookup keyword-id by function
 */
clojure_eval.commands.reverse_index = cljs.core.reduce_kv((function (p1__55894_SHARP_,p2__55896_SHARP_,p3__55895_SHARP_){
return cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(p1__55894_SHARP_,p3__55895_SHARP_,p2__55896_SHARP_);
}),cljs.core.PersistentArrayMap.EMPTY,clojure_eval.commands.index);

//# sourceMappingURL=clojure_eval.commands.js.map
