(()=>{"use strict";var e={d:(o,t)=>{for(var a in t)e.o(t,a)&&!e.o(o,a)&&Object.defineProperty(o,a,{enumerable:!0,get:t[a]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},o={};e.r(o),e.d(o,{BegingroupStack:()=>R,begingroupStack:()=>O});var t={};e.r(t),e.d(t,{BegingroupMethods:()=>T});var a={};e.r(a),e.d(a,{BegingroupConfiguration:()=>C});const n=("undefined"!=typeof window?window:global).MathJax._.components.global,i=(n.GLOBAL,n.isObject,n.combineConfig,n.combineDefaults,n.combineWithMathJax),r=(n.MathJax,MathJax._.input.tex.HandlerTypes),s=r.ConfigurationType,g=r.HandlerType,l=MathJax._.input.tex.Configuration,p=l.Configuration,u=(l.ConfigurationHandler,l.ParserConfiguration,MathJax._.input.tex.TokenMap),d=(u.parseResult,u.AbstractTokenMap,u.RegExpMap,u.AbstractParseMap,u.CharacterMap,u.DelimiterMap),b=(u.MacroMap,u.CommandMap),h=u.EnvironmentMap,M=MathJax._.input.tex.MapHandler,E=M.MapHandler,c=(M.SubHandler,M.SubHandlers,MathJax._.input.tex.TexError.default),N=MathJax._.input.tex.newcommand.NewcommandUtil,f=N.NewcommandTables,x=N.NewcommandPriority,m=(N.NewcommandUtil,MathJax._.input.tex.ParseMethods.default);class R{constructor(e){this.i=x,this.top=x,this.base=x,this.MARKER=Symbol("marker"),this.handlers=e.handlers,this.getGlobal()}getGlobal(){this.global={[f.NEW_DELIMITER]:E.getMap(f.NEW_DELIMITER),[f.NEW_ENVIRONMENT]:E.getMap(f.NEW_ENVIRONMENT),[f.NEW_COMMAND]:E.getMap(f.NEW_COMMAND)}}checkGlobal(e,o){for(const t of o){const o=e.shift(),a=this.handlers.get(R.handlerMap[t]);let n;this.global[t].add(o,this.MARKER);do{const e=a.applicable(o);n=e.lookup(o),e.remove(o)}while(n&&n!==this.MARKER)}return o.map((e=>this.global[e]))}push(){new d(f.NEW_DELIMITER,m.delimiter,{}),new b(f.NEW_COMMAND,{}),new h(f.NEW_ENVIRONMENT,m.environment,{}),this.handlers.add(R.handlerConfig,{},--this.i)}pop(){if(this.i===this.base)throw new c("MissingBegingroup","Missing \\begingroup or extra \\endgroup");this.handlers.remove(R.handlerConfig,{});for(const e of[f.NEW_COMMAND,f.NEW_ENVIRONMENT,f.NEW_DELIMITER])E.register(this.handlers.retrieve(e));this.i++}finish(){this.top=this.i}remove(){for(;this.i{o.parseOptions.packageData.set("begingroup",{stack:new R(o.parseOptions)})},[s.OPTIONS]:{begingroup:{allowGlobal:["let","def","newcommand","DeclareMathOperator","Newextarrow"]}},[s.PREPROCESSORS]:[({data:e})=>O(e).remove()],[s.POSTPROCESSORS]:[({data:e})=>O(e).finish()]});MathJax.loader&&MathJax.loader.checkVersion("[tex]/begingroup","4.0.0","tex-extension"),i({_:{input:{tex:{begingroup:{BegingroupConfiguration:a,BegingroupMethods:t,BegingroupStack:o}}}}})})();