import "./cljs_env.js";
goog.provide('clojure_eval.editor');
var module$node_modules$$codemirror$language$dist$index_cjs=shadow.js.require("module$node_modules$$codemirror$language$dist$index_cjs", {});
var module$node_modules$$codemirror$history$dist$index_cjs=shadow.js.require("module$node_modules$$codemirror$history$dist$index_cjs", {});
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.editor.theme = module$node_modules$$codemirror$view$dist$index_cjs.EditorView.theme(({".cm-content":({"white-space":"pre-wrap","padding":"10px 0"}),"&.cm-focused":({"outline":"none"}),".cm-line":({"padding":"0 10px","line-height":"1.6","font-size":"16px","font-family":"var(--code-font)"}),".cm-matchingBracket":({"border-bottom":"2px solid var(--black)","color":"inherit"}),".cm-gutters":({"background":"transparent","border":"none"}),".cm-gutterElement":({"margin-left":"5px"}),".cm-cursor":({"visibility":"hidden"}),"&.cm-focused .cm-cursor":({"visibility":"visible"})}));
if((typeof clojure_eval !== 'undefined') && (typeof clojure_eval.editor !== 'undefined') && (typeof clojure_eval.editor.extensions !== 'undefined')){
} else {
clojure_eval.editor.extensions = [clojure_eval.editor.theme,module$node_modules$$codemirror$history$dist$index_cjs.history(),module$node_modules$$codemirror$language$dist$index_cjs.syntaxHighlighting(module$node_modules$$codemirror$language$dist$index_cjs.defaultHighlightStyle),module$node_modules$$codemirror$view$dist$index_cjs.drawSelection(),module$node_modules$$codemirror$language$dist$index_cjs.foldGutter(),module$node_modules$$codemirror$state$dist$index_cjs.EditorState.allowMultipleSelections.of(true),nextjournal.clojure_mode.default_extensions,module$node_modules$$codemirror$view$dist$index_cjs.keymap.of(nextjournal.clojure_mode.complete_keymap),module$node_modules$$codemirror$view$dist$index_cjs.keymap.of(module$node_modules$$codemirror$history$dist$index_cjs.historyKeymap)];
}
clojure_eval.editor.make_state = (function clojure_eval$editor$make_state(extensions,doc){
var vec__59080 = cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (p__59083,match){
var vec__59084 = p__59083;
var doc__$1 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__59084,(0),null);
var ranges = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__59084,(1),null);
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(match,"|")){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [doc__$1,cljs.core.conj.cljs$core$IFn$_invoke$arity$2(ranges,module$node_modules$$codemirror$state$dist$index_cjs.EditorSelection.cursor(((doc__$1).length)))], null);
} else {
if(clojure.string.starts_with_QMARK_(match,"<")){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [[doc__$1,cljs.core.subs.cljs$core$IFn$_invoke$arity$3(match,(1),(cljs.core.count(match) - (1)))].join(''),cljs.core.conj.cljs$core$IFn$_invoke$arity$2(ranges,module$node_modules$$codemirror$state$dist$index_cjs.EditorSelection.range(((doc__$1).length),(((doc__$1).length) + (cljs.core.count(match) - (2)))))], null);
} else {
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [[doc__$1,cljs.core.str.cljs$core$IFn$_invoke$arity$1(match)].join(''),ranges], null);

}
}
}),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, ["",cljs.core.PersistentVector.EMPTY], null),cljs.core.re_seq(/\||<[^>]*?>|[^<>|]+/,doc));
var doc__$1 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__59080,(0),null);
var ranges = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__59080,(1),null);
return module$node_modules$$codemirror$state$dist$index_cjs.EditorState.create(({"doc": doc__$1, "selection": ((cljs.core.seq(ranges))?module$node_modules$$codemirror$state$dist$index_cjs.EditorSelection.create(cljs.core.to_array(ranges)):undefined), "extensions": (function (){var G__59087 = [module$node_modules$$codemirror$state$dist$index_cjs.EditorState.allowMultipleSelections.of(true)];
if(cljs.core.truth_(extensions)){
var array59088 = G__59087;
array59088.push(extensions);

return array59088;
} else {
return G__59087;
}
})()}));
});
clojure_eval.editor.inlineEval = (function clojure_eval$editor$inlineEval(source){
return cljs.core.reset_BANG_(clojure_eval.sci._BANG_viewer,(new module$node_modules$$codemirror$view$dist$index_cjs.EditorView(({"state":clojure_eval.editor.make_state([clojure_eval.editor.extensions].concat([clojure_eval.sci.extension()]),source),"parent":document.querySelector("#app")}))));
});
clojure_eval.editor.clojure = (function clojure_eval$editor$clojure(){
return nextjournal.clojure_mode.language_support;
});

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