/*StateMachine*/ var StateMachine = (function(){ function StateMachine(opts){ this.current = opts.initial||'none' this.events = opts.events||[] for(var i=0,length=this.events.length;i<length;i++){ var self = this var evt = self.events[i] self[evt.nam…