phaser4-rex-plugins
Version:
16 lines • 359 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).rexmarkedeventsheetsplugin=t()}(void 0,(function(){"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var t={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,n,s,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new i(n,s||e,o),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],a]:e._events[u].push(a):(e._events[u]=a,e._eventsCount++),e}function o(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,o=new Array(s);i<s;i++)o[i]=n[i].fn;return o},a.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},a.prototype.emit=function(e,t,n,i,s,o){var a=r?r+e:e;if(!this._events[a])return!1;var u,l,h=this._events[a],c=arguments.length;if(h.fn){switch(h.once&&this.removeListener(e,h.fn,void 0,!0),c){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,t),!0;case 3:return h.fn.call(h.context,t,n),!0;case 4:return h.fn.call(h.context,t,n,i),!0;case 5:return h.fn.call(h.context,t,n,i,s),!0;case 6:return h.fn.call(h.context,t,n,i,s,o),!0}for(l=1,u=new Array(c-1);l<c;l++)u[l-1]=arguments[l];h.fn.apply(h.context,u)}else{var p,d=h.length;for(l=0;l<d;l++)switch(h[l].once&&this.removeListener(e,h[l].fn,void 0,!0),c){case 1:h[l].fn.call(h[l].context);break;case 2:h[l].fn.call(h[l].context,t);break;case 3:h[l].fn.call(h[l].context,t,n);break;case 4:h[l].fn.call(h[l].context,t,n,i);break;default:if(!u)for(p=1,u=new Array(c-1);p<c;p++)u[p-1]=arguments[p];h[l].fn.apply(h[l].context,u)}}return!0},a.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},a.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},a.prototype.removeListener=function(e,t,n,i){var s=r?r+e:e;if(!this._events[s])return this;if(!t)return o(this,s),this;var a=this._events[s];if(a.fn)a.fn!==t||i&&!a.once||n&&a.context!==n||o(this,s);else{for(var u=0,l=[],h=a.length;u<h;u++)(a[u].fn!==t||i&&!a[u].once||n&&a[u].context!==n)&&l.push(a[u]);l.length?this._events[s]=1===l.length?l[0]:l:o(this,s)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&o(this,t)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,e.exports=a}(t);var r=e(t.exports);let n=class extends r{shutdown(){this.removeAllListeners()}destroy(){this.removeAllListeners()}};var i=function(e){if("object"!=typeof e||e.nodeType||e===e.window)return!1;try{if(e.constructor&&!{}.hasOwnProperty.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(e){return!1}return!0};const s="tree",o="composite",a="decorator",u="action",l="$state",h=window.crypto&&window.crypto.randomUUID;var c=null,p="#",d=function(e){void 0===e&&(e=null),c=e},f=function(){return c},g=function(){return null===c?h?window.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})):`${p}${c+=1}`},m={getTreeMemory(e){return e.getTreeMemory(this.id)},getData(e,t){return e.get(t,this.id)},setData(e,t,r){return e.set(t,r,this.id),this},getState(e){return this.getData(e,l)},resetState(e){return this.setData(e,l,0),this}},v=function(e,t,r){for(var n=[e];n.length>0;){var i=n.shift();if(!t.call(r,i))switch(i.category){case o:n.push(...i.children),(s=i.services)&&n.push(...s);break;case a:n.push(i.child);break;case u:var s;(s=i.services)&&n.push(...s)}}};function y(e){if(null===e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map((e=>y(e)));if(e instanceof Date)return new Date(e);if(e instanceof RegExp)return new RegExp(e);if(Object.getPrototypeOf(e)!==Object.prototype)return e;const t={};for(let r in e)e.hasOwnProperty(r)&&(t[r]=y(e[r]));return t}class b{setExpressionHandler(e){return this.expressionHandler=e,this}eval(e){return this.expressionHandler(e)}}function k(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var _={};!function(e){var t=function(){var e=function(e,t,r,n){for(r=r||{},n=e.length;n--;r[e[n]]=t);return r},t=[1,11],r=[1,3],n=[1,4],i=[1,5],s=[1,6],o=[1,8],a=[1,9],u=[1,10],l=[1,13],h=[1,14],c=[1,15],p=[1,16],d=[1,17],f=[1,18],g=[1,19],m=[1,20],v=[1,21],y=[1,22],b=[1,23],k=[1,24],_=[1,25],E=[1,26],D=[5,7,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,28,30],x=[5,7,9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,30],C=[5,7,12,13,14,19,20,21,22,23,24,25,26,28,30],w=[5,7,12,13,14,15,16,17,19,20,21,22,23,24,25,26,28,30],S=[5,7,12,19,20,21,22,23,24,25,26,28,30],A=[5,7,12,25,26,28,30],M=[7,28],O={trace:function(){},yy:{},symbols_:{error:2,expressions:3,e:4,EOF:5,expression_list:6,",":7,dot_name:8,".":9,NAME:10,"[":11,"]":12,"+":13,"-":14,"*":15,"/":16,"%":17,"^":18,">":19,"<":20,"==":21,"!=":22,">=":23,"<=":24,"||":25,"&&":26,"(":27,")":28,"?":29,":":30,true:31,false:32,QUOTED_STRING:33,NUMBER:34,HEXNUMBER:35,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",7:",",9:".",10:"NAME",11:"[",12:"]",13:"+",14:"-",15:"*",16:"/",17:"%",18:"^",19:">",20:"<",21:"==",22:"!=",23:">=",24:"<=",25:"||",26:"&&",27:"(",28:")",29:"?",30:":",31:"true",32:"false",33:"QUOTED_STRING",34:"NUMBER",35:"HEXNUMBER"},productions_:[0,[3,2],[6,3],[6,1],[8,3],[8,4],[8,1],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,2],[4,3],[4,7],[4,1],[4,1],[4,1],[4,3],[4,4],[4,1],[4,1],[4,1]],performAction:function(e,t,r,n,i,s,o){var a=s.length-1;switch(i){case 1:var u=s[a-1];return"function"==typeof u?u:function(e){return u};case 2:case 4:this.$=s[a-2].concat([s[a]]);break;case 3:case 6:this.$=[s[a]];break;case 5:this.$=s[a-3].concat([s[a-1]]);break;case 7:this.$=function(e){return T(n.parser,e,"_add",[s[a-2],s[a]])};break;case 8:this.$=function(e){return T(n.parser,e,"_subtract",[s[a-2],s[a]])};break;case 9:this.$=function(e){return T(n.parser,e,"_multiply",[s[a-2],s[a]])};break;case 10:this.$=function(e){return T(n.parser,e,"_divide",[s[a-2],s[a]])};break;case 11:this.$=function(e){return T(n.parser,e,"_mod",[s[a-2],s[a]])};break;case 12:this.$=function(e){return T(n.parser,e,"_pow",[s[a-2],s[a]])};break;case 13:this.$=function(e){return 1==T(n.parser,e,"_greaterThen",[s[a-2],s[a]])};break;case 14:this.$=function(e){return 1==T(n.parser,e,"_lessThen",[s[a-2],s[a]])};break;case 15:this.$=function(e){return 1==T(n.parser,e,"_equalTo",[s[a-2],s[a]])};break;case 16:this.$=function(e){return 0==T(n.parser,e,"_equalTo",[s[a-2],s[a]])};break;case 17:this.$=function(e){return 0==T(n.parser,e,"_lessThen",[s[a-2],s[a]])};break;case 18:this.$=function(e){return 0==T(n.parser,e,"_greaterThen",[s[a-2],s[a]])};break;case 19:this.$=function(e){return 1==T(n.parser,e,"_or",[s[a-2],s[a]])};break;case 20:this.$=function(e){return 1==T(n.parser,e,"_and",[s[a-2],s[a]])};break;case 21:this.$=function(e){return-F(s[a],e)};break;case 22:this.$=function(e){return F(s[a-1],e)};break;case 23:this.$=function(e){return F(s[a-5],e)?F(s[a-2],e):F(s[a],e)};break;case 24:this.$=!0;break;case 25:this.$=!1;break;case 26:this.$=function(e){return n.parser.getDotProperty(e,P(s[a],e),0)};break;case 27:this.$=function(e){return B(n.parser,e,P(s[a-2],e),void 0,!0)};break;case 28:this.$=function(e){return B(n.parser,e,P(s[a-3],e),s[a-1],!0)};break;case 29:this.$=e.slice(1,-1);break;case 30:this.$=Number(e);break;case 31:this.$=parseInt(e,16)}},table:[{3:1,4:2,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},{1:[3]},{5:[1,12],13:l,14:h,15:c,16:p,17:d,18:f,19:g,20:m,21:v,22:y,23:b,24:k,25:_,26:E},{4:27,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},{4:28,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},e(D,[2,24]),e(D,[2,25]),e(D,[2,26],{9:[1,30],11:[1,31],27:[1,29]}),e(D,[2,29]),e(D,[2,30]),e(D,[2,31]),e(x,[2,6]),{1:[2,1]},{4:32,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},{4:33,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},{4:34,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},{4:35,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},{4:36,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},{4:37,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},{4:38,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},{4:39,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},{4:40,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},{4:41,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},{4:42,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},{4:43,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},{4:44,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},{4:45,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},e(D,[2,21]),{13:l,14:h,15:c,16:p,17:d,18:f,19:g,20:m,21:v,22:y,23:b,24:k,25:_,26:E,28:[1,46]},{4:49,6:48,8:7,10:t,14:r,27:n,28:[1,47],31:i,32:s,33:o,34:a,35:u},{10:[1,50]},{4:51,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},e(C,[2,7],{15:c,16:p,17:d,18:f}),e(C,[2,8],{15:c,16:p,17:d,18:f}),e(w,[2,9],{18:f}),e(w,[2,10],{18:f}),e([5,7,12,13,14,17,19,20,21,22,23,24,25,26,28,30],[2,11],{15:c,16:p,18:f}),e(D,[2,12]),e(S,[2,13],{13:l,14:h,15:c,16:p,17:d,18:f}),e(S,[2,14],{13:l,14:h,15:c,16:p,17:d,18:f}),e(S,[2,15],{13:l,14:h,15:c,16:p,17:d,18:f}),e(S,[2,16],{13:l,14:h,15:c,16:p,17:d,18:f}),e(S,[2,17],{13:l,14:h,15:c,16:p,17:d,18:f}),e(S,[2,18],{13:l,14:h,15:c,16:p,17:d,18:f}),e(A,[2,19],{13:l,14:h,15:c,16:p,17:d,18:f,19:g,20:m,21:v,22:y,23:b,24:k}),e(A,[2,20],{13:l,14:h,15:c,16:p,17:d,18:f,19:g,20:m,21:v,22:y,23:b,24:k}),e(D,[2,22],{29:[1,52]}),e(D,[2,27]),{7:[1,54],28:[1,53]},e(M,[2,3],{13:l,14:h,15:c,16:p,17:d,18:f,19:g,20:m,21:v,22:y,23:b,24:k,25:_,26:E}),e(x,[2,4]),{12:[1,55],13:l,14:h,15:c,16:p,17:d,18:f,19:g,20:m,21:v,22:y,23:b,24:k,25:_,26:E},{4:56,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},e(D,[2,28]),{4:57,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},e(x,[2,5]),{13:l,14:h,15:c,16:p,17:d,18:f,19:g,20:m,21:v,22:y,23:b,24:k,25:_,26:E,30:[1,58]},e(M,[2,2],{13:l,14:h,15:c,16:p,17:d,18:f,19:g,20:m,21:v,22:y,23:b,24:k,25:_,26:E}),{4:59,8:7,10:t,14:r,27:n,31:i,32:s,33:o,34:a,35:u},e([5,7,12,28,30],[2,23],{13:l,14:h,15:c,16:p,17:d,18:f,19:g,20:m,21:v,22:y,23:b,24:k,25:_,26:E})],defaultActions:{12:[2,1]},parseError:function(e,t){if(!t.recoverable){var r=new Error(e);throw r.hash=t,r}this.trace(e)},parse:function(e){var t=this,r=[0],n=[null],i=[],s=this.table,o="",a=0,u=0,l=i.slice.call(arguments,1),h=Object.create(this.lexer),c={yy:{}};for(var p in this.yy)Object.prototype.hasOwnProperty.call(this.yy,p)&&(c.yy[p]=this.yy[p]);h.setInput(e,c.yy),c.yy.lexer=h,c.yy.parser=this,void 0===h.yylloc&&(h.yylloc={});var d=h.yylloc;i.push(d);var f=h.options&&h.options.ranges;"function"==typeof c.yy.parseError?this.parseError=c.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var g,m,v,y,b,k,_,E,D,x={};;){if(m=r[r.length-1],this.defaultActions[m]?v=this.defaultActions[m]:(null==g&&(D=void 0,"number"!=typeof(D=h.lex()||1)&&(D=t.symbols_[D]||D),g=D),v=s[m]&&s[m][g]),void 0===v||!v.length||!v[0]){var C="";for(b in E=[],s[m])this.terminals_[b]&&b>2&&E.push("'"+this.terminals_[b]+"'");C=h.showPosition?"Parse error on line "+(a+1)+":\n"+h.showPosition()+"\nExpecting "+E.join(", ")+", got '"+(this.terminals_[g]||g)+"'":"Parse error on line "+(a+1)+": Unexpected "+(1==g?"end of input":"'"+(this.terminals_[g]||g)+"'"),this.parseError(C,{text:h.match,token:this.terminals_[g]||g,line:h.yylineno,loc:d,expected:E})}if(v[0]instanceof Array&&v.length>1)throw new Error("Parse Error: multiple actions possible at state: "+m+", token: "+g);switch(v[0]){case 1:r.push(g),n.push(h.yytext),i.push(h.yylloc),r.push(v[1]),g=null,u=h.yyleng,o=h.yytext,a=h.yylineno,d=h.yylloc;break;case 2:if(k=this.productions_[v[1]][1],x.$=n[n.length-k],x._$={first_line:i[i.length-(k||1)].first_line,last_line:i[i.length-1].last_line,first_column:i[i.length-(k||1)].first_column,last_column:i[i.length-1].last_column},f&&(x._$.range=[i[i.length-(k||1)].range[0],i[i.length-1].range[1]]),void 0!==(y=this.performAction.apply(x,[o,u,a,c.yy,v[1],n,i].concat(l))))return y;k&&(r=r.slice(0,-1*k*2),n=n.slice(0,-1*k),i=i.slice(0,-1*k)),r.push(this.productions_[v[1]][0]),n.push(x.$),i.push(x._$),_=s[r[r.length-2]][r[r.length-1]],r.push(_);break;case 3:return!0}}return!0}};function F(e,t){return"function"==typeof e?e(t):e}function P(e,t){return e&&(e=e.map((function(e){return F(e,t)}))),e}function T(e,t,r,n){return e[r].apply(e,P(n,t))}function B(e,t,r,n,i){var s,o,a;if((s="string"==typeof r?i?r.split("."):[r]:r).length>1){var u=s.pop();o=(a=e.getDotProperty(t,s))[u]}else o=e.getProperty(t,r),a=e;return null==o&&(o=e.getProperty(t,"defaultHandler"),a=e),o.apply(a,P(n,t))}var R=function(){var e={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,r=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(n=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],r=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var s in i)this[s]=i[s];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,r,n;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),s=0;s<i.length;s++)if((r=this._input.match(this.rules[i[s]]))&&(!t||r[0].length>t[0].length)){if(t=r,n=s,this.options.backtrack_lexer){if(!1!==(e=this.test_match(r,i[s])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,i[n]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var e=this.next();return e||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(e,t,r,n){switch(r){case 0:break;case 1:return 34;case 2:return 35;case 3:return 15;case 4:return 16;case 5:return 14;case 6:return 13;case 7:return 18;case 8:return 17;case 9:return">=";case 10:return"<=";case 11:return 19;case 12:return 20;case 13:return"==";case 14:return"!=";case 15:return"||";case 16:return"&&";case 17:return"?";case 18:return":";case 19:return 27;case 20:return 28;case 21:return 11;case 22:return 12;case 23:return 7;case 24:return 9;case 25:return 31;case 26:return 32;case 27:return 10;case 28:return 33;case 29:return 5;case 30:return"INVALID"}},rules:[/^(?:\s+)/,/^(?:[0-9]+(\.[0-9]+)?\b)/,/^(?:\b0x[0-9A-Fa-f]+\b)/,/^(?:\*)/,/^(?:\/)/,/^(?:-)/,/^(?:\+)/,/^(?:\^)/,/^(?:%)/,/^(?:>=)/,/^(?:<=)/,/^(?:>)/,/^(?:<)/,/^(?:==)/,/^(?:!=)/,/^(?:\|\|)/,/^(?:&&)/,/^(?:\?)/,/^(?::)/,/^(?:\()/,/^(?:\))/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?:\.)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:[^\s\*\/\-\+\^\%\>\=\<\!\|\&\?\:\(\)\[\]\,\.\"\']+)/,/^(?:"(\\.|[^\"\\])*"|'(\\.|[^\'\\])*')/,/^(?:$)/,/^(?:.)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30],inclusive:!0}}};return e}();function L(){this.yy={}}return O.lexer=R,L.prototype=O,O.Parser=L,new L}();void 0!==k&&(e.parser=t,e.Parser=t.Parser,e.parse=function(){return t.parse.apply(t,arguments)})}(_);var E=e(_),D=function(e,t,r,n){if(void 0===n&&(n=!0),e&&"number"!=typeof e&&"string"!=typeof e){if(t in e)return e[t];if(n&&(Array.isArray(t)||-1!==t.indexOf("."))){for(var i=Array.isArray(t)?t:t.split("."),s=e,o=0;o<i.length;o++){if(!((t=i[o])in s)){s=r;break}s=s[t]}return s}return r}return r};class x extends E.Parser{getProperty(e,t,r){var n=D(e,t,void 0,!1);return void 0!==n?n:D(this,t,r,!1)}getDotProperty(e,t,r){var n=D(e,t,void 0,!0);return void 0!==n?n:D(this,t,r,!0)}static GetProperty(e,t,r,n){return D(e,t,r,n)}_add(e,t){return e+t}_subtract(e,t){return e-t}_multiply(e,t){return e*t}_divide(e,t){return e/t}_mod(e,t){return e%t}_pow(e,t){return Math.pow(e,t)}_greaterThen(e,t){return e>t}_lessThen(e,t){return e<t}_equalTo(e,t){return e==t}_or(e,t){return e||t}_and(e,t){return e&&t}defaultHandler(e,t){return 0}compile(e){return this.parse(e)}exec(e,t){return"string"==typeof e&&(e=this.compile(e)),e(t)}}var C=new x,w=function(e){return C.compile(e)};class S extends b{constructor(e){var t;super(),t="number"==typeof e?function(){return e}:w(e),this.setExpressionHandler(t)}}class A extends S{eval(e){return!!super.eval(e)}}var M=new class{constructor(e){void 0===e&&(e={});var t=e.delimiters;void 0===t&&(t=["{{","}}"]),this.setDelimiters(t[0],t[1]);var r=e.expressionParser;void 0===r&&(r=new x),this.setExpressionParser(r)}setDelimiters(e,t){return void 0===t&&(t=e[1],e=e[0]),this.delimiterLeft=e,this.delimiterRight=t,this.reDelimiter=RegExp(`${e}|${t}`,"gi"),this.reSplit=RegExp(`${e}.*?${t}`,"gi"),this}setExpressionParser(e){return this.expressionParser=e,this}compile(e,t){var r,n,i;if(t)if(t instanceof x){(u=t)&&(i=this.expressionParser,this.setExpressionParser(u))}else{var s=t.delimiters;s&&(r=this.delimiterLeft,n=this.delimiterRight,this.setDelimiters(s[0],s[1])),(u=t.expressionParser)&&(i=this.expressionParser,this.setExpressionParser(u))}for(var o=this.reDelimiter,a=this.reSplit,u=this.expressionParser,l=[],h=0;;){var c=a.exec(e);if(!c)break;var p=c[0],d=a.lastIndex,f=d-p.length;h<f&&l.push(e.substring(h,f));var g=e.substring(f,d).replace(o,"");l.push(u.compile(g)),h=d}var m=e.length;return h<m&&l.push(e.substring(h,m)),r&&this.setDelimiters(r,n),i&&this.setExpressionParser(i),function(e){return l.map((function(t){return"function"==typeof t&&(t=t(e)),t})).join("")}}render(e,t,r){return("string"==typeof e?this.compile(e,r):e)(t)}};class O extends b{constructor(e){super();var t,r,n=(t=e,M.compile(t,r));this.setExpressionHandler(n)}}class F{constructor({id:e,category:t,name:r,title:n,description:i,properties:s}={}){void 0===e&&(e=g()),this.parent=null,this.id=e,this.category=t||"",this.name=r||"",this.title=n||this.name,this.description=i||"",this.properties=s||{}}destroy(){this.parent=void 0,this.properties=void 0}setTitle(e){return this.title=e,this}setName(e){return this.name=e,this}setDescription(e){return this.description=e,this}setParent(e){return this.parent=e,this}getParent(){return this.parent}getTree(e){if(e)return e.tree;for(var t=this.parent;t;){if(t.category===s)return t;t=t.parent}return null}addExpression(e){return new S(e)}addBooleanExpression(e){return new A(e)}addStringTemplateExpression(e){return new O(e)}_execute(e){this._enter(e),this.getOpenState(e)||this._open(e);var t=this._tick(e);return 1!==t&&2!==t&&5!==t&&9!==t||this._close(e),this._exit(e),t}_enter(e){e._enterNode(this),this.enter(e)}_open(e){e._openNode(this),this.setOpenState(e,!0),this.open(e)}_tick(e){return e._tickNode(this),this.tick(e)}_close(e){e._closeNode(this),this.setOpenState(e,!1),this.close(e),this.abortChildren(e)}_exit(e){e._exitNode(this),this.exit(e)}_abort(e){this._close(e),this.abort(e)}enter(e){}open(e){}tick(e){}close(e){}exit(e){}abortChildren(e){}abort(e){}getNodeMemory(e){return e.getNodeMemory(this.id)}getOpenState(e){return this.getNodeMemory(e).$isOpen}setOpenState(e,t){return void 0===t&&(t=!0),this.getNodeMemory(e).$isOpen=t,this}get SUCCESS(){return 1}get FAILURE(){return 2}get RUNNING(){return 3}get ERROR(){return 9}}class P extends F{constructor({name:e="Action",title:t,properties:r,services:n}={},i){if(super({category:u,name:e,title:t,properties:r}),n)for(var s=0,o=n.length;s<o;s++)this.addService(n[s],i)}destroy(){if(this.services)for(var e=0,t=this.services.length;e<t;e++)this.services[e].destroy();this.services=void 0,super.destroy()}addService(e,t){return"string"==typeof e&&(e=t[e]),void 0===this.services&&(this.services=[]),-1===this.services.indexOf(e)&&(this.services.push(e),e.setParent(this)),this}_tick(e){if(e._tickNode(this),this.services)for(var t=0,r=this.services.length;t<r;t++)this.services[t]._tick(e);return this.tick(e)}}class T extends F{constructor({children:e=[],name:t="Composite",title:r,properties:n,services:i}={},s){super({category:o,name:t,title:r,properties:n}),this.children=[];for(var a=0,u=e.length;a<u;a++)this.addChild(e[a],s);if(i)for(a=0,u=i.length;a<u;a++)this.addService(i[a],s)}destroy(){for(var e=0,t=this.children.length;e<t;e++)this.children[e].destroy();if(this.services)for(e=0,t=this.services.length;e<t;e++)this.services[e].destroy();this.children=void 0,this.services=void 0,super.destroy()}insertChild(e,t,r){return"string"==typeof e&&(e=t[e]),-1===this.children.indexOf(e)&&(r<0&&(r=this.children.length+r),void 0===r||r>=this.children.length?this.children.push(e):this.children.splice(r,0,e),e.setParent(this)),this}addChild(e,t){return this.insertChild(e,t),this}addService(e,t){return"string"==typeof e&&(e=t[e]),void 0===this.services&&(this.services=[]),-1===this.services.indexOf(e)&&(this.services.push(e),e.setParent(this)),this}_tick(e){if(e._tickNode(this),this.services)for(var t=0,r=this.services.length;t<r;t++)this.services[t]._tick(e);return this.tick(e)}abortChildren(e){for(var t=0,r=this.children.length;t<r;t++){var n=this.children[t];n.getOpenState(e)&&n._abort(e)}}}class B extends F{constructor({child:e=null,name:t="Decorator",title:r,properties:n}={},i){super({category:a,name:t,title:r,properties:n}),this.child=null,e&&this.addChild(e,i)}destroy(){this.child&&this.child.destroy(),this.child=void 0,super.destroy()}addChild(e,t){return"string"==typeof e&&(e=t[e]),this.child=e,e.setParent(this),this}chainChild(e,t){for(var r=this;r.child instanceof B;)r=r.child;return r.addChild(e,t),this}isChildRunning(e){return this.child.getOpenState(e)}abortChildren(e){this.isChildRunning(e)&&this.child._abort(e)}openChild(e){return this.child.setOpenState(e,!0),this}}class R extends P{constructor({services:e,title:t,name:r="Succeeder"}={}){super({services:e,title:t,name:r})}tick(e){return 1}}class L extends P{constructor({services:e,title:t,name:r="Failer"}={}){super({services:e,title:t,name:r})}tick(e){return 2}}class N extends P{constructor({services:e,title:t,name:r="Abort"}={}){super({services:e,title:t,name:r})}tick(e){return 5}}let j=class extends B{constructor({child:e=null,title:t,name:r="Break",tag:n}={},i){super({child:e,title:t,name:r,properties:{tag:n}},i),this.breakFlag=!1,this.tag=n}setBreakFlag(e){return void 0===e&&(e=!0),this.breakFlag=e,this}tick(e){if(!this.child)return 1;var t=this.child._execute(e);return this.breakFlag&&(t=1,this.breakFlag=!1),t}},I=class extends P{constructor({breakDecoratorTitle:e,tag:t,services:r,title:n,name:i="Break"}={}){super({name:i,title:n,properties:{breakDecoratorTitle:e,tag:t},services:r}),this.breakDecoratorTitle=e,this.tag=t}tick(e){for(var t,r=this.getParent();!(r instanceof j)||this.tag&&this.tag!==r.tag||this.breakDecoratorTitle&&this.breakDecoratorTitle!==r.title;){if(!r.getParent){r=null;break}r=r.getParent()}return r?(r.setBreakFlag(),t=5):(console.error("[EventSheet] Can't get responded BreakDecorator, ignore this break action node."),t=1),t}};class $ extends T{constructor({children:e=[],services:t,title:r,name:n="Selector"}={},i){super({children:e,services:t,title:r,name:n},i)}open(e){this.getNodeMemory(e).$runningChild=-1}tick(e){if(0===this.children.length)return 9;var t,r=this.getNodeMemory(e),n=r.$runningChild;if(n<0){for(var i=0,s=this.children.length;i<s;i++)if(3===(t=this.children[i]._execute(e))||1===t||5===t){n=i;break}}else t=this.children[n]._execute(e);return r.$runningChild=3===t?n:-1,t}abortChildren(e){var t=this.getNodeMemory(e),r=this.children[t.$runningChild];r&&(r._abort(e),t.$runningChild=-1)}}class G extends T{constructor({children:e=[],services:t,title:r,name:n="Sequence"}={},i){super({children:e,services:t,title:r,name:n},i)}open(e){this.getNodeMemory(e).$runningChild=0}tick(e){if(0===this.children.length)return 9;for(var t,r=this.getNodeMemory(e),n=r.$runningChild,i=this.children.length;n<i&&(3!==(t=this.children[n]._execute(e))&&2!==t&&5!==t);n++);return r.$runningChild=3===t?n:-1,t}abortChildren(e){var t=this.getNodeMemory(e),r=this.children[t.$runningChild];r&&(r._abort(e),t.$runningChild=-1)}}
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/var U=function(e,t){if(!(t>=e.length)){for(var r=e.length-1,n=e[t],i=t;i<r;i++)e[i]=e[i+1];return e.length=r,n}},z=function(e,t,r,n){var i;if(void 0===n&&(n=e),!Array.isArray(t))return-1!==(i=e.indexOf(t))?(U(e,i),r&&r.call(n,t),t):null;for(var s=t.length-1;s>=0;){var o=t[s];-1!==(i=e.indexOf(o))?(U(e,i),r&&r.call(n,o)):t.pop(),s--}return t};
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2019 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/class V extends T{constructor({expression:e="true",conditionEvalBreak:t=!1,children:r=[],services:n,title:i,name:s="IfSelector"}={},o){super({children:r,services:n,title:i,name:s,properties:{expression:e,conditionEvalBreak:t}},o),this.expression=this.addBooleanExpression(e),this.conditionEvalBreak=t,this.forceSelectChildIndex=void 0}open(e){this.getNodeMemory(e).$runningChild=-1}setSelectChildIndex(e){return this.forceSelectChildIndex=e,this}evalCondition(e){return void 0!==this.forceSelectChildIndex?this.forceSelectChildIndex:e.evalExpression(this.expression)?0:1}tick(e){if(0===this.children.length)return 9;var t=this.getNodeMemory(e),r=t.$runningChild;if(r<0&&(r=this.evalCondition(e),this.conditionEvalBreak))return t.$runningChild=r,3;var n=this.children[r]._execute(e);return t.$runningChild=3===n?r:-1,n}abortChildren(e){var t=this.getNodeMemory(e),r=this.children[t.$runningChild];r&&(r._abort(e),t.$runningChild=-1)}}class H extends B{constructor({child:e=null,title:t,name:r="ForceFailure"}={},n){super({child:e,title:t,name:r,properties:{}},n)}tick(e){if(!this.child)return 9;var t=this.child._execute(e);return 1===t?2:t}}class W extends B{constructor({maxLoop:e=-1,child:t=null,title:r,name:n="Repeat"}={},i){super({child:t,title:r,name:n,properties:{maxLoop:e}},i),this.maxLoopExpression=this.addExpression(e)}open(e){var t=this.getNodeMemory(e);t.$maxLoop=e.evalExpression(this.maxLoopExpression),t.$i=0}tick(e){if(!this.child)return 9;for(var t=this.getNodeMemory(e),r=t.$maxLoop,n=t.$i,i=1;(r<0||n<r)&&(1===(i=this.child._execute(e))||2===i);)n++;return t.$i=n,i}}class q extends B{constructor({maxLoop:e=-1,returnSuccess:t=!1,child:r=null,title:n,name:i="RepeatUntilFailure"}={},s){super({child:r,title:n,name:i,properties:{returnSuccess:t,maxLoop:e}},s),this.maxLoopExpression=this.addExpression(e),this.returnSuccess=t}open(e){var t=this.getNodeMemory(e);t.$maxLoop=e.evalExpression(this.maxLoopExpression),t.$i=0}tick(e){if(!this.child)return 9;for(var t=this.getNodeMemory(e),r=t.$maxLoop,n=t.$i,i=9;(r<0||n<r)&&1===(i=this.child._execute(e));)n++;return t.$i=n,i===this.FAILURE&&this.returnSuccess&&(i=1),i}}class K extends B{constructor({expression:e="true",conditionEvalBreak:t=!1,onFailState:r=2,child:n=null,title:i,name:s="If"}={},o){super({child:n,title:i,name:s,properties:{expression:e,conditionEvalBreak:t,onFailState:r}},o),this.expression=this.addBooleanExpression(e),this.conditionEvalBreak=t,this.onFailState=r}tick(e){if(!this.child)return 9;if(!this.isChildRunning(e)){if(!e.evalExpression(this.expression))return this.onFailState;if(this.conditionEvalBreak)return this.openChild(),RUNNING}return this.child._execute(e)}}var X=Object.freeze({__proto__:null,Abort:N,AbortIf:class extends B{constructor({expression:e="true",returnSuccess:t=!0,child:r=null,title:n,name:i="AbortIf"}={},s){super({child:r,title:n,name:i,properties:{expression:e,returnSuccess:t}},s),this.expression=this.addBooleanExpression(e),this.returnSuccess=t}tick(e){return this.child?this.isChildRunning(e)&&e.evalExpression(this.expression)?this.returnSuccess?1:2:this.child._execute(e):9}},Action:P,BaseNode:F,BreakAction:I,BreakDecorator:j,Bypass:class extends B{constructor({child:e=null,title:t,name:r="Bypass"}={},n){super({child:e,title:t,name:r},n)}tick(e){return this.child?this.child._execute(e):9}},Composite:T,ContinueIf:class extends B{constructor({expression:e="true",returnSuccess:t=!0,child:r=null,title:n,name:i="ContinueIf"}={},s){super({child:r,title:n,name:i,properties:{expression:e,returnSuccess:t}},s),this.expression=this.addBooleanExpression(e),this.returnSuccess=t}tick(e){return this.child?this.isChildRunning(e)&&!e.evalExpression(this.expression)?this.returnSuccess?1:2:this.child._execute(e):9}},Cooldown:class extends B{constructor({duration:e=0,child:t=null,title:r,name:n="Cooldown"}={},i){super({child:t,title:r,name:n,properties:{duration:e}},i),this.durationExpression=this.addExpression(e)}open(e){this.getNodeMemory(e).$cooldownTime=e.evalExpression(this.durationExpression)}tick(e){if(!this.child)return 9;var t=this.getNodeMemory(e),r=e.currentTime,n=t.$lastEndTime,i=t.$cooldownTime;if(void 0!==n&&r-n<i)return 2;var s=this.child._execute(e);return 1!==s&&2!==s&&5!==s||(t.$lastEndTime=r),s}},Decorator:B,Error:class extends P{constructor({services:e,title:t,name:r="Error"}={}){super({services:e,title:t,name:r})}tick(e){return 9}},Failer:L,ForceFailure:H,ForceSuccess:class extends B{constructor({child:e=null,title:t,name:r="ForceSuccess"}={},n){super({child:e,title:t,name:r,properties:{}},n)}tick(e){if(!this.child)return 9;var t=this.child._execute(e);return 2===t?1:t}},If:K,IfSelector:V,Invert:class extends B{constructor({child:e=null,title:t,name:r="Invert"}={},n){super({child:e,title:t,name:r},n)}tick(e){if(!this.child)return 9;var t=this.child._execute(e);return 1===t?t=2:2===t&&(t=1),t}},Limiter:class extends B{constructor({maxLoop:e=1,child:t=null,title:r,name:n="Limiter"}={},i){super({child:t,title:r,name:n,properties:{maxLoop:e}},i),this.maxLoopExpression=this.addExpression(e)}open(e){var t=this.getNodeMemory(e);t.$maxLoop=e.evalExpression(this.maxLoopExpression),t.$i=0}tick(e){if(!this.child)return 9;var t=this.getNodeMemory(e),r=t.$maxLoop,n=t.$i;if(n>=r)return 2;var i=this.child._execute(e);return 1!==i&&2!==i||(t.$i=n+1),i}},Parallel:class extends T{constructor({finishMode:e=0,returnSuccess:t=!0,children:r=[],services:n,title:i,name:s="Parallel"}={},o){super({children:r,services:n,title:i,name:s,properties:{finishMode:e,returnSuccess:t}},o),this.finishMode=e,this.returnSuccess=t}open(e){this.getNodeMemory(e).$runningChildren=this.children.map(((e,t)=>t))}tick(e){if(0===this.children.length)return 9;for(var t=this.getNodeMemory(e),r=t.$runningChildren,n={},i=!1,s=!1,o=!1,a=!1,u=0,l=r.length;u<l;u++){var h=r[u],c=this.children[h]._execute(e);switch(n[h]=c,0===h&&(t.$mainTaskStatus=c),c){case 1:case 2:i=!0;break;case 3:s=!0;break;case 5:o=!0;break;case 9:a=!0}}if(i)for(var h in n){1!==(c=n[h])&&2!==c||z(r,parseInt(h))}return 0===this.finishMode?t.$mainTaskStatus:a?9:o?5:s?3:this.returnSuccess?1:t.$mainTaskStatus}abortChildren(e){for(var t=this.getNodeMemory(e),r=t.$runningChildren,n=0,i=r.length;n<i;n++){var s=r[n];this.children[s]._abort(e)}t.$runningChildren.length=0}},RandomSelector:class extends T{constructor({children:e=[],services:t,title:r,name:n="RandomSelector"}={},i){super({children:e,services:t,title:r,name:n},i)}open(e){this.getNodeMemory(e).$runningChild=-1}tick(e){if(0===this.children.length)return ERROR;var t=this.getNodeMemory(e),r=t.$runningChild;r<0&&(r=Math.floor(Math.random()*this.children.length));var n=this.children[r]._execute(e);return t.$runningChild=n===RUNNING?r:-1,n}abortChildren(e){var t=this.getNodeMemory(e),r=this.children[t.$runningChild];r&&(r._abort(e),t.$runningChild=-1)}}
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/,Repeat:W,RepeatUntilFailure:q,RepeatUntilSuccess:class extends B{constructor({maxLoop:e=-1,child:t=null,title:r,name:n="RepeatUntilSuccess"}={},i){super({child:t,title:r,name:n,properties:{maxLoop:e}},i),this.maxLoopExpression=this.addExpression(e)}open(e){var t=this.getNodeMemory(e);t.$maxLoop=e.evalExpression(this.maxLoopExpression),t.$i=0}tick(e){if(!this.child)return 9;for(var t=this.getNodeMemory(e),r=t.$maxLoop,n=t.$i,i=9;(r<0||n<r)&&2===(i=this.child._execute(e));)n++;return t.$i=n,i}},Runner:class extends P{constructor({services:e,title:t,name:r="Runner"}={}){super({services:e,title:t,name:r})}tick(e){return 3}},Selector:$,Sequence:G,Service:class extends F{constructor({interval:e=0,randomDeviation:t=0,name:r="Service",title:n,properties:i}={}){void 0===i&&(i={}),i.interval=e,i.randomDeviation=t,super({category:"service",name:r,title:n,properties:i}),this.intervalExpression=this.addExpression(e),this.randomDeviationExpression=this.addExpression(t)}_tick(e){this.canTick(e)&&this.tick(e)}canTick(e){var t=this.getNodeMemory(e),r=e.currentTime,n=t.$lastEndTime,i=t.$interval,s=void 0===n||r-n>=i;if(s){t.$lastEndTime=r;i=e.evalExpression(this.intervalExpression);var o=e.evalExpression(this.randomDeviationExpression);o>0&&(i+=(.5-Math.random())*o),t.$interval=i}return s}},ShuffleSelector:class extends T{constructor({children:e=[],services:t,title:r,name:n="ShuffleSelector"}={},i){super({children:e,services:t,title:r,name:n},i)}open(e){var t=this.getNodeMemory(e);t.$runningChild=0,t.$children||(t.$children=this.children.map(((e,t)=>t))),function(e){for(var t=e.length-1;t>0;t--){var r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}}(t.$children)}tick(e){if(0===this.children.length)return 9;for(var t,r=this.getNodeMemory(e),n=r.$runningChild,i=r.$children,s=n,o=i.length;s<o&&(3!==(t=this.children[i[s]]._execute(e))&&1!==t&&5!==t);s++);return r.$runningChild=3===t?s:-1,t}abortChildren(e){var t=this.getNodeMemory(e),r=this.children[t.$runningChild];r&&(r._abort(e),t.$runningChild=-1)}},Succeeder:R,SwitchSelector:class extends T{constructor({expression:e=null,keys:t,conditionEvalBreak:r=!1,children:n={},services:i,title:s,name:o="SwitchSelector"}={},a){void 0===t&&(t=Object.keys(n),n=Object.values(n)),super({children:n,services:i,title:s,name:o,properties:{expression:e,keys:t,conditionEvalBreak:r}},a),this.expression=this.addExpression(e),this.keys=t,this.conditionEvalBreak=r,this.forceSelectChildIndex=void 0}open(e){this.getNodeMemory(e).$runningChild=-1}setSelectChildIndex(e){return this.forceSelectChildIndex=e,this}evalCondition(e){if(void 0!==this.forceSelectChildIndex)return"number"==typeof this.forceSelectChildIndex?this.forceSelectChildIndex:this.keys.indexOf(this.forceSelectChildIndex);var t=e.evalExpression(this.expression);return this.keys.indexOf(t)}tick(e){if(0===this.children.length)return 9;var t=this.getNodeMemory(e),r=t.$runningChild;if(r<0){if(-1===(r=this.evalCondition(e))&&(r=this.keys.indexOf("default")),-1===r)return 9;if(this.conditionEvalBreak)return t.$runningChild=r,3}var n=this.children[r]._execute(e);return t.$runningChild=3===n?r:-1,n}abortChildren(e){var t=this.getNodeMemory(e),r=this.children[t.$runningChild];r&&(r._abort(e),t.$runningChild=-1)}},TimeLimit:class extends B{constructor({duration:e=0,returnSuccess:t=!0,child:r=null,title:n,name:i="TimeLimit"}={},s){super({child:r,title:n,name:i,properties:{duration:e,returnSuccess:t}},s),this.durationExpression=this.addExpression(e),this.returnSuccess=t}open(e){var t=this.getNodeMemory(e);t.$startTime=e.currentTime,t.$duration=e.evalExpression(this.durationExpression)}tick(e){if(!this.child)return 9;var t=this.getNodeMemory(e);return e.currentTime-t.$startTime>=t.$duration?this.returnSuccess?SUCCESS:2:this.child._execute(e)}},Wait:class extends P{constructor({duration:e=0,services:t,title:r,name:n="Wait"}={}){super({title:r,name:n,properties:{duration:e},services:t}),this.durationExpression=this.addExpression(e)}open(e){var t=this.getNodeMemory(e);t.$startTime=e.currentTime,t.$duration=e.evalExpression(this.durationExpression)}tick(e){var t=this.getNodeMemory(e),r=e.currentTime,n=t.$startTime,i=t.$duration;if(i>0){if(r-n<i)return 3}else if(0===i&&r===n)return 3;return 1}},WeightSelector:class extends T{constructor({expression:e=null,weights:t,conditionEvalBreak:r=!1,children:n=[],services:i,title:s,name:o="WeightSelector"}={},a){if(void 0===t){t=[];for(var u=0,l=0,h=n.length;l<h;l++){var c,p=n[l];p instanceof F||"string"==typeof p?c=1:(c=p.weight,n[l]=p.node),t.push(c),u+=c}for(l=0,h=t.length;l<h;l++)t[l]/=u}super({children:n,services:i,title:s,name:o,properties:{expression:e,weights:t,conditionEvalBreak:r}},a),this.expression=e?this.addExpression(e):null,this.weights=t,this.conditionEvalBreak=r,this.forceSelectChildIndex=void 0}open(e){this.getNodeMemory(e).$runningChild=-1}setSelectChildIndex(e){return void 0!==this.forceSelectChildIndex?this.forceSelectChildIndex:(this.forceSelectChildIndex=e,this)}evalCondition(e){if(void 0!==this.forceSelectChildIndex)return this.forceSelectChildIndex;for(var t=this.expression?e.evalExpression(this.expression):Math.random(),r=0,n=this.weights.length;r<n;r++)if((t-=this.weights[r])<0)return r}tick(e){if(0===this.children.length)return 9;var t=this.getNodeMemory(e),r=t.$runningChild;if(r<0&&(void 0===(r=this.evalCondition(e))&&(r=this.children.length-1),this.conditionEvalBreak))return t.$runningChild=r,3;var n=this.children[r]._execute(e);return t.$runningChild=3===n?r:-1,n}abortChildren(e){var t=this.getNodeMemory(e),r=this.children[t.$runningChild];r&&(r._abort(e),t.$runningChild=-1)}}});class Y{constructor(){this.tree=null,this.blackboard=null,this.target=null,this._openNodes=[],this._nodeCount=0,this._currentNode=null,this._currentTime=void 0}destroy(){this.tree=null,this.blackboard=null,this.target=null,this._openNodes.length=0}setTree(e){return this.tree=e,this}setBlackBoard(e){return this.blackboard=e,this}setTarget(e){return this.target=e,this}reset(){return this._openNodes.length=0,this._nodeCount=0,this._currentTime=void 0,this}getGlobalMemory(){return this.blackboard.getGlobalMemory()}getTreeMemory(){return this.blackboard.getTreeMemory(this.tree.id)}getNodeMemory(e){return this.blackboard.getNodeMemory(this.tree.id,e)}get currentTime(){return this.blackboard.hasValidCurrentTime()?this.blackboard.getCurrentTime():(void 0===this._currentTime&&(this._currentTime=(new Date).getTime()),this._currentTime)}evalExpression(e){return e.eval(this.blackboard.getGlobalMemory())}_enterNode(e){this._nodeCount++,this._openNodes.push(e),this._currentNode=e}_openNode(e){this._currentNode=e}_tickNode(e){this._currentNode=e}_closeNode(e){z(this._openNodes,e),this._currentNode=e}_exitNode(e){this._currentNode=e}}class J{constructor({id:e,title:t,description:r,properties:n,root:i=null}={}){void 0===e&&(e=g()),this.id=e,this.name="",this.category=s,this.title=t||"",this.description=r||"",this.properties=n||{},this._root=i,this.ticker=(new Y).setTree(this)}destroy(){this._root.destroy(),this.ticker.destroy(),this._root=void 0,this.ticker=void 0}setTitle(e){return this.title=e,this}setName(e){return this.name=e,this}setDescription(e){return this.description=e,this}setRoot(e){return this.root=e,this}getRoot(){return this.root}get root(){return this._root}set root(e){e?(this._root=e,e.setParent(this)):(this._root&&this._root.setParent(null),this._root=null)}forEachNode(e,t){return v(this.root,e,t),this}getAllNodes(e){return void 0===e&&(e=[]),this.forEachNode((function(t){e.push(t)})),e}getChildrenNodes(e,t){return void 0===e&&(e=this.root),void 0===t&&(t=[]),v(e,(function(e){t.push(e)})),t}tick(e,t){if(!e)throw"The blackboard parameter is obligatory and must be an instance of Blackboard";var r=this.ticker;r.setBlackBoard(e).setTarget(t).reset();var n=this.root._execute(r);return e.set(l,n,this.id),n}abort(e,t){if(!e)throw"The blackboard parameter is obligatory and must be an instance of Blackboard";var r=this.ticker;return r.setBlackBoard(e).setTarget(t).reset(),this.root.abortChildren(r),e.set(l,0,this.id),0}static setStartIDValue(e){d(e)}static getSerialNumber(){return f()}static setSerialIDPrefix(e){!function(e){p=e}(e)}}var Z={dump:function(){var e={sn:f(),id:this.id,title:this.title,description:this.description,root:this.root?this.root.id:null,properties:y(this.properties),nodes:[]};if(!this.root)return e;var t=[];v(this.root,(function(e){t.push(e)}));for(var r=0,n=t.length;r<n;r++){var i=t[r],s={id:i.id,name:i.name,title:i.title,description:i.description,properties:y(i.properties)};switch(i.category){case o:s.children=i.children.map((e=>e.id)),i.services&&(s.services=i.services.map((e=>e.id)));break;case a:i.child&&(s.child=i.child.id);break;case u:i.services&&(s.services=i.services.map((e=>e.id)))}e.nodes.push(s)}return e},load:function(e,t){var r=e.sn;null!=r&&d(Math.max(f(),r)),t=t||{},this.title=e.title||this.title,this.description=e.description||this.description,this.properties=e.properties||this.properties;for(var n=e.nodes,i={},s=n.length-1;s>=0;s--){var o,a=n[s],u=a.name;if(u in t)o=t[u];else{if(!(u in X))throw new EvalError(`BehaviorTree.load: Invalid node name "${u}".`);o=X[u]}var l={};a.hasOwnProperty("children")&&(l.children=a.children),a.hasOwnProperty("child")&&(l.child=a.child),a.hasOwnProperty("services")&&(l.services=a.services);var h=new o(l=Object.assign(l,a.properties),i);h.id=a.id||h.id,h.title=a.title||h.title,h.description=a.description||h.description,h.properties=a.properties||h.properties,i[h.id]=h}return this.root=i[e.root],this}};Object.assign(J.prototype,Z,m);var Q=function(e){return null==e||""===e||0===e.length},ee=function(e,t,r,n){if(void 0===n&&(n="."),"object"==typeof e){if(Q(t)){if(null==r)return;"object"==typeof r&&(e=r)}else{"string"==typeof t&&(t=t.split(n));var i=t.pop(),s=function(e,t,r){var n=e;if(Q(t));else{var i;"string"==typeof t&&(t=t.split("."));for(var s=0,o=t.length;s<o;s++){var a;null!=n[i=t[s]]&&"object"==typeof n[i]||(a=s===o-1?void 0===r?{}:r:{},n[i]=a),n=n[i]}}return n}(e,t);s[i]=r}return e}},te=function(e,t,r){if(!e||"number"==typeof e)return r;if("string"==typeof t){if(e.hasOwnProperty(t))return e[t];if(-1===t.indexOf("."))return r;t=t.split(".")}for(var n=t,i=e,s=r,o=0;o<n.length;o++){if(t=n[o],!i.hasOwnProperty(t)){s=r;break}i=s=i[t]}return s},re=function(e){return null==e||""===e||0===e.length},ne=function(e,t,r){if(void 0===r&&(r="."),"object"==typeof e){if(re(t));else{"string"==typeof t&&(t=t.split(r));var n=t.pop(),i=function(e,t){var r=e;if(re(t));else{var n;"string"==typeof t&&(t=t.split("."));for(var i=0,s=t.length;i<s;i++){if(null==r[n=t[i]]||"object"!=typeof r[n])return;r=r[n]}}return r}(e,t);i&&delete i[n]}return e}};let ie=class{constructor(){this._baseMemory={},this._treeMemory={}}destroy(){this._baseMemory=void 0,this._treeMemory=void 0}_getTreeMemory(e){return this._treeMemory[e]||(this._treeMemory[e]={nodeMemory:{}}),this._treeMemory[e]}_getNodeMemory(e,t){var r=e.nodeMemory;return r[t]||(r[t]={}),r[t]}_getMemory(e,t){var r;return void 0!==e?(r=this._getTreeMemory(e),void 0!==t&&(r=this._getNodeMemory(r,t))):r=this._baseMemory,r}set(e,t,r,n){var i=this._getMemory(r,n);return ee(i,e,t),this}setData(e,t,r,n){return this.set(e,t,r,n)}get(e,t,r){var n=this._getMemory(t,r);return te(n,e)}getData(e,t,r){return this.get(e,t,r)}has(e,t,r){var n;return void 0!==t?(n=this._treeMemory[t])&&void 0!==r&&(n=treeMemory.nodeMemory[r]):n=this._baseMemory,!!n&&function(e,t){if(e&&"number"!=typeof e){if(e.hasOwnProperty(t))return!0;if(-1!==t.indexOf(".")){for(var r=t.split("."),n=e,i=0;i<r.length;i++){if(!n.hasOwnProperty(r[i]))return!1;n=n[r[i]]}return!0}return!1}return!1}(n,e)}hasData(e,t,r){return this.has(e,t,r)}inc(e,t,r,n,i){var s;return this.has(e,r,n)?s=this.get(e,r,n)+t:(void 0===i&&(i=0),s=i),this.set(e,s,r,n),this}incData(e,t,r,n,i){return this.inc(e,t,r,n,i)}toggle(e,t,r,n){var i;return this.has(e,t,r)?i=!this.get(e,t,r):(void 0===n&&(n=!1),i=n),this.set(e,i,t,r),this}toggleData(e,t,r,n){return this.toggle(e,t,r,n)}removeData(e,t,r){var n=this._getMemory(t,r);ne(n,e)}removeTree(e){return this._treeMemory[e]&&delete this._treeMemory[e],this}removeTreeData(e){return this.removeTree(e)}removeNode(e,t){var r=this._treeMemory[e];return r&&r.nodeMemory[t]&&delete r.nodeMemory[t],this}removeNodeData(e,t){return this.removeNode(e,t)}getGlobalMemory(){return this._baseMemory}getTreeMemory(e){return this._getTreeMemory(e)}getNodeMemory(e,t){return this._getNodeMemory(this._getTreeMemory(e),t)}dump(){return{base:y(this._baseMemory),tree:y(this._treeMemory)}}load(e){return this._baseMemory=y(e.base),this._treeMemory=y(e.tree),this}};class se extends ie{constructor({currentTimeKey:e="$currentTime"}={}){super(),this.currentTimeKey=e}getTreeState(e){return this.get(l,e)}setTreeState(e,t){return this.set(l,t,e),this}hasValidCurrentTime(){return this.has(this.currentTimeKey)}setCurrentTime(e){return this.set(this.currentTimeKey,e),this}getCurrentTime(){return this.get(this.currentTimeKey)}incCurrentTime(e){return this.inc(this.currentTimeKey,e),this}}var oe={bindTaskActionNode(e,t){this.__bindTick||(this.__bindTick=[],this.__bindNode=[]),this.__bindTick.push(e),this.__bindNode.push(t)},unBindTaskAction(){this.__bindTick&&(this.__bindTick.pop(),this.__bindNode.pop())},pauseEventSheet(){var e=this.__bindNode[this.__bindNode.length-1];if(!e)return null;var t=this.__bindTick[this.__bindTick.length-1];return e.pauseEventSheet(t)},pauseEventSheetUnitlEvent(e,t){var r=this.__bindNode[this.__bindNode.length-1];if(!r)return null;var n=this.__bindTick[this.__bindTick.length-1];return r.pauseEventSheetUnitlEvent(n,e,t),this}},ae={getTree(e){for(var t=this.trees,r=0,n=t.length;r<n;r++){var i=t[r]