import "./cljs_env.js";
goog.provide('nextjournal.clojure_mode.util');
var module$node_modules$$codemirror$state$dist$index_cjs=shadow.js.require("module$node_modules$$codemirror$state$dist$index_cjs", {});
/**
 * @define {boolean}
 */
nextjournal.clojure_mode.util.node_js_QMARK_ = goog.define("nextjournal.clojure_mode.util.node_js_QMARK_",false);
nextjournal.clojure_mode.util.user_event_annotation = (function nextjournal$clojure_mode$util$user_event_annotation(event_name){
return module$node_modules$$codemirror$state$dist$index_cjs.Transaction.userEvent.of(event_name);
});
nextjournal.clojure_mode.util.get_user_event_annotation = (function nextjournal$clojure_mode$util$get_user_event_annotation(tr){
return tr.annotation(module$node_modules$$codemirror$state$dist$index_cjs.Transaction.userEvent);
});
nextjournal.clojure_mode.util.guard = (function nextjournal$clojure_mode$util$guard(x,f){
if(cljs.core.truth_((f.cljs$core$IFn$_invoke$arity$1 ? f.cljs$core$IFn$_invoke$arity$1(x) : f.call(null,x)))){
return x;
} else {
return null;
}
});
nextjournal.clojure_mode.util.from_to = (function nextjournal$clojure_mode$util$from_to(p1,p2){
if((p1 > p2)){
return ({"from": p2, "to": p1});
} else {
return ({"from": p1, "to": p2});
}
});
/**
 * If passed a transaction, dispatch to view and return true to stop processing commands.
 */
nextjournal.clojure_mode.util.dispatch_some = (function nextjournal$clojure_mode$util$dispatch_some(view,tr){
if(cljs.core.truth_(tr)){
view.dispatch(tr);

return true;
} else {
return false;
}
});
/**
 * Returns a `change` that inserts string `s` at position `from` and moves cursor to end of insertion.
 */
nextjournal.clojure_mode.util.insertion = (function nextjournal$clojure_mode$util$insertion(var_args){
var G__56373 = arguments.length;
switch (G__56373) {
case 2:
return nextjournal.clojure_mode.util.insertion.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));

break;
case 3:
return nextjournal.clojure_mode.util.insertion.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('')));

}
});

(nextjournal.clojure_mode.util.insertion.cljs$core$IFn$_invoke$arity$2 = (function (from,s){
return nextjournal.clojure_mode.util.insertion.cljs$core$IFn$_invoke$arity$3(from,from,s);
}));

(nextjournal.clojure_mode.util.insertion.cljs$core$IFn$_invoke$arity$3 = (function (from,to,s){
return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"changes","changes",1492088),new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"insert","insert",1286475395),s,new cljs.core.Keyword(null,"from","from",1815293044),from,new cljs.core.Keyword(null,"to","to",192099007),to], null),new cljs.core.Keyword(null,"cursor","cursor",1011937484),(from + ((s).length))], null);
}));

(nextjournal.clojure_mode.util.insertion.cljs$lang$maxFixedArity = 3);

nextjournal.clojure_mode.util.deletion = (function nextjournal$clojure_mode$util$deletion(var_args){
var G__56375 = arguments.length;
switch (G__56375) {
case 1:
return nextjournal.clojure_mode.util.deletion.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));

break;
case 2:
return nextjournal.clojure_mode.util.deletion.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));

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

}
});

(nextjournal.clojure_mode.util.deletion.cljs$core$IFn$_invoke$arity$1 = (function (from){
return nextjournal.clojure_mode.util.deletion.cljs$core$IFn$_invoke$arity$2((function (){var x__4306__auto__ = (0);
var y__4307__auto__ = (from - (1));
return ((x__4306__auto__ > y__4307__auto__) ? x__4306__auto__ : y__4307__auto__);
})(),from);
}));

(nextjournal.clojure_mode.util.deletion.cljs$core$IFn$_invoke$arity$2 = (function (from,to){
var from__$1 = ((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(from,to))?(function (){var x__4306__auto__ = (0);
var y__4307__auto__ = (from - (1));
return ((x__4306__auto__ > y__4307__auto__) ? x__4306__auto__ : y__4307__auto__);
})():from);
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.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"from","from",1815293044),from__$1,new cljs.core.Keyword(null,"to","to",192099007),to], null)], null);
}));

