import "./cljs_env.js";
shadow$provide.module$node_modules$$codemirror$gutter$dist$index_cjs=function(global,require,module,exports){function gutters(config){let result=[gutterView,baseTheme];config&&!1===config.fixed&&result.push(unfixGutters.of(!0));return result}function asArray(val){return Array.isArray(val)?val:[val]}function advanceCursor(cursor,collect,pos){for(;cursor.value&&cursor.from<=pos;)cursor.from==pos&&collect.push(cursor.value),cursor.next()}function formatNumber(view,number){return view.state.facet(lineNumberConfig).formatNumber(number,
view.state)}function maxLineNumber(lines){let last=9;for(;last<lines;)last=10*last+9;return last}Object.defineProperty(exports,"__esModule",{value:!0});var view$jscomp$0=require("module$node_modules$$codemirror$view$dist$index_cjs"),rangeset=require("module$node_modules$$codemirror$rangeset$dist$index_cjs"),state$jscomp$0=require("module$node_modules$$codemirror$state$dist$index_cjs");class GutterMarker extends rangeset.RangeValue{compare(other){return this==other||this.constructor==other.constructor&&
this.eq(other)}eq(other){return!1}destroy(dom){}}GutterMarker.prototype.elementClass="";GutterMarker.prototype.toDOM=void 0;GutterMarker.prototype.mapMode=state$jscomp$0.MapMode.TrackBefore;GutterMarker.prototype.startSide=GutterMarker.prototype.endSide=-1;GutterMarker.prototype.point=!0;const gutterLineClass=state$jscomp$0.Facet.define(),defaults={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>rangeset.RangeSet.empty,lineMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,
domEventHandlers:{}},activeGutters=state$jscomp$0.Facet.define(),baseTheme=view$jscomp$0.EditorView.baseTheme({".cm-gutters":{display:"flex",height:"100%",boxSizing:"border-box",left:0,zIndex:200},"\x26light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#999",borderRight:"1px solid #ddd"},"\x26dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},
".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"\x26light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"\x26dark .cm-activeLineGutter":{backgroundColor:"#222227"}}),unfixGutters=state$jscomp$0.Facet.define({combine:values=>values.some(x=>x)}),gutterView=view$jscomp$0.ViewPlugin.fromClass(class{constructor(view){this.view=view;this.prevViewport=view.viewport;this.dom=document.createElement("div");this.dom.className="cm-gutters";
this.dom.setAttribute("aria-hidden","true");this.dom.style.minHeight=this.view.contentHeight+"px";this.gutters=view.state.facet(activeGutters).map(conf=>new SingleGutterView(view,conf));for(let gutter of this.gutters)this.dom.appendChild(gutter.dom);if(this.fixed=!view.state.facet(unfixGutters))this.dom.style.position="sticky";this.syncGutters(!1);view.scrollDOM.insertBefore(this.dom,view.contentDOM)}update(update){if(this.updateGutters(update)){let vpA=this.prevViewport,vpB=update.view.viewport;
this.syncGutters(Math.min(vpA.to,vpB.to)-Math.max(vpA.from,vpB.from)<.8*(vpB.to-vpB.from))}update.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px");this.view.state.facet(unfixGutters)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"");this.prevViewport=update.view.viewport}syncGutters(detach){let after=this.dom.nextSibling;detach&&this.dom.remove();let lineClasses=rangeset.RangeSet.iter(this.view.state.facet(gutterLineClass),this.view.viewport.from),
classSet=[],contexts=this.gutters.map(gutter=>new UpdateContext(gutter,this.view.viewport,-this.view.documentPadding.top));for(let line of this.view.viewportLineBlocks){let text;if(Array.isArray(line.type))for(let b of line.type){if(b.type==view$jscomp$0.BlockType.Text){text=b;break}}else text=line.type==view$jscomp$0.BlockType.Text?line:void 0;if(text){classSet.length&&(classSet=[]);advanceCursor(lineClasses,classSet,line.from);for(let cx of contexts)cx.line(this.view,text,classSet)}}for(let cx of contexts)cx.finish();
detach&&this.view.scrollDOM.insertBefore(this.dom,after)}updateGutters(update){let prev=update.startState.facet(activeGutters);var cur=update.state.facet(activeGutters);let change=update.docChanged||update.heightChanged||update.viewportChanged||!rangeset.RangeSet.eq(update.startState.facet(gutterLineClass),update.state.facet(gutterLineClass),update.view.viewport.from,update.view.viewport.to);if(prev==cur)for(var gutter of this.gutters)gutter.update(update)&&(change=!0);else{change=!0;gutter=[];for(let conf of cur)cur=
prev.indexOf(conf),0>cur?gutter.push(new SingleGutterView(this.view,conf)):(this.gutters[cur].update(update),gutter.push(this.gutters[cur]));for(let g of this.gutters)g.dom.remove(),0>gutter.indexOf(g)&&g.destroy();for(let g of gutter)this.dom.appendChild(g.dom);this.gutters=gutter}return change}destroy(){for(let view of this.gutters)view.destroy();this.dom.remove()}},{provide:view$jscomp$0.PluginField.scrollMargins.from(value=>0!=value.gutters.length&&value.fixed?value.view.textDirection==view$jscomp$0.Direction.LTR?
{left:value.dom.offsetWidth}:{right:value.dom.offsetWidth}:null)});class UpdateContext{constructor(gutter,viewport,height){this.gutter=gutter;this.height=height;this.localMarkers=[];this.i=0;this.cursor=rangeset.RangeSet.iter(gutter.markers,viewport.from)}line(view,line,extraMarkers){this.localMarkers.length&&(this.localMarkers=[]);advanceCursor(this.cursor,this.localMarkers,line.from);extraMarkers=extraMarkers.length?this.localMarkers.concat(extraMarkers):this.localMarkers;var forLine=this.gutter.config.lineMarker(view,
line,extraMarkers);forLine&&extraMarkers.unshift(forLine);forLine=this.gutter;if(0!=extraMarkers.length||forLine.config.renderEmptyElements){var above=line.top-this.height;this.i==forLine.elements.length?(view=new GutterElement(view,line.height,above,extraMarkers),forLine.elements.push(view),forLine.dom.appendChild(view.dom)):forLine.elements[this.i].update(view,line.height,above,extraMarkers);this.height=line.bottom;this.i++}}finish(){let gutter=this.gutter;for(;gutter.elements.length>this.i;){let last=
gutter.elements.pop();gutter.dom.removeChild(last.dom);last.destroy()}}}class SingleGutterView{constructor(view,config){this.view=view;this.config=config;this.elements=[];this.spacer=null;this.dom=document.createElement("div");this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let prop in config.domEventHandlers)this.dom.addEventListener(prop,event=>{let line=view.lineBlockAtHeight(event.clientY-view.documentTop);config.domEventHandlers[prop](view,line,event)&&event.preventDefault()});
this.markers=asArray(config.markers(view));config.initialSpacer&&(this.spacer=new GutterElement(view,0,0,[config.initialSpacer(view)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(update){let prevMarkers=this.markers;this.markers=asArray(this.config.markers(update.view));if(this.spacer&&this.config.updateSpacer){var updated=this.config.updateSpacer(this.spacer.markers[0],update);updated!=this.spacer.markers[0]&&this.spacer.update(update.view,
0,0,[updated])}updated=update.view.viewport;return!rangeset.RangeSet.eq(this.markers,prevMarkers,updated.from,updated.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(update):!1)}destroy(){for(let elt of this.elements)elt.destroy()}}class GutterElement{constructor(view,height,above,markers){this.height=-1;this.above=0;this.markers=[];this.dom=document.createElement("div");this.update(view,height,above,markers)}update(view,height,above,markers){this.height!=height&&(this.dom.style.height=
(this.height=height)+"px");this.above!=above&&(this.dom.style.marginTop=(this.above=above)?above+"px":"");a:if(height=this.markers,height.length!=markers.length)height=!1;else{for(above=0;above<height.length;above++)if(!height[above].compare(markers[above])){height=!1;break a}height=!0}height||this.setMarkers(view,markers)}setMarkers(view,markers){let cls="cm-gutterElement",domPos=this.dom.firstChild;for(let iNew=0,iOld=0;;){let skipTo=iOld,marker=iNew<markers.length?markers[iNew++]:null,matched=
!1;if(marker){var c=marker.elementClass;c&&(cls+=" "+c);for(c=iOld;c<this.markers.length;c++)if(this.markers[c].compare(marker)){skipTo=c;matched=!0;break}}else skipTo=this.markers.length;for(;iOld<skipTo;)c=this.markers[iOld++],c.toDOM&&(c.destroy(domPos),c=domPos.nextSibling,domPos.remove(),domPos=c);if(!marker)break;marker.toDOM&&(matched?domPos=domPos.nextSibling:this.dom.insertBefore(marker.toDOM(view),domPos));matched&&iOld++}this.dom.className=cls;this.markers=markers}destroy(){this.setMarkers(null,
[])}}const lineNumberMarkers=state$jscomp$0.Facet.define(),lineNumberConfig=state$jscomp$0.Facet.define({combine(values){return state$jscomp$0.combineConfig(values,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(a,b){a=Object.assign({},a);for(let event$jscomp$0 in b){let exists=a[event$jscomp$0],add=b[event$jscomp$0];a[event$jscomp$0]=exists?(view,line,event)=>exists(view,line,event)||add(view,line,event):add}return a}})}});class NumberMarker extends GutterMarker{constructor(number){super();
this.number=number}eq(other){return this.number==other.number}toDOM(){return document.createTextNode(this.number)}}const lineNumberGutter=activeGutters.compute([lineNumberConfig],state=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(view){return view.state.facet(lineNumberMarkers)},lineMarker(view,line,others){return others.some(m=>m.toDOM)?null:new NumberMarker(formatNumber(view,view.state.doc.lineAt(line.from).number))},lineMarkerChange:update=>update.startState.facet(lineNumberConfig)!=
update.state.facet(lineNumberConfig),initialSpacer(view){return new NumberMarker(formatNumber(view,maxLineNumber(view.state.doc.lines)))},updateSpacer(spacer,update){update=formatNumber(update.view,maxLineNumber(update.view.state.doc.lines));return update==spacer.number?spacer:new NumberMarker(update)},domEventHandlers:state.facet(lineNumberConfig).domEventHandlers})),activeLineGutterMarker=new class extends GutterMarker{constructor(){super(...arguments);this.elementClass="cm-activeLineGutter"}},
activeLineGutterHighlighter=gutterLineClass.compute(["selection"],state=>{let marks=[],last=-1;for(let range of state.selection.ranges)if(range.empty){let linePos=state.doc.lineAt(range.head).from;linePos>last&&(last=linePos,marks.push(activeLineGutterMarker.range(linePos)))}return rangeset.RangeSet.of(marks)});exports.GutterMarker=GutterMarker;exports.gutter=function(config){return[gutters(),activeGutters.of(Object.assign(Object.assign({},defaults),config))]};exports.gutterLineClass=gutterLineClass;
exports.gutters=gutters;exports.highlightActiveLineGutter=function(){return activeLineGutterHighlighter};exports.lineNumberMarkers=lineNumberMarkers;exports.lineNumbers=function(config={}){return[lineNumberConfig.of(config),gutters(),lineNumberGutter]}}
//# sourceMappingURL=module$node_modules$$codemirror$gutter$dist$index_cjs.js.map
