"use strict";(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[8885],{88885:(e,n,t)=>{t.r(n);var i=t(85704),r=t(26131);i.defineOption("autoCloseLatex",!1,(function(e,n,t){if(t&&e.removeKeyMap("autoCloseLatex"),n){var l={name:"autoCloseLatex",Enter:function(e){return function(e){var n,t;if(e.getOption("disableInput"))return i.Pass;var l=[],c=[],o=!1,s=0,u=function(e){l.push("\n");var n={line:e.line+1,ch:0};s+=1,c.push({head:n,anchor:n})};try{for(var f=function(e){var n="function"==typeof Symbol&&Symbol.iterator,t=n&&e[n],i=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}(e.listSelections()),h=f.next();!h.done;h=f.next()){var d=h.value;if(!d.empty())return i.Pass;var p=d.head,g=e.getTokenAt(p);if("stex"===i.innerMode(e.getMode(),g.state).mode.name)if("bracket"===g.type||"}"===g.string)if(e.getTokenAt({line:p.line,ch:p.ch+1}).start===g.start){var v=e.getLine(p.line),b=v.lastIndexOf("\\begin{");if(-1!==b){var y=v.slice(b+"\\begin{".length,p.ch-1);-1!=(b=y.indexOf("}"))&&(y=y.slice(0,b));var m="\\end{".concat(y,"}"),x=e.getRange({line:p.line+1,ch:0},{line:p.line+1e3,ch:0});b=x.indexOf("\\end{".concat(y,"}"));var k=x.indexOf("\\begin{".concat(y,"}"));if(-1!==b&&(-1===k||k>b))u(p);else{var O=a(y);l.push("".concat(O,"\n").concat(m,"\n"));var w={line:p.line+s+1,ch:O.length};s+=(0,r.splitlines)(l[l.length-1]).length+1,c.push({head:w,anchor:w}),o=!0}}else u(p)}else u(p);else u(p);else u(p)}}catch(e){n={error:e}}finally{try{h&&!h.done&&(t=f.return)&&t.call(f)}finally{if(n)throw n.error}}if(!o)return i.Pass;e.replaceSelections(l),e.setSelections(c)}(e)}};e.addKeyMap(l)}}));var a=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"}}}}]);