(nextjournal.clojure_mode.util.deletion.cljs$lang$maxFixedArity = 2);

nextjournal.clojure_mode.util.line_content_at = (function nextjournal$clojure_mode$util$line_content_at(state,from){
var obj__45053__auto__ = (function (){var parent__45060__auto__ = (state["doc"]);
var f__45061__auto__ = (parent__45060__auto__["lineAt"]);
return f__45061__auto__.call(parent__45060__auto__,from);
})();
var f__45054__auto__ = (obj__45053__auto__["slice"]);
return f__45054__auto__.call(obj__45053__auto__);
});
nextjournal.clojure_mode.util.map_cursor = (function nextjournal$clojure_mode$util$map_cursor(original_range,state,update_map){
if(cljs.core.map_QMARK_(update_map)){
} else {
throw (new Error("Assert failed: (map? update-map)"));
}

var map__56376 = nextjournal.clojure_mode.util.guard(update_map,cljs.core.map_QMARK_);
var map__56376__$1 = cljs.core.__destructure_map(map__56376);
var mapped = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__56376__$1,new cljs.core.Keyword("cursor","mapped","cursor/mapped",1625530272));
var cursor = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__56376__$1,new cljs.core.Keyword(null,"cursor","cursor",1011937484));
var from_to = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__56376__$1,new cljs.core.Keyword(null,"from-to","from-to",-640428401));
var range = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__56376__$1,new cljs.core.Keyword(null,"range","range",1639692286));
var changes = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__56376__$1,new cljs.core.Keyword(null,"changes","changes",1492088));
var change_desc = (cljs.core.truth_(changes)?state.changes(cljs.core.clj__GT_js(changes)):null);
var G__56377 = ({"range": (function (){var or__4223__auto__ = range;
if(cljs.core.truth_(or__4223__auto__)){
return or__4223__auto__;
} else {
var or__4223__auto____$1 = (cljs.core.truth_(mapped)?nextjournal.clojure_mode.selections.cursor(change_desc.mapPos(mapped)):(cljs.core.truth_(cursor)?nextjournal.clojure_mode.selections.cursor(cursor):(cljs.core.truth_(from_to)?nextjournal.clojure_mode.selections.range.cljs$core$IFn$_invoke$arity$2((from_to.cljs$core$IFn$_invoke$arity$1 ? from_to.cljs$core$IFn$_invoke$arity$1((0)) : from_to.call(null,(0))),(from_to.cljs$core$IFn$_invoke$arity$1 ? from_to.cljs$core$IFn$_invoke$arity$1((1)) : from_to.call(null,(1)))):null)));
if(cljs.core.truth_(or__4223__auto____$1)){
return or__4223__auto____$1;
} else {
return original_range;
}
}
})()});
if(cljs.core.truth_(change_desc)){
var obj56378 = G__56377;
(obj56378["changes"] = change_desc);

return obj56378;
} else {
return G__56377;
}
});
/**
 * Applies `f` to each range in `state` (see `changeByRange`)
 */
nextjournal.clojure_mode.util.update_ranges = (function nextjournal$clojure_mode$util$update_ranges(var_args){
var G__56381 = arguments.length;
switch (G__56381) {
case 2:
return nextjournal.clojure_mode.util.update_ranges.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));

break;
case 3:
return nextjournal.clojure_mode.util.update_ranges.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('')));

}
});

(nextjournal.clojure_mode.util.update_ranges.cljs$core$IFn$_invoke$arity$2 = (function (state,f){
return nextjournal.clojure_mode.util.update_ranges.cljs$core$IFn$_invoke$arity$3(state,null,f);
}));

(nextjournal.clojure_mode.util.update_ranges.cljs$core$IFn$_invoke$arity$3 = (function (state,tr_specs,f){
return state.update((function (p1__56379_SHARP_){
return applied_science.js_interop.extend_BANG_.cljs$core$IFn$_invoke$arity$2(p1__56379_SHARP_,tr_specs);
})(state.changeByRange((function (range){
var or__4223__auto__ = (function (){var temp__5757__auto__ = (f.cljs$core$IFn$_invoke$arity$1 ? f.cljs$core$IFn$_invoke$arity$1(range) : f.call(null,range));
if((temp__5757__auto__ == null)){
return null;
} else {
var result = temp__5757__auto__;
return nextjournal.clojure_mode.util.map_cursor(range,state,result);
}
})();
if(cljs.core.truth_(or__4223__auto__)){
return or__4223__auto__;
} else {
return ({"range": range});
}
}))));
}));

