UNPKG

39.8 kBJavaScriptView Raw
1!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Daux={})}(this,function(t){"use strict";function e(t,e){return t(e={exports:{}},e.exports),e.exports}var n=e(function(t){var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)}),r=e(function(t){var e=t.exports={version:"2.5.7"};"number"==typeof __e&&(__e=e)}),i=(r.version,function(t){return"object"==typeof t?null!==t:"function"==typeof t}),o=function(t){if(!i(t))throw TypeError(t+" is not an object!");return t},a=function(t){try{return!!t()}catch(t){return!0}},u=!a(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),c=n.document,s=i(c)&&i(c.createElement),f=function(t){return s?c.createElement(t):{}},l=!u&&!a(function(){return 7!=Object.defineProperty(f("div"),"a",{get:function(){return 7}}).a}),h=function(t,e){if(!i(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!i(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!i(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!i(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")},p=Object.defineProperty,d={f:u?Object.defineProperty:function(t,e,n){if(o(t),e=h(e,!0),o(n),l)try{return p(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t}},v=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},y=u?function(t,e,n){return d.f(t,e,v(1,n))}:function(t,e,n){return t[e]=n,t},g={}.hasOwnProperty,m=function(t,e){return g.call(t,e)},b=0,_=Math.random(),k=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++b+_).toString(36))},w=e(function(t){var e=k("src"),i=Function.toString,o=(""+i).split("toString");r.inspectSource=function(t){return i.call(t)},(t.exports=function(t,r,i,a){var u="function"==typeof i;u&&(m(i,"name")||y(i,"name",r)),t[r]!==i&&(u&&(m(i,e)||y(i,e,t[r]?""+t[r]:o.join(String(r)))),t===n?t[r]=i:a?t[r]?t[r]=i:y(t,r,i):(delete t[r],y(t,r,i)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[e]||i.call(this)})}),O=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t},S=function(t,e,n){if(O(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,i){return t.call(e,n,r,i)}}return function(){return t.apply(e,arguments)}},j=function(t,e,i){var o,a,u,c,s=t&j.F,f=t&j.G,l=t&j.S,h=t&j.P,p=t&j.B,d=f?n:l?n[e]||(n[e]={}):(n[e]||{}).prototype,v=f?r:r[e]||(r[e]={}),g=v.prototype||(v.prototype={});for(o in f&&(i=e),i)u=((a=!s&&d&&void 0!==d[o])?d:i)[o],c=p&&a?S(u,n):h&&"function"==typeof u?S(Function.call,u):u,d&&w(d,o,u,t&j.U),v[o]!=u&&y(v,o,c),h&&g[o]!=u&&(g[o]=u)};n.core=r,j.F=1,j.G=2,j.S=4,j.P=8,j.B=16,j.W=32,j.U=64,j.R=128;var x=j,E={}.toString,T=function(t){return E.call(t).slice(8,-1)},R=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==T(t)?t.split(""):Object(t)},P=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},L=function(t){return R(P(t))},A=Math.ceil,M=Math.floor,F=function(t){return isNaN(t=+t)?0:(t>0?M:A)(t)},B=Math.min,C=function(t){return t>0?B(F(t),9007199254740991):0},N=Math.max,D=Math.min,I=function(t){return function(e,n,r){var i,o=L(e),a=C(o.length),u=function(t,e){return(t=F(t))<0?N(t+e,0):D(t,e)}(r,a);if(t&&n!=n){for(;a>u;)if((i=o[u++])!=i)return!0}else for(;a>u;u++)if((t||u in o)&&o[u]===n)return t||u||0;return!t&&-1}},G=e(function(t){var e=n["__core-js_shared__"]||(n["__core-js_shared__"]={});(t.exports=function(t,n){return e[t]||(e[t]=void 0!==n?n:{})})("versions",[]).push({version:r.version,mode:"global",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})}),z=G("keys"),q=function(t){return z[t]||(z[t]=k(t))},H=I(!1),K=q("IE_PROTO"),V="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),W=Object.keys||function(t){return function(t,e){var n,r=L(t),i=0,o=[];for(n in r)n!=K&&m(r,n)&&o.push(n);for(;e.length>i;)m(r,n=e[i++])&&(~H(o,n)||o.push(n));return o}(t,V)},U={f:Object.getOwnPropertySymbols},Y={f:{}.propertyIsEnumerable},J=function(t){return Object(P(t))},Q=Object.assign,X=!Q||a(function(){var t={},e={},n=Symbol(),r="abcdefghijklmnopqrst";return t[n]=7,r.split("").forEach(function(t){e[t]=t}),7!=Q({},t)[n]||Object.keys(Q({},e)).join("")!=r})?function(t,e){for(var n=J(t),r=arguments.length,i=1,o=U.f,a=Y.f;r>i;)for(var u,c=R(arguments[i++]),s=o?W(c).concat(o(c)):W(c),f=s.length,l=0;f>l;)a.call(c,u=s[l++])&&(n[u]=c[u]);return n}:Q;function Z(t){return(Z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function $(t,e,n,r,i,o,a){try{var u=t[o](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,i)}function tt(t){return function(){var e=this,n=arguments;return new Promise(function(r,i){var o=t.apply(e,n);function a(t){$(o,r,i,a,u,"next",t)}function u(t){$(o,r,i,a,u,"throw",t)}a(void 0)})}}function et(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function nt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function rt(t,e,n){return e&&nt(t.prototype,e),n&&nt(t,n),t}function it(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ot(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}x(x.S+x.F,"Object",{assign:X});var at=function(){function t(){et(this,t)}return rt(t,null,[{key:"deserialize",value:function(t){return Object.assign({},t)}},{key:"attributes",get:function(){return[]}},{key:"relationship",get:function(){return{}}}]),t}(),ut=e(function(t){var e=G("wks"),r=n.Symbol,i="function"==typeof r;(t.exports=function(t){return e[t]||(e[t]=i&&r[t]||(i?r:k)("Symbol."+t))}).store=e}),ct=ut("unscopables"),st=Array.prototype;null==st[ct]&&y(st,ct,{});var ft=function(t){st[ct][t]=!0},lt=I(!0);x(x.P,"Array",{includes:function(t){return lt(this,t,arguments.length>1?arguments[1]:void 0)}}),ft("includes");var ht=ut("match"),pt=function(t,e,n){if(i(r=e)&&(void 0!==(o=r[ht])?o:"RegExp"==T(r)))throw TypeError("String#"+n+" doesn't accept regex!");var r,o;return String(P(t))},dt=ut("match");x(x.P+x.F*function(t){var e=/./;try{"/./"[t](e)}catch(n){try{return e[dt]=!1,!"/./"[t](e)}catch(t){}}return!0}("includes"),"String",{includes:function(t){return!!~pt(this,t,"includes").indexOf(t,arguments.length>1?arguments[1]:void 0)}});var vt=u?Object.defineProperties:function(t,e){o(t);for(var n,r=W(e),i=r.length,a=0;i>a;)d.f(t,n=r[a++],e[n]);return t},yt=n.document,gt=yt&&yt.documentElement,mt=q("IE_PROTO"),bt=function(){},_t=function(){var t,e=f("iframe"),n=V.length;for(e.style.display="none",gt.appendChild(e),e.src="javascript:",(t=e.contentWindow.document).open(),t.write("<script>document.F=Object<\/script>"),t.close(),_t=t.F;n--;)delete _t.prototype[V[n]];return _t()},kt=Object.create||function(t,e){var n;return null!==t?(bt.prototype=o(t),n=new bt,bt.prototype=null,n[mt]=t):n=_t(),void 0===e?n:vt(n,e)},wt=function(t,e,n){for(var r in e)w(t,r,e[r],n);return t},Ot=function(t,e,n,r){if(!(t instanceof e)||void 0!==r&&r in t)throw TypeError(n+": incorrect invocation!");return t},St=function(t,e,n,r){try{return r?e(o(n)[0],n[1]):e(n)}catch(e){var i=t.return;throw void 0!==i&&o(i.call(t)),e}},jt={},xt=ut("iterator"),Et=Array.prototype,Tt=function(t){return void 0!==t&&(jt.Array===t||Et[xt]===t)},Rt=ut("toStringTag"),Pt="Arguments"==T(function(){return arguments}()),Lt=function(t){var e,n,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),Rt))?n:Pt?T(e):"Object"==(r=T(e))&&"function"==typeof e.callee?"Arguments":r},At=ut("iterator"),Mt=r.getIteratorMethod=function(t){if(null!=t)return t[At]||t["@@iterator"]||jt[Lt(t)]},Ft=e(function(t){var e={},n={},r=t.exports=function(t,r,i,a,u){var c,s,f,l,h=u?function(){return t}:Mt(t),p=S(i,a,r?2:1),d=0;if("function"!=typeof h)throw TypeError(t+" is not iterable!");if(Tt(h)){for(c=C(t.length);c>d;d++)if((l=r?p(o(s=t[d])[0],s[1]):p(t[d]))===e||l===n)return l}else for(f=h.call(t);!(s=f.next()).done;)if((l=St(f,p,s.value,r))===e||l===n)return l};r.BREAK=e,r.RETURN=n}),Bt=d.f,Ct=ut("toStringTag"),Nt=function(t,e,n){t&&!m(t=n?t:t.prototype,Ct)&&Bt(t,Ct,{configurable:!0,value:e})},Dt={};y(Dt,ut("iterator"),function(){return this});var It=function(t,e,n){t.prototype=kt(Dt,{next:v(1,n)}),Nt(t,e+" Iterator")},Gt=q("IE_PROTO"),zt=Object.prototype,qt=Object.getPrototypeOf||function(t){return t=J(t),m(t,Gt)?t[Gt]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?zt:null},Ht=ut("iterator"),Kt=!([].keys&&"next"in[].keys()),Vt=function(){return this},Wt=function(t,e,n,r,i,o,a){It(n,e,r);var u,c,s,f=function(t){if(!Kt&&t in d)return d[t];switch(t){case"keys":case"values":return function(){return new n(this,t)}}return function(){return new n(this,t)}},l=e+" Iterator",h="values"==i,p=!1,d=t.prototype,v=d[Ht]||d["@@iterator"]||i&&d[i],g=v||f(i),m=i?h?f("entries"):g:void 0,b="Array"==e&&d.entries||v;if(b&&(s=qt(b.call(new t)))!==Object.prototype&&s.next&&(Nt(s,l,!0),"function"!=typeof s[Ht]&&y(s,Ht,Vt)),h&&v&&"values"!==v.name&&(p=!0,g=function(){return v.call(this)}),(Kt||p||!d[Ht])&&y(d,Ht,g),jt[e]=g,jt[l]=Vt,i)if(u={values:h?g:f("values"),keys:o?g:f("keys"),entries:m},a)for(c in u)c in d||w(d,c,u[c]);else x(x.P+x.F*(Kt||p),e,u);return u},Ut=function(t,e){return{value:e,done:!!t}},Yt=ut("species"),Jt=function(t){var e=n[t];u&&e&&!e[Yt]&&d.f(e,Yt,{configurable:!0,get:function(){return this}})},Qt=e(function(t){var e=k("meta"),n=d.f,r=0,o=Object.isExtensible||function(){return!0},u=!a(function(){return o(Object.preventExtensions({}))}),c=function(t){n(t,e,{value:{i:"O"+ ++r,w:{}}})},s=t.exports={KEY:e,NEED:!1,fastKey:function(t,n){if(!i(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!m(t,e)){if(!o(t))return"F";if(!n)return"E";c(t)}return t[e].i},getWeak:function(t,n){if(!m(t,e)){if(!o(t))return!0;if(!n)return!1;c(t)}return t[e].w},onFreeze:function(t){return u&&s.NEED&&o(t)&&!m(t,e)&&c(t),t}}}),Xt=(Qt.KEY,Qt.NEED,Qt.fastKey,Qt.getWeak,Qt.onFreeze,function(t,e){if(!i(t)||t._t!==e)throw TypeError("Incompatible receiver, "+e+" required!");return t}),Zt=d.f,$t=Qt.fastKey,te=u?"_s":"size",ee=function(t,e){var n,r=$t(e);if("F"!==r)return t._i[r];for(n=t._f;n;n=n.n)if(n.k==e)return n},ne={getConstructor:function(t,e,n,r){var i=t(function(t,o){Ot(t,i,e,"_i"),t._t=e,t._i=kt(null),t._f=void 0,t._l=void 0,t[te]=0,null!=o&&Ft(o,n,t[r],t)});return wt(i.prototype,{clear:function(){for(var t=Xt(this,e),n=t._i,r=t._f;r;r=r.n)r.r=!0,r.p&&(r.p=r.p.n=void 0),delete n[r.i];t._f=t._l=void 0,t[te]=0},delete:function(t){var n=Xt(this,e),r=ee(n,t);if(r){var i=r.n,o=r.p;delete n._i[r.i],r.r=!0,o&&(o.n=i),i&&(i.p=o),n._f==r&&(n._f=i),n._l==r&&(n._l=o),n[te]--}return!!r},forEach:function(t){Xt(this,e);for(var n,r=S(t,arguments.length>1?arguments[1]:void 0,3);n=n?n.n:this._f;)for(r(n.v,n.k,this);n&&n.r;)n=n.p},has:function(t){return!!ee(Xt(this,e),t)}}),u&&Zt(i.prototype,"size",{get:function(){return Xt(this,e)[te]}}),i},def:function(t,e,n){var r,i,o=ee(t,e);return o?o.v=n:(t._l=o={i:i=$t(e,!0),k:e,v:n,p:r=t._l,n:void 0,r:!1},t._f||(t._f=o),r&&(r.n=o),t[te]++,"F"!==i&&(t._i[i]=o)),t},getEntry:ee,setStrong:function(t,e,n){Wt(t,e,function(t,n){this._t=Xt(t,e),this._k=n,this._l=void 0},function(){for(var t=this._k,e=this._l;e&&e.r;)e=e.p;return this._t&&(this._l=e=e?e.n:this._t._f)?Ut(0,"keys"==t?e.k:"values"==t?e.v:[e.k,e.v]):(this._t=void 0,Ut(1))},n?"entries":"values",!n,!0),Jt(e)}},re=ut("iterator"),ie=!1;try{[7][re]().return=function(){ie=!0}}catch(t){}var oe,ae,ue,ce,se,fe,le,he,pe,de=function(t,e){if(!e&&!ie)return!1;var n=!1;try{var r=[7],i=r[re]();i.next=function(){return{done:n=!0}},r[re]=function(){return i},t(r)}catch(t){}return n},ve=Object.getOwnPropertyDescriptor,ye={f:u?ve:function(t,e){if(t=L(t),e=h(e,!0),l)try{return ve(t,e)}catch(t){}if(m(t,e))return v(!Y.f.call(t,e),t[e])}},ge=function(t,e){if(o(t),!i(e)&&null!==e)throw TypeError(e+": can't set as prototype!")},me={set:Object.setPrototypeOf||("__proto__"in{}?function(t,e,n){try{(n=S(Function.call,ye.f(Object.prototype,"__proto__").set,2))(t,[]),e=!(t instanceof Array)}catch(t){e=!0}return function(t,r){return ge(t,r),e?t.__proto__=r:n(t,r),t}}({},!1):void 0),check:ge}.set,be=(function(t,e,r,o,u,c){var s=n[t],f=s,l=u?"set":"add",h=f&&f.prototype,p={},d=function(t){var e=h[t];w(h,t,"delete"==t?function(t){return!(c&&!i(t))&&e.call(this,0===t?0:t)}:"has"==t?function(t){return!(c&&!i(t))&&e.call(this,0===t?0:t)}:"get"==t?function(t){return c&&!i(t)?void 0:e.call(this,0===t?0:t)}:"add"==t?function(t){return e.call(this,0===t?0:t),this}:function(t,n){return e.call(this,0===t?0:t,n),this})};if("function"==typeof f&&(c||h.forEach&&!a(function(){(new f).entries().next()}))){var v=new f,y=v[l](c?{}:-0,1)!=v,g=a(function(){v.has(1)}),m=de(function(t){new f(t)}),b=!c&&a(function(){for(var t=new f,e=5;e--;)t[l](e,e);return!t.has(-0)});m||((f=e(function(e,n){Ot(e,f,t);var r=function(t,e,n){var r,o=e.constructor;return o!==n&&"function"==typeof o&&(r=o.prototype)!==n.prototype&&i(r)&&me&&me(t,r),t}(new s,e,f);return null!=n&&Ft(n,u,r[l],r),r})).prototype=h,h.constructor=f),(g||b)&&(d("delete"),d("has"),u&&d("get")),(b||y)&&d(l),c&&h.clear&&delete h.clear}else f=o.getConstructor(e,t,u,l),wt(f.prototype,r),Qt.NEED=!0;Nt(f,t),p[t]=f,x(x.G+x.W+x.F*(f!=s),p),c||o.setStrong(f,t,u)}("Set",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},{add:function(t){return ne.def(Xt(this,"Set"),t=0===t?0:t,t)}},ne),Array.isArray||function(t){return"Array"==T(t)}),_e=ut("species"),ke=(ue=1==(oe=5),ce=2==oe,se=3==oe,fe=4==oe,le=6==oe,he=5==oe||le,pe=ae||function(t,e){return new(function(t){var e;return be(t)&&("function"!=typeof(e=t.constructor)||e!==Array&&!be(e.prototype)||(e=void 0),i(e)&&null===(e=e[_e])&&(e=void 0)),void 0===e?Array:e}(t))(e)},function(t,e,n){for(var r,i,o=J(t),a=R(o),u=S(e,n,3),c=C(a.length),s=0,f=ue?pe(t,c):ce?pe(t,0):void 0;c>s;s++)if((he||s in a)&&(i=u(r=a[s],s,o),oe))if(ue)f[s]=i;else if(i)switch(oe){case 3:return!0;case 5:return r;case 6:return s;case 2:f.push(r)}else if(fe)return!1;return le?-1:se||fe?fe:f}),we=!0;"find"in[]&&Array(1).find(function(){we=!1}),x(x.P+x.F*we,"Array",{find:function(t){return ke(this,t,arguments.length>1?arguments[1]:void 0)}}),ft("find");var Oe=function(){var t=o(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e};u&&"g"!=/./g.flags&&d.f(RegExp.prototype,"flags",{configurable:!0,get:Oe});var Se=/./.toString,je=function(t){w(RegExp.prototype,"toString",t,!0)};a(function(){return"/a/b"!=Se.call({source:"a",flags:"b"})})?je(function(){var t=o(this);return"/".concat(t.source,"/","flags"in t?t.flags:!u&&t instanceof RegExp?Oe.call(t):void 0)}):"toString"!=Se.name&&je(function(){return Se.call(this)});!function(t,e){var n=(r.Object||{})[t]||Object[t],i={};i[t]=e(n),x(x.S+x.F*a(function(){n(1)}),"Object",i)}("keys",function(){return function(t){return W(J(t))}});var xe,Ee,Te,Re=ut("species"),Pe=n.process,Le=n.setImmediate,Ae=n.clearImmediate,Me=n.MessageChannel,Fe=n.Dispatch,Be=0,Ce={},Ne=function(){var t=+this;if(Ce.hasOwnProperty(t)){var e=Ce[t];delete Ce[t],e()}},De=function(t){Ne.call(t.data)};Le&&Ae||(Le=function(t){for(var e=[],n=1;arguments.length>n;)e.push(arguments[n++]);return Ce[++Be]=function(){!function(t,e,n){var r=void 0===n;switch(e.length){case 0:return r?t():t.call(n);case 1:return r?t(e[0]):t.call(n,e[0]);case 2:return r?t(e[0],e[1]):t.call(n,e[0],e[1]);case 3:return r?t(e[0],e[1],e[2]):t.call(n,e[0],e[1],e[2]);case 4:return r?t(e[0],e[1],e[2],e[3]):t.call(n,e[0],e[1],e[2],e[3])}t.apply(n,e)}("function"==typeof t?t:Function(t),e)},xe(Be),Be},Ae=function(t){delete Ce[t]},"process"==T(Pe)?xe=function(t){Pe.nextTick(S(Ne,t,1))}:Fe&&Fe.now?xe=function(t){Fe.now(S(Ne,t,1))}:Me?(Te=(Ee=new Me).port2,Ee.port1.onmessage=De,xe=S(Te.postMessage,Te,1)):n.addEventListener&&"function"==typeof postMessage&&!n.importScripts?(xe=function(t){n.postMessage(t+"","*")},n.addEventListener("message",De,!1)):xe="onreadystatechange"in f("script")?function(t){gt.appendChild(f("script")).onreadystatechange=function(){gt.removeChild(this),Ne.call(t)}}:function(t){setTimeout(S(Ne,t,1),0)});var Ie={set:Le,clear:Ae},Ge=Ie.set,ze=n.MutationObserver||n.WebKitMutationObserver,qe=n.process,He=n.Promise,Ke="process"==T(qe);function Ve(t){var e,n;this.promise=new t(function(t,r){if(void 0!==e||void 0!==n)throw TypeError("Bad Promise constructor");e=t,n=r}),this.resolve=O(e),this.reject=O(n)}var We,Ue,Ye,Je,Qe={f:function(t){return new Ve(t)}},Xe=function(t){try{return{e:!1,v:t()}}catch(t){return{e:!0,v:t}}},Ze=n.navigator,$e=Ze&&Ze.userAgent||"",tn=Ie.set,en=function(){var t,e,r,i=function(){var n,i;for(Ke&&(n=qe.domain)&&n.exit();t;){i=t.fn,t=t.next;try{i()}catch(n){throw t?r():e=void 0,n}}e=void 0,n&&n.enter()};if(Ke)r=function(){qe.nextTick(i)};else if(!ze||n.navigator&&n.navigator.standalone)if(He&&He.resolve){var o=He.resolve(void 0);r=function(){o.then(i)}}else r=function(){Ge.call(n,i)};else{var a=!0,u=document.createTextNode("");new ze(i).observe(u,{characterData:!0}),r=function(){u.data=a=!a}}return function(n){var i={fn:n,next:void 0};e&&(e.next=i),t||(t=i,r()),e=i}}(),nn=n.TypeError,rn=n.process,on=rn&&rn.versions,an=on&&on.v8||"",un=n.Promise,cn="process"==Lt(rn),sn=function(){},fn=Ue=Qe.f,ln=!!function(){try{var t=un.resolve(1),e=(t.constructor={})[ut("species")]=function(t){t(sn,sn)};return(cn||"function"==typeof PromiseRejectionEvent)&&t.then(sn)instanceof e&&0!==an.indexOf("6.6")&&-1===$e.indexOf("Chrome/66")}catch(t){}}(),hn=function(t){var e;return!(!i(t)||"function"!=typeof(e=t.then))&&e},pn=function(t,e){if(!t._n){t._n=!0;var n=t._c;en(function(){for(var r=t._v,i=1==t._s,o=0,a=function(e){var n,o,a,u=i?e.ok:e.fail,c=e.resolve,s=e.reject,f=e.domain;try{u?(i||(2==t._h&&yn(t),t._h=1),!0===u?n=r:(f&&f.enter(),n=u(r),f&&(f.exit(),a=!0)),n===e.promise?s(nn("Promise-chain cycle")):(o=hn(n))?o.call(n,c,s):c(n)):s(r)}catch(t){f&&!a&&f.exit(),s(t)}};n.length>o;)a(n[o++]);t._c=[],t._n=!1,e&&!t._h&&dn(t)})}},dn=function(t){tn.call(n,function(){var e,r,i,o=t._v,a=vn(t);if(a&&(e=Xe(function(){cn?rn.emit("unhandledRejection",o,t):(r=n.onunhandledrejection)?r({promise:t,reason:o}):(i=n.console)&&i.error&&i.error("Unhandled promise rejection",o)}),t._h=cn||vn(t)?2:1),t._a=void 0,a&&e.e)throw e.v})},vn=function(t){return 1!==t._h&&0===(t._a||t._c).length},yn=function(t){tn.call(n,function(){var e;cn?rn.emit("rejectionHandled",t):(e=n.onrejectionhandled)&&e({promise:t,reason:t._v})})},gn=function(t){var e=this;e._d||(e._d=!0,(e=e._w||e)._v=t,e._s=2,e._a||(e._a=e._c.slice()),pn(e,!0))},mn=function(t){var e,n=this;if(!n._d){n._d=!0,n=n._w||n;try{if(n===t)throw nn("Promise can't be resolved itself");(e=hn(t))?en(function(){var r={_w:n,_d:!1};try{e.call(t,S(mn,r,1),S(gn,r,1))}catch(t){gn.call(r,t)}}):(n._v=t,n._s=1,pn(n,!1))}catch(t){gn.call({_w:n,_d:!1},t)}}};ln||(un=function(t){Ot(this,un,"Promise","_h"),O(t),We.call(this);try{t(S(mn,this,1),S(gn,this,1))}catch(t){gn.call(this,t)}},(We=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=wt(un.prototype,{then:function(t,e){var n,r,i,a=fn((n=un,void 0===(i=o(this).constructor)||null==(r=o(i)[Re])?n:O(r)));return a.ok="function"!=typeof t||t,a.fail="function"==typeof e&&e,a.domain=cn?rn.domain:void 0,this._c.push(a),this._a&&this._a.push(a),this._s&&pn(this,!1),a.promise},catch:function(t){return this.then(void 0,t)}}),Ye=function(){var t=new We;this.promise=t,this.resolve=S(mn,t,1),this.reject=S(gn,t,1)},Qe.f=fn=function(t){return t===un||t===Je?new Ye(t):Ue(t)}),x(x.G+x.W+x.F*!ln,{Promise:un}),Nt(un,"Promise"),Jt("Promise"),Je=r.Promise,x(x.S+x.F*!ln,"Promise",{reject:function(t){var e=fn(this);return(0,e.reject)(t),e.promise}}),x(x.S+x.F*!ln,"Promise",{resolve:function(t){return function(t,e){if(o(t),i(e)&&e.constructor===t)return e;var n=Qe.f(t);return(0,n.resolve)(e),n.promise}(this,t)}}),x(x.S+x.F*!(ln&&de(function(t){un.all(t).catch(sn)})),"Promise",{all:function(t){var e=this,n=fn(e),r=n.resolve,i=n.reject,o=Xe(function(){var n=[],o=0,a=1;Ft(t,!1,function(t){var u=o++,c=!1;n.push(void 0),a++,e.resolve(t).then(function(t){c||(c=!0,n[u]=t,--a||r(n))},i)}),--a||r(n)});return o.e&&i(o.v),n.promise},race:function(t){var e=this,n=fn(e),r=n.reject,i=Xe(function(){Ft(t,!1,function(t){e.resolve(t).then(n.resolve,r)})});return i.e&&r(i.v),n.promise}});var bn=Wt(Array,"Array",function(t,e){this._t=L(t),this._i=0,this._k=e},function(){var t=this._t,e=this._k,n=this._i++;return!t||n>=t.length?(this._t=void 0,Ut(1)):Ut(0,"keys"==e?n:"values"==e?t[n]:[n,t[n]])},"values");jt.Arguments=jt.Array,ft("keys"),ft("values"),ft("entries");var _n=function(t){return function(e,n){var r,i,o=String(P(e)),a=F(n),u=o.length;return a<0||a>=u?t?"":void 0:(r=o.charCodeAt(a))<55296||r>56319||a+1===u||(i=o.charCodeAt(a+1))<56320||i>57343?t?o.charAt(a):r:t?o.slice(a,a+2):i-56320+(r-55296<<10)+65536}}(!0);Wt(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,e=this._t,n=this._i;return n>=e.length?{value:void 0,done:!0}:(t=_n(e,n),this._i+=t.length,{value:t,done:!1})});for(var kn=ut("iterator"),wn=ut("toStringTag"),On=jt.Array,Sn={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},jn=W(Sn),xn=0;xn<jn.length;xn++){var En,Tn=jn[xn],Rn=Sn[Tn],Pn=n[Tn],Ln=Pn&&Pn.prototype;if(Ln&&(Ln[kn]||y(Ln,kn,On),Ln[wn]||y(Ln,wn,Tn),jt[Tn]=On,Rn))for(En in bn)Ln[En]||w(Ln,En,bn[En],!0)}e(function(t){!function(e){var n,r=Object.prototype,i=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag",s=e.regeneratorRuntime;if(s)t.exports=s;else{(s=e.regeneratorRuntime=t.exports).wrap=b;var f="suspendedStart",l="suspendedYield",h="executing",p="completed",d={},v={};v[a]=function(){return this};var y=Object.getPrototypeOf,g=y&&y(y(P([])));g&&g!==r&&i.call(g,a)&&(v=g);var m=O.prototype=k.prototype=Object.create(v);w.prototype=m.constructor=O,O.constructor=w,O[c]=w.displayName="GeneratorFunction",s.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},s.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,O):(t.__proto__=O,c in t||(t[c]="GeneratorFunction")),t.prototype=Object.create(m),t},s.awrap=function(t){return{__await:t}},S(j.prototype),j.prototype[u]=function(){return this},s.AsyncIterator=j,s.async=function(t,e,n,r){var i=new j(b(t,e,n,r));return s.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},S(m),m[c]="Generator",m[a]=function(){return this},m.toString=function(){return"[object Generator]"},s.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},s.values=P,R.prototype={constructor:R,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(T),!t)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=n)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,i){return u.type="throw",u.arg=t,e.next=r,i&&(e.method="next",e.arg=n),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var c=i.call(a,"catchLoc"),s=i.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),T(n),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;T(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),d}}}function b(t,e,n,r){var i=e&&e.prototype instanceof k?e:k,o=Object.create(i.prototype),a=new R(r||[]);return o._invoke=function(t,e,n){var r=f;return function(i,o){if(r===h)throw new Error("Generator is already running");if(r===p){if("throw"===i)throw o;return L()}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var u=x(a,n);if(u){if(u===d)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===f)throw r=p,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=h;var c=_(t,e,n);if("normal"===c.type){if(r=n.done?p:l,c.arg===d)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r=p,n.method="throw",n.arg=c.arg)}}}(t,n,a),o}function _(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}function k(){}function w(){}function O(){}function S(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function j(t){var e;this._invoke=function(n,r){function o(){return new Promise(function(e,o){!function e(n,r,o,a){var u=_(t[n],t,r);if("throw"!==u.type){var c=u.arg,s=c.value;return s&&"object"==typeof s&&i.call(s,"__await")?Promise.resolve(s.__await).then(function(t){e("next",t,o,a)},function(t){e("throw",t,o,a)}):Promise.resolve(s).then(function(t){c.value=t,o(c)},a)}a(u.arg)}(n,r,e,o)})}return e=e?e.then(o,o):o()}}function x(t,e){var r=t.iterator[e.method];if(r===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=n,x(t,e),"throw"===e.method))return d;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var i=_(r,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,d;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=n),e.delegate=null,d):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function R(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function P(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(i.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=n,e.done=!0,e};return o.next=o}}return{next:L}}function L(){return{value:n,done:!0}}}(function(){return this}()||Function("return this")())});var An=function(){function t(e){et(this,t),this.store=e,this.queues=[]}return rt(t,[{key:"set",value:function(t,e){this.queues.push({operation:"set",data:{type:t,records:e}})}},{key:"update",value:function(t,e,n){this.queues.push({operation:"update",data:{type:t,id:e,attribute:n}})}},{key:"delete",value:function(t,e){this.queues.push({operation:"delete",data:{type:t,id:e}})}},{key:"commit",value:function(t){var e=this;this.queues.forEach(function(n,r){var i=n.operation,o=n.data,a=t;a||(a={isBackgroundOperation:r!==e.queues.length-1});"set"===i?e.store.set(o.type,o.records,a):"update"===i?e.store.update(o.type,o.id,o.attribute,a):"delete"===i&&e.store.delete(o.type,o.id,a)}),this.queues=[]}}]),t}();function Mn(t,e,n){var r=t[e].relationship[n];return"belongsTo"===r.kind?r.inverse?"belongsTo"===t[r.type].relationship[r.inverse].kind?"oneToOne":"oneToMany":"oneToNone":r.inverse?"belongsTo"===t[r.type].relationship[r.inverse].kind?"oneToMany":"manyToMany":"manyToNone"}function Fn(t,e){var n={id:e.id};return t.attributes.forEach(function(t){n[t]=Object.prototype.hasOwnProperty.call(e,t)?e[t]:null}),Object.keys(t.relationship).forEach(function(r){var i;"belongsTo"===t.relationship[r].kind?n[r]=function(t){return"string"==typeof t||null===t?t:"object"===Z(t)?t.id:null}(e[r]):n[r]=(i=e[r],Array.isArray(i)?i.map(function(t){return"string"==typeof t?t:t.id}):[])}),n}var Bn=function(){function t(e){et(this,t),this.model=e,this.state=this.buildInitialState(),this.subscription={}}var e,n,r,i,o;return rt(t,[{key:"set",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e.id)throw new Error("Record to set has no ID");var r=this.model[t],i=n.isDeserialized?e:r.deserialize(e);if(i){var o=Fn(r,i);this.state[t].data[o.id]=o,this.syncAddedRelationships(t,i),n.isBackgroundOperation||this.triggerSubscriptions()}}},{key:"update",value:function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=this.getStateForRecord(t,e);if(!i)throw new Error("Record doesn't exist");var o=this.model[t].deserialize(Object.assign({},i,n,{id:e}));this.set(t,o,{isBackgroundOperation:!0,isDeserialized:!0}),this.syncRemovedRelationships(t,o,i),r.isBackgroundOperation||this.triggerSubscriptions()}},{key:"delete",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!this.getStateForRecord(t,e))throw new Error("Record doesn't exist");var r=function(t){var e={};return t.attributes.forEach(function(t){e[t]=null}),Object.keys(t.relationship).forEach(function(n){"belongsTo"===t.relationship[n].kind?e[n]=null:e[n]=[]}),e}(this.model[t]);this.update(t,e,r,{isBackgroundOperation:!0}),delete this.state[t].data[e],n.isBackgroundOperation||this.triggerSubscriptions()}},{key:"get",value:(o=tt(regeneratorRuntime.mark(function t(e,n){var r,i,o,a=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=a.length>2&&void 0!==a[2]?a[2]:{},this.isRecordAttributePopulated(e,n)||!r.fetch){t.next=8;break}return t.next=4,r.fetch();case 4:if(i=t.sent){t.next=7;break}return t.abrupt("return",null);case 7:this.set(e,i,{isBackgroundOperation:!0});case 8:if(!(o=this.getStateForRecord(e,n))||!r.include){t.next=12;break}return t.next=12,this.includeRelationships(e,o,r);case 12:return t.abrupt("return",this.getCachedRecord(e,n));case 13:case"end":return t.stop()}},t,this)})),function(t,e){return o.apply(this,arguments)})},{key:"getAll",value:(i=tt(regeneratorRuntime.mark(function t(e){var n,r=this,i=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n=i.length>1&&void 0!==i[1]?i[1]:{}).fetch||this.state[e].isDataComplete){t.next=10;break}return t.next=4,n.fetch();case 4:if(t.t0=t.sent,t.t0){t.next=7;break}t.t0=[];case 7:t.t0.forEach(function(t){return r.set(e,t,{isBackgroundOperation:!0})}),this.state[e].isDataComplete=!0;case 10:return t.abrupt("return",Promise.all(Object.keys(this.state[e].data).map(function(t){return r.get(e,t,{include:n.include})})));case 11:case"end":return t.stop()}},t,this)})),function(t){return i.apply(this,arguments)})},{key:"query",value:(r=tt(regeneratorRuntime.mark(function t(e){var n,r,i=this,o=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=o.length>1&&void 0!==o[1]?o[1]:{},t.next=3,n.fetch();case 3:if(t.t0=t.sent,t.t0){t.next=6;break}t.t0=[];case 6:return(r=t.t0).forEach(function(t){return i.set(e,t,{isBackgroundOperation:!0})}),t.abrupt("return",Promise.all(r.map(function(t){return i.get(e,t.id,{include:n.include})})));case 9:case"end":return t.stop()}},t,this)})),function(t){return r.apply(this,arguments)})},{key:"subscribe",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.random().toString(32).slice(2).substr(0,5);return this.subscription[n]=t,function(){return delete e.subscription[n]}}},{key:"batch",value:function(){return new An(this)}},{key:"buildInitialState",value:function(){var t=this.model,e={};return Object.keys(t).forEach(function(t){e[t]={isDataComplete:!1,data:{}}}),e}},{key:"getCachedRecord",value:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(this.state[t].data[e]){var i=Object.assign({},this.state[t].data[e]),o=this.model[t];return Object.keys(o.relationship).forEach(function(t){var e=o.relationship[t];if("belongsTo"===e.kind&&i[t]){var a=i[t];i[t]=r<1?n.getCachedRecord(e.type,a,r+1):Object.assign({},n.state[e.type].data[a])}else"hasMany"===e.kind&&i[t].length>0&&(i[t]=i[t].map(function(t){return r<1?n.getCachedRecord(e.type,t,r+1):Object.assign({},n.state[e.type].data[t])}))}),i}return null}},{key:"getStateForRecord",value:function(t,e){return this.state[t].data[e]||null}},{key:"isRecordAttributePopulated",value:function(t,e){var n=this.getStateForRecord(t,e);return!!n&&this.model[t].attributes.find(function(t){return!(null===n[t]||Array.isArray(n[t])&&0===n[t].length)})}},{key:"includeRelationship",value:(n=tt(regeneratorRuntime.mark(function t(e,n,r,i,o){var a,u,c,s,f=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if("belongsTo"!==o.kind){t.next=9;break}if(null!==n[i]&&this.isRecordAttributePopulated(o.type,n[i])){t.next=7;break}return t.next=4,r.include[i](n);case 4:a=t.sent,this.set(o.type,a,{isBackgroundOperation:!0}),this.update(e,n.id,it({},i,a.id),{isBackgroundOperation:!0});case 7:t.next=17;break;case 9:if("hasMany"!==o.kind){t.next=17;break}return t.next=12,r.include[i](n);case 12:(u=t.sent).forEach(function(t){return f.set(o.type,t,{isBackgroundOperation:!0})}),c=u.map(function(t){return t.id}),s=ot(new Set(ot(n[i]).concat(ot(c)))),this.update(e,n.id,it({},i,s),{isBackgroundOperation:!0});case 17:case"end":return t.stop()}},t,this)})),function(t,e,r,i,o){return n.apply(this,arguments)})},{key:"includeRelationships",value:(e=tt(regeneratorRuntime.mark(function t(e,n,r){var i,o,a=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return i=this.model[e].relationship,o=[],Object.keys(i).forEach(function(t){r.include[t]&&o.push(a.includeRelationship(e,n,r,t,i[t]))}),t.next=5,Promise.all(o);case 5:case"end":return t.stop()}},t,this)})),function(t,n,r){return e.apply(this,arguments)})},{key:"syncAddedBelongsTo",value:function(t,e,n){var r,i=Mn(this.model,t,n),o=this.model[t].relationship[n];if(r="object"===Z(e[n])&&null!==e[n]?this.model[o.type].deserialize(e[n]):{id:e[n]},"oneToOne"===i){var a=this.getStateForRecord(o.type,r.id);if(!a||!a[o.inverse]){var u=Object.assign(r,it({},o.inverse,e.id));this.set(o.type,u,{isBackgroundOperation:!0})}}else if("oneToMany"===i){var c=this.getStateForRecord(o.type,r.id);if(c)c[o.inverse].find(function(t){return t===e.id})||c[o.inverse].push(e.id);else{var s=Object.assign(r,it({},o.inverse,[e.id]));this.set(o.type,s,{isBackgroundOperation:!0})}}else{var f=this.getStateForRecord(o.type,r.id)||{},l=Object.assign(f,r);this.set(o.type,l,{isBackgroundOperation:!0})}}},{key:"syncAddedHasMany",value:function(t,e,n){var r=this,i=e[n];Array.isArray(i)&&i.forEach(function(i){var o,a=Mn(r.model,t,n),u=r.model[t].relationship[n];if(o="object"===Z(i)&&null!==i?r.model[u.type].deserialize(i):{id:i},"oneToMany"===a){var c=r.getStateForRecord(u.type,o.id);if(c)c[u.inverse]=e.id;else{var s=Object.assign(o,it({},u.inverse,e.id));r.set(u.type,s,{isBackgroundOperation:!0})}}else if("manyToMany"===a){var f=r.getStateForRecord(u.type,o.id);if(f)f[u.inverse].find(function(t){return t===e.id})||f[u.inverse].push(e.id);else{var l=Object.assign(o,it({},u.inverse,[e.id]));r.set(u.type,l,{isBackgroundOperation:!0})}}else{var h=r.getStateForRecord(u.type,o.id)||{},p=Object.assign(h,o);r.set(u.type,p,{isBackgroundOperation:!0})}})}},{key:"syncExistingHasMany",value:function(t,e,n){var r=Mn(this.model,t,n),i=this.model[t].relationship[n],o=this.state[i.type].data,a="object"===Z(e)&&null!==e?e.id:e;if("oneToMany"===r){var u=this.state[t].data[a][n];Object.keys(this.state[i.type].data).filter(function(t){return o[t][i.inverse]===a}).forEach(function(t){u.includes(t)||u.push(t)})}else if("manyToMany"===r){var c=this.state[t].data[a][n];Object.keys(this.state[i.type].data).filter(function(t){return o[t][i.inverse].includes(a)}).forEach(function(t){c.includes(t)||c.push(t)})}}},{key:"syncAddedRelationships",value:function(t,e){var n=this;Object.keys(this.model[t].relationship).forEach(function(r){var i=n.model[t].relationship[r].kind;e[r]?"belongsTo"===i?n.syncAddedBelongsTo(t,e,r):n.syncAddedHasMany(t,e,r):"hasMany"===i&&n.syncExistingHasMany(t,e,r)})}},{key:"syncRemovedBelongsToRelationship",value:function(t,e,n,r,i){if(null===e[r]&&e[r]!==n[r]){var o=this.getStateForRecord(i.type,n[r]);if(o){var a=Mn(this.model,t,r);"oneToOne"===a?o[i.inverse]=null:"oneToMany"===a&&(o[i.inverse]=o[i.inverse].filter(function(t){return t!==n.id}))}}}},{key:"syncRemovedHasManyRelationship",value:function(t,e,n,r,i){var o=this;n[r].filter(function(t){return!e[r].includes(t)}).forEach(function(e){var a=o.getStateForRecord(i.type,e);if(a){var u=Mn(o.model,t,r);"oneToMany"===u?a[i.inverse]=null:"manyToMany"===u&&(a[i.inverse]=a[i.inverse].filter(function(t){return t!==n.id}))}})}},{key:"syncRemovedRelationships",value:function(t,e,n){var r=this,i=this.model[t];Object.keys(i.relationship).forEach(function(o){var a=i.relationship[o];"belongsTo"===a.kind?r.syncRemovedBelongsToRelationship(t,e,n,o,a):"hasMany"===a.kind&&r.syncRemovedHasManyRelationship(t,e,n,o,a)})}},{key:"triggerSubscriptions",value:function(){var t=this;Object.keys(this.subscription).forEach(function(e){try{t.subscription[e]()}catch(n){delete t.subscription[e]}})}}]),t}();t.Model=at,t.Store=Bn,Object.defineProperty(t,"__esModule",{value:!0})});