UNPKG

ember-intl

Version:

Ember toolbox for internationalization.

2 lines 82.8 kB
(function(){"use strict";var e=Ember.get;var r=["description","fileName","lineNumber","message","name","number","stack"];function t(e){var t=Error.prototype.constructor.call(this,"The backend rejected the commit because it was invalid: "+Ember.inspect(e));this.errors=e;for(var i=0,n=r.length;i<n;i++){this[r[i]]=t[r[i]]}}t.prototype=Ember.create(Error.prototype);var i=Ember.Object.extend({find:Ember.required(Function),findAll:null,findQuery:null,generateIdForRecord:null,serialize:function(r,t){return e(r,"store").serializerFor(r.constructor.typeKey).serialize(r,t)},createRecord:Ember.required(Function),updateRecord:Ember.required(Function),deleteRecord:Ember.required(Function),coalesceFindRequests:true,groupRecordsForFindMany:function(e,r){return[r]}});var n=i;var a=Ember.get;var o=Ember.String.fmt;var s=Ember.EnumerableUtils.indexOf;var u=0;var c=n.extend({serializer:null,simulateRemoteResponse:true,latency:50,fixturesForType:function(e){if(e.FIXTURES){var r=Ember.A(e.FIXTURES);return r.map(function(e){var r=typeof e.id;if(r!=="number"&&r!=="string"){throw new Error(o("the id property must be defined as a number or string for fixture %@",[e]))}e.id=e.id+"";return e})}return null},queryFixtures:function(e,r,t){},updateFixtures:function(e,r){if(!e.FIXTURES){e.FIXTURES=[]}var t=e.FIXTURES;this.deleteLoadedFixture(e,r);t.push(r)},mockJSON:function(e,r,t){return e.serializerFor(r).serialize(t,{includeId:true})},generateIdForRecord:function(e){return"fixture-"+u++},find:function(e,r,t){var i=this.fixturesForType(r);var n;if(i){n=Ember.A(i).findBy("id",t)}if(n){return this.simulateRemoteCall(function(){return n},this)}},findMany:function(e,r,t){var i=this.fixturesForType(r);if(i){i=i.filter(function(e){return s(t,e.id)!==-1})}if(i){return this.simulateRemoteCall(function(){return i},this)}},findAll:function(e,r){var t=this.fixturesForType(r);return this.simulateRemoteCall(function(){return t},this)},findQuery:function(e,r,t,i){var n=this.fixturesForType(r);n=this.queryFixtures(n,t,r);if(n){return this.simulateRemoteCall(function(){return n},this)}},createRecord:function(e,r,t){var i=this.mockJSON(e,r,t);this.updateFixtures(r,i);return this.simulateRemoteCall(function(){return i},this)},updateRecord:function(e,r,t){var i=this.mockJSON(e,r,t);this.updateFixtures(r,i);return this.simulateRemoteCall(function(){return i},this)},deleteRecord:function(e,r,t){this.deleteLoadedFixture(r,t);return this.simulateRemoteCall(function(){return null})},deleteLoadedFixture:function(e,r){var t=this.findExistingFixture(e,r);if(t){var i=s(e.FIXTURES,t);e.FIXTURES.splice(i,1);return true}},findExistingFixture:function(e,r){var t=this.fixturesForType(e);var i=a(r,"id");return this.findFixtureById(t,i)},findFixtureById:function(e,r){return Ember.A(e).find(function(e){if(""+a(e,"id")===""+r){return true}else{return false}})},simulateRemoteCall:function(e,r){var t=this;return new Ember.RSVP.Promise(function(i){var n=Ember.copy(e.call(r),true);if(a(t,"simulateRemoteResponse")){Ember.run.later(function(){i(n)},a(t,"latency"))}else{Ember.run.schedule("actions",null,function(){i(n)})}},"DS: FixtureAdapter#simulateRemoteCall")}});var l,d;function h(){Ember.OrderedSet.apply(this,arguments)}function f(){Ember.Map.apply(this,arguments)}function p(){Ember.MapWithDefault.apply(this,arguments)}var m=Ember.Map.create();m.set("key","value");var v=false;m.forEach(function(e,r){v=e==="key"&&r==="value"});f.prototype=Ember.create(Ember.Map.prototype);p.prototype=Ember.create(Ember.MapWithDefault.prototype);h.prototype=Ember.create(Ember.OrderedSet.prototype);h.create=function(){return new h};function y(e){return function(r,t){e.call(this,t,r)}}if(v){l=function(e,r){this.__super$forEach(y(e),r)};d=function(e){this.remove(e)};f.prototype.__super$forEach=Ember.Map.prototype.forEach;f.prototype.forEach=l;f.prototype["delete"]=d;p.prototype.forEach=l;p.prototype.__super$forEach=Ember.MapWithDefault.prototype.forEach;p.prototype["delete"]=d;h.prototype["delete"]=d}p.constructor=p;f.constructor=f;p.create=function(e){if(e){return new p(e)}else{return new f}};f.create=function(){return new this.constructor};var b=f;var g=Ember.get;var R=Ember.ArrayPolyfills.forEach;var E=i.extend({defaultSerializer:"-rest",coalesceFindRequests:false,find:function(e,r,t,i){return this.ajax(this.buildURL(r.typeKey,t,i),"GET")},findAll:function(e,r,t){var i;if(t){i={since:t}}return this.ajax(this.buildURL(r.typeKey),"GET",{data:i})},findQuery:function(e,r,t){return this.ajax(this.buildURL(r.typeKey),"GET",{data:t})},findMany:function(e,r,t,i){return this.ajax(this.buildURL(r.typeKey,t,i),"GET",{data:{ids:t}})},findHasMany:function(e,r,t,i){var n=g(this,"host");var a=g(r,"id");var o=r.constructor.typeKey;if(n&&t.charAt(0)==="/"&&t.charAt(1)!=="/"){t=n+t}return this.ajax(this.urlPrefix(t,this.buildURL(o,a)),"GET")},findBelongsTo:function(e,r,t,i){var n=g(r,"id");var a=r.constructor.typeKey;return this.ajax(this.urlPrefix(t,this.buildURL(a,n)),"GET")},createRecord:function(e,r,t){var i={};var n=e.serializerFor(r.typeKey);n.serializeIntoHash(i,r,t,{includeId:true});return this.ajax(this.buildURL(r.typeKey,null,t),"POST",{data:i})},updateRecord:function(e,r,t){var i={};var n=e.serializerFor(r.typeKey);n.serializeIntoHash(i,r,t);var a=g(t,"id");return this.ajax(this.buildURL(r.typeKey,a,t),"PUT",{data:i})},deleteRecord:function(e,r,t){var i=g(t,"id");return this.ajax(this.buildURL(r.typeKey,i,t),"DELETE")},buildURL:function(e,r,t){var i=[],n=g(this,"host"),a=this.urlPrefix();if(e){i.push(this.pathForType(e))}if(r&&!Ember.isArray(r)){i.push(encodeURIComponent(r))}if(a){i.unshift(a)}i=i.join("/");if(!n&&i){i="/"+i}return i},urlPrefix:function(e,r){var t=g(this,"host");var i=g(this,"namespace");var n=[];if(e){if(e.charAt(0)==="/"){if(t){e=e.slice(1);n.push(t)}}else if(!/^http(s)?:\/\//.test(e)){n.push(r)}}else{if(t){n.push(t)}if(i){n.push(i)}}if(e){n.push(e)}return n.join("/")},_stripIDFromURL:function(e,r){var t=r.constructor;var i=this.buildURL(t.typeKey,r.get("id"),r);var n=i.split("/");var a=n[n.length-1];var o=r.get("id");if(a===o){n[n.length-1]=""}else if(F(a,"?id="+o)){n[n.length-1]=a.substring(0,a.length-o.length-1)}return n.join("/")},maxUrlLength:2048,groupRecordsForFindMany:function(e,r){var t=p.create({defaultValue:function(){return[]}});var i=this;var n=this.maxUrlLength;R.call(r,function(r){var n=i._stripIDFromURL(e,r);t.get(n).push(r)});function a(r,t,n){var a=i._stripIDFromURL(e,r[0]);var o=0;var s=[[]];R.call(r,function(e){var r=encodeURIComponent(e.get("id")).length+n;if(a.length+o+r>=t){o=0;s.push([])}o+=r;var i=s.length-1;s[i].push(e)});return s}var o=[];t.forEach(function(e,r){var t="&ids%5B%5D=".length;var i=a(e,n,t);R.call(i,function(e){o.push(e)})});return o},pathForType:function(e){var r=Ember.String.camelize(e);return Ember.String.pluralize(r)},ajaxError:function(e,r,t){var i=e!==null&&typeof e==="object";if(i){e.then=null;if(!e.errorThrown){e.errorThrown=t}}return e},ajaxSuccess:function(e,r){return r},ajax:function(e,r,i){var n=this;return new Ember.RSVP.Promise(function(a,o){var s=n.ajaxOptions(e,r,i);s.success=function(e,r,i){e=n.ajaxSuccess(i,e);if(e instanceof t){Ember.run(null,o,e)}else{Ember.run(null,a,e)}};s.error=function(e,r,t){Ember.run(null,o,n.ajaxError(e,e.responseText,t))};Ember.$.ajax(s)},"DS: RESTAdapter#ajax "+r+" to "+e)},ajaxOptions:function(e,r,t){var i=t||{};i.url=e;i.type=r;i.dataType="json";i.context=this;if(i.data&&r!=="GET"){i.contentType="application/json; charset=utf-8";i.data=JSON.stringify(i.data)}var n=g(this,"headers");if(n!==undefined){i.beforeSend=function(e){R.call(Ember.keys(n),function(r){e.setRequestHeader(r,n[r])})}}return i}});function F(e,r){if(typeof String.prototype.endsWith!=="function"){return e.indexOf(r,e.length-r.length)!==-1}else{return e.endsWith(r)}}var _=Ember.String.capitalize;var A=/^\s*$/;var S=/(\w+[_-])([a-z\d]+$)/;var z=/(\w+)([A-Z][a-z\d]*$)/;var k=/[A-Z][a-z\d]*$/;function C(e,r){for(var t=0,i=r.length;t<i;t++){e.uncountable[r[t].toLowerCase()]=true}}function T(e,r){var t;for(var i=0,n=r.length;i<n;i++){t=r[i];e.irregular[t[0].toLowerCase()]=t[1];e.irregular[t[1].toLowerCase()]=t[1];e.irregularInverse[t[1].toLowerCase()]=t[0];e.irregularInverse[t[0].toLowerCase()]=t[0]}}function x(e){e=e||{};e.uncountable=e.uncountable||D();e.irregularPairs=e.irregularPairs||D();var r=this.rules={plurals:e.plurals||[],singular:e.singular||[],irregular:D(),irregularInverse:D(),uncountable:D()};C(r,e.uncountable);T(r,e.irregularPairs);this.enableCache()}if(!Object.create&&!Object.create(null).hasOwnProperty){throw new Error("This browser does not support Object.create(null), please polyfil with es5-sham: http://git.io/yBU2rg")}function D(){var e=Object.create(null);e["_dict"]=null;delete e["_dict"];return e}x.prototype={enableCache:function(){this.purgeCache();this.singularize=function(e){this._cacheUsed=true;return this._sCache[e]||(this._sCache[e]=this._singularize(e))};this.pluralize=function(e){this._cacheUsed=true;return this._pCache[e]||(this._pCache[e]=this._pluralize(e))}},purgeCache:function(){this._cacheUsed=false;this._sCache=D();this._pCache=D()},disableCache:function(){this._sCache=null;this._pCache=null;this.singularize=function(e){return this._singularize(e)};this.pluralize=function(e){return this._pluralize(e)}},plural:function(e,r){if(this._cacheUsed){this.purgeCache()}this.rules.plurals.push([e,r.toLowerCase()])},singular:function(e,r){if(this._cacheUsed){this.purgeCache()}this.rules.singular.push([e,r.toLowerCase()])},uncountable:function(e){if(this._cacheUsed){this.purgeCache()}C(this.rules,[e.toLowerCase()])},irregular:function(e,r){if(this._cacheUsed){this.purgeCache()}T(this.rules,[[e,r]])},pluralize:function(e){return this._pluralize(e)},_pluralize:function(e){return this.inflect(e,this.rules.plurals,this.rules.irregular)},singularize:function(e){return this._singularize(e)},_singularize:function(e){return this.inflect(e,this.rules.singular,this.rules.irregularInverse)},inflect:function(e,r,t){var i,n,a,o,s,u,c,l,d,h,f,p,m;l=A.test(e);d=k.test(e);u="";if(l){return e}o=e.toLowerCase();s=S.exec(e)||z.exec(e);if(s){u=s[1];c=s[2].toLowerCase()}h=this.rules.uncountable[o]||this.rules.uncountable[c];if(h){return e}f=t&&(t[o]||t[c]);if(f){if(t[o]){return f}else{f=d?_(f):f;return u+f}}for(var v=r.length,y=0;v>y;v--){i=r[v-1];m=i[0];if(m.test(e)){break}}i=i||[];m=i[0];n=i[1];a=e.replace(m,n);return a}};var w=x;function M(e){return w.inflector.pluralize(e)}function P(e){return w.inflector.singularize(e)}var O={plurals:[[/$/,"s"],[/s$/i,"s"],[/^(ax|test)is$/i,"$1es"],[/(octop|vir)us$/i,"$1i"],[/(octop|vir)i$/i,"$1i"],[/(alias|status)$/i,"$1es"],[/(bu)s$/i,"$1ses"],[/(buffal|tomat)o$/i,"$1oes"],[/([ti])um$/i,"$1a"],[/([ti])a$/i,"$1a"],[/sis$/i,"ses"],[/(?:([^f])fe|([lr])f)$/i,"$1$2ves"],[/(hive)$/i,"$1s"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/(x|ch|ss|sh)$/i,"$1es"],[/(matr|vert|ind)(?:ix|ex)$/i,"$1ices"],[/^(m|l)ouse$/i,"$1ice"],[/^(m|l)ice$/i,"$1ice"],[/^(ox)$/i,"$1en"],[/^(oxen)$/i,"$1"],[/(quiz)$/i,"$1zes"]],singular:[[/s$/i,""],[/(ss)$/i,"$1"],[/(n)ews$/i,"$1ews"],[/([ti])a$/i,"$1um"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i,"$1sis"],[/(^analy)(sis|ses)$/i,"$1sis"],[/([^f])ves$/i,"$1fe"],[/(hive)s$/i,"$1"],[/(tive)s$/i,"$1"],[/([lr])ves$/i,"$1f"],[/([^aeiouy]|qu)ies$/i,"$1y"],[/(s)eries$/i,"$1eries"],[/(m)ovies$/i,"$1ovie"],[/(x|ch|ss|sh)es$/i,"$1"],[/^(m|l)ice$/i,"$1ouse"],[/(bus)(es)?$/i,"$1"],[/(o)es$/i,"$1"],[/(shoe)s$/i,"$1"],[/(cris|test)(is|es)$/i,"$1is"],[/^(a)x[ie]s$/i,"$1xis"],[/(octop|vir)(us|i)$/i,"$1us"],[/(alias|status)(es)?$/i,"$1"],[/^(ox)en/i,"$1"],[/(vert|ind)ices$/i,"$1ex"],[/(matr)ices$/i,"$1ix"],[/(quiz)zes$/i,"$1"],[/(database)s$/i,"$1"]],irregularPairs:[["person","people"],["man","men"],["child","children"],["sex","sexes"],["move","moves"],["cow","kine"],["zombie","zombies"]],uncountable:["equipment","information","rice","money","species","series","fish","sheep","jeans","police"]};w.inflector=new w(O);Ember.Handlebars.helper("singularize",P);Ember.Handlebars.helper("pluralize",function(e,r,t){if(arguments.length<3){return M(e)}else{if(e!=1){r=M(r)}return e+" "+r}});if(Ember.EXTEND_PROTOTYPES===true||Ember.EXTEND_PROTOTYPES.String){String.prototype.pluralize=function(){return M(this)};String.prototype.singularize=function(){return P(this)}}w.defaultRules=O;Ember.Inflector=w;Ember.String.pluralize=M;Ember.String.singularize=P;var $=w;var I=Ember.String.decamelize,K=Ember.String.underscore;var L=E.extend({defaultSerializer:"-active-model",pathForType:function(e){var r=I(e);var t=K(r);return M(t)},ajaxError:function(e){var r=this._super.apply(this,arguments);if(e&&e.status===422){return new t(Ember.$.parseJSON(e.responseText))}else{return r}}});var j=L;var U=Ember.get;var N=Ember.isNone;var B=Ember.ArrayPolyfills.map;var H=Ember.merge;var V=Ember.Object.extend({primaryKey:"id",applyTransforms:function(e,r){e.eachTransformedAttribute(function t(e,i){if(!r.hasOwnProperty(e)){return}var n=this.transformFor(i);r[e]=n.deserialize(r[e])},this);return r},normalize:function(e,r){if(!r){return r}this.normalizeId(r);this.normalizeAttributes(e,r);this.normalizeRelationships(e,r);this.normalizeUsingDeclaredMapping(e,r);this.applyTransforms(e,r);return r},normalizePayload:function(e){return e},normalizeAttributes:function(e,r){var t;if(this.keyForAttribute){e.eachAttribute(function(e){t=this.keyForAttribute(e);if(e===t){return}if(!r.hasOwnProperty(t)){return}r[e]=r[t];delete r[t]},this)}},normalizeRelationships:function(e,r){var t;if(this.keyForRelationship){e.eachRelationship(function(e,i){t=this.keyForRelationship(e,i.kind);if(e===t){return}if(!r.hasOwnProperty(t)){return}r[e]=r[t];delete r[t]},this)}},normalizeUsingDeclaredMapping:function(e,r){var t=U(this,"attrs"),i,n;if(t){for(n in t){i=this._getMappedKey(n);if(!r.hasOwnProperty(i)){continue}if(i!==n){r[n]=r[i];delete r[i]}}}},normalizeId:function(e){var r=U(this,"primaryKey");if(r==="id"){return}e.id=e[r];delete e[r]},normalizeErrors:function(e,r){this.normalizeId(r);this.normalizeAttributes(e,r);this.normalizeRelationships(e,r)},_getMappedKey:function(e){var r=U(this,"attrs");var t;if(r&&r[e]){t=r[e];if(t.key){t=t.key}if(typeof t==="string"){e=t}}return e},_canSerialize:function(e){var r=U(this,"attrs");return!r||!r[e]||r[e].serialize!==false},serialize:function(e,r){var t={};if(r&&r.includeId){var i=U(e,"id");if(i){t[U(this,"primaryKey")]=i}}e.eachAttribute(function(r,i){this.serializeAttribute(e,t,r,i)},this);e.eachRelationship(function(r,i){if(i.kind==="belongsTo"){this.serializeBelongsTo(e,t,i)}else if(i.kind==="hasMany"){this.serializeHasMany(e,t,i)}},this);return t},serializeIntoHash:function(e,r,t,i){H(e,this.serialize(t,i))},serializeAttribute:function(e,r,t,i){var n=i.type;if(this._canSerialize(t)){var a=U(e,t);if(n){var o=this.transformFor(n);a=o.serialize(a)}var s=this._getMappedKey(t);if(s===t&&this.keyForAttribute){s=this.keyForAttribute(t)}r[s]=a}},serializeBelongsTo:function(e,r,t){var i=t.key;if(this._canSerialize(i)){var n=U(e,i);var a=this._getMappedKey(i);if(a===i&&this.keyForRelationship){a=this.keyForRelationship(i,"belongsTo")}if(N(n)||N(U(n,"id"))){r[a]=null}else{r[a]=U(n,"id")}if(t.options.polymorphic){this.serializePolymorphicType(e,r,t)}}},serializeHasMany:function(e,r,t){var i=t.key;if(this._canSerialize(i)){var n;n=this._getMappedKey(i);if(n===i&&this.keyForRelationship){n=this.keyForRelationship(i,"hasMany")}var a=e.constructor.determineRelationshipType(t);if(a==="manyToNone"||a==="manyToMany"){r[n]=U(e,i).mapBy("id")}}},serializePolymorphicType:Ember.K,extract:function(e,r,t,i,n){this.extractMeta(e,r,t);var a="extract"+n.charAt(0).toUpperCase()+n.substr(1);return this[a](e,r,t,i,n)},extractFindAll:function(e,r,t,i,n){return this.extractArray(e,r,t,i,n)},extractFindQuery:function(e,r,t,i,n){return this.extractArray(e,r,t,i,n)},extractFindMany:function(e,r,t,i,n){return this.extractArray(e,r,t,i,n)},extractFindHasMany:function(e,r,t,i,n){return this.extractArray(e,r,t,i,n)},extractCreateRecord:function(e,r,t,i,n){return this.extractSave(e,r,t,i,n)},extractUpdateRecord:function(e,r,t,i,n){return this.extractSave(e,r,t,i,n)},extractDeleteRecord:function(e,r,t,i,n){return this.extractSave(e,r,t,i,n)},extractFind:function(e,r,t,i,n){return this.extractSingle(e,r,t,i,n)},extractFindBelongsTo:function(e,r,t,i,n){return this.extractSingle(e,r,t,i,n)},extractSave:function(e,r,t,i,n){return this.extractSingle(e,r,t,i,n)},extractSingle:function(e,r,t,i,n){t=this.normalizePayload(t);return this.normalize(r,t)},extractArray:function(e,r,t,i,n){var a=this.normalizePayload(t);var o=this;return B.call(a,function(e){return o.normalize(r,e)})},extractMeta:function(e,r,t){if(t&&t.meta){e.setMetadataFor(r,t.meta);delete t.meta}},extractErrors:function(e,r,t,i){if(t&&typeof t==="object"&&t.errors){t=t.errors;this.normalizeErrors(r,t)}return t},keyForAttribute:function(e){return e},keyForRelationship:function(e,r){return e},transformFor:function(e,r){var t=this.container.lookup("transform:"+e);return t}});var W=Ember.get;var q=Ember.ArrayPolyfills.forEach;var Q=Ember.ArrayPolyfills.map;var X=Ember.String.camelize;function Y(e){return e==null?null:e+""}var G=V.extend({normalize:function(e,r,t){this.normalizeId(r);this.normalizeAttributes(e,r);this.normalizeRelationships(e,r);this.normalizeUsingDeclaredMapping(e,r);if(this.normalizeHash&&this.normalizeHash[t]){this.normalizeHash[t](r)}this.applyTransforms(e,r);return r},extractSingle:function(e,r,t,i){var n=this.normalizePayload(t);var a=r.typeKey;var o;for(var s in n){var u=this.typeForRoot(s);if(!e.modelFactoryFor(u)){continue}var c=e.modelFor(u);var l=c.typeKey===a;var d=n[s];if(d===null){continue}if(l&&Ember.typeOf(d)!=="array"){o=this.normalize(r,d,s);continue}q.call(d,function(r){var t=this.typeForRoot(s);var n=e.modelFor(t);var a=e.serializerFor(n);r=a.normalize(n,r,s);var u=l&&!i&&!o;var c=l&&Y(r.id)===i;if(u||c){o=r}else{e.push(t,r)}},this)}return o},extractArray:function(e,r,t){var i=this.normalizePayload(t);var n=r.typeKey;var a;for(var o in i){var s=o;var u=false;if(o.charAt(0)==="_"){u=true;s=o.substr(1)}var c=this.typeForRoot(s);if(!e.modelFactoryFor(c)){continue}var l=e.modelFor(c);var d=e.serializerFor(l);var h=!u&&l.typeKey===n;var f=Q.call(i[o],function(e){return d.normalize(l,e,o)},this);if(h){a=f}else{e.pushMany(c,f)}}return a},pushPayload:function(e,r){var t=this.normalizePayload(r);for(var i in t){var n=this.typeForRoot(i);if(!e.modelFactoryFor(n,i)){continue}var a=e.modelFor(n);var o=e.serializerFor(a);var s=Q.call(Ember.makeArray(t[i]),function(e){return o.normalize(a,e,i)},this);e.pushMany(n,s)}},typeForRoot:function(e){return X(P(e))},serialize:function(e,r){return this._super.apply(this,arguments)},serializeIntoHash:function(e,r,t,i){e[r.typeKey]=this.serialize(t,i)},serializePolymorphicType:function(e,r,t){var i=t.key;var n=W(e,i);i=this.keyForAttribute?this.keyForAttribute(i):i;if(Ember.isNone(n)){r[i+"Type"]=null}else{r[i+"Type"]=Ember.String.camelize(n.constructor.typeKey)}}});var J=G;var Z=Ember.get,er=Ember.EnumerableUtils.forEach,rr=Ember.String.camelize,tr=Ember.String.capitalize,ir=Ember.String.decamelize,nr=Ember.String.underscore;var ar=J.extend({keyForAttribute:function(e){return ir(e)},keyForRelationship:function(e,r){var t=ir(e);if(r==="belongsTo"){return t+"_id"}else if(r==="hasMany"){return P(t)+"_ids"}else{return t}},serializeHasMany:Ember.K,serializeIntoHash:function(e,r,t,i){var n=nr(ir(r.typeKey));e[n]=this.serialize(t,i)},serializePolymorphicType:function(e,r,t){var i=t.key;var n=Z(e,i);var a=nr(i+"_type");if(Ember.isNone(n)){r[a]=null}else{r[a]=tr(rr(n.constructor.typeKey))}},normalize:function(e,r,t){this.normalizeLinks(r);return this._super(e,r,t)},normalizeLinks:function(e){if(e.links){var r=e.links;for(var t in r){var i=rr(t);if(i!==t){r[i]=r[t];delete r[t]}}}},normalizeRelationships:function(e,r){if(this.keyForRelationship){e.eachRelationship(function(e,t){var i,n;if(t.options.polymorphic){i=this.keyForAttribute(e);n=r[i];if(n&&n.type){n.type=this.typeForRoot(n.type)}else if(n&&t.kind==="hasMany"){var a=this;er(n,function(e){e.type=a.typeForRoot(e.type)})}}else{i=this.keyForRelationship(e,t.kind);if(!r.hasOwnProperty(i)){return}n=r[i]}r[e]=n;if(e!==i){delete r[i]}},this)}}});var or=ar;function sr(e){this.container=e}sr.prototype.aliasedFactory=function(e,r){var t=this;return{create:function(){if(r){r()}return t.container.lookup(e)}}};sr.prototype.registerAlias=function(e,r,t){var i=this.aliasedFactory(r,t);return this.container.register(e,i)};sr.prototype.registerDeprecation=function(e,r){var t=function(){};return this.registerAlias(e,r,t)};sr.prototype.registerDeprecations=function(e){var r,t,i,n;for(r=e.length;r>0;r--){t=e[r-1];i=t["deprecated"];n=t["valid"];this.registerDeprecation(i,n)}};var ur=sr;function cr(e,r){var t=new ur(e);t.registerDeprecations([{deprecated:"serializer:_ams",valid:"serializer:-active-model"},{deprecated:"adapter:_ams",valid:"adapter:-active-model"}]);e.register("serializer:-active-model",or);e.register("adapter:-active-model",j)}var lr=cr;var dr=Ember.Namespace.create({VERSION:"1.0.0-beta.14.1"});if(Ember.libraries){Ember.libraries.registerCoreLibrary("Ember Data",dr.VERSION)}var hr=dr;var fr=Ember.RSVP.Promise;var pr=Ember.get;var mr=Ember.ArrayProxy.extend(Ember.PromiseProxyMixin);var vr=Ember.ObjectProxy.extend(Ember.PromiseProxyMixin);var yr=function(e,r){return vr.create({promise:fr.resolve(e,r)})};var br=function(e,r){return mr.create({promise:fr.resolve(e,r)})};function gr(e){return function(){var r=pr(this,"content");return r[e].apply(r,arguments)}}var Rr=mr.extend({reload:function(){return Rr.create({promise:pr(this,"content").reload()})},createRecord:gr("createRecord"),on:gr("on"),one:gr("one"),trigger:gr("trigger"),off:gr("off"),has:gr("has")});var Er=function(e,r){return Rr.create({promise:fr.resolve(e,r)})};var Fr=Ember.get;var _r=Ember.set;var Ar=Ember.ArrayProxy.extend(Ember.Evented,{type:null,content:null,isLoaded:false,isUpdating:false,store:null,objectAtContent:function(e){var r=Fr(this,"content");return r.objectAt(e)},update:function(){if(Fr(this,"isUpdating")){return}var e=Fr(this,"store");var r=Fr(this,"type");return e.fetchAll(r,this)},addRecord:function(e,r){var t=Fr(this,"content");if(r===undefined){t.addObject(e)}else{if(!t.contains(e)){t.insertAt(r,e)}}},pushRecord:function(e){Fr(this,"content").pushObject(e)},removeRecord:function(e){Fr(this,"content").removeObject(e)},save:function(){var e="DS: RecordArray#save "+Fr(this,"type");var r=Ember.RSVP.all(this.invoke("save"),e).then(function(e){return Ember.A(e)},null,"DS: RecordArray#save apply Ember.NativeArray");return mr.create({promise:r})},_dissociateFromOwnRecords:function(){var e=this;this.forEach(function(r){var t=r._recordArrays;if(t){t["delete"](e)}})},_unregisterFromManager:function(){var e=Fr(this,"manager");if(e){e.unregisterFilteredRecordArray(this)}},willDestroy:function(){this._unregisterFromManager();this._dissociateFromOwnRecords();_r(this,"content",undefined);this._super()}});var Sr=Ember.get;var zr=Ar.extend({filterFunction:null,isLoaded:true,replace:function(){var e=Sr(this,"type").toString();throw new Error("The result of a client-side filter (on "+e+") is immutable.")},_updateFilter:function(){var e=Sr(this,"manager");e.updateFilter(this,Sr(this,"type"),Sr(this,"filterFunction"))},updateFilter:Ember.observer(function(){Ember.run.once(this,this._updateFilter)},"filterFunction")});var kr=Ember.get;function Cr(e){var r=Ember.create(null);for(var t in e){r[t]=e[t]}return r}var Tr=Ar.extend({query:null,replace:function(){var e=kr(this,"type").toString();throw new Error("The result of a server query (on "+e+") is immutable.")},load:function(e){var r=kr(this,"store");var t=kr(this,"type");var i=r.pushMany(t,e);var n=r.metadataFor(t);this.setProperties({content:Ember.A(i),isLoaded:true,meta:Cr(n)});i.forEach(function(e){this.manager.recordArraysForRecord(e).add(this)},this);Ember.run.once(this,"trigger","didLoad")}});var xr=Ember.get,Dr=Ember.set;var wr=Ember.Object.extend(Ember.MutableArray,Ember.Evented,{init:function(){this.currentState=Ember.A([]);this.diff=[]},record:null,canonicalState:null,currentState:null,diff:null,length:0,objectAt:function(e){if(this.currentState[e]){return this.currentState[e]}else{return this.canonicalState[e]}},flushCanonical:function(){var e=this.canonicalState.slice(0);var r=this.currentState.filter(function(e){return e.get("isNew")});e=e.concat(r);this.arrayContentWillChange(0,this.length,this.length);this.set("length",e.length);this.currentState=e;this.arrayContentDidChange(0,this.length,this.length);this.relationship.notifyHasManyChanged();this.record.updateRecordArrays()},isPolymorphic:false,isLoaded:false,relationship:null,internalReplace:function(e,r,t){if(!t){t=[]}this.arrayContentWillChange(e,r,t.length);this.currentState.splice.apply(this.currentState,[e,r].concat(t));this.set("length",this.currentState.length);this.arrayContentDidChange(e,r,t.length);if(t){this.relationship.notifyHasManyChanged()}this.record.updateRecordArrays()},internalRemoveRecords:function(e){var r;for(var t=0;t<e.length;t++){r=this.currentState.indexOf(e[t]);this.internalReplace(r,1)}},internalAddRecords:function(e,r){if(r===undefined){r=this.currentState.length}this.internalReplace(r,0,e)},replace:function(e,r,t){var i;if(r>0){i=this.currentState.slice(e,e+r);this.get("relationship").removeRecords(i)}if(t){this.get("relationship").addRecords(t,e)}},promise:null,loadingRecordsCount:function(e){this.loadingRecordsCount=e},loadedRecord:function(){this.loadingRecordsCount--;if(this.loadingRecordsCount===0){Dr(this,"isLoaded",true);this.trigger("didLoad")}},reload:function(){return this.relationship.reload()},createRecord:function(e){var r=xr(this,"store");var t=xr(this,"type");var i;i=r.createRecord(t,e);this.pushObject(i);return i}});var Mr=Ember.get;var Pr=Ember.EnumerableUtils.forEach;var Or=Ember.EnumerableUtils.indexOf;var $r=Ember.Object.extend({init:function(){this.filteredRecordArrays=p.create({defaultValue:function(){return[]}});this.changedRecords=[];this._adapterPopulatedRecordArrays=[]},recordDidChange:function(e){if(this.changedRecords.push(e)!==1){return}Ember.run.schedule("actions",this,this.updateRecordArrays)},recordArraysForRecord:function(e){e._recordArrays=e._recordArrays||h.create();return e._recordArrays},updateRecordArrays:function(){Pr(this.changedRecords,function(e){if(Mr(e,"isDeleted")){this._recordWasDeleted(e)}else{this._recordWasChanged(e)}},this);this.changedRecords.length=0},_recordWasDeleted:function(e){var r=e._recordArrays;if(!r){return}r.forEach(function(r){r.removeRecord(e)});e._recordArrays=null},_recordWasChanged:function(e){var r=e.constructor;var t=this.filteredRecordArrays.get(r);var i;Pr(t,function(t){i=Mr(t,"filterFunction");this.updateRecordArray(t,i,r,e)},this);var n=e._loadingRecordArrays;if(n){for(var a=0,o=n.length;a<o;a++){n[a].loadedRecord()}e._loadingRecordArrays=[]}},updateRecordArray:function(e,r,t,i){var n;if(!r){n=true}else{n=r(i)}var a=this.recordArraysForRecord(i);if(n){if(!a.has(e)){e.pushRecord(i);a.add(e)}}else if(!n){a["delete"](e);e.removeRecord(i)}},updateFilter:function(e,r,t){var i=this.store.typeMapFor(r);var n=i.records,a;for(var o=0,s=n.length;o<s;o++){a=n[o];if(!Mr(a,"isDeleted")&&!Mr(a,"isEmpty")){this.updateRecordArray(e,t,r,a)}}},createRecordArray:function(e){var r=Ar.create({type:e,content:Ember.A(),store:this.store,isLoaded:true,manager:this});this.registerFilteredRecordArray(r,e);return r},createFilteredRecordArray:function(e,r,t){var i=zr.create({query:t,type:e,content:Ember.A(),store:this.store,manager:this,filterFunction:r});this.registerFilteredRecordArray(i,e,r);return i},createAdapterPopulatedRecordArray:function(e,r){var t=Tr.create({type:e,query:r,content:Ember.A(),store:this.store,manager:this});this._adapterPopulatedRecordArrays.push(t);return t},registerFilteredRecordArray:function(e,r,t){var i=this.filteredRecordArrays.get(r);i.push(e);this.updateFilter(e,r,t)},unregisterFilteredRecordArray:function(e){var r=this.filteredRecordArrays.get(e.type);var t=Or(r,e);r.splice(t,1)},registerWaitingRecordArray:function(e,r){var t=e._loadingRecordArrays||[];t.push(r);e._loadingRecordArrays=t},willDestroy:function(){this._super();Pr(Lr(Ir(this.filteredRecordArrays.values)),Kr);Pr(this._adapterPopulatedRecordArrays,Kr)}});function Ir(e){var r=[];var t=Ember.keys(e);for(var i=0;i<t.length;i++){r.push(e[t[i]])}return r}function Kr(e){e.destroy()}function Lr(e){var r=e.length;var t=Ember.A();for(var i=0;i<r;i++){t=t.concat(e[i])}return t}var jr=Ember.get;var Ur=Ember.set;function Nr(e,r){if(r.value===r.originalValue){delete e._attributes[r.name];e.send("propertyWasReset",r.name)}else if(r.value!==r.oldValue){e.send("becomeDirty")}e.updateRecordArraysLater()}var Br={initialState:"uncommitted",isDirty:true,uncommitted:{didSetProperty:Nr,loadingData:Ember.K,propertyWasReset:function(e,r){var t=Ember.keys(e._attributes).length;var i=t>0;if(!i){e.send("rolledBack")}},pushedData:Ember.K,becomeDirty:Ember.K,willCommit:function(e){e.transitionTo("inFlight")},reloadRecord:function(e,r){r(jr(e,"store").reloadRecord(e))},rolledBack:function(e){e.transitionTo("loaded.saved")},becameInvalid:function(e){e.transitionTo("invalid")},rollback:function(e){e.rollback()}},inFlight:{isSaving:true,didSetProperty:Nr,becomeDirty:Ember.K,pushedData:Ember.K,unloadRecord:function(e){},willCommit:Ember.K,didCommit:function(e){var r=jr(this,"dirtyType");e.transitionTo("saved");e.send("invokeLifecycleCallbacks",r)},becameInvalid:function(e){e.transitionTo("invalid");e.send("invokeLifecycleCallbacks")},becameError:function(e){e.transitionTo("uncommitted");e.triggerLater("becameError",e)}},invalid:{isValid:false,deleteRecord:function(e){e.transitionTo("deleted.uncommitted");e.disconnectRelationships()},didSetProperty:function(e,r){jr(e,"errors").remove(r.name);Nr(e,r)},becomeDirty:Ember.K,willCommit:function(e){jr(e,"errors").clear();e.transitionTo("inFlight")},rolledBack:function(e){jr(e,"errors").clear()},becameValid:function(e){e.transitionTo("uncommitted")},invokeLifecycleCallbacks:function(e){e.triggerLater("becameInvalid",e)},exit:function(e){e._inFlightAttributes={}}}};function Hr(e){var r={},t;for(var i in e){t=e[i];if(t&&typeof t==="object"){r[i]=Hr(t)}else{r[i]=t}}return r}function Vr(e,r){for(var t in r){e[t]=r[t]}return e}function Wr(e){var r=Hr(Br);return Vr(r,e)}var qr=Wr({dirtyType:"created",isNew:true});qr.uncommitted.rolledBack=function(e){e.transitionTo("deleted.saved")};var Qr=Wr({dirtyType:"updated"});qr.uncommitted.deleteRecord=function(e){e.disconnectRelationships();e.transitionTo("deleted.saved")};qr.uncommitted.rollback=function(e){Br.uncommitted.rollback.apply(this,arguments);e.transitionTo("deleted.saved")};qr.uncommitted.propertyWasReset=Ember.K;function Xr(e){}Qr.inFlight.unloadRecord=Xr;Qr.uncommitted.deleteRecord=function(e){e.transitionTo("deleted.uncommitted");e.disconnectRelationships()};var Yr={isEmpty:false,isLoading:false,isLoaded:false,isDirty:false,isSaving:false,isDeleted:false,isNew:false,isValid:true,rolledBack:Ember.K,unloadRecord:function(e){e.clearRelationships();e.transitionTo("deleted.saved")},propertyWasReset:Ember.K,empty:{isEmpty:true,loadingData:function(e,r){e._loadingPromise=r;e.transitionTo("loading")},loadedData:function(e){e.transitionTo("loaded.created.uncommitted")},pushedData:function(e){e.transitionTo("loaded.saved");e.triggerLater("didLoad")}},loading:{isLoading:true,exit:function(e){e._loadingPromise=null},pushedData:function(e){e.transitionTo("loaded.saved");e.triggerLater("didLoad");Ur(e,"isError",false)},becameError:function(e){e.triggerLater("becameError",e)},notFound:function(e){e.transitionTo("empty")}},loaded:{initialState:"saved",isLoaded:true,loadingData:Ember.K,saved:{setup:function(e){var r=e._attributes;var t=Ember.keys(r).length>0;if(t){e.adapterDidDirty()}},didSetProperty:Nr,pushedData:Ember.K,becomeDirty:function(e){e.transitionTo("updated.uncommitted") },willCommit:function(e){e.transitionTo("updated.inFlight")},reloadRecord:function(e,r){r(jr(e,"store").reloadRecord(e))},deleteRecord:function(e){e.transitionTo("deleted.uncommitted");e.disconnectRelationships()},unloadRecord:function(e){e.clearRelationships();e.transitionTo("deleted.saved")},didCommit:function(e){e.send("invokeLifecycleCallbacks",jr(e,"lastDirtyType"))},notFound:Ember.K},created:qr,updated:Qr},deleted:{initialState:"uncommitted",dirtyType:"deleted",isDeleted:true,isLoaded:true,isDirty:true,setup:function(e){e.updateRecordArrays()},uncommitted:{willCommit:function(e){e.transitionTo("inFlight")},rollback:function(e){e.rollback()},becomeDirty:Ember.K,deleteRecord:Ember.K,rolledBack:function(e){e.transitionTo("loaded.saved")}},inFlight:{isSaving:true,unloadRecord:Xr,willCommit:Ember.K,didCommit:function(e){e.transitionTo("saved");e.send("invokeLifecycleCallbacks")},becameError:function(e){e.transitionTo("uncommitted");e.triggerLater("becameError",e)}},saved:{isDirty:false,setup:function(e){var r=jr(e,"store");r.dematerializeRecord(e)},invokeLifecycleCallbacks:function(e){e.triggerLater("didDelete",e);e.triggerLater("didCommit",e)},willCommit:Ember.K,didCommit:Ember.K}},invokeLifecycleCallbacks:function(e,r){if(r==="created"){e.triggerLater("didCreate",e)}else{e.triggerLater("didUpdate",e)}e.triggerLater("didCommit",e)}};function Gr(e,r,t){e=Vr(r?Ember.create(r):{},e);e.parentState=r;e.stateName=t;for(var i in e){if(!e.hasOwnProperty(i)||i==="parentState"||i==="stateName"){continue}if(typeof e[i]==="object"){e[i]=Gr(e[i],e,t+"."+i)}}return e}Yr=Gr(Yr,null,"root");var Jr=Yr;var Zr=Ember.get;var et=Ember.isEmpty;var rt=Ember.EnumerableUtils.map;var tt=Ember.Object.extend(Ember.Enumerable,Ember.Evented,{registerHandlers:function(e,r,t){this.on("becameInvalid",e,r);this.on("becameValid",e,t)},errorsByAttributeName:Ember.reduceComputed("content",{initialValue:function(){return p.create({defaultValue:function(){return Ember.A()}})},addedItem:function(e,r){e.get(r.attribute).pushObject(r);return e},removedItem:function(e,r){e.get(r.attribute).removeObject(r);return e}}),errorsFor:function(e){return Zr(this,"errorsByAttributeName").get(e)},messages:Ember.computed.mapBy("content","message"),content:Ember.computed(function(){return Ember.A()}),unknownProperty:function(e){var r=this.errorsFor(e);if(et(r)){return null}return r},nextObject:function(e,r,t){return Zr(this,"content").objectAt(e)},length:Ember.computed.oneWay("content.length").readOnly(),isEmpty:Ember.computed.not("length").readOnly(),add:function(e,r){var t=Zr(this,"isEmpty");r=this._findOrCreateMessages(e,r);Zr(this,"content").addObjects(r);this.notifyPropertyChange(e);this.enumerableContentDidChange();if(t&&!Zr(this,"isEmpty")){this.trigger("becameInvalid")}},_findOrCreateMessages:function(e,r){var t=this.errorsFor(e);return rt(Ember.makeArray(r),function(r){return t.findBy("message",r)||{attribute:e,message:r}})},remove:function(e){if(Zr(this,"isEmpty")){return}var r=Zr(this,"content").rejectBy("attribute",e);Zr(this,"content").setObjects(r);this.notifyPropertyChange(e);this.enumerableContentDidChange();if(Zr(this,"isEmpty")){this.trigger("becameValid")}},clear:function(){if(Zr(this,"isEmpty")){return}Zr(this,"content").clear();this.enumerableContentDidChange();this.trigger("becameValid")},has:function(e){return!et(this.errorsFor(e))}});function it(e,r){if(!r||typeof r!=="object"){return e}var t=Ember.keys(r);var i;var n=t.length;for(var a=0;a<n;a++){i=t[a];e[i]=r[i]}return e}var nt=it;var at=Ember.EnumerableUtils.forEach;var ot=function(e,r,t,i){this.members=new h;this.canonicalMembers=new h;this.store=e;this.key=i.key;this.inverseKey=t;this.record=r;this.isAsync=i.options.async;this.relationshipMeta=i;this.inverseKeyForImplicit=this.store.modelFor(this.record.constructor).typeKey+this.key;this.linkPromise=null};ot.prototype={constructor:ot,destroy:Ember.K,clear:function(){var e=this.members.list;var r;while(e.length>0){r=e[0];this.removeRecord(r)}},disconnect:function(){this.members.forEach(function(e){this.removeRecordFromInverse(e)},this)},reconnect:function(){this.members.forEach(function(e){this.addRecordToInverse(e)},this)},removeRecords:function(e){var r=this;at(e,function(e){r.removeRecord(e)})},addRecords:function(e,r){var t=this;at(e,function(e){t.addRecord(e,r);if(r!==undefined){r++}})},addCanonicalRecords:function(e,r){for(var t=0;t<e.length;t++){if(r!==undefined){this.addCanonicalRecord(e[t],t+r)}else{this.addCanonicalRecord(e[t])}}},addCanonicalRecord:function(e,r){if(!this.canonicalMembers.has(e)){this.canonicalMembers.add(e);if(this.inverseKey){e._relationships[this.inverseKey].addCanonicalRecord(this.record)}else{if(!e._implicitRelationships[this.inverseKeyForImplicit]){e._implicitRelationships[this.inverseKeyForImplicit]=new ot(this.store,e,this.key,{options:{}})}e._implicitRelationships[this.inverseKeyForImplicit].addCanonicalRecord(this.record)}}this.flushCanonicalLater()},removeCanonicalRecords:function(e,r){for(var t=0;t<e.length;t++){if(r!==undefined){this.removeCanonicalRecord(e[t],t+r)}else{this.removeCanonicalRecord(e[t])}}},removeCanonicalRecord:function(e,r){if(this.canonicalMembers.has(e)){this.removeCanonicalRecordFromOwn(e);if(this.inverseKey){this.removeCanonicalRecordFromInverse(e)}else{if(e._implicitRelationships[this.inverseKeyForImplicit]){e._implicitRelationships[this.inverseKeyForImplicit].removeCanonicalRecord(this.record)}}}this.flushCanonicalLater()},addRecord:function(e,r){if(!this.members.has(e)){this.members.add(e);this.notifyRecordRelationshipAdded(e,r);if(this.inverseKey){e._relationships[this.inverseKey].addRecord(this.record)}else{if(!e._implicitRelationships[this.inverseKeyForImplicit]){e._implicitRelationships[this.inverseKeyForImplicit]=new ot(this.store,e,this.key,{options:{}})}e._implicitRelationships[this.inverseKeyForImplicit].addRecord(this.record)}this.record.updateRecordArrays()}},removeRecord:function(e){if(this.members.has(e)){this.removeRecordFromOwn(e);if(this.inverseKey){this.removeRecordFromInverse(e)}else{if(e._implicitRelationships[this.inverseKeyForImplicit]){e._implicitRelationships[this.inverseKeyForImplicit].removeRecord(this.record)}}}},addRecordToInverse:function(e){if(this.inverseKey){e._relationships[this.inverseKey].addRecord(this.record)}},removeRecordFromInverse:function(e){var r=e._relationships[this.inverseKey];if(r){r.removeRecordFromOwn(this.record)}},removeRecordFromOwn:function(e){this.members["delete"](e);this.notifyRecordRelationshipRemoved(e);this.record.updateRecordArrays()},removeCanonicalRecordFromInverse:function(e){var r=e._relationships[this.inverseKey];if(r){r.removeCanonicalRecordFromOwn(this.record)}},removeCanonicalRecordFromOwn:function(e){this.canonicalMembers["delete"](e);this.flushCanonicalLater()},flushCanonical:function(){this.willSync=false;var e=[];for(var r=0;r<this.members.list.length;r++){if(this.members.list[r].get("isNew")){e.push(this.members.list[r])}}this.members=this.canonicalMembers.copy();for(r=0;r<e.length;r++){this.members.add(e[r])}},flushCanonicalLater:function(){if(this.willSync){return}this.willSync=true;var e=this;this.store._backburner.join(function(){e.store._backburner.schedule("syncRelationships",e,e.flushCanonical)})},updateLink:function(e){if(e!==this.link){this.link=e;this.linkPromise=null;this.record.notifyPropertyChange(this.key)}},findLink:function(){if(this.linkPromise){return this.linkPromise}else{var e=this.fetchLink();this.linkPromise=e;return e.then(function(e){return e})}},updateRecordsFromAdapter:function(e){var r=this;r.computeChanges(e)},notifyRecordRelationshipAdded:Ember.K,notifyRecordRelationshipRemoved:Ember.K};var st=ot;var ut=function(e,r,t,i){this._super$constructor(e,r,t,i);this.belongsToType=i.type;this.canonicalState=[];this.manyArray=wr.create({canonicalState:this.canonicalState,store:this.store,relationship:this,type:this.belongsToType,record:r});this.isPolymorphic=i.options.polymorphic;this.manyArray.isPolymorphic=this.isPolymorphic};ut.prototype=Ember.create(st.prototype);ut.prototype.constructor=ut;ut.prototype._super$constructor=st;ut.prototype.destroy=function(){this.manyArray.destroy()};ut.prototype._super$addCanonicalRecord=st.prototype.addCanonicalRecord;ut.prototype.addCanonicalRecord=function(e,r){if(this.canonicalMembers.has(e)){return}if(r!==undefined){this.canonicalState.splice(r,0,e)}else{this.canonicalState.push(e)}this._super$addCanonicalRecord(e,r)};ut.prototype._super$addRecord=st.prototype.addRecord;ut.prototype.addRecord=function(e,r){if(this.members.has(e)){return}this._super$addRecord(e,r);this.manyArray.internalAddRecords([e],r)};ut.prototype._super$removeCanonicalRecordFromOwn=st.prototype.removeCanonicalRecordFromOwn;ut.prototype.removeCanonicalRecordFromOwn=function(e,r){var t=r;if(!this.canonicalMembers.has(e)){return}if(t===undefined){t=this.canonicalState.indexOf(e)}if(t>-1){this.canonicalState.splice(t,1)}this._super$removeCanonicalRecordFromOwn(e,r)};ut.prototype._super$flushCanonical=st.prototype.flushCanonical;ut.prototype.flushCanonical=function(){this.manyArray.flushCanonical();this._super$flushCanonical()};ut.prototype._super$removeRecordFromOwn=st.prototype.removeRecordFromOwn;ut.prototype.removeRecordFromOwn=function(e,r){if(!this.members.has(e)){return}this._super$removeRecordFromOwn(e,r);if(r!==undefined){this.manyArray.currentState.removeAt(r)}else{this.manyArray.internalRemoveRecords([e])}};ut.prototype.notifyRecordRelationshipAdded=function(e,r){var t=this.relationshipMeta.type;this.record.notifyHasManyAdded(this.key,e,r)};ut.prototype.reload=function(){var e=this;if(this.link){return this.fetchLink()}else{return this.store.scheduleFetchMany(this.manyArray.toArray()).then(function(){e.manyArray.set("isLoaded",true);return e.manyArray})}};ut.prototype.computeChanges=function(e){var r=this.canonicalMembers;var t=[];var i;var n;var a;e=ct(e);r.forEach(function(r){if(e.has(r))return;t.push(r)});this.removeCanonicalRecords(t);var o=this.manyArray;e=e.toArray();i=e.length;for(a=0;a<i;a++){n=e[a];if(o.objectAt(a)===n){continue}this.removeCanonicalRecord(n);this.addCanonicalRecord(n,a)}};ut.prototype.fetchLink=function(){var e=this;return this.store.findHasMany(this.record,this.link,this.relationshipMeta).then(function(r){e.updateRecordsFromAdapter(r);return e.manyArray})};ut.prototype.findRecords=function(){var e=this.manyArray;return this.store.findMany(e.toArray()).then(function(){e.set("isLoaded",true);return e})};ut.prototype.notifyHasManyChanged=function(){this.record.notifyHasManyAdded(this.key)};ut.prototype.getRecords=function(){if(this.isAsync){var e=this;var r;if(this.link){r=this.findLink().then(function(){return e.findRecords()})}else{r=this.findRecords()}return Rr.create({content:this.manyArray,promise:r})}else{if(!this.manyArray.get("isDestroyed")){this.manyArray.set("isLoaded",true)}return this.manyArray}};function ct(e){var r=new h;if(e){for(var t=0,i=e.length;t<i;t++){r.add(e[t])}}return r}var lt=ut;var dt=function(e,r,t,i){this._super$constructor(e,r,t,i);this.record=r;this.key=i.key;this.inverseRecord=null;this.canonicalState=null};dt.prototype=Ember.create(st.prototype);dt.prototype.constructor=dt;dt.prototype._super$constructor=st;dt.prototype.setRecord=function(e){if(e){this.addRecord(e)}else if(this.inverseRecord){this.removeRecord(this.inverseRecord)}};dt.prototype.setCanonicalRecord=function(e){if(e){this.addCanonicalRecord(e)}else if(this.inverseRecord){this.removeCanonicalRecord(this.inverseRecord)}};dt.prototype._super$addCanonicalRecord=st.prototype.addCanonicalRecord;dt.prototype.addCanonicalRecord=function(e){if(this.canonicalMembers.has(e)){return}var r=this.relationshipMeta.type;if(this.canonicalState){this.removeCanonicalRecord(this.canonicalState)}this.canonicalState=e;this._super$addCanonicalRecord(e)};dt.prototype._super$flushCanonical=st.prototype.flushCanonical;dt.prototype.flushCanonical=function(){if(this.inverseRecord&&this.inverseRecord.get("isNew")&&!this.canonicalState){return}this.inverseRecord=this.canonicalState;this.record.notifyBelongsToChanged(this.key);this._super$flushCanonical()};dt.prototype._super$addRecord=st.prototype.addRecord;dt.prototype.addRecord=function(e){if(this.members.has(e)){return}var r=this.relationshipMeta.type;if(this.inverseRecord){this.removeRecord(this.inverseRecord)}this.inverseRecord=e;this._super$addRecord(e);this.record.notifyBelongsToChanged(this.key)};dt.prototype.setRecordPromise=function(e){var r=e.get&&e.get("content");this.setRecord(r)};dt.prototype._super$removeRecordFromOwn=st.prototype.removeRecordFromOwn;dt.prototype.removeRecordFromOwn=function(e){if(!this.members.has(e)){return}this.inverseRecord=null;this._super$removeRecordFromOwn(e);this.record.notifyBelongsToChanged(this.key)};dt.prototype._super$removeCanonicalRecordFromOwn=st.prototype.removeCanonicalRecordFromOwn;dt.prototype.removeCanonicalRecordFromOwn=function(e){if(!this.canonicalMembers.has(e)){return}this.canonicalState=null;this._super$removeCanonicalRecordFromOwn(e)};dt.prototype.findRecord=function(){if(this.inverseRecord){return this.store._findByRecord(this.inverseRecord)}else{return Ember.RSVP.Promise.resolve(null)}};dt.prototype.fetchLink=function(){var e=this;return this.store.findBelongsTo(this.record,this.link,this.relationshipMeta).then(function(r){if(r){e.addRecord(r)}return r})};dt.prototype.getRecord=function(){if(this.isAsync){var e;if(this.link){var r=this;e=this.findLink().then(function(){return r.findRecord()})}else{e=this.findRecord()}return vr.create({promise:e,content:this.inverseRecord})}else{return this.inverseRecord}};var ht=dt;var ft=function(e,r,t){var i;var n=e.constructor.inverseFor(r.key);if(n){i=n.name}if(r.kind==="hasMany"){return new lt(t,e,i,r)}else{return new ht(t,e,i,r)}};var pt=ft;var mt=Ember.get;var vt=Ember.set;var yt=Ember.RSVP.Promise;var bt=Ember.ArrayPolyfills.forEach;var gt=Ember.ArrayPolyfills.map;var Rt=Ember.computed("currentState",function(e,r){return mt(mt(this,"currentState"),e)}).readOnly();var Et=Ember.create(null);var Ft=Ember.create(null);function _t(e){return Ft[e]||(Ft[e]=e.split("."))}function At(e){return Et[e]||(Et[e]=_t(e)[0])}var St=Ember.Object.extend(Ember.Evented,{_recordArrays:undefined,_relationships:undefined,_loadingRecordArrays:undefined,isEmpty:Rt,isLoading:Rt,isLoaded:Rt,isDirty:Rt,isSaving:Rt,isDeleted:Rt,isNew:Rt,isValid:Rt,dirtyType:Rt,isError:false,isReloading:false,clientId:null,id:null,currentState:Jr.empty,errors:Ember.computed(function(){var e=tt.create();e.registerHandlers(this,function(){this.send("becameInvalid")},function(){this.send("becameValid")});return e}).readOnly(),serialize:function(e){var r=mt(this,"store");return r.serialize(this,e)},toJSON:function(e){var r=V.create({container:this.container});return r.serialize(this,e)},didLoad:Ember.K,didUpdate:Ember.K,didCreate:Ember.K,didDelete:Ember.K,becameInvalid:Ember.K,becameError:Ember.K,data:Ember.computed(function(){this._data=this._data||{};return this._data}).readOnly(),_data:null,init:function(){this._super();this._setup()},_setup:function(){this._changesToSync={};this._deferredTriggers=[];this._data={};this._attributes=Ember.create(null);this._inFlightAttributes=Ember.create(null);this._relationships={};this._implicitRelationships=Ember.create(null);var e=this;this.constructor.eachRelationship(function(r,t){e._relationships[r]=pt(e,t,e.store)})},send:function(e,r){var t=mt(this,"currentState");if(!t[e]){this._unhandledEvent(t,e,r)}return t[e](this,r)},transitionTo:function(e){var r=At(e);var t=mt(this,"currentState");var i=t;do{if(i.exit){i.exit(this)}i=i.parentState}while(!i.hasOwnProperty(r));var n=_t(e);var a=[],o=[],s,u;for(s=0,u=n.length;s<u;s++){i=i[n[s]];if(i.enter){o.push(i)}if(i.setup){a.push(i)}}for(s=0,u=o.length;s<u;s++){o[s].enter(this)}vt(this,"currentState",i);for(s=0,u=a.length;s<u;s++){a[s].setup(this)}this.updateRecordArraysLater()},_unhandledEvent:function(e,r,t){var i="Attempted to handle event `"+r+"` ";i+="on "+String(this)+" while in state ";i+=e.stateName+". ";if(t!==undefined){i+="Called with "+Ember.inspect(t)+"."}throw new Ember.Error(i)},withTransaction:function(e){var r=mt(this,"transaction");if(r){e(r)}},loadingData:function(e){this.send("loadingData",e)},loadedData:function(){this.send("loadedData")},notFound:function(){this.send("notFound")},pushedData:function(){this.send("pushedData")},deleteRecord:function(){this.send("deleteRecord")},destroyRecord:function(){this.deleteRecord();return this.save()},unloadRecord:function(){if(this.isDestroyed){return}this.send("unloadRecord")},clearRelationships:function(){this.eachRelationship(function(e,r){var t=this._relationships[e];if(t){t.clear();t.destroy()}},this)},disconnectRelationships:function(){this.eachRelationship(function(e,r){this._relationships[e].disconnect()},this);var e=this;bt.call(Ember.keys(this._implicitRelationships),function(r){e._implicitRelationships[r].disconnect()})},reconnectRelationships:function(){this.eachRelationship(function(e,r){this._relationships[e].reconnect()},this);var e=this;bt.call(Ember.keys(this._implicitRelationships),function(r){e._implicitRelationships[r].reconnect()})},updateRecordArrays:function(){this._updatingRecordArraysLater=false;mt(this,"store").dataWasUpdated(this.constructor,this)},_preloadData:function(e){var r=this;bt.call(Ember.keys(e),function(t){var i=mt(e,t);var n=r.constructor.metaForProperty(t);if(n.isRelationship){r._preloadRelationship(t,i)}else{mt(r,"_data")[t]=i}})},_preloadRelationship:function(e,r){var t=this.constructor.metaForProperty(e);var i=t.type;if(t.kind==="hasMany"){this._preloadHasMany(e,r,i)}else{this._preloadBelongsTo(e,r,i)}},_preloadHasMany:function(e,r,t){var i=this;var n=gt.call(r,function(e){return i._convertStringOrNumberIntoRecord(e,t)});this._relationships[e].updateRecordsFromAdapter(n)},_preloadBelongsTo:function(e,r,t){var i=this._convertStringOrNumberIntoRecord(r,t);this._relationships[e].setRecord(i)},_convertStringOrNumberIntoRec