(nextjournal.clojure_mode.util.update_ranges.cljs$lang$maxFixedArity = 3);

nextjournal.clojure_mode.util.dispatch_changes = (function nextjournal$clojure_mode$util$dispatch_changes(state,dispatch,changes){
if(cljs.core.truth_(changes.empty)){
return null;
} else {
var G__56382 = state.update(({"changes": changes}));
return (dispatch.cljs$core$IFn$_invoke$arity$1 ? dispatch.cljs$core$IFn$_invoke$arity$1(G__56382) : dispatch.call(null,G__56382));
}
});
nextjournal.clojure_mode.util.update_lines = (function nextjournal$clojure_mode$util$update_lines(var_args){
var args__4835__auto__ = [];
var len__4829__auto___56523 = arguments.length;
var i__4830__auto___56524 = (0);
while(true){
if((i__4830__auto___56524 < len__4829__auto___56523)){
args__4835__auto__.push((arguments[i__4830__auto___56524]));

var G__56525 = (i__4830__auto___56524 + (1));
i__4830__auto___56524 = G__56525;
continue;
} else {
}
break;
}

var argseq__4836__auto__ = ((((2) < args__4835__auto__.length))?(new cljs.core.IndexedSeq(args__4835__auto__.slice((2)),(0),null)):null);
return nextjournal.clojure_mode.util.update_lines.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__4836__auto__);
});

