!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["lua-in-js"]=t():e["lua-in-js"]=t()}(global,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=5)}([function(e,t,r){(function(e){var r,n,a;!function(o,i,s){"use strict";var u={function:!0,object:!0},c=u[typeof t]&&t&&!t.nodeType&&t,l=u[typeof e]&&e&&!e.nodeType&&e,f=c&&l&&"object"==typeof global&&global,p=l&&l.exports===c&&c;!f||f.global!==f&&f.window!==f&&f.self,n=[t],void 0===(a="function"==typeof(r=s)?r.apply(t,n):r)||(e.exports=a),c&&p&&s(l.exports)}(0,0,function(e){"use strict";var t,r,n;e.version="0.2.1";var a=e.defaultOptions={wait:!1,comments:!0,scope:!1,locations:!1,ranges:!1,onCreateNode:null,onCreateScope:null,onDestroyScope:null},o=1,i=2,s=4,u=8,c=16,l=32,f=64,p=128,h=256;e.tokenTypes={EOF:o,StringLiteral:i,Keyword:s,Identifier:u,NumericLiteral:c,Punctuator:l,BooleanLiteral:f,NilLiteral:p,VarargLiteral:h};var d=e.errors={unexpected:"unexpected %1 '%2' near '%3'",expected:"'%1' expected near '%2'",expectedToken:"%1 expected near '%2'",unfinishedString:"unfinished string near '%1'",malformedNumber:"malformed number near '%1'",invalidVar:"invalid left-hand side of assignment near '%1'"},g=e.ast={labelStatement:function(e){return{type:"LabelStatement",label:e}},breakStatement:function(){return{type:"BreakStatement"}},gotoStatement:function(e){return{type:"GotoStatement",label:e}},returnStatement:function(e){return{type:"ReturnStatement",arguments:e}},ifStatement:function(e){return{type:"IfStatement",clauses:e}},ifClause:function(e,t){return{type:"IfClause",condition:e,body:t}},elseifClause:function(e,t){return{type:"ElseifClause",condition:e,body:t}},elseClause:function(e){return{type:"ElseClause",body:e}},whileStatement:function(e,t){return{type:"WhileStatement",condition:e,body:t}},doStatement:function(e){return{type:"DoStatement",body:e}},repeatStatement:function(e,t){return{type:"RepeatStatement",condition:e,body:t}},localStatement:function(e,t){return{type:"LocalStatement",variables:e,init:t}},assignmentStatement:function(e,t){return{type:"AssignmentStatement",variables:e,init:t}},callStatement:function(e){return{type:"CallStatement",expression:e}},functionStatement:function(e,t,r,n){return{type:"FunctionDeclaration",identifier:e,isLocal:r,parameters:t,body:n}},forNumericStatement:function(e,t,r,n,a){return{type:"ForNumericStatement",variable:e,start:t,end:r,step:n,body:a}},forGenericStatement:function(e,t,r){return{type:"ForGenericStatement",variables:e,iterators:t,body:r}},chunk:function(e){return{type:"Chunk",body:e}},identifier:function(e){return{type:"Identifier",name:e}},literal:function(e,t,r){return{type:e=e===i?"StringLiteral":e===c?"NumericLiteral":e===f?"BooleanLiteral":e===p?"NilLiteral":"VarargLiteral",value:t,raw:r}},tableKey:function(e,t){return{type:"TableKey",key:e,value:t}},tableKeyString:function(e,t){return{type:"TableKeyString",key:e,value:t}},tableValue:function(e){return{type:"TableValue",value:e}},tableConstructorExpression:function(e){return{type:"TableConstructorExpression",fields:e}},binaryExpression:function(e,t,r){return{type:"and"===e||"or"===e?"LogicalExpression":"BinaryExpression",operator:e,left:t,right:r}},unaryExpression:function(e,t){return{type:"UnaryExpression",operator:e,argument:t}},memberExpression:function(e,t,r){return{type:"MemberExpression",indexer:t,identifier:r,base:e}},indexExpression:function(e,t){return{type:"IndexExpression",base:e,index:t}},callExpression:function(e,t){return{type:"CallExpression",base:e,arguments:t}},tableCallExpression:function(e,t){return{type:"TableCallExpression",base:e,arguments:t}},stringCallExpression:function(e,t){return{type:"StringCallExpression",base:e,argument:t}},comment:function(e,t){return{type:"Comment",value:e,raw:t}}};function m(e){if(re){var t=ne.pop();t.complete(),r.locations&&(e.loc=t.loc),r.ranges&&(e.range=t.range)}return r.onCreateNode&&r.onCreateNode(e),e}var b,_,y,v,w,$,x,S,C,A,E,k=Array.prototype.slice,T=(Object.prototype.toString,function(e,t){for(var r=0,n=e.length;r=n)return{type:o,value:"",line:x,lineStart:S,range:[b,b]};var e=t.charCodeAt(b),r=t.charCodeAt(b+1);if($=b,function(e){return e>=65&&e<=90||e>=97&&e<=122||95===e}(e))return function(){var e,r;for(;n=t.charCodeAt(++b),n>=65&&n<=90||n>=97&&n<=122||95===n||n>=48&&n<=57;);var n;!function(e){switch(e.length){case 2:return"do"===e||"if"===e||"in"===e||"or"===e;case 3:return"and"===e||"end"===e||"for"===e||"not"===e;case 4:return"else"===e||"goto"===e||"then"===e;case 5:return"break"===e||"local"===e||"until"===e||"while"===e;case 6:return"elseif"===e||"repeat"===e||"return"===e;case 8:return"function"===e}return!1}(e=t.slice($,b))?"true"===e||"false"===e?(r=f,e="true"===e):"nil"===e?(r=p,e=null):r=u:r=s;return{type:r,value:e,line:x,lineStart:S,range:[$,b]}}();switch(e){case 39:case 34:return function(){var e,r=t.charCodeAt(b++),a=b,o="";for(;b=n||G(e))&&(o+=t.slice(a,b-1),O({},d.unfinishedString,o+String.fromCharCode(e)));return o+=t.slice(a,b-1),{type:i,value:o,line:x,lineStart:S,range:[$,b]}}();case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return U();case 46:return J(r)?U():46===r?46===t.charCodeAt(b+2)?{type:h,value:"...",line:x,lineStart:S,range:[$,b+=3]}:P(".."):P(".");case 61:return P(61===r?"==":"=");case 62:return P(61===r?">=":62===r?">>":">");case 60:return P(60===r?"<<":61===r?"<=":"<");case 126:return P(61===r?"~=":"~");case 58:return P(58===r?"::":":");case 91:return 91===r||61===r?function(){var e=z();!1===e&&O(_,d.expected,"[",_.value);return{type:i,value:e,line:x,lineStart:S,range:[$,b]}}():P("[");case 47:return P(47===r?"//":"/");case 42:case 94:case 37:case 44:case 123:case 124:case 125:case 93:case 40:case 41:case 59:case 38:case 35:case 45:case 43:return P(t.charAt(b))}return I(t.charAt(b))}function N(){var e=t.charCodeAt(b),r=t.charCodeAt(b+1);return!!G(e)&&(10===e&&13===r&&b++,13===e&&10===r&&b++,x++,S=++b,!0)}function V(){for(;b=0?function(){var e,r,n,a,o=0,i=1,s=1;a=b+=2,B(t.charCodeAt(b))||O({},d.malformedNumber,t.slice($,b));for(;B(t.charCodeAt(b));)b++;if(e=parseInt(t.slice(a,b),16),"."===t.charAt(b)){for(r=++b;B(t.charCodeAt(b));)b++;o=t.slice(r,b),o=r===b?0:parseInt(o,16)/Math.pow(16,b-r)}if("pP".indexOf(t.charAt(b)||null)>=0){for(b++,"+-".indexOf(t.charAt(b)||null)>=0&&(s="+"===t.charAt(b++)?1:-1),n=b,J(t.charCodeAt(b))||O({},d.malformedNumber,t.slice($,b));J(t.charCodeAt(b));)b++;i=t.slice(n,b),i=Math.pow(2,i*s)}return(e+o)*i}():function(){for(;J(t.charCodeAt(b));)b++;if("."===t.charAt(b))for(b++;J(t.charCodeAt(b));)b++;if("eE".indexOf(t.charAt(b)||null)>=0)for(b++,"+-".indexOf(t.charAt(b)||null)>=0&&b++,J(t.charCodeAt(b))||O({},d.malformedNumber,t.slice($,b));J(t.charCodeAt(b));)b++;return parseFloat(t.slice($,b))}();return{type:c,value:n,line:x,lineStart:S,range:[$,b]}}function F(){var e=b;switch(t.charAt(b)){case"n":return b++,"\n";case"r":return b++,"\r";case"t":return b++,"\t";case"v":return b++,"\v";case"b":return b++,"\b";case"f":return b++,"\f";case"z":return b++,V(),"";case"x":return B(t.charCodeAt(b+1))&&B(t.charCodeAt(b+2))?(b+=3,"\\"+t.slice(e,b)):"\\"+t.charAt(b++);default:if(J(t.charCodeAt(b))){for(;J(t.charCodeAt(++b)););return"\\"+t.slice(e,b)}return t.charAt(b++)}}function D(){$=b,b+=2;var e=t.charAt(b),a="",o=!1,i=b,s=S,u=x;if("["===e&&(!1===(a=z())?a=e:o=!0),!o){for(;b=48&&e<=57}function B(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function K(e){if(o===e.type)return!0;if(s!==e.type)return!1;switch(e.value){case"else":case"elseif":case"end":case"until":return!0;default:return!1}}function Y(){var e=Array.apply(null,C[A++]);C.push(e),r.onCreateScope&&r.onCreateScope()}function H(){C.pop();A--,r.onDestroyScope&&r.onDestroyScope()}function X(e){-1===T(C[A],e)&&C[A].push(e)}function Q(e){X(e.name),ee(e,!0)}function ee(e,t){t||-1!==function(e,t,r){for(var n=0,a=e.length;n",_)}();case"if":return W(),function(){var e,t,n,a=[];re&&(n=ne[ne.length-1],ne.push(n));e=ge(),Z("then"),r.scope&&Y();t=ue(),r.scope&&H();a.push(m(g.ifClause(e,t))),re&&(n=ae());for(;q("elseif");)se(n),e=ge(),Z("then"),r.scope&&Y(),t=ue(),r.scope&&H(),a.push(m(g.elseifClause(e,t))),re&&(n=ae());q("else")&&(re&&(n=new oe(y),ne.push(n)),r.scope&&Y(),t=ue(),r.scope&&H(),a.push(m(g.elseClause(t))));return Z("end"),m(g.ifStatement(a))}();case"return":return W(),function(){var e=[];if("end"!==_.value){var t=de();for(null!=t&&e.push(t);q(",");)t=ge(),e.push(t);q(";")}return m(g.returnStatement(e))}();case"function":return W(),pe(function(){var e,t,n;re&&(n=ae());e=fe(),r.scope&&(ee(e,te(e.name)),Y());for(;q(".");)se(n),t=fe(),e=m(g.memberExpression(e,".",t));q(":")&&(se(n),t=fe(),e=m(g.memberExpression(e,":",t)),r.scope&&X("self"));return e}());case"while":return W(),function(){var e=ge();Z("do"),r.scope&&Y();var t=ue();r.scope&&H();return Z("end"),m(g.whileStatement(e,t))}();case"for":return W(),function(){var e,t=fe();r.scope&&(Y(),Q(t));if(q("=")){var n=ge();Z(",");var a=ge(),o=q(",")?ge():null;return Z("do"),e=ue(),Z("end"),r.scope&&H(),m(g.forNumericStatement(t,n,a,o,e))}for(var i=[t];q(",");)t=fe(),r.scope&&Q(t),i.push(t);Z("in");var s=[];do{var u=ge();s.push(u)}while(q(","));return Z("do"),e=ue(),Z("end"),r.scope&&H(),m(g.forGenericStatement(i,s,e))}();case"repeat":return W(),function(){r.scope&&Y();var e=ue();Z("until");var t=ge();r.scope&&H();return m(g.repeatStatement(t,e))}();case"break":return W(),m(g.breakStatement());case"do":return W(),function(){r.scope&&Y();var e=ue();r.scope&&H();return Z("end"),m(g.doStatement(e))}();case"goto":return W(),function(){_.value;var e=fe();return m(g.gotoStatement(e))}()}return l===_.type&&q("::")?function(){var e=_.value,t=fe();r.scope&&(X("::"+e+"::"),ee(t,!0));return Z("::"),m(g.labelStatement(t))}():(re&&ne.pop(),q(";")?void 0:function(){var e,t,r=_;re&&(t=ae());if(null==(e=be()))return I(_);if(",=".indexOf(_.value)>=0){var n,a=[e],o=[];for(le(e);q(",");)null==(n=be())&&j("",_),le(n),a.push(n);Z("=");do{n=ge(),o.push(n)}while(q(","));return se(t),m(g.assignmentStatement(a,o))}if(function(e){switch(e.type){case"CallExpression":case"TableCallExpression":case"StringCallExpression":return!0}return!1}(e))return se(t),m(g.callStatement(e));return I(r)}())}function le(e){(e.inParens||-1===["Identifier","MemberExpression","IndexExpression"].indexOf(e.type))&&O(_,d.invalidVar,_.value)}function fe(){ie();var e=_.value;return u!==_.type&&j("",_),W(),m(g.identifier(e))}function pe(e,t){var n=[];if(Z("("),!q(")"))for(;;)if(u===_.type){var a=fe();if(r.scope&&Q(a),n.push(a),q(","))continue;if(q(")"))break}else{if(h===_.type){n.push(ye()),Z(")");break}j(" or '...'",_)}var o=ue();return Z("end"),r.scope&&H(),t=t||!1,m(g.functionStatement(e,n,t,o))}function he(){for(var e,t,r=[];;){if(ie(),l===_.type&&q("["))e=ge(),Z("]"),Z("="),t=ge(),r.push(m(g.tableKey(e,t)));else if(u===_.type)"="===v.value?(e=fe(),W(),t=ge(),r.push(m(g.tableKeyString(e,t)))):(t=ge(),r.push(m(g.tableValue(t))));else{if(null==(t=de())){ne.pop();break}r.push(m(g.tableValue(t)))}if(!(",;".indexOf(_.value)>=0))break;W()}return Z("}"),m(g.tableConstructorExpression(r))}function de(){return function e(t){var r,n,a=_.value;re&&(n=ae());if(function(e){return l===e.type?"#-~".indexOf(e.value)>=0:s===e.type&&"not"===e.value}(_)){ie(),W();var o=e(10);null==o&&j("",_),r=m(g.unaryExpression(a,o))}null==r&&null==(r=ye())&&(r=be());if(null==r)return null;var i;for(;a=_.value,!(0===(i=l===_.type||s===_.type?me(a):0)||i<=t);){"^"!==a&&".."!==a||i--,W();var u=e(i);null==u&&j("",_),re&&ne.push(n),r=m(g.binaryExpression(a,r,u))}return r}(0)}function ge(){var e=de();if(null!=e)return e;j("",_)}function me(e){var t=e.charCodeAt(0),r=e.length;if(1===r)switch(t){case 94:return 12;case 42:case 47:case 37:return 10;case 43:case 45:return 9;case 38:return 6;case 126:return 5;case 124:return 4;case 60:case 62:return 3}else if(2===r)switch(t){case 47:return 10;case 46:return 8;case 60:case 62:return"<<"===e||">>"===e?7:3;case 61:case 126:return 3;case 111:return 1}else if(97===t&&"and"===e)return 2;return 0}function be(){var e,t,n,a,o;if(re&&(n=ae()),u===_.type)t=_.value,e=fe(),r.scope&&ee(e,te(t));else{if(!q("("))return null;e=ge(),Z(")"),e.inParens=!0}for(;;)if(l===_.type)switch(_.value){case"[":se(n),W(),a=ge(),e=m(g.indexExpression(e,a)),Z("]");break;case".":se(n),W(),o=fe(),e=m(g.memberExpression(e,".",o));break;case":":se(n),W(),o=fe(),e=m(g.memberExpression(e,":",o)),se(n),e=_e(e);break;case"(":case"{":se(n),e=_e(e);break;default:return e}else{if(i!==_.type)break;se(n),e=_e(e)}return e}function _e(e){if(l===_.type)switch(_.value){case"(":W();var t=[],r=de();for(null!=r&&t.push(r);q(",");)r=ge(),t.push(r);return Z(")"),m(g.callExpression(e,t));case"{":ie(),W();var n=he();return m(g.tableCallExpression(e,n))}else if(i===_.type)return m(g.stringCallExpression(e,ye()));j("function arguments",_)}function ye(){var e,n=i|c|f|p|h,a=_.value,o=_.type;if(re&&(e=ae()),o&n){se(e);var u=t.slice(_.range[0],_.range[1]);return W(),m(g.literal(o,a,u))}return s===o&&"function"===a?(se(e),W(),r.scope&&Y(),pe(null)):q("{")?(se(e),he()):void 0}function ve(r){return t+=String(r),n=t.length,e}function we(e){void 0!==e&&ve(e),t&&"#!"===t.substr(0,2)&&(t=t.replace(/^.*/,function(e){return e.replace(/./g," ")})),n=t.length,re=r.locations||r.ranges,v=L();var a=function(){W(),ie(),r.scope&&Y();var e=ue();return r.scope&&H(),o!==_.type&&I(_),re&&!e.length&&(y=_),m(g.chunk(e))}();if(r.comments&&(a.comments=w),r.scope&&(a.globals=E),ne.length>0)throw new Error("Location tracking failed. This is most likely a bug in luaparse");return a}oe.prototype.complete=function(){r.locations&&(this.loc.end.line=y.line,this.loc.end.column=y.range[1]-y.lineStart),r.ranges&&(this.range[1]=y.range[1])},e.parse=function(o,i){void 0===i&&"object"==typeof o&&(i=o,o=void 0);i||(i={});t=o||"",r=function(){for(var e,t,r=k.call(arguments),n={},a=0,o=r.length;a127)throw new Error("invalid character code passed to %c in printf");e.arg=isNaN(t)?""+t:String.fromCharCode(t)}}},s:{setMaxWidth:function(e){e.maxWidth="."==e.period?e.precision:-1}},e:{isDouble:!0,doubleNotation:"e"},E:{extend:["e"],toUpper:!0},f:{isDouble:!0,doubleNotation:"f"},F:{extend:["f"]},g:{isDouble:!0,doubleNotation:"g"},G:{extend:["g"],toUpper:!0},O:{isObject:!0}},a.prototype.format=function(e){if(this._mapped&&"object"!=typeof e)throw new Error("format requires a mapping");for(var t,r="",n=0,a=0;a=arguments.length)throw new Error("got "+arguments.length+" printf arguments, insufficient for '"+this._format+"'");t.arg=arguments[n++]}if(!t.compiled){t.compiled=!0,t.sign="",t.zeroPad=!1,t.rightJustify=!1,t.alternative=!1;for(var c={},l=t.flags.length;l--;){var f=t.flags.charAt(l);switch(c[f]=!0,f){case" ":t.sign=" ";break;case"+":t.sign="+";break;case"0":t.zeroPad=!c["-"];break;case"-":t.rightJustify=!0,t.zeroPad=!1;break;case"#":t.alternative=!0;break;default:throw Error("bad formatting flag '"+t.flags.charAt(l)+"'")}}t.minWidth=t._minWidth?parseInt(t._minWidth):0,t.maxWidth=-1,t.toUpper=!1,t.isUnsigned=!1,t.isInt=!1,t.isDouble=!1,t.isObject=!1,t.precision=1,"."==t.period&&(t._precision?t.precision=parseInt(t._precision):t.precision=0);var p=this._specifiers[t.specifier];if(void 0===p)throw new Error("unexpected specifier '"+t.specifier+"'");if(p.extend){var h=this._specifiers[p.extend];for(var d in h)p[d]=h[d];delete p.extend}for(var g in p)t[g]=p[g]}if("function"==typeof t.setArg&&t.setArg(t),"function"==typeof t.setMaxWidth&&t.setMaxWidth(t),"*"==t._minWidth){if(this._mapped)throw new Error("* width not supported in mapped formats");if(t.minWidth=parseInt(arguments[n++]),isNaN(t.minWidth))throw new Error("the argument for * width at position "+n+" is not a number in "+this._format);t.minWidth<0&&(t.rightJustify=!0,t.minWidth=-t.minWidth)}if("*"==t._precision&&"."==t.period){if(this._mapped)throw new Error("* precision not supported in mapped formats");if(t.precision=parseInt(arguments[n++]),isNaN(t.precision))throw Error("the argument for * precision at position "+n+" is not a number in "+this._format);t.precision<0&&(t.precision=1,t.period="")}t.isInt?("."==t.period&&(t.zeroPad=!1),this.formatInt(t)):t.isDouble?("."!=t.period&&(t.precision=6),this.formatDouble(t)):t.isObject&&this.formatObject(t),this.fitField(t),r+=""+t.arg}return r},a.prototype._zeros10="0000000000",a.prototype._spaces10=" ",a.prototype.formatInt=function(e){var t=parseInt(e.arg);if(!isFinite(t)){if("number"!=typeof e.arg)throw new Error("format argument '"+e.arg+"' not an integer; parseInt returned "+t);t=0}t<0&&(e.isUnsigned||10!=e.base)&&(t=4294967295+t+1),t<0?(e.arg=(-t).toString(e.base),this.zeroPad(e),e.arg="-"+e.arg):(e.arg=t.toString(e.base),t||e.precision?this.zeroPad(e):e.arg="",e.sign&&(e.arg=e.sign+e.arg)),16==e.base&&(e.alternative&&(e.arg="0x"+e.arg),e.arg=e.toUpper?e.arg.toUpperCase():e.arg.toLowerCase()),8==e.base&&e.alternative&&"0"!=e.arg.charAt(0)&&(e.arg="0"+e.arg)},a.prototype.formatDouble=function(e){var t=parseFloat(e.arg);if(!isFinite(t)){if("number"!=typeof e.arg)throw new Error("format argument '"+e.arg+"' not a float; parseFloat returned "+t);t=0}switch(e.doubleNotation){case"e":e.arg=t.toExponential(e.precision);break;case"f":e.arg=t.toFixed(e.precision);break;case"g":Math.abs(t)<1e-4?e.arg=t.toExponential(e.precision>0?e.precision-1:e.precision):e.arg=t.toPrecision(e.precision),e.alternative||(e.arg=e.arg.replace(/(\..*[^0])0*e/,"$1e"),e.arg=e.arg.replace(/\.0*e/,"e").replace(/\.0$/,""));break;default:throw new Error("unexpected double notation '"+e.doubleNotation+"'")}e.arg=e.arg.replace(/e\+(\d)$/,"e+0$1").replace(/e\-(\d)$/,"e-0$1"),e.alternative&&(e.arg=e.arg.replace(/^(\d+)$/,"$1."),e.arg=e.arg.replace(/^(\d+)e/,"$1.e")),t>=0&&e.sign&&(e.arg=e.sign+e.arg),e.arg=e.toUpper?e.arg.toUpperCase():e.arg.toLowerCase()},a.prototype.formatObject=function(e){var t="."===e.period?e.precision:null;e.arg=n.inspect(e.arg,!e.alternative,t,e.sign)},a.prototype.zeroPad=function(e,t){t=2==arguments.length?t:e.precision;var r=!1;"string"!=typeof e.arg&&(e.arg=""+e.arg),"-"===e.arg.substr(0,1)&&(r=!0,e.arg=e.arg.substr(1));for(var n=t-10;e.arg.length=0&&e.arg.length>e.maxWidth)return e.arg.substring(0,e.maxWidth);e.zeroPad?this.zeroPad(e,e.minWidth):this.spacePad(e)},a.prototype.spacePad=function(e,t){t=2==arguments.length?t:e.minWidth,"string"!=typeof e.arg&&(e.arg=""+e.arg);for(var r=t-10;e.arg.length":"gt","<=":"lte",">=":"gte","^":"pow"},h={AssignmentStatement(e,t){let r=e.variables.map((e,r)=>{const n=m(e,t);if(n instanceof s)return n.set(`__star_tmp[${r}]`);{const[e,t]=[].concat(n.match(/^\$get\((.*)\)$/));if(!e)throw new Error("Unhandled");return`$set(${t}, __star_tmp[${r}])`}}).join(";\n");return`__star_tmp = [${d(e.init,t).join(", ")}];${r}`},BinaryExpression(e,t){let r=m(e.left,t),n=m(e.right,t),a=p[e.operator];if(b(e.left)&&(r+="[0]"),b(e.right)&&(n+="[0]"),!a)throw console.info(e),new Error(`Unhandled binary operator: ${e.operator}`);return`__star_op_${a}(${r}, ${n})`},BooleanLiteral:e=>e.value?"true":"false",BreakStatement:e=>"break",CallStatement:(e,t)=>_(e.expression,t),CallExpression(e,t){let r=m(e.base,t);const n=d(e.arguments,t);return b(e.base)?n.unshift(`${r}[0]`):(r instanceof s&&":"===e.base.indexer&&n.unshift(r.base),n.unshift(`${r}`)),`__star_call(${n})`},Chunk:(e,t)=>e.body.map(e=>_(e,t)+";").join("\n"),DoStatement(e,t){let{scope:r,scopeDef:n}=g(t),a=this.Chunk(e,r);return`${n=n.replace(",",";")}\n${a}\n$=$${t};`},ElseClause(e,t){return`{\n${this.Chunk(e,t)}\n}`},ElseifClause(e,t){return this.IfClause(e,t)},ForNumericStatement(e,t){let{scope:r,scopeDef:n}=g(t),a=_(e.variable,t),o=m(e.start,t),i=m(e.end,t),s=null===e.step?1:_(e.step,t),u=s>0?"<=":">=",c=this.Chunk(e,r),f=++l;return`for (${`$${t}._forLoop${f} = ${o}`}; ${`$${t}._forLoop${f} ${u} ${i}`}; ${`$${t}._forLoop${f} += ${s}`}) {\n${n}\n${`$${r}.setLocal('${a}',$${t}._forLoop${f});`}\n${c}\n}`},ForGenericStatement(e,t){const{scope:r,scopeDef:n}=g(t),{scope:a,scopeDef:o}=g(r),i=d(e.iterators,t).join(", "),s=this.Chunk(e,a),u=e.variables.map((e,t)=>{return`$setLocal($, '${_(e,r)}', __star_tmp[${t}])`}).join(";\n");return`${n.split(", ")[0]};\n[$${r}._iterator, $${r}._table, $${r}._next] = [${i}];\nwhile((__star_tmp = __star_call($${r}._iterator, $${r}._table, $${r}._next)),__star_tmp[0] !== undefined) {\n${o}$${r}._next = __star_tmp[0]\n${u}\n${s}\n}`},FunctionDeclaration(e,t){let r,{scope:n,scopeDef:a}=g(t),o=!e.identifier,i=o?"":_(e.identifier,t),u=i instanceof s,l=e.parameters.map((e,t)=>{let r=_(e,n);return"...$.getVarargs()"===r?"$.setVarargs(args)":`$setLocal($, '${r}', __star_shift(args))`});u?(r=i.property.replace(/'/g,""),":"===e.identifier.indexer&&l.unshift("$setLocal($, 'self', __star_shift(args))")):r=i;let f=`(__star_tmp = function ${o?"":"func$"}${r}(...args){${a}\n${l.join(";\n")};\n${this.Chunk(e,n)} return [];}, __star_tmp.toString=()=>'function: 0x${(++c).toString(16)}', __star_tmp)`;if(o)return f;if(u)return i.set(f);return`$set${e.isLocal?"Local":""}($, '${i}', ${f})`},Identifier:(e,t)=>e.name,IfClause(e,t){let r=m(e.condition,t);return b(e.condition)&&(r+="[0]"),`if (__star_op_bool(${r})) {\n${this.Chunk(e,t)}\n}`},IfStatement:(e,t)=>e.clauses.map(e=>_(e,t)).join(" else "),IndexExpression(e,t){let r=m(e.base,t),n=m(e.index,t);return b(e.base)&&(r+="[0]"),b(e.index)&&(n+="[0]"),new s(r,n)},LocalStatement(e,t){let r=e.variables.map((e,r)=>{return`$setLocal($, '${_(e,t)}', __star_tmp[${r}])`}).join(";\n");return`__star_tmp = [${d(e.init,t).join(", ")}];${r}`},LogicalExpression(e,t){let r=m(e.left,t),n=m(e.right,t),a=e.operator;if(b(e.left)&&(r+="[0]"),b(e.right)&&(n+="[0]"),"and"===a)return`(!__star.op.bool(${r})?${r}:${n})`;if("or"===a)return`(__star.op.bool(${r})?${r}:${n})`;throw console.info(e),new Error(`Unhandled logical operator: ${e.operator}`)},MemberExpression(e,t){let r=m(e.base,t),n=_(e.identifier,t);return b(e.base)&&(r+="[0]"),new s(r,`'${n}'`)},NilLiteral:e=>"undefined",NumericLiteral:e=>e.value.toString(),RepeatStatement(e,t){let{scope:r,scopeDef:n}=g(t),a=m(e.condition,t);return`do{\n${n}\n${this.Chunk(e,r)}\n}while(!(${a}))`},ReturnStatement:(e,t)=>`return [${d(e.arguments,t).join(", ")}];`,StringCallExpression(e,t){return e.arguments=e.argument,this.TableCallExpression(e,t)},StringLiteral(e){let t=e.raw;return/^\[\[[^]*]$/m.test(t)?`\`${t.substr(2,t.length-4).replace(/\\/g,"\\\\")}\``:t=t.replace(/([^\\])\\(\d{1,3})/g,(e,t,r)=>`${t}\\u${("000"+parseInt(r,10).toString(16)).substr(-4)}`)},TableCallExpression(e,t){let r=m(e.base,t),n=[_(e.arguments,t)];return b(e.base)?`__star_call(${r}[0],${n})`:(r instanceof s&&":"===e.base.indexer&&n.unshift(r.base),`__star_call(${r},${n})`)},TableConstructorExpression(e,t){return`new __star_T(t => {${e.fields.map((e,r,n)=>{if("TableValue"==e.type){const a=r===n.length-1;return this.TableValue(e,t,a)}return _(e,t)}).join(";\n")}})`},TableKeyString:(e,t)=>`Tset(t, '${_(e.key,t)}', ${m(e.value,t)})`,TableKey:(e,t)=>`Tset(t, ${m(e.key,t)}, ${m(e.value,t)})`,TableValue(e,t,r){let n=m(e.value,t);return b(e.value)&&(n=r?`...${n}`:`${n}[0]`),`Tins(t, ${n})`},UnaryExpression(e,t){let r=f[e.operator],n=m(e.argument,t);if(b(e.argument)&&(n+="[0]"),!r)throw console.info(e),new Error(`Unhandled unary operator: ${e.operator}`);return`__star_op_${r}(${n})`},VarargLiteral:e=>"...$.getVarargs()",WhileStatement(e,t){let{scope:r,scopeDef:n}=g(t);return`while(${m(e.condition,t)}) {\n${n}\n${this.Chunk(e,r)}\n}`}};function d(e,t){return e.map((e,r,n)=>{let a=m(e,t);return b(e)?r==n.length-1?`...${a}`:`${a}[0]`:a})}function g(e){let t=u++;return{scope:t,scopeDef:`let $${t} = $${e}.extend(), $ = $${t};`}}function m(e,t){let r=_(e,t);return"Identifier"===e.type?`$get($, '${r}')`:r}function b(e){return!!e.type.match(/CallExpression$/)}function _(e,t){let r=h[e.type];if(!r)throw console.info(e),new Error(`No generator found for: ${e.type}`);return r.call(h,e,t)}function v(e){return`\n\t"use strict"; if (typeof global === 'undefined' && typeof window !== 'undefined') { window.global = window; }\n\tlet __star = global.starlight.runtime, $0 = __star.globalScope, $ = $0, __star_tmp;\n\tlet __star_call = __star.call, __star_T = __star.T, __star_op_bool = __star.op.bool;\n\tlet __star_op_unm = __star.op.unm, __star_op_not = __star.op.not, __star_op_len = __star.op.len, __star_op_concat = __star.op.concat, __star_op_add = __star.op.add, __star_op_sub = __star.op.sub, __star_op_mul = __star.op.mul, __star_op_div = __star.op.div, __star_op_mod = __star.op.mod, __star_op_eq = __star.op.eq, __star_op_neq = __star.op.neq, __star_op_lt = __star.op.lt, __star_op_gt = __star.op.gt, __star_op_lte = __star.op.lte, __star_op_gte = __star.op.gte, __star_op_pow = __star.op.pow;\n\tlet __star_op_and = __star.op.and, __star_op_or = __star.op.or;\n\tlet Tget, Tset, Tins, $get, $set, $setLocal, __star_shift;\n\t(()=>{\n\t\tlet call = Function.prototype.call, bind = call.bind.bind(call), Tproto = __star_T.prototype, $proto = __star.globalScope.constructor.prototype;\n\t\tTget = bind(Tproto.get), Tset = bind(Tproto.set), Tins = bind(Tproto.insert);\n\t\t$get = bind($proto.get), $set = bind($proto.set), $setLocal = bind($proto.setLocal);\n\t\t__star_shift = bind(Array.prototype.shift);\n\t})();\n\t${_(i.a.parse(e),0)}\n\t`}const w=Object.prototype.hasOwnProperty;class ${constructor(e={}){this._variables=e}get(e){return this._variables[e]}set(e,t){let r=this._variables;w.call(this._variables,e)||!this.parent?r[e]=t:this.parent.set(e,t)}setLocal(e,t){this._variables[e]=t}setVarargs(e){this._varargs=e}getVarargs(){return this._varargs||this.parent&&this.parent.getVarargs()}add(e,t){this._variables[e]+=t}extend(e){let t=Object.create(this._variables),r=new $(t);return r.parent=this,r}}class x extends Error{constructor(e){super(),this.message=e}toString(){return`LuaError: ${this.message}`}}let S,C,A=0;class E{constructor(e){if(this.index=++A,this.numValues=[void 0],this.strValues={},this.keys=[],this.values=[],this.metatable=null,e)if("function"==typeof e)e(this);else{let t=e instanceof Array;for(let r in e)if(e.hasOwnProperty(r)){let n=e[r];null===n&&(n=void 0);let a=t?parseInt(r,10)+1:r,o="object"==typeof n&&n.constructor===Object||n instanceof Array;this.set(a,o?new E(n):n)}}else;}get(e){if(!(this instanceof E)){if("string"==ne(this))return S.get(e);if(("userdata"===ne(this)||"function"===ne(this)&&"new"===e)&&e in this)return this[e];throw new x(`attempt to index a ${ne(this)} value`)}let t=this.rawget(e);if(void 0===t){let r,n;if((r=this.metatable)&&(n=r.get("__index")))switch(n.constructor){case E:return n.get(e);case Function:return(t=n.call(void 0,this,e))instanceof Array?t[0]:t}}return t}rawget(e){switch(typeof e){case"string":return Object.prototype.hasOwnProperty.call(this.strValues,e)?this.strValues[e]:void 0;case"number":if(e>0&&e==e>>0)return this.numValues[e];default:let t=this.keys.indexOf(e);return t>=0?this.values[t]:void 0}}set(e,t){if(!(this instanceof E)){if("userdata"==ne(this))return void(this[e]=t);throw new x(`attempt to index a ${ne(this)} value`)}let r,n;if((r=this.metatable)&&(n=r.get("__newindex"))){let r;switch(typeof e){case"string":r=this.strValues[e];break;case"number":if(e>0&&e==e>>0){r=this.numValues[e];break}default:let t=this.keys.indexOf(e);r=-1==t?void 0:this.values[t]}if(void 0===r)switch(n.constructor){case E:return n.set(e,t);case Function:return n(this,e,t)}}this.rawset(e,t)}rawset(e,t){switch(t instanceof Array&&(t=t[0]),typeof e){case"string":this.strValues[e]=t;break;case"number":if(e>0&&e==e>>0){this.numValues[e]=t;break}default:let r=this.keys,n=r.indexOf(e);n<0&&(r[n=r.length]=e),this.values[n]=t}}insert(...e){this.numValues.push(...e)}toString(){let e,t;return(e=this.metatable)&&(t=e.get("__tostring"))?t(this)[0]:"table: 0x"+this.index.toString(16)}toObject(){const e=C(this)>0?[]:{},t=this.numValues,r=this.strValues;let n;const a=t.length;for(n=1;n{let e,t,r;return(e=global.starlight)&&(t=e.config)&&(r=t.stdout)&&r.writeln||j})()};function L(e,t){if(t)throw t=(""+t).replace(/\%type/gi,ne(e)),new x(t)}function N(e){return!(!1===e||void 0===e)}function V(e,t){let r,n,a;switch(!0){case"number"==typeof e:return e;case void 0===e:return;case"inf"===e:return 1/0;case"-inf"===e:return-1/0;case"nan"===e:return NaN;default:return(""+e).match(M)?r=parseFloat(e):(n=(""+e).match(O))&&(a=n[3],((r=n[2])||a)&&(r=parseInt(r,16)||0,a&&(r+=parseInt(a,16)/Math.pow(16,a.length)),n[1]&&(r*=-1))),void 0===r&&L(e,t),r}}function P(e,t){switch(!0){case"string"==typeof e:return e;case void 0===e:case null===e:return"nil";case e===1/0:return"inf";case e===-1/0:return"-inf";case"number"==typeof e:case"boolean"==typeof e:return global.isNaN(e)?"nan":`${e}`;default:return L(e,t)||"userdata"}}function U(e,t,r,n,a){return t(e,`bad argument #${a} to '${n}' (${r} expected, got %type)`)}function F(e,t,r){return U(e,V,"number",t,r)}function D(e,t,r){return U(e,P,"string",t,r)}function z(e,t,r){if(e instanceof E)return e;{let n=ne(e);throw new x(`bad argument #${r} to '${t}' (table expected, got ${n})`)}}function W(e,t,r){if(e instanceof Function)return e;{let n=ne(e);throw new x(`bad argument #${r} to '${t}' (function expected, got ${n})`)}}const q={"([^a-zA-Z0-9%(])-":"$1*?","([^%])-([^a-zA-Z0-9?])":"$1*?$2","(.)-$":"$1*?","%a":"[a-zA-Z]","%A":"[^a-zA-Z]","%c":"[\0-]","%C":"[^\0-]","%d":"\\d","%D":"[^d]","%l":"[a-z]","%L":"[^a-z]","%p":"[.,\"'?!;:#$%&()*+-/<>=@\\[\\]\\\\^_{}|~]","%P":"[^.,\"'?!;:#$%&()*+-/<>=@\\[\\]\\\\^_{}|~]","%s":"[ \\t\\n\\f\\v\\r]","%S":"[^ \t\n\f\v\r]","%u":"[A-Z]","%U":"[^A-Z]","%w":"[a-zA-Z0-9]","%W":"[^a-zA-Z0-9]","%x":"[a-fA-F0-9]","%X":"[^a-fA-F0-9]","%([^a-zA-Z])":"\\$1"};function Z(e){e=(e=""+e).replace(new RegExp("\\\\","g"),"\\\\");for(let t in q)q.hasOwnProperty(t)&&(e=e.replace(new RegExp(t,"g"),q[t]));let t=e.length,r=0;for(let n=0;ne.charCodeAt(0))},char:function(...e){return e.map((e,t)=>(e=F(e,"char",t),String.fromCharCode(e))).join("")},dump:function(e){throw e=W(e,"dump",1),new x("string.dump() is not supported")},find:function(e,t,r=1,n=!1){if(e=D(e,"find",1),t=D(t,"find",2),r=F(r,"find",3),!(n=N(n))){t=Z(t);let n=new RegExp(t),a=e.substr(r-1).search(n);if(a<0)return;let o=e.substr(r-1).match(n),i=[a+r,a+r+o[0].length-1];return o.shift(),i.concat(o)}let a=e.indexOf(t,r-1);return-1===a?void 0:[a+1,a+t.length]},format:function(e,...t){return T()(e,...t)},gmatch:function(e,t){e=D(e,"gmatch",1),t=Z(t=D(t,"gmatch",2));let r=new RegExp(t,"g"),n=e.match(r);return()=>{let e=n.shift(),r=new RegExp(t).exec(e);if(void 0!==e)return r.shift(),r.length?r:e}},gsub:function(e,t,r,n=1/0){e=D(e,"gsub",1),t=D(t,"gsub",2),n=F(n,"gsub",3),t=Z(""+t);let a,o,i,s,u="function"==typeof r,c=0,l="";for(;ci[t]),o=0===i[0].length?void 0===s?"":e.substr(0,1):e.substr(0,i.index),s=i[0],l+=`${o}${a}`,e=e.substr(`${o}${s}`.length),c++;return[`${l}${e}`,c]},len:function(e){return(e=D(e,"len",1)).length},lower:function(e){return(e=D(e,"lower",1)).toLowerCase()},match:function(e,t,r=0){e=D(e,"match",1),t=D(t,"match",2),r=F(r,"match",3);let n=(e=e.substr(r)).match(new RegExp(Z(t)));if(n)return n[1]?(n.shift(),n):n[0]},rep:function(e,t){return e=D(e,"rep",1),t=F(t,"rep",2),Array(t+1).join(e)},reverse:function(e){return e=D(e,"reverse",1),Array.prototype.map.call(e,e=>e).reverse().join("")},sub:function(e,t=1,r){return e=D(e,"sub",1),t=F(t,"sub",2),void 0===r?e.length:r=F(r,"sub",3),t>0?t-=1:t<0&&(t=e.length+t),r<0&&(r=e.length+r+1),e.substring(t,r)},upper:function(e){return(e=D(e,"upper",1)).toUpperCase()}});var G=R;const J=new E({__index:R});function B(e){let t=(e=z(e,"getn",1)).numValues,r=[],n=0;for(let e in t)t.hasOwnProperty(e)&&(r[e]=!0);for(;r[n+1];)n++;if(n>0&&void 0===t[n]){let e=0;for(;n-e>1;){let r=Math.floor((e+n)/2);void 0===t[r]?n=r:e=r}return e}return n}function K(e){return(e=z(e,"maxn",1)).numValues.length-1}var Y=new E({concat:function(e,t="",r=1,n){return e=z(e,"concat",1),t=D(t,"concat",2),r=F(r,"concat",3),n=void 0===n?K(e):F(n,"concat",4),[].concat(e.numValues).splice(r,n-r+1).join(t)},getn:B,insert:function(e,t,r){e=z(e,"insert",1),void 0===r?(r=t,t=e.numValues.length):t=F(t,"insert",2),e.numValues.splice(t,0,void 0),e.set(t,r)},maxn:K,remove:function(e,t){e=z(e,"remove",1),t=F(t,"remove",2);let r=B(e),n=e.numValues;if(t>r)return;void 0===t&&(t=r);let a=n.splice(t,1);for(;tN(t(e,r)[0])?-1:1)):r=((e,t)=>et),t}function Q(e,t){if(void 0===t)throw new x("Bad argument #2 to ipairs() iterator");var r=t+1,n=e.numValues;if(n.hasOwnProperty(r)&&void 0!==n[r])return[r,n[r]]}function ee(e){if(e&&e instanceof E){let t=e.metatable;if(t){let e;return(e=t.rawget("__metatable"))?e:t}}else if("string"==typeof e)return J}function te(e,t){e=z(e,"next",1);let r,n,a,o,i=void 0===t;if(i||"number"==typeof t&&t>0&&t==t>>0){let s=e.numValues;if("keys"in Object){let e=Object.keys(s);if(i?a=1:(a=e.indexOf(""+t)+1)&&(i=!0),i){for(;void 0!==(r=e[a])&&void 0===(n=s[r]);)a++;if(void 0!==n)return[r>>=0,n]}}else for(o in s)if(a=o>>0,i){if(void 0!==s[a])return[a,s[a]]}else a===t&&(i=!0)}for(a in e.strValues)if(e.strValues.hasOwnProperty(a))if(i){if(void 0!==e.strValues[a])return[a,e.strValues[a]]}else a==t&&(i=!0);for(a in e.keys)if(e.keys.hasOwnProperty(a)){let r=e.keys[a];if(i){if(void 0!==e.values[a])return[r,e.values[a]]}else r===t&&(i=!0)}return[]}function re(e){let t,r;return void 0!==e&&e instanceof E&&(t=e.metatable)&&(r=t.rawget("__tostring"))?r.call(r,e):e instanceof E?e.toString():e instanceof Function?e.hasOwnProperty("toString")?`${e}`:"function: [host code]":P(e)}function ne(e){let t=typeof e;switch(t){case"undefined":return"nil";case"number":case"string":case"boolean":case"function":return t;case"object":return e.constructor===E?"table":e&&e instanceof Function?"function":"userdata"}}const ae=new E({_VERSION:"Lua 5.1",assert:function(e,t){if(!N(e))throw t=D(t,"assert",2),new x(t||"Assertion failed!");return[e,t]},error:function(e){throw"string"!=typeof e&&"number"!=typeof e&&(e="(error object is not a string)"),new x(e)},getmetatable:ee,ipairs:function(e){const t=ee(e=z(e,"ipairs",1)),r=t&&t.get("__ipairs");return r?r(e).slice(0,3):[Q,e,0]},loadstring:function(e,t){e=D(e,"loadstring",1);let r=global.starlight.parser;if(!r)throw new Error("Starlight parser not found in call to loadstring(). The parser is required to execute Lua strings at runtime.");try{return r.parse(e)}catch(e){return[void 0,e.message]}},next:te,pairs:function(e){const t=ee(e=z(e,"pairs",1)),r=t&&t.get("__pairs");return r?r(e).slice(0,3):[te,e]},pcall:function(e,...t){let r;try{if("function"!=typeof e)throw new x("Attempt to call non-function");r=e(...t)}catch(e){return[!1,e&&e.toString()]}return r=[].concat(r),[!0,...r]},print:function(...e){let t=e.map(e=>re(e)).join("\t");I.writeln(t)},rawequal:function(e,t){return e===t},rawget:function(e,t){return(e=z(e,"rawget",1)).rawget(t)},rawset:function(e,t,r){if(e=z(e,"rawset",1),void 0===t)throw new x("table index is nil");return e.rawset(t,r),e},require:function(e){e=(e=D(e,"require",1)).replace(/\//g,".");let[t,r]=X(),n=r.rawget(e);if(n)return n;let a=t.rawget(e);if(void 0===a)throw new x(`module '${e}' not found:\n\tno field package.preload['${e}']`);let o=a(e);return n=o instanceof Array?o[0]:o,r.rawset(e,void 0===n||n),n},select:function(e,...t){if("#"===e)return t.length;if(e=parseInt(e,10))return t.slice(e-1);{let t=ne(e);throw new x(`bad argument #1 to 'select' (number expected, got ${t})`)}},setmetatable:function(e,t){let r;if(e=z(e,"setmetatable",1),void 0!==t&&(t=z(t,"setmetatable",2)),(r=e.metatable)&&r.rawget("__metatable"))throw new x("cannot change a protected metatable");return e.metatable=t,e},tonumber:function(e,t=10){if(t=F(t,"tonumber",2),""===e)return;if(t<2||t>36)throw new x("bad argument #2 to 'tonumber' (base out of range)");if(10==t&&(e===1/0||e===-1/0||"number"==typeof e&&global.isNaN(e)))return e;if(10!=t&&void 0===e)throw new x("bad argument #1 to 'tonumber' (string expected, got nil)");if(e=`${e}`.trim(),10===t)return V(e);let r;return e=P(e),16===t&&(r=e.match(/^(\-)?0[xX](.+)$/))&&(e=`${r[1]||""}${r[2]}`),new RegExp("^["+H.substr(0,t)+"]*$","gi").test(e)?parseInt(e,t):void 0},tostring:re,type:ne,unpack:function(e,t=1,r){return e=z(e,"unpack",1),t=F(t,"unpack",2),r=void 0===r?B(e):F(r,"unpack",3),e.numValues.slice(t,r+1)},xpcall:function(e,t){let r,n,a;try{"function"==typeof e?r=e():a=!0,n=!0}catch(e){r=t(void 0,!0)[0],n=!1}if(a)throw new x("Attempt to call non-function");return r&&r instanceof Array||(r=[r]),r.unshift(n),r}});ae.rawset("_G",ae);var oe=ae;function ie(e,t,r,n){let a,o;return e&&e instanceof E&&(a=e.metatable)&&(o=a.rawget(r))||t&&t instanceof E&&(a=t.metatable)&&(o=a.rawget(r))?o(e,t)[0]:("number"!=typeof e&&(e=V(e,"attempt to perform arithmetic on a %type value")),"number"!=typeof t&&(t=V(t,"attempt to perform arithmetic on a %type value")),n(e,t))}function se(e,t,r,n){return"string"==typeof e&&"string"==typeof t?n(e,t):ie(e,t,r,n)}function ue(e,t){var r,n,a;return t!==e&&e&&e instanceof E&&t&&t instanceof E&&(r=e.metatable)&&(n=t.metatable)&&r===n&&(a=r.rawget("__eq"))?!!a(e,t)[0]:e===t}function ce(e,t){if(0===t||t===-1/0||t===1/0||global.isNaN(e)||global.isNaN(t))return NaN;let r=Math.abs(t),n=Math.abs(e)%r;return e*t<0&&(n=r-n),t<0&&(n*=-1),n}const le={concat:function(e,t){let r,n;return e&&e instanceof E&&(r=e.metatable)&&(n=r.rawget("__concat"))||t&&t instanceof E&&(r=t.metatable)&&(n=r.rawget("__concat"))?n(e,t)[0]:(t=P(t,"attempt to concatenate a %type value"),`${e=P(e,"attempt to concatenate a %type value")}${t}`)},len:function(e){if(void 0===e)throw new x("attempt to get length of a nil value");if(e instanceof E)return B(e);if("object"==typeof e){let t=0;for(let r in e)e.hasOwnProperty(r)&&t++;return t}return e.length},eq:ue,unm:function(e){var t,r;return e&&e instanceof E&&(t=e.metatable)&&(r=t.rawget("__unm"))?r(e)[0]:("number"!=typeof e&&(e=V(e,"attempt to perform arithmetic on a %type value")),-e)},bool:N,neq:(...e)=>!ue(...e),not:(...e)=>!N(...e),add:(e,t)=>ie(e,t,"__add",(e,t)=>e+t),sub:(e,t)=>ie(e,t,"__sub",(e,t)=>e-t),mul:(e,t)=>ie(e,t,"__mul",(e,t)=>e*t),div:(e,t)=>{if(void 0===t)throw new x("attempt to perform arithmetic on a nil value");return ie(e,t,"__div",(e,t)=>e/t)},mod:(e,t)=>ie(e,t,"__mod",ce),pow:(e,t)=>ie(e,t,"__pow",Math.pow),lt:(e,t)=>se(e,t,"__lt",(e,t)=>ese(e,t,"__le",(e,t)=>e<=t),gt:(e,t)=>!le.lte(e,t),gte:(e,t)=>!le.lt(e,t)};var fe=le;const pe=16807,he=2147483647;let de=1;function ge(){return(de=pe*de%he)/he}function me(e){return e=F(e,"exp",1),Math.exp(e)}const be=Math.PI;var _e=new E({abs:function(e){return e=F(e,"abs",1),Math.abs(e)},acos:function(e){return e=F(e,"acos",1),Math.acos(e)},asin:function(e){return e=F(e,"asin",1),Math.asin(e)},atan:function(e){return e=F(e,"atan",1),Math.atan(e)},atan2:function(e,t){return e=F(e,"atan2",1),t=F(t,"atan2",2),Math.atan2(e,t)},ceil:function(e){return e=F(e,"ceil",1),Math.ceil(e)},cos:function(e){return e=F(e,"cos",1),Math.cos(e)},cosh:function(e){return(me(e=F(e,"cosh",1))+me(-e))/2},deg:function(e){return 180*(e=F(e,"deg",1))/Math.PI},exp:me,floor:function(e){return e=F(e,"floor",1),Math.floor(e)},fmod:function(e,t){return(e=F(e,"fmod",1))%(t=F(t,"fmod",2))},frexp:function(e){if(0===(e=F(e,"frexp",1)))return[0,0];let t=e>0?1:-1;e*=t;let r=Math.floor(Math.log(e)/Math.log(2))+1;return[e/Math.pow(2,r)*t,r]},huge:1/0,ldexp:function(e,t){return e=F(e,"ldexp",1),t=F(t,"ldexp",2),e*Math.pow(2,t)},log:function(e,t){return e=F(e,"log",1),void 0===t?Math.log(e):(y=F(y,"log",2),Math.log(e)/Math.log(t))},log10:function(e){return e=F(e,"log10",1),Math.log(e)/Math.log(10)},max:function(...e){return Math.max(...e)},min:function(...e){return Math.min(...e)},modf:function(e){e=F(e,"modf",1);let t=Math.floor(e);return[t,e-t]},pi:be,pow:function(e,t){return e=F(e,"pow",1),t=coercArgToNumber(t,"pow",2),Math.pow(e,t)},rad:function(e){return e=F(e,"rad",1),Math.PI/180*e},random:function(e,t){if(void 0===e&&void 0===t)return ge();if(e=F(e,"random",1),void 0===t?(t=e,e=1):t=F(t,"random",2),e>t)throw new shine.Error("bad argument #2 to 'random' (interval is empty)");return Math.floor(ge()*(t-e+1)+e)},randomseed:function(e){e=F(e,"randomseed",1),de=e},sin:function(e){return e=F(e,"sin",1),Math.sin(e)},sinh:function(e){return(me(e=F(e,"sinh",1))-me(-e))/2},sqrt:function(e){return e=F(e,"sqrt",1),Math.sqrt(e)},tan:function(e){return e=F(e,"tan",1),Math.tan(e)},tanh:function(e){return(me(e=F(e,"tanh",1))-me(-e))/(me(e)+me(-e))}});const ye=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ve=["January","February","March","April","May","June","July","August","September","October","November","December"],we=[31,28,31,30,31,30,31,31,30,31,30,31],$e={"%a":(e,t)=>ye[e["get"+(t?"UTC":"")+"Day"]()].substr(0,3),"%A":(e,t)=>ye[e["get"+(t?"UTC":"")+"Day"]()],"%b":(e,t)=>ve[e["get"+(t?"UTC":"")+"Month"]()].substr(0,3),"%B":(e,t)=>ve[e["get"+(t?"UTC":"")+"Month"]()],"%c":(e,t)=>e["to"+(t?"UTC":"")+"LocaleString"](),"%d":(e,t)=>("0"+e["get"+(t?"UTC":"")+"Date"]()).substr(-2),"%H":(e,t)=>("0"+e["get"+(t?"UTC":"")+"Hours"]()).substr(-2),"%I":(e,t)=>("0"+((e["get"+(t?"UTC":"")+"Hours"]()+11)%12+1)).substr(-2),"%j":(e,t)=>{let r=e["get"+(t?"UTC":"")+"Date"](),n=e["get"+(t?"UTC":"")+"Month"]();for(let e=0;e1&&e["get"+(t?"UTC":"")+"FullYear"]()%4==0&&(r+=1),("00"+r).substr(-3)},"%m":(e,t)=>("0"+(e["get"+(t?"UTC":"")+"Month"]()+1)).substr(-2),"%M":(e,t)=>("0"+e["get"+(t?"UTC":"")+"Minutes"]()).substr(-2),"%p":(e,t)=>e["get"+(t?"UTC":"")+"Hours"]()<12?"AM":"PM","%S":(e,t)=>("0"+e["get"+(t?"UTC":"")+"Seconds"]()).substr(-2),"%U":(e,t)=>Se(e,0,t),"%w":(e,t)=>""+e["get"+(t?"UTC":"")+"Day"](),"%W":(e,t)=>Se(e,1,t),"%x":(e,t)=>$e["%m"](e,t)+"/"+$e["%d"](e,t)+"/"+$e["%y"](e,t),"%X":(e,t)=>$e["%H"](e,t)+":"+$e["%M"](e,t)+":"+$e["%S"](e,t),"%y":(e,t)=>$e["%Y"](e,t).substr(-2),"%Y":(e,t)=>""+e["get"+(t?"UTC":"")+"FullYear"](),"%Z":(e,t)=>{let r;return t?"UTC":(r=e.toString().match(/[A-Z][A-Z][A-Z]/))&&r[0]},"%%":()=>"%"};function xe(e){let t=e.getFullYear(),r=new Date(t,0);return e.getTimezoneOffset()!==r.getTimezoneOffset()}function Se(e,t,r){let n=parseInt($e["%j"](e),10),a=(8-new Date(e.getFullYear(),0,1,12)["get"+(r?"UTC":"")+"Day"]()+t)%7;return("0"+(Math.floor((n-a)/7)+1)).substr(-2)}var Ce=new E({date:function(e="%c",t){let r,n=new Date;if(t&&n.setTime(1e3*t),"!"===e.substr(0,1)&&(e=e.substr(1),r=!0),"*t"===e)return new E({year:parseInt($e["%Y"](n,r),10),month:parseInt($e["%m"](n,r),10),day:parseInt($e["%d"](n,r),10),hour:parseInt($e["%H"](n,r),10),min:parseInt($e["%M"](n,r),10),sec:parseInt($e["%S"](n,r),10),wday:parseInt($e["%w"](n,r),10)+1,yday:parseInt($e["%j"](n,r),10),isdst:xe(n)});for(let t in $e)$e.hasOwnProperty(t)&&e.indexOf(t)>=0&&(e=e.replace(t,$e[t](n,r)));return e},exit:function(e=0){var t=global.process;if(!t||!t.exit)throw new Error(`Exit with code: ${e}`);t.exit(e)}}),Ae=new E({preload:new E,loaded:new E});let Ee=global.starlight=global.starlight||{},ke=oe;!function(){let e=Ee.config&&Ee.config.env;if(e)for(let t in e)oe.set(t,e[t])}();Ee.runtime={globalScope:new $(oe.strValues),_G:ke,op:fe,T:E,LuaError:x,call:function(e,...t){if(!(e instanceof Function)){if(e instanceof E){let r,n;(r=e.metatable)&&(n=r.rawget("__call"))&&(t.unshift(e),e=n)}if(!(e instanceof Function)){let t=ne(e);throw new x(`attempt to call a ${t} value`)}}return(r=e(...t))instanceof Array?r:[r];var r}};var Te;ke.set("math",_e),ke.set("table",Y),ke.set("string",G),ke.set("os",Ce),ke.set("package",Ae),S=(Te={string:G,getn:B}).string,C=Te.getn,r.d(t,"parser",function(){return n}),r.d(t,"runtime",function(){return a})}])});