"use strict";(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[4967],{54967:(e,n,t)=>{t.r(n);var i=t(33638),a=t(24620);i.defineOption("autoCloseLatex",!1,(function(e,n,t){if(t&&e.removeKeyMap("autoCloseLatex"),n){var c={name:"autoCloseLatex",Enter:function(e){return function(e){if(e.getOption("disableInput"))return i.Pass;var n=[],t=[],c=!1,l=0,s=function(e){n.push("\n");var i={line:e.line+1,ch:0};l+=1,t.push({head:i,anchor:i})},o=!0,u=!1,f=void 0;try{for(var h,d=e.listSelections()[Symbol.iterator]();!(o=(h=d.next()).done);o=!0){var g=h.value;if(!g.empty())return i.Pass;var p=g.head,v=e.getTokenAt(p);if("stex"===i.innerMode(e.getMode(),v.state).mode.name)if("bracket"===v.type||"}"===v.string)if(e.getTokenAt({line:p.line,ch:p.ch+1}).start===v.start){var b=e.getLine(p.line),m=b.lastIndexOf("\\begin{");if(-1!==m){var y=b.slice(m+"\\begin{".length,p.ch-1);-1!=(m=y.indexOf("}"))&&(y=y.slice(0,m));var x="\\end{".concat(y,"}"),k=e.getRange({line:p.line+1,ch:0},{line:p.line+1e3,ch:0});m=k.indexOf("\\end{".concat(y,"}"));var O=k.indexOf("\\begin{".concat(y,"}"));if(-1!==m&&(-1===O||O>m))s(p);else{var C=r(y);n.push("".concat(C,"\n").concat(x,"\n"));var w={line:p.line+l+1,ch:C.length};l+=(0,a.splitlines)(n[n.length-1]).length+1,t.push({head:w,anchor:w}),c=!0}}else s(p)}else s(p);else s(p);else s(p)}}catch(e){u=!0,f=e}finally{try{o||null==d.return||d.return()}finally{if(u)throw f}}if(!c)return i.Pass;e.replaceSelections(n),e.setSelections(t)}(e)}};e.addKeyMap(c)}}));var r=function(e){switch(e){case"enumerate":case"itemize":case"list":return"\n\\item First ";case"description":return"\n\\item [label] First  ";case"figure":return"\n% body of the figure\n\\caption{figure title}";default:return"\n"}}}}]);