(nextjournal.clojure_mode.util.update_lines.cljs$core$IFn$_invoke$arity$variadic = (function (state,f,p__56386){
var vec__56387 = p__56386;
var map__56390 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__56387,(0),null);
var map__56390__$1 = cljs.core.__destructure_map(map__56390);
var from = cljs.core.get.cljs$core$IFn$_invoke$arity$3(map__56390__$1,new cljs.core.Keyword(null,"from","from",1815293044),(0));
var to = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__56390__$1,new cljs.core.Keyword(null,"to","to",192099007));
var spec = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__56390__$1,new cljs.core.Keyword(null,"spec","spec",347520401));
var iterator = state.doc.iter();
var result = iterator.next();
var changes = [];
var from_pos = from;
var line_num = (1);
while(true){
var map__56404 = result;
var map__56404__$1 = (((((!((map__56404 == null))))?(((((map__56404.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__56404.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__56404):map__56404);
var done = (function (){var obj56406 = map__56404__$1;
var k56407 = "done";
if((function (){var obj56408 = obj56406;
return (((!((obj56408 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56407,obj56408)));
})()){
return (obj56406[k56407]);
} else {
return undefined;
}
})();
var lineBreak = (function (){var obj56409 = map__56404__$1;
var k56410 = "lineBreak";
if((function (){var obj56411 = obj56409;
return (((!((obj56411 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56410,obj56411)));
})()){
return (obj56409[k56410]);
} else {
return undefined;
}
})();
var value = (function (){var obj56412 = map__56404__$1;
var k56413 = "value";
if((function (){var obj56414 = obj56412;
return (((!((obj56414 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56413,obj56414)));
})()){
return (obj56412[k56413]);
} else {
return undefined;
}
})();
if(cljs.core.truth_((function (){var or__4223__auto__ = done;
if(cljs.core.truth_(or__4223__auto__)){
return or__4223__auto__;
} else {
return (from > to);
}
})())){
return state.update(applied_science.js_interop.extend_BANG_.cljs$core$IFn$_invoke$arity$2(({"changes": state.changes(changes)}),spec));
} else {
var G__56526 = iterator.next();
var G__56527 = (function (){var temp__5751__auto__ = (function (){var and__4221__auto__ = cljs.core.not(lineBreak);
if(and__4221__auto__){
return (f.cljs$core$IFn$_invoke$arity$3 ? f.cljs$core$IFn$_invoke$arity$3(from_pos,value,line_num) : f.call(null,from_pos,value,line_num));
} else {
return and__4221__auto__;
}
})();
if(cljs.core.truth_(temp__5751__auto__)){
var change = temp__5751__auto__;
var array56415 = changes;
array56415.push(change);

return array56415;
} else {
return changes;
}
})();
var G__56528 = (from_pos + ((value).length));
var G__56529 = (function (){var G__56416 = line_num;
if(cljs.core.truth_(lineBreak)){
return (G__56416 + (1));
} else {
return G__56416;
}
})();
result = G__56526;
changes = G__56527;
from_pos = G__56528;
line_num = G__56529;
continue;
}
break;
}
}));

(nextjournal.clojure_mode.util.update_lines.cljs$lang$maxFixedArity = (2));

/** @this {Function} */
(nextjournal.clojure_mode.util.update_lines.cljs$lang$applyTo = (function (seq56383){
var G__56384 = cljs.core.first(seq56383);
var seq56383__$1 = cljs.core.next(seq56383);
var G__56385 = cljs.core.first(seq56383__$1);
var seq56383__$2 = cljs.core.next(seq56383__$1);
var self__4816__auto__ = this;
return self__4816__auto__.cljs$core$IFn$_invoke$arity$variadic(G__56384,G__56385,seq56383__$2);
}));

/**
 * `f` will be called for each selected line with args [line, changes-array, range]
 * and should *mutate* changes-array
 */
nextjournal.clojure_mode.util.update_selected_lines = (function nextjournal$clojure_mode$util$update_selected_lines(state,f){
var at_line = cljs.core.atom.cljs$core$IFn$_invoke$arity$1((-1));
var doc = state.doc;
return state.changeByRange((function (p__56418){
var map__56419 = p__56418;
var map__56419__$1 = (((((!((map__56419 == null))))?(((((map__56419.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__56419.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__56419):map__56419);
var range = map__56419__$1;
var from = (function (){var obj56421 = map__56419__$1;
var k56422 = "from";
if((function (){var obj56423 = obj56421;
return (((!((obj56423 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56422,obj56423)));
})()){
return (obj56421[k56422]);
} else {
return undefined;
}
})();
var to = (function (){var obj56424 = map__56419__$1;
var k56425 = "to";
if((function (){var obj56426 = obj56424;
return (((!((obj56426 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56425,obj56426)));
})()){
return (obj56424[k56425]);
} else {
return undefined;
}
})();
var anchor = (function (){var obj56427 = map__56419__$1;
var k56428 = "anchor";
if((function (){var obj56429 = obj56427;
return (((!((obj56429 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56428,obj56429)));
})()){
return (obj56427[k56428]);
} else {
return undefined;
}
})();
var head = (function (){var obj56430 = map__56419__$1;
var k56431 = "head";
if((function (){var obj56432 = obj56430;
return (((!((obj56432 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56431,obj56432)));
})()){
return (obj56430[k56431]);
} else {
return undefined;
}
})();
var changes = [];
var line = doc.lineAt(from);
while(true){
var map__56441 = line;
var map__56441__$1 = (((((!((map__56441 == null))))?(((((map__56441.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__56441.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__56441):map__56441);
var line_number = (function (){var obj56443 = map__56441__$1;
var k56444 = "number";
if((function (){var obj56445 = obj56443;
return (((!((obj56445 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56444,obj56445)));
})()){
return (obj56443[k56444]);
} else {
return undefined;
}
})();
var line_to = (function (){var obj56446 = map__56441__$1;
var k56447 = "to";
if((function (){var obj56448 = obj56446;
return (((!((obj56448 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56447,obj56448)));
})()){
return (obj56446[k56447]);
} else {
return undefined;
}
})();
if((line.number > cljs.core.deref(at_line))){
cljs.core.reset_BANG_(at_line,line_number);

(f.cljs$core$IFn$_invoke$arity$3 ? f.cljs$core$IFn$_invoke$arity$3(line,changes,range) : f.call(null,line,changes,range));
} else {
}

var temp__5751__auto__ = (function (){var and__4221__auto__ = (to > line_to);
if(and__4221__auto__){
return nextjournal.clojure_mode.util.guard(doc.lineAt((line_to + (1))),((function (line,and__4221__auto__,map__56441,map__56441__$1,line_number,line_to,changes,map__56419,map__56419__$1,range,from,to,anchor,head,at_line,doc){
return (function (p1__56417_SHARP_){
return (p1__56417_SHARP_.number > line_number);
});})(line,and__4221__auto__,map__56441,map__56441__$1,line_number,line_to,changes,map__56419,map__56419__$1,range,from,to,anchor,head,at_line,doc))
);
} else {
return and__4221__auto__;
}
})();
if(cljs.core.truth_(temp__5751__auto__)){
var next_line = temp__5751__auto__;
var G__56531 = next_line;
line = G__56531;
continue;
} else {
var change_set = state.changes(changes);
return ({"changes": changes, "range": module$node_modules$$codemirror$state$dist$index_cjs.EditorSelection.range(change_set.mapPos(anchor,(1)),change_set.mapPos(head,(1)))});
}
break;
}
}));
});
/**
 * `f` will be called for each changed line with args [line, changes-array]
 * and should *mutate* changes-array. Selections will be mapped through the resulting changeset.
 */
nextjournal.clojure_mode.util.iter_changed_lines = (function nextjournal$clojure_mode$util$iter_changed_lines(p__56449,f){
var map__56450 = p__56449;
var map__56450__$1 = (((((!((map__56450 == null))))?(((((map__56450.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__56450.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__56450):map__56450);
var tr = map__56450__$1;
var map__56451 = (function (){var obj56453 = map__56450__$1;
var k56454 = "state";
if((function (){var obj56455 = obj56453;
return (((!((obj56455 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56454,obj56455)));
})()){
return (obj56453[k56454]);
} else {
return undefined;
}
})();
var map__56451__$1 = (((((!((map__56451 == null))))?(((((map__56451.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__56451.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__56451):map__56451);
var state = map__56451__$1;
var doc = (function (){var obj56457 = map__56451__$1;
var k56458 = "doc";
if((function (){var obj56459 = obj56457;
return (((!((obj56459 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56458,obj56459)));
})()){
return (obj56457[k56458]);
} else {
return undefined;
}
})();
var changes = (function (){var obj56460 = map__56450__$1;
var k56461 = "changes";
if((function (){var obj56462 = obj56460;
return (((!((obj56462 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56461,obj56462)));
})()){
return (obj56460[k56461]);
} else {
return undefined;
}
})();
var effects = (function (){var obj56463 = map__56450__$1;
var k56464 = "effects";
if((function (){var obj56465 = obj56463;
return (((!((obj56465 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56464,obj56465)));
})()){
return (obj56463[k56464]);
} else {
return undefined;
}
})();
var selection = (function (){var obj56466 = map__56450__$1;
var k56467 = "selection";
if((function (){var obj56468 = obj56466;
return (((!((obj56468 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56467,obj56468)));
})()){
return (obj56466[k56467]);
} else {
return undefined;
}
})();
var at_line = cljs.core.atom.cljs$core$IFn$_invoke$arity$1((-1));
var next_changes = [];
var _ = changes.iterChanges((function (from_a,to_a,from_b,to_b,inserted){
var map__56469 = doc.lineAt(from_b);
var map__56469__$1 = (((((!((map__56469 == null))))?(((((map__56469.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__56469.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__56469):map__56469);
var line = map__56469__$1;
var line_number = (function (){var obj56471 = map__56469__$1;
var k56472 = "number";
if((function (){var obj56473 = obj56471;
return (((!((obj56473 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56472,obj56473)));
})()){
return (obj56471[k56472]);
} else {
return undefined;
}
})();
var line_to = (function (){var obj56474 = map__56469__$1;
var k56475 = "to";
if((function (){var obj56476 = obj56474;
return (((!((obj56476 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56475,obj56476)));
})()){
return (obj56474[k56475]);
} else {
return undefined;
}
})();
var line__$1 = line;
while(true){
if((line_number > cljs.core.deref(at_line))){
cljs.core.reset_BANG_(at_line,line_number);

(f.cljs$core$IFn$_invoke$arity$2 ? f.cljs$core$IFn$_invoke$arity$2(line__$1,next_changes) : f.call(null,line__$1,next_changes));
} else {
}

if((to_b <= line_to)){
return null;
} else {
var next_line = doc.lineAt((line_to + (1)));
if(cljs.core.truth_((function (){var and__4221__auto__ = next_line;
if(cljs.core.truth_(and__4221__auto__)){
return (next_line.number > line__$1.number);
} else {
return and__4221__auto__;
}
})())){
var G__56532 = next_line;
line__$1 = G__56532;
continue;
} else {
return null;
}
}
break;
}
}));
var next_changeset = state.changes(next_changes);
if(cljs.core.seq(next_changes)){
var G__56477 = (function (){var obj56478 = (function (){var obj56479 = tr;
if((!((obj56479 == null)))){
var out56480 = ({});
var k__44961__auto___56533 = "annotations";
if(applied_science.js_interop.impl.in_QMARK__STAR_(k__44961__auto___56533,obj56479)){
var obj56483_56534 = out56480;
(obj56483_56534[k__44961__auto___56533] = (obj56479[k__44961__auto___56533]));

} else {
}

var k__44961__auto___56535 = "scrollIntoView";
if(applied_science.js_interop.impl.in_QMARK__STAR_(k__44961__auto___56535,obj56479)){
var obj56484_56536 = out56480;
(obj56484_56536[k__44961__auto___56535] = (obj56479[k__44961__auto___56535]));

} else {
}

var k__44961__auto___56537 = "reconfigure";
if(applied_science.js_interop.impl.in_QMARK__STAR_(k__44961__auto___56537,obj56479)){
var obj56485_56538 = out56480;
(obj56485_56538[k__44961__auto___56537] = (obj56479[k__44961__auto___56537]));

} else {
}

return out56480;
} else {
return ({});
}
})();
var obj56488 = (((!((obj56478 == null))))?obj56478:({}));
(obj56488["changes"] = changes.compose(next_changeset));

return obj56488;
})();
var G__56477__$1 = (cljs.core.truth_(selection)?(function (){var obj56491 = G__56477;
var obj56492 = (((!((obj56491 == null))))?obj56491:({}));
(obj56492["selection"] = state.selection.map(next_changeset));

return obj56492;
})():G__56477);
if(cljs.core.truth_(effects)){
var obj56495 = G__56477__$1;
var obj56496 = (((!((obj56495 == null))))?obj56495:({}));
(obj56496["effects"] = module$node_modules$$codemirror$state$dist$index_cjs.StateEffect.mapEffects(effects,next_changeset));

return obj56496;
} else {
return G__56477__$1;
}
} else {
return tr;
}
});
nextjournal.clojure_mode.util.something_selected_QMARK_ = (function nextjournal$clojure_mode$util$something_selected_QMARK_(p__56500){
var map__56501 = p__56500;
var map__56501__$1 = (((((!((map__56501 == null))))?(((((map__56501.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__56501.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__56501):map__56501);
var map__56502 = (function (){var obj56504 = map__56501__$1;
var k56505 = "selection";
if((function (){var obj56506 = obj56504;
return (((!((obj56506 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56505,obj56506)));
})()){
return (obj56504[k56505]);
} else {
return undefined;
}
})();
var map__56502__$1 = (((((!((map__56502 == null))))?(((((map__56502.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__56502.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__56502):map__56502);
var ranges = (function (){var obj56508 = map__56502__$1;
var k56509 = "ranges";
if((function (){var obj56510 = obj56508;
return (((!((obj56510 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56509,obj56510)));
})()){
return (obj56508[k56509]);
} else {
return undefined;
}
})();
return (!(cljs.core.every_QMARK_((function (p1__56499_SHARP_){
return p1__56499_SHARP_.empty;
}),ranges)));
});
nextjournal.clojure_mode.util.range_str = (function nextjournal$clojure_mode$util$range_str(state,p__56511){
var map__56512 = p__56511;
var map__56512__$1 = (((((!((map__56512 == null))))?(((((map__56512.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__56512.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__56512):map__56512);
var selection = map__56512__$1;
var from = (function (){var obj56514 = map__56512__$1;
var k56515 = "from";
if((function (){var obj56516 = obj56514;
return (((!((obj56516 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56515,obj56516)));
})()){
return (obj56514[k56515]);
} else {
return undefined;
}
})();
var to = (function (){var obj56517 = map__56512__$1;
var k56518 = "to";
if((function (){var obj56519 = obj56517;
return (((!((obj56519 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k56518,obj56519)));
})()){
return (obj56517[k56518]);
} else {
return undefined;
}
})();
return cljs.core.str.cljs$core$IFn$_invoke$arity$1((function (){var parent__45060__auto__ = (state["doc"]);
var f__45061__auto__ = (parent__45060__auto__["slice"]);
return f__45061__auto__.call(parent__45060__auto__,from,to);
})());
});

//# sourceMappingURL=nextjournal.clojure_mode.util.js.map
