Backbone.StateRouter=Backbone.Router.extend({constructor:function(t){if(Backbone.Router.prototype.constructor.call(this,t),this.manager=t.manager,this.manager){var e=this;this.manager.sub("stay",function(t){var s,r,i,n=e._stateRoutes[t],a=Array.prototype.slice.call(arguments,1);if(n){if(s=e._routeToRegExp(n),r=s.exec(n).slice(1),r.length>=1&&a.length>=1)for(i=0;r.length>i;i++)n=n.replace(r[i],a[i]);e.navigate(n)}}),this.on("all",function(t){var e=/^route:state:([a-zA-Z0-9_]+)/.exec(t),s=Array.prototype.slice.call(arguments,1)||[];e&&(s.unshift(e[1]),this.manager.go.apply(this.manager,s))})}},route:function(t,e){Backbone.Router.prototype.route.apply(this,arguments);var s=/^state:([a-zA-Z0-9_]+)/.exec(e);this._stateRoutes||(this._stateRoutes={}),s&&(this._stateRoutes[s[1]]=t)}});