import{r as e}from"./chunk-CFjPhJqf.js";var t=e({stex:()=>r,stexMath:()=>i});function n(e){function t(e,t){e.cmdState.push(t)}function n(e){return e.cmdState.length>0?e.cmdState[e.cmdState.length-1]:null}function r(e){var t=e.cmdState.pop();t&&t.closeBracket()}function i(e){for(var t=e.cmdState,n=t.length-1;n>=0;n--){var r=t[n];if(r.name!=`DEFAULT`)return r}return{styleIdentifier:function(){return null}}}function a(e,t,n){return function(){this.name=e,this.bracketNo=0,this.style=t,this.styles=n,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,`bracket`},this.closeBracket=function(){}}}var o={};o.importmodule=a(`importmodule`,`tag`,[`string`,`builtin`]),o.documentclass=a(`documentclass`,`tag`,[``,`atom`]),o.usepackage=a(`usepackage`,`tag`,[`atom`]),o.begin=a(`begin`,`tag`,[`atom`]),o.end=a(`end`,`tag`,[`atom`]),o.label=a(`label`,`tag`,[`atom`]),o.ref=a(`ref`,`tag`,[`atom`]),o.eqref=a(`eqref`,`tag`,[`atom`]),o.cite=a(`cite`,`tag`,[`atom`]),o.bibitem=a(`bibitem`,`tag`,[`atom`]),o.Bibitem=a(`Bibitem`,`tag`,[`atom`]),o.RBibitem=a(`RBibitem`,`tag`,[`atom`]),o.DEFAULT=function(){this.name=`DEFAULT`,this.style=`tag`,this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function s(e,t){e.f=t}function c(e,r){var a;if(e.match(/^\\[a-zA-Z@\xc0-\u1fff\u2060-\uffff]+/)){var c=e.current().slice(1);return a=o.hasOwnProperty(c)?o[c]:o.DEFAULT,a=new a,t(r,a),s(r,u),a.style}if(e.match(/^\\[$&%#{}_]/)||e.match(/^\\[,;!\/\\]/))return`tag`;if(e.match(`\\[`))return s(r,function(e,t){return l(e,t,`\\]`)}),`keyword`;if(e.match(`\\(`))return s(r,function(e,t){return l(e,t,`\\)`)}),`keyword`;if(e.match(`$$`))return s(r,function(e,t){return l(e,t,`$$`)}),`keyword`;if(e.match(`$`))return s(r,function(e,t){return l(e,t,`$`)}),`keyword`;var d=e.next();if(d==`%`)return e.skipToEnd(),`comment`;if(d==`}`||d==`]`){if(a=n(r),a)a.closeBracket(d),s(r,u);else return`error`;return`bracket`}else if(d==`{`||d==`[`)return a=o.DEFAULT,a=new a,t(r,a),`bracket`;else if(/\d/.test(d))return e.eatWhile(/[\w.%]/),`atom`;else return e.eatWhile(/[\w\-_]/),a=i(r),a.name==`begin`&&(a.argument=e.current()),a.styleIdentifier()}function l(e,t,n){if(e.eatSpace())return null;if(n&&e.match(n))return s(t,c),`keyword`;if(e.match(/^\\[a-zA-Z@]+/))return`tag`;if(e.match(/^[a-zA-Z]+/))return`variableName.special`;if(e.match(/^\\[$&%#{}_]/)||e.match(/^\\[,;!\/]/)||e.match(/^[\^_&]/))return`tag`;if(e.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(e.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return`number`;var r=e.next();return r==`{`||r==`}`||r==`[`||r==`]`||r==`(`||r==`)`?`bracket`:r==`%`?(e.skipToEnd(),`comment`):`error`}function u(e,t){var i=e.peek(),a;return i==`{`||i==`[`?(a=n(t),a.openBracket(i),e.eat(i),s(t,c),`bracket`):/[ \t\r]/.test(i)?(e.eat(i),null):(s(t,c),r(t),c(e,t))}return{name:`stex`,startState:function(){return{cmdState:[],f:e?function(e,t){return l(e,t)}:c}},copyState:function(e){return{cmdState:e.cmdState.slice(),f:e.f}},token:function(e,t){return t.f(e,t)},blankLine:function(e){e.f=c,e.cmdState.length=0},languageData:{commentTokens:{line:`%`}}}}var r=n(!1),i=n(!0);export{t as n,r as t};