text: !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).spraypaint={})}(this,(function(t){"use strict";
  /*! *****************************************************************************
      Copyright (c) Microsoft Corporation.
  
      Permission to use, copy, modify, and/or distribute this software for any
      purpose with or without fee is hereby granted.
  
      THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
      REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
      AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
      INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
      LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
      OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
      PERFORMANCE OF THIS SOFTWARE.
      ***************************************************************************** */var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,r)};function r(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return(n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function i(t,e,r,n){var i,s=arguments.length,o=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(o=(s<3?i(o):s>3?i(e,r,o):i(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o}function s(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{u(n.next(t))}catch(t){s(t)}}function a(t){try{u(n.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((n=n.apply(t,e||[])).next())}))}function o(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}}var a,u=function(){function t(t,e){this.model=t,this.payload=e}return t.apply=function(e,r){new t(e,r).apply()},t.prototype.apply=function(){var t=this,e={};this.payload.errors&&(this.payload.errors.forEach((function(r){var n=r.meta;if(!n)throw new Error("invalid json");var i=n.relationship;i?t._processRelationship(t.model,i,r):t._processResource(e,n,r)})),this.model.errors=e)},t.prototype._processResource=function(t,e,r){var n=this.model.klass.deserializeKey(e.attribute);t[n]={title:r.title,code:r.code,attribute:e.attribute,message:e.message,fullMessage:"base"===n?e.message:r.detail,rawPayload:r}},t.prototype._processRelationship=function(t,e,r){var n=t[t.klass.deserializeKey(e.name)];if(Array.isArray(n)&&(n=n.find((function(t){return t.id&&String(t.id)===String(e.id)||t.temp_id&&t.temp_id===e["temp-id"]}))),e.relationship)this._processRelationship(n,e.relationship,r);else{var i={};this._processResource(i,e,r);var s={};Object.keys(n.errors).forEach((function(t){s[t]=n.errors[t]})),Object.keys(i).forEach((function(t){var e=i[t];void 0!==e&&(s[t]=e)})),n.errors=s}},t}(),c=function(t,e){var r=e.headers.get("X-JWT");r&&t.setJWT(r)},l={green:[32,39],cyan:[36,39],magenta:[35,39],bold:[1,22]},p=function(t,e){if(h()){var r=l[t];return"["+r[0]+"m"+e+"["+r[1]+"m"}return e},h=function(){return void 0===typeof window&&!!/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)},f=function(){function t(t,e,r){this.middleware=t,this.logger=e,this.config=Object.assign({patchAsPost:!1},r)}return t.prototype.get=function(t,e){return e.method="GET",this._fetchWithLogging(t,e)},t.prototype.post=function(t,e,r){return r.method="POST",r.body=JSON.stringify(e),this._fetchWithLogging(t,r)},t.prototype.patch=function(t,e,r){return this.config.patchAsPost?(r.method="POST",r.headers||(r.headers={}),r.headers["X-HTTP-Method-Override"]="PATCH"):r.method="PATCH",r.body=JSON.stringify(e),this._fetchWithLogging(t,r)},t.prototype.delete=function(t,e){return e.method="DELETE",this._fetchWithLogging(t,e)},t.prototype._logRequest=function(t,e){this.logger.info(p("cyan",t+": ")+p("magenta",e))},t.prototype._logResponse=function(t){this.logger.debug(p("bold",JSON.stringify(t,null,4)))},t.prototype._fetchWithLogging=function(t,e){return s(this,void 0,void 0,(function(){var r;return o(this,(function(n){switch(n.label){case 0:return this._logRequest(e.method||"UNDEFINED METHOD",t),[4,this._fetch(t,e)];case 1:return r=n.sent(),this._logResponse(r.jsonPayload),[2,r]}}))}))},t.prototype._fetch=function(t,e){return s(this,void 0,void 0,(function(){var r,n,i;return o(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.middleware.beforeFetch(t,e)];case 1:return s.sent(),[3,3];case 2:throw r=s.sent(),new d("beforeFetch failed; review middleware.beforeFetch stack",t,e,r);case 3:return s.trys.push([3,5,,6]),[4,fetch(t,e)];case 4:return n=s.sent(),[3,6];case 5:throw i=s.sent(),new y(null,i.message,i);case 6:return[4,this._handleResponse(n,e)];case 7:return s.sent(),[2,n]}}))}))},t.prototype._handleResponse=function(t,e){return s(this,void 0,void 0,(function(){var r,n,i;return o(this,(function(s){switch(s.label){case 0:if("DELETE"===e.method&&[204,200].indexOf(t.status)>-1)return[2];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,t.clone().json()];case 2:return r=s.sent(),[3,4];case 3:if(n=s.sent(),[202,204].indexOf(t.status)>-1)return[2];throw new y(t,"invalid json",n);case 4:return s.trys.push([4,6,,7]),[4,this.middleware.afterFetch(t,r)];case 5:return s.sent(),[3,7];case 6:throw i=s.sent(),new y(t,"afterFetch failed; review middleware.afterFetch stack",i);case 7:if(t.status>=500)throw new y(t,"Server Error");if(422!==t.status&&void 0===r.data)throw 404===t.status?new y(t,"record not found"):new y(t,"invalid json");return t.jsonPayload=r,[2]}}))}))},t}(),d=function(t){function e(e,r,n,i){var s=t.call(this,e)||this;return s.stack=i.stack,s.url=r,s.options=n,s.originalError=i,s}return r(e,t),e}(Error),y=function(t){function e(e,r,n){var i=t.call(this,r||"Invalid Response")||this;return i.response=e,i.originalError=n,i}return r(e,t),e}(Error),v=function(){function t(e){this.dct={};var r=this._parseIncludeArgs(e);for(var n in r)r.hasOwnProperty(n)&&(this.dct[n]=new t(r[n]))}return t.prototype.toScopeObject=function(){var t={};for(var e in this.dct)this.dct.hasOwnProperty(e)&&(t[e]=this.dct[e].toScopeObject());return t},t.prototype.toString=function(){var t=[],e=function(e){if(r.dct.hasOwnProperty(e)){var n=r.dct[e].toString();if(""===n)t.push(e);else{var i=n.split(",");i=i.map((function(t){return e+"."+t})),t.push(i.join(","))}}},r=this;for(var n in this.dct)e(n);return t.join(",")},t.prototype._parseIncludeArgs=function(t){if(Array.isArray(t))return this._parseArray(t);if("string"==typeof t){var e={};return e[t]={},e}return"object"==typeof t?this._parseObject(t):{}},t.prototype._parseObject=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[r]=this._parseIncludeArgs(t[r]));return e},t.prototype._parseArray=function(t){for(var e={},r=0,n=t;r<n.length;r++){var i=n[r],s=this._parseIncludeArgs(i);for(var o in s)s.hasOwnProperty(o)&&(e[o]=s[o])}return e},t}(),b=0,g=function(){return"temp-id-"+ ++b},_=function(){function t(t,e,r){void 0===r&&(r=!1),this.included=[],this.idOnly=!1;var n=new v(e);if(this.includeDirective=n.toScopeObject(),this.model=t,this.idOnly=r,!t.klass.jsonapiType)throw new Error("Cannot serialize model: Undefined jsonapiType");this.jsonapiType=t.klass.jsonapiType}return t.prototype.attributes=function(){var t=this,e={};return this._eachAttribute((function(r,n,i){if(!t.model.isPersisted||t.model.changes()[r]){var s=t.model.klass.serializeKey(r);i.type===Number&&""===n?e[s]=null:e[s]=n}})),e},t.prototype.removeDeletions=function(t,e){var r=this;Object.keys(e).forEach((function(n){var i=e[n],s=t,o=s[n];if(o)if(Array.isArray(o))o.forEach((function(t,e){t.isMarkedForDestruction||t.isMarkedForDisassociation?s[n].splice(e,1):r.removeDeletions(t,i)}));else{var a=o;a.isMarkedForDestruction||a.isMarkedForDisassociation?s[n]=null:r.removeDeletions(a,i)}}))},t.prototype.postProcess=function(){this.removeDeletions(this.model,this.includeDirective),this.model.resetRelationTracking(this.includeDirective)},t.prototype.relationships=function(){var t=this,e={};return Object.keys(this.includeDirective).forEach((function(r){var n,i=t.includeDirective[r],s=!1;r.indexOf(".")>-1&&(r=r.split(".")[0],s=!0);var o=t.model[r];o&&(Array.isArray(o)?(n=[],o.forEach((function(e){!t._isNewAndMarkedForDestruction(e)&&(s||t.model.hasDirtyRelation(r,e)||e.isDirty(i))&&n.push(t._processRelatedModel(e,i,s))})),0===n.length&&(n=null)):!t._isNewAndMarkedForDestruction(o)&&(s||t.model.hasDirtyRelation(r,o)||o.isDirty(i))&&(n=t._processRelatedModel(o,i,s)),n&&(e[t.model.klass.serializeKey(r)]={data:n}))})),e},t.prototype.asJSON=function(){var t={type:this.jsonapiType};if(this.model.id&&(t.id=this.model.id),this.model.temp_id&&(t["temp-id"]=this.model.temp_id),!this.idOnly){var e=this.attributes();Object.keys(e).length>0&&(t.attributes=e)}var r=this.relationships();Object.keys(r).length>0&&(t.relationships=r);var n={data:t};this.included.length>0&&(n.included=this.included);var i=this.model.meta;return this.model.isMetaDirty&&Object.keys(i).length>0&&(t.meta=i),n},t.prototype._isNewAndMarkedForDestruction=function(t){return!t.isPersisted&&t.isMarkedForDestruction},t.prototype._processRelatedModel=function(e,r,n){var i=this;e.clearErrors(),e.isPersisted||(e.temp_id=g());var s=new t(e,r,n),o=s.asJSON().data;return this._isNewAndMarkedForDestruction(e)||this._pushInclude(o),s.included.forEach((function(t){i._isNewAndMarkedForDestruction(e)||i._pushInclude(t)})),this._resourceIdentifierFor(e)},t.prototype._resourceIdentifierFor=function(t){if(!t.klass.jsonapiType)throw new Error("Cannot serialize model: Undefined jsonapiType for model "+t);var e,r={type:t.klass.jsonapiType};return t.id&&(r.id=t.id),t.temp_id&&(r["temp-id"]=t.temp_id),e=t.isPersisted?t.isMarkedForDestruction?"destroy":t.isMarkedForDisassociation?"disassociate":"update":"create",r.method=e,r},t.prototype._pushInclude=function(t){this._isIncluded(t)||this.included.push(t)},t.prototype._isIncluded=function(t){return this.included.forEach((function(e){if(e.type===t.type&&(e.id===t.id||e["temp-id"]===t["temp-id"]))return!0})),!1},t.prototype._eachAttribute=function(t){var e=this,r=this.model.typedAttributes;Object.keys(r).forEach((function(n){var i=e.model.klass.attributeList[n];if(i.persist){var s=r[n];t(n,s,i)}}))},t}(),m=function(){function t(){this._data={}}return t.prototype.getItem=function(t){return this._data[t]||null},t.prototype.setItem=function(t,e){this._data[t]=e},t.prototype.removeItem=function(t){delete this._data[t]},t}();try{a=localStorage}catch(t){a=new m}var w=function(){function t(t,e){void 0===e&&(e=a),this._jwtKey=t,this._backend=e}return Object.defineProperty(t.prototype,"backend",{get:function(){return this._backend},enumerable:!0,configurable:!0}),t.prototype.getJWT=function(){return this._backend.getItem(this._jwtKey)||void 0},t.prototype.setJWT=function(t){t?this._backend.setItem(this._jwtKey,t):this._backend.removeItem(this._jwtKey)},t}();function j(t,e){return t===e||t!=t&&e!=e}function k(t,e){for(var r=t.length;r--;)if(j(t[r][0],e))return r;return-1}var O=Array.prototype.splice;function P(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}P.prototype.clear=function(){this.__data__=[],this.size=0},P.prototype.delete=function(t){var e=this.__data__,r=k(e,t);return!(r<0)&&(r==e.length-1?e.pop():O.call(e,r,1),--this.size,!0)},P.prototype.get=function(t){var e=this.__data__,r=k(e,t);return r<0?void 0:e[r][1]},P.prototype.has=function(t){return k(this.__data__,t)>-1},P.prototype.set=function(t,e){var r=this.__data__,n=k(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var A="object"==typeof global&&global&&global.Object===Object&&global,C="object"==typeof self&&self&&self.Object===Object&&self,S=A||C||Function("return this")(),R=S.Symbol,E=Object.prototype,$=E.hasOwnProperty,x=E.toString,F=R?R.toStringTag:void 0;var T=Object.prototype.toString;var D=R?R.toStringTag:void 0;function L(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":D&&D in Object(t)?function(t){var e=$.call(t,F),r=t[F];try{t[F]=void 0;var n=!0}catch(t){}var i=x.call(t);return n&&(e?t[F]=r:delete t[F]),i}(t):function(t){return T.call(t)}(t)}function z(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function I(t){if(!z(t))return!1;var e=L(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var M,U=S["__core-js_shared__"],N=(M=/[^.]+$/.exec(U&&U.keys&&U.keys.IE_PROTO||""))?"Symbol(src)_1."+M:"";var B=Function.prototype.toString;function J(t){if(null!=t){try{return B.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var K=/^\[object .+?Constructor\]$/,W=Function.prototype,H=Object.prototype,q=W.toString,G=H.hasOwnProperty,Z=RegExp("^"+q.call(G).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Q(t){return!(!z(t)||(e=t,N&&N in e))&&(I(t)?Z:K).test(J(t));var e}function V(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Q(r)?r:void 0}var Y=V(S,"Map"),X=V(Object,"create");var tt=Object.prototype.hasOwnProperty;var et=Object.prototype.hasOwnProperty;function rt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function nt(t,e){var r,n,i=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?i["string"==typeof e?"string":"hash"]:i.map}function it(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}rt.prototype.clear=function(){this.__data__=X?X(null):{},this.size=0},rt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},rt.prototype.get=function(t){var e=this.__data__;if(X){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return tt.call(e,t)?e[t]:void 0},rt.prototype.has=function(t){var e=this.__data__;return X?void 0!==e[t]:et.call(e,t)},rt.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=X&&void 0===e?"__lodash_hash_undefined__":e,this},it.prototype.clear=function(){this.size=0,this.__data__={hash:new rt,map:new(Y||P),string:new rt}},it.prototype.delete=function(t){var e=nt(this,t).delete(t);return this.size-=e?1:0,e},it.prototype.get=function(t){return nt(this,t).get(t)},it.prototype.has=function(t){return nt(this,t).has(t)},it.prototype.set=function(t,e){var r=nt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function st(t){var e=this.__data__=new P(t);this.size=e.size}st.prototype.clear=function(){this.__data__=new P,this.size=0},st.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},st.prototype.get=function(t){return this.__data__.get(t)},st.prototype.has=function(t){return this.__data__.has(t)},st.prototype.set=function(t,e){var r=this.__data__;if(r instanceof P){var n=r.__data__;if(!Y||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new it(n)}return r.set(t,e),this.size=r.size,this};var ot=function(){try{var t=V(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function at(t,e,r){"__proto__"==e&&ot?ot(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var ut=Object.prototype.hasOwnProperty;function ct(t,e,r){var n=t[e];ut.call(t,e)&&j(n,r)&&(void 0!==r||e in t)||at(t,e,r)}function lt(t,e,r,n){var i=!r;r||(r={});for(var s=-1,o=e.length;++s<o;){var a=e[s],u=n?n(r[a],t[a],a,r,t):void 0;void 0===u&&(u=t[a]),i?at(r,a,u):ct(r,a,u)}return r}function pt(t){return null!=t&&"object"==typeof t}function ht(t){return pt(t)&&"[object Arguments]"==L(t)}var ft=Object.prototype,dt=ft.hasOwnProperty,yt=ft.propertyIsEnumerable,vt=ht(function(){return arguments}())?ht:function(t){return pt(t)&&dt.call(t,"callee")&&!yt.call(t,"callee")},bt=Array.isArray;var gt="object"==typeof t&&t&&!t.nodeType&&t,_t=gt&&"object"==typeof module&&module&&!module.nodeType&&module,mt=_t&&_t.exports===gt?S.Buffer:void 0,wt=(mt?mt.isBuffer:void 0)||function(){return!1},jt=/^(?:0|[1-9]\d*)$/;function kt(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&jt.test(t))&&t>-1&&t%1==0&&t<e}function Ot(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var Pt={};function At(t){return function(e){return t(e)}}Pt["[object Float32Array]"]=Pt["[object Float64Array]"]=Pt["[object Int8Array]"]=Pt["[object Int16Array]"]=Pt["[object Int32Array]"]=Pt["[object Uint8Array]"]=Pt["[object Uint8ClampedArray]"]=Pt["[object Uint16Array]"]=Pt["[object Uint32Array]"]=!0,Pt["[object Arguments]"]=Pt["[object Array]"]=Pt["[object ArrayBuffer]"]=Pt["[object Boolean]"]=Pt["[object DataView]"]=Pt["[object Date]"]=Pt["[object Error]"]=Pt["[object Function]"]=Pt["[object Map]"]=Pt["[object Number]"]=Pt["[object Object]"]=Pt["[object RegExp]"]=Pt["[object Set]"]=Pt["[object String]"]=Pt["[object WeakMap]"]=!1;var Ct="object"==typeof t&&t&&!t.nodeType&&t,St=Ct&&"object"==typeof module&&module&&!module.nodeType&&module,Rt=St&&St.exports===Ct&&A.process,Et=function(){try{var t=St&&St.require&&St.require("util").types;return t||Rt&&Rt.binding&&Rt.binding("util")}catch(t){}}(),$t=Et&&Et.isTypedArray,xt=$t?At($t):function(t){return pt(t)&&Ot(t.length)&&!!Pt[L(t)]},Ft=Object.prototype.hasOwnProperty;function Tt(t,e){var r=bt(t),n=!r&&vt(t),i=!r&&!n&&wt(t),s=!r&&!n&&!i&&xt(t),o=r||n||i||s,a=o?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],u=a.length;for(var c in t)!e&&!Ft.call(t,c)||o&&("length"==c||i&&("offset"==c||"parent"==c)||s&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||kt(c,u))||a.push(c);return a}var Dt=Object.prototype;function Lt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Dt)}function zt(t,e){return function(r){return t(e(r))}}var It=zt(Object.keys,Object),Mt=Object.prototype.hasOwnProperty;function Ut(t){if(!Lt(t))return It(t);var e=[];for(var r in Object(t))Mt.call(t,r)&&"constructor"!=r&&e.push(r);return e}function Nt(t){return null!=t&&Ot(t.length)&&!I(t)}function Bt(t){return Nt(t)?Tt(t):Ut(t)}var Jt=Object.prototype.hasOwnProperty;function Kt(t){if(!z(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Lt(t),r=[];for(var n in t)("constructor"!=n||!e&&Jt.call(t,n))&&r.push(n);return r}function Wt(t){return Nt(t)?Tt(t,!0):Kt(t)}var Ht="object"==typeof t&&t&&!t.nodeType&&t,qt=Ht&&"object"==typeof module&&module&&!module.nodeType&&module,Gt=qt&&qt.exports===Ht?S.Buffer:void 0,Zt=Gt?Gt.allocUnsafe:void 0;function Qt(){return[]}var Vt=Object.prototype.propertyIsEnumerable,Yt=Object.getOwnPropertySymbols,Xt=Yt?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,i=0,s=[];++r<n;){var o=t[r];e(o,r,t)&&(s[i++]=o)}return s}(Yt(t),(function(e){return Vt.call(t,e)})))}:Qt;function te(t,e){for(var r=-1,n=e.length,i=t.length;++r<n;)t[i+r]=e[r];return t}var ee=zt(Object.getPrototypeOf,Object),re=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)te(e,Xt(t)),t=ee(t);return e}:Qt;function ne(t,e,r){var n=e(t);return bt(t)?n:te(n,r(t))}function ie(t){return ne(t,Bt,Xt)}function se(t){return ne(t,Wt,re)}var oe=V(S,"DataView"),ae=V(S,"Promise"),ue=V(S,"Set"),ce=V(S,"WeakMap"),le="[object Map]",pe="[object Promise]",he="[object Set]",fe="[object WeakMap]",de="[object DataView]",ye=J(oe),ve=J(Y),be=J(ae),ge=J(ue),_e=J(ce),me=L;(oe&&me(new oe(new ArrayBuffer(1)))!=de||Y&&me(new Y)!=le||ae&&me(ae.resolve())!=pe||ue&&me(new ue)!=he||ce&&me(new ce)!=fe)&&(me=function(t){var e=L(t),r="[object Object]"==e?t.constructor:void 0,n=r?J(r):"";if(n)switch(n){case ye:return de;case ve:return le;case be:return pe;case ge:return he;case _e:return fe}return e});var we=me,je=Object.prototype.hasOwnProperty;var ke=S.Uint8Array;function Oe(t){var e=new t.constructor(t.byteLength);return new ke(e).set(new ke(t)),e}var Pe=/\w*$/;var Ae=R?R.prototype:void 0,Ce=Ae?Ae.valueOf:void 0;function Se(t,e,r){var n,i,s,o=t.constructor;switch(e){case"[object ArrayBuffer]":return Oe(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return function(t,e){var r=e?Oe(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t,e){var r=e?Oe(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,r);case"[object Map]":return new o;case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return(s=new(i=t).constructor(i.source,Pe.exec(i))).lastIndex=i.lastIndex,s;case"[object Set]":return new o;case"[object Symbol]":return n=t,Ce?Object(Ce.call(n)):{}}}var Re=Object.create,Ee=function(){function t(){}return function(e){if(!z(e))return{};if(Re)return Re(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();var $e=Et&&Et.isMap,xe=$e?At($e):function(t){return pt(t)&&"[object Map]"==we(t)};var Fe=Et&&Et.isSet,Te=Fe?At(Fe):function(t){return pt(t)&&"[object Set]"==we(t)},De="[object Arguments]",Le="[object Function]",ze="[object Object]",Ie={};function Me(t,e,r,n,i,s){var o,a=1&e,u=2&e,c=4&e;if(r&&(o=i?r(t,n,i,s):r(t)),void 0!==o)return o;if(!z(t))return t;var l=bt(t);if(l){if(o=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&je.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!a)return function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}(t,o)}else{var p=we(t),h=p==Le||"[object GeneratorFunction]"==p;if(wt(t))return function(t,e){if(e)return t.slice();var r=t.length,n=Zt?Zt(r):new t.constructor(r);return t.copy(n),n}(t,a);if(p==ze||p==De||h&&!i){if(o=u||h?{}:function(t){return"function"!=typeof t.constructor||Lt(t)?{}:Ee(ee(t))}(t),!a)return u?function(t,e){return lt(t,re(t),e)}(t,function(t,e){return t&&lt(e,Wt(e),t)}(o,t)):function(t,e){return lt(t,Xt(t),e)}(t,function(t,e){return t&&lt(e,Bt(e),t)}(o,t))}else{if(!Ie[p])return i?t:{};o=Se(t,p,a)}}s||(s=new st);var f=s.get(t);if(f)return f;s.set(t,o),Te(t)?t.forEach((function(n){o.add(Me(n,e,r,n,t,s))})):xe(t)&&t.forEach((function(n,i){o.set(i,Me(n,e,r,i,t,s))}));var d=l?void 0:(c?u?se:ie:u?Wt:Bt)(t);return function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););}(d||t,(function(n,i){d&&(n=t[i=n]),ct(o,i,Me(n,e,r,i,t,s))})),o}Ie[De]=Ie["[object Array]"]=Ie["[object ArrayBuffer]"]=Ie["[object DataView]"]=Ie["[object Boolean]"]=Ie["[object Date]"]=Ie["[object Float32Array]"]=Ie["[object Float64Array]"]=Ie["[object Int8Array]"]=Ie["[object Int16Array]"]=Ie["[object Int32Array]"]=Ie["[object Map]"]=Ie["[object Number]"]=Ie[ze]=Ie["[object RegExp]"]=Ie["[object Set]"]=Ie["[object String]"]=Ie["[object Symbol]"]=Ie["[object Uint8Array]"]=Ie["[object Uint8ClampedArray]"]=Ie["[object Uint16Array]"]=Ie["[object Uint32Array]"]=!0,Ie["[object Error]"]=Ie[Le]=Ie["[object WeakMap]"]=!1;function Ue(t){return Me(t,5)}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var Ne=function(t){var e={exports:{}};return t(e,e.exports),e.exports}((function(t,e){var r;t.exports=(r={},(r=function(){this.listeners={}}).prototype={addEventListener:function(t,e,r){for(var n=[],i=arguments.length,s=0;s<i;s++)n.push(arguments[s]);n=n.length>3?n.splice(3,n.length-1):[],void 0!==this.listeners[t]?this.listeners[t].push({scope:r,callback:e,args:n}):this.listeners[t]=[{scope:r,callback:e,args:n}]},removeEventListener:function(t,e,r){if(void 0!==this.listeners[t]){for(var n=this.listeners[t].length,i=[],s=0;s<n;s++){var o=this.listeners[t][s];o.scope==r&&o.callback==e||i.push(o)}this.listeners[t]=i}},hasEventListener:function(t,e,r){if(void 0!==this.listeners[t]){var n=this.listeners[t].length;if(void 0===e&&void 0===r)return n>0;for(var i=0;i<n;i++){var s=this.listeners[t][i];if((!r||s.scope==r)&&s.callback==e)return!0}}return!1},dispatch:function(t,e){for(var r={type:t,target:e},n=[],i=arguments.length,s=0;s<i;s++)n.push(arguments[s]);if(n=n.length>2?n.splice(2,n.length-1):[],n=[r].concat(n),void 0!==this.listeners[t]){var o=this.listeners[t].slice(),a=o.length;for(s=0;s<a;s++){var u=o[s];if(u&&u.callback){var c=n.concat(u.args);u.callback.apply(u.scope,c)}}}},getEvents:function(){var t="";for(var e in this.listeners)for(var r=this.listeners[e].length,n=0;n<r;n++){var i=this.listeners[e][n];t+=i.scope&&i.scope.className?i.scope.className:"anonymous",t+=" listen for '"+e+"'\n"}return t}},new r)})),Be=function(){function t(){this.data={}}return Object.defineProperty(t.prototype,"count",{get:function(){return Object.keys(this.data).length},enumerable:!0,configurable:!0}),t.prototype.find=function(t,e){return void 0===e&&(e=null),e||(e=t.storeKey),this.data[e]},t.prototype.findAll=function(t){var e=this,r=[];return t.forEach((function(t){var n=e.find(t);n&&r.push(n)})),r},t.prototype.create=function(t,e){t.storeKey=e,t.stale=!1,this.data[e]=Ue(t.attributes)},t.prototype.updateOrCreate=function(t){if(t.storeKey)this.create(t,t.storeKey);else{var e=this.keyFor(t);this.create(t,e)}Ne.dispatch(t.storeKey,{},this.data[t.storeKey])},t.prototype.destroy=function(t){t.stale=!0,delete this.data[t.storeKey]},t.prototype.keyFor=function(t){return t.klass.jsonapiType+"-"+t.id},t}(),Je=function(){function t(t,e){this._deserialized=[],this._resources=[],this.registry=t,this.payload=e,this.addResources(e.data),this.addResources(e.included)}return t.prototype.addResources=function(t){if(t)if(Array.isArray(t))for(var e=0,r=t;e<r.length;e++){var n=r[e];this._resources.push(n)}else this._resources.push(t)},t.prototype.instanceFor=function(t){var e=this.registry.get(t);if(!e)throw new Error('Unknown type "'+t+'"');return new e},t.prototype.klassFor=function(t){var e=this.registry.get(t);if(!e)throw new Error('Unknown type "'+t+'"');return e},t.prototype.relationshipInstanceFor=function(t,e){var r=e.find((function(e){return!(e.klass.jsonapiType!==t.type||!(e.id&&t.id&&e.id===t.id||e.temp_id&&t["temp-id"]&&e.temp_id===t["temp-id"]))}));return r||(r=this.instanceFor(t.type)),r},t.prototype.lookupAssociated=function(t,e){return t.find((function(t){return!(t.klass.jsonapiType!==e.klass.jsonapiType||!(t.temp_id&&e.temp_id&&t.temp_id===e.temp_id||t.id&&e.id&&t.id===e.id))}))},t.prototype.pushRelation=function(t,e,r){var n=t,i=n[e];this.lookupAssociated(i,r)||n[e].push(r)},t.prototype.deserialize=function(t){var e=this.instanceFor(t.type);return this.deserializeInstance(e,t,{})},t.prototype.deserializeInstance=function(t,e,r){void 0===r&&(r={});var n=this.alreadyDeserialized(e);return n||(t.id=e.id,t.temp_id=e["temp-id"],t.assignAttributes(e.attributes),t.assignLinks(e.links),t.setMeta(e.meta,!1),this._deserialized.push(t),this._processRelationships(t,e.relationships||{},r),this._removeDeletions(t,r),t.isPersisted=!0,t.reset(),t)},t.prototype._removeDeletions=function(t,e){var r=this;Object.keys(e).forEach((function(n){var i=t,s=i[n];if(s)if(Array.isArray(s))s.forEach((function(t,s){t.isMarkedForDestruction?i.klass.store.destroy(t):t.isMarkedForDisassociation?i[n].splice(s,1):r._removeDeletions(t,e[n]||{})}));else{var o=s;o.isMarkedForDestruction?i.klass.store.destroy(o):o.isMarkedForDisassociation?i[n]=null:r._removeDeletions(o,e[n]||{})}}))},t.prototype._processRelationships=function(t,e,r){var n=this;this._iterateValidRelationships(t,e,(function(e,i){var s=r[e],o=t;if(Array.isArray(i))for(var a=0,u=i;a<u.length;a++){var c=u[a],l=n.findResource(c),p=o[e]||[],h=n.relationshipInstanceFor(l,p);h=n.deserializeInstance(h,l,s),n.pushRelation(t,e,h)}else{l=n.findResource(i);var f=o[e],d=f||n.instanceFor(l.type);d=n.deserializeInstance(d,l,s),f||(o[e]=d)}}))},t.prototype._iterateValidRelationships=function(t,e,r){for(var n in e)if(e.hasOwnProperty(n)){var i=t.klass.deserializeKey(n),s=t.klass.attributeList[i];if(s){var o=e[n].data;o&&r(i,o),t[i+"Links"]={};var a=e[n].links;if(a&&a.related){var u=s.type;u||(u=this.klassFor(s.name)),t[i+"Links"]={related:u.fromUrl(a.related)}}}}},t.prototype.alreadyDeserialized=function(t){return this._deserialized.find((function(e){return!(e.klass.jsonapiType!==t.type||!(e.id&&t.id&&e.id===t.id||e.temp_id&&t.temp_id&&e.temp_id===t["temp-id"]))}))},t.prototype.findResource=function(t){return this._resources.find((function(e){return!(e.type!==t.type||!(e.id&&t.id&&e.id===t.id||e["temp-id"]&&t["temp-id"]&&e["temp-id"]===t["temp-id"]))}))||t},t}(),Ke=Object.prototype.hasOwnProperty;var We=function(){function t(t){this.model=t}return t.prototype.checkRelation=function(t,e){var r=!1;e.isPersisted&&((this.model._originalRelationships[t]||[]).find((function(t){return JSON.stringify(t)===JSON.stringify(e.resourceIdentifier)}))||(r=!0));return r},t.prototype.check=function(t){void 0===t&&(t={});var e=new v(t).toScopeObject();return this._hasDirtyAttributes()||this._hasDirtyRelationships(e)||this.model.isMarkedForDestruction||this.model.isMarkedForDisassociation||this._isUnpersisted()},t.prototype.dirtyAttributes=function(){for(var t={},e=0,r=Object.keys(this.model.attributes);e<r.length;e++){var n=r[e],i=this.model._originalAttributes[n],s=this.model.attributes[n],o=this.model.klass.attributeList[n];this.model.isPersisted?o.dirtyChecker(i,s)&&(t[n]=[i,s]):t[n]=[null,s]}return t},t.prototype._isUnpersisted=function(){return!this.model.isPersisted&&JSON.stringify(this.model.attributes)!==JSON.stringify({})},t.prototype._hasDirtyAttributes=function(){return!function(t){if(null==t)return!0;if(Nt(t)&&(bt(t)||"string"==typeof t||"function"==typeof t.splice||wt(t)||xt(t)||vt(t)))return!t.length;var e=we(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(Lt(t))return!Ut(t).length;for(var r in t)if(Ke.call(t,r))return!1;return!0}(this.dirtyAttributes())},t.prototype._hasDirtyRelationships=function(t){var e=this,r=!1;return this._eachRelatedObject(t,(function(t,n,i){n.isDirty(i)&&(r=!0),e.checkRelation(t,n)&&(r=!0)})),r},t.prototype._eachRelatedObject=function(t,e){var r=this;Object.keys(t).forEach((function(n){var i=t[n],s=r.model[n];Array.isArray(s)||(s=[s]),s.forEach((function(t){t&&e(n,t,i)}))}))},t}(),He=function(t,e){var r=[];for(var n in t)if(t.hasOwnProperty(n)){var i=t[n];null!=i&&""!==i&&(e&&(n=e+"["+n+"]"),Array.isArray(i)?(i=i.map((function(t){return qe(t)}))).length>0&&r.push(n+"="+i.join(",")):"object"==typeof i?r.push(He(i,n)):r.push(n+"="+qe(i)))}return(r=r.filter((function(t){return!!t}))).join("&")},qe=function(t){var e="undefined"!=typeof window,r=e&&window.navigator.userAgent.match(/(MSIE|Trident)/),n="string"==typeof t&&-1!==t.indexOf("%");return e&&r&&!n?encodeURIComponent(t):t},Ge=function(){function t(t,e){void 0===e&&(e={data:[]}),this._collection=t,this._raw_json=e}return Object.defineProperty(t.prototype,"raw",{get:function(){return this._raw_json},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"data",{get:function(){return this._collection},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"meta",{get:function(){return this.raw.meta||{}},enumerable:!0,configurable:!0}),t}(),Ze=function(){function t(t,e){this._record=t,this._raw_json=e}return Object.defineProperty(t.prototype,"raw",{get:function(){return this._raw_json},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"data",{get:function(){return this._record},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"meta",{get:function(){return this.raw.meta||{}},enumerable:!0,configurable:!0}),t}(),Qe=function(){function t(t){this._raw_json=t}return Object.defineProperty(t.prototype,"raw",{get:function(){return this._raw_json},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"data",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"meta",{get:function(){return this.raw.meta||{}},enumerable:!0,configurable:!0}),t}(),Ve=function(){function t(t){this._associations={},this._pagination={},this._filter={},this._sort={},this._fields={},this._extra_fields={},this._include={},this._stats={},this._extraParams={},this._extraFetchOptions={},this._overriddenUrl="",this.model=t}return t.prototype.all=function(){return s(this,void 0,void 0,(function(){var t,e;return o(this,(function(r){switch(r.label){case 0:return t=this._overriddenUrl||this.model.url(),[4,this._fetch(t)];case 1:return e=r.sent(),[2,this._buildCollectionResult(e)]}}))}))},t.prototype.find=function(t){return s(this,void 0,void 0,(function(){var e,r;return o(this,(function(n){switch(n.label){case 0:return e=this._overriddenUrl||this.model.url(t),[4,this._fetch(e)];case 1:return r=n.sent(),[2,this._buildRecordResult(r)]}}))}))},t.prototype.get=function(){return s(this,void 0,void 0,(function(){var t,e;return o(this,(function(r){switch(r.label){case 0:return t=this._overriddenUrl,[4,this._fetch(t)];case 1:return e=r.sent(),[2,this._buildRecordResult(e)]}}))}))},t.prototype.first=function(){return s(this,void 0,void 0,(function(){var t,e,r;return o(this,(function(n){switch(n.label){case 0:return t=this.per(1),e=this._overriddenUrl||t.model.url(),[4,t._fetch(e)];case 1:return r=n.sent(),[2,this._buildRecordResult(r)]}}))}))},t.prototype.merge=function(t){var e=this,r=this.copy();return Object.keys(t).forEach((function(n){var i=e.model.serializeKey(n);r._associations[i]=t[n]})),r},t.prototype.page=function(t){var e=this.copy();return e._pagination.number=t,e},t.prototype.per=function(t){var e=this.copy();return e._pagination.size=t,e},t.prototype.where=function(t){var e=this.copy();for(var r in t=this._serverCasedWhereClause(t))t.hasOwnProperty(r)&&(e._filter[r]=t[r]);return e},t.prototype.fromUrl=function(t){var e=this.copy();return e._overriddenUrl=t,e},t.prototype.extraParams=function(t){var e=this.copy();for(var r in t)t.hasOwnProperty(r)&&(e._extraParams[r]=t[r]);return e},t.prototype.stats=function(t){var e=this.copy();for(var r in t=this._serverCasedStatsClause(t))t.hasOwnProperty(r)&&(e._stats[r]=t[r]);return e},t.prototype.order=function(t){var e=this.copy();if("object"==typeof(t=this._serverCasedOrderClause(t)))for(var r in t)t.hasOwnProperty(r)&&(e._sort[r]=t[r]);else e._sort[t]="asc";return e},t.prototype.select=function(t){var e=this.copy();if(t=this._serverCasedFieldsClause(t),Array.isArray(t)){var r=t,n=this.model.jsonapiType;e._fields[n]=r}else for(var i in t)t.hasOwnProperty(i)&&(e._fields[i]=t[i]);return e},t.prototype.selectExtra=function(t){var e=this.copy();if(t=this._serverCasedFieldsClause(t),Array.isArray(t)){var r=t,n=this.model.jsonapiType;e._extra_fields[n]=r}else for(var i in t)t.hasOwnProperty(i)&&(e._extra_fields[i]=t[i]);return e},t.prototype.includes=function(t){var e=this.copy();t=this._serverCasedIncludesClause(t);var r=new v(t).toScopeObject();for(var n in r)r.hasOwnProperty(n)&&(e._include[n]=r[n]);return e},t.prototype.extraFetchOptions=function(t){var e=this.copy();for(var r in t)t.hasOwnProperty(r)&&(e._extraFetchOptions[r]=t[r]);return e},t.prototype.scope=function(){return this},t.prototype.asQueryParams=function(){var t=this,e={page:this._pagination,filter:this._filter,sort:this._sortParam(this._sort)||[],fields:this._fields,extra_fields:this._extra_fields,stats:this._stats,include:new v(this._include).toString()};return this._mergeAssociationQueryParams(e,this._associations),Object.keys(this._extraParams).forEach((function(r){e[r]=t._extraParams[r]})),e},t.prototype.toQueryParams=function(){var t=He(this.asQueryParams());if(""!==t)return t},t.prototype.fetchOptions=function(){return n({},this.model.fetchOptions(),this._extraFetchOptions)},t.prototype.copy=function(){return Ue(this)},t.prototype._mergeAssociationQueryParams=function(t,e){var r=this,n=function(n){if(e.hasOwnProperty(n)){var i=e[n].asQueryParams();t.page[n]=i.page,t.filter[n]=i.filter,t.stats[n]=i.stats,Object.assign(t.fields,i.fields),Object.assign(t.extra_fields,i.extra_fields),i.sort.forEach((function(e){var i=r._transformAssociationSortParam(n,e);t.sort.push(i)}))}};for(var i in e)n(i)},t.prototype._transformAssociationSortParam=function(t,e){return-1!==e.indexOf("-")&&(e=e.replace("-",""),t="-"+t),t+"."+e},t.prototype._sortParam=function(t){if(t&&Object.keys(t).length>0){var e=[];for(var r in t)t.hasOwnProperty(r)&&("asc"!==t[r]&&(r="-"+r),e.push(r));return e}},t.prototype._fetch=function(t){return s(this,void 0,void 0,(function(){var e,r;return o(this,(function(n){switch(n.label){case 0:return(e=this.toQueryParams())&&(t=t+"?"+e),[4,new f(this.model.middlewareStack,this.model.logger).get(t,this.fetchOptions())];case 1:return r=n.sent(),c(this.model,r),[2,r.jsonPayload]}}))}))},t.prototype._buildRecordResult=function(t){var e,r;if(t.data instanceof Array){if(!(r=t.data[0]))return new Qe(t)}else r=t.data;return e=this.model.fromJsonapi(r,t),new Ze(e,t)},t.prototype._buildCollectionResult=function(t){var e=this,r=[];return t.data.forEach((function(n){r.push(e.model.fromJsonapi(n,t))})),new Ge(r,t)},t.prototype._serverCasedWhereClause=function(t){return this._serverCasedClause(t,!1)},t.prototype._serverCasedOrderClause=function(t){return"string"==typeof t?this._serverCasedClause(t,!0):this._serverCasedClause(t,!1)},t.prototype._serverCasedFieldsClause=function(t){return this._serverCasedClause(t,!0)},t.prototype._serverCasedIncludesClause=function(t){return this._serverCasedClause(t,!0)},t.prototype._serverCasedStatsClause=function(t){return this._serverCasedClause(t,!0)},t.prototype._serverCasedClause=function(t,e){var r=this;if(void 0===e&&(e=!1),"string"==typeof t)return e?this.model.serializeKey(t):t;if(t instanceof Array)return t.map((function(t){return r._serverCasedClause(t,e)}));if(t instanceof Object){var n={};for(var i in t)if(t.hasOwnProperty(i)){var s=this.model.serializeKey(i),o=this._serverCasedClause(t[i],e);n[s]=o}return n}return t},t}(),Ye=function(){function t(t){this._typeMap={},this._baseClass=t}return t.prototype.register=function(t,e){if(this._typeMap[t])throw new Error('Type "'+t+'" already registered on base class '+this._baseClass);this._typeMap[t]=e},t.prototype.get=function(t){return this._typeMap[t]},t}(),Xe=Object.prototype.toString;var tr=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},er=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}();function rr(t){return t.split("").map((function(t){return"(?:"+t.toUpperCase()+"|"+t.toLowerCase()+")"})).join("")}function nr(t,e){for(var r=t.length-1;r>=0;r--)t[r]===e&&Array.prototype.splice.call(t,r,1)}function ir(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var sr={},or=function(){function t(){tr(this,t),this.plurals=[],this.singulars=[],this.uncountables=[],this.humans=[],this.acronyms={},this.acronymRegex=/(?=a)b/}return er(t,null,[{key:"getInstance",value:function(e){return sr[e]=sr[e]||new t,sr[e]}}]),er(t,[{key:"acronym",value:function(t){this.acronyms[t.toLowerCase()]=t;var e=[];for(var r in this.acronyms)ir(this.acronyms,r)&&e.push(this.acronyms[r]);this.acronymRegex=new RegExp(e.join("|"))}},{key:"plural",value:function(t,e){"string"==typeof t&&nr(this.uncountables,t),nr(this.uncountables,e),this.plurals.unshift([t,e])}},{key:"singular",value:function(t,e){"string"==typeof t&&nr(this.uncountables,t),nr(this.uncountables,e),this.singulars.unshift([t,e])}},{key:"irregular",value:function(t,e){nr(this.uncountables,t),nr(this.uncountables,e);var r=t[0],n=t.substr(1),i=e[0],s=e.substr(1);if(r.toUpperCase()===i.toUpperCase())this.plural(new RegExp("("+r+")"+n+"$","i"),"$1"+s),this.plural(new RegExp("("+i+")"+s+"$","i"),"$1"+s),this.singular(new RegExp("("+r+")"+n+"$","i"),"$1"+n),this.singular(new RegExp("("+i+")"+s+"$","i"),"$1"+n);else{var o=rr(n),a=rr(s);this.plural(new RegExp(r.toUpperCase()+o+"$"),i.toUpperCase()+s),this.plural(new RegExp(r.toLowerCase()+o+"$"),i.toLowerCase()+s),this.plural(new RegExp(i.toUpperCase()+a+"$"),i.toUpperCase()+s),this.plural(new RegExp(i.toLowerCase()+a+"$"),i.toLowerCase()+s),this.singular(new RegExp(r.toUpperCase()+o+"$"),r.toUpperCase()+n),this.singular(new RegExp(r.toLowerCase()+o+"$"),r.toLowerCase()+n),this.singular(new RegExp(i.toUpperCase()+a+"$"),r.toUpperCase()+n),this.singular(new RegExp(i.toLowerCase()+a+"$"),r.toLowerCase()+n)}}},{key:"uncountable",value:function(){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];this.uncountables=this.uncountables.concat(e)}},{key:"human",value:function(t,e){this.humans.unshift([t,e])}},{key:"clear",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"all";"all"===t?(this.plurals=[],this.singulars=[],this.uncountables=[],this.humans=[]):this[t]=[]}}]),t}();var ar={en:function(t){t.plural(/$/,"s"),t.plural(/s$/i,"s"),t.plural(/^(ax|test)is$/i,"$1es"),t.plural(/(octop|vir)us$/i,"$1i"),t.plural(/(octop|vir)i$/i,"$1i"),t.plural(/(alias|status)$/i,"$1es"),t.plural(/(bu)s$/i,"$1ses"),t.plural(/(buffal|tomat)o$/i,"$1oes"),t.plural(/([ti])um$/i,"$1a"),t.plural(/([ti])a$/i,"$1a"),t.plural(/sis$/i,"ses"),t.plural(/(?:([^f])fe|([lr])f)$/i,"$1$2ves"),t.plural(/(hive)$/i,"$1s"),t.plural(/([^aeiouy]|qu)y$/i,"$1ies"),t.plural(/(x|ch|ss|sh)$/i,"$1es"),t.plural(/(matr|vert|ind)(?:ix|ex)$/i,"$1ices"),t.plural(/^(m|l)ouse$/i,"$1ice"),t.plural(/^(m|l)ice$/i,"$1ice"),t.plural(/^(ox)$/i,"$1en"),t.plural(/^(oxen)$/i,"$1"),t.plural(/(quiz)$/i,"$1zes"),t.singular(/s$/i,""),t.singular(/(ss)$/i,"$1"),t.singular(/(n)ews$/i,"$1ews"),t.singular(/([ti])a$/i,"$1um"),t.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i,"$1sis"),t.singular(/(^analy)(sis|ses)$/i,"$1sis"),t.singular(/([^f])ves$/i,"$1fe"),t.singular(/(hive)s$/i,"$1"),t.singular(/(tive)s$/i,"$1"),t.singular(/([lr])ves$/i,"$1f"),t.singular(/([^aeiouy]|qu)ies$/i,"$1y"),t.singular(/(s)eries$/i,"$1eries"),t.singular(/(m)ovies$/i,"$1ovie"),t.singular(/(x|ch|ss|sh)es$/i,"$1"),t.singular(/^(m|l)ice$/i,"$1ouse"),t.singular(/(bus)(es)?$/i,"$1"),t.singular(/(o)es$/i,"$1"),t.singular(/(shoe)s$/i,"$1"),t.singular(/(cris|test)(is|es)$/i,"$1is"),t.singular(/^(a)x[ie]s$/i,"$1xis"),t.singular(/(octop|vir)(us|i)$/i,"$1us"),t.singular(/(alias|status)(es)?$/i,"$1"),t.singular(/^(ox)en/i,"$1"),t.singular(/(vert|ind)ices$/i,"$1ex"),t.singular(/(matr)ices$/i,"$1ix"),t.singular(/(quiz)zes$/i,"$1"),t.singular(/(database)s$/i,"$1"),t.irregular("person","people"),t.irregular("man","men"),t.irregular("child","children"),t.irregular("sex","sexes"),t.irregular("move","moves"),t.irregular("zombie","zombies"),t.uncountable("equipment","information","rice","money","species","series","fish","sheep","jeans","police")}};function ur(t,e){var r;if(r=t,"[object Function]"===Xe.call(r)&&(e=t,t=null),t=t||"en",!e)return or.getInstance(t);e(or.getInstance(t))}for(var cr in ar)ur(cr,ar[cr]);function lr(t,e){var r,n,i,s=""+t;if(0===s.length)return s;var o=s.toLowerCase().match(/\b\w+$/);if(o&&ur().uncountables.indexOf(o[0])>-1)return s;for(var a=0,u=e.length;a<u;a++)if(n=(r=e[a])[0],i=r[1],s.match(n)){s=s.replace(n,i);break}return s}function pr(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en";return lr(t,ur(e).plurals)}function hr(t){var e=null==t?"":String(t);return e.charAt(0).toUpperCase()+e.slice(1)}function fr(t,e){null==e&&(e=!0);var r=""+t;return r=(r=e?r.replace(/^[a-z\d]*/,(function(t){return ur().acronyms[t]||hr(t)})):r.replace(new RegExp("^(?:"+ur().acronymRegex.source+"(?=\\b|[A-Z_])|\\w)"),(function(t){return t.toLowerCase()}))).replace(/(?:_|(\/))([a-z\d]*)/gi,(function(t,e,r,n,i){return e||(e=""),""+e+(ur().acronyms[r]||hr(r))}))}function dr(t){var e=""+t;return(e=(e=(e=(e=e.replace(new RegExp("(?:([A-Za-z\\d])|^)("+ur().acronymRegex.source+")(?=\\b|[^a-z])","g"),(function(t,e,r){return(e||"")+(e?"_":"")+r.toLowerCase()}))).replace(/([A-Z\d]+)([A-Z][a-z])/g,"$1_$2")).replace(/([a-z\d])([A-Z])/g,"$1_$2")).replace(/-/g,"_")).toLowerCase()}function yr(t){return t.replace(/_/g,"-")}var vr,br={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","×":"x","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","Þ":"Th","ß":"ss","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","þ":"th","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Ĉ":"C","ĉ":"c","Ċ":"C","ċ":"c","Č":"C","č":"c","Ď":"D","ď":"d","Đ":"D","đ":"d","Ē":"E","ē":"e","Ĕ":"E","ĕ":"e","Ė":"E","ė":"e","Ę":"E","ę":"e","Ě":"E","ě":"e","Ĝ":"G","ĝ":"g","Ğ":"G","ğ":"g","Ġ":"G","ġ":"g","Ģ":"G","ģ":"g","Ĥ":"H","ĥ":"h","Ħ":"H","ħ":"h","Ĩ":"I","ĩ":"i","Ī":"I","ī":"i","Ĭ":"I","ĭ":"i","Į":"I","į":"i","İ":"I","ı":"i","Ĳ":"IJ","ĳ":"ij","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","ĺ":"l","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ŀ":"L","ŀ":"l","Ł":"L","ł":"l","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","ŉ":"'n","Ŋ":"NG","ŋ":"ng","Ō":"O","ō":"o","Ŏ":"O","ŏ":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","Ŕ":"R","ŕ":"r","Ŗ":"R","ŗ":"r","Ř":"R","ř":"r","Ś":"S","ś":"s","Ŝ":"S","ŝ":"s","Ş":"S","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","Ť":"T","ť":"t","Ŧ":"T","ŧ":"t","Ũ":"U","ũ":"u","Ū":"U","ū":"u","Ŭ":"U","ŭ":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","А":"A","Б":"B","В":"V","Г":"G","Д":"D","Е":"E","Ё":"E","Ж":"ZH","З":"Z","И":"I","Й":"J","К":"K","Л":"L","М":"M","Н":"N","О":"O","П":"P","Р":"R","С":"S","Т":"T","У":"U","Ф":"F","Х":"KH","Ц":"C","Ч":"CH","Ш":"SH","Щ":"SHCH","Ъ":"","Ы":"Y","Ь":"","Э":"E","Ю":"YU","Я":"YA","а":"a","б":"b","в":"v","г":"g","д":"d","е":"e","ё":"e","ж":"zh","з":"z","и":"i","й":"j","к":"k","л":"l","м":"m","н":"n","о":"o","п":"p","р":"r","с":"s","т":"t","у":"u","ф":"f","х":"kh","ц":"c","ч":"ch","ш":"sh","щ":"shch","ъ":"","ы":"y","ь":"","э":"e","ю":"yu","я":"ya"},gr={};!function(){function t(){for(var e in tr(this,t),this.approximations={},br)this.approximate(e,br[e])}er(t,null,[{key:"getInstance",value:function(e){return gr[e]=gr[e]||new t,gr[e]}}]),er(t,[{key:"approximate",value:function(t,e){this.approximations[t]=e}},{key:"transliterate",value:function(t,e){var r=this;return t.replace(/[^\u0000-\u007f]/g,(function(t){return r.approximations[t]||e||"?"}))}}])}(),function(t){t[t.debug=1]="debug",t[t.info=2]="info",t[t.warn=3]="warn",t[t.error=4]="error"}(vr||(vr={}));var _r={debug:1,info:2,warn:3,error:4},mr=new(function(){function t(t){void 0===t&&(t="warn"),this._level=vr.info,"number"==typeof t?this._level=t:this.level=t}return t.prototype.debug=function(t){this._level<=vr.debug&&console.info(t)},t.prototype.info=function(t){this._level<=vr.info&&console.info(t)},t.prototype.warn=function(t){this._level<=vr.warn&&console.warn(t)},t.prototype.error=function(t){this._level<=vr.warn&&console.error(t)},Object.defineProperty(t.prototype,"level",{get:function(){var t;for(t in vr){if(vr.hasOwnProperty(t))if(vr[t]===this._level)return t}throw new Error("Invalid log level: "+this._level)},set:function(t){var e=vr[t];if(!e)throw new Error("Log level must be one of "+Object.keys(_r).join(", "));this._level=e},enumerable:!0,configurable:!0}),t}());function wr(t,e){return s(this,void 0,void 0,(function(){var r;return o(this,(function(n){switch(n.label){case 0:r=0,n.label=1;case 1:return r<t.length?[4,e(t[r],r,t)]:[3,4];case 2:n.sent(),n.label=3;case 3:return r+=1,[3,1];case 4:return[2]}}))}))}var jr=function(){function t(t,e){void 0===t&&(t=[]),void 0===e&&(e=[]),this._beforeFilters=[],this._afterFilters=[],this._beforeFilters=t,this._afterFilters=e}return Object.defineProperty(t.prototype,"beforeFilters",{get:function(){return this._beforeFilters},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"afterFilters",{get:function(){return this._afterFilters},enumerable:!0,configurable:!0}),t.prototype.beforeFetch=function(t,e){return s(this,void 0,void 0,(function(){var r=this;return o(this,(function(n){switch(n.label){case 0:return[4,wr(this._beforeFilters,(function(n){return s(r,void 0,void 0,(function(){return o(this,(function(r){switch(r.label){case 0:return[4,n(t,e)];case 1:return r.sent(),[2]}}))}))}))];case 1:return n.sent(),[2]}}))}))},t.prototype.afterFetch=function(t,e){return s(this,void 0,void 0,(function(){var r=this;return o(this,(function(n){switch(n.label){case 0:return[4,wr(this._afterFilters,(function(n){return s(r,void 0,void 0,(function(){return o(this,(function(r){switch(r.label){case 0:return[4,n(t,e)];case 1:return r.sent(),[2]}}))}))}))];case 1:return n.sent(),[2]}}))}))},t}(),kr=function(t,e){Object.defineProperty(t,e,{get:function(){},set:function(t){Object.defineProperty(this,e,{value:t,writable:!0,configurable:!0,enumerable:!1})},configurable:!0,enumerable:!1})},Or=function(t,e){var r;for(r in(e=n({},e)).credentialStorageBackend&&(t.credentialStorageBackend=e.credentialStorageBackend,delete e.jwtStorage),e.jwtStorage&&(t.jwtStorage=e.jwtStorage,delete e.jwtStorage),e.jwt&&(t.setJWT(e.jwt),delete e.jwt),e)e.hasOwnProperty(r)&&(t[r]=e[r]);void 0===t.isBaseClass?t.setAsBase():!0===t.isBaseClass&&(t.isBaseClass=!1)},Pr=function(){function t(t){this.stale=!1,this.storeKey="",this.relationships={},this._persisted=!1,this._markedForDestruction=!1,this._markedForDisassociation=!1,this._originalRelationships={},this._metaDirty=!1,this._errors={},this._initializeAttributes(),this._initializeLinks(),this.assignAttributes(t),this._originalAttributes=Ue(this._attributes),this._originalLinks=Ue(this._links),this._originalLinkRelations=Ue(this._linkRelations),this._originalRelationships=this.relationshipResourceIdentifiers(Object.keys(this.relationships))}return Object.defineProperty(t,"credentialStorage",{get:function(){return this._credentialStorage},enumerable:!0,configurable:!0}),Object.defineProperty(t,"jwtStorage",{get:function(){return this._jwtStorage},set:function(t){t!==this._jwtStorage&&(this._jwtStorage=t,this.credentialStorageBackend=this._credentialStorageBackend)},enumerable:!0,configurable:!0}),Object.defineProperty(t,"credentialStorageBackend",{get:function(){return this._credentialStorageBackend},set:function(t){this._credentialStorageBackend=t,this._credentialStorage=new w(this.jwtStorage||"jwt",this._credentialStorageBackend)},enumerable:!0,configurable:!0}),t.initializeCredentialStorage=function(){this.jwtStorage&&"undefined"!=typeof localStorage?this.credentialStorageBackend=localStorage:this.credentialStorageBackend=new m},t.fromJsonapi=function(t,e){return function(t,e,r){return new Je(t,r).deserialize(e)}(this.typeRegistry,t,e)},t.inherited=function(t){t.parentClass=this,t.currentClass=t,t.prototype.klass=t,t.attributeList=Ue(t.attributeList),t.linkList=Ue(t.linkList)},t.setAsBase=function(){this.isBaseClass=!0,this.jsonapiType=void 0,this.typeRegistry||(this.typeRegistry=new Ye(this)),this.middlewareStack||(this._middlewareStack=new jr),this._IDMap||(this._IDMap=new Be)},t.isSubclassOf=function(t){for(var e=this.currentClass;e;){if(e===t)return!0;e=e.parentClass}return!1},Object.defineProperty(t,"baseClass",{get:function(){for(var t=this.currentClass;t;){if(t.isBaseClass)return t;t=t.parentClass}},enumerable:!0,configurable:!0}),Object.defineProperty(t,"store",{get:function(){if(void 0===this.baseClass)throw new Error("No base class for "+this.name);return this.baseClass._IDMap},enumerable:!0,configurable:!0}),Object.defineProperty(t,"typeRegistry",{get:function(){if(void 0===this.baseClass)throw new Error("No base class for "+this.name);return this.baseClass._typeRegistry},set:function(t){if(!this.isBaseClass)throw new Error("Cannot set a registry on a non-base class");this._typeRegistry=t},enumerable:!0,configurable:!0}),t.registerType=function(){if(this.jsonapiType){var t=this.typeRegistry.get(this.jsonapiType);t&&this.isSubclassOf(t)||this.typeRegistry.register(this.jsonapiType,this)}},t.extend=function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(this);this.inherited(e);var n={};if(t.attrs)for(var i in t.attrs)if(t.attrs.hasOwnProperty(i)){var s=t.attrs[i];s.name||(s.name=i),s.owner=e,n[i]=s}if(e.attributeList=Object.assign({},e.attributeList,n),e.linkList=Object.assign({},e.linkList),Or(e,t.static||{}),e.registerType(),t.methods)for(var o in t.methods)t.methods.hasOwnProperty(o)&&(e.prototype[o]=t.methods[o]);return e},t.prototype._initializeAttributes=function(){this._attributes={},this._copyPrototypeDescriptors()},t.prototype._initializeLinks=function(){this._links={},this._linkRelations={}},t.prototype._copyPrototypeDescriptors=function(){var e=this,r=this.klass.attributeList;for(var n in r)if(r.hasOwnProperty(n)){var i=r[n];Object.defineProperty(this,n,i.descriptor())}["errors","isPersisted","isMarkedForDestruction","isMarkedForDisassociation"].forEach((function(r){var n=Object.getOwnPropertyDescriptor(t.prototype,r);n&&Object.defineProperty(e,r,n)}))},t.prototype.isType=function(t){return this.klass.jsonapiType===t},Object.defineProperty(t.prototype,"isPersisted",{get:function(){return this._persisted},set:function(t){this._persisted=t,t&&this.reset()},enumerable:!0,configurable:!0}),t.prototype.onSyncRelationships=function(){var t=this;return this._onSyncRelationships||(this._onSyncRelationships=function(e,r){t.relationships=r}),this._onSyncRelationships},t.prototype.onStoreChange=function(){var t=this;return this._onStoreChange||(this._onStoreChange=function(e,r){var n={};Object.keys(r).forEach((function(e){var i=t,s=t.changes();t.klass.attributeList[e].dirtyChecker(i[e],r[e])&&!s[e]&&(n[e]=[i[e],r[e]],i[e]=r[e],i._originalAttributes[e]=r[e])})),Object.keys(n).length>0&&void 0!==t.afterSync&&t.afterSync(n)}),this._onStoreChange},t.prototype.unlisten=function(){var t=this;this.klass.sync&&(this.storeKey&&(Ne.removeEventListener(this.storeKey,this.onStoreChange()),Ne.removeEventListener(this.storeKey+"-sync-relationships",this.onSyncRelationships())),Object.keys(this.relationships).forEach((function(e){var r=t.relationships[e];r&&(Array.isArray(r)?r.forEach((function(t){return t.unlisten()})):r.unlisten())})))},t.prototype.listen=function(){this.klass.sync&&(this._onStoreChange||(Ne.addEventListener(this.storeKey,this.onStoreChange()),Ne.addEventListener(this.storeKey+"-sync-relationships",this.onSyncRelationships())))},t.prototype.syncRelationships=function(){Ne.dispatch(this.storeKey+"-sync-relationships",{},this.relationships)},t.prototype.reset=function(){this.klass.sync&&(this.klass.store.updateOrCreate(this),this.listen()),this._originalAttributes=Ue(this._attributes),this._originalRelationships=this.relationshipResourceIdentifiers(Object.keys(this.relationships))},t.prototype.rollback=function(){this._attributes=Ue(this._originalAttributes)},Object.defineProperty(t.prototype,"isMarkedForDestruction",{get:function(){return this._markedForDestruction},set:function(t){this._markedForDestruction=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isMarkedForDisassociation",{get:function(){return this._markedForDisassociation},set:function(t){this._markedForDisassociation=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"attributes",{get:function(){return this._attributes},set:function(t){this._attributes={},this.assignAttributes(t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stored",{get:function(){return this.klass.store.find(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"typedAttributes",{get:function(){return this._attributes},enumerable:!0,configurable:!0}),t.prototype.relationship=function(t){return this.relationships[t]},t.prototype.assignAttributes=function(t){if(t)for(var e in t)if(t.hasOwnProperty(e)){var r;if(r=this.klass.deserializeKey(e),"id"===e||this.klass.attributeList[r])this[r]=t[e];else if(this.klass.strictAttributes)throw new Error("Unknown attribute: "+e)}},t.prototype.setMeta=function(t,e){void 0===e&&(e=!0),this.__meta__=t,e&&(this._metaDirty=!0)},Object.defineProperty(t.prototype,"meta",{get:function(){return this.__meta__||{}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isMetaDirty",{get:function(){return this._metaDirty},enumerable:!0,configurable:!0}),t.prototype.relationshipResourceIdentifiers=function(t){return function(t,e){var r={};return e.forEach((function(e){var n=t.relationship(e);n&&(Array.isArray(n)||(n=[n]),n.forEach((function(t){t.isPersisted&&(r[e]||(r[e]=[]),r[e].push(t.resourceIdentifier))})))})),r}(this,t)},t.prototype.fromJsonapi=function(t,e,r){return void 0===r&&(r={}),function(t,e,r,n){return void 0===n&&(n={}),new Je(t.klass.typeRegistry,r).deserializeInstance(t,e,n)}(this,t,e,r)},Object.defineProperty(t.prototype,"resourceIdentifier",{get:function(){if(void 0===this.klass.jsonapiType)throw new Error("Cannot build resource identifier for class. No JSONAPI Type specified.");return{id:this.id,type:this.klass.jsonapiType}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"errors",{get:function(){return this._errors},set:function(t){this._errors=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasError",{get:function(){return!!Object.keys(this._errors).length},enumerable:!0,configurable:!0}),t.prototype.clearErrors=function(){this.errors={}},t.prototype.isDirty=function(t){return new We(this).check(t)},t.prototype.changes=function(){return new We(this).dirtyAttributes()},t.prototype.hasDirtyRelation=function(t,e){var r=new We(this);return!this.isPersisted||r.checkRelation(t,e)},t.prototype.dup=function(){var t=Object.assign({},this.attributes,this.relationships),e=new this.klass(t);return e.id=this.id,e.isPersisted=this.isPersisted,e.isMarkedForDestruction=this.isMarkedForDestruction,e.isMarkedForDisassociation=this.isMarkedForDisassociation,e.errors=Object.assign({},this.errors),e.links=Object.assign({},this.links),e},t.fetchOptions=function(){var t,e={credentials:"same-origin",headers:(t={Accept:"application/vnd.api+json"},t["Content-Type"]="application/vnd.api+json",t)};this.credentials&&(e.credentials=this.credentials),this.clientApplication&&(e.headers["Client-Application"]=this.clientApplication);var r=this.getJWT();return r&&(e.headers.Authorization=this.generateAuthHeader(r)),e},t.url=function(t,e){var r=this.endpoint||""+this.jsonapiType,n=[this.fullBasePath(),r];return t&&n.push(t),e&&n.push(e),n.join("/")+(this.appendSlash?"/":"")},t.fullBasePath=function(){return""+this.baseUrl+this.apiNamespace},Object.defineProperty(t,"middlewareStack",{get:function(){if(this.baseClass){var t=this.baseClass._middlewareStack;if(this.beforeFetch||this.afterFetch){var e=this.beforeFetch?[this.beforeFetch]:t.beforeFilters,r=this.afterFetch?[this.afterFetch]:t.afterFilters;return new jr(e,r)}return t}return new jr},set:function(t){this._middlewareStack=t},enumerable:!0,configurable:!0}),t.scope=function(){return new Ve(this)},t.first=function(){return this.scope().first()},t.all=function(){return this.scope().all()},t.find=function(t){return this.scope().find(t)},t.get=function(){return this.scope().get()},t.where=function(t){return this.scope().where(t)},t.page=function(t){return this.scope().page(t)},t.per=function(t){return this.scope().per(t)},t.fromUrl=function(t){return this.scope().fromUrl(t)},t.extraParams=function(t){return this.scope().extraParams(t)},t.extraFetchOptions=function(t){return this.scope().extraFetchOptions(t)},t.order=function(t){return this.scope().order(t)},t.select=function(t){return this.scope().select(t)},t.selectExtra=function(t){return this.scope().selectExtra(t)},t.stats=function(t){return this.scope().stats(t)},t.includes=function(t){return this.scope().includes(t)},t.merge=function(t){return this.scope().merge(t)},t.setJWT=function(t){this.credentialStorage.setJWT(t)},t.getJWT=function(){return this.credentialStorage.getJWT()},Object.defineProperty(t,"jwt",{get:function(){return this.getJWT()},set:function(t){this.setJWT(t)},enumerable:!0,configurable:!0}),t.generateAuthHeader=function(t){return'Token token="'+t+'"'},t.getJWTOwner=function(){return this.logger.warn("SpraypaintBase#getJWTOwner() is deprecated. Use #baseClass property instead"),this.baseClass},t.serializeKey=function(t){switch(this.keyCase.server){case"dash":return yr(dr(t));case"snake":return dr(t);case"camel":return fr(dr(t),!1)}},t.deserializeKey=function(t){switch(this.keyCase.client){case"dash":return yr(dr(t));case"snake":return dr(t);case"camel":return fr(dr(t),!1)}},t.prototype.destroy=function(){return s(this,void 0,void 0,(function(){var t,e,r,n=this;return o(this,(function(i){switch(i.label){case 0:t=this.klass.url(this.id),e=new f(this._middleware(),this.klass.logger),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,e.delete(t,this._fetchOptions())];case 2:return r=i.sent(),[3,4];case 3:throw i.sent();case 4:return 202!==r.status?[3,6]:[4,this._handleAcceptedResponse(r,this.onDeferredDestroy)];case 5:return[2,i.sent()];case 6:return this.klass.baseClass.store.destroy(this),[4,this._handleResponse(r,(function(){n.isPersisted=!1}))];case 7:return[2,i.sent()]}}))}))},t.createBatch=function(t,e){return void 0===e&&(e={}),s(this,void 0,void 0,(function(){var r,n,i,s,a,u,c,l;return o(this,(function(o){switch(o.label){case 0:if(r=t[0],n=r.klass.url(void 0,"batch"),i="post",s=new f(r._middleware(),r.klass.logger,{patchAsPost:r.klass.patchAsPost}),a=[],t.forEach((function(t){a.push(new _(t,e.with))})),e.returnScope){if((c=e.returnScope).model!==r.klass)throw new Error("returnScope must be a scope of type Scope<"+r.klass.name+">");n=n+"?"+c.toQueryParams()}t.forEach((function(t){t.clearErrors()})),l={data:[],included:[]},a.forEach((function(t){var e=t.asJSON();e.data&&l.data.push(e.data),e.included&&(l.included||(l.included=[]),l.included.push(e.included))})),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,s[i](n,l,r._fetchOptions())];case 2:return u=o.sent(),[3,4];case 3:throw o.sent();case 4:return 202!==u.status&&204!==u.status?[3,6]:[4,this._handleAcceptedResponse(u,void 0)];case 5:return[2,o.sent()];case 6:return[4,this._handleResponse(u,(function(){r.fromJsonapi(u.jsonPayload.data,u.jsonPayload)}))];case 7:return[2,o.sent()]}}))}))},t._handleAcceptedResponse=function(t,e){return s(this,void 0,void 0,(function(){var r;return o(this,(function(n){switch(n.label){case 0:return t.jsonPayload&&e&&(r=this.fromJsonapi(t.jsonPayload.data,t.jsonPayload),e(r)),[4,this._handleResponse(t,(function(){}))];case 1:return[2,n.sent()]}}))}))},t._handleResponse=function(t,e){return s(this,void 0,void 0,(function(){return o(this,(function(r){return c(this,t),422===t.status?[2,!1]:(e(),[2,!0])}))}))},t.prototype.save=function(t){return void 0===t&&(t={}),s(this,void 0,void 0,(function(){var e,r,n,i,s,a,u,c=this;return o(this,(function(o){switch(o.label){case 0:if(e=this.klass.url(),r="post",n=new f(this._middleware(),this.klass.logger,{patchAsPost:this.klass.patchAsPost}),i=new _(this,t.with),this.isPersisted&&(e=this.klass.url(this.id),r="patch"),t.returnScope){if((a=t.returnScope).model!==this.klass)throw new Error("returnScope must be a scope of type Scope<"+this.klass.name+">");e=e+"?"+a.toQueryParams()}this.clearErrors(),u=i.asJSON(),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,n[r](e,u,this._fetchOptions())];case 2:return s=o.sent(),[3,4];case 3:throw o.sent();case 4:return 202!==s.status&&204!==s.status?[3,6]:[4,this._handleAcceptedResponse(s,this.onDeferredUpdate)];case 5:return[2,o.sent()];case 6:return[4,this._handleResponse(s,(function(){c.fromJsonapi(s.jsonPayload.data,s.jsonPayload,i.includeDirective),i.postProcess()}))];case 7:return[2,o.sent()]}}))}))},t.prototype._handleAcceptedResponse=function(t,e){return s(this,void 0,void 0,(function(){var r;return o(this,(function(n){switch(n.label){case 0:return t.jsonPayload&&e&&(r=this.klass.fromJsonapi(t.jsonPayload.data,t.jsonPayload),e(r)),[4,this._handleResponse(t,(function(){}))];case 1:return[2,n.sent()]}}))}))},t.prototype._handleResponse=function(t,e){return s(this,void 0,void 0,(function(){return o(this,(function(r){if(c(this.klass,t),422===t.status){try{u.apply(this,t.jsonPayload)}catch(e){throw new y(t,"validation failed",e)}return[2,!1]}return e(),[2,!0]}))}))},t.prototype._fetchOptions=function(){return this.klass.fetchOptions()},t.prototype._middleware=function(){return this.klass.middlewareStack},t.prototype.resetRelationTracking=function(t){this._originalRelationships=this.relationshipResourceIdentifiers(Object.keys(t))},Object.defineProperty(t.prototype,"linkRelations",{get:function(){return this._linkRelations},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"links",{get:function(){return this._links},set:function(t){this._links={},this.assignLinks(t)},enumerable:!0,configurable:!0}),t.prototype.assignLinks=function(t){if(t)for(var e in t){var r=this.klass.deserializeKey(e);this.klass.linkList.hasOwnProperty(r)&&(this._links[r]=t[e],this.klass.linkList[e]&&(this._linkRelations[r]=this.klass.linkList[e].fromUrl(t[e])))}},t.baseUrl="http://please-set-a-base-url.com",t.apiNamespace="/",t.keyCase={server:"snake",client:"camel"},t.strictAttributes=!1,t.logger=mr,t.sync=!1,t.clientApplication=null,t.patchAsPost=!1,t.appendSlash=!1,t.attributeList={},t.linkList={},t.currentClass=t,t._jwtStorage="jwt",t.isSpraypaintModel=!0,i([kr],t.prototype,"afterSync",void 0),i([kr],t.prototype,"relationships",void 0),i([kr],t.prototype,"klass",void 0),i([kr],t.prototype,"_persisted",void 0),i([kr],t.prototype,"_markedForDestruction",void 0),i([kr],t.prototype,"_markedForDisassociation",void 0),i([kr],t.prototype,"_originalRelationships",void 0),i([kr],t.prototype,"_attributes",void 0),i([kr],t.prototype,"_originalAttributes",void 0),i([kr],t.prototype,"_links",void 0),i([kr],t.prototype,"_originalLinks",void 0),i([kr],t.prototype,"_linkRelations",void 0),i([kr],t.prototype,"_originalLinkRelations",void 0),i([kr],t.prototype,"__meta__",void 0),i([kr],t.prototype,"_metaDirty",void 0),i([kr],t.prototype,"_errors",void 0),t}();Pr.prototype.klass=Pr,Pr.initializeCredentialStorage();var Ar=function(t){return!!t&&(t.currentClass&&t.currentClass.isSpraypaintModel)},Cr=function(t,e){return t!==e},Sr=function(){function t(t){this.isRelationship=!1,this.type=void 0,this.persist=!0,this.dirtyChecker=Cr,this.metadata=void 0,t&&(t.name&&(this.name=t.name),t.type&&(this.type=t.type),void 0!==t.persist&&(this.persist=!!t.persist),t.dirtyChecker&&(this.dirtyChecker=t.dirtyChecker),t.metadata&&(this.metadata=t.metadata))}return t.prototype.apply=function(t){Object.defineProperty(t.prototype,this.name,this.descriptor())},t.prototype.setter=function(t,e){t._attributes[this.name]=e},t.prototype.getter=function(t){return t.attributes[this.name]},t.prototype.descriptor=function(){var t=this;return{configurable:!0,enumerable:!0,get:function(){return t.getter(this)},set:function(e){t.setter(this,e)}}},t}(),Rr=function(t){return!!t.klass.sync&&((t.isPersisted||t.stale)&&!t.stored)},Er=function(t){function e(e){var r=t.call(this,e)||this;return r.isRelationship=!0,e.jsonapiType&&(r.jsonapiType=e.jsonapiType),r.type&&(r._klass=r.type),r}return r(e,t),Object.defineProperty(e.prototype,"klass",{get:function(){return this._klass||(this._klass=Dr(this,this.jsonapiType)),this._klass},enumerable:!0,configurable:!0}),e.prototype.getter=function(t){var e=t.relationships[this.name];return e&&Rr(e)&&delete t.relationships[this.name],t.relationships[this.name]},e.prototype.setter=function(t,e){e&&!e.hasOwnProperty("isRelationship")?(e instanceof Pr||Array.isArray(e)||e._overriddenUrl||(e=new this.klass(e)),t.relationships[this.name]=e):null==e&&(t.relationships[this.name]=e)},e}(Sr),$r=function(t){function e(e){var r=t.call(this,e)||this;return r.isRelationship=!0,e.jsonapiType&&(r.jsonapiType=e.jsonapiType),r.type&&(r._klass=r.type),r}return r(e,t),Object.defineProperty(e.prototype,"klass",{get:function(){return this._klass||(this._klass=Dr(this,this.jsonapiType)),this._klass},enumerable:!0,configurable:!0}),e.prototype.getter=function(t){var e=t.relationships[this.name];if(!e)return this.setter(t,[]),t.relationships[this.name];for(var r=e.length;r--;)Rr(e[r])&&(t.relationships[this.name],e.splice(r,1));return t.relationships[this.name]},e.prototype.setter=function(t,e){e&&!e.hasOwnProperty("isRelationship")?(e instanceof Pr||Array.isArray(e)||e._overriddenUrl||(e=new this.klass(e)),t.relationships[this.name]=e):null==e&&(t.relationships[this.name]=e)},e}(Sr),xr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(Er),Fr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(Er),Tr=function(t){var e={};return void 0!==t&&("string"==typeof t?e={jsonapiType:t}:(e={persist:t.persist,name:t.name},"string"==typeof t.type?e.jsonapiType=t.type:e.type=t.type)),e},Dr=function(t,e){var r=t.owner.typeRegistry.get(e);if(r)return r;throw new Error('Unknown type "'+e+'"')},Lr="undefined"!=typeof window,zr=!("production"===process.env.NODE_ENV);var Ir=function(t){return t&&void 0!==t.kind},Mr=function(t,e){Ur(t),Or(t,e||{}),t.jsonapiType||t.isBaseClass||(t.jsonapiType=pr(dr(t.name)),zr&&Lr&&mr.warn('Inferring model jsonapiType as "'+t.jsonapiType+'".\nYou should explicitly set this on your model if targeting a minified code bundle.')),t.registerType()},Ur=function(t){t.currentClass&&t.currentClass!==t&&t.currentClass.inherited(t)},Nr=function(t){return function(e,r,n){var i,s=function(e,r){if(void 0===n){var s=pr(dr(r));i={jsonapiType:s}}else"string"==typeof n?i={jsonapiType:n}:Ar(n)?i={type:n}:(i={persist:n.persist,name:n.name},"string"==typeof n.type?i.jsonapiType=n.type:i.type=n.type);var o=new t(i);o.name||(o.name=r);var a=function(t){return Ur(t),t}(e.constructor);return a.attributeList[r]=o,o.owner=e.constructor,o.apply(a),o.descriptor()};if(Ir(e))return Object.assign(e,{finisher:function(t){s(t.prototype,e.key)}});if(!Ar(e)||!r){return function(t,r){return Ir(t)?Object.assign(t,{finisher:function(e){s(e.prototype,t.key)}}):(n=e,s(t,r))}}s(e.prototype,r)}},Br=Nr($r),Jr=Nr(xr),Kr=Nr(Fr);t.Attr=function(t,e,r){var n=new Sr({name:e}),i=function(t,e){return Ur(t),n.name||(n.name=e),t.attributeList[e]=n,n.apply(t),n.descriptor()};if(Ir(t))return Object.assign(t,{finisher:function(e){i(e,t.key)}});if(!(Ar(t)||(s=t,s&&Ar(s.constructor.currentClass))))return t&&(n=new Sr(t)),function(t,e){return i(t.constructor,e)};if(!e)throw new Error("Must provide a propertyKey");var s,o=t;if(!Ar(o))return i(o.constructor,e);r&&(n=new Sr(r)),i(o,e)},t.Attribute=Sr,t.BelongsTo=Kr,t.HasMany=Br,t.HasOne=Jr,t.Link=function(t,e,r){var n=function(e,r){var n=function(t){return Ur(t),t}(e.constructor);Ar(t)?n.linkList[r]=t:n.linkList[r]=null};if(Ir(t))return Object.assign(t,{finisher:function(e){n(e.prototype,t.key)}});if(!Ar(t)||!e){return function(t,e){return Ir(t)?Object.assign(t,{finisher:function(e){n(e.prototype,t.key)}}):n(t,e)}}n(t.prototype,e)},t.MiddlewareStack=jr,t.Model=function(t){return e=function(e){return Mr(e,t),e},function(t){return Ir(t)?Object.assign(t,{finisher:e}):e(t)};var e},t.Request=f,t.Scope=Ve,t.SpraypaintBase=Pr,t.attr=function(t){return t||(t={}),new Sr(t)},t.belongsTo=function(t){var e=Tr(t);return new Fr(e)},t.hasMany=function(t){var e=Tr(t);return new $r(e)},t.hasOne=function(t){var e=Tr(t);return new xr(e)},Object.defineProperty(t,"__esModule",{value:!0})}));
  