!function(a,b){var c={};c.Emitter=function(){},c.Emitter.extend=a.Model.extend,b.extend(c.Emitter,a.Events),b.extend(c.Emitter.prototype,a.Events),a.SE=c,c.Engine={},c.Engine.Base=c.Emitter.extend({sync:function(a,b,c){return this[a](b,c)}},{createSync:function(){var a,c;return a=this.construct.apply(this,arguments),c=b.bind(a.sync,a),c.engine=a,c},construct:function(){throw"`construct` factory method not implemented"}}),c.Engine.LocalStorage=function(a,b,d){function e(){function a(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()}var f=function(a){if(!this.localStorage)throw"Backbone.localStorage: Environment does not support localStorage.";this.name=a;var b=this.localStorage().getItem(this.name);this.records=b&&b.split(",")||[]};return b.extend(f.prototype,{save:function(){this.localStorage().setItem(this.name,this.records.join(","))},create:function(a){return a.id||(a.id=e(),a.set(a.idAttribute,a.id)),this.localStorage().setItem(this.name+"-"+a.id,JSON.stringify(a)),this.records.push(a.id.toString()),this.save(),this.find(a)},update:function(a){return this.localStorage().setItem(this.name+"-"+a.id,JSON.stringify(a)),b.include(this.records,a.id.toString())||this.records.push(a.id.toString()),this.save(),this.find(a)},find:function(a){return this.jsonData(this.localStorage().getItem(this.name+"-"+a.id))},findAll:function(){return(b.chain||b)(this.records).map(function(a){return this.jsonData(this.localStorage().getItem(this.name+"-"+a))},this).compact().value()},destroy:function(a){return a.isNew()?!1:(this.localStorage().removeItem(this.name+"-"+a.id),this.records=b.reject(this.records,function(b){return b===a.id.toString()}),this.save(),a)},localStorage:function(){return a.localStorage},jsonData:function(a){return a&&JSON.parse(a)},_clear:function(){var a=this.localStorage(),c=new RegExp("^"+this.name+"-");a.removeItem(this.name),(b.chain||b)(a).keys().filter(function(a){return c.test(a)}).each(function(b){a.removeItem(b)}),this.records.length=0},_storageSize:function(){return this.localStorage().length}}),c.Engine.Base.extend({constructor:function(a){c.Engine.Base.prototype.constructor.apply(this,arguments),this.store=new f(a)},sync:function(a,b,c){var e,f,g=this.store,h=d.$.Deferred&&d.$.Deferred();try{switch(a){case"read":e=void 0!==b.id?g.find(b):g.findAll();break;case"create":e=g.create(b);break;case"update":e=g.update(b);break;case"delete":e=g.destroy(b)}}catch(i){f=22===i.code&&0===g._storageSize()?"Private browsing is unsupported":i.message}return e?(c&&c.success&&("0.9.10"===d.VERSION?c.success(b,e,c):c.success(e)),h&&h.resolve(e)):(f=f||"Record Not Found",c&&c.error&&("0.9.10"===d.VERSION?c.error(b,f,c):c.error(f)),h&&h.reject(f)),c&&c.complete&&c.complete(e),h&&h.promise()}},{construct:b.memoize(function(a){return new this(a)})})}(this,b,a),c.Router={},c.Router.Base=c.Engine.Base,c.Router.LateBind=c.Router.Base.extend({constructor:function(a){this._cb=a},sync:function(a,c){var d=this._cb.apply(this,arguments);return c.sync=b.bind(d.sync,d),c.sync.apply(c,arguments)}},{construct:function(a){return new this(a)}})}(Backbone,_);