function gamemeiHistory(){this.clear()}gamemeiHistory.prototype.onChange=function(){};gamemeiHistory.prototype.add=function(i){this.index++;this.history[this.index]={params:i,timestamp:new Date};this.index<this.history.length-1&&this.history.splice(this.index+1,this.history.length-this.index-1);this.onChange()};gamemeiHistory.prototype.clear=function(){this.history=[];this.index=-1;this.onChange()};gamemeiHistory.prototype.canUndo=function(){return this.index>=0};gamemeiHistory.prototype.canRedo=function(){return this.index<this.history.length-1};gamemeiHistory.prototype.undo=function(){if(this.canUndo()){var i=this.history[this.index];if(i){var t=i.params;t&&t.undo&&t.undo(t.oldValue,t.newValue)}this.index--;this.onChange()}};gamemeiHistory.prototype.redo=function(){if(this.canRedo()){this.index++;var i=this.history[this.index];if(i){var t=i.params;t&&t.redo&&t.redo(t.oldValue,t.newValue)}this.onChange()}};gamemeiHistory.prototype.getStatus=function(){return this.index};gamemeiHistory.prototype.setStatus=function(i){var t=this.history.length,e=0;if(i>-1&&t>i){if(i===this.index)return!0;if(i>this.index)for(;i>this.index;){this.redo();e++;if(e>1e3)return}else for(;i<this.index;){this.undo();e++;if(e>1e3)return}}return 1e3>e};window.gamemeiHistory=gamemeiHistory;