2
0

ember-data.min.js 75 KB

12345678910111213141516
  1. // ==========================================================================
  2. // Project: Ember Data
  3. // Copyright: ©2011-2012 Tilde Inc. and contributors.
  4. // Portions ©2011 Living Social Inc. and contributors.
  5. // License: Licensed under MIT license (see license.js)
  6. // ==========================================================================
  7. // Version: v0.14
  8. // Last commit: d9cd270 (2013-08-31 17:12:14 -0700)
  9. !function(){var e,t;!function(){var r={},n={};e=function(e,t,n){r[e]={deps:t,callback:n}},t=function(e){if(n[e])return n[e];n[e]={};var i,a,o,s,c;if(i=r[e],!i)throw new Error("Module '"+e+"' not found.");a=i.deps,o=i.callback,s=[];for(var d=0,u=a.length;u>d;d++)"exports"===a[d]?s.push(c={}):s.push(t(a[d]));var h=o.apply(this,s);return n[e]=c||h}}(),function(){"undefined"==typeof DS&&(DS=Ember.Namespace.create({VERSION:"0.14"}),"undefined"!=typeof window&&(window.DS=DS))}(),function(){var e=Ember.get;Ember.set,DS.NewJSONSerializer=Ember.Object.extend({deserialize:function(t,r){return e(this,"store"),t.eachRelationship(function(e,t){var n=t.type,i=r[e];null!=i&&("belongsTo"===t.kind?this.deserializeRecordId(r,e,n,i):"hasMany"===t.kind&&this.deserializeRecordIds(r,e,n,i))},this),r},deserializeRecordId:function(t,r,n,i){("number"==typeof i||"string"==typeof i)&&(t[r]=e(this,"store").recordFor(n,i))},deserializeRecordIds:function(e,t,r,n){for(var i=0,a=n.length;a>i;i++)this.deserializeRecordId(n,i,r,n[i])}})}(),function(){if(Ember.DataAdapter){var e=Ember.get,t=Ember.String.capitalize,r=Ember.String.underscore,n=window.DS;n.DebugAdapter=Ember.DataAdapter.extend({getFilters:function(){return[{name:"isNew",desc:"New"},{name:"isModified",desc:"Modified"},{name:"isClean",desc:"Clean"}]},detect:function(e){return e!==n.Model&&n.Model.detect(e)},columnsForType:function(n){var i=[{name:"id",desc:"Id"}],a=0,o=this;return Ember.A(e(n,"attributes")).forEach(function(e){if(a++>o.attributeLimit)return!1;var n=t(r(e).replace("_"," "));i.push({name:e,desc:n})}),i},getRecords:function(e){return this.get("store").all(e)},getRecordColumnValues:function(t){var r=this,n=0,i={id:e(t,"id")};return t.eachAttribute(function(a){if(n++>r.attributeLimit)return!1;var o=e(t,a);i[a]=o}),i},getRecordKeywords:function(t){var r=[],n=Ember.A(["id"]);return t.eachAttribute(function(e){n.push(e)}),n.forEach(function(n){r.push(e(t,n))}),r},getRecordFilterValues:function(e){return{isNew:e.get("isNew"),isModified:e.get("isDirty")&&!e.get("isNew"),isClean:!e.get("isDirty")}},getRecordColor:function(e){var t="black";return e.get("isNew")?t="green":e.get("isDirty")&&(t="blue"),t},observeRecord:function(e,t){var r=Ember.A(),n=this,i=Ember.A(["id","isNew","isDirty"]);e.eachAttribute(function(e){i.push(e)}),i.forEach(function(i){var a=function(){t(n.wrapRecord(e))};Ember.addObserver(e,i,a),r.push(function(){Ember.removeObserver(e,i,a)})});var a=function(){r.forEach(function(e){e()})};return a}})}}(),function(){Ember.set,Ember.onLoad("Ember.Application",function(e){e.initializer({name:"store",initialize:function(e,t){t.register("store:main",t.Store),t.register("serializer:_default",DS.NewJSONSerializer),e.lookup("store:main")}}),DS.DebugAdapter&&e.initializer({name:"dataAdapter",initialize:function(e,t){t.register("dataAdapter:main",DS.DebugAdapter)}}),e.initializer({name:"injectStore",initialize:function(e,t){t.inject("controller","store","store:main"),t.inject("route","store","store:main"),t.inject("dataAdapter","store","store:main")}})})}(),function(){Ember.Date=Ember.Date||{};var e=Date.parse,t=[1,4,5,6,7,10,11];Ember.Date.parse=function(r){var n,i,a=0;if(i=/^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(r)){for(var o,s=0;o=t[s];++s)i[o]=+i[o]||0;i[2]=(+i[2]||1)-1,i[3]=+i[3]||1,"Z"!==i[8]&&void 0!==i[9]&&(a=60*i[10]+i[11],"+"===i[9]&&(a=0-a)),n=Date.UTC(i[1],i[2],i[3],i[4],i[5]+a,i[6],i[7])}else n=e?e(r):0/0;return n},(Ember.EXTEND_PROTOTYPES===!0||Ember.EXTEND_PROTOTYPES.Date)&&(Date.parse=Ember.Date.parse)}(),function(){var e=Ember.Evented,t=Ember.DeferredMixin,r=(Ember.run,Ember.get),n=Ember.Mixin.create(e,t,{init:function(){this._super.apply(this,arguments),this.one("didLoad",this,function(){this.resolve(this)}),this.one("becameError",this,function(){this.reject(this)}),r(this,"isLoaded")&&this.trigger("didLoad")}});DS.LoadPromise=n}(),function(){var e=Ember.get;Ember.set;var t=DS.LoadPromise;DS.RecordArray=Ember.ArrayProxy.extend(t,{type:null,content:null,isLoaded:!1,isUpdating:!1,store:null,objectAtContent:function(t){var r=e(this,"content"),n=r.objectAt(t),i=e(this,"store");return n instanceof DS.Model?n:n?i.recordForReference(n):void 0},materializedObjectAt:function(t){var r=e(this,"content").objectAt(t);if(r)return e(this,"store").recordIsMaterialized(r)?this.objectAt(t):void 0},update:function(){if(!e(this,"isUpdating")){var t=e(this,"store"),r=e(this,"type");t.fetchAll(r,this)}},addReference:function(t){e(this,"content").addObject(t)},removeReference:function(t){e(this,"content").removeObject(t)}})}(),function(){var e=Ember.get;DS.FilteredRecordArray=DS.RecordArray.extend({filterFunction:null,isLoaded:!0,replace:function(){var t=e(this,"type").toString();throw new Error("The result of a client-side filter (on "+t+") is immutable.")},updateFilter:Ember.observer(function(){var t=e(this,"manager");t.updateFilter(this,e(this,"type"),e(this,"filterFunction"))},"filterFunction")})}(),function(){var e=Ember.get;Ember.set,DS.AdapterPopulatedRecordArray=DS.RecordArray.extend({query:null,replace:function(){var t=e(this,"type").toString();throw new Error("The result of a server query (on "+t+") is immutable.")},load:function(e){this.setProperties({content:Ember.A(e),isLoaded:!0}),Ember.run.once(this,"trigger","didLoad")}})}(),function(){var e=Ember.get,t=Ember.set,r=Ember.EnumerableUtils.map;DS.ManyArray=DS.RecordArray.extend({init:function(){this._super.apply(this,arguments),this._changesToSync=Ember.OrderedSet.create()},owner:null,isPolymorphic:!1,isLoaded:!1,loadingRecordsCount:function(e){this.loadingRecordsCount=e},loadedRecord:function(){this.loadingRecordsCount--,0===this.loadingRecordsCount&&(t(this,"isLoaded",!0),this.trigger("didLoad"))},fetch:function(){var t=e(this,"content"),r=e(this,"store"),n=e(this,"owner");r.fetchUnloadedReferences(t,n)},replaceContent:function(t,n,i){i=r(i,function(t){return e(t,"_reference")},this),this._super(t,n,i)},arrangedContentDidChange:function(){this.fetch()},arrayContentWillChange:function(t,r){var n=e(this,"owner"),i=e(this,"name");if(!n._suspendedRelationships)for(var a=t;t+r>a;a++){var o=e(this,"content").objectAt(a),s=DS.RelationshipChange.createChange(n.get("_reference"),o,e(this,"store"),{parentType:n.constructor,changeType:"remove",kind:"hasMany",key:i});this._changesToSync.add(s)}return this._super.apply(this,arguments)},arrayContentDidChange:function(t,r,n){this._super.apply(this,arguments);var i=e(this,"owner"),a=e(this,"name"),o=e(this,"store");if(!i._suspendedRelationships){for(var s=t;t+n>s;s++){var c=e(this,"content").objectAt(s),d=DS.RelationshipChange.createChange(i.get("_reference"),c,o,{parentType:i.constructor,changeType:"add",kind:"hasMany",key:a});d.hasManyName=a,this._changesToSync.add(d)}this._changesToSync.forEach(function(e){e.sync()}),DS.OneToManyChange.ensureSameTransaction(this._changesToSync,o),this._changesToSync.clear()}},createRecord:function(t,r){var n,i=e(this,"owner"),a=e(i,"store"),o=e(this,"type");return r=r||e(i,"transaction"),n=a.createRecord.call(a,o,t,r),this.pushObject(n),n}})}(),function(){var e=Ember.get,t=Ember.set,r=Ember.EnumerableUtils.forEach;DS.Transaction=Ember.Object.extend({init:function(){t(this,"records",Ember.OrderedSet.create())},createRecord:function(t,r){var n=e(this,"store");return n.createRecord(t,r,this)},isEqualOrDefault:function(t){return this===t||t===e(this,"store.defaultTransaction")?!0:void 0},isDefault:Ember.computed(function(){return this===e(this,"store.defaultTransaction")}).volatile(),add:function(t){var r=e(this,"store"),n=e(r,"_adapter"),i=e(n,"serializer");i.eachEmbeddedRecord(t,function(e,t){"load"!==t&&this.add(e)},this),this.adoptRecord(t)},relationships:Ember.computed(function(){var t=Ember.OrderedSet.create(),n=e(this,"records"),i=e(this,"store");return r(n,function(r){for(var n=e(r,"_reference"),a=i.relationshipChangesFor(n),o=0;o<a.length;o++)t.add(a[o])}),t}).volatile(),commitDetails:Ember.computed(function(){var t=Ember.MapWithDefault.create({defaultValue:function(){return{created:Ember.OrderedSet.create(),updated:Ember.OrderedSet.create(),deleted:Ember.OrderedSet.create()}}}),n=e(this,"records"),i=e(this,"store");return r(n,function(r){if(e(r,"isDirty")){r.send("willCommit");var n=i.adapterForType(r.constructor);t.get(n)[e(r,"dirtyType")].add(r)}}),t}).volatile(),commit:function(){var n=e(this,"store");e(this,"isDefault")&&t(n,"defaultTransaction",n.transaction()),this.removeCleanRecords();var i=e(this,"commitDetails"),a=e(this,"relationships");r(i,function(e,t){e.commit(n,t)}),a.forEach(function(e){e.destroy()})},rollback:function(){var t=Ember.OrderedSet.create(),n=e(this,"relationships");n.forEach(function(e){t.add(e.firstRecordReference),t.add(e.secondRecordReference),e.destroy()});var i=e(this,"records");r(i,function(e){e.get("isDirty")&&e.send("rollback")}),this.removeCleanRecords(),t.forEach(function(e){if(e&&e.record){var t=e.record;t.suspendRelationshipObservers(function(){t.reloadHasManys()})}},this)},remove:function(t){var r=e(this,"store.defaultTransaction");r.adoptRecord(t)},removeCleanRecords:function(){var t=e(this,"records");r(t,function(e){e.get("isDirty")||this.remove(e)},this)},adoptRecord:function(r){var n=e(r,"transaction");n&&n.removeRecord(r),e(this,"records").add(r),t(r,"transaction",this)},removeRecord:function(t){e(this,"records").remove(t)}}),DS.Transaction.reopenClass({ensureSameTransaction:function(t){var n=Ember.A();r(t,function(t){t&&n.pushObject(e(t,"transaction"))});var i=n.reduce(function(t,r){return e(r,"isDefault")||null!==t?t:r},null);return i?r(t,function(e){e&&i.add(e)}):i=n.objectAt(0),i}})}(),function(){function e(e){var t=Ember.meta(e,!0),r="DS.Mappable",n=t[r];return n||(t[r]={}),t.hasOwnProperty(r)||(t[r]=Ember.create(t[r])),t[r]}Ember.get;var t=function(e){return e},r=function(e){return e},n=function(e,t){return t};DS._Mappable=Ember.Mixin.create({createInstanceMapFor:function(t){var r=e(this);if(r.values=r.values||{},r.values[t])return r.values[t];for(var n=r.values[t]=new Ember.Map,i=this.constructor;i&&i!==DS.Store;)this._copyMap(t,i,n),i=i.superclass;return r.values[t]=n,n},_copyMap:function(i,a,o){function s(e,i){var s=(a.transformMapKey||r)(e,i),c=(a.transformMapValue||n)(e,i),d=o.get(s),u=c;d&&(u=(this.constructor.resolveMapConflict||t)(d,u)),o.set(s,u)}var c=e(a),d=c[i];d&&d.forEach(s,this)}}),DS._Mappable.generateMapFunctionFor=function(t,r){return function(n,i){var a=e(this),o=a[t]||Ember.MapWithDefault.create({defaultValue:function(){return{}}});r.call(this,n,i,o),a[t]=o}}}(),function(){var e=Ember.get,t=Ember.set,r=Ember.run.once,n=Ember.isNone,i=Ember.EnumerableUtils.forEach,a=Ember.EnumerableUtils.indexOf,o=Ember.EnumerableUtils.map,s="unloaded",c="loading",d={materialized:!0},u={created:!0},h=function(e){return null==e?null:e+""};DS.Store=Ember.Object.extend(DS._Mappable,{init:function(){(!e(DS,"defaultStore")||e(this,"isDefaultStore"))&&t(DS,"defaultStore",this),this.typeMaps={},this.recordArrayManager=DS.RecordArrayManager.create({store:this}),this.relationshipChanges={},t(this,"currentTransaction",this.transaction()),t(this,"defaultTransaction",this.transaction())},transaction:function(){return DS.Transaction.create({store:this})},materializeData:function(t){var r=e(t,"_reference"),n=r.data,i=this.adapterForType(t.constructor);r.data=d,t.setupData(),n!==u&&i.materialize(t,n,r.prematerialized)},adapter:Ember.computed(function(){return!Ember.testing,"DS.RESTAdapter"}).property(),serialize:function(e,t){return this.adapterForType(e.constructor).serialize(e,t)},_adapter:Ember.computed(function(){var t=e(this,"adapter");return"string"==typeof t&&(t=e(this,t,!1)||e(Ember.lookup,t)),DS.Adapter.detect(t)&&(t=t.create()),t}).property("adapter"),clientIdCounter:1,createRecord:function(r,i,a){i=i||{};var o=r._create({store:this});a=a||e(this,"defaultTransaction"),a.adoptRecord(o);var s=i.id;if(n(s)){var c=this.adapterForType(r);c&&c.generateIdForRecord&&(s=h(c.generateIdForRecord(this,o)),i.id=s)}s=h(s);var d=this.createReference(r,s);return d.data=u,t(o,"_reference",d),d.record=o,o.loadedData(),o.setupData(),o.setProperties(i),Ember.run(o,"resolve",o),o},deleteRecord:function(e){e.deleteRecord()},unloadRecord:function(e){e.unloadRecord()},find:function(e,t){return e=this.modelFor(e),void 0===t?this.findAll(e):"object"===Ember.typeOf(t)?this.findQuery(e,t):this.findById(e,h(t))},findById:function(e,t){var r;if(this.hasReferenceForId(e,t)&&(r=this.referenceForId(e,t),r.data!==s))return this.recordForReference(r);r||(r=this.createReference(e,t)),r.data=c;var n=this.legacyMaterializeRecord(r);if(r.data===c){var i=this.adapterForType(e),a=this,o=i.find(this,e,t);o&&o.then&&o.then(null,function(){a.recordWasError(n)})}return n},reloadRecord:function(t){var r=t.constructor,n=this.adapterForType(r),i=this,a=e(t,"id"),o=n.find(this,r,a);o&&o.then&&o.then(null,function(){i.recordWasError(t)})},recordForReference:function(e){var t=e.record;return t||(t=this.legacyMaterializeRecord(e)),t},unloadedReferences:function(t){for(var r=[],n=0,i=t.length;i>n;n++){var a=t[n];a instanceof DS.Model?e(a,"isEmpty")&&r.push(a):a.data===s&&(r.push(a),a.data=c)}return r},fetchUnloadedReferences:function(e,t){var r=this.unloadedReferences(e);this.fetchMany(r,t)},fetchMany:function(e,t){if(e.length){var r=Ember.MapWithDefault.create({defaultValue:function(){return Ember.A()}});i(e,function(e){r.get(e.type).push(e)}),i(r,function(e){var n=r.get(e),i=o(n,function(e){return e.id}),a=this.adapterForType(e);a.findMany(this,e,i,t)},this)}},hasReferenceForId:function(e,t){return t=h(t),!!this.typeMapFor(e).idToReference[t]},referenceForId:function(e,t){t=h(t);var r=this.typeMapFor(e).idToReference[t];return r||(r=this.createReference(e,t),r.data=s),r},findMany:function(e,t,r,i){if(!Ember.isArray(t)){var a=this.adapterForType(e);return a&&a.findHasMany?a.findHasMany(this,r,i,t):!n(t),this.recordArrayManager.createManyArray(e,Ember.A())}var s,c,d,u=o(t,function(t){return"object"==typeof t||null===t||t instanceof DS.Model?t:this.referenceForId(e,t)},this),h=this.unloadedReferences(u),l=this.recordArrayManager.createManyArray(e,Ember.A(u));if(l.loadingRecordsCount(h.length),h.length){for(c=0,d=h.length;d>c;c++)s=h[c],this.recordArrayManager.registerWaitingRecordArray(l,s);this.fetchMany(h,r)}else l.set("isLoaded",!0),Ember.run.once(function(){l.trigger("didLoad")});return l},findQuery:function(e,t){var r=DS.AdapterPopulatedRecordArray.create({type:e,query:t,content:Ember.A(),store:this}),n=this.adapterForType(e);return n.findQuery(this,e,t,r),r},findAll:function(e){return this.fetchAll(e,this.all(e))},fetchAll:function(e,r){var n=this.adapterForType(e),i=this.typeMapFor(e).metadata.since;return t(r,"isUpdating",!0),n.findAll(this,e,i),r},metaForType:function(e,r,n){var i=this.typeMapFor(e).metadata;t(i,r,n)},didUpdateAll:function(e){var r=this.typeMapFor(e).findAllCache;t(r,"isUpdating",!1)},all:function(e){var t=this.typeMapFor(e),r=t.findAllCache;if(r)return r;var n=DS.RecordArray.create({type:e,content:Ember.A(),store:this,isLoaded:!0});return this.recordArrayManager.registerFilteredRecordArray(n,e),t.findAllCache=n,n},filter:function(e,t,r){3===arguments.length?this.findQuery(e,t):2===arguments.length&&(r=t);var n=DS.FilteredRecordArray.create({type:e,content:Ember.A(),store:this,manager:this.recordArrayManager,filterFunction:r});return this.recordArrayManager.registerFilteredRecordArray(n,e,r),n},recordIsLoaded:function(e,t){return this.hasReferenceForId(e,t)?"object"==typeof this.referenceForId(e,t).data:!1},dataWasUpdated:function(t,r,n){e(n,"isDeleted")||"object"==typeof r.data&&this.recordArrayManager.referenceDidChange(r)},save:function(){r(this,"commitDefaultTransaction")},commit:Ember.aliasMethod("save"),commitDefaultTransaction:function(){e(this,"defaultTransaction").commit()},scheduleSave:function(t){e(this,"currentTransaction").add(t),r(this,"flushSavedRecords")},flushSavedRecords:function(){e(this,"currentTransaction").commit(),t(this,"currentTransaction",this.transaction())},didSaveRecord:function(e,t){t?(this.updateId(e,t),this.updateRecordData(e,t)):this.didUpdateAttributes(e),e.adapterDidCommit()},didSaveRecords:function(e,t){var r=0;i(e,function(e){this.didSaveRecord(e,t&&t[r++])},this)},recordWasInvalid:function(e,t){e.adapterDidInvalidate(t)},recordWasError:function(e){e.adapterDidError()},didUpdateAttribute:function(e,t,r){e.adapterDidUpdateAttribute(t,r)},didUpdateAttributes:function(e){e.eachAttribute(function(t){this.didUpdateAttribute(e,t)},this)},didUpdateRelationship:function(t,r){var n=e(t,"_reference").clientId,i=this.relationshipChangeFor(n,r);i&&i.adapterDidUpdate()},didUpdateRelationships:function(t){var r=this.relationshipChangesFor(e(t,"_reference"));for(var n in r)r.hasOwnProperty(n)&&r[n].adapterDidUpdate()},didReceiveId:function(t,r){var n=this.typeMapFor(t.constructor),i=e(t,"clientId");e(t,"id"),n.idToCid[r]=i,this.clientIdToId[i]=r},updateRecordData:function(t,r){e(t,"_reference").data=r,t.didChangeData()},updateId:function(t,r){var n=t.constructor,i=this.typeMapFor(n),a=e(t,"_reference"),o=(e(t,"id"),this.preprocessData(n,r));i.idToReference[o]=a,a.id=o},preprocessData:function(e,t){return this.adapterForType(e).extractId(e,t)},typeMapFor:function(t){var r,n=e(this,"typeMaps"),i=Ember.guidFor(t);return(r=n[i])?r:(r={idToReference:{},references:[],metadata:{}},n[i]=r,r)},load:function(e,t,n){var i;("number"==typeof t||"string"==typeof t)&&(i=t,t=n,n=null),n&&n.id?i=n.id:void 0===i&&(i=this.preprocessData(e,t)),i=h(i);var a=this.referenceForId(e,i);return a.record&&r(a.record,"loadedData"),a.data=t,a.prematerialized=n,this.recordArrayManager.referenceDidChange(a),a},newLoad:function(e,t){var r=h(t.id),n=this.referenceForId(e,r);return n.data=d,n.record&&n.record.setupData(t),this.recordArrayManager.referenceDidChange(n),n},modelFor:function(e){if("string"!=typeof e)return e;var t=this.container.lookupFactory("model:"+e);return t.store=this,t},push:function(e,t){var r=this.serializerFor(e);e=this.modelFor(e),t=r.deserialize(e,t),this.newLoad(e,t);var n=this.referenceForId(e,t.id),i=n.record;return i?i:this.materializeRecord(n,t)},recordFor:function(e,t){e=this.modelFor(e);var r=this.referenceForId(e,t);return r.record?r.record:this.materializeRecord(r)},loadMany:function(e,t,r){return void 0===r&&(r=t,t=o(r,function(t){return this.preprocessData(e,t)},this)),o(t,function(t,n){return this.load(e,t,r[n])},this)},loadHasMany:function(e,r,n){var i=e.get(r+".type"),a=o(n,function(e){return{id:e,type:i}});e.materializeHasMany(r,a),e.hasManyDidChange(r);var s=e.cacheFor(r);s&&(t(s,"isLoaded",!0),s.trigger("didLoad"))},createReference:function(e,t){var r=this.typeMapFor(e),n=r.idToReference,i={id:t,clientId:this.clientIdCounter++,type:e};return t&&(n[t]=i),r.references.push(i),i},materializeRecord:function(t,r){var n=t.type._create({id:t.id,store:this,_reference:t});return t.record=n,e(this,"defaultTransaction").adoptRecord(n),r&&n.setupData(r),n},legacyMaterializeRecord:function(t){var r=t.type._create({id:t.id,store:this,_reference:t});return t.record=r,e(this,"defaultTransaction").adoptRecord(r),r.loadingData(),"object"==typeof t.data&&r.loadedData(),r},dematerializeRecord:function(t){var r=e(t,"_reference"),n=r.type,i=r.id,o=this.typeMapFor(n);t.updateRecordArrays(),i&&delete o.idToReference[i];var s=a(o.references,r);o.references.splice(s,1)},willDestroy:function(){e(DS,"defaultStore")===this&&t(DS,"defaultStore",null)},addRelationshipChangeFor:function(e,t,r,n,i){var a=e.clientId,o=r?r.clientId:r,s=t+n,c=this.relationshipChanges;a in c||(c[a]={}),o in c[a]||(c[a][o]={}),s in c[a][o]||(c[a][o][s]={}),c[a][o][s][i.changeType]=i},removeRelationshipChangeFor:function(e,t,r,n,i){var a=e.clientId,o=r?r.clientId:r,s=this.relationshipChanges,c=t+n;a in s&&o in s[a]&&c in s[a][o]&&delete s[a][o][c][i]},relationshipChangeFor:function(e,t,r,n,i){var a=e.clientId,o=r?r.clientId:r,s=this.relationshipChanges,c=t+n;return a in s&&o in s[a]?i?s[a][o][c][i]:s[a][o][c].add||s[a][o][c].remove:void 0},relationshipChangePairsFor:function(e){var t=[];if(!e)return t;var r=this.relationshipChanges[e.clientId];for(var n in r)if(r.hasOwnProperty(n))for(var i in r[n])r[n].hasOwnProperty(i)&&t.push(r[n][i]);return t},relationshipChangesFor:function(e){var t=[];if(!e)return t;var r=this.relationshipChangePairsFor(e);return i(r,function(e){var r=e.add,n=e.remove;r&&t.push(r),n&&t.push(n)}),t},adapterForType:function(e){this._adaptersMap=this.createInstanceMapFor("adapters");var t=this._adaptersMap.get(e);return t?t:this.get("_adapter")},recordAttributeDidChange:function(e,t,r,n){var i=e.record,a=new Ember.OrderedSet,o=this.adapterForType(i.constructor);o.dirtyRecordsForAttributeChange&&o.dirtyRecordsForAttributeChange(a,i,t,r,n),a.forEach(function(e){e.adapterDidDirty()})},recordBelongsToDidChange:function(e,t,r){var n=this.adapterForType(t.constructor);n.dirtyRecordsForBelongsToChange&&n.dirtyRecordsForBelongsToChange(e,t,r)},recordHasManyDidChange:function(e,t,r){var n=this.adapterForType(t.constructor);n.dirtyRecordsForHasManyChange&&n.dirtyRecordsForHasManyChange(e,t,r)},serializerFor:function(e){var t=this.container;return t.lookup("serializer:"+e)||t.lookup("serializer:application")||t.lookup("serializer:_default")}}),DS.Store.reopenClass({registerAdapter:DS._Mappable.generateMapFunctionFor("adapters",function(e,t,r){r.set(e,t)}),transformMapKey:function(t){if("string"==typeof t){var r;return r=e(Ember.lookup,t)}return t},transformMapValue:function(e,t){return Ember.Object.detect(t)?t.create():t}})}(),function(){function e(t){var r,n={};for(var i in t)r=t[i],n[i]=r&&"object"==typeof r?e(r):r;return n}function t(e,t){for(var r in t)e[r]=t[r];return e}function r(r){var n=e(h);return t(n,r)}function n(e,r,i){e=t(r?Ember.create(r):{},e),e.parentState=r,e.stateName=i;for(var a in e)e.hasOwnProperty(a)&&"parentState"!==a&&"stateName"!==a&&"object"==typeof e[a]&&(e[a]=n(e[a],e,i+"."+a));return e}var i=Ember.get,a=Ember.set,o=Ember.run.once;Ember.ArrayPolyfills.map;var s=function(e){var t,r,n,i=Ember.keys(e);for(t=0,r=i.length;r>t;t++)if(n=i[t],e.hasOwnProperty(n)&&e[n])return!0;return!1},c=function(e){e.materializeData()},d=function(e,t){t.oldValue=i(e,t.name);var r=DS.AttributeChange.createChange(t);e._changesToSync[t.name]=r},u=function(e,t){var r=e._changesToSync[t.name];r.value=i(e,t.name),r.sync()},h={initialState:"uncommitted",isDirty:!0,uncommitted:{willSetProperty:d,didSetProperty:u,becomeDirty:Ember.K,willCommit:function(e){e.transitionTo("inFlight")},becameClean:function(e){e.withTransaction(function(t){t.remove(e)}),e.transitionTo("loaded.materializing")},becameInvalid:function(e){e.transitionTo("invalid")},rollback:function(e){e.rollback()}},inFlight:{isSaving:!0,enter:function(e){e.becameInFlight()},materializingData:function(e){a(e,"lastDirtyType",i(this,"dirtyType")),e.transitionTo("materializing")},didCommit:function(e){var t=i(this,"dirtyType");e.withTransaction(function(t){t.remove(e)}),e.transitionTo("saved"),e.send("invokeLifecycleCallbacks",t)},didChangeData:c,becameInvalid:function(e,t){a(e,"errors",t),e.transitionTo("invalid"),e.send("invokeLifecycleCallbacks")},becameError:function(e){e.transitionTo("error"),e.send("invokeLifecycleCallbacks")}},invalid:{isValid:!1,exit:function(e){e.withTransaction(function(t){t.remove(e)})},deleteRecord:function(e){e.transitionTo("deleted.uncommitted"),e.clearRelationships()},willSetProperty:d,didSetProperty:function(e,t){var r=i(e,"errors"),n=t.name;a(r,n,null),s(r)||e.send("becameValid"),u(e,t)},becomeDirty:Ember.K,rollback:function(e){e.send("becameValid"),e.send("rollback")},becameValid:function(e){e.transitionTo("uncommitted")},invokeLifecycleCallbacks:function(e){e.trigger("becameInvalid",e)}}},l=r({dirtyType:"created",isNew:!0}),f=r({dirtyType:"updated"});l.uncommitted.deleteRecord=function(e){e.clearRelationships(),e.transitionTo("deleted.saved")},l.uncommitted.rollback=function(e){h.uncommitted.rollback.apply(this,arguments),e.transitionTo("deleted.saved")},f.uncommitted.deleteRecord=function(e){e.transitionTo("deleted.uncommitted"),e.clearRelationships()};var p={isEmpty:!1,isLoading:!1,isLoaded:!1,isReloading:!1,isDirty:!1,isSaving:!1,isDeleted:!1,isError:!1,isNew:!1,isValid:!0,empty:{isEmpty:!0,loadingData:function(e){e.transitionTo("loading")},loadedData:function(e){e.transitionTo("loaded.created.uncommitted")},pushedData:function(e){e.transitionTo("loaded.saved")}},loading:{isLoading:!0,loadedData:c,materializingData:function(e){e.transitionTo("loaded.materializing.firstTime")},becameError:function(e){e.transitionTo("error"),e.send("invokeLifecycleCallbacks")}},loaded:{initialState:"saved",isLoaded:!0,materializing:{willSetProperty:Ember.K,didSetProperty:Ember.K,didChangeData:c,finishedMaterializing:function(e){e.transitionTo("loaded.saved")},firstTime:{isLoaded:!1,exit:function(e){o(function(){e.trigger("didLoad")})}}},reloading:{isReloading:!0,enter:function(e){var t=i(e,"store");t.reloadRecord(e)},exit:function(e){o(e,"trigger","didReload")},loadedData:c,materializingData:function(e){e.transitionTo("loaded.materializing")}},saved:{willSetProperty:d,didSetProperty:u,didChangeData:c,loadedData:c,reloadRecord:function(e){e.transitionTo("loaded.reloading")},materializingData:function(e){e.transitionTo("loaded.materializing")},becomeDirty:function(e){e.transitionTo("updated.uncommitted")},deleteRecord:function(e){e.transitionTo("deleted.uncommitted"),e.clearRelationships()},unloadRecord:function(e){e.clearRelationships(),e.transitionTo("deleted.saved")},didCommit:function(e){e.withTransaction(function(t){t.remove(e)}),e.send("invokeLifecycleCallbacks",i(e,"lastDirtyType"))},invokeLifecycleCallbacks:function(e,t){"created"===t?e.trigger("didCreate",e):e.trigger("didUpdate",e),e.trigger("didCommit",e)}},created:l,updated:f},deleted:{initialState:"uncommitted",dirtyType:"deleted",isDeleted:!0,isLoaded:!0,isDirty:!0,setup:function(e){var t=i(e,"store");t.recordArrayManager.remove(e)},uncommitted:{willCommit:function(e){e.transitionTo("inFlight")},rollback:function(e){e.rollback()},becomeDirty:Ember.K,becameClean:function(e){e.withTransaction(function(t){t.remove(e)}),e.transitionTo("loaded.materializing")}},inFlight:{isSaving:!0,enter:function(e){e.becameInFlight()},didCommit:function(e){e.withTransaction(function(t){t.remove(e)}),e.transitionTo("saved"),e.send("invokeLifecycleCallbacks")}},saved:{isDirty:!1,setup:function(e){var t=i(e,"store");t.dematerializeRecord(e)},invokeLifecycleCallbacks:function(e){e.trigger("didDelete",e),e.trigger("didCommit",e)}}},error:{isError:!0,invokeLifecycleCallbacks:function(e){e.trigger("becameError",e)}}};({}).hasOwnProperty,p=n(p,null,"root"),DS.RootState=p}(),function(){var e=DS.LoadPromise,t=Ember.get,r=Ember.set,n=Ember.EnumerableUtils.map,i=Ember.merge;Ember.ArrayPolyfills.map;var a=Ember.computed(function(e){return t(t(this,"currentState"),e)}).property("currentState").readOnly();DS.Model=Ember.Object.extend(Ember.Evented,e,{isEmpty:a,isLoading:a,isLoaded:a,isReloading:a,isDirty:a,isSaving:a,isDeleted:a,isError:a,isNew:a,isValid:a,dirtyType:a,clientId:null,id:null,transaction:null,currentState:null,errors:null,serialize:function(e){var r=t(this,"store");return r.serialize(this,e)},toJSON:function(e){var t=DS.JSONSerializer.create();return t.serialize(this,e)},didLoad:Ember.K,didReload:Ember.K,didUpdate:Ember.K,didCreate:Ember.K,didDelete:Ember.K,becameInvalid:Ember.K,becameError:Ember.K,data:Ember.computed(function(){return this._data||this.setupData(),this._data}).property(),materializeData:function(){this.send("materializingData"),t(this,"store").materializeData(this),this.suspendRelationshipObservers(function(){this.notifyPropertyChange("data")})},_data:null,init:function(){r(this,"currentState",DS.RootState.empty),this._super(),this._setup()},_setup:function(){this._changesToSync={}},send:function(e,r){var n=t(this,"currentState");return n[e]||this._unhandledEvent(n,e,r),n[e](this,r)},transitionTo:function(e){var n=e.split(".",1),i=t(this,"currentState"),a=i;do a.exit&&a.exit(this),a=a.parentState;while(!a.hasOwnProperty(n));var o,s,c=e.split("."),d=[],u=[];for(o=0,s=c.length;s>o;o++)a=a[c[o]],a.enter&&u.push(a),a.setup&&d.push(a);for(o=0,s=u.length;s>o;o++)u[o].enter(this);for(r(this,"currentState",a),o=0,s=d.length;s>o;o++)d[o].setup(this)},_unhandledEvent:function(e,t,r){var n="Attempted to handle event `"+t+"` ";throw n+="on "+String(this)+" while in state ",n+=e.stateName+". ",void 0!==r&&(n+="Called with "+Ember.inspect(r)+"."),new Ember.Error(n)},withTransaction:function(e){var r=t(this,"transaction");r&&e(r)},loadingData:function(){this.send("loadingData")},loadedData:function(){this.send("loadedData")},pushedData:function(){this.send("pushedData")},didChangeData:function(){this.send("didChangeData")},deleteRecord:function(){this.send("deleteRecord")},unloadRecord:function(){this.send("unloadRecord")},clearRelationships:function(){this.eachRelationship(function(e,t){"belongsTo"===t.kind?r(this,e,null):"hasMany"===t.kind&&this.clearHasMany(t)},this)},updateRecordArrays:function(){var e=t(this,"store");e&&e.dataWasUpdated(this.constructor,t(this,"_reference"),this)},adapterDidCommit:function(){var e=t(this,"data");t(this.constructor,"attributes").forEach(function(r){e[r]=t(this,r)},this),this.send("didCommit"),this.updateRecordArraysLater()},adapterDidDirty:function(){this.send("becomeDirty"),this.updateRecordArraysLater()},dataDidChange:Ember.observer(function(){this.reloadHasManys(),this.send("finishedMaterializing")},"data"),reloadHasManys:function(){var e=t(this.constructor,"relationshipsByName");this.updateRecordArraysLater(),e.forEach(function(e,t){"hasMany"===t.kind&&this.hasManyDidChange(t.key)},this)},hasManyDidChange:function(e){var i=this.cacheFor(e);if(i){var a=t(this.constructor,"relationshipsByName").get(e).type,o=t(this,"store"),s=this._data[e]||[],c=n(s,function(e){return"object"==typeof e?e.clientId?e:o.referenceForId(e.type,e.id):o.referenceForId(a,e)});r(i,"content",Ember.A(c))}},updateRecordArraysLater:function(){Ember.run.once(this,this.updateRecordArrays)},setupData:function(e){this._data=e||{id:null},e&&this.pushedData()},materializeId:function(e){r(this,"id",e)},materializeAttributes:function(e){i(this._data,e)},materializeAttribute:function(e,t){this._data[e]=t},materializeHasMany:function(e,t){var r=typeof t;if(t&&"string"!==r&&t.length>1,"string"===r)this._data[e]=t;else{var n=t;t&&Ember.isArray(t)&&(n=this._convertTuplesToReferences(t)),this._data[e]=n}},materializeBelongsTo:function(e,t){t&&Ember.assert("materializeBelongsTo expects a tuple or a reference, not a "+t,!t||t.hasOwnProperty("id")&&t.hasOwnProperty("type")),this._data[e]=t},_convertTuplesToReferences:function(e){return n(e,function(e){return this._convertTupleToReference(e)},this)},_convertTupleToReference:function(e){var r=t(this,"store");return e.clientId?e:r.referenceForId(e.type,e.id)},rollback:function(){this._setup(),this.send("becameClean"),this.suspendRelationshipObservers(function(){this.notifyPropertyChange("data")})},toStringExtension:function(){return t(this,"id")},suspendRelationshipObservers:function(e,r){var n=t(this.constructor,"relationshipNames").belongsTo,i=this;try{this._suspendedRelationships=!0,Ember._suspendObservers(i,n,null,"belongsToDidChange",function(){Ember._suspendBeforeObservers(i,n,null,"belongsToWillChange",function(){e.call(r||i)})})}finally{this._suspendedRelationships=!1}},becameInFlight:function(){},resolveOn:function(e){var t=this;return new Ember.RSVP.Promise(function(r,n){function i(){this.off("becameError",a),this.off("becameInvalid",a),r(this)}function a(){this.off(e,i),n(this)}t.one(e,i),t.one("becameError",a),t.one("becameInvalid",a)})},save:function(){return this.get("store").scheduleSave(this),this.resolveOn("didCommit")},reload:function(){return this.send("reloadRecord"),this.resolveOn("didReload")},adapterDidUpdateAttribute:function(e,r){void 0!==r?(t(this,"data")[e]=r,this.notifyPropertyChange(e)):(r=t(this,e),t(this,"data")[e]=r),this.updateRecordArraysLater()},adapterDidInvalidate:function(e){this.send("becameInvalid",e)},adapterDidError:function(){this.send("becameError")},trigger:function(e){Ember.tryInvoke(this,e,[].slice.call(arguments,1)),this._super.apply(this,arguments)}});var o=function(e){return function(){var r=t(DS,"defaultStore"),n=[].slice.call(arguments);return n.unshift(this),r[e].apply(r,n)}};DS.Model.reopenClass({_create:DS.Model.create,create:function(){throw new Ember.Error("You should not call `create` on a model. Instead, call `createRecord` with the attributes you would like to set.")},find:o("find"),all:o("all"),query:o("findQuery"),filter:o("filter"),createRecord:o("createRecord")})
  10. }(),function(){function e(e,r,n){var i=t(e,"data"),a=i[n];return void 0===a&&(a="function"==typeof r.defaultValue?r.defaultValue():r.defaultValue),a}var t=Ember.get;DS.Model.reopenClass({attributes:Ember.computed(function(){var e=Ember.Map.create();return this.eachComputedProperty(function(t,r){r.isAttribute&&(r.name=t,e.set(t,r))}),e})}),DS.Model.reopen({eachAttribute:function(e,r){t(this.constructor,"attributes").forEach(function(t,n){e.call(r,t,n)},r)},attributeWillChange:Ember.beforeObserver(function(e,r){var n=t(e,"_reference"),i=t(e,"store");e.send("willSetProperty",{reference:n,store:i,name:r})}),attributeDidChange:Ember.observer(function(e,t){e.send("didSetProperty",{name:t})})}),DS.attr=function(t,r){r=r||{};var n={type:t,isAttribute:!0,options:r};return Ember.computed(function(t,n){return arguments.length>1||(n=e(this,r,t)),n}).property("data").meta(n)}}(),function(){var e=DS.AttributeChange=function(e){this.reference=e.reference,this.store=e.store,this.name=e.name,this.oldValue=e.oldValue};e.createChange=function(t){return new e(t)},e.prototype={sync:function(){this.store.recordAttributeDidChange(this.reference,this.name,this.value,this.oldValue),this.destroy()},destroy:function(){var e=this.reference.record;delete e._changesToSync[this.name]}}}(),function(){var e=Ember.get,t=Ember.set,r=Ember.EnumerableUtils.forEach;DS.RelationshipChange=function(e){this.parentReference=e.parentReference,this.childReference=e.childReference,this.firstRecordReference=e.firstRecordReference,this.firstRecordKind=e.firstRecordKind,this.firstRecordName=e.firstRecordName,this.secondRecordReference=e.secondRecordReference,this.secondRecordKind=e.secondRecordKind,this.secondRecordName=e.secondRecordName,this.changeType=e.changeType,this.store=e.store,this.committed={}},DS.RelationshipChangeAdd=function(e){DS.RelationshipChange.call(this,e)},DS.RelationshipChangeRemove=function(e){DS.RelationshipChange.call(this,e)},DS.RelationshipChange.create=function(e){return new DS.RelationshipChange(e)},DS.RelationshipChangeAdd.create=function(e){return new DS.RelationshipChangeAdd(e)},DS.RelationshipChangeRemove.create=function(e){return new DS.RelationshipChangeRemove(e)},DS.OneToManyChange={},DS.OneToNoneChange={},DS.ManyToNoneChange={},DS.OneToOneChange={},DS.ManyToManyChange={},DS.RelationshipChange._createChange=function(e){return"add"===e.changeType?DS.RelationshipChangeAdd.create(e):"remove"===e.changeType?DS.RelationshipChangeRemove.create(e):void 0},DS.RelationshipChange.determineRelationshipType=function(e,t){var r,n,i=t.key,a=t.kind,o=e.inverseFor(i);return o&&(r=o.name,n=o.kind),o?"belongsTo"===n?"belongsTo"===a?"oneToOne":"manyToOne":"belongsTo"===a?"oneToMany":"manyToMany":"belongsTo"===a?"oneToNone":"manyToNone"},DS.RelationshipChange.createChange=function(e,t,r,n){var i,a=e.type;return i=DS.RelationshipChange.determineRelationshipType(a,n),"oneToMany"===i?DS.OneToManyChange.createChange(e,t,r,n):"manyToOne"===i?DS.OneToManyChange.createChange(t,e,r,n):"oneToNone"===i?DS.OneToNoneChange.createChange(e,t,r,n):"manyToNone"===i?DS.ManyToNoneChange.createChange(e,t,r,n):"oneToOne"===i?DS.OneToOneChange.createChange(e,t,r,n):"manyToMany"===i?DS.ManyToManyChange.createChange(e,t,r,n):void 0},DS.OneToNoneChange.createChange=function(e,t,r,n){var i=n.key,a=DS.RelationshipChange._createChange({parentReference:t,childReference:e,firstRecordReference:e,store:r,changeType:n.changeType,firstRecordName:i,firstRecordKind:"belongsTo"});return r.addRelationshipChangeFor(e,i,t,null,a),a},DS.ManyToNoneChange.createChange=function(e,t,r,n){var i=n.key,a=DS.RelationshipChange._createChange({parentReference:e,childReference:t,secondRecordReference:e,store:r,changeType:n.changeType,secondRecordName:n.key,secondRecordKind:"hasMany"});return r.addRelationshipChangeFor(e,i,t,null,a),a},DS.ManyToManyChange.createChange=function(e,t,r,n){var i=n.key,a=DS.RelationshipChange._createChange({parentReference:t,childReference:e,firstRecordReference:e,secondRecordReference:t,firstRecordKind:"hasMany",secondRecordKind:"hasMany",store:r,changeType:n.changeType,firstRecordName:i});return r.addRelationshipChangeFor(e,i,t,null,a),a},DS.OneToOneChange.createChange=function(e,t,r,n){var i;n.parentType?i=n.parentType.inverseFor(n.key).name:n.key&&(i=n.key);var a=DS.RelationshipChange._createChange({parentReference:t,childReference:e,firstRecordReference:e,secondRecordReference:t,firstRecordKind:"belongsTo",secondRecordKind:"belongsTo",store:r,changeType:n.changeType,firstRecordName:i});return r.addRelationshipChangeFor(e,i,t,null,a),a},DS.OneToOneChange.maintainInvariant=function(t,r,n,i){if("add"===t.changeType&&r.recordIsMaterialized(n)){var a=r.recordForReference(n),o=e(a,i);if(o){var s=DS.OneToOneChange.createChange(n,o.get("_reference"),r,{parentType:t.parentType,hasManyName:t.hasManyName,changeType:"remove",key:t.key});r.addRelationshipChangeFor(n,i,t.parentReference,null,s),s.sync()}}},DS.OneToManyChange.createChange=function(e,t,r,n){var i;n.parentType?(i=n.parentType.inverseFor(n.key).name,DS.OneToManyChange.maintainInvariant(n,r,e,i)):n.key&&(i=n.key);var a=DS.RelationshipChange._createChange({parentReference:t,childReference:e,firstRecordReference:e,secondRecordReference:t,firstRecordKind:"belongsTo",secondRecordKind:"hasMany",store:r,changeType:n.changeType,firstRecordName:i});return r.addRelationshipChangeFor(e,i,t,a.getSecondRecordName(),a),a},DS.OneToManyChange.maintainInvariant=function(t,r,n,i){var a=n.record;if("add"===t.changeType&&a){var o=e(a,i);if(o){var s=DS.OneToManyChange.createChange(n,o.get("_reference"),r,{parentType:t.parentType,hasManyName:t.hasManyName,changeType:"remove",key:t.key});r.addRelationshipChangeFor(n,i,t.parentReference,s.getSecondRecordName(),s),s.sync()}}},DS.OneToManyChange.ensureSameTransaction=function(e){var t=Ember.A();return r(e,function(e){t.addObject(e.getSecondRecord()),t.addObject(e.getFirstRecord())}),DS.Transaction.ensureSameTransaction(t)},DS.RelationshipChange.prototype={getSecondRecordName:function(){var e,t=this.secondRecordName;if(!t){if(e=this.secondRecordReference,!e)return;var r=this.firstRecordReference.type,n=r.inverseFor(this.firstRecordName);this.secondRecordName=n.name}return this.secondRecordName},getFirstRecordName:function(){var e=this.firstRecordName;return e},destroy:function(){var e=this.childReference,t=this.getFirstRecordName(),r=this.getSecondRecordName(),n=this.store;n.removeRelationshipChangeFor(e,t,this.parentReference,r,this.changeType)},getByReference:function(e){return e?e.record?e.record:void 0:e},getSecondRecord:function(){return this.getByReference(this.secondRecordReference)},getFirstRecord:function(){return this.getByReference(this.firstRecordReference)},ensureSameTransaction:function(){var e=this.getFirstRecord(),t=this.getSecondRecord(),r=DS.Transaction.ensureSameTransaction([e,t]);return this.transaction=r,r},callChangeEvents:function(){var t=this.getFirstRecord(),r=this.getSecondRecord(),n=new Ember.OrderedSet;r&&e(r,"isLoaded")&&this.store.recordHasManyDidChange(n,r,this),t&&this.store.recordBelongsToDidChange(n,t,this),n.forEach(function(e){e.adapterDidDirty()})},coalesce:function(){var e=this.store.relationshipChangePairsFor(this.firstRecordReference);r(e,function(e){var t=e.add,r=e.remove;t&&r&&(t.destroy(),r.destroy())})}},DS.RelationshipChangeAdd.prototype=Ember.create(DS.RelationshipChange.create({})),DS.RelationshipChangeRemove.prototype=Ember.create(DS.RelationshipChange.create({})),DS.RelationshipChangeAdd.prototype.changeType="add",DS.RelationshipChangeAdd.prototype.sync=function(){var r=this.getSecondRecordName(),n=this.getFirstRecordName(),i=this.getFirstRecord(),a=this.getSecondRecord();this.ensureSameTransaction(),this.callChangeEvents(),a&&i&&("belongsTo"===this.secondRecordKind?a.suspendRelationshipObservers(function(){t(a,r,i)}):"hasMany"===this.secondRecordKind&&a.suspendRelationshipObservers(function(){e(a,r).addObject(i)})),i&&a&&e(i,n)!==a&&("belongsTo"===this.firstRecordKind?i.suspendRelationshipObservers(function(){t(i,n,a)}):"hasMany"===this.firstRecordKind&&i.suspendRelationshipObservers(function(){e(i,n).addObject(a)})),this.coalesce()},DS.RelationshipChangeRemove.prototype.changeType="remove",DS.RelationshipChangeRemove.prototype.sync=function(){var r=this.getSecondRecordName(),n=this.getFirstRecordName(),i=this.getFirstRecord(),a=this.getSecondRecord();this.ensureSameTransaction(i,a,r,n),this.callChangeEvents(),a&&i&&("belongsTo"===this.secondRecordKind?a.suspendRelationshipObservers(function(){t(a,r,null)}):"hasMany"===this.secondRecordKind&&a.suspendRelationshipObservers(function(){e(a,r).removeObject(i)})),i&&e(i,n)&&("belongsTo"===this.firstRecordKind?i.suspendRelationshipObservers(function(){t(i,n,null)}):"hasMany"===this.firstRecordKind&&i.suspendRelationshipObservers(function(){e(i,n).removeObject(a)})),this.coalesce()}}(),function(){var e=Ember.get,t=(Ember.set,Ember.isNone);DS.belongsTo=function(r,n){n=n||{};var i={type:r,isRelationship:!0,options:n,kind:"belongsTo"};return Ember.computed(function(n,i){var a,o=e(this,"data"),s=e(this,"store");return"string"==typeof r&&(r=-1===r.indexOf(".")?s.modelFor(r):e(Ember.lookup,r)),2===arguments.length?void 0===i?null:i:(a=o[n],a instanceof DS.Model?a:t(a)?null:a.clientId?s.recordForReference(a):s.findById(a.type,a.id))}).property("data").meta(i)},DS.Model.reopen({belongsToWillChange:Ember.beforeObserver(function(t,r){if(e(t,"isLoaded")){var n=e(t,r),i=e(t,"_reference"),a=e(t,"store");if(n){var o=DS.RelationshipChange.createChange(i,e(n,"_reference"),a,{key:r,kind:"belongsTo",changeType:"remove"});o.sync(),this._changesToSync[r]=o}}}),belongsToDidChange:Ember.immediateObserver(function(t,r){if(e(t,"isLoaded")){var n=e(t,r);if(n){var i=e(t,"_reference"),a=e(t,"store"),o=DS.RelationshipChange.createChange(i,e(n,"_reference"),a,{key:r,kind:"belongsTo",changeType:"add"});o.sync(),this._changesToSync[r]&&DS.OneToManyChange.ensureSameTransaction([o,this._changesToSync[r]],a)}}delete this._changesToSync[r]})})}(),function(){function e(e,i){var a=t(e,"data"),o=a[i.key];if(o){var s=e.constructor.inverseFor(i.key);s&&n(o,function(t){var n;(n=t.record)&&e.suspendRelationshipObservers(function(){r(n,s.name,null)})})}}var t=Ember.get,r=Ember.set,n=Ember.EnumerableUtils.forEach,i=function(e,n){n=n||{};var i={type:e,isRelationship:!0,options:n,kind:"hasMany"};return Ember.computed(function(a){var o,s,c=t(this,"data"),d=t(this,"store");return"string"==typeof e&&(e=-1===e.indexOf(".")?d.modelFor(e):t(Ember.lookup,e)),o=c[a],s=d.findMany(e,o,this,i),r(s,"owner",this),r(s,"name",a),r(s,"isPolymorphic",n.polymorphic),s}).property().meta(i)};DS.hasMany=function(e,t){return i(e,t)},DS.Model.reopen({clearHasMany:function(t){var r=this.cacheFor(t.name);r?r.clear():e(this,t)}})}(),function(){var e=Ember.get;Ember.set,DS.Model.reopen({didDefineProperty:function(e,t,r){if(r instanceof Ember.Descriptor){var n=r.meta();n.isRelationship&&"belongsTo"===n.kind&&(Ember.addObserver(e,t,null,"belongsToDidChange"),Ember.addBeforeObserver(e,t,null,"belongsToWillChange")),n.isAttribute&&(Ember.addObserver(e,t,null,"attributeDidChange"),Ember.addBeforeObserver(e,t,null,"attributeWillChange")),n.parentType=e.constructor}}}),DS.Model.reopenClass({typeForRelationship:function(t){var r=e(this,"relationshipsByName").get(t);return r&&r.type},inverseFor:function(t){function r(t,n,i){i=i||[];var a=e(n,"relationships");if(a){var o=a.get(t);return o&&i.push.apply(i,a.get(t)),t.superclass&&r(t.superclass,n,i),i}}var n=this.typeForRelationship(t);if(!n)return null;var i=this.metaForProperty(t).options;if(null===i.inverse)return null;var a,o;if(i.inverse)a=i.inverse,o=Ember.get(n,"relationshipsByName").get(a).kind;else{var s=r(this,n);if(0===s.length)return null;a=s[0].name,o=s[0].kind}return{type:n,name:a,kind:o}},relationships:Ember.computed(function(){var e=new Ember.MapWithDefault({defaultValue:function(){return[]}});return this.eachComputedProperty(function(t,r){if(r.isRelationship){"string"==typeof r.type&&(r.type=Ember.get(Ember.lookup,r.type));var n=e.get(r.type);n.push({name:t,kind:r.kind})}}),e}),relationshipNames:Ember.computed(function(){var e={hasMany:[],belongsTo:[]};return this.eachComputedProperty(function(t,r){r.isRelationship&&e[r.kind].push(t)}),e}),relatedTypes:Ember.computed(function(){var t,r=Ember.A();return this.eachComputedProperty(function(n,i){i.isRelationship&&(t=i.type,"string"==typeof t&&(t=e(this,t,!1)||e(Ember.lookup,t)),r.contains(t)||r.push(t))}),r}),relationshipsByName:Ember.computed(function(){var t,r=Ember.Map.create();return this.eachComputedProperty(function(n,i){i.isRelationship&&(i.key=n,t=i.type,"string"==typeof t&&(t=t.match(/^[^A-Z]/)?this.store.modelFor(t):e(this,t,!1)||e(Ember.lookup,t),i.type=t),r.set(n,i))}),r}),fields:Ember.computed(function(){var e=Ember.Map.create();return this.eachComputedProperty(function(t,r){r.isRelationship?e.set(t,r.kind):r.isAttribute&&e.set(t,"attribute")}),e}),eachRelationship:function(t,r){e(this,"relationshipsByName").forEach(function(e,n){t.call(r,e,n)})},eachRelatedType:function(t,r){e(this,"relatedTypes").forEach(function(e){t.call(r,e)})}}),DS.Model.reopen({eachRelationship:function(e,t){this.constructor.eachRelationship(e,t)}})}(),function(){var e=Ember.get;Ember.set;var t=Ember.run.once,r=Ember.EnumerableUtils.forEach;DS.RecordArrayManager=Ember.Object.extend({init:function(){this.filteredRecordArrays=Ember.MapWithDefault.create({defaultValue:function(){return[]}}),this.changedReferences=[]},referenceDidChange:function(e){this.changedReferences.push(e),t(this,this.updateRecordArrays)},recordArraysForReference:function(e){return e.recordArrays=e.recordArrays||Ember.OrderedSet.create(),e.recordArrays},updateRecordArrays:function(){r(this.changedReferences,function(t){var n,i=t.type,a=this.filteredRecordArrays.get(i);r(a,function(r){n=e(r,"filterFunction"),this.updateRecordArray(r,n,i,t)},this);var o=t.loadingRecordArrays;if(o){for(var s=0,c=o.length;c>s;s++)o[s].loadedRecord();t.loadingRecordArrays=[]}},this),this.changedReferences=[]},updateRecordArray:function(e,t,r,n){var i,a;t?(a=this.store.recordForReference(n),i=t(a)):i=!0;var o=this.recordArraysForReference(n);i?(o.add(e),e.addReference(n)):i||(o.remove(e),e.removeReference(n))},remove:function(t){var n=e(t,"_reference"),i=n.recordArrays||[];r(i,function(e){e.removeReference(n)})},updateFilter:function(t,r,n){for(var i,a,o,s,c=this.store.typeMapFor(r),d=c.references,u=0,h=d.length;h>u;u++)i=d[u],o=!1,a=i.data,"object"==typeof a&&((s=i.record)?e(s,"isDeleted")||(o=!0):o=!0,o&&this.updateRecordArray(t,n,r,i))},createManyArray:function(e,t){var n=DS.ManyArray.create({type:e,content:t,store:this.store});return r(t,function(e){var t=this.recordArraysForReference(e);t.add(n)},this),n},registerFilteredRecordArray:function(e,t,r){var n=this.filteredRecordArrays.get(t);n.push(e),this.updateFilter(e,t,r)},registerWaitingRecordArray:function(e,t){var r=t.loadingRecordArrays||[];r.push(e),t.loadingRecordArrays=r}})}(),function(){function e(e){return function(){throw new Ember.Error("Your serializer "+this.toString()+" does not implement the required method "+e)}}var t=Ember.get,r=(Ember.set,Ember.ArrayPolyfills.map),n=Ember.isNone;DS.Serializer=Ember.Object.extend({init:function(){this.mappings=Ember.Map.create(),this.aliases=Ember.Map.create(),this.configurations=Ember.Map.create(),this.globalConfigurations={}},extract:e("extract"),extractMany:e("extractMany"),extractId:e("extractId"),extractAttribute:e("extractAttribute"),extractHasMany:e("extractHasMany"),extractBelongsTo:e("extractBelongsTo"),extractRecordRepresentation:function(e,t,r,i){var a,o={};return a=i?e.sideload(t,r):e.load(t,r),this.eachEmbeddedHasMany(t,function(t,i){var s=this.extractEmbeddedData(r,this.keyFor(i));n(s)||this.extractEmbeddedHasMany(e,i,s,a,o)},this),this.eachEmbeddedBelongsTo(t,function(t,i){var s=this.extractEmbeddedData(r,this.keyFor(i));n(s)||this.extractEmbeddedBelongsTo(e,i,s,a,o)},this),e.prematerialize(a,o),a},extractEmbeddedHasMany:function(e,t,n,i,a){var o=r.call(n,function(r){if(r){var n=this.extractEmbeddedType(t,r),a=this.extractRecordRepresentation(e,n,r,!0),o=this.embeddedType(i.type,t.key);"always"===o&&(a.parent=i);var s=t.parentType,c=s.inverseFor(t.key);if(c){var d=c.name;a.prematerialized[d]=i}return a}},this);a[t.key]=o},extractEmbeddedBelongsTo:function(e,t,r,n,i){var a=this.extractEmbeddedType(t,r),o=this.extractRecordRepresentation(e,a,r,!0);i[t.key]=o;var s=this.embeddedType(n.type,t.key);"always"===s&&(o.parent=n)},extractEmbeddedType:function(e){return e.type},extractEmbeddedData:e(),serialize:function(e,r){r=r||{};var n,i=this.createSerializedForm();return r.includeId&&(n=t(e,"id"))&&this._addId(i,e.constructor,n),r.includeType&&this.addType(i,e.constructor),this.addAttributes(i,e),this.addRelationships(i,e),i},serializeValue:function(e,t){var r=this.transforms?this.transforms[t]:null;return r.serialize(e)},serializeId:function(e){return Ember.isEmpty(e)?null:isNaN(+e)?e:+e},addAttributes:function(e,t){t.eachAttribute(function(r,n){this._addAttribute(e,t,r,n.type)},this)},addAttribute:e("addAttribute"),addId:e("addId"),addType:Ember.K,createSerializedForm:function(){return{}},addRelationships:function(e,t){t.eachRelationship(function(r,n){"belongsTo"===n.kind?this._addBelongsTo(e,t,r,n):"hasMany"===n.kind&&this._addHasMany(e,t,r,n)},this)},addBelongsTo:e("addBelongsTo"),addHasMany:e("addHasMany"),keyForAttributeName:function(e,t){return t},primaryKey:function(){return"id"},keyForBelongsTo:function(e,t){return this.keyForAttributeName(e,t)},keyForHasMany:function(e,t){return this.keyForAttributeName(e,t)},materialize:function(e,r,n){var i;Ember.isNone(t(e,"id"))&&(i=n&&n.hasOwnProperty("id")?n.id:this.extractId(e.constructor,r),e.materializeId(i)),this.materializeAttributes(e,r,n),this.materializeRelationships(e,r,n)},deserializeValue:function(e,t){var r=this.transforms?this.transforms[t]:null;return r.deserialize(e)},materializeAttributes:function(e,t,r){e.eachAttribute(function(n,i){r&&r.hasOwnProperty(n)?e.materializeAttribute(n,r[n]):this.materializeAttribute(e,t,n,i.type)},this)},materializeAttribute:function(e,t,r,n){var i=this.extractAttribute(e.constructor,t,r);i=this.deserializeValue(i,n),e.materializeAttribute(r,i)},materializeRelationships:function(e,t,r){e.eachRelationship(function(n,i){if("hasMany"===i.kind)if(r&&r.hasOwnProperty(n)){var a=this._convertPrematerializedHasMany(i.type,r[n]);e.materializeHasMany(n,a)}else this.materializeHasMany(n,e,t,i,r);else if("belongsTo"===i.kind)if(r&&r.hasOwnProperty(n)){var o=this._convertTuple(i.type,r[n]);e.materializeBelongsTo(n,o)}else this.materializeBelongsTo(n,e,t,i,r)},this)},materializeHasMany:function(e,t,r,n){var i=t.constructor,a=this._keyForHasMany(i,n.key),o=this.extractHasMany(i,r,a),s=o;o&&Ember.isArray(o)&&(s=this._convertTuples(n.type,o)),t.materializeHasMany(e,s)},materializeBelongsTo:function(e,t,r,i){var a,o=t.constructor,s=this._keyForBelongsTo(o,i.key),c=null;a=i.options&&i.options.polymorphic?this.extractBelongsToPolymorphic(o,r,s):this.extractBelongsTo(o,r,s),n(a)||(c=this._convertTuple(i.type,a)),t.materializeBelongsTo(e,c)},_convertPrematerializedHasMany:function(e,t){var r;return r="string"==typeof t?t:this._convertTuples(e,t)},_convertTuples:function(e,t){return r.call(t,function(t){return this._convertTuple(e,t)},this)},_convertTuple:function(e,t){var r;return"object"==typeof t?DS.Model.detect(t.type)?t:(r=this.typeFromAlias(t.type),{id:t.id,type:r}):{id:t,type:e}},_primaryKey:function(e){var t=this.configurationForType(e),r=t&&t.primaryKey;return r?r:this.primaryKey(e)},_addAttribute:function(e,r,n,i){var a=this._keyForAttributeName(r.constructor,n),o=t(r,n);this.addAttribute(e,a,this.serializeValue(o,i))},_addId:function(e,t,r){var n=this._primaryKey(t);this.addId(e,n,this.serializeId(r))},_keyForAttributeName:function(e,t){return this._keyFromMappingOrHook("keyForAttributeName",e,t)},_keyForBelongsTo:function(e,t){return this._keyFromMappingOrHook("keyForBelongsTo",e,t)},keyFor:function(e){var t=e.parentType,r=e.key;switch(e.kind){case"belongsTo":return this._keyForBelongsTo(t,r);case"hasMany":return this._keyForHasMany(t,r)}},_keyForHasMany:function(e,t){return this._keyFromMappingOrHook("keyForHasMany",e,t)},_addBelongsTo:function(e,t,r,n){var i=this._keyForBelongsTo(t.constructor,r);this.addBelongsTo(e,t,i,n)},_addHasMany:function(e,t,r,n){var i=this._keyForHasMany(t.constructor,r);this.addHasMany(e,t,i,n)},_keyFromMappingOrHook:function(e,t,r){var n=this.mappingOption(t,r,"key");return n?n:this[e](t,r)},registerTransform:function(e,t){this.transforms[e]=t},registerEnumTransform:function(e,t){var r={deserialize:function(e){return Ember.A(t).objectAt(e)},serialize:function(e){return Ember.EnumerableUtils.indexOf(t,e)},values:t};this.registerTransform(e,r)},map:function(e,t){this.mappings.set(e,t)},configure:function(e,t){if(e&&!t)return Ember.merge(this.globalConfigurations,e),void 0;var r,n;t.alias&&(n=t.alias,this.aliases.set(n,e),delete t.alias),r=Ember.create(this.globalConfigurations),Ember.merge(r,t),this.configurations.set(e,r)},typeFromAlias:function(e){return this._completeAliases(),this.aliases.get(e)},mappingForType:function(e){return this._reifyMappings(),this.mappings.get(e)||{}},configurationForType:function(e){return this._reifyConfigurations(),this.configurations.get(e)||this.globalConfigurations},_completeAliases:function(){this._pluralizeAliases(),this._reifyAliases()},_pluralizeAliases:function(){if(!this._didPluralizeAliases){var e,t=this.aliases,r=this.aliases.sideloadMapping,n=this;t.forEach(function(r,i){e=n.pluralize(r),t.set(e,i)}),r&&(r.forEach(function(e,r){t.set(e,r)}),delete this.aliases.sideloadMapping),this._didPluralizeAliases=!0}},_reifyAliases:function(){if(!this._didReifyAliases){var e,t=this.aliases,r=Ember.Map.create();t.forEach(function(t,n){"string"==typeof n?(e=Ember.get(Ember.lookup,n),r.set(t,e)):r.set(t,n)}),this.aliases=r,this._didReifyAliases=!0}},_reifyMappings:function(){if(!this._didReifyMappings){var e=this.mappings,t=Ember.Map.create();e.forEach(function(e,r){if("string"==typeof e){var n=Ember.get(Ember.lookup,e);t.set(n,r)}else t.set(e,r)}),this.mappings=t,this._didReifyMappings=!0}},_reifyConfigurations:function(){if(!this._didReifyConfigurations){var e=this.configurations,t=Ember.Map.create();e.forEach(function(e,r){if("string"==typeof e&&"plurals"!==e){var n=Ember.get(Ember.lookup,e);t.set(n,r)}else t.set(e,r)}),this.configurations=t,this._didReifyConfigurations=!0}},mappingOption:function(e,t,r){var n=this.mappingForType(e)[t];return n&&n[r]},configOption:function(e,t){var r=this.configurationForType(e);return r[t]},embeddedType:function(e,t){return this.mappingOption(e,t,"embedded")},eachEmbeddedRecord:function(e,t,r){this.eachEmbeddedBelongsToRecord(e,t,r),this.eachEmbeddedHasManyRecord(e,t,r)},eachEmbeddedBelongsToRecord:function(e,r,n){this.eachEmbeddedBelongsTo(e.constructor,function(i,a,o){var s=t(e,i);s&&r.call(n,s,o)})},eachEmbeddedHasManyRecord:function(e,r,n){this.eachEmbeddedHasMany(e.constructor,function(i,a,o){for(var s=t(e,i),c=0,d=t(s,"length");d>c;c++)r.call(n,s.objectAt(c),o)})},eachEmbeddedHasMany:function(e,t,r){this.eachEmbeddedRelationship(e,"hasMany",t,r)},eachEmbeddedBelongsTo:function(e,t,r){this.eachEmbeddedRelationship(e,"belongsTo",t,r)},eachEmbeddedRelationship:function(e,t,r,n){e.eachRelationship(function(i,a){var o=this.embeddedType(e,i);o&&a.kind===t&&r.call(n,i,a,o)},this)},pluralize:function(e){var t=this.configurations.get("plurals");return t&&t[e]||e+"s"},singularize:function(e){var t=this.configurations.get("plurals");if(t)for(var r in t)if(t[r]===e)return r;return e.lastIndexOf("s")===e.length-1?e.substring(0,e.length-1):e}})}(),function(){var e=Ember.isNone,t=Ember.isEmpty;DS.JSONTransforms={string:{deserialize:function(t){return e(t)?null:String(t)},serialize:function(t){return e(t)?null:String(t)}},number:{deserialize:function(e){return t(e)?null:Number(e)},serialize:function(e){return t(e)?null:Number(e)}},boolean:{deserialize:function(e){var t=typeof e;return"boolean"===t?e:"string"===t?null!==e.match(/^true$|^t$|^1$/i):"number"===t?1===e:!1},serialize:function(e){return Boolean(e)}},date:{deserialize:function(e){var t=typeof e;return"string"===t?new Date(Ember.Date.parse(e)):"number"===t?new Date(e):null===e||void 0===e?e:null},serialize:function(e){if(e instanceof Date){var t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],n=function(e){return 10>e?"0"+e:""+e},i=e.getUTCFullYear(),a=e.getUTCMonth(),o=e.getUTCDate(),s=e.getUTCDay(),c=e.getUTCHours(),d=e.getUTCMinutes(),u=e.getUTCSeconds(),h=t[s],l=n(o),f=r[a];return h+", "+l+" "+f+" "+i+" "+n(c)+":"+n(d)+":"+n(u)+" GMT"}return null}}}}(),function(){var e=Ember.get;Ember.set,DS.JSONSerializer=DS.Serializer.extend({init:function(){this._super(),e(this,"transforms")||this.set("transforms",DS.JSONTransforms),this.sideloadMapping=Ember.Map.create(),this.metadataMapping=Ember.Map.create(),this.configure({meta:"meta",since:"since"})},configure:function(t,r){var n;if(t&&!r){for(n in t)this.metadataMapping.set(e(t,n),n);return this._super(t)}var i,a=r.sideloadAs;a&&(i=this.aliases.sideloadMapping||Ember.Map.create(),i.set(a,t),this.aliases.sideloadMapping=i,delete r.sideloadAs),this._super.apply(this,arguments)},addId:function(e,t,r){e[t]=r},addAttribute:function(e,t,r){e[t]=r},extractAttribute:function(e,t,r){var n=this._keyForAttributeName(e,r);return t[n]},extractId:function(e,t){var r=this._primaryKey(e);return t.hasOwnProperty(r)?t[r]+"":null},extractEmbeddedData:function(e,t){return e[t]},extractHasMany:function(e,t,r){return t[r]},extractBelongsTo:function(e,t,r){return t[r]},extractBelongsToPolymorphic:function(e,t,r){var n,i=this.keyForPolymorphicId(r),a=t[i];return a?(n=this.keyForPolymorphicType(r),{id:a,type:t[n]}):null},addBelongsTo:function(t,r,n,i){var a,o,s,c=r.constructor,d=i.key,u=null,h=i.options&&i.options.polymorphic;this.embeddedType(c,d)?((a=e(r,d))&&(u=this.serialize(a,{includeId:!0,includeType:h})),t[n]=u):(o=e(r,i.key),s=e(o,"id"),i.options&&i.options.polymorphic&&!Ember.isNone(s)?this.addBelongsToPolymorphic(t,n,s,o.constructor):t[n]=this.serializeId(s))},addBelongsToPolymorphic:function(e,t,r,n){var i=this.keyForPolymorphicId(t),a=this.keyForPolymorphicType(t);e[i]=r,e[a]=this.rootForType(n)},addHasMany:function(t,r,n,i){var a,o,s=r.constructor,c=i.key,d=[],u=i.options&&i.options.polymorphic;o=this.embeddedType(s,c),"always"===o&&(a=e(r,c),a.forEach(function(e){d.push(this.serialize(e,{includeId:!0,includeType:u}))},this),t[n]=d)},addType:function(e,t){var r=this.keyForEmbeddedType();e[r]=this.rootForType(t)},extract:function(e,t,r,n){var i=this.rootForType(r);this.sideload(e,r,t,i),this.extractMeta(e,r,t),t[i]?(n&&e.updateId(n,t[i]),this.extractRecordRepresentation(e,r,t[i])):Ember.Logger.warn("Extract requested, but no data given for "+r+". This may cause weird problems.")},extractMany:function(e,t,r,n){var i=this.rootForType(r);if(i=this.pluralize(i),this.sideload(e,r,t,i),this.extractMeta(e,r,t),t[i]){var a=t[i],o=[];n&&(n=n.toArray());for(var s=0;s<a.length;s++){n&&e.updateId(n[s],a[s]);var c=this.extractRecordRepresentation(e,r,a[s]);o.push(c)}e.populateArray(o)}},extractMeta:function(e,t,r){var n,i=this.configOption(t,"meta"),a=r;i&&r[i]&&(a=r[i]),this.metadataMapping.forEach(function(r,i){n=a[r],Ember.isNone(n)||e.metaForType(t,i,n)})},extractEmbeddedType:function(e,t){var r=e.type;if(e.options&&e.options.polymorphic){var n=this.keyFor(e),i=this.keyForEmbeddedType(n);r=this.typeFromAlias(t[i]),delete t[i]}return r},sideload:function(e,t,r,n){var i;this.configureSideloadMappingForType(t);for(var a in r)r.hasOwnProperty(a)&&a!==n&&!this.metadataMapping.get(a)&&(i=this.typeFromAlias(a),this.loadValue(e,i,r[a]))},configureSideloadMappingForType:function(e,t){t||(t=Ember.A()),t.pushObject(e),e.eachRelatedType(function(e){if(!t.contains(e)){var r=this.defaultSideloadRootForType(e);this.aliases.set(r,e),this.configureSideloadMappingForType(e,t)}},this)},loadValue:function(e,t,r){if(r instanceof Array)for(var n=0;n<r.length;n++)e.sideload(t,r[n]);else e.sideload(t,r)},keyForPolymorphicId:function(e){return e},keyForPolymorphicType:function(e){return this.keyForPolymorphicId(e)+"_type"},keyForEmbeddedType:function(){return"type"},rootForType:function(e){var t=e.toString(),r=t.split("."),n=r[r.length-1];return n.replace(/([A-Z])/g,"_$1").toLowerCase().slice(1)},defaultSideloadRootForType:function(e){return this.pluralize(this.rootForType(e))}})}(),function(){function e(e){return{load:function(t,r,n){return e.load(t,r,n)},loadMany:function(t,r){return e.loadMany(t,r)},updateId:function(t,r){return e.updateId(t,r)},populateArray:Ember.K,sideload:function(t,r){return e.adapterForType(t).load(e,t,r)},sideloadMany:function(t,r){return e.loadMany(t,r)},prematerialize:function(e,t){e.prematerialized=t},metaForType:function(t,r,n){e.metaForType(t,r,n)}}}var t=Ember.get,r=Ember.set,n=Ember.merge,i=Ember.EnumerableUtils.forEach;DS.loaderFor=e,DS.Adapter=Ember.Object.extend(DS._Mappable,{init:function(){var e=t(this,"serializer");Ember.Object.detect(e)&&(e=e.create(),r(this,"serializer",e)),this._attributesMap=this.createInstanceMapFor("attributes"),this._configurationsMap=this.createInstanceMapFor("configurations"),this._outstandingOperations=new Ember.MapWithDefault({defaultValue:function(){return 0}}),this._dependencies=new Ember.MapWithDefault({defaultValue:function(){return new Ember.OrderedSet}}),this.registerSerializerTransforms(this.constructor,e,{}),this.registerSerializerMappings(e)},load:function(r,n,i){var a=e(r);return t(this,"serializer").extractRecordRepresentation(a,n,i)},didCreateRecord:function(e,r,n,i){if(e.didSaveRecord(n),i){var a=DS.loaderFor(e);a.load=function(t,r,i){return e.updateId(n,r),e.load(t,r,i)},t(this,"serializer").extract(a,i,r)}},didCreateRecords:function(e,r,n,i){if(n.forEach(function(t){e.didSaveRecord(t)},this),i){var a=DS.loaderFor(e);t(this,"serializer").extractMany(a,i,r,n)}},didSaveRecord:function(e,r,n,i){e.didSaveRecord(n);var a=t(this,"serializer");if(a.eachEmbeddedRecord(n,function(t,r){"load"!==r&&this.didSaveRecord(e,t.constructor,t)},this),i){var o=DS.loaderFor(e);a.extract(o,i,r)}},didUpdateRecord:function(){this.didSaveRecord.apply(this,arguments)},didDeleteRecord:function(){this.didSaveRecord.apply(this,arguments)},didSaveRecords:function(e,r,n,i){if(n.forEach(function(t){e.didSaveRecord(t)},this),i){var a=DS.loaderFor(e);t(this,"serializer").extractMany(a,i,r)}},didUpdateRecords:function(){this.didSaveRecords.apply(this,arguments)},didDeleteRecords:function(){this.didSaveRecords.apply(this,arguments)},didFindRecord:function(e,r,n,i){var a=DS.loaderFor(e);a.load=function(t,r,n){return n=n||{},n.id=i,e.load(t,r,n)},t(this,"serializer").extract(a,n,r)},didFindAll:function(e,r,n){var i=DS.loaderFor(e),a=t(this,"serializer");e.didUpdateAll(r),a.extractMany(i,n,r)},didFindQuery:function(e,r,n,i){var a=DS.loaderFor(e);a.populateArray=function(e){i.load(e)},t(this,"serializer").extractMany(a,n,r)},didFindMany:function(e,r,n){var i=DS.loaderFor(e);t(this,"serializer").extractMany(i,n,r)},didError:function(e,t,r){e.recordWasError(r)},dirtyRecordsForAttributeChange:function(e,t,r,n,i){n!==i&&this.dirtyRecordsForRecordChange(e,t)},dirtyRecordsForRecordChange:function(e,t){e.add(t)},dirtyRecordsForBelongsToChange:function(e,t){this.dirtyRecordsForRecordChange(e,t)},dirtyRecordsForHasManyChange:function(e,t){this.dirtyRecordsForRecordChange(e,t)},registerSerializerTransforms:function(e,t,r){var n,i,a=e._registeredTransforms,o=e._registeredEnumTransforms;for(i in a)!a.hasOwnProperty(i)||i in r||(r[i]=!0,t.registerTransform(i,a[i]));for(i in o)!o.hasOwnProperty(i)||i in r||(r[i]=!0,t.registerEnumTransform(i,o[i]));(n=e.superclass)&&this.registerSerializerTransforms(n,t,r)},registerSerializerMappings:function(e){var t=this._attributesMap,r=this._configurationsMap;t.forEach(e.map,e),r.forEach(e.configure,e)},find:Ember.required(Function),findAll:null,findQuery:null,serializer:DS.JSONSerializer,registerTransform:function(e,r){t(this,"serializer").registerTransform(e,r)},registerEnumTransform:function(e,r){t(this,"serializer").registerEnumTransform(e,r)},generateIdForRecord:null,materialize:function(e,r,n){t(this,"serializer").materialize(e,r,n)},serialize:function(e,r){return t(this,"serializer").serialize(e,r)},extractId:function(e,r){return t(this,"serializer").extractId(e,r)},groupByType:function(e){var t=Ember.MapWithDefault.create({defaultValue:function(){return Ember.OrderedSet.create()}});return i(e,function(e){t.get(e.constructor).add(e)}),t},commit:function(e,t){this.save(e,t)},save:function(e,t){function r(e){var t=Ember.OrderedSet.create();
  11. return e.forEach(function(e){n.shouldSave(e)&&t.add(e)}),t}var n=this;this.groupByType(t.created).forEach(function(t,n){this.createRecords(e,t,r(n))},this),this.groupByType(t.updated).forEach(function(t,n){this.updateRecords(e,t,r(n))},this),this.groupByType(t.deleted).forEach(function(t,n){this.deleteRecords(e,t,r(n))},this)},shouldSave:function(){return!0},createRecord:Ember.required(Function),createRecords:function(e,t,r){r.forEach(function(r){this.createRecord(e,t,r)},this)},updateRecord:Ember.required(Function),updateRecords:function(e,t,r){r.forEach(function(r){this.updateRecord(e,t,r)},this)},deleteRecord:Ember.required(Function),deleteRecords:function(e,t,r){r.forEach(function(r){this.deleteRecord(e,t,r)},this)},findMany:function(e,t,r){r.forEach(function(r){this.find(e,t,r)},this)}}),DS.Adapter.reopenClass({registerTransform:function(e,t){var r=this._registeredTransforms||{};r[e]=t,this._registeredTransforms=r},registerEnumTransform:function(e,t){var r=this._registeredEnumTransforms||{};r[e]=t,this._registeredEnumTransforms=r},map:DS._Mappable.generateMapFunctionFor("attributes",function(e,t,r){var i=r.get(e);n(i,t)}),configure:DS._Mappable.generateMapFunctionFor("configurations",function(e,t,r){var i=r.get(e),a=t&&t.mappings;a&&(this.map(e,a),delete t.mappings),n(i,t)}),resolveMapConflict:function(e,t){return n(t,e),t}})}(),function(){var e=Ember.get;Ember.set,DS.FixtureSerializer=DS.Serializer.extend({deserializeValue:function(e){return e},serializeValue:function(e){return e},addId:function(e,t,r){e[t]=r},addAttribute:function(e,t,r){e[t]=r},addBelongsTo:function(t,r,n,i){var a=e(r,i.key+".id");Ember.isNone(a)||(t[n]=a)},addHasMany:function(t,r,n,i){var a=e(r,i.key).map(function(e){return e.get("id")});t[i.key]=a},extract:function(e,t,r,n){n&&e.updateId(n,t),this.extractRecordRepresentation(e,r,t)},extractMany:function(e,t,r,n){var i=t,a=[];n&&(n=n.toArray());for(var o=0;o<i.length;o++){n&&e.updateId(n[o],i[o]);var s=this.extractRecordRepresentation(e,r,i[o]);a.push(s)}e.populateArray(a)},extractId:function(e,t){var r=this._primaryKey(e);return t.hasOwnProperty(r)?t[r]+"":null},extractAttribute:function(e,t,r){var n=this._keyForAttributeName(e,r);return t[n]},extractHasMany:function(e,t,r){return t[r]},extractBelongsTo:function(e,t,r){var n=t[r];return null!=n&&(n+=""),n},extractBelongsToPolymorphic:function(e,t,r){var n,i=this.keyForPolymorphicId(r),a=t[i];return a?(n=this.keyForPolymorphicType(r),{id:a,type:t[n]}):null},keyForPolymorphicId:function(e){return e},keyForPolymorphicType:function(e){return e+"_type"}})}(),function(){var e=Ember.get,t=Ember.String.fmt,r=Ember.EnumerableUtils.indexOf;DS.FixtureAdapter=DS.Adapter.extend({simulateRemoteResponse:!0,latency:50,serializer:DS.FixtureSerializer,fixturesForType:function(e){if(e.FIXTURES){var r=Ember.A(e.FIXTURES);return r.map(function(e){var r=typeof e.id;if("number"!==r&&"string"!==r)throw new Error(t("the id property must be defined as a number or string for fixture %@",[e]));return e.id=e.id+"",e})}return null},queryFixtures:function(){},updateFixtures:function(e,t){e.FIXTURES||(e.FIXTURES=[]);var r=e.FIXTURES;this.deleteLoadedFixture(e,t),r.push(t)},mockJSON:function(e,t){return this.serialize(t,{includeId:!0})},generateIdForRecord:function(e,t){return Ember.guidFor(t)},find:function(e,t,r){var n,i=this.fixturesForType(t);i&&(n=Ember.A(i).findProperty("id",r)),n&&this.simulateRemoteCall(function(){this.didFindRecord(e,t,n,r)},this)},findMany:function(e,t,n){var i=this.fixturesForType(t);i&&(i=i.filter(function(e){return-1!==r(n,e.id)})),i&&this.simulateRemoteCall(function(){this.didFindMany(e,t,i)},this)},findAll:function(e,t){var r=this.fixturesForType(t);this.simulateRemoteCall(function(){this.didFindAll(e,t,r)},this)},findQuery:function(e,t,r,n){var i=this.fixturesForType(t);i=this.queryFixtures(i,r,t),i&&this.simulateRemoteCall(function(){this.didFindQuery(e,t,i,n)},this)},createRecord:function(e,t,r){var n=this.mockJSON(t,r);this.updateFixtures(t,n),this.simulateRemoteCall(function(){this.didCreateRecord(e,t,r,n)},this)},updateRecord:function(e,t,r){var n=this.mockJSON(t,r);this.updateFixtures(t,n),this.simulateRemoteCall(function(){this.didUpdateRecord(e,t,r,n)},this)},deleteRecord:function(e,t,r){var n=this.mockJSON(t,r);this.deleteLoadedFixture(t,n),this.simulateRemoteCall(function(){this.didDeleteRecord(e,t,r)},this)},deleteLoadedFixture:function(e,t){var n=this.findExistingFixture(e,t);if(n){var i=r(e.FIXTURES,n);return e.FIXTURES.splice(i,1),!0}},findExistingFixture:function(e,t){var r=this.fixturesForType(e),n=this.extractId(e,t);return this.findFixtureById(r,n)},findFixtureById:function(t,r){return Ember.A(t).find(function(t){return""+e(t,"id")==""+r?!0:!1})},simulateRemoteCall:function(t,r){e(this,"simulateRemoteResponse")?Ember.run.later(r,t,e(this,"latency")):Ember.run.once(r,t)}})}(),function(){var e=Ember.get;DS.RESTSerializer=DS.JSONSerializer.extend({keyForAttributeName:function(e,t){return Ember.String.decamelize(t)},keyForBelongsTo:function(e,t){var r=this.keyForAttributeName(e,t);return this.embeddedType(e,t)?r:r+"_id"},keyForHasMany:function(e,t){var r=this.keyForAttributeName(e,t);return this.embeddedType(e,t)?r:this.singularize(r)+"_ids"},keyForPolymorphicId:function(e){return e},keyForPolymorphicType:function(e){return e.replace(/_id$/,"_type")},extractValidationErrors:function(t,r){var n={};return e(t,"attributes").forEach(function(e){var i=this._keyForAttributeName(t,e);r.errors.hasOwnProperty(i)&&(n[e]=r.errors[i])},this),n}})}(),function(){var e=Ember.get;Ember.set,DS.rejectionHandler=function(e){throw Ember.Logger.assert([e,e.message,e.stack]),e},DS.RESTAdapter=DS.Adapter.extend({namespace:null,bulkCommit:!1,since:"since",serializer:DS.RESTSerializer,shouldSave:function(t){var r=e(t,"_reference");return!r.parent},dirtyRecordsForRecordChange:function(e,t){this._dirtyTree(e,t)},dirtyRecordsForHasManyChange:function(t,r,n){var i=e(this,"serializer").embeddedType(r.constructor,n.secondRecordName);"always"===i&&(n.childReference.parent=n.parentReference,this._dirtyTree(t,r))},_dirtyTree:function(t,r){t.add(r),e(this,"serializer").eachEmbeddedRecord(r,function(e,r){"always"===r&&(t.has(e)||this._dirtyTree(t,e))},this);var n=r.get("_reference");if(n.parent){var i=e(r,"store"),a=i.recordForReference(n.parent);this._dirtyTree(t,a)}},createRecord:function(e,t,r){var n=this.rootForType(t),i=this,a={};return a[n]=this.serialize(r,{includeId:!0}),this.ajax(this.buildURL(n),"POST",{data:a}).then(function(n){i.didCreateRecord(e,t,r,n)},function(n){throw i.didError(e,t,r,n),n}).then(null,DS.rejectionHandler)},createRecords:function(t,r,n){var i=this;if(e(this,"bulkCommit")===!1)return this._super(t,r,n);var a=this.rootForType(r),o=this.pluralize(a),s={};return s[o]=[],n.forEach(function(e){s[o].push(this.serialize(e,{includeId:!0}))},this),this.ajax(this.buildURL(a),"POST",{data:s}).then(function(e){i.didCreateRecords(t,r,n,e)}).then(null,DS.rejectionHandler)},updateRecord:function(t,r,n){var i,a,o,s;return i=e(n,"id"),a=this.rootForType(r),o=this,s={},s[a]=this.serialize(n),this.ajax(this.buildURL(a,i,n),"PUT",{data:s}).then(function(e){o.didUpdateRecord(t,r,n,e)},function(e){throw o.didError(t,r,n,e),e}).then(null,DS.rejectionHandler)},updateRecords:function(t,r,n){var i,a,o,s;return e(this,"bulkCommit")===!1?this._super(t,r,n):(i=this.rootForType(r),a=this.pluralize(i),o=this,s={},s[a]=[],n.forEach(function(e){s[a].push(this.serialize(e,{includeId:!0}))},this),this.ajax(this.buildURL(i,"bulk"),"PUT",{data:s}).then(function(e){o.didUpdateRecords(t,r,n,e)}).then(null,DS.rejectionHandler))},deleteRecord:function(t,r,n){var i,a,o;return i=e(n,"id"),a=this.rootForType(r),o=this,this.ajax(this.buildURL(a,i,n),"DELETE").then(function(e){o.didDeleteRecord(t,r,n,e)},function(e){throw o.didError(t,r,n,e),e}).then(null,DS.rejectionHandler)},deleteRecords:function(t,r,n){var i,a,o,s,c;return e(this,"bulkCommit")===!1?this._super(t,r,n):(i=this.rootForType(r),a=this.pluralize(i),o=e(this,"serializer"),s=this,c={},c[a]=[],n.forEach(function(t){c[a].push(o.serializeId(e(t,"id")))}),this.ajax(this.buildURL(i,"bulk"),"DELETE",{data:c}).then(function(e){s.didDeleteRecords(t,r,n,e)}).then(null,DS.rejectionHandler))},find:function(e,t,r){var n=this.rootForType(t),i=this;return this.ajax(this.buildURL(n,r),"GET").then(function(n){i.didFindRecord(e,t,n,r)}).then(null,DS.rejectionHandler)},findAll:function(e,t,r){var n,i;return n=this.rootForType(t),i=this,this.ajax(this.buildURL(n),"GET",{data:this.sinceQuery(r)}).then(function(r){i.didFindAll(e,t,r)}).then(null,DS.rejectionHandler)},findQuery:function(e,t,r,n){var i=this.rootForType(t),a=this;return this.ajax(this.buildURL(i),"GET",{data:r}).then(function(r){a.didFindQuery(e,t,r,n)}).then(null,DS.rejectionHandler)},findMany:function(e,t,r){var n=this.rootForType(t),i=this;return r=this.serializeIds(r),this.ajax(this.buildURL(n),"GET",{data:{ids:r}}).then(function(r){i.didFindMany(e,t,r)}).then(null,DS.rejectionHandler)},serializeIds:function(t){var r=e(this,"serializer");return Ember.EnumerableUtils.map(t,function(e){return r.serializeId(e)})},didError:function(t,r,n,i){if(422===i.status){var a=JSON.parse(i.responseText),o=e(this,"serializer"),s=o.extractValidationErrors(r,a);t.recordWasInvalid(n,s)}else this._super.apply(this,arguments)},ajax:function(e,t,r){var n=this;return new Ember.RSVP.Promise(function(i,a){if(r=r||{},r.url=e,r.type=t,r.dataType="json",r.context=n,r.data&&"GET"!==t&&(r.contentType="application/json; charset=utf-8",r.data=JSON.stringify(r.data)),void 0!==n.headers){var o=n.headers;r.beforeSend=function(e){Ember.keys(o).forEach(function(t){e.setRequestHeader(t,o[t])})}}r.success=function(e){Ember.run(null,i,e)},r.error=function(e){e&&(e.then=null),Ember.run(null,a,e)},Ember.$.ajax(r)})},url:"",rootForType:function(t){var r=e(this,"serializer");return r.rootForType(t)},pluralize:function(t){var r=e(this,"serializer");return r.pluralize(t)},buildURL:function(e,t){var r=[this.url];return Ember.isNone(this.namespace)||r.push(this.namespace),r.push(this.pluralize(e)),void 0!==t&&r.push(t),r.join("/")},sinceQuery:function(t){var r={};return r[e(this,"since")]=t,t?r:null}})}(),function(){DS.Model.reopen({_debugInfo:function(){var e=["id"],t={belongsTo:[],hasMany:[]},r=[];this.eachAttribute(function(t){e.push(t)},this),this.eachRelationship(function(e,n){t[n.kind].push(e),r.push(e)});var n=[{name:"Attributes",properties:e,expand:!0},{name:"Belongs To",properties:t.belongsTo,expand:!0},{name:"Has Many",properties:t.hasMany,expand:!0},{name:"Flags",properties:["isLoaded","isDirty","isSaving","isDeleted","isError","isNew","isValid"]}];return{propertyInfo:{includeOtherProperties:!0,groups:n,expensiveProperties:r}}}})}()}(),"undefined"==typeof location||"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname||Ember.Logger.warn("You are running a production build of Ember on localhost and won't receive detailed error messages. If you want full error messages please use the non-minified build provided on the Ember website.");